From patchwork Sat Nov 7 19:33:38 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3948 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id BFB5B1C6DB2 for ; Sat, 7 Nov 2026 21:11:49 +0100 (CET) Authentication-Results: mxe881; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-27345-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-27345-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 9DF8C43DA0 for ; Sat, 7 Nov 2026 20:10:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794082212; b=Lbk1dEJWEkl/qk2K7onN7J23sRbNW1Zb94d3X7sWBqj7oIZWn3hB+42nUavG6H9JAztP Qge0v1f4Al7IChuhvcvYAvJs33BWNhGClccVbnJJGaDxUl4mKboaoPc2InlAMUasULMTq WybVzTmpbelblpbsyCZYMCI016VPA+BpQTtRM7b0ZyPnKBtwEdXsXef+5XdUOEzZHP1bo gnIPcT4C7h/arBt7m34x55LaDRFWo3LeWjQ9VTphdyVWU8+5J1GmB1YT0F1+dplMLuexr J8ftYzILqoU+ymox9TzRqAnZ9FiTltui9edL05AWKzgmEahJ8wyii0hJ5Qesl4Y1n3A== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794082212; h=X-Original-To:Received:DMARC-Filter:Received:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-ID:References: In-Reply-To:To:Cc:X-Mailer; bh=0BAmvwUewoGLOJLuXxq6dZ5RycZKZl8yqwoNBMJWREA=; b=mSCXKWqPAS/Z+7Gg4klDzwHt53ie1q9PH8wbWHUymkbDgsW7SCaXWDTHoAK3gQteN8nl QvEka1aWVdjBJIclRbZkDJ4VV6lNmaHvKxW3eEuZEjxkiyZAYy/SPS1BEmo3h/iFmTMBZ JWZiIaoiW+b4xIRQQs29GUn0X/iaRNRgGiLmrf9wDDbDB/lmhJw+fpqKvGmAORi+AWDmx rBRgiYxJUe54816jVqrxkhCC2AG22EVVEJkGjrP1b11IHsCrpdQt/tc8yHqmuEqLc+HU3 1+e6puVG+KgT0rXxDJnwWxwmH/YZ+5JdrPD8BTcdawjS9YCICQlAFY90gTePaNHXk9w== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=fail header.from=gmail.com; spf=pass smtp.mailfrom=upstreamdata.ca; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5701F606D83F; Sat, 7 Nov 2026 20:10:12 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794082212; b=ipsvFyOXSz4vqUByU1Eb1acq38zzo7SYc3xcVbjajKiCmSbhqwB8YaJJ9JUiHJp9cIOV vcMqm8kbkUPZ4+2iFIiQ4by0jQWnGEECdUG78ELSKCgPZU2wgzt34JulklRU306znhGiC bfb7CTf4UZURlwhdQLLBPf4Q6nSmXz0fbD9poi9KGetd+L9MvvFvW8qj7PuUpmxin1kLD Fozys06ceiNTs/jFUIyLo7QLVE3fg2qmnkfONdNMBUX+H909zd/GHU2mOgpCVu3t6aBAS Mzl7FSzjwVkpmEKPLxFPZe2bA/y7OPdljQGyhlJnofNZt+9EXHmGmUBFD28vtyVsIpQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794082212; h=DMARC-Filter:Received:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:Date:Subject: MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID: References:In-Reply-To:To:Cc:X-Mailer; bh=0BAmvwUewoGLOJLuXxq6dZ5RycZKZl8yqwoNBMJWREA=; b=g7vIwxz7FLnFx/YPNxAl+qw+E3VWr2usCZo9DgL1qpsMX/0zVikgw0N305wXbrNS+4lQ 9tKPxVMfG0LXRK9CpUH/1wiwiSS6U94tYN61KXcXreHI5A0SHuWH9NeS64F42YtpIDJ10 4b86bzJGKldW2MxHnHrfr4xlMERBGrl+m1Bgsb/YL27t03zA+3qSbhMt4LGYb49eqT9x6 vyqG9/mxNqtGQoY/mLJKzYsFFVo5xXgn9qELZ8dYuXJiWEXLaz3rqYpKqxD0D7f4urhBi n8WGICq1PCf5b+v0yN5jRNAfxhHcPYSOpPUkMPo+jKOPObm6RaXBO1AAkkR61TLJmbQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail header.from=gmail.com; spf=pass smtp.mailfrom=upstreamdata.ca; arc=none smtp.remote-ip=209.85.161.51 Received: from mail-oo1-f51.google.com (mail-oo1-f51.google.com [209.85.161.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D069606D81E for ; Sat, 7 Nov 2026 20:10:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4D069606D81E Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=upstreamdata.ca Received: by mail-oo1-f51.google.com with SMTP id 006d021491bc7-70b875f6f1fso1600195eaf.2 for ; Sat, 07 Nov 2026 12:10:11 -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=Tx2saBwINw9NnetWNu9K0VJn7MULpjhpLKIodqK/lFyW+Tmq4+zj02wsoJoy3Ijyta JNI2Nyv8m9m/0v7Hnay8GT4JRdMsk0lXHpjhXoMwtCEB/A3bxPY5bL+Ebbgxm0ZFvy1y sJiKvx75Pr96LpgLdiLmE1SNRgva+1orS9MSHbVFTejRhIYJ4QPGkNkeC2rExC/H8qze IIQWrpuxL+/R+w2qs6iMiQzPYQBttV3nDy6v5PIUzlDG81OxGP0ZFf5cfiLVDwbEkF7d uYtyPVxxDfRJMAo5TIjgBWhT58b9TZMKKnofnE2WTk3iMruv/I1BZHAN0hfS+XnjY3eJ MO6g== X-Forwarded-Encrypted: i=1; AKwUvBws8s0TLmJx+dOAvzzdGb13IGeEP5ig9swooP48/D3jEhjaK24+FQ7ddDelifN7XxBtwx9jrYUOdPwp8A==@lists.linux.dev X-Gm-Message-State: APuU4Z+92VvmuQ33UvP2jiYvtQLuFJQGv0Mcazo6LWwBQW2V4z+LahZx VDgV0z3l9BSfAHiU/br/GcTd/Fc3JxN5E5UU2I6OyPPBDaop7VWvWrh2v9TIj+UXeAw= X-Gm-Gg: AYBFou3WJygFTopzzGyKGhy9hzabvY06DOYv5mJ9YNhdFB3KGnjzuyd9sr4Una8zlb5 L/UGc34s1CrhbiyRf5QwtFyx9mgLOJsDxNffMpMIP8DOzhC4FqNDDIKZvFA6cH6DJUo9fBIs26d gTZOvlYMLPOEsY9h4YiDa7axZpOpIpXtijoO8Kpygl4rDEHlRuDHkgdMpVlpO48tMDjTCCe/d9L 71Lgzu/O183xbEsZfxmREUPVfSsjZtxb8axfi3zx61+e0GQl8o7L7fxYEd1kKrDbW8jxqvm239K s4uLJKfdb3JQR9H0nEKOeiyUMIloACZz22ytop9RvvMJ5oL74h/A9r6xyJfnE37itA5LVLKe87v aZv4hNruBJ5HXw2wAjU+rL8h6JFON8EGZD3aiV+nCHrS9DJcjwKcP2+FuqvzogkYvi3XGr/TfSv fC/9bdVrzzXlPx0CsKn2jJsbi7mEoKketPSLh6wf609mol2AwDQl9dD0Unhl6QLWzNWXP6bd/CA g5vS+XGeLSX1CKF/sbvzKp/AwagnOQhUC1Ny1zNLeTLnt7n4Y0KaC8JW7rqhYdcfoZIC3hR6hhi JMUu3s3rd93lnccemMsmeuL3/wNXvGUKmMNaQn0vtoSDPeVnj0HXzLLBEd0= 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-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-1.19 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.234.253.10:from]; SUSPICIOUS_RECIPS(1.50)[]; DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed), No valid DKIM,none]; MAILLIST(-0.18)[generic]; BAD_REP_POLICIES(0.10)[]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; RCVD_COUNT_FIVE(0.00)[6]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TAGGED_RCPT(0.00)[kernel]; FREEMAIL_CC(0.00)[altera.com,lists.infradead.org,vger.kernel.org,lists.linux.dev,gmail.com]; FORGED_SENDER_MAILLIST(0.00)[]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; MIME_TRACE(0.00)[0:+]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[174.29.1.49:received,100.77.114.92:received,209.85.161.51:received]; TAGGED_FROM(0.00)[bounces-27345-noreply=patchwork.local]; RCPT_COUNT_GT_50(0.00)[73]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; FREEMAIL_TO(0.00)[bootlin.com,nod.at,ti.com,gmail.com,kernel.org,sberdevices.ru,sholland.org,infradead.org,arm.linux.org.uk,intel.com,foss.st.com,st.com,amd.com,collabora.com,mxic.com.tw,linux.intel.com,agner.ch,lynxeye.de,nvidia.com,oss.qualcomm.com,sntech.de,rock-chips.com,microchip.com,tuxon.dev,nuvoton.com,nxp.com,pengutronix.de,amlogic.com,linaro.org,baylibre.com,googlemail.com,broadcom.com,mleia.com,timesys.com,crapouillou.net,walle.cc]; R_DKIM_NA(0.00)[]; RCVD_TLS_LAST(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: BFB5B1C6DB2 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: INBOX 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