From patchwork Fri Oct 1 05:02:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 515012 Delivered-To: patch@linaro.org Received: by 2002:a02:606e:0:0:0:0:0 with SMTP id d46csp454446jaf; Thu, 30 Sep 2021 22:09:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6b7aMJlO+V5OE2RHKNErANHyeOQirodEGycwqyZruSB8CJ+dq/PeZiMV4dqA/pPXmfVRp X-Received: by 2002:a05:6402:21d2:: with SMTP id bi18mr11809784edb.21.1633064969416; Thu, 30 Sep 2021 22:09:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633064969; cv=none; d=google.com; s=arc-20160816; b=VwU8sD1GS//kQBgR4dAfV0BrD5jXHsEtYZvDqws8zt5aQPItmnzUS1upiIN5CQElUQ NMm6Pg734TRT17oHBp44V1cI7AbbKeEUG7MP9wLxe98xVZM6+jvFGUEeLxSJWu0ajG7w VlCjaGOd9tXOUn4199JK8M4+WXQz/cwLIHORES62ERglpPIKNYIsjjFihvccUxPeCC9E fZwA/GDYysinC55b41sFj+d0686LCRfncWR+7JtRSzeCo1mSbcOHWtXUO8gQsbrwpIeI J5WmZ9G5YlXCEbPnNUwkhLi/72LyCM5ZGUHBX65S8TzkCmu9D2j603nifyWmHcJIAQfK GpMg== 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=3twPqvbIuj/O0dFgQHqyndh2aMFnT3N8S7zk68TTxgo=; b=zbNmN0XRRzZQg2m9FJTcpaV4yIp2y6LeslXqD3Un30IXKIgiH9B1ipfl1PIJjMEPZF EGHBaNUUjdNnvXiizzhQvp7ZIfr+u2+Sck57SBeU90iJkoHNManqiOVX+WWH2HO/BJqQ 6n7hsO+a5F8f1YU+AVRKlCibfwAjMJR6J7IDFaiPOAUBPDuBOZFP1ULuoxSpQXMU3cDv 5Sb2RvxlSMaEFnZvHTiq88l2HQwMEsw6WPmWAD+B1bCi2P4b5MGAQa+EKXVwueuuHUwx bG7IlMSewWFH7Cb3aALmXXpMtRCEXTMOnxYanscIX0GbEtpkKEt6FSj8tbnv4H8Wwy0F wcYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QmdjNkL1; 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 f12si5576936edy.16.2021.09.30.22.09.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 22:09:29 -0700 (PDT) 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=QmdjNkL1; 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 EEF4F834AA; Fri, 1 Oct 2021 07:05:36 +0200 (CEST) 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="QmdjNkL1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 142EA83453; Fri, 1 Oct 2021 07:04:57 +0200 (CEST) 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-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) (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 EB79583455 for ; Fri, 1 Oct 2021 07:04:50 +0200 (CEST) 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-x102b.google.com with SMTP id om12-20020a17090b3a8c00b0019eff43daf5so6384623pjb.4 for ; Thu, 30 Sep 2021 22:04:50 -0700 (PDT) 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=3twPqvbIuj/O0dFgQHqyndh2aMFnT3N8S7zk68TTxgo=; b=QmdjNkL1qKi2D5Lk+8DMiFpdcN6OSACpjwI2NYIwX34ziBAfhI82AG1FwIp7tBXtzv j8FzYmlQhum7ksIRFpFV4YIZN0jqn+y65V81ueGoB/Fq/axBkrMggTzZ/IO18Vr8c1he GeP8zPXzhASASikrPX5pgllx3yWiuy5GS6phl07kCDn9AcVndhOVFnQ4xdt6muQQu9Jj J+nwTBaWPcJMsvZ0YbK42ht+oUgYvFu8VOnkicvse7jmxECuqbnCHjIEtyutPv6d/Gqg d2Cax3E12TdcNpmlK84ln1vZjA6Os5AjKExL/URbrizeXGw30UrCqo1Z4UbPSWAsoPyt 44gg== 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=3twPqvbIuj/O0dFgQHqyndh2aMFnT3N8S7zk68TTxgo=; b=LDaUnhAjTsF6gypSwl4RIEFBD3C13Ijl95aPtAaWQ+qo/xEx8L/a186fhLn3INHW67 /lIW4AOr39trwgKcQatAMTQBkrnTXNfHzVG/1IT9u0dLWpIN8qlX/ec01aApCI6vsABF Y3Nl/h2TmFkWFyiuvP9S9H0hzcXcQ89SJHhhr3fGZY6W7BcINoHHub7mt2l6V5c0fWxw A3UaX4ZF9UEUQlbeIZgtu6BpmsWuPcAZk7wJOa7aU2Uqx4Sk3Z4IQCOhq0CplfaCfrtU fGYf8+aGlrITAPx7OytLTwAto68peeHG/021OaVBi6X2gXLPx4TD52jfcJLQfv4hwk1m Ay+Q== X-Gm-Message-State: AOAM532X2gnFCoOJGgOhA6O4BJ0MFqrQhKam1zRUgCUvcBcV6Ir26RnV lHffDLQUK4JgYx9GTJxhvk1/2w== X-Received: by 2002:a17:90b:4c4d:: with SMTP id np13mr391326pjb.193.1633064689215; Thu, 30 Sep 2021 22:04:49 -0700 (PDT) Received: from localhost.localdomain (122-100-26-52m5.mineo.jp. [122.100.26.52]) by smtp.gmail.com with ESMTPSA id z8sm4615113pgc.53.2021.09.30.22.04.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 22:04:48 -0700 (PDT) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: u-boot@lists.denx.de, AKASHI Takahiro Subject: [RFC 18/22] dm: blk: call efi's device-removal hook Date: Fri, 1 Oct 2021 14:02:19 +0900 Message-Id: <20211001050228.55183-36-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211001050228.55183-1-takahiro.akashi@linaro.org> References: <20211001050228.55183-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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 Adding the callback function, efi_disk_delete(), in block devices's pre_remove hook will allows for automatically deleting efi_disk objects per block device. This will eliminate any improper efi_disk objects which hold a link to non-existing udevice structures when associated block devices are physically un-plugged or udevices are once removed (and re-created) by executing commands like "scsi rescan." Signed-off-by: AKASHI Takahiro --- drivers/block/blk-uclass.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) -- 2.33.0 diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c index ce45cf0a8768..b8ad267c6c61 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -847,6 +847,16 @@ static int blk_post_probe(struct udevice *dev) return 0; } +static int blk_pre_remove(struct udevice *dev) +{ + if (CONFIG_IS_ENABLED(EFI_LOADER)) { + if (efi_disk_delete(dev)) + debug("*** efi_pre_remove_device failed\n"); + } + + return 0; +} + static int blk_part_post_probe(struct udevice *dev) { if (CONFIG_IS_ENABLED(EFI_LOADER)) { @@ -861,10 +871,21 @@ static int blk_part_post_probe(struct udevice *dev) return 0; } +static int blk_part_pre_remove(struct udevice *dev) +{ + if (CONFIG_IS_ENABLED(EFI_LOADER)) { + if (efi_disk_delete(dev)) + debug("*** efi_pre_remove_device failed\n"); + } + + return 0; +} + UCLASS_DRIVER(blk) = { .id = UCLASS_BLK, .name = "blk", .post_probe = blk_post_probe, + .pre_remove = blk_pre_remove, .per_device_plat_auto = sizeof(struct blk_desc), }; @@ -937,6 +958,7 @@ U_BOOT_DRIVER(blk_partition) = { UCLASS_DRIVER(partition) = { .id = UCLASS_PARTITION, .post_probe = blk_part_post_probe, + .pre_remove = blk_part_pre_remove, .per_device_plat_auto = sizeof(struct disk_part), .name = "partition", };