From patchwork Fri Nov 13 18:14:16 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 483 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 5DAA31C43F7 for ; Fri, 13 Nov 2026 21:38:15 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-27585-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-27585-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 84F0A3C4D4 for ; Fri, 13 Nov 2026 18:15:16 +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=1794593716; b=KwdwRxnZYpjahrRTaAzGr3Ra9qTx6IJ2lOXQyT/3F6pJfcqfNYnXLLCErzp+Rrlq+GGY kU7Px8TPXjpjArfbbx9jWz0bpd4nv+V5wi3VODyWl22/P/gggaWVfte9aA9VVpU7XERCz Lse8X+rne2krAqOCzU7kh+/DiQEY9RzulwwTNxfjZKE0GfLVNeaoTIotHWgi3cQuRpgXd Fm9EZAD7Kzyabx6gwF778eOgj3akhFWR2zN4QVRs/iaMROXC/ox01Q6ON0VKDThGyrDHD JgNeQv/OUge0jgYJR9FI8nANNRa16ulXuVXthm7vAt6dnadarDprSFEVcXSgb5VH8Xg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794593716; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature: X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State: X-Gm-Gg:X-Received:Received:From:Subject:Date:Message-Id: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer; bh=npRJKj6BlqdwFJKciGGphf3F65mEV9WXqQjzPBUisy8=; b=i8ynfdIzsKJ17ITE2K6LEzvEP/yGBl7a+KSgtIhZBHR9kWa0Y2NZB+8NW7oEga2P9y+2 ghKZ1egLoYZgWXJRvVk4pIPTmVVrpFYElGfHQeHVe154S59xc96k4zg4bMuxS4oTkV4RT 1tDB+7s7TJqJRAIr/dUQnwWUhryhCRgKHl27seBL2AmfkuBnBWocjRxauj4ZMgNRkLZnB un7/IqiRkOKJyLoDDG4F5Uun4t9/EhjUnZImLRgVE/wLClG+HCc2faOt2xmkBCvlouT/W HgZF3Y7/aIczuYeKVNOHfaYddrNh3WOhIdHUf1Z3KfKCX5msVNCRcsauwGYvQkc2lMg== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=YE2FY4LY; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; 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 18243606A323; Fri, 13 Nov 2026 18:15:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=YE2FY4LY X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794593716; b=tvzdhQBcvhW9hLFP+meJPM5UkYyW81W4GKd7MPEPHBYuhuU8Y83QKAeloT7be+lC38Ee PtzpYjdcSZghAFxs8KJbZJQhtWnffi5tW38oslsyaiaz6xYTs9/3v5bTSg4vnsszW49cV +O+Z91f6xrho2CZKzKFbvv6ZMg/BCi8dMtcjIdemEy9hDg3WofMdWy4DHQDcsWTFGFGQM ZP25/8QutNnXCWS3EU/DXTK/CQoacfHaIJCJdju34imqh0wLIazsfLamuKasL6Rj9dTnP 5r6ioBy21JYnYt7MtlxhJMR5oONMo9nbb/IEzux/fgZ71iaJGTXl4J0LszfjFyL3K7A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794593716; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Subject:Date:Message-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer; bh=npRJKj6BlqdwFJKciGGphf3F65mEV9WXqQjzPBUisy8=; b=u1ek858LE+CcBPRW+YsBTMmJkIz2PH4iT1GWofTRlhY7Dwbjx0pcGSIZPzhp5JLI6LSb r4vik69br50sjaKrHI+EpcxeBUxlImJNtO0AHqKElx+mV/CtG03++Aw9fLeM0mSr99gMk XQDD6u6saftYqUL9aNNLnmouYHv+e51+voJUa76ctSyWJVgLComPEs5ymF+UOucxXmDxs 5YKkSjxA/X6uxUfzuCeJiPs0MFligSsta7PtR3qft3oqAgfkdP001JY1RDi7a52ghz7D6 6o06F1Fe6YDR+4PCmMYgIodUHbl0o6fa5m8L/fbJOna1xi7ZPIgzvwzJw0Vj9q4CXlA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=YE2FY4LY; arc=none smtp.remote-ip=209.85.210.48 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (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 678A8606A333 for ; Fri, 13 Nov 2026 18:15:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 678A8606A333 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-8241a56cd70so1486173a34.3 for ; Fri, 13 Nov 2026 10:15:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794593714; x=1795198514; darn=lists.linux.dev; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=npRJKj6BlqdwFJKciGGphf3F65mEV9WXqQjzPBUisy8=; b=YE2FY4LYLVynmdXShw9GEGjKlR4jgT0XpsSWV8ZAJ3pcMmjHFI0s5u0FLicvzLe0eQ S/Avsyft3bxOIk1hFYvDxYTWN9wTVWG6Ln1JWwEZjZdH4xuoMTCecCY3OIfqYMXLFeIE rqyPMIvbkPMMjAHyEPs0F0TiwM453kwMMWgzu5Tny0ScOWxy53CrveXNwoEFCsdmYRr9 +LNCjQ1q+eU8crFbsQ/xBmFHCSHrVWpK0RRKVItZdka+aQndhw7Rthnkv1mjvwW74Nsa I7RTF+IB1uVQ8TAAiuzyEnz6Lsq6slo3tD9OvWlltBJfCKTKeNj46idg969zvGiZ2hJk S+yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794593714; x=1795198514; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=npRJKj6BlqdwFJKciGGphf3F65mEV9WXqQjzPBUisy8=; b=PHRRgYtChARbNk2HIrzc9rHCsU4Ovb7U9AXLdEfJrjGnEzFCTkCnw2jstfl8z8BSgz j020fZrpelWnJEYAf6l62MPDPqGw+jaQHuxKVFbY3z6dz2JRy6FXanrJ/ppMr6lLCpE0 voFx3AavCCykYdTbU8aIkxHZcyZ/lBC1FhkHLY6MkLM1BPDFHVEruPiZubgrLg7FO+ng T5pHZoZfu1RIqq3R5JZMadI96lfPpDS+9QO/O3TwEpanpimhQRvtgmNBpjpji21MZcyi nbjsUrXqfEz5FA60K5+DXZLVZAAzIMYhdPBfhqirRtywGhV1mOTVsR1Dz4lhy2/jto2G ifeg== X-Forwarded-Encrypted: i=1; AL+hErEEpJo94U+zS+a81wegVZY5xGLfmbVvPl8nAaVy0bbVH8ghwGcWUZMP9Pb/2Qz4o25s5CfE2I2fkXcEUQ==@lists.linux.dev X-Gm-Message-State: APuU4Z9vXvI340PNzem1jjP5A9yVsvKSqyzffYhuyCMhBLSSoJ0NH8aS 8tsc7kuZ2RuppKdRZdHEOFabFht5gE8x0w5BM426r2PzaUwIh0IibntA X-Gm-Gg: AYBFou3zV1Qcaowjy/sZ+zHW1ldnrgZpHgARt9uWFvRnnGhiZJkr2gkKyvm/iBeRoP4 oRh5Hll3pgqqJDb0ja5gJ1z0MVv2iBWz6xAaGhpbzdcJOVsj2cqeYqU8Lib4PZzq6ZRiiig9XK0 p6xQ/pn2bkF243FMPR4iwTqtMV3IORaBbutnnG9qsObUUMS5lmz0buUgLceDObdmBEVkDjp8G59 q58qkqYnsxhTCZKrEmHPXBN5mzvmYhFJmlHK2jGDxfbXJEwmln82D0wrGJbnZ7axrKLJFVBnoaX 1E9gErblfTEMhYQ0bFp85w5OD+m87+DbZLtY55NewMloDDTGrBgZEavkyKCYZ0dejZKTwPZIC4j S/IMRacPyPF7NmII6NrwvN7zMOElEV1fMSfM82gUHUEQDseKiP8biJ8k0e+8o0SJWLXCOv58QWD PbJ0OX6ejQSfgFmXMMOgbEV1Q2dYxiazKnhtbVbuRRgZdxgaCeJLdY0FA5D4zZZsM8cdlrO9KN4 vrdlYWlLDJphMD4je2HT/yWqQXcAGNIJWO5UMjTXgFwzBTdq6eIBX5+PwSL9Qc0nnDPMNg0i3j9 G+XpXx9gTbnCjnnG7N4hq460fSqCm6k1bGqtqOXw4pSPVqqoUOaZw5cLe5rgSdZTCUp2nOw5EGa PYWdNVglr13rRO7j+WOaOnukBw59OJJoxKuJm9xYgCMGuBLxwxnzfCrkNzGEFj+M35v5d+Q4/w2 SowwCv1pgx2KT11TlYfMwLf6+TQqXqIMQm+rxoDG0Et/zB5XBAfTo= X-Received: by 2002:a05:6830:230f:b0:85f:aa6:b7f1 with SMTP id 46e09a7af769-862898e6a6cmr2948369a34.23.1794593714124; Fri, 13 Nov 2026 10:15:14 -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 46e09a7af769-8628817d979sm3253414a34.22.2026.11.13.10.15.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2026 10:15:12 -0800 (PST) From: James Hilliard Subject: [PATCH v4 00/58] mtd: rawnand: retain chip and controller state across removal Date: Fri, 13 Nov 2026 11:14:16 -0700 Message-Id: <20261113-submit-rawnand-retained-handle-lifetime-v1-v4-0-556b1d7c6221@gmail.com> 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 X-B4-Tracking: v=1; b=H4sIAAAAAAAC/5VUzW6jNwx8lcDnuqAoSpRy6nsUPYh/m69InK3tT Vss8u6lvYsi9i3QSYBmhuIM+X138uPmp93jw/fd0d+20/Z6yAv98rDTp3X44vvN8r5DwF4K0P7 0TV628/64/j6sg+2Pfl7bwW2fj+3Z989b+Hl78f1b2YMQYvOmDrJLwq9Hj+2fq9jvf/y4J9ufr ueLws8XR//rW1Zx/vFs93Wd9SlreHxYrchUIWAu0GjOUqtSqdaG8jIsNrlKHVee/1FSO0+1RZb QrCTBKBGOZtC4CzayILJbFLA0ZXCiZbMVQ3Bfk3joHGGrNlfuTeEWtcRXA+Q2EcNrm8aoqZwdE MVSBEjEGt+iGvOljkIRArWWWmYAEhWM/FNKka4Jrd9VOMVR1sqvlIBWGQh7VSUBqzMw1qKgqbc orctG6wCmY/LSWkCcGtiwtTArD5nF/U6L1hXTWjVTZZO2Zip6WNa1uKh1rNHb/b/mnNk3WjRx5 mttq80qAJ4qalxjleZ3fmGqlzVWxbBCbA0dYhpUbqNXmgVtSHjcogoNthjqw7vSIC5hzMrEoD7 TgIGWjtx1I10UHz0mDpuadkqgSod0tnVGhtFKCaU7l7UPn9Kb1bVa70UsOwmBmS3TyNy00PC7b DhD5FEyqmBU+rpYQUMqRywrPVks4C4b2V5TM9EGwdTcsRPIyDBFleC+sHAgzTtU/kF4SS+zA/e oyDpLBqY5yxBBaGlywQtK1sn3+vqSM/34kJVloqpzhkPSdZvC6E1ARzfrjhlmzgDtLtP7tJ3Or 8d/r5vjrVyH9eeS4M8sicue2EMZxbM7Sjp++/Kytudfs6arzBt+oC7wKWpM6lwTbDByRizuqet H6vIp6prU6jkFGXKmYh+p39/f/wM6ZulZWAUAAA== X-Change-ID: 20261104-submit-rawnand-retained-handle-lifetime-v1-0b4225e5ce0b To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , James Hilliard , Srinivas Kandagatla , Tze Yee Ng , Richard Cochran , Jonathan Lemon , Vadim Fedorenko , Yuqiang Sun , Amit Kumar Mahapatra , Luca Ceresoli , Bernhard Frauendienst , "Gustavo A. R. Silva" , Kees Cook , linux-hardening@vger.kernel.org, Arseniy Krasnov , Boris Brezillon , Brian Norris , Jernej Skrabec , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Samuel Holland , Chen-Yu Tsai , David Woodhouse , Thomas Gleixner , Vitaly Wool , David Woodhouse , Russell King , Mike Rapoport , Alexandre Torgue , Christophe Kerello , Maxime Coquelin , Jason Roberts , Boris Brezillon , Michal Simek , Mason Yang , Ramuthevar Vadivel Murugan , Lucas Stach , Dmitry Osipenko , Jonathan Hunter , linux-tegra@vger.kernel.org, Stefan Agner , Thierry Reding , AngeloGioacchino Del Regno , Jorge Ramirez-Ortiz , linux-mediatek@lists.infradead.org, Matthias Brugger , Heiko Stuebner , linux-rockchip@lists.infradead.org, Yifeng Zhao , Alexandre Belloni , Claudiu Beznea , Nicolas Ferre , Keguang Zhang , linux-mips@vger.kernel.org, Shan-Chun Hung , Jacky Huang , Fabio Estevam , Frank Li , imx@lists.linux.dev, Pengutronix Kernel Team , Sascha Hauer , Han Xu , linux-renesas-soc@vger.kernel.org, Jerome Brunet , Kevin Hilman , Liang Yang , linux-amlogic@lists.infradead.org, Martin Blumenstingl , Neil Armstrong , linux-arm-msm@vger.kernel.org, Manivannan Sadhasivam , Broadcom internal kernel review list , Kamal Dasu , Piotr Wojtaszczyk , Vladimir Zapolskiy , Harvey Hunt , Paul Cercueil , Maxim Levitsky X-Mailer: b4 0.15.2 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [4.31 / 15.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)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; RCVD_COUNT_FIVE(0.00)[6]; FROM_HAS_DN(0.00)[]; TAGGED_RCPT(0.00)[kernel]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_CC(0.00)[lists.infradead.org,vger.kernel.org,linuxfoundation.org,gmail.com,kernel.org,altera.com,linux.dev,amd.com,bootlin.com,nospam.obeliks.de,sberdevices.ru,lists.linux.dev,sholland.org,infradead.org,intel.com,arm.linux.org.uk,foss.st.com,st.com,collabora.com,mxic.com.tw,linux.intel.com,lynxeye.de,nvidia.com,agner.ch,oss.qualcomm.com,sntech.de,rock-chips.com,tuxon.dev,microchip.com,nuvoton.com,nxp.com,pengutronix.de,baylibre.com,amlogic.com,googlemail.com,linaro.org,broadcom.com,timesys.com,mleia.com,crapouillou.net]; DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns,msgid.link:url,infradead.org:email,ti.com:email,bootlin.com:email]; FORGED_SENDER_MAILLIST(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; TAGGED_FROM(0.00)[bounces-27585-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)[100.77.114.92:received,209.85.210.48:received]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; RCPT_COUNT_GT_50(0.00)[83]; RECEIVED_SPAMHAUS_PBL(0.00)[174.29.1.49:received]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from] X-Rspamd-Queue-Id: 5DAA31C43F7 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: INBOX An MTD handle can outlive controller unbind. Its metadata and NAND locks must remain valid, including when a writable file closes and calls sync, while further hardware access must be rejected after disconnection. This builds on earlier MTD removal-lifetime work. Commit 19bfa9ebebb5 ("mtd: use refcount to prevent corruption") added MTD reference counting [0], but retaining an MTD reference does not by itself retain the driver-owned allocation containing the master. The read/unbind discussion also covered raw NAND [1] and draining active operations [2]. Tze Yee Ng's SPI-NOR series addresses the corresponding SPI-NOR paths [3]. Following Greg's review [7], separate class-device data from the MTD backing allocation. Delete the device's interfaces and drain NVMEM and class PM callbacks before releasing backing data. Bare device references retain an independently allocated device, whose type, PM dispatch and final release are built in even when MTD is modular. NVMEM similarly disconnects and drains provider and layout callbacks before unregister returns; retained consumers keep core-owned metadata and receive -ENODEV on subsequent access. Introduce opt-in backing-object ownership for MTD masters. Registered nodes and acquired MTD handles retain the chip, while nested partitions also retain their parent metadata. Unregister first so removal notifiers can finish I/O, then disconnect raw NAND and drain admitted operations. Hardware resources can be released without waiting for open files to close. Virtual concatenations serialize publication and removal across physical controllers. Disconnect and drain a published concatenation before any component can disappear, then release its component references. An old handle keeps the disconnected virtual device, independently of a later replacement. Run NAND and controller-specific cleanup during disconnection, while the controller driver is still bound. Snapshot the OOB layout in core-owned data before publication so metadata queries remain valid without driver callbacks. The NAND core frees retained chip and controller allocations; the final MTD put never calls back into the controller module. Ordinary MTD and NVMEM handles retain the NAND core that implements their operations, rather than the hardware driver. Share allocation ownership across the raw-NAND drivers, including partially published probes. Shared controllers remain allocated until their last retained chip is released. R852 allocates a new chip for each card, and NDFC allocates controller state per binding. Based on NAND next at 30daaf3e7897, with Tze Yee Ng's module-reference ordering fix [4], Karl Mehltretter's OTP cleanup fix [6], and the separately posted registration, operation-locking and controller probe/teardown fixes identified by the prerequisite metadata. TLA+ models and their assumptions and coverage limits are available in [5]. [0] https://lore.kernel.org/r/20230620131905.648089-2-alexander.usyskin@intel.com [1] https://lore.kernel.org/r/CAND4H7dz94Gsi_tXSQmLNme9uROnouOUwuCX9BW_+RCc2ZFDqA@mail.gmail.com [2] https://lore.kernel.org/r/mafs0bjs73tbq.fsf@kernel.org [3] https://lore.kernel.org/r/20261022035352.52129-1-tze.yee.ng@altera.com [4] https://lore.kernel.org/r/20261022035352.52129-2-tze.yee.ng@altera.com [5] https://github.com/jameshilliard/linux-h616-nand-tla [6] https://lore.kernel.org/r/20260816163027.10044-1-kmehltretter@gmail.com [7] https://lore.kernel.org/r/2026111037-stir-hermit-cb21@gregkh Assisted-by: Codex:gpt-6-astra Signed-off-by: James Hilliard --- Changes in v4: - Keep MTD subdirectories behind CONFIG_MTD so boolean child options do not become built-in users of a modular MTD core. - Serialize partition publication with deletion and retain a handle while parsing subpartitions. Reject children of removed partitions. - Distinguish explicit NULL NVMEM owners from the parent-module fallback, including OTP providers backed by built-in NAND code. - Register layout-owned cells explicitly, preserving provider cells added before or after a layout binds. - Rebuild cell attributes across layout bind/unbind, free partial allocations on failure and remove attributes before device deletion. - Pair NVMEM_REMOVE notifications only with successful NVMEM_ADD notifications and remove the redundant disconnected-device check. - Resolve concatenation OOB layouts through the first component's master, including partition-backed components. - Link to v3: https://patch.msgid.link/20261111-submit-rawnand-retained-handle-lifetime-v1-v3-0-ce537999741d@gmail.com Changes in v3: - Finish NAND and driver cleanup during disconnection, leaving final allocation release in the NAND core, following Greg's networking example. - Snapshot OOB layouts before publication and drain complete BBM/BBT updates before releasing their working state. - Separate MTD class-device allocation and final release from backing-object ownership, following Greg's review. - Drain class PM callbacks under the device lock before detaching backing data; keep device-type and PM dispatch storage with the built-in device. - Drain NVMEM provider and layout callbacks during unregister, retaining core-owned metadata for old consumers and retiring cells across rebind. - Keep NVMEM consumer-owner references, with converted raw NAND providers naming the NAND core instead of the controller module. Release write-protect GPIOs once provider callbacks are drained. - Acquire an MTD handle for PTP OCP firmware updates through a class device. - Drain concatenation operations before releasing components, including concurrent removal of masters without opt-in lifetime ownership. - Use scoped cleanup consistently in Tegra probe and add the introducing commits for Socrates and FSL UPM, following Sashiko's review. - Link to v2: https://patch.msgid.link/20261110-submit-rawnand-retained-handle-lifetime-v1-v2-0-9137d08f05df@gmail.com Changes in v2: - Keep the MTD device callback owner pinned through callback return, with the final module put performed by the device core. - Retain virtual-concat components across removal and rebind, serialize staging/publication and unwind incomplete partition registrations. - Balance Tegra's probe-time child-node reference separately from the reference retained for the chip lifetime. - Refresh the prerequisite stack to the separately posted fixes, using the latest QCOM child-probe revision. - Keep the lifetime changes on top of those fixes: preserve QCOM scan before publication, R852 per-card initialization and Intel probe hardware shutdown. - Fold Macronix disconnection handling into the NAND disconnect patch; its operation locking is supplied by the posted prerequisite. - Use Karl Mehltretter's posted OTP cleanup fix as a prerequisite in place of the duplicate preparatory patch. - Keep the NVMEM context callback module pinned until its final callback returns, independently of the provider's consumer owner. - Use the posted fixes for dynamic partition publication and partition-node ownership. Keep master get/put accounting independent of later master registration in the MTD ownership patch. - Propagate disconnection through BBT error recovery without marking the eraseblock bad. - Make suspend of a disconnected, retained NAND device a no-op. - Handle R852 card events during removal while preventing new work from being queued. - Initialize Denali and Atmel cleanup variables at allocation and add the introducing-commit trailers for Orion and MPC5121. - Link to v1: https://patch.msgid.link/20261107-submit-rawnand-retained-handle-lifetime-v1-v1-0-0181ef0cc4c8@gmail.com To: Miquel Raynal To: Richard Weinberger To: Vignesh Raghavendra Cc: linux-kernel@vger.kernel.org Cc: linux-mtd@lists.infradead.org --- James Hilliard (58): nvmem: disconnect provider callbacks before unregister returns mtd: acquire an MTD handle from a referenced class device mtd: separate class devices from retained backing objects mtd: retain virtual concatenations across component removal mtd: rawnand: separate hardware disconnection from cleanup mtd: rawnand: share retained chip and controller ownership mtd: rawnand: sunxi: retain chip state until the final MTD put mtd: rawnand: plat_nand: retain open-handle state on removal mtd: rawnand: gpio: retain open-handle state on removal mtd: rawnand: stm32_fmc2: retain open-handle state on removal mtd: rawnand: denali: retain chips across controller removal mtd: rawnand: arasan: retain chips across controller removal mtd: rawnand: mxic: retain open-handle state on removal mtd: rawnand: intel: retain open-handle state on removal mtd: rawnand: tegra: retain open-handle state on removal mtd: rawnand: mtk: retain chips across controller removal mtd: rawnand: rockchip: retain chips across controller removal mtd: rawnand: atmel: retain chips across controller removal mtd: rawnand: orion: retain open-handle state on removal mtd: rawnand: socrates: retain open-handle state on removal mtd: rawnand: fsl_upm: retain open-handle state on removal mtd: rawnand: pasemi: retain open-handle state on removal mtd: rawnand: ams-delta: retain open-handle state on removal mtd: rawnand: xway: retain open-handle state on removal mtd: rawnand: hisi504: retain open-handle state on removal mtd: rawnand: vf610: retain open-handle state on removal mtd: rawnand: technologic: retain open-handle state on removal mtd: rawnand: loongson: retain open-handle state on removal mtd: rawnand: ma35d1: retain open-handle state on removal mtd: rawnand: pl35x: retain open-handle state on removal mtd: rawnand: mxc: retain open-handle state on removal mtd: rawnand: fsmc: retain open-handle state on removal mtd: rawnand: gpmi: retain open-handle state on removal mtd: rawnand: omap2: retain open-handle state on removal mtd: rawnand: marvell: retain open-handle state on removal mtd: rawnand: renesas: retain open-handle state on removal mtd: rawnand: meson: retain open-handle state on removal mtd: rawnand: cadence: retain open-handle state on removal mtd: rawnand: qcom: retain open-handle state on removal mtd: rawnand: cafe: retain open-handle state on removal mtd: rawnand: brcmnand: retain open-handle state on removal mtd: rawnand: au1550nd: retain chip state across removal mtd: rawnand: sharpsl: retain chip state across removal mtd: rawnand: davinci: retain chip state across removal mtd: rawnand: sh_flctl: retain chip state across removal mtd: rawnand: lpc32xx_slc: retain chip state across removal mtd: rawnand: lpc32xx_mlc: retain chip state across removal mtd: rawnand: ndfc: retain chip state across removal mtd: rawnand: txx9ndfmc: retain chip state across removal mtd: rawnand: ingenic: retain chip state across removal mtd: rawnand: mpc5121: retain chip state across removal mtd: rawnand: bcm47xxnflash: retain chip state across removal mtd: rawnand: fsl_elbc: retain chip state across removal mtd: rawnand: fsl_ifc: retain chip state across removal mtd: rawnand: r852: retain chip state across removal mtd: rawnand: nandsim: retain chip state across removal mtd: rawnand: cs553x: retain chip state across removal mtd: rawnand: diskonchip: retain chip state across removal drivers/Makefile | 2 +- drivers/media/pci/cobalt/cobalt-flash.c | 2 +- drivers/mtd/Kconfig | 5 + drivers/mtd/Makefile | 5 +- drivers/mtd/devices/bcm47xxsflash.c | 2 +- drivers/mtd/devices/docg3.c | 4 +- drivers/mtd/devices/mchp23k256.c | 2 +- drivers/mtd/devices/mchp48l640.c | 2 +- drivers/mtd/devices/mtd_dataflash.c | 2 +- drivers/mtd/devices/mtd_intel_dg.c | 30 +- drivers/mtd/devices/powernv_flash.c | 4 +- drivers/mtd/devices/spear_smi.c | 2 +- drivers/mtd/devices/sst25l.c | 2 +- drivers/mtd/devices/st_spi_fsm.c | 8 +- drivers/mtd/hyperbus/hyperbus-core.c | 2 +- drivers/mtd/lpddr/lpddr2_nvm.c | 2 +- drivers/mtd/maps/lantiq-flash.c | 2 +- drivers/mtd/maps/physmap-core.c | 2 +- drivers/mtd/maps/plat-ram.c | 2 +- drivers/mtd/maps/pxa2xx-flash.c | 2 +- drivers/mtd/maps/sa1100-flash.c | 2 +- drivers/mtd/maps/vmu-flash.c | 2 +- drivers/mtd/mtd_blkdevs.c | 2 +- drivers/mtd/mtd_virt_concat.c | 526 +++++++++++---------- drivers/mtd/mtdconcat.c | 103 +++- drivers/mtd/mtdcore.c | 306 +++++++----- drivers/mtd/mtdcore.h | 5 + drivers/mtd/mtddevice.c | 59 +++ drivers/mtd/mtddevice.h | 12 + drivers/mtd/mtdpart.c | 61 ++- drivers/mtd/mtdpstore.c | 50 +- drivers/mtd/nand/ecc.c | 3 +- drivers/mtd/nand/onenand/generic.c | 2 +- drivers/mtd/nand/onenand/onenand_omap2.c | 2 +- drivers/mtd/nand/onenand/onenand_samsung.c | 2 +- drivers/mtd/nand/raw/Makefile | 1 + drivers/mtd/nand/raw/ams-delta.c | 28 +- drivers/mtd/nand/raw/arasan-nand-controller.c | 49 +- drivers/mtd/nand/raw/atmel/nand-controller.c | 44 +- drivers/mtd/nand/raw/au1550nd.c | 23 +- drivers/mtd/nand/raw/bcm47xxnflash/main.c | 18 +- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 65 ++- drivers/mtd/nand/raw/cadence-nand-controller.c | 51 +- drivers/mtd/nand/raw/cafe_nand.c | 27 +- drivers/mtd/nand/raw/cs553x_nand.c | 44 +- drivers/mtd/nand/raw/davinci_nand.c | 26 +- drivers/mtd/nand/raw/denali.c | 28 +- drivers/mtd/nand/raw/denali_dt.c | 13 +- drivers/mtd/nand/raw/denali_pci.c | 9 +- drivers/mtd/nand/raw/diskonchip.c | 17 +- drivers/mtd/nand/raw/fsl_elbc_nand.c | 56 ++- drivers/mtd/nand/raw/fsl_ifc_nand.c | 48 +- drivers/mtd/nand/raw/fsl_upm.c | 20 +- drivers/mtd/nand/raw/fsmc_nand.c | 19 +- drivers/mtd/nand/raw/gpio.c | 18 +- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 19 +- drivers/mtd/nand/raw/hisi504_nand.c | 20 +- drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c | 41 +- drivers/mtd/nand/raw/intel-nand-controller.c | 20 +- drivers/mtd/nand/raw/internals.h | 2 +- drivers/mtd/nand/raw/loongson-nand-controller.c | 21 +- drivers/mtd/nand/raw/lpc32xx_mlc.c | 38 +- drivers/mtd/nand/raw/lpc32xx_slc.c | 40 +- drivers/mtd/nand/raw/marvell_nand.c | 46 +- drivers/mtd/nand/raw/meson_nand.c | 49 +- drivers/mtd/nand/raw/mpc5121_nfc.c | 26 +- drivers/mtd/nand/raw/mtk_nand.c | 40 +- drivers/mtd/nand/raw/mxc_nand.c | 23 +- drivers/mtd/nand/raw/mxic_nand.c | 23 +- drivers/mtd/nand/raw/nand_base.c | 103 +++- drivers/mtd/nand/raw/nand_bbt.c | 24 +- drivers/mtd/nand/raw/nand_lifetime.c | 246 ++++++++++ drivers/mtd/nand/raw/nand_macronix.c | 8 +- drivers/mtd/nand/raw/nand_onfi.c | 4 +- drivers/mtd/nand/raw/nandsim.c | 21 +- drivers/mtd/nand/raw/ndfc.c | 34 +- .../mtd/nand/raw/nuvoton-ma35d1-nand-controller.c | 42 +- drivers/mtd/nand/raw/omap2.c | 27 +- drivers/mtd/nand/raw/orion_nand.c | 24 +- drivers/mtd/nand/raw/pasemi_nand.c | 22 +- drivers/mtd/nand/raw/pl35x-nand-controller.c | 38 +- drivers/mtd/nand/raw/plat_nand.c | 20 +- drivers/mtd/nand/raw/qcom_nandc.c | 39 +- drivers/mtd/nand/raw/r852.c | 111 +++-- drivers/mtd/nand/raw/r852.h | 1 + drivers/mtd/nand/raw/renesas-nand-controller.c | 37 +- drivers/mtd/nand/raw/rockchip-nand-controller.c | 45 +- drivers/mtd/nand/raw/sh_flctl.c | 22 +- drivers/mtd/nand/raw/sharpsl.c | 22 +- drivers/mtd/nand/raw/sm_common.c | 15 +- drivers/mtd/nand/raw/sm_common.h | 2 +- drivers/mtd/nand/raw/socrates_nand.c | 19 +- drivers/mtd/nand/raw/stm32_fmc2_nand.c | 19 +- drivers/mtd/nand/raw/sunxi_nand.c | 46 +- drivers/mtd/nand/raw/technologic-nand-controller.c | 22 +- drivers/mtd/nand/raw/tegra_nand.c | 27 +- drivers/mtd/nand/raw/txx9ndfmc.c | 41 +- drivers/mtd/nand/raw/vf610_nfc.c | 20 +- drivers/mtd/nand/raw/xway_nand.c | 24 +- drivers/mtd/nand/spi/core.c | 2 +- drivers/mtd/nand/spi/esmt.c | 2 +- drivers/mtd/nand/spi/micron.c | 4 +- drivers/mtd/nand/spi/otp.c | 2 +- drivers/mtd/spi-nor/core.c | 2 +- drivers/mtd/ubi/build.c | 2 +- drivers/nvmem/Kconfig | 1 + drivers/nvmem/core.c | 463 ++++++++++++------ drivers/nvmem/internals.h | 16 +- drivers/nvmem/layouts.c | 2 + drivers/nvmem/layouts/fixed-layout.c | 2 +- drivers/nvmem/layouts/onie-tlv.c | 20 +- drivers/nvmem/layouts/sl28vpd.c | 3 +- drivers/nvmem/layouts/u-boot-env.c | 25 +- drivers/ptp/ptp_ocp.c | 7 +- include/linux/mtd/concat.h | 22 +- include/linux/mtd/mtd.h | 21 +- include/linux/mtd/rawnand.h | 37 +- include/linux/nvmem-provider.h | 16 +- 118 files changed, 2744 insertions(+), 1263 deletions(-) --- base-commit: 30daaf3e7897b4a8d9b72e5b0c86dd6e2a4d7d85 change-id: 20261104-submit-rawnand-retained-handle-lifetime-v1-0b4225e5ce0b prerequisite-patch-id: a51b9cb4077105499133c413d58c7ad21d973b38 prerequisite-patch-id: b3679cda4dcb45ce7712bffe2dd0576b254df44d prerequisite-patch-id: 07b5c70e44ad951d20eea9478c98fda35ec765c0 prerequisite-patch-id: abea50275922fe359d72ca4de5cbc211b04bbd57 prerequisite-patch-id: 57776b214ffb0331319f024412f21d35e4ca9056 prerequisite-patch-id: 09be2baaffe1f053704263cc4b0d39f2faa4f49c prerequisite-patch-id: c3ad85600dc897ac310be450d8daa2275fb91ee6 prerequisite-patch-id: 4a85600553ddcc7db5a9537efd905a71cd623f65 prerequisite-patch-id: 579990ee4a49297efc5a593b00efb9cd73fa15e8 prerequisite-patch-id: 2ee61a8a32fd147d52e0f9d03758634912d8bfef prerequisite-patch-id: 1487df8ce8e6c48471fd77c7470ce9de582dfe3c prerequisite-patch-id: 5ecbe86f928d9c5c0bf2cb6065c5672708511fc4 prerequisite-patch-id: ac68e9b65d3aa5661bd7ac0f2e77dcf5c75fcfe0 prerequisite-patch-id: e70f0f0c4d430d416a3ad848b37ffad16bd7df07 prerequisite-patch-id: 05adcddbc50f745ee2640b8c21f3bf76a217f249 prerequisite-patch-id: 0b60b7ab6196076f327c919be5e7b8bb2051ee12 Best regards, -- James Hilliard