Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E3E3CC25B08 for ; Sat, 20 Aug 2022 06:40:20 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B638D845D8; Sat, 20 Aug 2022 08:40:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="PVC76T66"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="bW8j3tbn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 03AE4845D8; Sat, 20 Aug 2022 08:40:18 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 18AD5845C8 for ; Sat, 20 Aug 2022 08:40:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=msuchanek@suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id CCBD933850; Sat, 20 Aug 2022 06:40:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1660977614; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jzG2i1JitscpLjLGTV7nVHRGXJPde3fvVT3FrZymjPs=; b=PVC76T66TlgombhOh3VtYDc1KvvB7KdauCZUb+ZlUsxS27JvcKmxiRbIUTps2GlMEaslW6 +CStp2ewaw5mIUT2/Wg7LVlcU3BPqMBeeTczJyzGdZSMEiauiKRNlR7YuVX7g4mPXoJIgU 2PtzyiMobGFo8C5nDPeXILgxZ9za4SM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1660977614; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jzG2i1JitscpLjLGTV7nVHRGXJPde3fvVT3FrZymjPs=; b=bW8j3tbn4dRvBDMt89HREzdJw+qn1Frlk40+QHCEUtYuMzy2v29UIyv4HCaMDql0HQmlAK NnwZeP0LfOi4q8Bg== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id A164A2C141; Sat, 20 Aug 2022 06:40:14 +0000 (UTC) Date: Sat, 20 Aug 2022 08:40:13 +0200 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Heinrich Schuchardt Cc: Simon Glass , U-Boot Mailing List , Marek Vasut , AKASHI Takahiro Subject: Re: [PATCH] doc: dm: clarify activation. Message-ID: <20220820064013.GF28810@kitsune.suse.cz> References: <20220804175746.3746-1-msuchanek@suse.de> <20220804194238.GG17705@kitsune.suse.cz> <5046420f-da2a-a50f-87b9-7d4b541096a3@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5046420f-da2a-a50f-87b9-7d4b541096a3@gmx.de> User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Hello, On Sat, Aug 20, 2022 at 08:27:05AM +0200, Heinrich Schuchardt wrote: > On 8/4/22 22:30, Simon Glass wrote: > > Hi Michal, > > > > On Thu, 4 Aug 2022 at 13:42, Michal Suchánek wrote: > > > > > > On Thu, Aug 04, 2022 at 01:22:53PM -0600, Simon Glass wrote: > > > > Hi Michal, > > > > > > > > On Thu, 4 Aug 2022 at 11:58, Michal Suchanek wrote: > > > > > > > > > > Explain when devices should get activated. > > > > > > > > > > Signed-off-by: Michal Suchanek > > > > > --- > > > > > doc/develop/driver-model/design.rst | 22 ++++++++++++++++++++-- > > > > > 1 file changed, 20 insertions(+), 2 deletions(-) > > > > > > > > Reviewed-by: Simon Glass > > > > > > > > Much appreciated! > > > > > > > > one note below > > > > > > > > > > > > > > diff --git a/doc/develop/driver-model/design.rst b/doc/develop/driver-model/design.rst > > > > > index 5f33f9fbb3..c925d21b24 100644 > > > > > --- a/doc/develop/driver-model/design.rst > > > > > +++ b/doc/develop/driver-model/design.rst > > > > > @@ -794,8 +794,26 @@ fall afoul of this rule. > > > > > Activation/probe > > > > > ^^^^^^^^^^^^^^^^ > > > > > > > > > > -When a device needs to be used, U-Boot activates it, by first reading ofdata > > > > > -as above and then following these steps (see device_probe()): > > > > > +To save resources devices in U-Boot are probed lazily. U-Boot is a bootloader, > > > > > +not an operating system. Many devices are never used during an U-Boot run, and > > > > > +probing them takes time, requires memory, may add delays to the main loop, etc. > > > > > + > > > > > +The device should be probed by the uclass code. Different uclasses are > > When merging I will put the following here: > > The device should be probed by the uclass code or generic device code > (e.g. device_find_global_by_ofnode()). Uclasses differ but two common > use cases can be seen: I wanted to look at this direct device lookup, and send a v2 when I am done with it. I am currently trying to figure out how (if at all) the pins and clocks required by i2c devices are activated, and I suppose this direct lookup would be related. Noneteless, if you can fix up the patch right away that's great. Thanks Michal > > Best regards > > Heinrich > > > > > > > > > or the device code (e.g. device_get_child()) > > > > > > Can you elaborate a bit more, please? > > > > I mean that we can use 'device' code to probe, as well as the 'uclass' > > code. The function I cite is an example of that, but actually a better > > one is device_find_global_by_ofnode() > > > > > > > > This change is the reasult of some previous discussion about the device > > > activation with Marek. > > > > > > The device activation is really difficult to understand for people who > > > did not participate in designing the DM, and is probably quite specific > > > to U-Boot. > > > > OK, well good to have it. I wish more people would do what you have > > done here, i.e. go back and update the docs to clarify things that you > > found confusing / inadequate. > > > > > > > > > > > > > BTW probing a child probes all its parents automatically (that is said > > > > elsewhere I think). > > > > > > Yes, right below this part. > > > > > > Thanks > > > > > > Michal > > > > OK > > > > Regards, > > Simon > > > > > > > > > > > > > > > > +different but two common use cases can be seen: > > > > > + > > > > > + 1. The uclass is asked to look up a specific device, such as SPI bus 0, > > > > > + first chip select - in this case the returned device should be > > > > > + activated. > > > > > + > > > > > + 2. The uclass is asked to perform a specific function on any device that > > > > > + supports it, eg. reset the board using any sysreset that can be found - > > > > > + for this case the core uclass code provides iterators that activate > > > > > + each device before returning it, and the uclass typically implements a > > > > > + walk function that iterates over all devices of the uclass and tries > > > > > + to perform the requested function on each in turn until succesful. > > > > > + > > > > > +To activate a device U-Boot first reads ofdata as above and then follows these > > > > > +steps (see device_probe()): > > > > > > > > > > 1. All parent devices are probed. It is not possible to activate a device > > > > > unless its predecessors (all the way up to the root device) are activated. > > > > > -- > > > > > 2.37.1 > > > > > > > > > > > > > Regards, > > > > Simon >