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 4B3E6C433F5 for ; Fri, 22 Apr 2022 13:43:57 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D8CBC83D5E; Fri, 22 Apr 2022 15:43:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=foss.st.com header.i=@foss.st.com header.b="584C0/z4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E8C0783D57; Fri, 22 Apr 2022 15:43:53 +0200 (CEST) Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8FBC083D62 for ; Fri, 22 Apr 2022 15:43:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=prvs=011196f9c1=patrice.chotard@foss.st.com Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 23M9Xk9X025876; Fri, 22 Apr 2022 15:43:48 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=selector1; bh=GxyUl2TQnaxcfF2T0xy1TB3oPudtKWx9gocXPj2BWqQ=; b=584C0/z4+yxqhsUqF/nvYjkjW3D53ItpvdA7nFeDEJR+0JxupPjxNjNbKiT7LmMKZBEB OzmmxVUry17ieJ3EI3sngBTkgBZCQW/M085xhRz7yMLP6gIf4NfJReku/Ai1onSg3azC l5U0n7c6DQhYs9fSXAqF64hgLVEotIdpYgFXyKc+K3B2Qhy01o/fwSfr/R/YbyEY25iH PXWznRe+9I5ocmWLUpmF0bDRJEUjHVvee21M1PGBHlT75/evobMpa1cpuuKjXw45E5ff 6m7rE8qW1SNyUthjRMfweGnWAsaHMleaHbIICx2mzcWS26rZ35GlfnTdRm4OZGr+3nhl ng== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3ffpqe9f3w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 22 Apr 2022 15:43:48 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C7CAA10002A; Fri, 22 Apr 2022 15:43:47 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id C15EB22ECF7; Fri, 22 Apr 2022 15:43:47 +0200 (CEST) Received: from [10.201.21.201] (10.75.127.46) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.20; Fri, 22 Apr 2022 15:43:47 +0200 Message-ID: <3fde7af1-cd2a-aee6-4c6e-e23cedc77baa@foss.st.com> Date: Fri, 22 Apr 2022 15:43:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH 1/3] dm: core: Add DM_FLAG_PROBE_AFTER_BIND flag Content-Language: en-US To: Marek Vasut , CC: Patrick Delaunay , Sean Anderson , Simon Glass , Steven Lawrance References: <20220422131555.123598-1-marex@denx.de> From: Patrice CHOTARD In-Reply-To: <20220422131555.123598-1-marex@denx.de> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-22_04,2022-04-22_01,2022-02-23_01 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.5 at phobos.denx.de X-Virus-Status: Clean Hi Marek On 4/22/22 15:15, Marek Vasut wrote: > Introduce DM_FLAG_PROBE_AFTER_BIND flag, which can be set by driver or > uclass in .bind(), to indicate such driver instance should be probe()d > once binding of all devices is complete. > > This is useful in case the driver determines that hardware initialization > is mandatory on boot, and such initialization happens only in probe(). > This also solves the inability to call device_probe() from .bind(). > > Signed-off-by: Marek Vasut > Cc: Patrice Chotard > Cc: Patrick Delaunay > Cc: Sean Anderson > Cc: Simon Glass > Cc: Steven Lawrance > --- > drivers/core/root.c | 24 +++++++++++++++++++++++- > include/dm/device.h | 3 +++ > 2 files changed, 26 insertions(+), 1 deletion(-) > > diff --git a/drivers/core/root.c b/drivers/core/root.c > index e09c12f4d6e..17dd1205a32 100644 > --- a/drivers/core/root.c > +++ b/drivers/core/root.c > @@ -361,6 +361,28 @@ void *dm_priv_to_rw(void *priv) > } > #endif > > +static int dm_probe_devices(struct udevice *dev, bool pre_reloc_only) > +{ > + u32 mask = DM_FLAG_PROBE_AFTER_BIND; > + u32 flags = dev_get_flags(dev); > + struct udevice *child; > + int ret; > + > + if (pre_reloc_only) > + mask |= DM_FLAG_PRE_RELOC; > + > + if ((flags & mask) == mask) { > + ret = device_probe(dev); > + if (ret) > + return ret; > + } > + > + list_for_each_entry(child, &dev->child_head, sibling_node) > + dm_probe_devices(child, pre_reloc_only); > + > + return 0; > +} > + > /** > * dm_scan() - Scan tables to bind devices > * > @@ -393,7 +415,7 @@ static int dm_scan(bool pre_reloc_only) > if (ret) > return ret; > > - return 0; > + return dm_probe_devices(gd->dm_root, pre_reloc_only); > } > > int dm_init_and_scan(bool pre_reloc_only) > diff --git a/include/dm/device.h b/include/dm/device.h > index e0f86f5df9f..e7dd90399f9 100644 > --- a/include/dm/device.h > +++ b/include/dm/device.h > @@ -80,6 +80,9 @@ struct driver_info; > */ > #define DM_FLAG_VITAL (1 << 14) > > +/* Device must be probed after it was bound */ > +#define DM_FLAG_PROBE_AFTER_BIND (1 << 15) > + > /* > * One or multiple of these flags are passed to device_remove() so that > * a selective device removal as specified by the remove-stage and the Reviewed-by: Patrice Chotard Tested-by: Patrice Chotard Tested on stm32mp157c-dk2 board Thanks Patrice