From patchwork Fri Dec 10 06:49:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 522742 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2171057imb; Thu, 9 Dec 2021 22:53:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPzOaQtvpZ4MEiRxFp0QEJ++VYF7Jgg7VQNpadBn6sDDmwm8OkmnJYsBRccdPbUlJUg3GR X-Received: by 2002:a17:906:9b8e:: with SMTP id dd14mr21601871ejc.337.1639119223558; Thu, 09 Dec 2021 22:53:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119223; cv=none; d=google.com; s=arc-20160816; b=SKtadqhV7CQDXIHsrhfsSAaFj1F4htkaUAT8zZPRnrFkFMVOxAAt07tEQxg3/O2zN8 Z9zve2oJgw2QIQ2siP1z8LwD2y1VG9H1BHFHLHyHlVa1WMb+7puPTmTCgW6pQVbFPsHG YeLf4zeKjVBfZTI6qs9O8gn3HuDkOeHXzUmPoe4ECwYIsopIVNnR06Wb5jvQ843bpFZ6 WH4EZbxHJOik4U1IGcg5W5Qw4yNPJDUI6OfYn0EA29SbvHmgaq8MD5+4CTDEiD4WSbAV /tOWZkgH37hfkyyHB3fa3madVQqxvhDMwTSPTXiAQ9WvP7VeNnDpNgtj52bn75ztRVT4 Ddzw== 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=7kmYl4c08xqigOLNyOCeB6rtRrnbW/qILnthkGKOw7I=; b=dkNj+xaNOHETym4dPqEdcGsDYBU8WNRTwHI4/3WB4rDuGGukYoLirzdATVJzghqgyJ JZZ1dRXGt9QRqPLq7FeJG2usCXiYwsILxNtoPjP/2MT5MzLTNqb+QWmDhVbcY/ObVC6W GhvL4f8hjoA3h8/rf0C4JIyo4+Pels/tzNn8WMn87odiJRGixpWtvedCsJzeGtLTZEVK TvJ4ySEYjIJbN//hNcCEt70eS3YAWXz4Z6lI4EhugKd1jmeDq2zpd2mrzIZa5QqcUnRh h5AR2e0rhDG8/vooxLsVeqhrnw5XSPBC305Ya2ONgCy0WWEJBbOdhCmt/qq6ouaIfHTX eAQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kkaf1V+d; 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 qw11si4534118ejc.59.2021.12.09.22.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:53:43 -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=kkaf1V+d; 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 230938366F; Fri, 10 Dec 2021 07:51:50 +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="kkaf1V+d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 35A47834EE; Fri, 10 Dec 2021 07:51:24 +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-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) (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 2C4CE82F03 for ; Fri, 10 Dec 2021 07:51:19 +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-x1029.google.com with SMTP id w33-20020a17090a6ba400b001a722a06212so7599962pjj.0 for ; Thu, 09 Dec 2021 22:51:19 -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=7kmYl4c08xqigOLNyOCeB6rtRrnbW/qILnthkGKOw7I=; b=kkaf1V+dlj4r7KG3yAdxh2Al58l3NXzvnSU2KtMtFm3TqUEPytcL5pwX+A2C/OyV06 2ZVP4ax2eFX7Da71i2jDb0OMlOa2Vos72C+n8z6USmblojFzLA+UGbXcyl6LuH9MNxq7 E2CL2FBlVVNTS13kgbcwG9CChRL3B1OXkmFaEGdw0wt03ge3ahfK5D+YgfIU/AmmkrO+ Wh/28R7SqI1mwis1Af1JIibeJhin/kwnMD9s/tJ354ta8iZe7n1QHWT6jjGec0pHiv7g 7zykcHINjxdjd1v2alQF7qK64u/5ZNijbWqh4qEL4/o/ag4kyFJGSgSx3avcjYA+mZaz VNAw== 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=7kmYl4c08xqigOLNyOCeB6rtRrnbW/qILnthkGKOw7I=; b=f+1OL1vdIh+Z+Ju0VJsuFHsZjPpuca+s5lhGIKtQKjw0ds4209LxkQs8WbrcLdjKgd ECNWgdjLCoqStNQpnbOZAc/9u77z7T3NbVn65PzcF2g76r9VtEVLT1fmFyqTTRnxcbQZ 47T9fJ/KgFYZWSjdannd8SMwNGQoLgf0WbPlx9j5Ed8rMGrXCGHYu1pe4/iNmrRCxQ6F ROTSGHfTU1H05XhhxusP5tLa6ARfxL2U6w7maE6NqUBeE6Nhz9Yz/ksb4r4T/BIXpyY3 f1QsKG3eOYFDSEE86f3IUVt7iDVxr9ygNTVm+Uwe6HPOVc4IatGUL3wFaB67KxSlJhqo bbYQ== X-Gm-Message-State: AOAM5331DsuB1q0QMJMtbdS8wTln8FXVgdn1xK89xLyhAPlAN/26DDIt R+m5R0cLxG+65UwFOYNhXXdSOw== X-Received: by 2002:a17:90b:17c4:: with SMTP id me4mr21563587pjb.15.1639119077552; Thu, 09 Dec 2021 22:51:17 -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.51.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:51:16 -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 19/20] efi_loader: disk: not create BLK device for BLK(IF_TYPE_EFI) devices Date: Fri, 10 Dec 2021 15:49:46 +0900 Message-Id: <20211210064947.73361-20-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 When we create an efi_disk device with an UEFI application using driver binding protocol, the 'efi_driver' framework tries to create a corresponding block device(UCLASS_BLK/IF_TYPE_EFI). This will lead to calling a PROBE callback, efi_disk_probe(). In this case, however, we don't need to create another "efi_disk" device as we already have this device instance. So we should avoid recursively invoke further processing in the callback function. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- lib/efi_loader/efi_disk.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 8e33af76711f..f37f8c1ab0f1 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -603,6 +603,7 @@ static int efi_disk_probe(void *ctx, struct event *event) { struct udevice *dev; enum uclass_id id; + struct blk_desc *desc; struct udevice *child; int ret; @@ -616,9 +617,16 @@ static int efi_disk_probe(void *ctx, struct event *event) return 0; } - ret = efi_disk_create_raw(dev); - if (ret) - return -1; + /* + * 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) { + ret = efi_disk_create_raw(dev); + if (ret) + return -1; + } device_foreach_child(child, dev) { ret = efi_disk_create_part(child); @@ -642,13 +650,17 @@ static int efi_disk_probe(void *ctx, struct event *event) static int efi_disk_delete_raw(struct udevice *dev) { efi_handle_t handle; + struct blk_desc *desc; struct efi_disk_obj *diskobj; if (dev_tag_get_ptr(dev, DM_TAG_EFI, (void **)&handle)) return -1; - diskobj = container_of(handle, struct efi_disk_obj, header); - efi_free_pool(diskobj->dp); + desc = dev_get_uclass_plat(dev); + if (desc->if_type != IF_TYPE_EFI) { + diskobj = container_of(handle, struct efi_disk_obj, header); + efi_free_pool(diskobj->dp); + } efi_delete_handle(handle); dev_tag_del(dev, DM_TAG_EFI);