2020-10-23 03:36:03

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type

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 <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
---
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


2020-10-23 15:49:36

by Heikki Krogerus

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type

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 <[email protected]>
> Signed-off-by: Andy Shevchenko <[email protected]>

FWIW:

Reviewed-by: Heikki Krogerus <[email protected]>

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

2020-10-23 16:21:27

by Ferry Toth

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type

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<[email protected]>
>> Signed-off-by: Andy Shevchenko<[email protected]>
> FWIW:
>
> Reviewed-by: Heikki Krogerus<[email protected]>
> Tested-by: Ferry Toth<[email protected]>
>> ---
>> 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

2020-10-23 18:17:50

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type

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 <[email protected]>
> > > Signed-off-by: Andy Shevchenko <[email protected]>
> > FWIW:
> >
> > Reviewed-by: Heikki Krogerus <[email protected]>
> > Tested-by: Ferry Toth <[email protected]>

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

Tested-by: Ferry Toth <[email protected]>

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


2020-10-28 19:30:52

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH v1 1/2] device property: Keep secondary firmware node secondary by type

On Thu, Oct 22, 2020 at 8:41 PM Andy Shevchenko
<[email protected]> 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 <[email protected]>
> Signed-off-by: Andy Shevchenko <[email protected]>
> ---
> 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!