[SCSI] libsas: don't recover end devices attached to disabled phys
authorDan Williams <dan.j.williams@intel.com>
Tue, 31 Jan 2012 05:40:45 +0000 (21:40 -0800)
committerJames Bottomley <JBottomley@Parallels.com>
Wed, 29 Feb 2012 21:42:51 +0000 (15:42 -0600)
If userspace has decided to disable a phy the kernel should honor that
and not inadvertantly re-enable the phy via error recovery.  This is
more straightforward in the sata case where link recovery (via
libata-eh) is separate from sas_task cancelling in libsas-eh.  Teach
libsas to accept -ENODEV as a successful response from I_T_nexus_reset
('successful' in terms of not escalating further).

This is a more comprehensive fix then "libsas: don't recover 'gone'
devices in sas_ata_hard_reset()", as it is no longer sata-specific.

aic94xx does check the return value from sas_phy_reset() so if the phy
is disabled we proceed with clearing the I_T_nexus.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/aic94xx/aic94xx_tmf.c
drivers/scsi/libsas/sas_ata.c
drivers/scsi/libsas/sas_init.c
drivers/scsi/libsas/sas_scsi_host.c

index 50b914ffab9440d20d3844ea631733535265b202..cf9040933da6497ca500454274fe163c50ec324d 100644 (file)
@@ -192,7 +192,7 @@ int asd_I_T_nexus_reset(struct domain_device *dev)
        ASD_DPRINTK("sending %s reset to %s\n",
                    reset_type ? "hard" : "soft", dev_name(&phy->dev));
        res = sas_phy_reset(phy, reset_type);
-       if (res == TMF_RESP_FUNC_COMPLETE) {
+       if (res == TMF_RESP_FUNC_COMPLETE || res == -ENODEV) {
                /* wait for the maximum settle time */
                msleep(500);
                /* clear all outstanding commands (keep nexus suspended) */
index 08d2103a45b79a22a7bb6a3fefe788b636f3e6ab..bc0cecc6ad62492c02b153ecee767ed0cfd650b1 100644 (file)
@@ -407,10 +407,9 @@ static int sas_ata_hard_reset(struct ata_link *link, unsigned int *class,
        struct domain_device *dev = ap->private_data;
        struct sas_internal *i = dev_to_sas_internal(dev);
 
-       if (test_bit(SAS_DEV_GONE, &dev->state))
-               return -ENODEV;
-
        res = i->dft->lldd_I_T_nexus_reset(dev);
+       if (res == -ENODEV)
+               return res;
 
        if (res != TMF_RESP_FUNC_COMPLETE)
                sas_ata_printk(KERN_DEBUG, dev, "Unable to reset ata device?\n");
index 09c14ca3fbd539ee58b59065bef9493a09b9ef65..120bff64be303c67cc66aba9fdfae3af7d58e2c8 100644 (file)
@@ -298,6 +298,9 @@ int sas_phy_reset(struct sas_phy *phy, int hard_reset)
        int ret;
        enum phy_func reset_type;
 
+       if (!phy->enabled)
+               return -ENODEV;
+
        if (hard_reset)
                reset_type = PHY_FUNC_HARD_RESET;
        else
index fd3291337c1b93c3e2a9cdd4a1a91e3f3b2b7a6d..f0b9b7bf1882b1c45e78cf3bc35b3aa820a3c402 100644 (file)
@@ -607,7 +607,8 @@ static void sas_eh_handle_sas_errors(struct Scsi_Host *shost, struct list_head *
                        SAS_DPRINTK("task 0x%p is not at LU: I_T recover\n",
                                    task);
                        tmf_resp = sas_recover_I_T(task->dev);
-                       if (tmf_resp == TMF_RESP_FUNC_COMPLETE) {
+                       if (tmf_resp == TMF_RESP_FUNC_COMPLETE ||
+                           tmf_resp == -ENODEV) {
                                struct domain_device *dev = task->dev;
                                SAS_DPRINTK("I_T %016llx recovered\n",
                                            SAS_ADDR(task->dev->sas_addr));