From patchwork Thu Feb 10 08:11:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541401 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2039016imo; Thu, 10 Feb 2022 00:13:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzds9HGrjMSeAvnhocEaJ6FZefg3MUHr3Cvgd93GQUUx3E9UH34tm/lF5n9shFbY6aFUa7q X-Received: by 2002:a17:907:3d01:: with SMTP id gm1mr5401047ejc.22.1644480820336; Thu, 10 Feb 2022 00:13:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644480820; cv=none; d=google.com; s=arc-20160816; b=N8qNLpUqyug26wiyq6hXdFsGaD79XHr+JkfoWXEAnbGoB3X+5ZGGG0bhWmlBsS0P2b IswW70xiRmHFQ4A4SuPgnRG5O14Dk+54gQcgUgnaHPUaK0ttsNt1Wh45N3XBsk6x2jY5 2soDMM0PL101Rm339pg0BomO7ilfLYIsxvOp3VpHjbIEBHR2yqJ+mdt+pBUyGULr84GP oUA/8uzUPf107uDNAnfEKKIx0bgYIgIkw0tU9L3KGucDmF0tP7HVaQo/4ZqevyvyBRub 1LsG1j5rUKoajgsTr1OYFLYauxfxcEF/GMex+IHvqtOSKoq57jKFO6tAhV0+PYWCm6n7 2n1A== 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=yIEuw8VjVGQvofCc/OWrAWt2nr5YdVhtbfatwEwQSd3bZNbC/CKx9STahF2EWGdlcc Q14ioRtBsq8hfTr3zkgL6e6jhy5NIKpb5ra/wjraoTVH3izNzD00yVgAPntGIZuV4z6o jrntUNeawf/B0QPAbZEP6TeCvBWfB6+vfeGlCRNH5Inv/hF6b+kBE54PGN0CUxn+VHz7 XqLtWmrLV1oIETQ8CCOukolHDo3u5AInt+jZiYZHzymmtHMkktZ0Q73QeIJqFKZF9LF8 Qy75jCkY2bp0TNKhQ7/z3VPmX1Ac5ikWgOcmojNvbuMYTSo44rIesItd02Lpff9xhIKV RNKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aDLUm+3+; 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 hd20si6718523ejc.944.2022.02.10.00.13.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:13:40 -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=aDLUm+3+; 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 757B081A03; Thu, 10 Feb 2022 09:12:59 +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="aDLUm+3+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F41088309D; Thu, 10 Feb 2022 09:12:55 +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-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) (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 D89968321B for ; Thu, 10 Feb 2022 09:12:38 +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-x42d.google.com with SMTP id d187so8875657pfa.10 for ; Thu, 10 Feb 2022 00:12:38 -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=aDLUm+3+Yz7cW+SNMPY52K2jnSS23UDTtYa+OPiM8m6EceAkiCb6nWevD4fhYnVJlX 9uZEe7zNisvBtIB/P/GUVIGLSiB4FJpvMUoUtf3zZGOKXsBdOwHnZR7Lashsm+B0qpm4 krV3GStIc8iGuCTborWjCPgKQupvJdHMIW47NkGho0igELcyyHCsmBANEsqNQxjtzXbg pouIRHYfLlCy3d+/nWWHtq8UOA+mRH3iFMN64Fw9LLH6ymdpXghqxg/8syTpt5vs+0Cw UiajjUSPNkt6Vzxo1LD3zA+AULHNCz4IPyWcHSiHWQSJhSgTzA8+skFyLPnE+x6xNr13 yFbQ== 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=gFMlVA2ehWfJ4kXCR/I3TXElcP0gBoQn2OQeWyk9rGnIeZ2QHYfnp/3upteYi0OHrt nQJoZ85q6O8iPDAu1BeKxFKzsM3obGov2AkMPqCWg5ajf07X+3fjk1+vDmO/6xiwLU3j g+AR8NpiHtZwPvpeh/GXKtn55biMipMXqMpFbEH8Pt22POVuyVGl+PxWlN19MWaNycRX QvTniL7gvYMW4AaA/UUy9Q4IKTEH6YKeVYl+jV8hNebnHUbzjQ74WJZ/609diYygGKmY r+7eVkuPMMNcLl1SHtwZuolZ5XZJ4vEUpYGcJBEwe0iRGFNrd7Z0wX1uxrI78Ox8odek sm8Q== X-Gm-Message-State: AOAM532ZAQqdniHDVcor83qYkrJnrH+duIQMwM82B1OFL2/LXCdBgURm vuw+1xV7WUG05PSvTtm0+5Psow== X-Received: by 2002:a05:6a00:2305:: with SMTP id h5mr6460979pfh.13.1644480757246; Thu, 10 Feb 2022 00:12:37 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.12.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:12:36 -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 v2 07/20] virtio: call device_probe() in scanning Date: Thu, 10 Feb 2022 17:11:11 +0900 Message-Id: <20220210081124.86612-8-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-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; }