Skip to content

Commit 750d4fb

Browse files
Xingui Yangmartinkpetersen
authored andcommitted
scsi: hisi_sas: Fixed failure to issue vendor specific commands
At present, we determine the protocol through the cmd type, but other cmd types, such as vendor-specific commands, default to the PIO protocol. This strategy often causes the execution of different vendor-specific commands to fail. In fact, for these commands, a better way is to use the protocol configured by the command's tf to determine its protocol. Fixes: 6f2ff1a ("hisi_sas: add v2 path to send ATA command") Signed-off-by: Xingui Yang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Yihang Li <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent bd06776 commit 750d4fb

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

drivers/scsi/hisi_sas/hisi_sas.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,7 @@ extern struct dentry *hisi_sas_debugfs_dir;
633633
extern void hisi_sas_stop_phys(struct hisi_hba *hisi_hba);
634634
extern int hisi_sas_alloc(struct hisi_hba *hisi_hba);
635635
extern void hisi_sas_free(struct hisi_hba *hisi_hba);
636-
extern u8 hisi_sas_get_ata_protocol(struct host_to_dev_fis *fis,
637-
int direction);
636+
extern u8 hisi_sas_get_ata_protocol(struct sas_task *task);
638637
extern struct hisi_sas_port *to_hisi_sas_port(struct asd_sas_port *sas_port);
639638
extern void hisi_sas_sata_done(struct sas_task *task,
640639
struct hisi_sas_slot *slot);

drivers/scsi/hisi_sas/hisi_sas_main.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,32 @@ struct hisi_sas_internal_abort_data {
2121
bool rst_ha_timeout; /* reset the HA for timeout */
2222
};
2323

24-
u8 hisi_sas_get_ata_protocol(struct host_to_dev_fis *fis, int direction)
24+
static u8 hisi_sas_get_ata_protocol_from_tf(struct ata_queued_cmd *qc)
2525
{
26+
if (!qc)
27+
return HISI_SAS_SATA_PROTOCOL_PIO;
28+
29+
switch (qc->tf.protocol) {
30+
case ATA_PROT_NODATA:
31+
return HISI_SAS_SATA_PROTOCOL_NONDATA;
32+
case ATA_PROT_PIO:
33+
return HISI_SAS_SATA_PROTOCOL_PIO;
34+
case ATA_PROT_DMA:
35+
return HISI_SAS_SATA_PROTOCOL_DMA;
36+
case ATA_PROT_NCQ_NODATA:
37+
case ATA_PROT_NCQ:
38+
return HISI_SAS_SATA_PROTOCOL_FPDMA;
39+
default:
40+
return HISI_SAS_SATA_PROTOCOL_PIO;
41+
}
42+
}
43+
44+
u8 hisi_sas_get_ata_protocol(struct sas_task *task)
45+
{
46+
struct host_to_dev_fis *fis = &task->ata_task.fis;
47+
struct ata_queued_cmd *qc = task->uldd_task;
48+
int direction = task->data_dir;
49+
2650
switch (fis->command) {
2751
case ATA_CMD_FPDMA_WRITE:
2852
case ATA_CMD_FPDMA_READ:
@@ -93,7 +117,7 @@ u8 hisi_sas_get_ata_protocol(struct host_to_dev_fis *fis, int direction)
93117
{
94118
if (direction == DMA_NONE)
95119
return HISI_SAS_SATA_PROTOCOL_NONDATA;
96-
return HISI_SAS_SATA_PROTOCOL_PIO;
120+
return hisi_sas_get_ata_protocol_from_tf(qc);
97121
}
98122
}
99123
}

drivers/scsi/hisi_sas/hisi_sas_v2_hw.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,9 +2538,7 @@ static void prep_ata_v2_hw(struct hisi_hba *hisi_hba,
25382538
(task->ata_task.fis.control & ATA_SRST))
25392539
dw1 |= 1 << CMD_HDR_RESET_OFF;
25402540

2541-
dw1 |= (hisi_sas_get_ata_protocol(
2542-
&task->ata_task.fis, task->data_dir))
2543-
<< CMD_HDR_FRAME_TYPE_OFF;
2541+
dw1 |= (hisi_sas_get_ata_protocol(task)) << CMD_HDR_FRAME_TYPE_OFF;
25442542
dw1 |= sas_dev->device_id << CMD_HDR_DEV_ID_OFF;
25452543
hdr->dw1 = cpu_to_le32(dw1);
25462544

drivers/scsi/hisi_sas/hisi_sas_v3_hw.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,9 +1456,7 @@ static void prep_ata_v3_hw(struct hisi_hba *hisi_hba,
14561456
(task->ata_task.fis.control & ATA_SRST))
14571457
dw1 |= 1 << CMD_HDR_RESET_OFF;
14581458

1459-
dw1 |= (hisi_sas_get_ata_protocol(
1460-
&task->ata_task.fis, task->data_dir))
1461-
<< CMD_HDR_FRAME_TYPE_OFF;
1459+
dw1 |= (hisi_sas_get_ata_protocol(task)) << CMD_HDR_FRAME_TYPE_OFF;
14621460
dw1 |= sas_dev->device_id << CMD_HDR_DEV_ID_OFF;
14631461

14641462
if (FIS_CMD_IS_UNCONSTRAINED(task->ata_task.fis))

0 commit comments

Comments
 (0)