From patchwork Wed Feb 2 01:08:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 539318 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1193086imr; Tue, 1 Feb 2022 17:14:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNQLtT4ooj4suf6yJvYMZkVrRawe0LmYc5UhhXR/w3Ek7t6Vu+P8WnD4xYvcQhJEVPDrUe X-Received: by 2002:a17:907:d8d:: with SMTP id go13mr22502920ejc.440.1643764440244; Tue, 01 Feb 2022 17:14:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764440; cv=none; d=google.com; s=arc-20160816; b=QX1IoXxbIRhXm3R5GSw2aI127w9CTIoLfsjjyrPIfsf7TZeX1M8M7EW+3cOLAHUzvz xlYtTgKexRtcYPXQqQG3ya23jyJWfdDWgatCpQtnvYRhh4Yelyj4+dvW+lL97eXJRNtV 7TWwEzGPmX6xxrWqbH6TCp9VOjv0MzVHFCbnT2ZKCAORqJzVG32mU4+oSWTOaMfWYlyA zuzBLl03aYDU1etvmmPZzlcoIw4ZhCO9wYU59lTiLmAwLiVaavVg4R98VwsXSJmrNVou gIz7kUVtV50zHCaeXLttmBmiQVhVUrpzmUGJypXY+SyMU/TQpYUoK9y+V8s6nN8kIgpU uj5g== 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=ha2wSAj7i1Ko6BdG1tS4mSnA4lyWSDCDvN964INYsL8=; b=RxOmdztaqMmgIbTUhRnKHdBriCjhqDrSCJ2/pkxWvw8U8CZ4uw1vYI7EVRP4e5V8n1 vPMzGEo0LmdL8kz+j5aypYl/1V+iq2234fmnNK9A68+JvIOO+X9p6Emg86oSguZwHYqP 5wQ80VZzrDR+dSlNJ5FlT613JzjYNzhSXqxszr1tbXlB+kmGPn+qmXhMtT1oVBMMNBHe ckObEk3HfGOsQvTD3XdqgxaXypLg+e5mos53UH24Qt87DcRrbrCWLHyeFYzqR5a98tpV O8QwKeqGRdB6Jcar8V6cRgXFQ0xa0A4ZVRbRxYAZSWcmb+ZcxVyApbZ06sBGj5KZTNjg a5gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jHQ+v1WI; 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 a26si10143815edx.29.2022.02.01.17.13.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:14:00 -0800 (PST) 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=jHQ+v1WI; 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 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) 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, T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR autolearn=unavailable autolearn_force=no version=3.4.2 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-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 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);