From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796415123; b=xmbN7MJYtmjIBLqbX6pBB3Ev9rcodUX752oc4kskY2+EbGFqittlVGb+5s8Pg+H3VrHg ag4BeIIPHaa3sVSxdxxus1EjU4As9WhKFDQ51KoBHp+m1Hqa5lSyHlKbV3gkWWgkeqQjI fwF1zW/kEJ9rqxkbulivIxRDVHNvGdoHzM2HluxymFm46Bc5v7/iH0ZaDJhofFi5T0XvC c3NyKjWF+aADoltSxOFkazPteaegB77KN7xLHagvhJrAylD1j9xDLNUpZqLB0TSZ2329A IM0PXaWFFDu1aQ6vQbT3PAY7qDL5IbYcw9n3XP+j987oJmPgv+LM2p5BFXOyvhd7dtA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796415123; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding: Content-Disposition; bh=On5q+gkZsDbLqUTUkQHVABiP/IAaziuPDHbbOJ9z8KQ=; b=BKAoN/rWypsmNljyJkIAZW6BOvR2GWKQjkAj3yvsz5ZFSUY6uaRP8AYG279+MrCIoih7 ZzPUfQpKrxBvd3QDC2aFWG0csWfM2qNXFQg2MrAh9XMplrFLtCHvl9o6XK5OAMWpV0zhq Q68Zk42e3o5HmbS3bDzIOQRZi3mdUOFeHcyhxIP2xMXlMiV06t7wRbOh/WdFuw6j+dG43 CvIL+68NrRInpwZou5xiiyvpu1yA9SwX68wXE+ymmsh2Ln6VpJAe+uxUZPxGFxZz7sbAo Lne+/Vk67SaWFIR+AuNx5ltBy5VgmP4jHKNo/vCxh5X23WMg0MAORYMk+n4nyTvLaKg== 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=Gv0hkkgI; arc=none smtp.remote-ip=74.125.82.49 Received: from mail-dl1-f49.google.com (mail-dl1-f49.google.com [74.125.82.49]) (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 7CB02606A336 for ; Fri, 4 Dec 2026 20:12:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7CB02606A336 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 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=Gv0hkkgI Received: by mail-dl1-f49.google.com with SMTP id a92af1059eb24-1a2af4c8d00so701323c88.0 for ; Fri, 04 Dec 2026 12:12:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796415123; x=1797019923; darn=vger.kernel.org; h=content-disposition:content-transfer-encoding:content-type :mime-version:references:in-reply-to:subject:cc:to:from:message-id :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=On5q+gkZsDbLqUTUkQHVABiP/IAaziuPDHbbOJ9z8KQ=; b=Gv0hkkgIUZ7C+lj6oVH+UjEggzz3VUyh6XE+CnZeBJk+iUhMtWGXO9nu5QC4Ia2vJu QsqwuMRcUB1fpPjEDR15slm40SMGJMpg8TQvOxmGvAe8lPba5AIfgSCnC5pC8LoxxuZR beRFwlAumS3MOu9/52z+8SQ22mwHBOmSytWyYKijjKJqKm92icZKDERZS3JaCI3xpDe6 wMqAq+uKQeTzfPWtukGvLxVnxywO3b5oJNDTe1uNBhF4Z5C+1VF3ZBu+zdQRlXl6Mu04 wuka0Pyv0hfXUbEdCvNRk0EgfgijChEqRcJ9cWb6vg29OG2APUF3cQk/yP9W4PJjhL6M kFsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796415123; x=1797019923; h=content-disposition:content-transfer-encoding:content-type :mime-version:references:in-reply-to:subject:cc:to:from:message-id :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=On5q+gkZsDbLqUTUkQHVABiP/IAaziuPDHbbOJ9z8KQ=; b=N6cAm52j+bC/a3eaf4i/jStC5apT8YY/Fk9DsGfUQABgkdNeXQxcpByTKnolL7KF+2 4HRSpdHim0CpKMGHjbykLOgDJgUGQdVDrND4xUgUfdlFz9K1ayzcGAgxzdqtANMfRYmH Mnb5/A2jN8XVHI6fu04GuwIEo3v7O3+c+VVPKS67DFOE78MrqC1R0SqFk9UNgC9uWsZ9 ercnFeYWVRLi1UixO83cv7ERnP+1Bt7JXXS8VMl233X0+bjLiqATKBbcfwXc6nJzzzSs duDpGehV9h6etOFItcDmdk5HtqXww7fZ6tLuo/aOpPjQ9AJD8JPySdS08y8DznatcP3m ZW5w== X-Forwarded-Encrypted: i=1; AL+hErHgqZaEc/85UCHdhDpURoTFFrcCLP+VJvUS47o9zCHVmPaOf2EXbrkJCCLs1HEOEC95AOU6ur+bgS1OTAM=@vger.kernel.org X-Gm-Message-State: APuU4Z/tcjDIMUbeVk0yusdDSVIo+Z+mH2l4PVB3MDRhDHX7HMBVqwNC GPXnVLj3Nxh3eJ1v+Bntf1OWzYhcvbcGNa33bvrjFfqRkHhL8LNkgpbn X-Gm-Gg: AZFdTZcWJd2LbYDTYDvUcnlYPPUa5oQoB4zUcPOjOzknTKsZ6h96Pz2FrIO4AgB35UY 0WoO7ohY83ZkgkavSi/A501WjCMy4ZrpIj2pbl8dK9lcxDskzDwXN8EAVKV64W9HQ2NcniOlUDX 6UUSOBUA30WK2vInaOi19RZw0m1vLi6EMn4aUTCKZ2eEJ7uPKJgf+Bl4ibkVoS593k73UubBzaM klbd9qiHfQM5KuzFC1bakuSC9L4J8dB+e+WICCrqkG1QWhbdT0C8/ASG56SH0wPV84BNMGsko+D OglN1ObjtA/9fNNefSVmkngFA4c39JjGZD2yVeXQ0u7p9ztgDtz3X4/VfCPYWnK6Kh6bP+6mnll A1NfR59rbYEvdaGiUAQXHtBE/rBk3aI7+C6gr9P9XPkfda77k32pFAW5kONHAkWnO89xVsqN9SI edWK9CePzwT6wXNndG/A3HvvOY23SEeLvq2nrq0hbBuQ+68Ob5MsPM/Xh2e46LR6wgZLGi4w8P3 PL749uSLzf7GHWwy9LhEtEzInlQ6o8dJRzquZgzTBvz0Mtbw86vw7RDxTqRK3vzkPZaA139sUjZ Ch1GuVxEu1QK2lRTo9IS7gL3wl2+6GKUccYHwa+HAizf813vAn5dGITKJnmJnyXjsrYWmw== X-Received: by 2002:a05:701b:4204:10b0:168:3243:c911 with SMTP id a92af1059eb24-1b5d7233433mr2956544c88.37.1796415122375; Fri, 04 Dec 2026 12:12:02 -0800 (PST) Received: from localhost ([2a00:79e0:2ebe:8:17a1:4895:5021:5d36]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5d644109esm10344603c88.8.2026.12.04.12.12.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 12:12:01 -0800 (PST) Date: Fri, 04 Dec 2026 12:12:00 -0800 Message-ID: <8d70cb6010e7451c7ddbbfc448abd424@gmail.com> From: Dmitry Torokhov To: Andy Shevchenko , Cesar Cibrian Cc: Lee Jones , mfd@lists.linux.dev, Heikki Krogerus , linux-i2c@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Danilo Krummrich , Bartosz Golaszewski , Johan Hovold Subject: Re: [PATCH] mfd: core: Remove software node after unregistering platform device In-Reply-To: References: <20261204181605.22364-1-cesarcibrian.ai@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Andy, On Fri, Dec 04, 2026 at 09:47:14PM +0200, Andy Shevchenko wrote: > On Fri, Dec 04, 2026 at 10:16:05AM -0800, Cesar Cibrian wrote: > > mfd_add_device() attaches cell->swnode before calling > > platform_device_add(), but mfd_remove_devices_fn() calls > > device_remove_software_node() before platform_device_unregister(). > > > > If the child driver propagates dev_fwnode() to a sub-device (for > > example, i2c-designware sharing its fwnode with the i2c_adapter > > device on Intel LPSS), removing the software node first clears > > fwnode->secondary while the sub-device is still registered. When > > platform_device_unregister() subsequently tears down the child, > > software_node_notify_remove() sees dev_to_swnode() == NULL on the > > sub-device and skips cleanup, leaking a swnode reference and > > leaving a stale sysfs symlink that triggers a warning on rebind: > > > > sysfs: cannot create duplicate filename '/kernel/software_nodes/node0/i2c-0' > > > > Move device_remove_software_node() after platform_device_unregister() > > (device_for_each_child_reverse() holds a reference on dev throughout > > mfd_remove_devices_fn()). Because acpi_unbind_one() calls > > set_primary_fwnode(dev, NULL), which skips clearing fn->secondary > > when fn == dev->parent->fwnode, also clear the parent's secondary > > fwnode when the child shared its parent's fwnode so rebinding does > > not fail with -EBUSY. > > I believe it's a local hack against bigger issue which is discussed here > https://lore.kernel.org/lkml/20261202-swnode-shared-primary-fix-v1-0-7ff23caaa1ed@gmail.com/ > > I Cc'ed people from that thread. Meanwhile, can you test the proposed series > and confirm if it fixes your issue or not? My series will not fix this on its own. We still need to reorder software node removal so it stays intact while child devices are being torn down. What my series does fix is the shared_fwnode/set_secondary_fwnode() workaround in this patch. Once device_del() unbinds the driver first and tears down i2c_adapter while the secondary link is intact, set_primary_fwnode(&pdev->dev, NULL) sees that pdev->dev attached the secondary node, moves it onto pdev->dev.fwnode, and clears fn->secondary automatically. Also, on non-ACPI shared primary nodes where acpi_unbind_one() does not run, clearing dev->parent's secondary fwnode before calling device_remove_software_node(&pdev->dev) makes dev_to_swnode(&pdev->dev) return NULL and actually leaks cell->swnode's reference. Thanks. -- Dmitry