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 DFB62606EE9D for ; Sat, 7 Nov 2026 20:10:20 +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=4kKcR47b 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=3W8iRI/dBALtGoMLlICK7A6gZuLB0hzKAayPyZdUSjo=; b=4kKcR47bbm4QVJONWay4nsRaLL krRH8Ai6K9RpKlhOxWLeMU8Vj9qPmM9F2XEUtzlQg8NACJ2W8BB8wz3tW/VkfzGX2z4CBNdrUZZwC ahVXoRron06O9op72u7rUbqoedp3OYiL6AmXc2pflqwzwCCzcyhIJugo5g4RMHuHgHcoLnBWEbu+A Vywr6GdicsSgZQilpF/tL+Y74dmPJVDZCNaYbJs9dazAJg2yP36WTwmgK8V5Jz0oKQb+4Hvm9TCMS Z+lZ7d4Gitv427Wk/3sc1X+2hFZ8QDpS3fZB4kYeRTY4VZioQuo/G8oJK9E9W65JKfxMxY8GQRpIA EZZrD6Bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xPmjx-0000000FGaJ-0FF2; Sat, 07 Nov 2026 20:10:17 +0000 Received: from mail-oo1-f53.google.com ([209.85.161.53]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xPmjs-0000000FGWg-0Yxa for linux-amlogic@lists.infradead.org; Sat, 07 Nov 2026 20:10:15 +0000 Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-716ea2598eeso979583eaf.0 for ; Sat, 07 Nov 2026 12:10:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794082210; x=1794687010; 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=0BAmvwUewoGLOJLuXxq6dZ5RycZKZl8yqwoNBMJWREA=; b=usCeo2K+R1IbcOHSMSvHB0Wog0Kmln7dnvoq+c1Y3vWnmBH2pXQ+NHVodTJmQzf1lo kjyLSVM7y6FF+l0qgsiQYBegdYDCjBnQm5oagqbaS5iNg5U56p3ZTcvdF1Qoymyh+1yI FXdKvEqU8PaXfzqHYbLtgmrHVvDPHyDjUZuoBh2WS8sSijNtk+rQGlDReqfPzkT0O0lr 4L79F9t92HkqNJHXIlCZrCfAW23eMNXWheQfy8KDBKGhBJeyomvlEf+IxaypdkVus8t0 3gs5Us+YGswdYwEnkXeUyp6j+t5H+oDI076x15BokyLbOPQtFEEqLxP6JrRAvvQCESt+ hOSA== X-Forwarded-Encrypted: i=1; AKwUvBzKsGDVo/BeY8X3pQwujVRU/c7FF8B1Rv9muF9TmRYVgEmLfgkA4f9icnT79cUZzIhCSYEtf/4LCjMtq/dz@lists.infradead.org X-Gm-Message-State: APuU4Z9OcwvwO7wXFNsc5sSDBOwbsrIGCChSzZD+pFZQ29VNLFXqzAWh lX8l5Z5PxsVI0mKVQrV//vZfqwUa/ywbtiuVBkn/K5kHW9zt1Q+xBh7TOfvkOBBUZ/s= X-Gm-Gg: AYBFou2ce7eXP11KC5smMDcjIz/+yW1VSP2f91yHKKp6sBN5VZo3UqLWB3kDPa0iREe LT4j+M5uNdU0COY5zr/GwcGnJGw7PHmfaxUOoWun0cMLJ+qZ9eowFofR0xS75Rid8fH4tC5wYMx 6hVghaRqdJscNMpto8w73nhh59FbcmDpJ/j0ZZAKUNnT4THKFls+qFpph9NEbA4JoJA+yqOJubf 707SwBt97EgNyYj0Uhxc4y27tFLdPObGNS0KV7Tvd0IY1U10i1HKMLpt6Q9ZSkssaWz77peqxGT uRsbGXvnhJA5zhGxEJptMgBbXT1vnVnIiLaBbZCIzYfzhrUv3gb8IbBxVZyHhQvPFGbqef/9+Bj dhz1qxk/qwYchElOCVI/aWnlPbgCRhk9kq/MxYB7NUpNJzeNQFVty7C+Vqysg5gbQATL15RCWN/ 5N7F8dBz+xdMzq8hNl1S8V9FG0+2lKyyr18Y/hECUfq3/lOttCKMDMdjszdYVMhO+sf9Fo8wQCK fNW+52iYP37GAs5vEpHeYkrJ5kTUxE86mbf44e7lIFLmbntFqhiQ/SaX+9Eh7D1ZYGcA4444P8P SsGTHGuZkIGVHFNU1Cc61E31gV/kngQngOgd50sDurDu1YWJfzSAHfkTVKM= X-Received: by 2002:a05:6820:7054:b0:6de:25a7:3be4 with SMTP id 006d021491bc7-7170f349085mr6610eaf.75.1794082210155; Sat, 07 Nov 2026 12:10: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-4ade6a26d74sm212708fac.15.2026.11.07.12.10.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Nov 2026 12:10:09 -0800 (PST) From: James Hilliard Date: Sat, 07 Nov 2026 19:33:38 +0000 Subject: [PATCH 25/58] mtd: rawnand: hisi504: retain open-handle state on removal X-Archived-By: MIME-Version: 1.0 Message-ID: <20261107-submit-rawnand-retained-handle-lifetime-v1-v1-25-4311be01fa4f@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_121012_187405_CB741489 X-CRM114-Status: GOOD ( 15.27 ) X-Spam-Score: 0.2 (/) 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=-13.8 required=3.0 tests=BAYES_00, 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. Retain the host through its embedded legacy controller. Signed-off-by: James Hilliard --- drivers/mtd/nand/raw/hisi504_nand.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/raw/hisi504_nand.c b/drivers/mtd/nand/raw/hisi504_nand.c index d97270ec1185..36427a242c2b 100644 --- a/drivers/mtd/nand/raw/hisi504_nand.c +++ b/drivers/mtd/nand/raw/hisi504_nand.c @@ -731,6 +731,11 @@ static const struct nand_controller_ops hisi_nfc_controller_ops = { .attach_chip = hisi_nfc_attach_chip, }; +static void hisi_nfc_release(struct nand_controller *controller) +{ + kfree(container_of(controller, struct hinfc_host, chip.legacy.dummy_controller)); +} + static int hisi_nfc_probe(struct platform_device *pdev) { int ret = 0, irq, max_chips = HINFC504_MAX_CHIP; @@ -740,9 +745,14 @@ static int hisi_nfc_probe(struct platform_device *pdev) struct mtd_info *mtd; struct device_node *np = dev->of_node; - host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL); + host = kzalloc_obj(*host); if (!host) return -ENOMEM; + chip = &host->chip; + chip->controller = &chip->legacy.dummy_controller; + ret = devm_nand_controller_init(dev, chip->controller, hisi_nfc_release); + if (ret) + return ret; host->dev = dev; platform_set_drvdata(pdev, host); @@ -788,10 +798,16 @@ static int hisi_nfc_probe(struct platform_device *pdev) if (ret) return ret; + ret = nand_set_release(chip, NULL); + if (ret) { + nand_cleanup(chip); + return ret; + } ret = mtd_device_register(mtd, NULL, 0); if (ret) { dev_err(dev, "Err MTD partition=%d\n", ret); - nand_cleanup(chip); + nand_disconnect(chip); + mtd_put_master(mtd); return ret; } @@ -806,7 +822,8 @@ static void hisi_nfc_remove(struct platform_device *pdev) ret = mtd_device_unregister(nand_to_mtd(chip)); WARN_ON(ret); - nand_cleanup(chip); + nand_disconnect(chip); + mtd_put_master(nand_to_mtd(chip)); } #ifdef CONFIG_PM_SLEEP -- 2.53.0 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic