From patchwork Mon Oct 4 03:44:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 515148 Delivered-To: patch@linaro.org Received: by 2002:ac0:890a:0:0:0:0:0 with SMTP id 10csp1062827imy; Sun, 3 Oct 2021 20:48:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZ+wvZZl9gAsS4+YeUURCWU+UwbquYV9KIdvoaxo/OWXlAV1ACLvMgxU4EoS5kG3jSuHNI X-Received: by 2002:aa7:cd90:: with SMTP id x16mr16444749edv.148.1633319324972; Sun, 03 Oct 2021 20:48:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633319324; cv=none; d=google.com; s=arc-20160816; b=qGh3eMPIbQ45aicpxXpAu940S5erAQPgvzUUAuEXAG0zPSrDH4295oU61jIq1npLdS ZpFoyLGGU4I+jfaJUH0l80PjR/BtvbJKaL7h0BxslXICPYDOB3rM7xe30ZDNr373t2T2 VG8TacZBj4jmkvZkx1s8I++xuS7iG6vgibbMgWd5uBBrRda92sMXNRH6DLWk86MAzkb3 +Pn5OClUhQscC7W0I/385207u4HaM8aDCaHbIYNb5aGFIdLGqFtOcuwy0ji35lkySASO N/BUQFuPGQPAYqILrnQsiCp5cMQmU6QAM7xjQ6XHyIN3uIK4CedCtBAyowIatHZw9bRw CIWQ== 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=IMLou01UVX32J00wisgTmtBYHStTf0SPA0gx7glrqUOWv5UyoAiKtT80e7jjt5XSYy aEAhrNcs6wjSbo4Mwd/ZM5NiSdOWY8RpBGjsncPCT08MhsVbMD6HNvqIxRyuCZ89QrSk 6Xl6I2Pt+wmGAALFi8E2s4raI51jc+CD2/ZiZG9DKPkCAdNBAt27tqTy3E4S3BPbd3Iy OApyDe5fvAENJXsNOCUCO/fzyDWoQ22oym9ksebb8cMrtnTumDDxPjCJ63wk14g9485u p6dyaKc7N0Nr5zqhNN0tTJFtBdOGtdLRr3wbzSjF2GKjum41CHZUmlnPlgSQQ9vjymKh zeOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="P/VMh4Jv"; 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 dm15si11397755edb.88.2021.10.03.20.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 20:48:44 -0700 (PDT) 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="P/VMh4Jv"; 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 C53DF835AB; Mon, 4 Oct 2021 05:47:10 +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="P/VMh4Jv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A2557835A8; Mon, 4 Oct 2021 05:46:45 +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-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 F0A818356D for ; Mon, 4 Oct 2021 05:46:38 +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-pj1-x102e.google.com with SMTP id pi19-20020a17090b1e5300b0019fdd3557d3so465152pjb.5 for ; Sun, 03 Oct 2021 20:46:38 -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=P/VMh4JvSBSxpQVoFezL4uknosMthGGEiyvgTDwBwizaR7f6SamzbrP3I0+6Wa8OPO MIcJ0xbyK0gq9cn9kwkFtQv2gRv5DJ2rSLtAkm8ns/UzaI1eRXXpvh1tvhWfSucz//gY KoSAf2ep2WmQpraINSC18LtDgNZ38D2aCmEDUKLXVF2LXMPp2dwjEePVJbolPGSobVRS xwjgRbUiQiOe8qFaMjNzbybBB5TKej1xYUADcwkeJwyWf162MyDYtSdA/aKd87haGlkH DRY8w/7soyEGUBEoY2b8gDY4sQhQV79W+OT1fvCnoL1YQqkGGZ25DMlWtkut4BGeXrZ+ J7Zw== 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=DUhV0UxS2bh8yQ/ZqD50KNAj76YW+bCkZJBWFYh0fdCUgqpGWDOGreAGb/3c8RxPIG iGBD3zPrqwVQW/f+SL4oIq9eEUIKJfdHbUN2MF1rc2sGvNRDtWIkocJc8YOxLzc2IpPZ H7N23QdLtQHbS5lgqdFQEIPTDpbiNon3fG2b4sxICBImSZD0Y/m50otou2tJLfiuJ+pO 72RghlhAR9tHmGvrEBI+HLR+VIQ/5ubnRhR+8sauEvRnzziI9d0ReXqvHP9igEL8fIav GbRCmuLzPs32oMLbaZrk9dhSt3/BvNfZGBwA+Jp9WcjzrEanzA73p/PmfALERnG3ie8T uZKw== X-Gm-Message-State: AOAM531JApQSigRnIBr1Azuclh6qftU92xFcwjT2cyhq6T853WdLa5Ux qL2ppzSbJ2y0Qk85Ghq4a02i5A== X-Received: by 2002:a17:90b:4b85:: with SMTP id lr5mr12483345pjb.66.1633319197336; Sun, 03 Oct 2021 20:46:37 -0700 (PDT) Received: from localhost.localdomain (61-205-96-147m5.grp4.mineo.jp. [61.205.96.147]) by smtp.gmail.com with ESMTPSA id a11sm11863515pgj.75.2021.10.03.20.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 20:46:36 -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: [resent RFC 20/22] efi_driver: align with efi_disk-dm integration Date: Mon, 4 Oct 2021 12:44:28 +0900 Message-Id: <20211004034430.41355-21-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004034430.41355-1-takahiro.akashi@linaro.org> References: <20211004034430.41355-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);