Skip to content

Commit 4ca4ce0

Browse files
Yihang Limartinkpetersen
authored andcommitted
scsi: hisi_sas: Check usage count only when the runtime PM status is RPM_SUSPENDING
Users can suspend the machine with 'echo disk > /sys/power/state', but the suspend will fail because the SAS controller cannot be suspended: [root@localhost ~]# echo freeze > /sys/power/state -bash: echo: write error: Device or resource busy [15104.142955] PM: suspend entry (s2idle) ... [15104.283465] hisi_sas_v3_hw 0000:32:04.0: entering suspend state [15104.283480] hisi_sas_v3_hw 0000:30:04.0: entering suspend state [15104.283500] hisi_sas_v3_hw 0000:32:04.0: PM suspend: host status cannot be suspended [15104.283508] hisi_sas_v3_hw 0000:30:04.0: PM suspend: host status cannot be suspended [15104.283516] hisi_sas_v3_hw 0000:32:04.0: PM: pci_pm_suspend(): suspend_v3_hw+0x0/0x210 [hisi_sas_v3_hw] returns -16 [15104.283527] hisi_sas_v3_hw 0000:32:04.0: PM: dpm_run_callback(): pci_pm_suspend+0x0/0x1c0 returns -16 [15104.283524] hisi_sas_v3_hw 0000:30:04.0: PM: pci_pm_suspend(): suspend_v3_hw+0x0/0x210 [hisi_sas_v3_hw] returns -16 [15104.283533] hisi_sas_v3_hw 0000:32:04.0: PM: failed to suspend async: error -16 [15104.283536] hisi_sas_v3_hw 0000:30:04.0: PM: dpm_run_callback(): pci_pm_suspend+0x0/0x1c0 returns -16 [15104.283542] hisi_sas_v3_hw 0000:30:04.0: PM: failed to suspend async: error -16 The problem is that when the ->runtime_suspend() callback suspend_v3_hw() is executing, the current runtime PM status is RPM_ACTIVE and the usage count of the controller is not 0, so return immediately. To fix it, Check the device usage count only when the runtime PM status is RPM_SUSPENDING. Signed-off-by: Yihang Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Xiang Chen <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 64359af commit 4ca4ce0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/scsi/hisi_sas/hisi_sas_v3_hw.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5048,7 +5048,8 @@ static int _suspend_v3_hw(struct device *device)
50485048
interrupt_disable_v3_hw(hisi_hba);
50495049

50505050
#ifdef CONFIG_PM
5051-
if (atomic_read(&device->power.usage_count)) {
5051+
if ((device->power.runtime_status == RPM_SUSPENDING) &&
5052+
atomic_read(&device->power.usage_count)) {
50525053
dev_err(dev, "PM suspend: host status cannot be suspended\n");
50535054
rc = -EBUSY;
50545055
goto err_out;

0 commit comments

Comments
 (0)