From patchwork Thu Feb 10 08:11:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 541413 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2043934imo; Thu, 10 Feb 2022 00:23:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJx81YTnxyUJgH9lpZ09amofLS8Ot+TflMvRBqwpD5FYMEjO3ikFRNV92R6sydj1mRu8+UAh X-Received: by 2002:a17:907:948c:: with SMTP id dm12mr5749822ejc.770.1644481395170; Thu, 10 Feb 2022 00:23:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644481395; cv=none; d=google.com; s=arc-20160816; b=WM1iRHPvTI2V+FZHS0XrEiZAhzh7AhYwYuAHBB/DnbH8DY8IS9JDVtGcyG8Yy+gv/C eY3PI5wgOiTxVkH5uKTtSUzI8TZS/qlhKg+teD0DbRZeezlmw46PLK2mND06PePb5Mxr qEG9NIR5WnbGaColyGOVt/quphH4teLHOG3fs2XLB0s1BVzxU3EnriRzxBUGIhDuXYOm oaJDfcMI9VbdfAYvB0W7m/xSWGGVRPnCLWSnzFRIRPLbmiVBdAdavycmdeGw9AfQzYN3 gDvgW7MLWXOetbSl4UZfUxcrQkC0KjxRmp2RpHqV/sS2BY6jgWbAqbD7HRFkWWVZrhqZ czTw== 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=eUnD9r6UABYEGlnmE8mvDYkuB51/oGLpUMozPsW3RbM=; b=K8gkpPOP7Hr6wUAGtZ7wOky4ScgrGPaDSlN7kzr5hvsFN4+eZ67iTTZrxZ1XmWKuLn Q2JxNEHCOydpuyR4FcUF/E2bOHDXC75oSTKjoOGt2XGB7MCMq3Apk3xIPU0uYMiUUXWQ ggkcY3Ivy0/OB6ZQa+GOApDvuUDEkgdMj75wCWUOVQogyml4Ug7WX1BXB0B/0XRQBWZb c8OaV0fAsmOF8LMS4zXXkxZgGBY4+abFlnW6m+LtIGZcDpQpVumr3CXdY3vRChENtVot 51ZOmgYUhhdIWhES/aZbHA/KN2U3yLLgO6x0JupE6EbiXg8Kdd/JmuVM+wjDzdxTcCUg GDHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vwol8j44; 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 v4si7722588edc.51.2022.02.10.00.23.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:23:15 -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=Vwol8j44; 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 1FD8982F65; Thu, 10 Feb 2022 09:23:14 +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="Vwol8j44"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 84EB18141A; Thu, 10 Feb 2022 09:23:11 +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, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) (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 8D3B3838EC for ; Thu, 10 Feb 2022 09:13:22 +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-pf1-x430.google.com with SMTP id i6so7000559pfc.9 for ; Thu, 10 Feb 2022 00:13:22 -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=eUnD9r6UABYEGlnmE8mvDYkuB51/oGLpUMozPsW3RbM=; b=Vwol8j44MOj47tPxARoknWFQ5VNca1UHF/Lge+QrLFnRjU6sEYHH9asc+1dYZMbx7N 6slSJIeyPEQPj5uHiVADFr8qNuOS/EdrfLXTdAWXeWtOnk/Qb7aAQG5KE2XxBHLVtRBc fQVW7PXIBkNGzhHrAo920bUgIAN7hTmFX7TzGjl/gTyu8s925t4H2bovM2GXgTAU2GY6 yiOdw8RwyinDNnnpMOGGC4L+uhkpMF+TJAlJBMLhgoGf9lbWpQxD5fSxLdsbojFJ8XGO GD7tNlYi1aNR2d/5m+NQs9VLJ2+ZgT+QL8ePSrMnEm2ef7EHOYh7++0U846O06Eki6nA +UyA== 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=eUnD9r6UABYEGlnmE8mvDYkuB51/oGLpUMozPsW3RbM=; b=6NpASlaU2MROe9zyPQsp2Llh0PkrxS69qShFtG77JjsqPR+ZzvoPtMbTv0x0O0S76y WyQFypH5ZCWMTUOFZq9UwhKgjytVsqDEhl0soT90cY1t0O4RAeXDzWKsN7BG60EnYUHr LAuGWuHZ94hJkwDfnNSiSNGp6f/K3OPyLarx+Qd/KUbu/dwoeA2D/oDgAjpmfljy2tmw S/JiMyeE3ijZsyDfkPznKsEG3yApHgPjfa7rHCht24JRpIBPwgdALB2o4m4X9oFFgrJL l+lfGIzZNWCWQBdoK4HikqMy/sw6X+i29J7uLPMoUN6k8SWsMCsBQyiSvP0Jp30Eqnhm rifg== X-Gm-Message-State: AOAM533kVXPdS158aVahLkrLjHNzrpJagTfVicFtyFW5tnyiAWvq8k0O 17NKrBGvt8gk3/HRi8YksvVBow== X-Received: by 2002:a63:1f19:: with SMTP id f25mr5054119pgf.324.1644480800932; Thu, 10 Feb 2022 00:13:20 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id lk8sm1529208pjb.40.2022.02.10.00.13.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 00:13:20 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 19/20] efi_loader: disk: not create BLK device for BLK(IF_TYPE_EFI_LOADER) devices Date: Thu, 10 Feb 2022 17:11:23 +0900 Message-Id: <20220210081124.86612-20-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220210081124.86612-1-takahiro.akashi@linaro.org> References: <20220210081124.86612-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.5 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 a8cac0a002c9..5474e867533b 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_LOADER) { + 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_LOADER) { + 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);