@@ -51,6 +51,7 @@
#include <linux/suspend.h>
#include <asm/unaligned.h>
#include <linux/ioprio.h>
+#include <linux/pm_runtime.h>
#include "libata.h"
#include "libata-transport.h"
@@ -4568,6 +4569,7 @@ int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht)
void ata_scsi_scan_host(struct ata_port *ap, int sync)
{
int tries = 5;
+ int dev_attached = 0;
struct ata_device *last_failed_dev = NULL;
struct ata_link *link;
struct ata_device *dev;
@@ -4591,12 +4593,18 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync)
if (!IS_ERR(sdev)) {
dev->sdev = sdev;
scsi_device_put(sdev);
+ dev_attached = 1;
} else {
dev->sdev = NULL;
}
}
}
+#ifdef CONFIG_AHCI_HOTPLUG_DISABLED
+ if (!dev_attached)
+ pm_runtime_allow(&ap->tdev);
+#endif
+
/* If we scanned while EH was in progress or allocation
* failure occurred, scan would have failed silently. Check
* whether all devices are attached.