Re: [PATCH v2] driver core: Update device link status correctly for SYNC_STATE_ONLY links

From: Michael Walle
Date: Tue May 26 2020 - 17:53:38 EST


Am 2020-05-26 23:45, schrieb Saravana Kannan:
On Tue, May 26, 2020 at 2:13 PM Michael Walle <michael@xxxxxxxx> wrote:

Am 2020-05-26 21:43, schrieb Saravana Kannan:
> When SYNC_STATE_ONLY support was added in commit 05ef983e0d65 ("driver
> core: Add device link support for SYNC_STATE_ONLY flag"),
> SYNC_STATE_ONLY links were treated similar to STATELESS links in terms
> of not blocking consumer probe if the supplier hasn't probed yet.
>
> That caused a SYNC_STATE_ONLY device link's status to not get updated.
> Since SYNC_STATE_ONLY device link is no longer useful once the
> consumer probes, commit 21c27f06587d ("driver core: Fix
> SYNC_STATE_ONLY device link implementation") addresses the status
> update issue by deleting the SYNC_STATE_ONLY device link instead of
> complicating the status update code.
>
> However, there are still some cases where we need to update the status
> of a SYNC_STATE_ONLY device link. This is because a SYNC_STATE_ONLY
> device link can later get converted into a normal MANAGED device link
> when a normal MANAGED device link is created between a supplier and
> consumer that already have a SYNC_STATE_ONLY device link between them.
>
> If a SYNC_STATE_ONLY device link's status isn't maintained correctly
> till it's converted to a normal MANAGED device link, then the normal
> MANAGED device link will end up with a wrong link status. This can
> cause
> a warning stack trace[1] when the consumer device probes successfully.
>
> This commit fixes the SYNC_STATE_ONLY device link status update issue
> where it wouldn't transition correctly from DL_STATE_DORMANT or
> DL_STATE_AVAILABLE to DL_STATE_CONSUMER_PROBE. It also resets the
> status
> back to DL_STATE_DORMANT or DL_STATE_AVAILABLE if the consumer probe
> fails.
>
> [1] - https://lore.kernel.org/lkml/20200522204120.3b3c9ed6@apollo/
> Fixes: 05ef983e0d65 ("driver core: Add device link support for
> SYNC_STATE_ONLY flag")
> Fixes: 21c27f06587d ("driver core: Fix SYNC_STATE_ONLY device link
> implementation")
> Reported-by: Michael Walle <michael@xxxxxxxx>
> Signed-off-by: Saravana Kannan <saravanak@xxxxxxxxxx>
> ---
>
> v1->v2:
> - Added code to "revert" the link status if consumer probe fails
>
> Greg,
>
> I think this is the issue Michael ran into. I'd like him to test the
> fix
> before it's pulled in.
>
> Michael,
>
> If you can test this on the branch you saw the issue in and give a
> Tested-by if it works, that'd be great.

with v2 I'm triggering the
WARN_ON(!(link->status & DL_FLAG_SYNC_STATE_ONLY));
in __device_links_no_driver().

Thanks for the logs! The WARNING is due to a dump typo in this line. I
should be checking link->flags, not link->status here. I'll send out a
v3, but you can test with this change too.

Ahh, right. With that fix you can add:

Tested-by: Michael Walle <michael@xxxxxxxx>

Thanks,
-michael