Johannes Thumshirn 36f427
From: Xiang Chen <chenxiang66@hisilicon.com>
Johannes Thumshirn 36f427
Date: Wed, 2 May 2018 23:56:31 +0800
Johannes Thumshirn 36f427
Subject: scsi: hisi_sas: config ATA de-reset as an constrained command for v3
Johannes Thumshirn 36f427
 hw
Johannes Thumshirn 36f427
Git-commit: 9413532788df7470297dd0475995c5dc5b07f362
Johannes Thumshirn 36f427
Patch-mainline: v4.18-rc1
Johannes Thumshirn 36f427
References: FATE#326253
Johannes Thumshirn 36f427
Johannes Thumshirn 36f427
As a unconstrained command, a command can be sent to SATA disk even if
Johannes Thumshirn 36f427
SATA disk status is BUSY, ERR or DRQ.
Johannes Thumshirn 36f427
Johannes Thumshirn 36f427
If an ATA reset assert is successful but ATA reset de-assert fails, then
Johannes Thumshirn 36f427
it will retry the reset de-assert. If reset de- assert retry is
Johannes Thumshirn 36f427
successful, we think it is okay to probe the device but actually it
Johannes Thumshirn 36f427
still has Err status.
Johannes Thumshirn 36f427
Johannes Thumshirn 36f427
Apparently we need to retry the ATA reset assertion and de- assertion
Johannes Thumshirn 36f427
instead for this mentioned scenario.
Johannes Thumshirn 36f427
Johannes Thumshirn 36f427
As such, we config ATA reset assert as a constrained command, if ATA
Johannes Thumshirn 36f427
reset de-assert fails, then ATA reset de-assert retry will also
Johannes Thumshirn 36f427
fail. Then we will retry the proper process of ATA reset assert and
Johannes Thumshirn 36f427
de-assert again.
Johannes Thumshirn 36f427
Johannes Thumshirn 36f427
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Johannes Thumshirn 36f427
Signed-off-by: John Garry <john.garry@huawei.com>
Johannes Thumshirn 36f427
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Johannes Thumshirn 36f427
Acked-by: Johannes Thumshirn <jthumshirn@suse.de>
Johannes Thumshirn 36f427
---
Johannes Thumshirn 36f427
 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 11 ++++++-----
Johannes Thumshirn 36f427
 1 file changed, 6 insertions(+), 5 deletions(-)
Johannes Thumshirn 36f427
Johannes Thumshirn 36f427
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
Johannes Thumshirn 36f427
index ffa3cea5ca8f..026faeee5ead 100644
Johannes Thumshirn 36f427
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
Johannes Thumshirn 36f427
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
Johannes Thumshirn 36f427
@@ -351,10 +351,11 @@ struct hisi_sas_err_record_v3 {
Johannes Thumshirn 36f427
 #define DIR_TO_DEVICE 2
Johannes Thumshirn 36f427
 #define DIR_RESERVED 3
Johannes Thumshirn 36f427
 
Johannes Thumshirn 36f427
-#define CMD_IS_UNCONSTRAINT(cmd) \
Johannes Thumshirn 36f427
-	((cmd == ATA_CMD_READ_LOG_EXT) || \
Johannes Thumshirn 36f427
-	(cmd == ATA_CMD_READ_LOG_DMA_EXT) || \
Johannes Thumshirn 36f427
-	(cmd == ATA_CMD_DEV_RESET))
Johannes Thumshirn 36f427
+#define FIS_CMD_IS_UNCONSTRAINED(fis) \
Johannes Thumshirn 36f427
+	((fis.command == ATA_CMD_READ_LOG_EXT) || \
Johannes Thumshirn 36f427
+	(fis.command == ATA_CMD_READ_LOG_DMA_EXT) || \
Johannes Thumshirn 36f427
+	((fis.command == ATA_CMD_DEV_RESET) && \
Johannes Thumshirn 36f427
+	((fis.control & ATA_SRST) != 0)))
Johannes Thumshirn 36f427
 
Johannes Thumshirn 36f427
 static u32 hisi_sas_read32(struct hisi_hba *hisi_hba, u32 off)
Johannes Thumshirn 36f427
 {
Johannes Thumshirn 36f427
@@ -1075,7 +1076,7 @@ static int prep_ata_v3_hw(struct hisi_hba *hisi_hba,
Johannes Thumshirn 36f427
 		<< CMD_HDR_FRAME_TYPE_OFF;
Johannes Thumshirn 36f427
 	dw1 |= sas_dev->device_id << CMD_HDR_DEV_ID_OFF;
Johannes Thumshirn 36f427
 
Johannes Thumshirn 36f427
-	if (CMD_IS_UNCONSTRAINT(task->ata_task.fis.command))
Johannes Thumshirn 36f427
+	if (FIS_CMD_IS_UNCONSTRAINED(task->ata_task.fis))
Johannes Thumshirn 36f427
 		dw1 |= 1 << CMD_HDR_UNCON_CMD_OFF;
Johannes Thumshirn 36f427
 
Johannes Thumshirn 36f427
 	hdr->dw1 = cpu_to_le32(dw1);
Johannes Thumshirn 36f427