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 <[email protected]>
Cc: "Rafael J. Wysocki" <[email protected]>
Cc: Saravana Kannan <[email protected]>
Signed-off-by: Dong Aisheng <[email protected]>
---
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
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: [email protected]
Cc: Saravana Kannan <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Dong Aisheng <[email protected]>
---
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
Fix document of of_get_next_parent_dev.
Cc: [email protected]
Cc: Saravana Kannan <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Dong Aisheng <[email protected]>
---
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
On Thu, Nov 19, 2020 at 12:18 PM Dong Aisheng <[email protected]> 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 <[email protected]>
> Cc: "Rafael J. Wysocki" <[email protected]>
> Cc: Saravana Kannan <[email protected]>
> Signed-off-by: Dong Aisheng <[email protected]>
> ---
> 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);
> --
> From: Rafael J. Wysocki <[email protected]>
> Sent: Thursday, November 19, 2020 8:12 PM
>
> On Thu, Nov 19, 2020 at 12:18 PM Dong Aisheng <[email protected]>
> 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 <[email protected]>
> > Cc: "Rafael J. Wysocki" <[email protected]>
> > Cc: Saravana Kannan <[email protected]>
> > Signed-off-by: Dong Aisheng <[email protected]>
> > ---
> > 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);
> > --
On Thu, Nov 19, 2020 at 3:18 AM Dong Aisheng <[email protected]> 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: [email protected]
> Cc: Saravana Kannan <[email protected]>
> Cc: Rob Herring <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Signed-off-by: Dong Aisheng <[email protected]>
> ---
> 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/[email protected]/
On Thu, Nov 19, 2020 at 3:18 AM Dong Aisheng <[email protected]> wrote:
>
> Fix document of of_get_next_parent_dev.
>
> Cc: [email protected]
> Cc: Saravana Kannan <[email protected]>
> Cc: Rob Herring <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Signed-off-by: Dong Aisheng <[email protected]>
> ---
> 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/[email protected]/