From patchwork Fri Oct 1 05:02:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 515015 Delivered-To: patch@linaro.org Received: by 2002:a02:606e:0:0:0:0:0 with SMTP id d46csp454698jaf; Thu, 30 Sep 2021 22:09:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRPCnNl00cCUGvyf/ti5BfilkY+lZOPBQWCQmQ/3HbLqjGcLkV13yCm6nBcAO7zK4ca0Lh X-Received: by 2002:a17:906:1b08:: with SMTP id o8mr4021140ejg.21.1633064997592; Thu, 30 Sep 2021 22:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633064997; cv=none; d=google.com; s=arc-20160816; b=aTc6lU3lp4+6cjzu4UPHqjU+eY7fqh8Asm79niehuhfrYCnQsMyolbxbWN1zY90zX5 en5zwRs1RUxrWtA2MmbB1yKaHtaqbqjipbg1XtAGKmw1bc3gC3Npmy5WqXk1gXz2XfOm mbVSwZC0bbPlzt1PkEje5bFDqiUH1sVK2V+d03qcmWeFJzdGnGN4D07INEi7Qcfzbofi L/3EiWJrhKRVyI386+u+T4C3uRXZsi3FJgLuZxVxNPamNKTMz6mBvaGvdHMY8k6P5ad2 94FPGo+HesFuZMmUtzEnsfechzBMQKmlqFjPSQlBghrYCYvhthqMmfo8z5nLdQGMB1oc gINQ== 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=WAwvFwg3leeLDTApd450qkz2TpaTbs/P/06EIziOs85ubtmh0GtRZ67D9mUzSIqytu nyhG9LVpk2RKWo6tFTQ12+S703SEDw4jwQZu/aP0f0LaEzMhRsvc6Dn7in5aUc0k5EFU EIVJ1l2mFTV1s3K8tOB7BJHyI6ilulTZlq1y8Ja3Uj+KUze5s47+d9L8Cw4BqPHH65RR JsfiKZYNfnmwe7F7kpKhohggIizwZCyYC7eLS+/+gMIgKRPRcf7rrzoR/lZdS5v4LtPW irrpIV2VhrwcmbuSVPuA2JhwU9jmC9uK3SjrnbLYfo85kpK/kpqMYtwhKsnl70bIWVmJ uRGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="fd/XLje3"; 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 s16si5995173edu.136.2021.09.30.22.09.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 22:09:57 -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="fd/XLje3"; 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 1BA2B834D1; Fri, 1 Oct 2021 07:05:47 +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="fd/XLje3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A06058347F; Fri, 1 Oct 2021 07:05:18 +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=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) (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 BC9148348D for ; Fri, 1 Oct 2021 07:05:01 +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-pg1-x52a.google.com with SMTP id k24so8359363pgh.8 for ; Thu, 30 Sep 2021 22:05:01 -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=fd/XLje37/EppbtZcleVgFq7smgQCABNcHX7LUCAko27OSZ4wcswmAg7oIrllXT6Gv hoR4RPwj0hsDi2nY9K0fy4U4t8H1FnkmRQvbISWzWnlrm4Ncufak6RalBDWpzk/+kE/Y fhqHyaIDxJg3GQRZGg5MYvcCAcGjt2FGJTrLrZkm6oHy9ZKH+mkDl6uI8qB9REF+mJ2r DGZmtkHL4YhbR5I+Jz+J1bAewDiYR5YfcYLQYtwrzuT56n0Vcml1KpFqbAsRKphfX3a/ dSji7YnCxa21X6/SUive1C1Uy3uiGI5/KpWx2fjQUFazJrATj9kdMYxgLYf8eHDSAWG9 o2YA== 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=4/Xjbl606fuF1XVWJccJp40Ij2YQGDouvkfwLEXTWXczdYyeWJA2zZhDIrtgnIlI18 JfsF4SazyVVDgdABo0QcSU/k7ajiVCIgQlFcl6PLQhlXS0TdYz+kU8+j+7uuQf+fmw0o W0sMWEbSjKIgWWSDbi/YyxDkrBUsKsUNRqN68Odp4wSzE7wU9jRaPBzAnZjN6f1dQlay Uy0Bvm/MUJWDjjZg6u72SDE4VZ7v1l8tPbYWs81Ap/SbFQyQ2VWX1V0BLpOG9gZ0QsLA jMZ4aLwXNeJo9LH+JwaUEaR/2H0hdzl+eTbuqtzWvROok/I9lhBdR+vRI1lqd1XjSlxN DSIg== X-Gm-Message-State: AOAM531LVmS9/SRAOOLsTVY4xbTSk6AkZU8dc8n0DZEKLWPGD1D2c651 KcgeulAmfqZH1mfAOlK7scbDa51wCfU++g== X-Received: by 2002:a05:6a00:1c51:b0:44c:1522:443e with SMTP id s17-20020a056a001c5100b0044c1522443emr2432360pfw.76.1633064699855; Thu, 30 Sep 2021 22:04:59 -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.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 22:04:59 -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 19/22] efi_driver: align with efi_disk-dm integration Date: Fri, 1 Oct 2021 14:02:22 +0900 Message-Id: <20211001050228.55183-39-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);