All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] driver core: simply go out if the same device_link is added again
@ 2020-11-19 11:00 Dong Aisheng
  2020-11-19 11:00 ` [PATCH 2/3] of: property: add debug info for supplier devices still unavailable Dong Aisheng
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Dong Aisheng @ 2020-11-19 11:00 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-imx, dongas86, Dong Aisheng, Greg Kroah-Hartman,
	Rafael J. Wysocki, Saravana Kannan

It's possible that the same device link may be added by parsing the
function dependecy in DT. e.g. clock/gpio/regulators.
Simply go out for this case.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Saravana Kannan <saravanak@google.com>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/base/core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 4c03bdd3a268..7d91d4074136 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -567,6 +567,9 @@ struct device_link *device_link_add(struct device *consumer,
 		if (link->consumer != consumer)
 			continue;
 
+		if (flags == link->flags)
+			goto out;
+
 		if (flags & DL_FLAG_PM_RUNTIME) {
 			if (!(link->flags & DL_FLAG_PM_RUNTIME)) {
 				pm_runtime_new_link(consumer);
-- 
2.23.0


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

* [PATCH 2/3] of: property: add debug info for supplier devices still unavailable
  2020-11-19 11:00 [PATCH 1/3] driver core: simply go out if the same device_link is added again Dong Aisheng
@ 2020-11-19 11:00 ` Dong Aisheng
  2020-11-19 17:48   ` Saravana Kannan
  2020-11-19 11:00 ` [PATCH 3/3] of: property: fix document of of_get_next_parent_dev Dong Aisheng
  2020-11-19 12:11 ` [PATCH 1/3] driver core: simply go out if the same device_link is added again Rafael J. Wysocki
  2 siblings, 1 reply; 7+ messages in thread
From: Dong Aisheng @ 2020-11-19 11:00 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-imx, dongas86, Dong Aisheng, devicetree, Saravana Kannan,
	Rob Herring, Greg Kroah-Hartman

It's normal that supplier devices may still unavaiable when parse DT to
create dependency. e.g. supplier devices populated by drivers.
Add debug info for this case.

Cc: devicetree@vger.kernel.org
Cc: Saravana Kannan <saravanak@google.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/of/property.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/of/property.c b/drivers/of/property.c
index 408a7b5f06a9..21a854e85234 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -1150,6 +1150,8 @@ static int of_link_to_phandle(struct device *dev, struct device_node *sup_np,
 			 * Can't check for cycles or no cycles. So let's try
 			 * again later.
 			 */
+			dev_dbg(dev, "Not linking to %pOFP - device may still unavailable\n",
+				sup_np);
 			ret = -EAGAIN;
 		}
 
-- 
2.23.0


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

* [PATCH 3/3] of: property: fix document of of_get_next_parent_dev
  2020-11-19 11:00 [PATCH 1/3] driver core: simply go out if the same device_link is added again Dong Aisheng
  2020-11-19 11:00 ` [PATCH 2/3] of: property: add debug info for supplier devices still unavailable Dong Aisheng
@ 2020-11-19 11:00 ` Dong Aisheng
  2020-11-19 17:49   ` Saravana Kannan
  2020-11-19 12:11 ` [PATCH 1/3] driver core: simply go out if the same device_link is added again Rafael J. Wysocki
  2 siblings, 1 reply; 7+ messages in thread
From: Dong Aisheng @ 2020-11-19 11:00 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-imx, dongas86, Dong Aisheng, devicetree, Saravana Kannan,
	Rob Herring, Greg Kroah-Hartman

Fix document of of_get_next_parent_dev.

Cc: devicetree@vger.kernel.org
Cc: Saravana Kannan <saravanak@google.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/of/property.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/of/property.c b/drivers/of/property.c
index 21a854e85234..5bd4a9bead47 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -1038,7 +1038,7 @@ static bool of_is_ancestor_of(struct device_node *test_ancestor,
 }
 
 /**
- * of_get_next_parent_dev - Add device link to supplier from supplier phandle
+ * of_get_next_parent_dev - Get the closest ancestor device of a device node
  * @np: device tree node
  *
  * Given a device tree node (@np), this function finds its closest ancestor
-- 
2.23.0


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

* Re: [PATCH 1/3] driver core: simply go out if the same device_link is added again
  2020-11-19 11:00 [PATCH 1/3] driver core: simply go out if the same device_link is added again Dong Aisheng
  2020-11-19 11:00 ` [PATCH 2/3] of: property: add debug info for supplier devices still unavailable Dong Aisheng
  2020-11-19 11:00 ` [PATCH 3/3] of: property: fix document of of_get_next_parent_dev Dong Aisheng
@ 2020-11-19 12:11 ` Rafael J. Wysocki
  2020-11-19 15:44   ` Aisheng Dong
  2 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2020-11-19 12:11 UTC (permalink / raw)
  To: Dong Aisheng
  Cc: Linux Kernel Mailing List, dl-linux-imx, Dong Aisheng,
	Greg Kroah-Hartman, Rafael J. Wysocki, Saravana Kannan

On Thu, Nov 19, 2020 at 12:18 PM Dong Aisheng <aisheng.dong@nxp.com> wrote:
>
> It's possible that the same device link may be added by parsing the
> function dependecy in DT. e.g. clock/gpio/regulators.
> Simply go out for this case.

Why?

> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Saravana Kannan <saravanak@google.com>
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>  drivers/base/core.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 4c03bdd3a268..7d91d4074136 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -567,6 +567,9 @@ struct device_link *device_link_add(struct device *consumer,
>                 if (link->consumer != consumer)
>                         continue;
>
> +               if (flags == link->flags)
> +                       goto out;

But this prevents rpm_count from being incremented if
DL_FLAG_RPM_ACTIVE is set in flags, which is necessary, because the
supplier's PM-runtime usage counter has been incremented already.

Moreover, every attempt to create a stateless link must cause a new
reference on the existing link to be acquired, or the removal will not
work correctly.

> +
>                 if (flags & DL_FLAG_PM_RUNTIME) {
>                         if (!(link->flags & DL_FLAG_PM_RUNTIME)) {
>                                 pm_runtime_new_link(consumer);
> --

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

* RE: [PATCH 1/3] driver core: simply go out if the same device_link is added again
  2020-11-19 12:11 ` [PATCH 1/3] driver core: simply go out if the same device_link is added again Rafael J. Wysocki
@ 2020-11-19 15:44   ` Aisheng Dong
  0 siblings, 0 replies; 7+ messages in thread
From: Aisheng Dong @ 2020-11-19 15:44 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Linux Kernel Mailing List, dl-linux-imx, Dong Aisheng,
	Greg Kroah-Hartman, Saravana Kannan

> From: Rafael J. Wysocki <rafael@kernel.org>
> Sent: Thursday, November 19, 2020 8:12 PM
> 
> On Thu, Nov 19, 2020 at 12:18 PM Dong Aisheng <aisheng.dong@nxp.com>
> wrote:
> >
> > It's possible that the same device link may be added by parsing the
> > function dependecy in DT. e.g. clock/gpio/regulators.
> > Simply go out for this case.
> 
> Why?
> 
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: Saravana Kannan <saravanak@google.com>
> > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > ---
> >  drivers/base/core.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/base/core.c b/drivers/base/core.c index
> > 4c03bdd3a268..7d91d4074136 100644
> > --- a/drivers/base/core.c
> > +++ b/drivers/base/core.c
> > @@ -567,6 +567,9 @@ struct device_link *device_link_add(struct device
> *consumer,
> >                 if (link->consumer != consumer)
> >                         continue;
> >
> > +               if (flags == link->flags)
> > +                       goto out;
> 
> But this prevents rpm_count from being incremented if DL_FLAG_RPM_ACTIVE
> is set in flags, which is necessary, because the supplier's PM-runtime usage
> counter has been incremented already.
> 
> Moreover, every attempt to create a stateless link must cause a new reference
> on the existing link to be acquired, or the removal will not work correctly.

Yes, I see. Thanks for the explanation.

Regards
Aisheng

> 
> > +
> >                 if (flags & DL_FLAG_PM_RUNTIME) {
> >                         if (!(link->flags & DL_FLAG_PM_RUNTIME)) {
> >                                 pm_runtime_new_link(consumer);
> > --

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

* Re: [PATCH 2/3] of: property: add debug info for supplier devices still unavailable
  2020-11-19 11:00 ` [PATCH 2/3] of: property: add debug info for supplier devices still unavailable Dong Aisheng
@ 2020-11-19 17:48   ` Saravana Kannan
  0 siblings, 0 replies; 7+ messages in thread
From: Saravana Kannan @ 2020-11-19 17:48 UTC (permalink / raw)
  To: Dong Aisheng
  Cc: LKML, dl-linux-imx, Dong Aisheng,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Rob Herring, Greg Kroah-Hartman

On Thu, Nov 19, 2020 at 3:18 AM Dong Aisheng <aisheng.dong@nxp.com> wrote:
>
> It's normal that supplier devices may still unavaiable when parse DT to
> create dependency. e.g. supplier devices populated by drivers.
> Add debug info for this case.
>
> Cc: devicetree@vger.kernel.org
> Cc: Saravana Kannan <saravanak@google.com>
> Cc: Rob Herring <robh@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>  drivers/of/property.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/of/property.c b/drivers/of/property.c
> index 408a7b5f06a9..21a854e85234 100644
> --- a/drivers/of/property.c
> +++ b/drivers/of/property.c
> @@ -1150,6 +1150,8 @@ static int of_link_to_phandle(struct device *dev, struct device_node *sup_np,
>                          * Can't check for cycles or no cycles. So let's try
>                          * again later.
>                          */
> +                       dev_dbg(dev, "Not linking to %pOFP - device may still unavailable\n",
> +                               sup_np);
>                         ret = -EAGAIN;
>                 }
>

All of this is going away[1].
So, Nack.

-Saravana
[1] - https://lore.kernel.org/lkml/20201104232356.4038506-1-saravanak@google.com/

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

* Re: [PATCH 3/3] of: property: fix document of of_get_next_parent_dev
  2020-11-19 11:00 ` [PATCH 3/3] of: property: fix document of of_get_next_parent_dev Dong Aisheng
@ 2020-11-19 17:49   ` Saravana Kannan
  0 siblings, 0 replies; 7+ messages in thread
From: Saravana Kannan @ 2020-11-19 17:49 UTC (permalink / raw)
  To: Dong Aisheng
  Cc: LKML, dl-linux-imx, Dong Aisheng,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Rob Herring, Greg Kroah-Hartman

On Thu, Nov 19, 2020 at 3:18 AM Dong Aisheng <aisheng.dong@nxp.com> wrote:
>
> Fix document of of_get_next_parent_dev.
>
> Cc: devicetree@vger.kernel.org
> Cc: Saravana Kannan <saravanak@google.com>
> Cc: Rob Herring <robh@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>  drivers/of/property.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/of/property.c b/drivers/of/property.c
> index 21a854e85234..5bd4a9bead47 100644
> --- a/drivers/of/property.c
> +++ b/drivers/of/property.c
> @@ -1038,7 +1038,7 @@ static bool of_is_ancestor_of(struct device_node *test_ancestor,
>  }
>
>  /**
> - * of_get_next_parent_dev - Add device link to supplier from supplier phandle
> + * of_get_next_parent_dev - Get the closest ancestor device of a device node
>   * @np: device tree node
>   *
>   * Given a device tree node (@np), this function finds its closest ancestor

All of this is going away[1].
So, Nack.

-Saravana
[1] - https://lore.kernel.org/lkml/20201104232356.4038506-1-saravanak@google.com/

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

end of thread, other threads:[~2020-11-19 17:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-19 11:00 [PATCH 1/3] driver core: simply go out if the same device_link is added again Dong Aisheng
2020-11-19 11:00 ` [PATCH 2/3] of: property: add debug info for supplier devices still unavailable Dong Aisheng
2020-11-19 17:48   ` Saravana Kannan
2020-11-19 11:00 ` [PATCH 3/3] of: property: fix document of of_get_next_parent_dev Dong Aisheng
2020-11-19 17:49   ` Saravana Kannan
2020-11-19 12:11 ` [PATCH 1/3] driver core: simply go out if the same device_link is added again Rafael J. Wysocki
2020-11-19 15:44   ` Aisheng Dong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.