[PATCH v2] mfd: core: Preserve OF node when ACPI handle is present

Brian Mak posted 1 patch 1 month, 1 week ago
There is a newer version of this series
drivers/mfd/mfd-core.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
[PATCH v2] mfd: core: Preserve OF node when ACPI handle is present
Posted by Brian Mak 1 month, 1 week ago
Switch device_set_node to set_primary_fwnode, so that the ACPI fwnode
does not overwrite the of_node with NULL.

This allows MFD children with both OF nodes and ACPI handles to have OF
nodes again.

Fixes: 51e3b257099d ("mfd: core: Make use of device_set_node()")
Cc: stable@vger.kernel.org
Signed-off-by: Brian Mak <makb@juniper.net>
---
 drivers/mfd/mfd-core.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index 6be58eb5a746..5c5465763312 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -88,7 +88,20 @@ static void mfd_acpi_add_device(const struct mfd_cell *cell,
 		}
 	}
 
-	device_set_node(&pdev->dev, acpi_fwnode_handle(adev ?: parent));
+	/*
+	 * FIXME: The fwnode design doesn't allow proper stacking/sharing. This
+	 * should eventually turn into a device fwnode API call that will allow
+	 * prepending to a list of fwnodes (with ACPI taking precedence).
+	 *
+	 * set_primary_fwnode() is used here, instead of device_set_node(), as
+	 * device_set_node() will overwrite the existing fwnode, which may be an
+	 * OF node that was populated earlier. To support a use case where ACPI
+	 * and OF is used in conjunction, we call set_primary_fwnode() instead.
+	 */
+	if (adev)
+		set_primary_fwnode(&pdev->dev, acpi_fwnode_handle(adev));
+	else
+		set_primary_fwnode(&pdev->dev, acpi_fwnode_handle(parent));
 }
 #else
 static inline void mfd_acpi_add_device(const struct mfd_cell *cell,

base-commit: d9d32e5bd5a4e57675f2b70ddf73c3dc5cf44fc2
-- 
2.25.1
Re: [PATCH v2] mfd: core: Preserve OF node when ACPI handle is present
Posted by Lee Jones 1 month ago
On Thu, 26 Feb 2026, Brian Mak wrote:

> Switch device_set_node to set_primary_fwnode, so that the ACPI fwnode
> does not overwrite the of_node with NULL.
> 
> This allows MFD children with both OF nodes and ACPI handles to have OF
> nodes again.
> 
> Fixes: 51e3b257099d ("mfd: core: Make use of device_set_node()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Brian Mak <makb@juniper.net>
> ---
>  drivers/mfd/mfd-core.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
> index 6be58eb5a746..5c5465763312 100644
> --- a/drivers/mfd/mfd-core.c
> +++ b/drivers/mfd/mfd-core.c
> @@ -88,7 +88,20 @@ static void mfd_acpi_add_device(const struct mfd_cell *cell,
>  		}
>  	}
>  
> -	device_set_node(&pdev->dev, acpi_fwnode_handle(adev ?: parent));
> +	/*
> +	 * FIXME: The fwnode design doesn't allow proper stacking/sharing. This

So when will this be fixed exactly?

> +	 * should eventually turn into a device fwnode API call that will allow
> +	 * prepending to a list of fwnodes (with ACPI taking precedence).
> +	 *
> +	 * set_primary_fwnode() is used here, instead of device_set_node(), as
> +	 * device_set_node() will overwrite the existing fwnode, which may be an
> +	 * OF node that was populated earlier. To support a use case where ACPI
> +	 * and OF is used in conjunction, we call set_primary_fwnode() instead.
> +	 */
> +	if (adev)
> +		set_primary_fwnode(&pdev->dev, acpi_fwnode_handle(adev));
> +	else
> +		set_primary_fwnode(&pdev->dev, acpi_fwnode_handle(parent));
>  }
>  #else
>  static inline void mfd_acpi_add_device(const struct mfd_cell *cell,
> 
> base-commit: d9d32e5bd5a4e57675f2b70ddf73c3dc5cf44fc2
> -- 
> 2.25.1
> 

-- 
Lee Jones [李琼斯]
Re: [PATCH v2] mfd: core: Preserve OF node when ACPI handle is present
Posted by Andy Shevchenko 1 month ago
On Fri, Mar 06, 2026 at 01:38:06PM +0000, Lee Jones wrote:
> On Thu, 26 Feb 2026, Brian Mak wrote:

...

> > +	/*
> > +	 * FIXME: The fwnode design doesn't allow proper stacking/sharing. This
> 
> So when will this be fixed exactly?

I don't know, it's a huge task that requires of redesigning how struct
fwnode_handle looks like and how it cohabits with struct device. Do you
you think that NOTE will be more appropriate, because it may span several
releases.

> > +	 * should eventually turn into a device fwnode API call that will allow
> > +	 * prepending to a list of fwnodes (with ACPI taking precedence).
> > +	 *
> > +	 * set_primary_fwnode() is used here, instead of device_set_node(), as
> > +	 * device_set_node() will overwrite the existing fwnode, which may be an
> > +	 * OF node that was populated earlier. To support a use case where ACPI
> > +	 * and OF is used in conjunction, we call set_primary_fwnode() instead.
> > +	 */
> > +	if (adev)
> > +		set_primary_fwnode(&pdev->dev, acpi_fwnode_handle(adev));
> > +	else
> > +		set_primary_fwnode(&pdev->dev, acpi_fwnode_handle(parent));
> >  }

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v2] mfd: core: Preserve OF node when ACPI handle is present
Posted by Lee Jones 4 weeks ago
On Fri, 06 Mar 2026, Andy Shevchenko wrote:

> On Fri, Mar 06, 2026 at 01:38:06PM +0000, Lee Jones wrote:
> > On Thu, 26 Feb 2026, Brian Mak wrote:
> 
> ...
> 
> > > +	/*
> > > +	 * FIXME: The fwnode design doesn't allow proper stacking/sharing. This
> > 
> > So when will this be fixed exactly?
> 
> I don't know, it's a huge task that requires of redesigning how struct
> fwnode_handle looks like and how it cohabits with struct device. Do you
> you think that NOTE will be more appropriate, because it may span several
> releases.

If someone is going to do the work sometime in the near future, it can
stay as FIXME.  A few releases isn't going to offend anyone.  However,
if we're just going to sit on it and this is likely to be here for an
elongated period, it should be changed.

Any idea who is planning on working on it?

-- 
Lee Jones [李琼斯]
Re: [PATCH v2] mfd: core: Preserve OF node when ACPI handle is present
Posted by Andy Shevchenko 4 weeks ago
On Tue, Mar 10, 2026 at 09:21:48AM +0000, Lee Jones wrote:
> On Fri, 06 Mar 2026, Andy Shevchenko wrote:
> > On Fri, Mar 06, 2026 at 01:38:06PM +0000, Lee Jones wrote:
> > > On Thu, 26 Feb 2026, Brian Mak wrote:

...

> > > > +	/*
> > > > +	 * FIXME: The fwnode design doesn't allow proper stacking/sharing. This
> > > 
> > > So when will this be fixed exactly?
> > 
> > I don't know, it's a huge task that requires of redesigning how struct
> > fwnode_handle looks like and how it cohabits with struct device. Do you
> > you think that NOTE will be more appropriate, because it may span several
> > releases.
> 
> If someone is going to do the work sometime in the near future, it can
> stay as FIXME.  A few releases isn't going to offend anyone.  However,
> if we're just going to sit on it and this is likely to be here for an
> elongated period, it should be changed.

Then better to be just a NOTE:.

> Any idea who is planning on working on it?

I am not sure anyone is planning on working on this in the near future.
We see the problem, but it hasn't hit someone's work too much to become
a showstopper (some workarounds, or not fully correct, but acceptable
behaviour was a way out so far).

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v2] mfd: core: Preserve OF node when ACPI handle is present
Posted by Brian Mak 3 weeks, 5 days ago
On Mar 10, 2026, at 3:25 AM, Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> On Tue, Mar 10, 2026 at 09:21:48AM +0000, Lee Jones wrote:
>> On Fri, 06 Mar 2026, Andy Shevchenko wrote:
> ...
>> If someone is going to do the work sometime in the near future, it can
>> stay as FIXME.  A few releases isn't going to offend anyone.  However,
>> if we're just going to sit on it and this is likely to be here for an
>> elongated period, it should be changed.
> 
> Then better to be just a NOTE:.

Ok, should I raise a v3 patch, or can this just be changed when applied?
I'm okay either way.

Thanks,
Brian
Re: [PATCH v2] mfd: core: Preserve OF node when ACPI handle is present
Posted by Andy Shevchenko 3 weeks, 5 days ago
On Wed, Mar 11, 2026 at 05:00:45PM +0000, Brian Mak wrote:
> On Mar 10, 2026, at 3:25 AM, Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> > On Tue, Mar 10, 2026 at 09:21:48AM +0000, Lee Jones wrote:
> >> On Fri, 06 Mar 2026, Andy Shevchenko wrote:

...

> >> If someone is going to do the work sometime in the near future, it can
> >> stay as FIXME.  A few releases isn't going to offend anyone.  However,
> >> if we're just going to sit on it and this is likely to be here for an
> >> elongated period, it should be changed.
> > 
> > Then better to be just a NOTE:.
> 
> Ok, should I raise a v3 patch, or can this just be changed when applied?
> I'm okay either way.

It's better to have a v3 with a clear changelog why it has been changed
(changelog, not part a commit message).

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v2] mfd: core: Preserve OF node when ACPI handle is present
Posted by Andy Shevchenko 1 month, 1 week ago
On Thu, Feb 26, 2026 at 02:45:11PM -0800, Brian Mak wrote:
> Switch device_set_node to set_primary_fwnode, so that the ACPI fwnode
> does not overwrite the of_node with NULL.
> 
> This allows MFD children with both OF nodes and ACPI handles to have OF
> nodes again.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

-- 
With Best Regards,
Andy Shevchenko