From patchwork Fri Dec 10 06:49:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 522733 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2169767imb; Thu, 9 Dec 2021 22:52:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyrPXkxA/o3StUMYNIpEfOJhjXm5pWR+GzNcU9ZEVyY8wQtomQDcz22sAkvbZnKejkfV7B X-Received: by 2002:a05:6402:350a:: with SMTP id b10mr35486664edd.184.1639119128820; Thu, 09 Dec 2021 22:52:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119128; cv=none; d=google.com; s=arc-20160816; b=V9ItkDaZxY66mw/xPrMXz9nsi0W9A2hGikWVFniCo8+yQ3DutdSYUqr2Bo47bJ8nBt +tKf60d/16jVU7Of6Pg2lJUK8tvgMJJsgOEKiqP5Ke3hnR2qq9lRkZCRzetVtSV23o6E KkIwKKKSlaefCQltP+B9l5A9gcTvmSpFV56i7hAkYPYVLJ7dxsnYQvQpXukepDzFMpUt YeRfEcO2zdSeaml0OjlDhQjCKc/A8czRJ5MK+9w3DBsWOmMaYbvGdrKYHNBD4su6uXaX klhRPrjPOnFI9UD0Vx4E4/SzeTHS+soOUY5thuhmI3249HXBHORS2NFQyjR75lnXpKwZ DClw== 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=5ofz6CLdNamhisd2BzpPocTNzh4e+6k+0LG9jrDMQZs=; b=BV07XT4UYDOgnyWg9f4oSnQ7VE09NPr2AE7cxU9lOZ5nGSVz1IRfpCZoqOYPujzOrZ cYnMgwWmA50sZuiytrHqO6DonGdwD8SRyt+PcfrhZi1xEsu9/a9STdXwR+qfCAXtq8TC yCt7abIhYbhAX/lx/H0EwW9hUlmfFNvSPTXESxdLeRjbTrN4/4Pyx7xmjYNsJGv07ZMG UNq7nivK34EmeM2g0pUCmA3gjodyLe+MfjiIGSUt6a2pgwuUqVKArcv5fX5kt+tiQbiU dV8lUMDFYD6z3VXtCAARQ24s20RVC/ijJ1o5yyfvfVYFH0BfjwRa1lWsUbjny4/vc8Fr JvGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bvHfLATo; 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 s20si3023370ejb.327.2021.12.09.22.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:52:08 -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=bvHfLATo; 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 F3A4883515; Fri, 10 Dec 2021 07:51:15 +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="bvHfLATo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 054CB8203C; Fri, 10 Dec 2021 07:50: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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) (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 EA6828331E for ; Fri, 10 Dec 2021 07:50:48 +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-pj1-x102e.google.com with SMTP id n15-20020a17090a160f00b001a75089daa3so8756186pja.1 for ; Thu, 09 Dec 2021 22:50:48 -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=5ofz6CLdNamhisd2BzpPocTNzh4e+6k+0LG9jrDMQZs=; b=bvHfLAToCiBm/vOySAtqCKrSUwKlPJDQblx7nTj5fwe9MBCKRHON2SXKaD7NQHLnDa BZwXF16TKDXR0NJWCYfvXlGpyY4nqC+dRqhypaJ89idTF+bBohUwB2drJYFCxymrEoUc gYBggSClwUcTgd99bqaN68skgiM+y6E1/useE/4B00KmKoheoZW3EqI5+uTkSp+QdCOM ViK0nCHkprLCfelbVYaJCWOlNr08HyJlVU2nZRtoyMGkCEX4qSaafU/nVGX0R5rw2NVR gh2gtIervPtvtBPIE64hWeSFRTHrWjmhqjkclhDrt66JB1TXqClhe47+BMXlsB3HhN9p n3bw== 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=5ofz6CLdNamhisd2BzpPocTNzh4e+6k+0LG9jrDMQZs=; b=hlX58wDb+U4xwDw5jqHrbjN3/riKm6e2eCTvp/Jdvf++Fz51tPjdnmM1C2yrBPDBK+ UAAb3jb5wtbvV9jvK7SDlHQplJVV4Lf1s+xnVBd9Mjvr9eI5iosfEe3Uot6iCBxEpfRX sGvNYgEwNzT/gatLI7VqhoOLykB5E6MhYchbPv4/N1rIh8X/q2swJwFZPt4vDhWhfxD7 g9N3YLZQWdWDBUX/kCO2MH39htMxEzEkEc+xOH3uMbckBkSZsWV4sxhGqFfD1XkODbf7 K+/Wx9MUeSmTTH+AaWfNGxyjoWUif/y36ErkSDTnRlG0vjedZuaJNihfxCBvJJNxxDcg f6SA== X-Gm-Message-State: AOAM531C53tajHgSlCTRsk0L4eBKx+IFNJu3/R2eYsJHepJ0ENreVCBb d/beWeD6wrqgwAeWLAE/fHFZtA== X-Received: by 2002:a17:90b:3849:: with SMTP id nl9mr21990192pjb.145.1639119047348; Thu, 09 Dec 2021 22:50:47 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:50:46 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC v2 10/20] virtio: call device_probe() in scanning Date: Fri, 10 Dec 2021 15:49:37 +0900 Message-Id: <20211210064947.73361-11-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 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; }