hisi_sas: Some misc patches
Subsystems (2)
cover hisi_sas: Some misc patches
The patchset contains some misc patches for the driver, including:
- Workaround for acute scenario of SMP/internal IO timeout and reset racing
- Clear Affiliation for STP target port (from Luo Jiaxing and Xiang Chen)
- Fix PHY negotiated linkrate value for when PHY down
- Some init reg config changes
- Add support to coalesce and print PHY errors
- A tidy-up patch
John Garry (1):
scsi: hisi_sas: Set PHY linkrate when disconnected
Xiang Chen (4):
scsi: hisi_sas: Change return variable type in phy_up_v3_hw()
scsi: hisi_sas: Fix a timeout race of driver internal and SMP IO
scsi: hisi_sas: Send HARD RESET to clear the previous affiliation of
STP target port
scsi: hisi_sas: Change SERDES_CFG init value to increase reliability
of HiLink
Xiaofei Tan (1):
scsi: hisi_sas: print PHY RX errors count for later revision of v3 hw
drivers/scsi/hisi_sas/hisi_sas.h | 8 +++ drivers/scsi/hisi_sas/hisi_sas_main.c | 57 +++++++++++++++-- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 + drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 89 ++++++++++++++++++-------- 4 files changed, 125 insertions(+), 30 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/6 scsi: hisi_sas: Change return variable type in phy_up_v3_hw()
From: Xiang Chen <[email protected]>
According to the tool fortify, phy_up_v3_hw() returns signed value, while it should return an unsigned value.
So change variable "res" from int to irq_return_t.
--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +2 -1
@@ -1344,7 +1344,8 @@ static void prep_abort_v3_hw(struct hisi_hba *hisi_hba,static irqreturn_t phy_up_v3_hw (int phy_no,struct hisi_hba *hisi_hba) { -int i, res; +int i; +irqreturn_t res;u32 context, port_id, link_rate;struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];struct asd_sas_phy *sas_phy = &phy->sas_phy;
Signature · 1 line
2.17.1
PATCH 2/6 scsi: hisi_sas: Fix a timeout race of driver internal and SMP IO
In reply to John GarryFrom: Xiang Chen <[email protected]>
For internal IO and SMP IO, there is a time-out timer for them. In the timer handler, it checks whether IO is done according to the flag task->task_state_lock.
There is an issue which may cause system suspended: internal IO or SMP IO is sent, but at that time because of hardware exception (such as inject 2Bit ECC error), so IO is not completed and also not timeout. But, at that time, the SAS controller reset occurs to recover system. It will release the resource and set the status of IO to be SAS_TASK_STATE_DONE, so when IO timeout, it will never complete the completion of IO and wait for ever.
[ 729.123632] Call trace: [ 729.126791] [<ffff00000808655c>] __switch_to+0x94/0xa8 [ 729.133106] [<ffff000008d96e98>] __schedule+0x1e8/0x7fc [ 729.138975] [<ffff000008d974e0>] schedule+0x34/0x8c [ 729.144401] [<ffff000008d9b000>] schedule_timeout+0x1d8/0x3cc [ 729.150690] [<ffff000008d98218>] wait_for_common+0xdc/0x1a0 [ 729.157101] [<ffff000008d98304>] wait_for_completion+0x28/0x34 [ 729.165973] [<ffff000000dcefb4>] hisi_sas_internal_task_abort+0x2a0/0x424 [hisi_sas_test_main] [ 729.176447] [<ffff000000dd18f4>] hisi_sas_abort_task+0x244/0x2d8 [hisi_sas_test_main] [ 729.185258] [<ffff000008971714>] sas_eh_handle_sas_errors+0x1c8/0x7b8 [ 729.192391] [<ffff000008972774>] sas_scsi_recover_host+0x130/0x398 [ 729.199237] [<ffff00000894d8a8>] scsi_error_handler+0x148/0x5c0 [ 729.206009] [<ffff0000080f4118>] kthread+0x10c/0x138 [ 729.211563] [<ffff0000080855dc>] ret_from_fork+0x10/0x18
To solve the issue, callback function task_done of those IOs need to be called when on SAS controller reset.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +2 -1
@@ -980,7 +980,8 @@ static void hisi_sas_do_release_task(struct hisi_hba *hisi_hba, struct sas_taskspin_lock_irqsave (&task->task_state_lock, flags); task->task_state_flags &= ~(SAS_TASK_STATE_PENDING |SAS_TASK_AT_INITIATOR ); - task->task_state_flags |=SAS_TASK_STATE_DONE ; +if (!slot->is_internal && task->task_proto !=SAS_PROTOCOL_SMP ) + task->task_state_flags |=SAS_TASK_STATE_DONE ;spin_unlock_irqrestore (&task->task_state_lock, flags); }
Signature · 1 line
2.17.1
PATCH 3/6 scsi: hisi_sas: print PHY RX errors count for later revision of v3 hw
In reply to John GarryFrom: Xiaofei Tan <[email protected]>
The later revision of v3 hw has added an function of interrupt coalesce according to time for PHY RX errors. We set the coalesce time to 1s. Then we print PHY RX errors count when PHY RX errors happen, and don't need to worry that there may be too much log prints.
Besides, we use hisi_sas_phy.lock to protect error count value. Because we update them by calling phy_get_events_v3_hw(), which is also used by core driver (for get PHY events function).
We relocate phy_get_events_v3_hw() to avoid a further declaration.
--- drivers/scsi/hisi_sas/hisi_sas.h | 1 + drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 84 ++++++++++++++++++-------- 2 files changed, 60 insertions(+), 25 deletions(-)
drivers/scsi/hisi_sas/hisi_sas.h +1 -0
@@ -161,6 +161,7 @@ struct hisi_sas_phy {u8 in_reset;u8 reserved[2 ];u32 phy_type; +u32 code_violation_err_count;enum sas_linkrate minimum_linkrate;enum sas_linkrate maximum_linkrate; };
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +59 -25
120 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 4/6 scsi: hisi_sas: Set PHY linkrate when disconnected
In reply to John GarryWhen the PHY comes down, we currently do not set the negotiated linkrate:
root@(none)$ pwd /sys/class/sas_phy/phy-0:0 root@(none)$ more enable 1 root@(none)$ more negotiated_linkrate 12.0 Gbit root@(none)$ echo 0 > enable root@(none)$ more negotiated_linkrate 12.0 Gbit root@(none)$
This patch fixes the driver code to set it properly when the PHY comes down.
If the PHY had been enabled, then set unknown; otherwise, flag as disabled.
The logical place to set the negotiated linkrate for this scenario is PHY down routine, which is called from the PHY down ISR.
However, it is not possible to know if the PHY comes down due to PHY disable or loss of link, as sas_phy.enabled member is not set until after the transport disable routine is complete, which races with the PHY down ISR.
As an imperfect solution, use sas_phy_data.enable as the flag to know if the PHY is down due to disable. It's imperfect, as sas_phy_data is internal to libsas.
I can't see another way without adding a new field to hisi_sas_phy and managing it, or changing SCSI SAS transport.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/scsi/hisi_sas/hisi_sas_main.c +10 -0
@@ -10,6 +10,7 @@*/ #include "hisi_sas.h" +#include "../libsas/sas_internal.h" #define DRV_NAME "hisi_sas"#define DEV_IS_GONE (dev) \
@@ -2126,9 +2127,18 @@ static int hisi_sas_write_gpio(struct sas_ha_struct *sha, u8 reg_type,static void hisi_sas_phy_disconnected (struct hisi_sas_phy *phy) { +struct asd_sas_phy *sas_phy = &phy->sas_phy; +struct sas_phy *sphy = sas_phy->phy; +struct sas_phy_data *d = sphy->hostdata; + phy->phy_attached =0 ; phy->phy_type =0 ; phy->port =NULL ; + +if (d->enable) + sphy->negotiated_linkrate =SAS_LINK_RATE_UNKNOWN ; +else + sphy->negotiated_linkrate =SAS_PHY_DISABLED ; }void hisi_sas_phy_down (struct hisi_hba *hisi_hba,int phy_no,int rdy)
Signature · 1 line
2.17.1
PATCH 5/6 scsi: hisi_sas: Send HARD RESET to clear the previous affiliation of STP target port
In reply to John GarryFrom: Xiang Chen <[email protected]>
If we exchange SAS expander from one SAS controller to other SAS controller without powering it down, the STP target port will maintain previous affiliation and reject all subsequent connection requests from other STP initiator ports with OPEN_REJECT (STP RESOURCES BUSY).
To solve this issue, send HARD RESET to clear the previous affiliation of STP target port according to SPL (chapter 6.19.4).
We (re-)introduce dev status flag to know if to sleep in NEXUS reset code or not for remote PHYs. The idea is that if the device is being initialised, we don't require the delay, and caller would wait for link to be established, cf. sas_ata_hard_reset().
--- drivers/scsi/hisi_sas/hisi_sas.h | 7 ++++ drivers/scsi/hisi_sas/hisi_sas_main.c | 44 ++++++++++++++++++++++++-- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 1 + 3 files changed, 49 insertions(+), 3 deletions(-)
drivers/scsi/hisi_sas/hisi_sas.h +7 -0
@@ -18,6 +18,7 @@#include <linux/dmapool.h> #include <linux/iopoll.h> #include <linux/lcm.h> +#include <linux/libata.h> #include <linux/mfd/syscon.h> #include <linux/module.h> #include <linux/of_address.h>
@@ -94,6 +95,11 @@ enum { PORT_TYPE_SATA = (1U << 0), }; +enum dev_status { +HISI_SAS_DEV_INIT , +HISI_SAS_DEV_NORMAL , +}; +enum {HISI_SAS_INT_ABT_CMD =0 ,HISI_SAS_INT_ABT_DEV =1 ,
@@ -195,6 +201,7 @@ struct hisi_sas_device {struct hisi_sas_dq *dq;struct list_head list;enum sas_device_type dev_type; +enum dev_status dev_status;int device_id;int sata_idx;spinlock_t lock;/* For protecting slots */
drivers/scsi/hisi_sas/hisi_sas_main.c +41 -3
99 lines not on this page · raw message
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +1 -0
@@ -868,6 +868,7 @@ hisi_sas_device *alloc_dev_quirk_v2_hw(struct domain_device *device) hisi_hba->devices[i].device_id = i; sas_dev = &hisi_hba->devices[i]; + sas_dev->dev_status =HISI_SAS_DEV_INIT ; sas_dev->dev_type = device->dev_type; sas_dev->hisi_hba = hisi_hba; sas_dev->sas_device = device;
Signature · 1 line
2.17.1
PATCH 6/6 scsi: hisi_sas: Change SERDES_CFG init value to increase reliability of HiLink
In reply to John GarryFrom: Xiang Chen <[email protected]>
With default value of register SERDES_CFG, the link is not stable for some special disks when running IO. According to HW guys' suggestion, need to make the bit10~19 value of register SERDES_CFG the max value to increase the reliability of the HiLink.
--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +2 -0
@@ -129,6 +129,7 @@#define PHY_CTRL_RESET_MSK (0x1 << PHY_CTRL_RESET_OFF)#define CMD_HDR_PIR_OFF 8#define CMD_HDR_PIR_MSK (0x1 << CMD_HDR_PIR_OFF) +#define SERDES_CFG (PORT_BASE + 0x1c)#define SL_CFG (PORT_BASE + 0x84)#define AIP_LIMIT (PORT_BASE + 0x90)#define SL_CONTROL (PORT_BASE + 0x94)
@@ -525,6 +526,7 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba) }hisi_sas_phy_write32 (hisi_hba, i,PROG_PHY_LINK_RATE , prog_phy_link_rate); +hisi_sas_phy_write32 (hisi_hba, i,SERDES_CFG ,0xffc00 );hisi_sas_phy_write32 (hisi_hba, i,SAS_RX_TRAIN_TIMER ,0x13e80 );hisi_sas_phy_write32 (hisi_hba, i,CHL_INT0 ,0xffffffff );hisi_sas_phy_write32 (hisi_hba, i,CHL_INT1 ,0xffffffff );
Signature · 1 line
2.17.1
Martin K. Petersen
AppliedJohn,
Quoted 7 lines
The patchset contains some misc patches for the driver, including:
- Workaround for acute scenario of SMP/internal IO timeout and reset racing
- Clear Affiliation for STP target port (from Luo Jiaxing and Xiang Chen)
- Fix PHY negotiated linkrate value for when PHY down
- Some init reg config changes
- Add support to coalesce and print PHY errors
- A tidy-up patch
Applied to 5.1/scsi-queue, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering