From da1c2c4a2cc884a49a4c824a074b3ee381899747 Mon Sep 17 00:00:00 2001 From: Yifeng Zhao Date: Sun, 24 Apr 2022 10:52:34 +0800 Subject: [PATCH] scsi: sata: re enter sleep is prohibited during wake-up The work ata_scsi_dev_rescan will hangup and can not wakeup if PM enter sleep at the sata device wake-up process. Signed-off-by: Yifeng Zhao Change-Id: I44045505c2e691102ab90ba3b2ae3031e7bab0a6 --- drivers/ata/ahci_platform.c | 2 ++ drivers/scsi/sd.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index 1825b33cc274..6988ef6b5c3c 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c @@ -74,6 +74,8 @@ static int ahci_probe(struct platform_device *pdev) if (rc) goto disable_resources; + device_init_wakeup(dev, true); + return 0; disable_resources: ahci_platform_disable_resources(hpriv); diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index f0c0935d7909..8cf5d7ef7cc5 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3716,10 +3716,16 @@ static int sd_resume(struct device *dev) if (!sdkp->device->manage_start_stop) return 0; + /* The wake-up process cannot allow the PM to enter sleep */ + pm_stay_awake(dev); + sd_printk(KERN_NOTICE, sdkp, "Starting disk\n"); ret = sd_start_stop_device(sdkp, 1); if (!ret) opal_unlock_from_suspend(sdkp->opal_dev); + + pm_relax(dev); + return ret; }