* [RESEND PATCH 0/5] scsi: hisi_sas: Minor fixes and cleanups
@ 2023-12-14 3:45 chenxiang
2023-12-14 3:45 ` [RESEND PATCH 1/5] scsi: hisi_sas: Set .phy_attached before notifing phyup event HISI_PHYE_PHY_UP_PM chenxiang
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: chenxiang @ 2023-12-14 3:45 UTC (permalink / raw)
To: jejb, martin.petersen; +Cc: linuxarm, linux-scsi, Xiang Chen
From: Xiang Chen <chenxiang66@hisilicon.com>
This series contain some fixes and cleanups including:
- Set .phy_attached before notifying phyup event HISI_PHYEE_PHY_UP_PM;
- Use standard error code instead of hardcode;
- Check before using pointer variable;
- Rollback some operations if FLR failed;
- Correct the number of global debugfs registers;
Yihang Li (5):
scsi: hisi_sas: Set .phy_attached before notifing phyup event
HISI_PHYE_PHY_UP_PM
scsi: hisi_sas: Replace with standard error code return value
scsi: hisi_sas: Check before using pointer variables
scsi: hisi_sas: Rollback some operations if FLR failed
scsi: hisi_sas: Correct the number of global debugfs registers
drivers/scsi/hisi_sas/hisi_sas_main.c | 11 +++++++----
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 19 ++++++++++++-------
2 files changed, 19 insertions(+), 11 deletions(-)
--
2.8.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [RESEND PATCH 1/5] scsi: hisi_sas: Set .phy_attached before notifing phyup event HISI_PHYE_PHY_UP_PM
2023-12-14 3:45 [RESEND PATCH 0/5] scsi: hisi_sas: Minor fixes and cleanups chenxiang
@ 2023-12-14 3:45 ` chenxiang
2023-12-14 3:45 ` [RESEND PATCH 2/5] scsi: hisi_sas: Replace with standard error code return value chenxiang
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: chenxiang @ 2023-12-14 3:45 UTC (permalink / raw)
To: jejb, martin.petersen; +Cc: linuxarm, linux-scsi, Yihang Li, Xiang Chen
From: Yihang Li <liyihang9@huawei.com>
Currently in directly attached scenario, the phyup event
HISI_PHYE_PHY_UP_PM is notified before .phy_attached is set - this may
cause the phyup work hisi_sas_bytes_dmaed() execution failed and the
attached device will not be found.
To fix it, set .phy_attached before notifing phyup event.
Signed-off-by: Yihang Li <liyihang9@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
index d8437a9..f3eb5cd 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
@@ -1605,6 +1605,11 @@ static irqreturn_t phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba)
}
phy->port_id = port_id;
+ spin_lock(&phy->lock);
+ /* Delete timer and set phy_attached atomically */
+ del_timer(&phy->timer);
+ phy->phy_attached = 1;
+ spin_unlock(&phy->lock);
/*
* Call pm_runtime_get_noresume() which pairs with
@@ -1618,11 +1623,6 @@ static irqreturn_t phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba)
res = IRQ_HANDLED;
- spin_lock(&phy->lock);
- /* Delete timer and set phy_attached atomically */
- del_timer(&phy->timer);
- phy->phy_attached = 1;
- spin_unlock(&phy->lock);
end:
if (phy->reset_completion)
complete(phy->reset_completion);
--
2.8.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [RESEND PATCH 2/5] scsi: hisi_sas: Replace with standard error code return value
2023-12-14 3:45 [RESEND PATCH 0/5] scsi: hisi_sas: Minor fixes and cleanups chenxiang
2023-12-14 3:45 ` [RESEND PATCH 1/5] scsi: hisi_sas: Set .phy_attached before notifing phyup event HISI_PHYE_PHY_UP_PM chenxiang
@ 2023-12-14 3:45 ` chenxiang
2023-12-14 3:45 ` [RESEND PATCH 3/5] scsi: hisi_sas: Check before using pointer variables chenxiang
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: chenxiang @ 2023-12-14 3:45 UTC (permalink / raw)
To: jejb, martin.petersen; +Cc: linuxarm, linux-scsi, Yihang Li, Xiang Chen
From: Yihang Li <liyihang9@huawei.com>
In function hisi_sas_controller_prereset(), -ENOSYS (Function not
implemented) should be returned if the driver does not support .soft_reset.
Returns -EPERM (Operation not permitted) if HISI_SAS_RESETTING_BIT is
already be set.
In function _suspend_v3_hw(), returns -EPERM (Operation not permitted) if
HISI_SAS_RESETTING_BIT is already be set.
Fixes: 4522204ab218 ("scsi: hisi_sas: tidy host controller reset function a bit")
Signed-off-by: Yihang Li <liyihang9@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
drivers/scsi/hisi_sas/hisi_sas_main.c | 4 ++--
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index d50058b..1601706 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -1565,12 +1565,12 @@ EXPORT_SYMBOL_GPL(hisi_sas_controller_reset_done);
static int hisi_sas_controller_prereset(struct hisi_hba *hisi_hba)
{
if (!hisi_hba->hw->soft_reset)
- return -1;
+ return -ENOENT;
down(&hisi_hba->sem);
if (test_and_set_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags)) {
up(&hisi_hba->sem);
- return -1;
+ return -EPERM;
}
if (hisi_sas_debugfs_enable && hisi_hba->debugfs_itct[0].itct)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
index f3eb5cd..af2cc08 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
@@ -5018,7 +5018,7 @@ static int _suspend_v3_hw(struct device *device)
}
if (test_and_set_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags))
- return -1;
+ return -EPERM;
dev_warn(dev, "entering suspend state\n");
--
2.8.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [RESEND PATCH 3/5] scsi: hisi_sas: Check before using pointer variables
2023-12-14 3:45 [RESEND PATCH 0/5] scsi: hisi_sas: Minor fixes and cleanups chenxiang
2023-12-14 3:45 ` [RESEND PATCH 1/5] scsi: hisi_sas: Set .phy_attached before notifing phyup event HISI_PHYE_PHY_UP_PM chenxiang
2023-12-14 3:45 ` [RESEND PATCH 2/5] scsi: hisi_sas: Replace with standard error code return value chenxiang
@ 2023-12-14 3:45 ` chenxiang
2023-12-14 3:45 ` [RESEND PATCH 4/5] scsi: hisi_sas: Rollback some operations if FLR failed chenxiang
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: chenxiang @ 2023-12-14 3:45 UTC (permalink / raw)
To: jejb, martin.petersen; +Cc: linuxarm, linux-scsi, Yihang Li, Xiang Chen
From: Yihang Li <liyihang9@huawei.com>
In commit 4b329abc91800 ("scsi: hisi_sas: Move slot variable definition in
hisi_sas_abort_task()"), we move the variables slot to the function head.
However, the variable slot may be NULL, we should check it in each branch.
Fixes: 4b329abc9180 ("scsi: hisi_sas: Move slot variable definition in hisi_sas_abort_task()")
Signed-off-by: Yihang Li <liyihang9@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
drivers/scsi/hisi_sas/hisi_sas_main.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 1601706..bbb7b2d 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -1641,7 +1641,10 @@ static int hisi_sas_abort_task(struct sas_task *task)
task->task_state_flags |= SAS_TASK_STATE_ABORTED;
spin_unlock_irqrestore(&task->task_state_lock, flags);
- if (slot && task->task_proto & SAS_PROTOCOL_SSP) {
+ if (!slot)
+ goto out;
+
+ if (task->task_proto & SAS_PROTOCOL_SSP) {
u16 tag = slot->idx;
int rc2;
@@ -1688,7 +1691,7 @@ static int hisi_sas_abort_task(struct sas_task *task)
rc = hisi_sas_softreset_ata_disk(device);
}
}
- } else if (slot && task->task_proto & SAS_PROTOCOL_SMP) {
+ } else if (task->task_proto & SAS_PROTOCOL_SMP) {
/* SMP */
u32 tag = slot->idx;
struct hisi_sas_cq *cq = &hisi_hba->cq[slot->dlvry_queue];
--
2.8.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [RESEND PATCH 4/5] scsi: hisi_sas: Rollback some operations if FLR failed
2023-12-14 3:45 [RESEND PATCH 0/5] scsi: hisi_sas: Minor fixes and cleanups chenxiang
` (2 preceding siblings ...)
2023-12-14 3:45 ` [RESEND PATCH 3/5] scsi: hisi_sas: Check before using pointer variables chenxiang
@ 2023-12-14 3:45 ` chenxiang
2023-12-14 3:45 ` [RESEND PATCH 5/5] scsi: hisi_sas: Correct the number of global debugfs registers chenxiang
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: chenxiang @ 2023-12-14 3:45 UTC (permalink / raw)
To: jejb, martin.petersen; +Cc: linuxarm, linux-scsi, Yihang Li, Xiang Chen
From: Yihang Li <liyihang9@huawei.com>
We obtain the semaphore and set HISI_SAS_RESETTING_BIT in
hisi_sas_reset_prepare_v3_hw(), block the scsi host and set
HISI_SAS_REJECT_CMD_BIT in hisi_sas_controller_reset_prepare(),
released them in hisi_sas_controller_reset_done(). However, if the HW
reset failure in FLR results in early return, the semaphore and flag bits
will not be release.
Rollback some operations including clearing flags / releasing semaphore
when FLR is failed.
Fixes: e5ea48014adc ("scsi: hisi_sas: Implement handlers of PCIe FLR for v3 hw")
Signed-off-by: Yihang Li <liyihang9@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
index af2cc08..8473060 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
@@ -4968,6 +4968,7 @@ static void hisi_sas_reset_done_v3_hw(struct pci_dev *pdev)
{
struct sas_ha_struct *sha = pci_get_drvdata(pdev);
struct hisi_hba *hisi_hba = sha->lldd_ha;
+ struct Scsi_Host *shost = hisi_hba->shost;
struct device *dev = hisi_hba->dev;
int rc;
@@ -4976,6 +4977,10 @@ static void hisi_sas_reset_done_v3_hw(struct pci_dev *pdev)
rc = hw_init_v3_hw(hisi_hba);
if (rc) {
dev_err(dev, "FLR: hw init failed rc=%d\n", rc);
+ clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags);
+ scsi_unblock_requests(shost);
+ clear_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags);
+ up(&hisi_hba->sem);
return;
}
--
2.8.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [RESEND PATCH 5/5] scsi: hisi_sas: Correct the number of global debugfs registers
2023-12-14 3:45 [RESEND PATCH 0/5] scsi: hisi_sas: Minor fixes and cleanups chenxiang
` (3 preceding siblings ...)
2023-12-14 3:45 ` [RESEND PATCH 4/5] scsi: hisi_sas: Rollback some operations if FLR failed chenxiang
@ 2023-12-14 3:45 ` chenxiang
2023-12-14 4:25 ` [RESEND PATCH 0/5] scsi: hisi_sas: Minor fixes and cleanups Martin K. Petersen
2023-12-19 2:18 ` Martin K. Petersen
6 siblings, 0 replies; 8+ messages in thread
From: chenxiang @ 2023-12-14 3:45 UTC (permalink / raw)
To: jejb, martin.petersen; +Cc: linuxarm, linux-scsi, Yihang Li, Xiang Chen
From: Yihang Li <liyihang9@huawei.com>
In function debugfs_debugfs_snapshot_global_reg_v3_hw() it uses
debugfs_axi_reg.count (which is the number of axi debugfs registers) to
acquire the number of global debugfs registers.
Use debugfs_global_reg.count to acquire the number of global debugfs
registers instead.
Fixes: 623a4b6d5c2a ("scsi: hisi_sas: Move debugfs code to v3 hw driver")
Signed-off-by: Yihang Li <liyihang9@huawei.com>
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
index 8473060..b56fbc6 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
@@ -3476,7 +3476,7 @@ static void debugfs_snapshot_global_reg_v3_hw(struct hisi_hba *hisi_hba)
u32 *databuf = hisi_hba->debugfs_regs[dump_index][DEBUGFS_GLOBAL].data;
int i;
- for (i = 0; i < debugfs_axi_reg.count; i++, databuf++)
+ for (i = 0; i < debugfs_global_reg.count; i++, databuf++)
*databuf = hisi_sas_read32(hisi_hba, 4 * i);
}
--
2.8.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [RESEND PATCH 0/5] scsi: hisi_sas: Minor fixes and cleanups
2023-12-14 3:45 [RESEND PATCH 0/5] scsi: hisi_sas: Minor fixes and cleanups chenxiang
` (4 preceding siblings ...)
2023-12-14 3:45 ` [RESEND PATCH 5/5] scsi: hisi_sas: Correct the number of global debugfs registers chenxiang
@ 2023-12-14 4:25 ` Martin K. Petersen
2023-12-19 2:18 ` Martin K. Petersen
6 siblings, 0 replies; 8+ messages in thread
From: Martin K. Petersen @ 2023-12-14 4:25 UTC (permalink / raw)
To: chenxiang; +Cc: jejb, martin.petersen, linuxarm, linux-scsi
> This series contain some fixes and cleanups including:
> - Set .phy_attached before notifying phyup event HISI_PHYEE_PHY_UP_PM;
> - Use standard error code instead of hardcode;
> - Check before using pointer variable;
> - Rollback some operations if FLR failed;
> - Correct the number of global debugfs registers;
Applied to 6.8/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RESEND PATCH 0/5] scsi: hisi_sas: Minor fixes and cleanups
2023-12-14 3:45 [RESEND PATCH 0/5] scsi: hisi_sas: Minor fixes and cleanups chenxiang
` (5 preceding siblings ...)
2023-12-14 4:25 ` [RESEND PATCH 0/5] scsi: hisi_sas: Minor fixes and cleanups Martin K. Petersen
@ 2023-12-19 2:18 ` Martin K. Petersen
6 siblings, 0 replies; 8+ messages in thread
From: Martin K. Petersen @ 2023-12-19 2:18 UTC (permalink / raw)
To: jejb, chenxiang; +Cc: Martin K . Petersen, linuxarm, linux-scsi
On Thu, 14 Dec 2023 11:45:11 +0800, chenxiang wrote:
> This series contain some fixes and cleanups including:
> - Set .phy_attached before notifying phyup event HISI_PHYEE_PHY_UP_PM;
> - Use standard error code instead of hardcode;
> - Check before using pointer variable;
> - Rollback some operations if FLR failed;
> - Correct the number of global debugfs registers;
>
> [...]
Applied to 6.8/scsi-queue, thanks!
[1/5] scsi: hisi_sas: Set .phy_attached before notifing phyup event HISI_PHYE_PHY_UP_PM
https://git.kernel.org/mkp/scsi/c/ce26497c745d
[2/5] scsi: hisi_sas: Replace with standard error code return value
https://git.kernel.org/mkp/scsi/c/d34ee535705e
[3/5] scsi: hisi_sas: Check before using pointer variables
https://git.kernel.org/mkp/scsi/c/8dd10296be85
[4/5] scsi: hisi_sas: Rollback some operations if FLR failed
https://git.kernel.org/mkp/scsi/c/7ea3e7763c50
[5/5] scsi: hisi_sas: Correct the number of global debugfs registers
https://git.kernel.org/mkp/scsi/c/73e33f969ef0
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-12-19 2:19 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-14 3:45 [RESEND PATCH 0/5] scsi: hisi_sas: Minor fixes and cleanups chenxiang
2023-12-14 3:45 ` [RESEND PATCH 1/5] scsi: hisi_sas: Set .phy_attached before notifing phyup event HISI_PHYE_PHY_UP_PM chenxiang
2023-12-14 3:45 ` [RESEND PATCH 2/5] scsi: hisi_sas: Replace with standard error code return value chenxiang
2023-12-14 3:45 ` [RESEND PATCH 3/5] scsi: hisi_sas: Check before using pointer variables chenxiang
2023-12-14 3:45 ` [RESEND PATCH 4/5] scsi: hisi_sas: Rollback some operations if FLR failed chenxiang
2023-12-14 3:45 ` [RESEND PATCH 5/5] scsi: hisi_sas: Correct the number of global debugfs registers chenxiang
2023-12-14 4:25 ` [RESEND PATCH 0/5] scsi: hisi_sas: Minor fixes and cleanups Martin K. Petersen
2023-12-19 2:18 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox