Skip to contentSkip to conversation

Some misc changes

PATCH Applied chenxiang 2 participants 6 messages Jul 11, 2023 – Jul 26, 2023

Subsystems (2)
lore
Share & tools
lore

chenxiang

author
#0 lore raw

cover Some misc changes

From: Xiang Chen <[email protected]>

This series contain some fixes including:
- Fix completed I/O analysed as failed
- Block requests before a debugfs snapshot
- Delete unused lock in function hisi_sas_port_notify_formed()

Xingui Yang (1):
scsi: hisi_sas: Fix normally completed I/O analysed as failed

Yihang Li (2):
scsi: hisi_sas: Block requests before a debugfs snapshot
scsi: hisi_sas: Delete unused lock in hisi_sas_port_notify_formed()

 drivers/scsi/hisi_sas/hisi_sas_main.c  |  5 -----
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 11 +++++++++--
 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 16 +++++++++++-----
 3 files changed, 20 insertions(+), 12 deletions(-)
Signature · 1 line
2.8.1
author
#1 lore raw

PATCH 1/3 scsi: hisi_sas: Fix normally completed I/O analysed as failed

From: Xingui Yang <[email protected]>

Pio read command has no response frame and the struct iu[1024] won't be filled, and it's found that I/Os which are normally completed will be analysed as failed in sas_ata_task_done() when iu contain abnormal dirty data. So ending_fis should not be filled by iu when the response frame hasn't been written to the memory.

Fixes d380f55503ed ("scsi: hisi_sas: Don't bother clearing status buffer IU in task prep")
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 11 +++++++++--
 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c |  6 ++++--
 2 files changed, 13 insertions(+), 4 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +9 -2
index 87d8e40..404aa7e 100644
@@ -2026,6 +2026,11 @@ static void slot_err_v2_hw(struct hisi_hba *hisi_hba,
 	u16 dma_tx_err_type = le16_to_cpu(err_record->dma_tx_err_type);
 	u16 sipc_rx_err_type = le16_to_cpu(err_record->sipc_rx_err_type);
 	u32 dma_rx_err_type = le32_to_cpu(err_record->dma_rx_err_type);
+	struct hisi_sas_complete_v2_hdr *complete_queue =
+			hisi_hba->complete_hdr[slot->cmplt_queue];
+	struct hisi_sas_complete_v2_hdr *complete_hdr =
+			&complete_queue[slot->cmplt_queue_slot];
+	u32 dw0 = le32_to_cpu(complete_hdr->dw0);
 	int error = -1;
 
 	if (err_phase == 1) {
@@ -2310,7 +2315,8 @@ static void slot_err_v2_hw(struct hisi_hba *hisi_hba,
 			break;
 		}
 		}
-		hisi_sas_sata_done(task, slot);
+		if (dw0 & CMPLT_HDR_RSPNS_XFRD_MSK)
+			hisi_sas_sata_done(task, slot);
 	}
 		break;
 	default:
@@ -2443,7 +2449,8 @@ static void slot_complete_v2_hw(struct hisi_hba *hisi_hba,
 	case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:
 	{
 		ts->stat = SAS_SAM_STAT_GOOD;
-		hisi_sas_sata_done(task, slot);
+		if (dw0 & CMPLT_HDR_RSPNS_XFRD_MSK)
+			hisi_sas_sata_done(task, slot);
 		break;
 	}
 	default:
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +4 -2
index 20e1607..2f33e6b 100644
@@ -2257,7 +2257,8 @@ slot_err_v3_hw(struct hisi_hba *hisi_hba, struct sas_task *task,
 			ts->stat = SAS_OPEN_REJECT;
 			ts->open_rej_reason = SAS_OREJ_RSVD_RETRY;
 		}
-		hisi_sas_sata_done(task, slot);
+		if (dw0 & CMPLT_HDR_RSPNS_XFRD_MSK)
+			hisi_sas_sata_done(task, slot);
 		break;
 	case SAS_PROTOCOL_SMP:
 		ts->stat = SAS_SAM_STAT_CHECK_CONDITION;
@@ -2384,7 +2385,8 @@ static void slot_complete_v3_hw(struct hisi_hba *hisi_hba,
 	case SAS_PROTOCOL_STP:
 	case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:
 		ts->stat = SAS_SAM_STAT_GOOD;
-		hisi_sas_sata_done(task, slot);
+		if (dw0 & CMPLT_HDR_RSPNS_XFRD_MSK)
+			hisi_sas_sata_done(task, slot);
 		break;
 	default:
 		ts->stat = SAS_SAM_STAT_CHECK_CONDITION;
Signature · 1 line
2.8.1
author
#2 lore raw

PATCH 2/3 scsi: hisi_sas: Block requests before a debugfs snapshot

In reply to chenxiang

From: Yihang Li <[email protected]>

When FIO and debugfs snapshot occur concurrently, some SATA I/Os are failed to return to the upper layer due to the setting of HISI_SAS_REJECT_CMD_BIT. Then the SCSI layer invokes the error processing thread. However, sas_ata_hard_reset() in EH also fails to be reset due to
the setting of HISI_SAS_REJECT_CMD_BIT. As a result, the device is disabled.

Calling scsi_block_requests() in the front of a debugfs snapshot and wait command complete before setting HISI_SAS_REJECT_CMD_BIT to avoid SATA I/O failures.

---
 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +7 -3
index 2f33e6b..7aad495 100644
@@ -3106,21 +3106,25 @@ static const struct hisi_sas_debugfs_reg debugfs_ras_reg = {
 
 static void debugfs_snapshot_prepare_v3_hw(struct hisi_hba *hisi_hba)
 {
-	set_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags);
-
-	hisi_sas_write32(hisi_hba, DLVRY_QUEUE_ENABLE, 0);
+	struct Scsi_Host *shost = hisi_hba->shost;
 
+	scsi_block_requests(shost);
 	wait_cmds_complete_timeout_v3_hw(hisi_hba, 100, 5000);
 
+	set_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags);
 	hisi_sas_sync_cqs(hisi_hba);
+	hisi_sas_write32(hisi_hba, DLVRY_QUEUE_ENABLE, 0);
 }
 
 static void debugfs_snapshot_restore_v3_hw(struct hisi_hba *hisi_hba)
 {
+	struct Scsi_Host *shost = hisi_hba->shost;
+
 	hisi_sas_write32(hisi_hba, DLVRY_QUEUE_ENABLE,
 			 (u32)((1ULL << hisi_hba->queue_count) - 1));
 
 	clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags);
+	scsi_unblock_requests(shost);
 }
 
 static void read_iost_itct_cache_v3_hw(struct hisi_hba *hisi_hba,
Signature · 1 line
2.8.1
author
#3 lore raw

PATCH 3/3 scsi: hisi_sas: Delete unused lock in hisi_sas_port_notify_formed()

In reply to chenxiang

From: Yihang Li <[email protected]>

Currently spinlock hisi_hba->lock is used by interrupt and thread together which require to use spin_lock_irqsave/spin_unlcok_irqrestore, but some places still use spin_lock/unlock.
Check with the code and find there is no necessary to use hisi_hba->lock in function hisi_sas_port_notify_formed() which is the only place that use spinlock in interrupt. So delete unused lock in hisi_sas_port_notify_formed().

---
 drivers/scsi/hisi_sas/hisi_sas_main.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +0 -5
index 8f22ece..7a62590 100644
@@ -1065,23 +1065,18 @@ EXPORT_SYMBOL_GPL(hisi_sas_phy_enable);
 
 static void hisi_sas_port_notify_formed(struct asd_sas_phy *sas_phy)
 {
-	struct sas_ha_struct *sas_ha = sas_phy->ha;
-	struct hisi_hba *hisi_hba = sas_ha->lldd_ha;
 	struct hisi_sas_phy *phy = sas_phy->lldd_phy;
 	struct asd_sas_port *sas_port = sas_phy->port;
 	struct hisi_sas_port *port;
-	unsigned long flags;
 
 	if (!sas_port)
 		return;
 
 	port = to_hisi_sas_port(sas_port);
-	spin_lock_irqsave(&hisi_hba->lock, flags);
 	port->port_attached = 1;
 	port->id = phy->port_id;
 	phy->port = port;
 	sas_port->lldd_port = port;
-	spin_unlock_irqrestore(&hisi_hba->lock, flags);
 }
 
 static void hisi_sas_do_release_task(struct hisi_hba *hisi_hba, struct sas_task *task,
Signature · 1 line
2.8.1
#4 lore raw
In reply to chenxiang
Quoted 5 lines

This series contain some fixes including:
- Fix completed I/O analysed as failed
- Block requests before a debugfs snapshot
- Delete unused lock in function hisi_sas_port_notify_formed()

Applied to 6.6/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#5 lore raw
In reply to chenxiang
Quoted 9 lines · chenxiang

This series contain some fixes including:
- Fix completed I/O analysed as failed
- Block requests before a debugfs snapshot
- Delete unused lock in function hisi_sas_port_notify_formed()

Xingui Yang (1):
scsi: hisi_sas: Fix normally completed I/O analysed as failed

[...]

Applied to 6.6/scsi-queue, thanks!

[1/3] scsi: hisi_sas: Fix normally completed I/O analysed as failed

      https://git.kernel.org/mkp/scsi/c/f5393a5602ca
[2/3] scsi: hisi_sas: Block requests before a debugfs snapshot
      https://git.kernel.org/mkp/scsi/c/32be33747d5d
[3/3] scsi: hisi_sas: Delete unused lock in hisi_sas_port_notify_formed()
      https://git.kernel.org/mkp/scsi/c/29f45ed18aa9
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering