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

Reply via email to