From mboxrd@z Thu Jan 1 00:00:00 1970 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 174B2C433F5 for ; Wed, 2 Feb 2022 01:11:04 +0000 (UTC) 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) 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-Google-Smtp-Source: ABdhPJz822DMIK2jp5Nb8ChqzXBq+3f2Fcgva8cL0Gqw1Nel/uu8/GB71WTD673vKRNffi09+pU8Wg== 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 Content-Transfer-Encoding: 8bit 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; } -- 2.33.0