devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] fix DT overlays when device links are released
@ 2024-02-02 12:18 Nuno Sa via B4 Relay
  2024-02-02 12:18 ` [PATCH 1/2] driver: core: add dedicated workqueue for devlink removal Nuno Sa via B4 Relay
  2024-02-02 12:18 ` [PATCH 2/2] of: dynamic: flush devlinks workqueue before destroying the changeset Nuno Sa via B4 Relay
  0 siblings, 2 replies; 7+ messages in thread
From: Nuno Sa via B4 Relay @ 2024-02-02 12:18 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Frank Rowand, Rob Herring,
	Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Len Brown
  Cc: linux-acpi, devicetree, linux-kernel

Link to RFC:
 * https://lore.kernel.org/lkml/20240123-fix-device-links-overlays-v1-1-9e4f6acaab6c@analog.com/

Changes since RFC:
 * Use a dedicated workqueue to remove devlinks;
 * Flush the devlink workqueue before checking the of_node refcount
   value.

The following series is the result of the discussion I had with Rafael.
To sum up the fundamental issue, device links drop their refcounts
asynchronously and that means that the of_node refcount associated with
the device will also be dropped asynchronously. Now, in
__of_changeset_entry_destroy(), the assumption is that the node refcount
must be 1 and that cannot be guaranteed given the above.

I'm pasting again the link of the first time I exposed the issue where
one can see the resulps (big splat) of failing DT assumption:

https://lore.kernel.org/linux-devicetree/20230511151047.1779841-1-nuno.sa@analog.com/

---
Nuno Sa (2):
      driver: core: add dedicated workqueue for devlink removal
      of: dynamic: flush devlinks workqueue before destroying the changeset

 drivers/base/core.c    | 33 +++++++++++++++++++++++++++++----
 drivers/of/dynamic.c   |  8 ++++++++
 include/linux/fwnode.h |  1 +
 3 files changed, 38 insertions(+), 4 deletions(-)
---
base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d
change-id: 20240123-fix-device-links-overlays-5422e033a09b
--

Thanks!
- Nuno Sá


^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] driver: core: add dedicated workqueue for devlink removal
@ 2024-02-05 13:55 Andy Shevchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-02-05 13:55 UTC (permalink / raw)
  To: nuno.sa
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Frank Rowand, Rob Herring,
	Daniel Scally, Heikki Krogerus, Sakari Ailus, Len Brown,
	linux-acpi, devicetree, linux-kernel


On Fri, Feb 02, 2024 at 01:18:16PM +0100, Nuno Sa via B4 Relay wrote:
> From: Nuno Sa <nuno.sa@analog.com>
> 
> Let's use a dedicated queue for devlinks since releasing a link happens
> asynchronously but some code paths, like DT overlays, have some
> expectations regarding the of_node when being removed (the refcount must
> be 1). Given how devlinks are released that cannot be assured. Hence, add a
> dedicated queue so that it's easy to sync against devlinks removal.
> 
> While at it, make sure to explicitly include <linux/workqueue.h>.

...

> --- a/include/linux/fwnode.h
> +++ b/include/linux/fwnode.h
> @@ -213,5 +213,6 @@ extern bool fw_devlink_is_strict(void);
>  int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup);
>  void fwnode_links_purge(struct fwnode_handle *fwnode);
>  void fw_devlink_purge_absent_suppliers(struct fwnode_handle *fwnode);
> +void fwnode_links_flush_queue(void);

Can it be grouped like

  void fwnode_links_flush_queue(void);
  void fwnode_links_purge(struct fwnode_handle *fwnode);
  void fw_devlink_purge_absent_suppliers(struct fwnode_handle *fwnode);

?

(devlinks namespaces seems a bit messy to me, but I'm not familiar with that
 code at all)

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-02-05 13:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-02 12:18 [PATCH 0/2] fix DT overlays when device links are released Nuno Sa via B4 Relay
2024-02-02 12:18 ` [PATCH 1/2] driver: core: add dedicated workqueue for devlink removal Nuno Sa via B4 Relay
2024-02-02 15:59   ` Rafael J. Wysocki
2024-02-05  8:29     ` Nuno Sá
2024-02-05 13:36       ` Rafael J. Wysocki
2024-02-02 12:18 ` [PATCH 2/2] of: dynamic: flush devlinks workqueue before destroying the changeset Nuno Sa via B4 Relay
  -- strict thread matches above, loose matches on Subject: below --
2024-02-05 13:55 [PATCH 1/2] driver: core: add dedicated workqueue for devlink removal Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).