summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libsas
diff options
context:
space:
mode:
authorJohn Garry <john.garry@huawei.com>2022-05-12 19:15:32 +0800
committerMartin K. Petersen <martin.petersen@oracle.com>2022-05-19 20:16:25 -0400
commit057e5fc03369f8f2ed9b2ca884754b1d80b83620 (patch)
tree8c67af22ca4e3971aa7ff0501e1f396f02793a80 /drivers/scsi/libsas
parent53d5088deff64c526ac52b39ce1244ce10372367 (diff)
downloadlinux-stable-057e5fc03369f8f2ed9b2ca884754b1d80b83620.tar.gz
linux-stable-057e5fc03369f8f2ed9b2ca884754b1d80b83620.tar.bz2
linux-stable-057e5fc03369f8f2ed9b2ca884754b1d80b83620.zip
scsi: libsas: Refactor sas_ata_hard_reset()
Create function sas_ata_wait_after_reset() from sas_ata_hard_reset() as some LLDDs may want to check for a remote ATA phy is up after reset. Link: https://lore.kernel.org/r/1652354134-171343-2-git-send-email-john.garry@huawei.com Tested-by: Yihang Li <liyihang6@hisilicon.com> Reviewed-by: Xiang Chen <chenxiang66@hisilicon.com> Signed-off-by: John Garry <john.garry@huawei.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/libsas')
-rw-r--r--drivers/scsi/libsas/sas_ata.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index d34c82e24d9a..d35c9296f738 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -358,22 +358,14 @@ static int sas_ata_printk(const char *level, const struct domain_device *ddev,
return r;
}
-static int sas_ata_hard_reset(struct ata_link *link, unsigned int *class,
- unsigned long deadline)
+int sas_ata_wait_after_reset(struct domain_device *dev, unsigned long deadline)
{
- int ret = 0, res;
- struct sas_phy *phy;
- struct ata_port *ap = link->ap;
+ struct sata_device *sata_dev = &dev->sata_dev;
int (*check_ready)(struct ata_link *link);
- struct domain_device *dev = ap->private_data;
- struct sas_internal *i = dev_to_sas_internal(dev);
-
- 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");
+ struct ata_port *ap = sata_dev->ap;
+ struct ata_link *link = &ap->link;
+ struct sas_phy *phy;
+ int ret;
phy = sas_get_local_phy(dev);
if (scsi_is_sas_phy_local(phy))
@@ -386,6 +378,27 @@ static int sas_ata_hard_reset(struct ata_link *link, unsigned int *class,
if (ret && ret != -EAGAIN)
sas_ata_printk(KERN_ERR, dev, "reset failed (errno=%d)\n", ret);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(sas_ata_wait_after_reset);
+
+static int sas_ata_hard_reset(struct ata_link *link, unsigned int *class,
+ unsigned long deadline)
+{
+ struct ata_port *ap = link->ap;
+ struct domain_device *dev = ap->private_data;
+ struct sas_internal *i = dev_to_sas_internal(dev);
+ int ret;
+
+ ret = i->dft->lldd_I_T_nexus_reset(dev);
+ if (ret == -ENODEV)
+ return ret;
+
+ if (ret != TMF_RESP_FUNC_COMPLETE)
+ sas_ata_printk(KERN_DEBUG, dev, "Unable to reset ata device?\n");
+
+ ret = sas_ata_wait_after_reset(dev, deadline);
+
*class = dev->sata_dev.class;
ap->cbl = ATA_CBL_SATA;