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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D8A4C433F5 for ; Sun, 10 Oct 2021 14:16:22 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id CFFFE61058 for ; Sun, 10 Oct 2021 14:16:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CFFFE61058 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A1BDC836CD; Sun, 10 Oct 2021 16:16:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="jx1PHkjc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 570BD83698; Sun, 10 Oct 2021 16:14:50 +0200 (CEST) Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) (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 8CBD6836A2 for ; Sun, 10 Oct 2021 16:14:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@google.com Received: by mail-ot1-x334.google.com with SMTP id x33-20020a9d37a4000000b0054733a85462so18131052otb.10 for ; Sun, 10 Oct 2021 07:14:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1qpZKGWH1jWAsLLCy4JGub9j4P1vftpy1A1MkpKaalQ=; b=jx1PHkjcV6Hb0LSj7+Ey/28THriwhgnDjIOjYqyCvviqqPCKZSN53zoQMye0rz4RIQ 98elN9VQ6UHGQqKE6fJs3chTRZlRRl6PgCcyLsvjouceUb+7YIQTBFwnefAABjGXPyvV QEYtJHeUEOzPt7HfpVWbGTJJ1PCYkOIDRUQUQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1qpZKGWH1jWAsLLCy4JGub9j4P1vftpy1A1MkpKaalQ=; b=mK3cvl7btOXw44sK9KZSKFuksQWm0ZRu5yadS5nviEU+EZrihRy5oukWD9bc1kUf7L dTzUPQVSBPjd5kb74qBVbFgva6YeTCyRS4S4+stps5JU3cb8bzH8+XZ6qs3qg0Wvw6Q8 9IMTIhxlS3KSq7b8rEyqm6TYYjLrp47AU7yXZ8VC18P8y9l4nGehsjmmuxLdWLRkdJ+i 2Cu3JWegdB9fdYpTqdKcJcIFcKXNw1cKqijuBuxnewA//UPUqYbul9tZoM1OTfad+7+i /8V+6KzLdVEmUzgW8q2MowRrSy3bNl4AhU2VPoJJAwGuhTgTrn3v3JW1NbsLE6YrXFHh TLxQ== X-Gm-Message-State: AOAM533mu+3f3GwdlVzwVrTXufpgAl0uJVlQeQfx2cIrQgAOJ7ugN/TA n6LJdn4EAaqIYyZFgI85ii3CxYC2SVIALVgifkAO2IQh/uk= X-Google-Smtp-Source: ABdhPJzPGcHC2opf7JLaDlr9zlFO281DERRZoCoJEdkmASq78tqvaK1HpyiIQzyVDGw2BFkPQsA2s/Dti9KFO8Vj/W8= X-Received: by 2002:a05:6830:3190:: with SMTP id p16mr17253287ots.11.1633875275796; Sun, 10 Oct 2021 07:14:35 -0700 (PDT) MIME-Version: 1.0 References: <20211001050228.55183-1-takahiro.akashi@linaro.org> <20211001050228.55183-28-takahiro.akashi@linaro.org> In-Reply-To: <20211001050228.55183-28-takahiro.akashi@linaro.org> From: Simon Glass Date: Sun, 10 Oct 2021 08:14:23 -0600 Message-ID: Subject: Re: [RFC 14/22] dm: blk: call efi's device-probe hook To: AKASHI Takahiro Cc: Heinrich Schuchardt , Alex Graf , Ilias Apalodimas , U-Boot Mailing List Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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 Hi Takahiro, On Thu, 30 Sept 2021 at 23:04, AKASHI Takahiro wrote: > > Adding this callback function, efi_disk_create() in block devices's > post_probe hook will allows for automatically creating efi_disk objects > per block device. > > This will end up not only eliminating efi_disk_register() called in UEFI > initialization, but also enabling detections of new block devices even > after the initialization. > > Signed-off-by: AKASHI Takahiro > --- > drivers/block/blk-uclass.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) This is where events come in. We need a way to notify things when devices go through different stages, etc. I am thinking of: enum dm_event_t { DMEVT_PROBE, DMEVT_POST_PROBE, ... }; struct dm_event { enum dm_event_t type; union { // add data for different event types in here } data; } int (*dm_handler_t)(void *ctx, struct dm_event *event); int dm_register(enum dm_event_t evtype, dm_handler_t func, void *ctx) int dm_notify(struct udevice *dev, enum dm_event_t type, void *data); Then the code below becomes: dm_notify(struct udevice *dev, DMEVT_POST_PROBE, NULL); the implementation of which will call the handler. If you like I could create an impl of the above as a separate patch for discussion. > > diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c > index 8fbec8779e1e..ce45cf0a8768 100644 > --- a/drivers/block/blk-uclass.c > +++ b/drivers/block/blk-uclass.c > @@ -9,6 +9,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -827,6 +828,11 @@ int blk_create_partitions(struct udevice *parent) > > static int blk_post_probe(struct udevice *dev) > { > + if (CONFIG_IS_ENABLED(EFI_LOADER)) { > + if (efi_disk_create(dev)) > + debug("*** efi_post_probe_device failed\n"); > + } > + > if (IS_ENABLED(CONFIG_PARTITIONS) && > IS_ENABLED(CONFIG_HAVE_BLOCK_DEVICE)) { > struct blk_desc *desc = dev_get_uclass_plat(dev); > @@ -843,6 +849,10 @@ static int blk_post_probe(struct udevice *dev) > > static int blk_part_post_probe(struct udevice *dev) > { > + if (CONFIG_IS_ENABLED(EFI_LOADER)) { > + if (efi_disk_create(dev)) > + debug("*** efi_post_probe_device failed\n"); > + } > /* > * TODO: > * If we call blk_creat_partitions() here, it would allow for > -- > 2.33.0 > Regards, Simon