From patchwork Sat Nov 7 10:16:24 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 3964 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 E17E11C726C for ; Sat, 7 Nov 2026 21:17:17 +0100 (CET) Authentication-Results: mxe881; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-27347-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-27347-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 B99403DF18 for ; Sat, 7 Nov 2026 20:12:53 +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=1794082373; b=kAmzGeOqFK4XB1oSYFhQPgeZv1gSJEMKP3DNi380QgkveasYA4w2VkkoMniPth+7dmsn 2lW470V2XSdjG1l7PhkRC/tV0ZER9HG2nVdxaXdp+iLTNZf+jWUVYXV94nBJO5XfImiPC OwpLG87jxQ2MqU5WfkjcvOJwLe9B2el2GFciaX/ChZ+btqoH/ZhU4U2tUYZnrNclzW+yE u2Ahhyr8XgjzUOU92ZbHy4r/I2yajSRYz41k9TRcwjFUvBmYveQ/UvsZwKWEuGZtwcvVU qIKaEyf/qW13Kil2X5l3vvMtnBv3NcM2U3mSMeziwyOs4Q4OFtcVZzFUXS4W0g06iNg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794082373; 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=0NNmQES/+1JXrHeJNaKSoCC/3wqUoF1IkOWxzblHBjM=; b=xA6vSy1uhCNdvcGJbgg+S0NO53hisiL6caLGdDIs1/rX1mmhgnAsJi8UaAEjlNjQKNZd OiVW3CoFxd2u9j9UuA/VGAsj00XhqByy42tvEkkmWL161bYoGXSQpBFiOnIRVH08r63VF 78x6jn04YlmK4dHRhnaWZsAjaAZvVRDcBb+jJyuc3C7vUxkCmkKZ5dIdFHpTb/fSpoFDw dxjiHDINrW5wVjzplOd2hMMklA4Lkkudpkb3UWTKliMIeuJxTOa726Qf+qGoFBHNQivHo cR+sd8737edDs+W/dkpA1Zuf64o7lSj9js2x5QOdSH3vdPx+zKrK+pMvMAXIiWMtlCg== 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 46014606A335; Sat, 7 Nov 2026 20:12:53 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794082373; b=LFWj+yCyVkxpXhyBuBGRLPvs8kNBO1n40KmOg4eGKSbjeCuZudMOZYXj92QOEsGgX8ra 961CrQ5idDOiOoJR9C/52msJHMum/4M2nOV4l50GCbV2jfuLtyeDyJieLM+hz9OlXoZ35 bVaHuI5Z0gmHTB1HAMGay7JOd9JK/XjGaluNK/UsGqdUsnzLtJKay/wp15BQS3VWI4G3a uOCj1aBggXdzZy+MCMhOkdVJiVbAlcADm78YpWnCrs4sy2oMEE4Z3y23DtpIYPbDChrh9 NRPTjy46XjF+WhF5Oiz46MEL6afwSLTkYuRYvfhozL1i7vNwPY5eqDp3xwklQVPESLQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794082373; 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=0NNmQES/+1JXrHeJNaKSoCC/3wqUoF1IkOWxzblHBjM=; b=Py4UkQtGsm2HH/eHe63Muq5nsEZkZVO6CRvmvgLi9zc9JFc56JXqQUV3beXlvfkiDk4J NFe90kyjV4ARByb8BhQp83nMWqu5WDD5qQfacese7Vuny6yRvAXbzTF8Fmu1A63HGV5V4 +GxIlQoIaj6XvnXhFEV2bHzY1W9GFSi1PnLAxePDFC5zbc1p38XkGkOuxmC+tNwVrZkOr +Xxtmth1Zp60SeMrKPdZUCkiFJswVVSoLGwcrbowLdJc3GpKkhXfaUSBpN8Ir0J9pb0xD Io+aj+fwp6E4zAApeQz3NqR5dOstqwE4JsfT4M6+fdQi0GnieY3muEUR3lAQTqaBoNA== 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.160.52 Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com [209.85.160.52]) (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 DB4BB606A32D for ; Sat, 7 Nov 2026 20:12:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DB4BB606A32D 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-oa1-f52.google.com with SMTP id 586e51a60fabf-4a76f0cce5fso2067fac.2 for ; Sat, 07 Nov 2026 12:12:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794082372; x=1794687172; 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=0NNmQES/+1JXrHeJNaKSoCC/3wqUoF1IkOWxzblHBjM=; b=AkWnlEvrosfgJ1uu2qOIe32MUndC0p6PzQ59YVf9QLGMov/gM4TLHnkt0zgf60Skkr Z55O8Ye7ODARmxCByBK7pyz0H8mdLLrPieljmWWr/D6/ZIE5FPjL8M6hpNZp9jgsi9JD GSIk70hJZa+EnHnRdrdG6gfb//H4F9LGVbanmolba+wX0NH1w6B5Be+yTssMt+qiisJ4 NEI2yPkgiq2VFIm5RNxPWs+VlBeLx+TR8g5ED/ZxM29MVD92EdHDM+neSFkZhFL3UUTo VbsIWOBiMikLuWpKEor6lkci7oZhEdJvT/FYrF9pttkaGP4Tf8U6U5fUkU1humGF3RHj ZQ/A== X-Forwarded-Encrypted: i=1; AL+hErGQw4ifGk4XnworrWTcICAX1VJKh0Yu60pJj//i2LKmdOjLtDJS4HI9Cum/VbFhcCDWiLPsSBQ3k60WAw==@lists.linux.dev X-Gm-Message-State: APuU4Z+Nqu9A+iJHS+FVKi9K+k5FmLRwiJmeF3O6kxvZs0I0s7YU0KyC iWTS9yu5L6ve8Um6hpUTLzx/3DVpZcw4uIH79yAN5XleM+9dOcKFMyii8kCfJdiuNYc= X-Gm-Gg: AYBFou0Wis+cYAuptKbsybMbquyL6axFwc6bIlmqMrDfVcwlVE/9wQB7ucpID4HDJgP DfqJWLXOEJ7fRNlw0GBWKUUkL5eP6ogFXeXtJ90ZPlyOjcoYEwmK8ysGl9/h7VL3rmJCKS0LdML rxbXRaQiHmAW83Ux1VFEcoiEs3gwo0AJ0hD/PLP4nyVrDIRYVeWur3mA/dri553C+LdaYD4/MNJ NpuKcBQIZS56aPafynr2ZDrgG+CPnjqR5B47cNOxO749fBrB5sYDa4+V1QsiQDgjydfYNIJ58F7 uD6mI+1GHEjZgLw0h8BEsuwXHdYcICKlRXbr2zpDVQZVS7osZvuG0Zn9UyUvJYpf9E5Ey17oqLZ 7kLGA5hXpEn/cK/GqmiiXnk+fplFZaY/KDoYeX4HnNuD0J67eTVeKZyIeau5QPE8+oPb6ihawFB h3NiwHKOy8pwAVgrYx64E7ScoSqvfZx9fnT6JyqIeHtFxZ1ThQ8n9FDGOUmF3HDmo331C/WFmfj USHfiaiFGRrbgoh/449TXO5cgaD7JTosh+X+1qqIiahON5hr4MjWWLrNTLRGPYmQPAinDwy4bZe /CjgDXBbb7zSt4daS4TYCp5x7+7yEO/cKSjP6UaeCfaXg2Xo7sXosB3UE/F1 X-Received: by 2002:a05:6870:960b:b0:4a7:4d5f:c0a0 with SMTP id 586e51a60fabf-4ad98c4a8efmr4097388fac.38.1794082371748; Sat, 07 Nov 2026 12:12:51 -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.12.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Nov 2026 12:12:50 -0800 (PST) From: James Hilliard Date: Sat, 07 Nov 2026 03:16:24 -0700 Subject: [PATCH 27/58] mtd: rawnand: technologic: 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-27-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-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]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns]; TAGGED_RCPT(0.00)[kernel]; FORGED_SENDER_MAILLIST(0.00)[]; FREEMAIL_CC(0.00)[altera.com,lists.infradead.org,vger.kernel.org,lists.linux.dev,gmail.com]; RCVD_COUNT_FIVE(0.00)[6]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; TAGGED_FROM(0.00)[bounces-27347-noreply=patchwork.local]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[174.29.1.49:received,100.77.114.92:received,209.85.160.52:received]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; RCPT_COUNT_GT_50(0.00)[73]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; MIME_TRACE(0.00)[0:+]; 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)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from] X-Rspamd-Queue-Id: E17E11C726C 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. Transfer flash-node ownership to the retained-chip helper. Signed-off-by: James Hilliard --- drivers/mtd/nand/raw/technologic-nand-controller.c | 25 ++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/nand/raw/technologic-nand-controller.c b/drivers/mtd/nand/raw/technologic-nand-controller.c index a3294aaf43bd..a67f4d45f57b 100644 --- a/drivers/mtd/nand/raw/technologic-nand-controller.c +++ b/drivers/mtd/nand/raw/technologic-nand-controller.c @@ -132,6 +132,11 @@ static const struct nand_controller_ops ts72xx_nand_ops = { .exec_op = ts72xx_nand_exec_op, }; +static void ts72xx_nand_release(struct nand_controller *controller) +{ + kfree(container_of(controller, struct ts72xx_nand_data, controller)); +} + static int ts72xx_nand_probe(struct platform_device *pdev) { struct ts72xx_nand_data *data; @@ -139,11 +144,13 @@ static int ts72xx_nand_probe(struct platform_device *pdev) struct mtd_info *mtd; int err; - data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); + data = kzalloc_obj(*data); if (!data) return -ENOMEM; - nand_controller_init(&data->controller); + err = devm_nand_controller_init(&pdev->dev, &data->controller, ts72xx_nand_release); + if (err) + return err; data->controller.ops = &ts72xx_nand_ops; data->chip.controller = &data->controller; @@ -175,10 +182,17 @@ static int ts72xx_nand_probe(struct platform_device *pdev) if (err) goto err_handle_put; - err = mtd_device_parse_register(mtd, NULL, NULL, NULL, 0); + err = nand_set_release(&data->chip, NULL); if (err) goto err_clean_nand; + err = mtd_device_parse_register(mtd, NULL, NULL, NULL, 0); + if (err) { + nand_disconnect(&data->chip); + mtd_put_master(mtd); + goto err_handle_put; + } + fwnode_handle_put(child); return 0; err_clean_nand: @@ -191,14 +205,13 @@ static int ts72xx_nand_probe(struct platform_device *pdev) static void ts72xx_nand_remove(struct platform_device *pdev) { struct ts72xx_nand_data *data = platform_get_drvdata(pdev); - struct fwnode_handle *fwnode = dev_fwnode(&pdev->dev); struct nand_chip *chip = &data->chip; int ret; ret = mtd_device_unregister(nand_to_mtd(chip)); WARN_ON(ret); - nand_cleanup(chip); - fwnode_handle_put(fwnode); + nand_disconnect(chip); + mtd_put_master(nand_to_mtd(chip)); } static const struct of_device_id ts72xx_id_table[] = {