From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 004C0C433F5 for ; Tue, 8 Mar 2022 11:42:47 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DC431839E9; Tue, 8 Mar 2022 12:42:10 +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="rS0MLTgG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BDB5B817D8; Tue, 8 Mar 2022 12:41:24 +0100 (CET) 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 A643F839AC for ; Tue, 8 Mar 2022 12:38:47 +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-pl1-x62a.google.com with SMTP id q11so16800592pln.11 for ; Tue, 08 Mar 2022 03:38:47 -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=Yb4jmCeL3y33twnmqo5lT4wsbYA1nWE/mH2eJWBpHt4=; b=rS0MLTgG6Yh6CxRfK/+pHOHJFrSemHdr0JGylUQncxfezg/1vQejqPqz6ad5NwFsbQ w6sRD9cGLaQSBU5opDrQ0FSqVwbh7bOTPCg7cumZjCcBMgerbsYbcXl+NCvWtUaVIRQS a38Xt2m8XFLW3cSf7zQI3GtztrBDg/xl/Sv8NQ8hy7vsPNivqol1Ratsa7/fYAyDdd3g 05iMyVyn70vens7Y8J5kKhDZcRC89WaVFd9/CpuodPKabB9/4MiVDieyZbAgtW/uT1Wq V8uBMEVu7JiwJ68WAnrzBm43XVXiEGHX49etzhE2ao1DWgnZChiBj6nEZZCrxA+xVOZe AgLw== 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=Yb4jmCeL3y33twnmqo5lT4wsbYA1nWE/mH2eJWBpHt4=; b=klJIFi9b1O64r+zmF0WKJzbciID9l+PlRN3QDAqUrxrZOsAUlPdaT+/lsD3j4fA7Tj D2ZK6QNAKDx2QVnkp4lWNcXpz0x+T7Ng+nYd6WPmqD7e+QiITKDeukTGjPrgganqafzO +kskNd2MZrohYCUZf2vDGURZpmb3GccsSby//3U2pR/8KBi4+8sY/6/CXesLWzXHFiNs /WWKUqIDeOgAwO6Du+S3fpkkOhKgMjwitkUGt/TuH7pwbW6iBFGUE7YlfIb0iZNryoIN AxW7zUFrjGW9Cfuo6NkAMThHizPSo0tDH/C8t47kpJzmpePasMud7eDrdQbjUBjZXORs qQzw== X-Gm-Message-State: AOAM5301+AQDscQ50ITJPbSiR4TzTU5Ft2NG0+EcOBmHZdZNI81ege9w qAsEY+DrZtKXD72eFiTOyhj8wg== X-Google-Smtp-Source: ABdhPJwlwPVxbknSHoj2EOA3znsjvepD1+22isMTt6aGCpok8hVYkLqnxLIFOmqp01ZJwOHfaZIhQw== X-Received: by 2002:a17:90b:4a44:b0:1bf:8deb:9435 with SMTP id lb4-20020a17090b4a4400b001bf8deb9435mr2097437pjb.16.1646739525944; Tue, 08 Mar 2022 03:38:45 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:b94a:f47a:3d51:185c]) by smtp.gmail.com with ESMTPSA id z2-20020a17090a170200b001bf2d530d64sm3434677pjd.2.2022.03.08.03.38.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 03:38:45 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.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 v3 18/19] efi_loader: disk: not create BLK device for BLK(IF_TYPE_EFI_LOADER) devices Date: Tue, 8 Mar 2022 20:36:56 +0900 Message-Id: <20220308113657.221101-19-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220308113657.221101-1-takahiro.akashi@linaro.org> References: <20220308113657.221101-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 0b4f7a9ca317..7c3eebf31e22 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; @@ -613,9 +614,16 @@ static int efi_disk_probe(void *ctx, struct event *event) if (id != UCLASS_BLK) 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); @@ -639,13 +647,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); -- 2.33.0