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 76620C19F21 for ; Thu, 4 Aug 2022 19:42:46 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4098F8483E; Thu, 4 Aug 2022 21:42:44 +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="XzjahQZi"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="5d1A1UYA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4DA9A8483E; Thu, 4 Aug 2022 21:42:42 +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 E56E884846 for ; Thu, 4 Aug 2022 21:42:39 +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 AF0FA34D41; Thu, 4 Aug 2022 19:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1659642159; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=X/d9HCf6F7SdoHIHBhGOpaZAJpAzNHbHsGU5tLYPWRs=; b=XzjahQZiB8GSE+j1aIXo7TJMOWjEHZiydcNux9kHqnDu6QyOEqQHBZRViLJtMvEJq/4I7O 6HAdpt02s8vpvJXh8yu+1KRivcaAYdFyGOSKUcOFbpnmRp/LI66x46JWgF1dvHyRuF4w5x iEpjGxtUoaUG5ehmL9FqM/BV9CwYOX0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1659642159; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=X/d9HCf6F7SdoHIHBhGOpaZAJpAzNHbHsGU5tLYPWRs=; b=5d1A1UYAySEHChAh0kcN7z8y1vN3Xp2VbErA2T0KN5owOFc29BKASEPvkrbZ1Vs70iL0Kl JkCIXrcATngjwDCw== 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 951C02C141; Thu, 4 Aug 2022 19:42:39 +0000 (UTC) Date: Thu, 4 Aug 2022 21:42:38 +0200 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Simon Glass Cc: U-Boot Mailing List , Marek Vasut , AKASHI Takahiro Subject: Re: [PATCH] doc: dm: clarify activation. Message-ID: <20220804194238.GG17705@kitsune.suse.cz> References: <20220804175746.3746-1-msuchanek@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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 > > or the device code (e.g. device_get_child()) Can you elaborate a bit more, please? 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. > > BTW probing a child probes all its parents automatically (that is said > elsewhere I think). Yes, right below this part. Thanks Michal > > > +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