From patchwork Fri Oct 1 05:02:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 515014 Delivered-To: patch@linaro.org Received: by 2002:a02:606e:0:0:0:0:0 with SMTP id d46csp454595jaf; Thu, 30 Sep 2021 22:09:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOs7QdKa7QJ01o8bS5YqTym700KrcCZlGf2F9Qen6IRbH8CNDeb0X23EpTuXrPmmVRG4bJ X-Received: by 2002:aa7:c0d4:: with SMTP id j20mr11890558edp.26.1633064987439; Thu, 30 Sep 2021 22:09:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633064987; cv=none; d=google.com; s=arc-20160816; b=KP6rg1ugboZXeFUKY30JbXEABlprpxXvlS+rXsVUx6ekG6GMr6ZsW8DLyHumA2JK6N F5dnSdTH+GTH0yGZKs2OA7B+4cfz7RMcpqROl/pIPq7KR6uGN83Bq5WdTdlpqoNSnPMR YRD5cypbh7LPncaHxDJuaSLkJA4x/5qv4rKdZSjtQ2kLAlWYhkiiBLQpmw09hMmjly7e VvFZcLrGXUnmpZY+wfOeVl4vj1yoSl98FKwGz5tClf4Bwhd3PSsRU1S3SkCVUHsxLcVv IdK/c13+G+ghXJHAQN2d0TFBQHXZHQdS2li/Ox6qU+Lm+LuXeFj9rW7c8Cg4q9ZavrXy xXNQ== 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=yKCMbIeRUafdiq5KPryRP1KmHrlAxkmsjZtU9K9Tn0HFASObfqdssypJ7ROTJPn5Tn MaNDSR1mVj7mUgq+h+j7N85CThMPEI895gQq7KeQtDaPPsppLI7ftL44QtxqgCvLkNfp i7w2oRN800fQtWFD6jq7vBYGX62b5sqWCJaAhMQCd/ebv51B3aJE7chnHU7gScubUwbY oTYNto/UzQDGZlZXNoldSI1jNzjf9yvL8jH9N3gFPnFmgrQEiZYzJZHkqyFvPhQt9nx6 r2CRB1GmBvM7AGreHa8FnWyDqKB9ThwcEwqt1aeAVsZklnBmPVDHmj0gVDV7Rc3YVhA2 rSlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="B2/LAZp9"; 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 u15si6918575edt.211.2021.09.30.22.09.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 22:09:47 -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="B2/LAZp9"; 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 8060D834B5; Fri, 1 Oct 2021 07:05:43 +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="B2/LAZp9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B94BF834A4; Fri, 1 Oct 2021 07:05:17 +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-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) (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 3750B83460 for ; Fri, 1 Oct 2021 07:04:58 +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-pf1-x42b.google.com with SMTP id 187so2480828pfc.10 for ; Thu, 30 Sep 2021 22:04:58 -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=B2/LAZp9ftkpbiPyKZtOfLtdCqYbzPoGbQZvyBCoRVhR2wHtskdxiY+gWr2LLsxGiD 9jp0W7bsfEONOisAGIBpQzStYQWQf43t3Hmqi+Duqelp7xZSH6U2LaHOFSgliwxQ2dZg k8hbTERIhJ0yQLKxxFgu7Jr5jB1pr1OgRwYu4hAioy1zagNhM3QKaGK4BnfOOMfjKLKi InhLxrl76EH/Dn/QA7mjQ2WIMMhj1XyNM29l0Xc1TI0c506FDn9qlIs4ufVALS7+fJXQ XmdDMqm8xkISVlldGFNFXcL9n5QSnmAmLEfyU6eys7JTxFrS9OOgj99Q+otrpSTYd2sE XRKg== 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=ucx1SNWJ7Gnreck3loyp0Doi/wv2nrga+iWa5IlNTj4VgVH3RhK0PksVYEXd/F5f+L cmRtVBAM+XAvVuVxT2UZUeEVO/SUIZT4IoMybNFIe1YZs/NewjcF+buJ7wmEecBk7HMZ /c8k10tUDMrXxAPj+CY6zYQqE357g0waVQrbS8oSiBtmXCNkd3ksBdF4zmNmlubdd/9T ulApNksrviLS0d+OSja+7QwowWkqP4XSXuYqjYZM+QVuT5KcmU6WAgOwApt0k4/KKUAh 2tjE5ycWiTTOnzpmg5qjnPEZeiVZhn6eVAQvIbqdFW0K3ds9TAUMbpH1W7uHsTmMyIy/ FiqA== X-Gm-Message-State: AOAM531wosnOQ7pm+x1MDKGE8IWfEdCqiQRWC4PH/wUkLIBqKiyQoKdd GwHoHYlVJLZuKUpIpJgkwhlnHA== X-Received: by 2002:a62:f20c:0:b0:44c:1f55:b008 with SMTP id m12-20020a62f20c000000b0044c1f55b008mr17566pfh.22.1633064696458; Thu, 30 Sep 2021 22:04:56 -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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 22:04:55 -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 19/22] dm: blk: call efi's device-removal hook Date: Fri, 1 Oct 2021 14:02:21 +0900 Message-Id: <20211001050228.55183-38-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", };