From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78651606EE8F for ; Sat, 7 Nov 2026 20:13:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=s1jIrkff; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=gAPPljsj DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=Kc5F3lyEjNWOIGnGCNJya3vXfYud/SDBNxLW4aqGwec=; b=s1jIrkff+x/PnBO6lZahyfeLgx UdBP1j07RksrBqxg44TcWN6XzuwBUZZphrFt7diujBwrkUdH5NRDVXRw+ZNu8/08nTFnS5szo16Xo OzIN79LRCAZdci9VskXM+hi3mzv6hMo1jF17a31vUSDWHAxOfi2ISc99LTp8Vsyq8T7KUsioE60PD k4Fpe36HwjM4MWHBhfcomQDLtM0nBGRKbb+9vWghQbyJm1VgQHpg+glmt34KViZyVpuLacdyyW9BS FF9Gvkh58zoFun1W81bta5a8ZruJTQ79gSH7HYRyABF7EVGdY1pxdOP7u5wW6ELHJkxVYpeSWjRj/ WMCjDWVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xPmmu-0000000FHgj-3ZhJ; Sat, 07 Nov 2026 20:13:20 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xPmms-0000000FHZT-1uZU for linux-amlogic@bombadil.infradead.org; Sat, 07 Nov 2026 20:13:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=VloKSurmIYFY1UFfVkwmy64gkSHDogGYCar5RGOv9NU=; b=gAPPljsjKpha+AIVYA7G69STa1 we+gLlelsA8s6JXKmKxK/nHd3yw/kkbxPOjrPBdcBjX7apEPMhsZrurqfRcwLv8Pvw/4xU2/mTNcp 6a7kJClUFxKf00GcAvOTcuRgml5e0t0didrzkCBpG5fE5Jzpgn7hXOAgm57rc1W3r/+hII1eVy146 KZwSpJHueRHKqtWhi4yetWJeFs7mZsuuyBDgk/am+fnFtbZuAuyJUVzfpZSP5onGzZABwz2QRUNMl FnJlMrH2bIoFoKuh9T8LlpaaRp8CQ4GZNulqxGGe1kox/06B2xo7GVr/N2apcuQUYMF/SfS8ScBOs +39f9A4w==; Received: from mail-ot1-f43.google.com ([209.85.210.43]) by desiato.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xPmmm-00000005QOX-36e7 for linux-amlogic@lists.infradead.org; Sat, 07 Nov 2026 20:13:15 +0000 Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-843ea301d60so609a34.0 for ; Sat, 07 Nov 2026 12:13:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794082390; x=1794687190; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=VloKSurmIYFY1UFfVkwmy64gkSHDogGYCar5RGOv9NU=; b=tfIIZX562rFvaDpwyh7XpaNDLBdgKmUjoa8BLNgkrOSMwJs7fFmWTo9Cd06WKNfrDR t1kdUoU2NZRBcqIP7F/7VUrhf5FPbClutirGBRknAxCnlzZ0zTtl2x+OqnER/r+jFoHm nvkAoSNAVCwFqgPQy64Zw6FqQ4dc747brqHQtYcXFK3qspFpNWdN3Pdyp972LUh8i7HZ o2oLdcXYi2cBaddhMfofIZ4Z1H/QRzlySRn51zieDww9LUcAXsIiHaC62nqsrrll9IJD 6vcIPI09uKTqb8YgyCP/0z64J6R3xNKyKn7VDdq+MB1YzXYt7Nox8U2roDmP3KTaWX0O uk2w== X-Forwarded-Encrypted: i=1; AKwUvBwnkskfAJ57ozWcF9UG3O3lv4NFdp1gb6j5AWYhGGnENiUHB9vmbBqqWgL6nEIziW5VWw6JWHylNLwA7i7/@lists.infradead.org X-Gm-Message-State: APuU4Z/6a+oX+DXmpXTwZ/vMJiAHvDHXRN9mCtOR/JL0hEvGkj1DomrK 2RkeF/DfTkLKQBV+Z3eVb4IX0qnBbWXY24Kg+zXXwWPfqUu/nMJ9YrJpCPwoYuNZXRs= X-Gm-Gg: AYBFou3suLH8oXhOQ0B6Z49c6/6YZadrVgaPQnOnIStAooVz+tep0YLr0w/6WmB1PCd 9DOq2UQAuWJkNXDJjc2dq8xg4ZSZuleiWE4/zTJWv9G56at588E+TyabqcDMtCsoe5mZlP9+mJD kXKSVOTfuEzMxae+zHPtqro5gmfLTXR56jRmn2TfH+esVG7eUwauSYcG2JZz/TYvhZrdmQgMMUs h2Iu8snaLfyRJC59BbRKoxazaPNFuvkadcTxEBdSNLw4wSxL3TJH2LBM78q4YK2O7vIyTE09UGL jqqYHAsHxvcKKkVYtLvhHmqshj3Q0m0++IBSJz+gayreoUkXWeWJUkNLdwiD0qe4pw2+JXyqKKd 5JzI6RT2Qo+IljkgOYJiCPzOTBpKXSfKupaeFm7MfYuqOKesf3uIPsDyHVFpHad+C6ea6w0mgaq xCMysFzrocS9Ci9PoHD+igajm33Suj5GA/edTbqA8DxYOqeDuTgLdTqs2Cy3xhjpwPAYyG3/LNs Qc1h74PIQZD0p9iIuNeVnjfBtvipu9S8G3Tlk2JdNn/M4OHDZDgmz+CG2PwP1EYwxJe7R8D5mdm Po0ywZ77Z+1u4elPirBjJE4+7viFFgJjtVJGY3UVweNhLgf0NtjhovsXTdT2 X-Received: by 2002:a05:6820:838a:b0:716:c53c:3f4b with SMTP id 006d021491bc7-7170f35914amr8104eaf.88.1794082390463; Sat, 07 Nov 2026 12:13:10 -0800 (PST) Received: from [127.0.1.1] (174-29-1-49.hlrn.qwest.net. [174.29.1.49]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-4ade68aa561sm226096fac.5.2026.11.07.12.13.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Nov 2026 12:13:09 -0800 (PST) From: James Hilliard Date: Sat, 07 Nov 2026 03:16:30 -0700 Subject: [PATCH 33/58] mtd: rawnand: gpmi: retain open-handle state on removal X-Archived-By: MIME-Version: 1.0 Message-Id: <20261107-submit-rawnand-retained-handle-lifetime-v1-v1-33-0181ef0cc4c8@gmail.com> References: <20261107-submit-rawnand-retained-handle-lifetime-v1-v1-0-0181ef0cc4c8@gmail.com> In-Reply-To: <20261107-submit-rawnand-retained-handle-lifetime-v1-v1-0-0181ef0cc4c8@gmail.com> To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Brian Norris , Boris Brezillon , Arseniy Krasnov , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Thomas Gleixner , Vitaly Wool , David Woodhouse , Russell King , David Woodhouse , Mike Rapoport , Maxime Coquelin , Alexandre Torgue , Christophe Kerello , Jason Roberts , Michal Simek , Boris Brezillon , Mason Yang , Ramuthevar Vadivel Murugan , Stefan Agner , Lucas Stach , Thierry Reding , Jonathan Hunter , Dmitry Osipenko , Matthias Brugger , AngeloGioacchino Del Regno , Jorge Ramirez-Ortiz , Heiko Stuebner , Yifeng Zhao , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Keguang Zhang , Jacky Huang , Shan-Chun Hung , Frank Li , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Han Xu , Liang Yang , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Manivannan Sadhasivam , Kamal Dasu , Broadcom internal kernel review list , Vladimir Zapolskiy , Piotr Wojtaszczyk , Paul Cercueil , Harvey Hunt , Maxim Levitsky , Michael Walle , Srinivas Kandagatla Cc: Tze Yee Ng , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-mips@vger.kernel.org, imx@lists.linux.dev, linux-renesas-soc@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-msm@vger.kernel.org, James Hilliard X-Mailer: b4 0.15.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261107_201312_721224_E1E8C518 X-CRM114-Status: GOOD ( 16.86 ) X-Spam-Score: 3.5 (+++) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Keep chip metadata and controller storage alive until the final MTD reference is released. Unregister and disconnect each published chip before releasing the resources used by its hardware operations. Keep geometry available after removal while releasing DMA and clocks. Signed-off-by: James Hilliard --- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index 527165ccc839..cda3bbdca928 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -2744,7 +2744,6 @@ static int gpmi_nand_init(struct gpmi_nand_data *this) if (ret) return ret; - nand_controller_init(&this->base); this->base.ops = &gpmi_nand_controller_ops; chip->controller = &this->base; @@ -2759,9 +2758,15 @@ static int gpmi_nand_init(struct gpmi_nand_data *this) if (ret) goto err_nand_cleanup; - ret = mtd_device_register(mtd, NULL, 0); + ret = nand_set_release(chip, NULL); if (ret) goto err_nand_cleanup; + ret = mtd_device_register(mtd, NULL, 0); + if (ret) { + nand_disconnect(chip); + mtd_put_master(mtd); + goto err_out; + } return 0; err_nand_cleanup: @@ -2782,14 +2787,22 @@ static const struct of_device_id gpmi_nand_id_table[] = { }; MODULE_DEVICE_TABLE(of, gpmi_nand_id_table); +static void gpmi_nand_release(struct nand_controller *controller) +{ + kfree(container_of(controller, struct gpmi_nand_data, base)); +} + static int gpmi_nand_probe(struct platform_device *pdev) { struct gpmi_nand_data *this; int ret; - this = devm_kzalloc(&pdev->dev, sizeof(*this), GFP_KERNEL); + this = kzalloc_obj(*this); if (!this) return -ENOMEM; + ret = devm_nand_controller_init(&pdev->dev, &this->base, gpmi_nand_release); + if (ret) + return ret; this->devdata = of_device_get_match_data(&pdev->dev); platform_set_drvdata(pdev, this); @@ -2838,7 +2851,7 @@ static void gpmi_nand_remove(struct platform_device *pdev) ret = mtd_device_unregister(nand_to_mtd(chip)); WARN_ON(ret); - nand_cleanup(chip); + nand_disconnect(chip); gpmi_free_dma_buffer(this); release_resources(this); pm_runtime_dont_use_autosuspend(&pdev->dev); @@ -2846,6 +2859,7 @@ static void gpmi_nand_remove(struct platform_device *pdev) #ifndef CONFIG_PM gpmi_disable_clk(this); #endif + mtd_put_master(nand_to_mtd(chip)); } static int gpmi_pm_suspend(struct device *dev) -- 2.53.0 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic