linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type
@ 2020-10-22 18:40 Andy Shevchenko
  2020-10-22 18:41 ` [PATCH v1 2/2] device property: Don't clear secondary pointer for shared primary firmware node Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Andy Shevchenko @ 2020-10-22 18:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel, Saravana Kannan, linux-acpi,
	Rafael J. Wysocki, Heikki Krogerus
  Cc: Andy Shevchenko, Ferry Toth

Behind primary and secondary we understand the type of the nodes
which might define their ordering. However, if primary node gone,
we can't maintain the ordering by definition of the linked list.
Thus, by ordering secondary node becomes first in the list.
But in this case the meaning of it is still secondary (or auxiliary).
The type of the node is maintained by the secondary pointer in it:

	secondary pointer		Meaning
	NULL or valid			primary node
	ERR_PTR(-ENODEV)		secondary node

So, if by some reason we do the following sequence of calls

	set_primary_fwnode(dev, NULL);
	set_primary_fwnode(dev, primary);

we should preserve secondary node.

This concept is supported by the description of set_primary_fwnode()
along with implementation of set_secondary_fwnode(). Hence, fix
the commit c15e1bdda436 to follow this as well.

Fixes: c15e1bdda436 ("device property: Fix the secondary firmware node handling in set_primary_fwnode()")
Cc: Ferry Toth <fntoth@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index c852f16c111b..41feab679fa1 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -4278,7 +4278,7 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
 	} else {
 		if (fwnode_is_primary(fn)) {
 			dev->fwnode = fn->secondary;
-			fn->secondary = NULL;
+			fn->secondary = ERR_PTR(-ENODEV);
 		} else {
 			dev->fwnode = NULL;
 		}
-- 
2.28.0


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

* [PATCH v1 2/2] device property: Don't clear secondary pointer for shared primary firmware node
  2020-10-22 18:40 [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type Andy Shevchenko
@ 2020-10-22 18:41 ` Andy Shevchenko
  2020-10-23 12:35   ` Heikki Krogerus
  2020-10-23 12:34 ` [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type Heikki Krogerus
  2020-10-27 18:21 ` Rafael J. Wysocki
  2 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2020-10-22 18:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel, Saravana Kannan, linux-acpi,
	Rafael J. Wysocki, Heikki Krogerus
  Cc: Andy Shevchenko, Ferry Toth

It appears that firmware nodes can be shared between devices. In such case
when a (child) device is about to be deleted, its firmware node may be shared
and ACPI_COMPANION_SET(..., NULL) call for it breaks the secondary link
of the shared primary firmware node.

In order to prevent that, check, if the device has a parent and parent's
firmware node is shared with its child, and avoid crashing the link.

Fixes: c15e1bdda436 ("device property: Fix the secondary firmware node handling in set_primary_fwnode()")
Reported-by: Ferry Toth <fntoth@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 41feab679fa1..78114ddac755 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -4264,6 +4264,7 @@ static inline bool fwnode_is_primary(struct fwnode_handle *fwnode)
  */
 void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
 {
+	struct device *parent = dev->parent;
 	struct fwnode_handle *fn = dev->fwnode;
 
 	if (fwnode) {
@@ -4278,7 +4279,8 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
 	} else {
 		if (fwnode_is_primary(fn)) {
 			dev->fwnode = fn->secondary;
-			fn->secondary = ERR_PTR(-ENODEV);
+			if (!(parent && fn == parent->fwnode))
+				fn->secondary = ERR_PTR(-ENODEV);
 		} else {
 			dev->fwnode = NULL;
 		}
-- 
2.28.0


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

* Re: [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type
  2020-10-22 18:40 [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type Andy Shevchenko
  2020-10-22 18:41 ` [PATCH v1 2/2] device property: Don't clear secondary pointer for shared primary firmware node Andy Shevchenko
@ 2020-10-23 12:34 ` Heikki Krogerus
  2020-10-23 14:16   ` Ferry Toth
       [not found]   ` <ef59c911-8d8b-783a-c756-05123f428302@gmail.com>
  2020-10-27 18:21 ` Rafael J. Wysocki
  2 siblings, 2 replies; 9+ messages in thread
From: Heikki Krogerus @ 2020-10-23 12:34 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, linux-kernel, Saravana Kannan, linux-acpi,
	Rafael J. Wysocki, Ferry Toth

On Thu, Oct 22, 2020 at 09:40:59PM +0300, Andy Shevchenko wrote:
> Behind primary and secondary we understand the type of the nodes
> which might define their ordering. However, if primary node gone,
> we can't maintain the ordering by definition of the linked list.
> Thus, by ordering secondary node becomes first in the list.
> But in this case the meaning of it is still secondary (or auxiliary).
> The type of the node is maintained by the secondary pointer in it:
> 
> 	secondary pointer		Meaning
> 	NULL or valid			primary node
> 	ERR_PTR(-ENODEV)		secondary node
> 
> So, if by some reason we do the following sequence of calls
> 
> 	set_primary_fwnode(dev, NULL);
> 	set_primary_fwnode(dev, primary);
> 
> we should preserve secondary node.
> 
> This concept is supported by the description of set_primary_fwnode()
> along with implementation of set_secondary_fwnode(). Hence, fix
> the commit c15e1bdda436 to follow this as well.
> 
> Fixes: c15e1bdda436 ("device property: Fix the secondary firmware node handling in set_primary_fwnode()")
> Cc: Ferry Toth <fntoth@gmail.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

FWIW:

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/base/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index c852f16c111b..41feab679fa1 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -4278,7 +4278,7 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
>  	} else {
>  		if (fwnode_is_primary(fn)) {
>  			dev->fwnode = fn->secondary;
> -			fn->secondary = NULL;
> +			fn->secondary = ERR_PTR(-ENODEV);
>  		} else {
>  			dev->fwnode = NULL;
>  		}
> -- 
> 2.28.0

-- 
heikki

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

* Re: [PATCH v1 2/2] device property: Don't clear secondary pointer for shared primary firmware node
  2020-10-22 18:41 ` [PATCH v1 2/2] device property: Don't clear secondary pointer for shared primary firmware node Andy Shevchenko
@ 2020-10-23 12:35   ` Heikki Krogerus
  2020-10-23 14:03     ` Ferry Toth
  2020-10-23 14:16     ` Ferry Toth
  0 siblings, 2 replies; 9+ messages in thread
From: Heikki Krogerus @ 2020-10-23 12:35 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, linux-kernel, Saravana Kannan, linux-acpi,
	Rafael J. Wysocki, Ferry Toth

On Thu, Oct 22, 2020 at 09:41:00PM +0300, Andy Shevchenko wrote:
> It appears that firmware nodes can be shared between devices. In such case
> when a (child) device is about to be deleted, its firmware node may be shared
> and ACPI_COMPANION_SET(..., NULL) call for it breaks the secondary link
> of the shared primary firmware node.
> 
> In order to prevent that, check, if the device has a parent and parent's
> firmware node is shared with its child, and avoid crashing the link.
> 
> Fixes: c15e1bdda436 ("device property: Fix the secondary firmware node handling in set_primary_fwnode()")
> Reported-by: Ferry Toth <fntoth@gmail.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

FWIW:

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/base/core.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 41feab679fa1..78114ddac755 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -4264,6 +4264,7 @@ static inline bool fwnode_is_primary(struct fwnode_handle *fwnode)
>   */
>  void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
>  {
> +	struct device *parent = dev->parent;
>  	struct fwnode_handle *fn = dev->fwnode;
>  
>  	if (fwnode) {
> @@ -4278,7 +4279,8 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
>  	} else {
>  		if (fwnode_is_primary(fn)) {
>  			dev->fwnode = fn->secondary;
> -			fn->secondary = ERR_PTR(-ENODEV);
> +			if (!(parent && fn == parent->fwnode))
> +				fn->secondary = ERR_PTR(-ENODEV);
>  		} else {
>  			dev->fwnode = NULL;
>  		}
> -- 
> 2.28.0

-- 
heikki

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

* Re: [PATCH v1 2/2] device property: Don't clear secondary pointer for shared primary firmware node
  2020-10-23 12:35   ` Heikki Krogerus
@ 2020-10-23 14:03     ` Ferry Toth
  2020-10-23 14:16     ` Ferry Toth
  1 sibling, 0 replies; 9+ messages in thread
From: Ferry Toth @ 2020-10-23 14:03 UTC (permalink / raw)
  To: Heikki Krogerus, Andy Shevchenko
  Cc: Greg Kroah-Hartman, linux-kernel, Saravana Kannan, linux-acpi,
	Rafael J. Wysocki

Hi

Op 23-10-2020 om 14:35 schreef Heikki Krogerus:
> On Thu, Oct 22, 2020 at 09:41:00PM +0300, Andy Shevchenko wrote:
>> It appears that firmware nodes can be shared between devices. In such case
>> when a (child) device is about to be deleted, its firmware node may be shared
>> and ACPI_COMPANION_SET(..., NULL) call for it breaks the secondary link
>> of the shared primary firmware node.
>>
>> In order to prevent that, check, if the device has a parent and parent's
>> firmware node is shared with its child, and avoid crashing the link.
>>
>> Fixes: c15e1bdda436 ("device property: Fix the secondary firmware node handling in set_primary_fwnode()")
>> Reported-by: Ferry Toth <fntoth@gmail.com>
>> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> FWIW:
>
> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

Tested-by: Ferry Toth <fntoth@gmail.com>

>> ---
>>   drivers/base/core.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/base/core.c b/drivers/base/core.c
>> index 41feab679fa1..78114ddac755 100644
>> --- a/drivers/base/core.c
>> +++ b/drivers/base/core.c
>> @@ -4264,6 +4264,7 @@ static inline bool fwnode_is_primary(struct fwnode_handle *fwnode)
>>    */
>>   void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
>>   {
>> +	struct device *parent = dev->parent;
>>   	struct fwnode_handle *fn = dev->fwnode;
>>   
>>   	if (fwnode) {
>> @@ -4278,7 +4279,8 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
>>   	} else {
>>   		if (fwnode_is_primary(fn)) {
>>   			dev->fwnode = fn->secondary;
>> -			fn->secondary = ERR_PTR(-ENODEV);
>> +			if (!(parent && fn == parent->fwnode))
>> +				fn->secondary = ERR_PTR(-ENODEV);
>>   		} else {
>>   			dev->fwnode = NULL;
>>   		}
>> -- 
>> 2.28.0

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

* Re: [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type
  2020-10-23 12:34 ` [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type Heikki Krogerus
@ 2020-10-23 14:16   ` Ferry Toth
       [not found]   ` <ef59c911-8d8b-783a-c756-05123f428302@gmail.com>
  1 sibling, 0 replies; 9+ messages in thread
From: Ferry Toth @ 2020-10-23 14:16 UTC (permalink / raw)
  To: Heikki Krogerus, Andy Shevchenko
  Cc: Greg Kroah-Hartman, linux-kernel, Saravana Kannan, linux-acpi,
	Rafael J. Wysocki

Hi

Op 23-10-2020 om 14:34 schreef Heikki Krogerus:
> On Thu, Oct 22, 2020 at 09:40:59PM +0300, Andy Shevchenko wrote:
>> Behind primary and secondary we understand the type of the nodes
>> which might define their ordering. However, if primary node gone,
>> we can't maintain the ordering by definition of the linked list.
>> Thus, by ordering secondary node becomes first in the list.
>> But in this case the meaning of it is still secondary (or auxiliary).
>> The type of the node is maintained by the secondary pointer in it:
>>
>> 	secondary pointer		Meaning
>> 	NULL or valid			primary node
>> 	ERR_PTR(-ENODEV)		secondary node
>>
>> So, if by some reason we do the following sequence of calls
>>
>> 	set_primary_fwnode(dev, NULL);
>> 	set_primary_fwnode(dev, primary);
>>
>> we should preserve secondary node.
>>
>> This concept is supported by the description of set_primary_fwnode()
>> along with implementation of set_secondary_fwnode(). Hence, fix
>> the commit c15e1bdda436 to follow this as well.
>>
>> Fixes: c15e1bdda436 ("device property: Fix the secondary firmware node handling in set_primary_fwnode()")
>> Cc: Ferry Toth<fntoth@gmail.com>
>> Signed-off-by: Andy Shevchenko<andriy.shevchenko@linux.intel.com>
> FWIW:
>
> Reviewed-by: Heikki Krogerus<heikki.krogerus@linux.intel.com>
> Tested-by: Ferry Toth<fntoth@gmail.com>
>> ---
>>   drivers/base/core.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/base/core.c b/drivers/base/core.c
>> index c852f16c111b..41feab679fa1 100644
>> --- a/drivers/base/core.c
>> +++ b/drivers/base/core.c
>> @@ -4278,7 +4278,7 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
>>   	} else {
>>   		if (fwnode_is_primary(fn)) {
>>   			dev->fwnode = fn->secondary;
>> -			fn->secondary = NULL;
>> +			fn->secondary = ERR_PTR(-ENODEV);
>>   		} else {
>>   			dev->fwnode = NULL;
>>   		}
>> -- 
>> 2.28.0

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

* Re: [PATCH v1 2/2] device property: Don't clear secondary pointer for shared primary firmware node
  2020-10-23 12:35   ` Heikki Krogerus
  2020-10-23 14:03     ` Ferry Toth
@ 2020-10-23 14:16     ` Ferry Toth
  1 sibling, 0 replies; 9+ messages in thread
From: Ferry Toth @ 2020-10-23 14:16 UTC (permalink / raw)
  To: Heikki Krogerus, Andy Shevchenko
  Cc: Greg Kroah-Hartman, linux-kernel, Saravana Kannan, linux-acpi,
	Rafael J. Wysocki

Hi

Op 23-10-2020 om 14:35 schreef Heikki Krogerus:
> On Thu, Oct 22, 2020 at 09:41:00PM +0300, Andy Shevchenko wrote:
>> It appears that firmware nodes can be shared between devices. In such 
>> case
>> when a (child) device is about to be deleted, its firmware node may 
>> be shared
>> and ACPI_COMPANION_SET(..., NULL) call for it breaks the secondary link
>> of the shared primary firmware node.
>>
>> In order to prevent that, check, if the device has a parent and parent's
>> firmware node is shared with its child, and avoid crashing the link.
>>
>> Fixes: c15e1bdda436 ("device property: Fix the secondary firmware 
>> node handling in set_primary_fwnode()")
>> Reported-by: Ferry Toth <fntoth@gmail.com>
>> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> FWIW:
>
> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

Tested-by: Ferry Toth <fntoth@gmail.com>

>> ---
>> drivers/base/core.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/base/core.c b/drivers/base/core.c
>> index 41feab679fa1..78114ddac755 100644
>> --- a/drivers/base/core.c
>> +++ b/drivers/base/core.c
>> @@ -4264,6 +4264,7 @@ static inline bool fwnode_is_primary(struct 
>> fwnode_handle *fwnode)
>> */
>> void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
>> {
>> + struct device *parent = dev->parent;
>> struct fwnode_handle *fn = dev->fwnode;
>> if (fwnode) {
>> @@ -4278,7 +4279,8 @@ void set_primary_fwnode(struct device *dev, 
>> struct fwnode_handle *fwnode)
>> } else {
>> if (fwnode_is_primary(fn)) {
>> dev->fwnode = fn->secondary;
>> - fn->secondary = ERR_PTR(-ENODEV);
>> + if (!(parent && fn == parent->fwnode))
>> + fn->secondary = ERR_PTR(-ENODEV);
>> } else {
>> dev->fwnode = NULL;
>> }
>> -- 2.28.0

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

* Re: [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type
       [not found]   ` <ef59c911-8d8b-783a-c756-05123f428302@gmail.com>
@ 2020-10-23 14:19     ` Andy Shevchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2020-10-23 14:19 UTC (permalink / raw)
  To: Ferry Toth
  Cc: Heikki Krogerus, Greg Kroah-Hartman, linux-kernel,
	Saravana Kannan, linux-acpi, Rafael J. Wysocki

On Fri, Oct 23, 2020 at 04:03:20PM +0200, Ferry Toth wrote:
> Hi
> 
> Op 23-10-2020 om 14:34 schreef Heikki Krogerus:
> > On Thu, Oct 22, 2020 at 09:40:59PM +0300, Andy Shevchenko wrote:
> > > Behind primary and secondary we understand the type of the nodes
> > > which might define their ordering. However, if primary node gone,
> > > we can't maintain the ordering by definition of the linked list.
> > > Thus, by ordering secondary node becomes first in the list.
> > > But in this case the meaning of it is still secondary (or auxiliary).
> > > The type of the node is maintained by the secondary pointer in it:
> > > 
> > > 	secondary pointer		Meaning
> > > 	NULL or valid			primary node
> > > 	ERR_PTR(-ENODEV)		secondary node
> > > 
> > > So, if by some reason we do the following sequence of calls
> > > 
> > > 	set_primary_fwnode(dev, NULL);
> > > 	set_primary_fwnode(dev, primary);
> > > 
> > > we should preserve secondary node.
> > > 
> > > This concept is supported by the description of set_primary_fwnode()
> > > along with implementation of set_secondary_fwnode(). Hence, fix
> > > the commit c15e1bdda436 to follow this as well.
> > > 
> > > Fixes: c15e1bdda436 ("device property: Fix the secondary firmware node handling in set_primary_fwnode()")
> > > Cc: Ferry Toth <fntoth@gmail.com>
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > FWIW:
> > 
> > Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > Tested-by: Ferry Toth <fntoth@gmail.com>

The quoting above is broken, I dare to put it below without any quoting.

Tested-by: Ferry Toth <fntoth@gmail.com>

> > > ---
> > >   drivers/base/core.c | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/base/core.c b/drivers/base/core.c
> > > index c852f16c111b..41feab679fa1 100644
> > > --- a/drivers/base/core.c
> > > +++ b/drivers/base/core.c
> > > @@ -4278,7 +4278,7 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
> > >   	} else {
> > >   		if (fwnode_is_primary(fn)) {
> > >   			dev->fwnode = fn->secondary;
> > > -			fn->secondary = NULL;
> > > +			fn->secondary = ERR_PTR(-ENODEV);
> > >   		} else {
> > >   			dev->fwnode = NULL;
> > >   		}
> > > -- 
> > > 2.28.0

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type
  2020-10-22 18:40 [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type Andy Shevchenko
  2020-10-22 18:41 ` [PATCH v1 2/2] device property: Don't clear secondary pointer for shared primary firmware node Andy Shevchenko
  2020-10-23 12:34 ` [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type Heikki Krogerus
@ 2020-10-27 18:21 ` Rafael J. Wysocki
  2 siblings, 0 replies; 9+ messages in thread
From: Rafael J. Wysocki @ 2020-10-27 18:21 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, Linux Kernel Mailing List, Saravana Kannan,
	ACPI Devel Maling List, Rafael J. Wysocki, Heikki Krogerus,
	Ferry Toth

On Thu, Oct 22, 2020 at 8:41 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> Behind primary and secondary we understand the type of the nodes
> which might define their ordering. However, if primary node gone,
> we can't maintain the ordering by definition of the linked list.
> Thus, by ordering secondary node becomes first in the list.
> But in this case the meaning of it is still secondary (or auxiliary).
> The type of the node is maintained by the secondary pointer in it:
>
>         secondary pointer               Meaning
>         NULL or valid                   primary node
>         ERR_PTR(-ENODEV)                secondary node
>
> So, if by some reason we do the following sequence of calls
>
>         set_primary_fwnode(dev, NULL);
>         set_primary_fwnode(dev, primary);
>
> we should preserve secondary node.
>
> This concept is supported by the description of set_primary_fwnode()
> along with implementation of set_secondary_fwnode(). Hence, fix
> the commit c15e1bdda436 to follow this as well.
>
> Fixes: c15e1bdda436 ("device property: Fix the secondary firmware node handling in set_primary_fwnode()")
> Cc: Ferry Toth <fntoth@gmail.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/base/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index c852f16c111b..41feab679fa1 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -4278,7 +4278,7 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
>         } else {
>                 if (fwnode_is_primary(fn)) {
>                         dev->fwnode = fn->secondary;
> -                       fn->secondary = NULL;
> +                       fn->secondary = ERR_PTR(-ENODEV);
>                 } else {
>                         dev->fwnode = NULL;
>                 }
> --

Applied as 5.10-rc material along with the [2/2], thanks!

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

end of thread, other threads:[~2020-10-27 18:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-22 18:40 [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type Andy Shevchenko
2020-10-22 18:41 ` [PATCH v1 2/2] device property: Don't clear secondary pointer for shared primary firmware node Andy Shevchenko
2020-10-23 12:35   ` Heikki Krogerus
2020-10-23 14:03     ` Ferry Toth
2020-10-23 14:16     ` Ferry Toth
2020-10-23 12:34 ` [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type Heikki Krogerus
2020-10-23 14:16   ` Ferry Toth
     [not found]   ` <ef59c911-8d8b-783a-c756-05123f428302@gmail.com>
2020-10-23 14:19     ` Andy Shevchenko
2020-10-27 18:21 ` Rafael J. Wysocki

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).