Skip to content

Commit 9181ce3

Browse files
Jie Zhanmartinkpetersen
authored andcommitted
scsi: libsas: Add smp_ata_check_ready_type()
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 94a3555 commit 9181ce3

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

drivers/scsi/libsas/sas_ata.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,31 @@ static int sas_ata_clear_pending(struct domain_device *dev, struct ex_phy *phy)
287287
return 1;
288288
}
289289

290+
int smp_ata_check_ready_type(struct ata_link *link)
291+
{
292+
struct domain_device *dev = link->ap->private_data;
293+
struct sas_phy *phy = sas_get_local_phy(dev);
294+
struct domain_device *ex_dev = dev->parent;
295+
enum sas_device_type type = SAS_PHY_UNUSED;
296+
u8 sas_addr[SAS_ADDR_SIZE];
297+
int res;
298+
299+
res = sas_get_phy_attached_dev(ex_dev, phy->number, sas_addr, &type);
300+
sas_put_local_phy(phy);
301+
if (res)
302+
return res;
303+
304+
switch (type) {
305+
case SAS_SATA_PENDING:
306+
return 0;
307+
case SAS_END_DEVICE:
308+
return 1;
309+
default:
310+
return -ENODEV;
311+
}
312+
}
313+
EXPORT_SYMBOL_GPL(smp_ata_check_ready_type);
314+
290315
static int smp_ata_check_ready(struct ata_link *link)
291316
{
292317
int res;

drivers/scsi/libsas/sas_expander.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,8 +1688,8 @@ static int sas_get_phy_change_count(struct domain_device *dev,
16881688
return res;
16891689
}
16901690

1691-
static int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id,
1692-
u8 *sas_addr, enum sas_device_type *type)
1691+
int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id,
1692+
u8 *sas_addr, enum sas_device_type *type)
16931693
{
16941694
int res;
16951695
struct smp_disc_resp *disc_resp;

drivers/scsi/libsas/sas_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ struct domain_device *sas_ex_to_ata(struct domain_device *ex_dev, int phy_id);
8888
int sas_ex_phy_discover(struct domain_device *dev, int single);
8989
int sas_get_report_phy_sata(struct domain_device *dev, int phy_id,
9090
struct smp_rps_resp *rps_resp);
91+
int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id,
92+
u8 *sas_addr, enum sas_device_type *type);
9193
int sas_try_ata_reset(struct asd_sas_phy *phy);
9294
void sas_hae_reset(struct work_struct *work);
9395

include/scsi/sas_ata.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ void sas_ata_device_link_abort(struct domain_device *dev, bool force_reset);
3636
int sas_execute_ata_cmd(struct domain_device *device, u8 *fis,
3737
int force_phy_id);
3838
int sas_ata_wait_after_reset(struct domain_device *dev, unsigned long deadline);
39+
int smp_ata_check_ready_type(struct ata_link *link);
3940
#else
4041

4142

@@ -104,6 +105,11 @@ static inline int sas_ata_wait_after_reset(struct domain_device *dev,
104105
{
105106
return -ETIMEDOUT;
106107
}
108+
109+
static inline int smp_ata_check_ready_type(struct ata_link *link)
110+
{
111+
return 0;
112+
}
107113
#endif
108114

109115
#endif /* _SAS_ATA_H_ */

0 commit comments

Comments
 (0)