Re: [PATCH] mfd: core: Remove software node after unregistering platform device
From: Andy Shevchenko
Date: Fri Dec 04 2026 - 14:47:38 EST
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@xxxxxxxxx/
I Cc'ed people from that thread. Meanwhile, can you test the proposed series
and confirm if it fixes your issue or not?
--
With Best Regards,
Andy Shevchenko