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 43088C433F5 for ; Wed, 2 Feb 2022 01:14:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 72ECD839F1; Wed, 2 Feb 2022 02:10:46 +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="jHQ+v1WI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0E4B5838B6; Wed, 2 Feb 2022 02:10:43 +0100 (CET) Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) (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 2F0AD838D6 for ; Wed, 2 Feb 2022 02:10:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pl1-x635.google.com with SMTP id l13so8192640plg.9 for ; Tue, 01 Feb 2022 17:10:33 -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=ha2wSAj7i1Ko6BdG1tS4mSnA4lyWSDCDvN964INYsL8=; b=jHQ+v1WI1/89zxIRewshaG1qvbh3wWLEfs28LpYSuUY8XmDZMvWQm2Gz9HfLeMu4i4 LqSZ++sFon2E8GtrHU692sZBw8ucv9HZ+9ZIKA+qFWIxR+yF1/Jkd23+3NwVvgErnEY5 rwwbhxsJe5XcCEHI9KFcGO9aZivCz5gzehta3hSw/mGoc8L6gyDZHh/cZ1EoyBP3giFh nx6Uous30vuZuFcp9LYujrGi43mbfCaQ4XKhVoizppAJxgUqczeIMpQGDiKMxL8DMdla HT69c21M6jZjG7WVBA35Zc320dIXe72ECcwBtVvJhE0MEy1Z6tfQw19AOrLjAWeLVxVb SWNA== 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=ha2wSAj7i1Ko6BdG1tS4mSnA4lyWSDCDvN964INYsL8=; b=c6LFnzNKids1h0Cn+VJJjPmoWkmcPfj4NVTTIz5R/mRnkmF7orOz9/dqYen9qcu0Ai xUXCHxBP/er9Br0b8H4ET7ELpiI+iWvo44MtnmE+jXyl14yt3MqwiULHBgQMykn9yJG0 CxmrcKWenDiwqaRcVjhqqEAHs4PBTirg9dRNZm55Tw0sMjOgIag2qKziwIzb23LIqNFp nX2ehKdjT2ernYSOZqcfI9Gisu3bTk4eyeCuL0icx97RXznr3v+/+TfmMEAMSILlCPfI PVXsfn26v0OhZk9MFiTltzCkJ9S1UBDdtoos8nguqEaQtEbZjPIDFOY7LCRSDNIiEX6F Z4SA== X-Gm-Message-State: AOAM530DS0Bfqs6R1lmD9SKEn2ncjlqfbKnxn/VwFrz02I6Zy3+qpRJr MgWUC+UzF9mreK4p5/L7TBJGbg== X-Google-Smtp-Source: ABdhPJz72fc6BaenVPCZ9U8Zs52PsYnbTAI5VAZ27kd1lfPB3Fdx0hrkIG85IvcCMFptPRGDxPSkKw== X-Received: by 2002:a17:90b:17c4:: with SMTP id me4mr5479856pjb.198.1643764231612; Tue, 01 Feb 2022 17:10:31 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.10.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:10:31 -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 18/19] efi_loader: disk: not create BLK device for BLK(IF_TYPE_EFI_LOADER) devices Date: Wed, 2 Feb 2022 10:08:52 +0900 Message-Id: <20220202010853.40405-19-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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 8e33af76711f..0ee892c95bf0 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); -- 2.33.0