From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754903AbbFRJ6k (ORCPT ); Thu, 18 Jun 2015 05:58:40 -0400 Received: from pandora.arm.linux.org.uk ([78.32.30.218]:39686 "EHLO pandora.arm.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754139AbbFRJ6T (ORCPT ); Thu, 18 Jun 2015 05:58:19 -0400 Date: Thu, 18 Jun 2015 10:57:54 +0100 From: Russell King - ARM Linux To: Andrzej Hajda Cc: Tomeu Vizoso , linux-arm-kernel@lists.infradead.org, Alexander Holler , Alexandre Courbot , Arnd Bergmann , Dmitry Torokhov , Grant Likely , Greg Kroah-Hartman , Ian Campbell , Javier Martinez Canillas , Krzysztof Kozlowski , Kumar Gala , Len Brown , Linus Walleij , linux-kernel@vger.kernel.org, Lv Zheng , Mark Brown , Mark Rutland , Pawel Moll , "Rafael J. Wysocki" , Robert Moore , Rob Herring , Stephen Warren , Terje =?iso-8859-1?Q?Bergstr=F6m?= , Thierry Reding Subject: Re: [PATCH 00/13] Discover and probe dependencies Message-ID: <20150618095754.GI7557@n2100.arm.linux.org.uk> References: <1434548543-22949-1-git-send-email-tomeu.vizoso@collabora.com> <55829269.2090309@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55829269.2090309@samsung.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 18, 2015 at 11:42:01AM +0200, Andrzej Hajda wrote: > 2. Provider create/register their resources only during probe. > It is not always the case - for example componentized drivers in > probe often > calls only component_add, the real initialization is performed in > bind callback. bind is called in _a_ probe callback, but it may not be the probe callback associated with the device. (It'll be the final component's callback.) I'm willing to be less critical of componentised drivers claiming their resources in ->probe _iff_ they separate their data structures, like: struct foo_priv { void *base; struct clk *clk; struct dma_chan *chan; ... other resource data ...; struct foo_runtime { ... runtime data ... } rt; }; and then, in their bind callback, they memset the foo_runtime structure to zero, to ensure that the driver always re-binds in the same state as the first bind. I've seen too many lax drivers over the years that this is a point I'm very insistant on: either componentised drivers don't do any resource claiming in their probe function, or they take steps to ensure non- resource struct members are properly separated such that they can guarantee that they aren't going to accidentally use something from a previous binding. -- FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up according to speedtest.net. From mboxrd@z Thu Jan 1 00:00:00 1970 From: linux@arm.linux.org.uk (Russell King - ARM Linux) Date: Thu, 18 Jun 2015 10:57:54 +0100 Subject: [PATCH 00/13] Discover and probe dependencies In-Reply-To: <55829269.2090309@samsung.com> References: <1434548543-22949-1-git-send-email-tomeu.vizoso@collabora.com> <55829269.2090309@samsung.com> Message-ID: <20150618095754.GI7557@n2100.arm.linux.org.uk> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Thu, Jun 18, 2015 at 11:42:01AM +0200, Andrzej Hajda wrote: > 2. Provider create/register their resources only during probe. > It is not always the case - for example componentized drivers in > probe often > calls only component_add, the real initialization is performed in > bind callback. bind is called in _a_ probe callback, but it may not be the probe callback associated with the device. (It'll be the final component's callback.) I'm willing to be less critical of componentised drivers claiming their resources in ->probe _iff_ they separate their data structures, like: struct foo_priv { void *base; struct clk *clk; struct dma_chan *chan; ... other resource data ...; struct foo_runtime { ... runtime data ... } rt; }; and then, in their bind callback, they memset the foo_runtime structure to zero, to ensure that the driver always re-binds in the same state as the first bind. I've seen too many lax drivers over the years that this is a point I'm very insistant on: either componentised drivers don't do any resource claiming in their probe function, or they take steps to ensure non- resource struct members are properly separated such that they can guarantee that they aren't going to accidentally use something from a previous binding. -- FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up according to speedtest.net.