From patchwork Wed Feb 2 01:08:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 539306 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1191623imr; Tue, 1 Feb 2022 17:11:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJymvVDAdibBf08Yuuquy3VRQHO4M6/FKgij036Eg2oWhqpnS/vnFDO2eQNo944rxxkziwdy X-Received: by 2002:a05:6402:220c:: with SMTP id cq12mr27721284edb.138.1643764263968; Tue, 01 Feb 2022 17:11:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764263; cv=none; d=google.com; s=arc-20160816; b=jDJgrmBQIk1q63NEhCpzaviDCrIap+Qh1/9T34WhYqhInf57k1pflfn4vTNINeXw13 qJh/X9f2b6oPvmmXltQjVnO8wqy9ijuRgLiWPh6htNkV9mxWr1fwuW6a4m00m8hlkl14 fDWUMoZ069WFMzmf408guPYnSdnxlF7kt/b1g7wo1LzlWUoE5XIQJPp1CHgLWkWYIDyr xwGe9hiq/ChaZ44Zu1aeiAZbVYXa7pvDoHaBbEusApM7NS4Gr/uhgci2sRkzRtO2Ji9y QPmHFDljU73dmwuAOStyr2MqpM9QfpJ8YvpmtiTr+KBKDeQBgGtBbu9Ff34md33GYaLe n16g== 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=UxiGG5EcxKzIREA6492c+Lci6IAn9Kg1DDcRwiFlG4U=; b=s+Ori/CyN4cGWTMI5I/KYTHPnuJ/cx2qC4b6PMQpj6lqZdFoZejcpxFnO9PkUaCkWk rjPY2i3WSsL5X3DYxAJxB8DqBSeOgwNuzfak0/9afoNaXTOz42nlQSrvg3//S2+T1ZG6 Wh/kax2BIl7k+xUJZMO+M1Cmp6GilUJo6apJgdRgaKNr2W6zUNrajh/KW7rDIKwVs4Qt ybPDx7WxkPqFfJXXdf427k4+NXi/nv55xAXJRZTJl1XBBx6aSh4edcMghyRLzUDURvRc 9nHIlSmkelraFYfALFqGju2gWR1mHz7NUmgNrbzrPnl0GCq8ZcVMHhjeBuW795drtR5C LfAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DCgklVRn; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id t21si2411213edv.651.2022.02.01.17.11.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:11:03 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DCgklVRn; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 275988387F; Wed, 2 Feb 2022 02:10:05 +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="DCgklVRn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1B08F838C3; Wed, 2 Feb 2022 02:10:03 +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=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) (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 06A84831B5 for ; Wed, 2 Feb 2022 02:09:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x102d.google.com with SMTP id h20-20020a17090adb9400b001b518bf99ffso5213074pjv.1 for ; Tue, 01 Feb 2022 17:09:53 -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=UxiGG5EcxKzIREA6492c+Lci6IAn9Kg1DDcRwiFlG4U=; b=DCgklVRnyoYkYZJ+nQRuSzpSopbNRQwuibW+kM8e9rciwJ/HYcoK5OMoTrqVuRLUAK QCMBrT368ylykedZuZ1ws5nKMG8YIPBc7Wzc2nb7kANTcZHYsm4udrwkvUO2Pys5qzR2 qrPSSsjOXKbabAauXYB/rVS849yZDwpFu2ENPNUXUhtpo8060iN59LJjpGk5VFR073SO NO/bAx0mGPreDngx0s7rGo47kXAd8sliyYSp7RHdIWrtw+JhcuGYUVkYpc/tpThgidxu xCqRD1Ib/6uHpW+JnF8dhNe32pI+d9paMQ7UX7LuI6AKUwqZ94UHMyM1wBYh2M25KlBL GfnA== 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=UxiGG5EcxKzIREA6492c+Lci6IAn9Kg1DDcRwiFlG4U=; b=BcTLRKP3gYqoTajj9lOcc+fPAp1cSjYsP0AtOJjj6hX6zcRtfpT3eFbs7I3Q89Bp1N 2Vr5UlBmFN5ZQnZKR/cqJkc64UyNZcMuMAapjmtp/7YQOCCp0PEpuTnbD68nGGo8s45F 3QB6llJTXA+fYWBZ9BGWulhDDaC6NAxinWdxgUYcJPOIDeULK6NJvZ0bjiSOSFniX/F4 VI5tPoqfbyYsykwdOq1kcYmLfOljirHusQVYo8XrD6jZT7S65VcKVahjYYJLTmm9ftYG uxAW9HdwTQkO8LROrwYTt7kiLnwSLh3uqX/FIHAOvMtpirCx4VBO8YvsDZ/XdErTsSK0 mNWg== X-Gm-Message-State: AOAM532MmFU+FP9oLGBvtusGt8iMm94Pm5eiNu7hy9aAnpR2dj+hGoNU 1dvsZ0zhM2wJ77oqJgi3RlytaA== X-Received: by 2002:a17:90a:e284:: with SMTP id d4mr5355453pjz.5.1643764192410; Tue, 01 Feb 2022 17:09:52 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.09.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:09:52 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.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 07/19] virtio: call device_probe() in scanning Date: Wed, 2 Feb 2022 10:08:41 +0900 Message-Id: <20220202010853.40405-8-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 incovenient 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() (indrectly 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; }