scsi: libsas: Add smp_ata_check_ready_type()
authorJie Zhan <zhanjie9@hisilicon.com>
Fri, 18 Nov 2022 08:37:12 +0000 (16:37 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Feb 2023 10:25:39 +0000 (11:25 +0100)
[ Upstream commit 9181ce3cb5d96f0ee28246a857ca651830fa3746 ]

Create function smp_ata_check_ready_type() for LLDDs to wait for SATA
devices to come up after a link reset.

Signed-off-by: Jie Zhan <zhanjie9@hisilicon.com>
Link: https://lore.kernel.org/r/20221118083714.4034612-4-zhanjie9@hisilicon.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Stable-dep-of: 3c2673a09cf1 ("scsi: hisi_sas: Fix SATA devices missing issue during I_T nexus reset")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/libsas/sas_ata.c
drivers/scsi/libsas/sas_expander.c
drivers/scsi/libsas/sas_internal.h
include/scsi/sas_ata.h

index d35c9296f7388cae8598e178a16615e9feecd736..2fd55ef9ffca5c1bb55076ff3a24f91120b817d1 100644 (file)
@@ -287,6 +287,31 @@ static int sas_ata_clear_pending(struct domain_device *dev, struct ex_phy *phy)
                return 1;
 }
 
+int smp_ata_check_ready_type(struct ata_link *link)
+{
+       struct domain_device *dev = link->ap->private_data;
+       struct sas_phy *phy = sas_get_local_phy(dev);
+       struct domain_device *ex_dev = dev->parent;
+       enum sas_device_type type = SAS_PHY_UNUSED;
+       u8 sas_addr[SAS_ADDR_SIZE];
+       int res;
+
+       res = sas_get_phy_attached_dev(ex_dev, phy->number, sas_addr, &type);
+       sas_put_local_phy(phy);
+       if (res)
+               return res;
+
+       switch (type) {
+       case SAS_SATA_PENDING:
+               return 0;
+       case SAS_END_DEVICE:
+               return 1;
+       default:
+               return -ENODEV;
+       }
+}
+EXPORT_SYMBOL_GPL(smp_ata_check_ready_type);
+
 static int smp_ata_check_ready(struct ata_link *link)
 {
        int res;
index 5ce2518301040a7ce660787a08e717bcd2616680..63a23251fb1d87d7958d544f753067205e1b901f 100644 (file)
@@ -1693,8 +1693,8 @@ static int sas_get_phy_change_count(struct domain_device *dev,
        return res;
 }
 
-static int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id,
-                                   u8 *sas_addr, enum sas_device_type *type)
+int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id,
+                            u8 *sas_addr, enum sas_device_type *type)
 {
        int res;
        struct smp_disc_resp *disc_resp;
index 8d0ad3abc7b5c7942165ec8f0a1b9069b79a4709..a94bd0790b05573c922682d7830b1b5eafe6d734 100644 (file)
@@ -84,6 +84,8 @@ struct domain_device *sas_ex_to_ata(struct domain_device *ex_dev, int phy_id);
 int sas_ex_phy_discover(struct domain_device *dev, int single);
 int sas_get_report_phy_sata(struct domain_device *dev, int phy_id,
                            struct smp_rps_resp *rps_resp);
+int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id,
+                            u8 *sas_addr, enum sas_device_type *type);
 int sas_try_ata_reset(struct asd_sas_phy *phy);
 void sas_hae_reset(struct work_struct *work);
 
index a1df4f9d57a31eefdfeb58067af29ed67260808b..ec646217e7f6e0679a9d4449c797043de5813b51 100644 (file)
@@ -35,6 +35,7 @@ void sas_ata_end_eh(struct ata_port *ap);
 int sas_execute_ata_cmd(struct domain_device *device, u8 *fis,
                        int force_phy_id);
 int sas_ata_wait_after_reset(struct domain_device *dev, unsigned long deadline);
+int smp_ata_check_ready_type(struct ata_link *link);
 #else
 
 
@@ -98,6 +99,11 @@ static inline int sas_ata_wait_after_reset(struct domain_device *dev,
 {
        return -ETIMEDOUT;
 }
+
+static inline int smp_ata_check_ready_type(struct ata_link *link)
+{
+       return 0;
+}
 #endif
 
 #endif /* _SAS_ATA_H_ */