On Wed, May 5, 2021 at 12:07 PM Hans de Goede <hdegoede@xxxxxxxxxx> wrote: > On 5/4/21 9:52 AM, Andy Shevchenko wrote: > > On Monday, May 3, 2021, Hans de Goede <hdegoede@xxxxxxxxxx <mailto:hdegoede@xxxxxxxxxx>> wrote: ... > > + fwnode = device_get_next_child_node(kdev, fwnode); > > Who is dropping reference counting on fwnode ? > > We are dealing with ACPI fwnode-s here and those are not ref-counted, they > are embedded inside a struct acpi_device and their lifetime is tied to > that struct. They should probably still be ref-counted (with the count > never dropping to 0) so that the generic fwnode functions behave the same > anywhere but atm the ACPI nodes are not refcounted, see: acpi_get_next_subnode() > in drivers/acpi/property.c which is the get_next_child_node() implementation > for ACPI fwnode-s. Yes, ACPI currently is exceptional, but fwnode API is not. If you may guarantee that this case won't ever be outside of ACPI and even though if ACPI won't ever gain a reference counting for fwnodes, we can leave it as is. > > I’m in the middle of a pile of fixes for fwnode refcounting when for_each_child or get_next_child is used. So, please double check you drop a reference. > > The kdoc comments on device_get_next_child_node() / fwnode_get_next_child_node() > do not mention anything about these functions returning a reference. It's possible. I dunno if it had to be done earlier. Sakari? > So I think we need to first make up our mind here how we want this all to > work and then fix the actual implementation and docs before fixing callers. We have already issues, so I prefer not to wait for a documentation update, because for old kernels it will still be an issue. In any case most of my fixes are against LED subsystem (drivers) and they are valid due to use in the OF environment. -- With Best Regards, Andy Shevchenko