summaryrefslogtreecommitdiff
path: root/drivers/ata/libata-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r--drivers/ata/libata-core.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 0b24bd169d61..871ef87a02ca 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2358,6 +2358,24 @@ static bool ata_dev_check_adapter(struct ata_device *dev,
return false;
}
+bool ata_adapter_is_online(struct ata_port *ap)
+{
+ struct device *dev;
+
+ if (!ap || !ap->host)
+ return false;
+
+ dev = ap->host->dev;
+ if (!dev)
+ return false;
+
+ if (dev_is_pci(dev) &&
+ pci_channel_offline(to_pci_dev(dev)))
+ return false;
+
+ return true;
+}
+
static int ata_dev_config_ncq(struct ata_device *dev,
char *desc, size_t desc_sz)
{
@@ -5073,6 +5091,12 @@ void ata_qc_issue(struct ata_queued_cmd *qc)
qc->flags |= ATA_QCFLAG_ACTIVE;
ap->qc_active |= 1ULL << qc->tag;
+ /* Make sure the device is still accessible. */
+ if (!ata_adapter_is_online(ap)) {
+ qc->err_mask |= AC_ERR_HOST_BUS;
+ goto sys_err;
+ }
+
/*
* We guarantee to LLDs that they will have at least one
* non-zero sg if the command is a data command.