From patchwork Tue Mar 8 11:36:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 549275 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp2539761mag; Tue, 8 Mar 2022 03:39:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGa7Irxb5kTl7AhBeq28wFayAwKVgIyj/UUn84YowYKweHpEVDw7WnINxgxPVqm8sb2Wu4 X-Received: by 2002:a05:6402:5208:b0:416:78df:77af with SMTP id s8-20020a056402520800b0041678df77afmr1389654edd.161.1646739587975; Tue, 08 Mar 2022 03:39:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646739587; cv=none; d=google.com; s=arc-20160816; b=nj7rTxxsF8XrR8ZCG+sNRYZx6fNMpMfVf2lil6FKavolmcH0mShcfDzaIdWVSu3fQO slVEejN04OLM0HPw8LUZF42f54TqgVr0P0cK2aq2P8XOhpR29aERNDvXKOuVkGVdu3Qe 0ANRFlu59M+9upFmcwIKZfoSzhaN/OVhwyZ9KTK22o2vdrkPiLbDroqhwrnQRL2OngPA Ih7BAJdLopFOIm/zskNAlvJiiWym9K6fEGKkOHW268qjtqOFLF10BBiqz4iZd93442kc E65ZwulAGp9gzGLTdiiVK0SpUZfh+vYYIqrYiPiGxEdAZlD0M9y2lMyHJxZxPZx2xthI FGrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rPa/7DDkj4iBuuTqq6EESbf96QBNWiHX8VcQZUMtLjo=; b=ns4J/SXhi0LDXH6N+G/07a3yoSJH5wJzFgs6JFFzybClPcvPUY/DOxeviLIwp5y1mu bhjH4X1gC4v7TrALjcfbS/fcUfyDMQD+Zd6tMp2XiyQGvsiGr1BBCmXhRYL2P7FxuxEJ AwryKE5lKeSymiBbElT7XV6sa46sMD3Dezl4SuqkPMjWfdM7KcyRZ2EZ+axX+Rtz3y7u OCrR1fIk3SStpOTcT5v4ptPewuWjv6UCEZXpRhzcGKhc9p2TAOVEqEjr3kx7z/j398MI BEJF6kVrse49AzS+q5UNMlyPoON2QEsULEQR2KLlyoBz2dcTdWsCYfS3EdSC3/XTqf6Y J8BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q4zVB1JR; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id gs31-20020a1709072d1f00b006db48e67196si1653999ejc.717.2022.03.08.03.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 03:39:47 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q4zVB1JR; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6A3FE839BA; Tue, 8 Mar 2022 12:39:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="Q4zVB1JR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 06F8583919; Tue, 8 Mar 2022 12:39:22 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) (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 BBF428392A for ; Tue, 8 Mar 2022 12:38:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x42f.google.com with SMTP id a5so5517510pfv.2 for ; Tue, 08 Mar 2022 03:38:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rPa/7DDkj4iBuuTqq6EESbf96QBNWiHX8VcQZUMtLjo=; b=Q4zVB1JRRsewJsX4Jv6uFoX57LTRFZ5U0T+5X4uJx/9vsuJnUHOZKfMWfL/3oV+Js5 rqYqfH2Vum/nzLUwFdTfuR8f3LRicUcly+qDd5b1lt2hVr4OFaBM/Y4mTMGi3vZCKYyH tGhF4dfZlViayaVK/GZu5eAyea7rXKK+NJf0P4c9yT+2MjQQscLlGwamEtnWMrgihS5B eLyPtq4mfWYRaMNsqGsjFyxMyPmeclKyoj5/gBSd9ri6qXlmPXdi6x+wSnxXyggqCVJc tCTftfHmq6q5Ru1HFpmFk8AKw8n8urKyTg+Y94jeckgzbUlIXGwFC6a5nj8ypM0+htoc Hc2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rPa/7DDkj4iBuuTqq6EESbf96QBNWiHX8VcQZUMtLjo=; b=NgMaLkXZhihqzi6jPE4ZHhCEcqquhkPUBZeYCK2ZcANBmu3EJAIpmh3ku0fsIErrR9 tpl01vNAohpY2WHBP5NScV/Nx6TA9o94b6nIizAwIZgjciuX0dFHNIGqhGYz7mX3CV0I Lz1wPpeplE0zpCCjw4TQDllMVM6qQN5pwfgbOUh/fZhYkqUnySpnbwcDm5YeCSWrL5lj c1OAJMyADW5tY2Ltnzc2/cfA8xdQ5it7/y6tXQOLsP3GkGTtIlSuSYFIn6PiGlGq7X7Y X+QoNKJY1DhyVM1otZ/rGKjre3T7vxgttkkMcGKFISDKExXSVVtMMjwlxgadCQGS2qz1 Meqw== X-Gm-Message-State: AOAM532o0hzc2VoyPzuE90pGQD2s6h+mGgIpbi9Hr3nAX7CWufYEjt74 a0BsNbGGhF01de2B8DlSNqDGqg== X-Received: by 2002:a63:d74f:0:b0:374:5bda:909d with SMTP id w15-20020a63d74f000000b003745bda909dmr13833551pgi.215.1646739487059; Tue, 08 Mar 2022 03:38:07 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:b94a:f47a:3d51:185c]) by smtp.gmail.com with ESMTPSA id z2-20020a17090a170200b001bf2d530d64sm3434677pjd.2.2022.03.08.03.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 03:38:06 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v3 07/19] virtio: call device_probe() in scanning Date: Tue, 8 Mar 2022 20:36:45 +0900 Message-Id: <20220308113657.221101-8-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220308113657.221101-1-takahiro.akashi@linaro.org> References: <20220308113657.221101-1-takahiro.akashi@linaro.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.5 at phobos.denx.de X-Virus-Status: Clean virtio_init() enumerates all the peripherals that are to be materialised with udevices(UCLASS_VIRIO) and creates particular device instances (UCLASS_BlK or whatever else) as children. On the other hand, device_probe() won't be invoked against those resultant udevices unlike other ordinary device drivers do in the driver model. This is particularly inconvenient when we want to add "event notification" callback so that we will be able to automatically create all efi_disk objects in a later patch. With this patch applied, "virtio scan" will work in a similar way to "scsi rescan", "usb start" or others in term of 'probe' semantics. I didn't add this change to virtio_init() itself because this function may be called in board_init_r() (indirectly in board_late_init()) before UEFI subsustem is initialized. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- cmd/virtio.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/cmd/virtio.c b/cmd/virtio.c index 3dace5344f7e..ea3ed2e631e4 100644 --- a/cmd/virtio.c +++ b/cmd/virtio.c @@ -17,8 +17,25 @@ static int do_virtio(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { if (argc == 2 && !strcmp(argv[1], "scan")) { - /* make sure all virtio devices are enumerated */ - virtio_init(); + /* + * make sure all virtio devices are enumerated. + * Do the same as virtio_init(), but also call + * device_probe() for children (i.e. virtio devices) + */ + struct udevice *bus, *child; + int ret; + + ret = uclass_first_device(UCLASS_VIRTIO, &bus); + if (ret) + return CMD_RET_FAILURE; + + while (bus) { + device_foreach_child_probe(child, bus) + ; + ret = uclass_next_device(&bus); + if (ret) + break; + } return CMD_RET_SUCCESS; }