From patchwork Fri Nov 1 11:50:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2005105 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Wisybpq4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Xfzhn4hlhz1xxJ for ; Fri, 1 Nov 2024 22:51:05 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5A558892E5; Fri, 1 Nov 2024 12:50:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="Wisybpq4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3B88A892E1; Fri, 1 Nov 2024 12:50:41 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E237A892A2 for ; Fri, 1 Nov 2024 12:50:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a99cc265e0aso296330666b.3 for ; Fri, 01 Nov 2024 04:50:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1730461838; x=1731066638; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7aR4uu+yBdWM/WK4DWlVdXDM7WElFkpQM2rMuqNYQ8s=; b=Wisybpq4KuC2xre6tpDatXp2Eh13sioLSbZuyxDP5c57Ni1Oic46qsHrejzrbnMsab qNZ8hRlLKMOIaqMqByPIvRXgZ6DK50MBSY4SyJVZePn2xz4EIkHD9MPSWSM799RYSKVP 1JIVjnyp77lE91pxcja/0aEAsjsLSM8LaTpfk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730461838; x=1731066638; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7aR4uu+yBdWM/WK4DWlVdXDM7WElFkpQM2rMuqNYQ8s=; b=UwhEdfyVb6GusQ4+NNNt2FzjL3AMYUVCjjJm5mILEKTYC/AUCdbGL1163/m9xXeD5e Zyxk7eqkc1aH3XhQY+WhAi2slI6Vw2gDhH++mzS0A5giJc+lpCDjO3XEG1PeM7T1dzuA d0LaeSh2P10VvurMESptt5x3s5KBAZKwMsHNH42W2OW7nLrO69GZzNB4SJbbCCfhuwKn NgP/y5ikBAgipHNm9lLWWRYVvfY+5YFFAFOgubjPlsM09YpQ9X11PmEta4n9QEXFnCGK 1+nqMBAiz/Vtr8HWXAONwKeaPsVG6PoMFv48qAWLobbgLNIEzYEgJC1MY7A+7rbBdyk5 vSiQ== X-Gm-Message-State: AOJu0YzBTZBG7LVp6Tn0rLR0Pxz0j8CYOiLYi0jf5SPEkxIO8bFzRGb/ ccF0sAcl9Ksg7ni1OaNnWx7oIpSf1Lekf0YwI20mZx3jB6nyZEMKnu2iB2tClXjx5q0gCRZgvgg NHA== X-Google-Smtp-Source: AGHT+IGtbGogAR84Jm9BVsfOFG6a33K8fnkqo517IhNtNnGxBIwrtIhh88u6dcGBM54QwKsgZMcslw== X-Received: by 2002:a17:907:d29:b0:a99:4b56:cf76 with SMTP id a640c23a62f3a-a9de61d6bb6mr2260956566b.47.1730461837842; Fri, 01 Nov 2024 04:50:37 -0700 (PDT) Received: from chromium.org (43-114-103-145.static.glaslokaal.nl. [145.103.114.43]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9e564cc430sm171616566b.88.2024.11.01.04.50.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 04:50:37 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Marek Vasut , Svyatoslav , Simon Glass , Caleb Connolly , Christian Marangi , Devarsh Thakkar , Ilias Apalodimas , Jerome Forissier , Jonas Karlman , Peter Robinson , Quentin Schulz , Raymond Mao , Richard Weinberger , Sean Anderson , Sughosh Ganu , This contributor prefers not to receive mails , Tom Rini Subject: [PATCH v2 3/3] common: Move autoprobe out to board init Date: Fri, 1 Nov 2024 12:50:26 +0100 Message-ID: <20241101115028.214678-4-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241101115028.214678-1-sjg@chromium.org> References: <20241101115028.214678-1-sjg@chromium.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean Rather than doing autoprobe within the driver model code, move it out to the board-init code. This makes it clear that it is a separate step from binding devices. For now this is always done twice, before and after relocation, but we should discuss whether it might be possible to drop the post-relocation probe. For boards with SPL, the autoprobe is still done there as well. Note that with this change, autoprobe happens after the EVT_DM_POST_INIT_R/F events are sent, rather than before. Update the docs a little, for this feature. Signed-off-by: Simon Glass --- Changes in v2: - Add autoprobe to SPL also - Leave the function name the same - Fix 'Prove' typo - Update cover letter since SPL is now covered also - Update the documentation too, with a discussion link common/board_f.c | 4 ++++ common/board_r.c | 4 ++++ common/spl/spl.c | 4 ++++ doc/develop/driver-model/design.rst | 15 +++++++++++++++ drivers/core/root.c | 13 ++++++++++++- include/dm/root.h | 10 ++++++++++ 6 files changed, 49 insertions(+), 1 deletion(-) diff --git a/common/board_f.c b/common/board_f.c index 1e1aa08530a..974eb4f39e9 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -822,6 +822,10 @@ static int initf_dm(void) if (ret) return ret; + ret = dm_autoprobe(); + if (ret) + return ret; + if (IS_ENABLED(CONFIG_TIMER_EARLY)) { ret = dm_timer_init(); if (ret) diff --git a/common/board_r.c b/common/board_r.c index 62228a723e1..d1507b06f8d 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -241,6 +241,10 @@ static int initr_dm(void) if (ret) return ret; + ret = dm_autoprobe(); + if (ret) + return ret; + return 0; } #endif diff --git a/common/spl/spl.c b/common/spl/spl.c index 1ceb63daf31..c4256f237ee 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -500,6 +500,10 @@ static int spl_common_init(bool setup_malloc) debug("dm_init_and_scan() returned error %d\n", ret); return ret; } + + ret = dm_autoprobe(); + if (ret) + return ret; } return 0; diff --git a/doc/develop/driver-model/design.rst b/doc/develop/driver-model/design.rst index 8c2c81d7ac9..1dcac1408ff 100644 --- a/doc/develop/driver-model/design.rst +++ b/doc/develop/driver-model/design.rst @@ -842,6 +842,21 @@ steps (see device_probe()): cause the uclass to do some housekeeping to record the device as activated and 'known' by the uclass. +For some platforms, certain devices must be probed to get the platform into +a working state. To help with this, drivers marked with +``DM_FLAG_PROBE_AFTER_BIND`` will be probed immediately after all devices are +bound. For now, this happens in each xPL build as well as in U-Boot proper, +both before relocation and after relocation. See the call to ``dm_autoprobe()`` +for where this is done. + +Note that autoprobe happens after the ``EVT_DM_POST_INIT_R`` and +``EVT_DM_POST_INIT_F`` events are sent, since these events relate to +device-binding. + +See here for discussion of this feature: + +:Link: https://patchwork.ozlabs.org/project/uboot/patch/20240626235717.272219-1-marex@denx.de/ + Running stage ^^^^^^^^^^^^^ diff --git a/drivers/core/root.c b/drivers/core/root.c index 2d4f078f97f..371a37fe752 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -299,6 +299,17 @@ static int dm_probe_devices(struct udevice *dev) return 0; } +int dm_autoprobe(void) +{ + int ret; + + ret = dm_probe_devices(gd->dm_root); + if (ret) + return log_msg_ret("pro", ret); + + return 0; +} + /** * dm_scan() - Scan tables to bind devices * @@ -331,7 +342,7 @@ static int dm_scan(bool pre_reloc_only) if (ret) return ret; - return dm_probe_devices(gd->dm_root); + return 0; } int dm_init_and_scan(bool pre_reloc_only) diff --git a/include/dm/root.h b/include/dm/root.h index b2f30a842f5..cd240c6a716 100644 --- a/include/dm/root.h +++ b/include/dm/root.h @@ -136,6 +136,16 @@ int dm_scan_other(bool pre_reloc_only); */ int dm_init_and_scan(bool pre_reloc_only); +/** + * dm_autoprobe() - Probe devices which are marked for probe-after-bind + * + * This probes all devices with a DM_FLAG_PROBE_AFTER_BIND flag. It checks the + * entire tree, so parent nodes need not have the flag set. + * + * Return: 0 if OK, -ve on error + */ +int dm_autoprobe(void); + /** * dm_init() - Initialise Driver Model structures *