From aaea70a1683b05a6d12abc884b1f0d9f218812db Mon Sep 17 00:00:00 2001 From: Xingui Yang Date: Mon, 20 Dec 2021 20:45:48 +0800 Subject: [PATCH] scsi: hisi_sas: Add support for sata disk I/O errors report to libsas driver inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I4NDM8 CVE: NA --------------------------- If the response frame has been written back to the memory and carries the disk error and status when sata I/O completion abnormally, then set task stat to SAS_PROTO_RESPONSE and let libsas to handle it. Signed-off-by: Xingui Yang Reviewed-by: Kangfenglong Signed-off-by: Yang Yingliang --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 4508c4a2f02f..3c662fa5f6c0 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -470,6 +470,9 @@ struct hisi_sas_err_record_v3 { #define RX_DATA_LEN_UNDERFLOW_OFF 6 #define RX_DATA_LEN_UNDERFLOW_MSK (1 << RX_DATA_LEN_UNDERFLOW_OFF) +#define RX_FIS_STATUS_ERR_OFF 0 +#define RX_FIS_STATUS_ERR_MSK (1 << RX_FIS_STATUS_ERR_OFF) + #define HISI_SAS_COMMAND_ENTRIES_V3_HW 4096 #define HISI_SAS_MSI_COUNT_V3_HW 32 @@ -2241,17 +2244,20 @@ slot_err_v3_hw(struct hisi_hba *hisi_hba, struct sas_task *task, hisi_sas_status_buf_addr_mem(slot); u32 dma_rx_err_type = record->dma_rx_err_type; u32 trans_tx_fail_type = record->trans_tx_fail_type; + u16 sipc_rx_err_type = le16_to_cpu(record->sipc_rx_err_type); + u32 dw0 = le32_to_cpu(complete_hdr->dw0); + u32 dw3 = le32_to_cpu(complete_hdr->dw3); switch (task->task_proto) { case SAS_PROTOCOL_SSP: if (dma_rx_err_type & RX_DATA_LEN_UNDERFLOW_MSK) { ts->residual = trans_tx_fail_type; ts->stat = SAS_DATA_UNDERRUN; - if ((!(complete_hdr->dw0 & CMPLT_HDR_RSPNS_GOOD_MSK)) && - (complete_hdr->dw0 & CMPLT_HDR_RSPNS_XFRD_MSK)) { + if (!(dw0 & CMPLT_HDR_RSPNS_GOOD_MSK) && + (dw0 & CMPLT_HDR_RSPNS_XFRD_MSK)) { hisi_sas_set_sense_data(task, slot); } - } else if (complete_hdr->dw3 & CMPLT_HDR_IO_IN_TARGET_MSK) { + } else if (dw3 & CMPLT_HDR_IO_IN_TARGET_MSK) { ts->stat = SAS_QUEUE_FULL; slot->abort = 1; } else { @@ -2262,7 +2268,10 @@ slot_err_v3_hw(struct hisi_hba *hisi_hba, struct sas_task *task, case SAS_PROTOCOL_SATA: case SAS_PROTOCOL_STP: case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP: - if (complete_hdr->dw3 & CMPLT_HDR_IO_IN_TARGET_MSK) { + if ((dw0 & CMPLT_HDR_RSPNS_XFRD_MSK) && + (sipc_rx_err_type & RX_FIS_STATUS_ERR_MSK)) { + ts->stat = SAS_PROTO_RESPONSE; + } else if (dw3 & CMPLT_HDR_IO_IN_TARGET_MSK) { ts->stat = SAS_PHY_DOWN; slot->abort = 1; } else if (dma_rx_err_type & RX_DATA_LEN_UNDERFLOW_MSK) { -- GitLab