From patchwork Fri Oct 1 05:02:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 515016 Delivered-To: patch@linaro.org Received: by 2002:a02:606e:0:0:0:0:0 with SMTP id d46csp454856jaf; Thu, 30 Sep 2021 22:10:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuGxw5M2YgtJHcLe/sHelFfydNTsyXhPepBeViuYHvpzQbLpehgy7asgjWaXRfwfJ3sZve X-Received: by 2002:aa7:c2ca:: with SMTP id m10mr1671220edp.394.1633065008739; Thu, 30 Sep 2021 22:10:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633065008; cv=none; d=google.com; s=arc-20160816; b=FPXsPE7SDQvj8ocYPyDhbkQvxAESPC/JcaBXij64gN36SnlMxi4roBmSoNLyPIhzT+ paw+SmnAe/aG7eNvCD+OHG6yaKiZc6uXnufewFkLvCW2d2UDn1ZNOkzvSbxR8rjux6u9 vt6oIYPtFpCbCZhEThR2HPM2bsg7LPX9UCfGlqjDAUixSS2lysioAtcLUuw2ykagUvCQ mPd5E9EdH0c/1MeBJ0HK8TENSVjU4Q3d8UoCGN69iv5O3wEMiAAUfhStD0OoS99aah8x Nt22SNM04TKBO9Pyk7ZSFEjZKpS9Bm+hh9D7cnkMrRS41Qs71QeKtZnpGBJkBoeogO4j Lf1w== 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=YrQ0zQfK6xopCyFsakNibpnVNyGMpKui4X/QiOxRkwE=; b=R2JpzjcQqrW9eUvJtcGXOTg3issdq5NUYr3cHtz5mSagXYYe43DiZhvi6Al19++3tk 5Kc+nhvzYTGVINNaaHzSQD0W7H1KGoJKaXDmsV9FdlrKZ47T/UrwKNE7azZco747MPC8 GGck3up3S5wDrFndW3iGm/liOoI2vM5SUsh1tlp9UEk7722a6x7OaX6wfLTE4jXC4FJp wlBv/gJks1jK9khYF5C3U0mhpav06wc0JlelZXqDb/lz7xf/kmIWMtYLPBfc2okiJJak pQu0tvNQv/wvSIHp/bNIsU8WimKKe4owYaQ4djg6MDEQfi2M3U6SC9BvXPD3vyqG5+3R 0LDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="UIXos/Ar"; 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 y1si6251144ejk.130.2021.09.30.22.10.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 22:10:08 -0700 (PDT) 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="UIXos/Ar"; 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 D989C834B2; Fri, 1 Oct 2021 07:05:50 +0200 (CEST) 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="UIXos/Ar"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E1CD18349B; Fri, 1 Oct 2021 07:05:19 +0200 (CEST) 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-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) (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 C074C83423 for ; Fri, 1 Oct 2021 07:05:05 +0200 (CEST) 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-pl1-x62a.google.com with SMTP id w11so5516189plz.13 for ; Thu, 30 Sep 2021 22:05:05 -0700 (PDT) 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=YrQ0zQfK6xopCyFsakNibpnVNyGMpKui4X/QiOxRkwE=; b=UIXos/ArgegyXCVqTvVRDhF2/PsXAS+c72XjrblML/LdvlryZTANtBk/CEYrfE/hPx WZoATp2tN9LRFLPb0RTUAojxUKSO5YHIRQ4M9TUd4vW9LXw4XZL5gdiwSFv7p3LNpqx6 mdQEj9XZY+xo43x0168oKuNwDcyT6N6E4UnmJ8c6ueYEpMP+d0TnY0DKowr+RHOWPQ5e baMXwKWBz/9/fv92VbwYnclquaGjrDagt7br3PvvlyabEyATNvE+Dc7ttr2kaIzp/PrS s0tTj7B2Y0WtwalMPBrqjt8sYLB4/5NLSk32vpzupSPZAKp8pUA5896wNGTXlaI0wFDK RDdQ== 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=YrQ0zQfK6xopCyFsakNibpnVNyGMpKui4X/QiOxRkwE=; b=POV2bQAKwiZpDe1fyEs+s9/3pkwjuGYOlQTMd4PPK4KiKOkKorEu5yvPDEMmgMR50S Yo5Dmefzj97I9PDXomGU7qWjOCDml6yWdJUFFR1MDlSjCct7Mi0/81C1IIC3pC8Y/Pkf 9S2TIJBH7Rx4aoymV88N6vW9sxoFxYFpbwFIM5ug7ETT3ZJkc+dSnqwLBsapqXlysAQv NwD9DrupyhJ8iDYdcxAJmrZYI9jLZ40vC8MtYdSr0AUQr1LgfPQ5HjrZrtFR+g4kycRD ax42LS+gWCl54BZxCaegmPlXt206R9oO5pSzjk6bE6uzmp6enOiifc8qzkkq0A3r/2tQ MApA== X-Gm-Message-State: AOAM531AXps1sIR8bx2uaDAZYq34GU+uaXAt9LfAs+lB1N/816TNbYH/ cCmXf4DevYfLKGvuL0GMv+SYLxWUjdi82Q== X-Received: by 2002:a17:90a:5ac2:: with SMTP id n60mr10933067pji.184.1633064703974; Thu, 30 Sep 2021 22:05:03 -0700 (PDT) Received: from localhost.localdomain (122-100-26-52m5.mineo.jp. [122.100.26.52]) by smtp.gmail.com with ESMTPSA id z8sm4615113pgc.53.2021.09.30.22.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 22:05:03 -0700 (PDT) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC 20/22] efi_driver: align with efi_disk-dm integration Date: Fri, 1 Oct 2021 14:02:23 +0900 Message-Id: <20211001050228.55183-40-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211001050228.55183-1-takahiro.akashi@linaro.org> References: <20211001050228.55183-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 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 Signed-off-by: AKASHI Takahiro --- lib/efi_driver/efi_block_device.c | 6 ++++++ lib/efi_loader/efi_device_path.c | 29 +++++++++++++++++++++++++++++ lib/efi_loader/efi_disk.c | 12 +++++++++++- 3 files changed, 46 insertions(+), 1 deletion(-) -- 2.33.0 diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c index 0937e3595a43..b6afa939e1d1 100644 --- a/lib/efi_driver/efi_block_device.c +++ b/lib/efi_driver/efi_block_device.c @@ -173,6 +173,12 @@ static int efi_bl_bind(efi_handle_t handle, void *interface) plat->handle = handle; plat->io = interface; + /* + * FIXME: necessary because we won't do almost nothing in + * efi_disk_create() when called from device_probe(). + */ + bdev->efi_obj = handle; + ret = device_probe(bdev); if (ret) return ret; diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index cbdb466da41c..36c77bce9a05 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -628,6 +628,35 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) return &dp->vendor_data[1]; } #endif +#ifdef CONFIG_EFI_LOADER + /* + * FIXME: conflicting with CONFIG_SANDBOX + * This case is necessary to support efi_disk's created by + * efi_driver (and efi_driver_binding_protocol). + * TODO: + * The best way to work around here is to create efi_root as + * udevice and put all efi_driver objects under it. + */ + case UCLASS_ROOT: { + struct efi_device_path_vendor *dp; + struct blk_desc *desc = dev_get_uclass_plat(dev); + /* FIXME: guid_vendor used in selftest_block_device */ + static efi_guid_t guid_vendor = + EFI_GUID(0xdbca4c98, 0x6cb0, 0x694d, + 0x08, 0x72, 0x81, 0x9c, 0x65, 0x0c, 0xb7, 0xb8); + + + dp_fill(buf, dev->parent); + dp = buf; + ++dp; + dp->dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE; + dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR; + dp->dp.length = sizeof(*dp) + 1; + memcpy(&dp->guid, &guid_vendor, sizeof(efi_guid_t)); + dp->vendor_data[0] = desc->devnum; + return &dp->vendor_data[1]; + } +#endif #ifdef CONFIG_VIRTIO_BLK case UCLASS_VIRTIO: { struct efi_device_path_vendor *dp; diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index dfd06dd31e4a..e7cf1567929b 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -562,11 +562,21 @@ static int efi_disk_create_part(struct udevice *dev) int efi_disk_create(struct udevice *dev) { enum uclass_id id; + struct blk_desc *desc; id = device_get_uclass_id(dev); - if (id == UCLASS_BLK) + if (id == UCLASS_BLK) { + /* + * avoid creating duplicated objects now that efi_driver + * has already created an efi_disk at this moment. + */ + desc = dev_get_uclass_plat(dev); + if (desc->if_type == IF_TYPE_EFI) + return 0; + return efi_disk_create_raw(dev); + } if (id == UCLASS_PARTITION) return efi_disk_create_part(dev);