libata: Use per port sync for detach
authorKai-Heng Feng <kai.heng.feng@canonical.com>
Wed, 3 Jun 2020 07:48:19 +0000 (15:48 +0800)
committerSasha Levin <sashal@kernel.org>
Tue, 30 Jun 2020 19:38:31 +0000 (15:38 -0400)
commit3a4b09605f727d40cf104c26a83707c67f4e10e9
tree876871091f89717407d5925992b2268c3d891eb7
parenta54b15af2b495ed97660a6276710ef36e06ac6c9
libata: Use per port sync for detach

[ Upstream commit b5292111de9bb70cba3489075970889765302136 ]

Commit 130f4caf145c ("libata: Ensure ata_port probe has completed before
detach") may cause system freeze during suspend.

Using async_synchronize_full() in PM callbacks is wrong, since async
callbacks that are already scheduled may wait for not-yet-scheduled
callbacks, causes a circular dependency.

Instead of using big hammer like async_synchronize_full(), use async
cookie to make sure port probe are synced, without affecting other
scheduled PM callbacks.

Fixes: 130f4caf145c ("libata: Ensure ata_port probe has completed before detach")
Suggested-by: John Garry <john.garry@huawei.com>
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Tested-by: John Garry <john.garry@huawei.com>
BugLink: https://bugs.launchpad.net/bugs/1867983
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/ata/libata-core.c
include/linux/libata.h