hisi_sas internal abort support
Subsystems (2)
v2 cover hisi_sas internal abort support
This patchset introduces support for the internal abort feature for the HiSilicon SAS controller.
The internal abort feature allows commands which are active in the controller to be aborted before being sent to the slave device.
Only support will be added for v2 HW since v1 HW has issues in supporting internal abort feature.
Differences to v1 patchset:
- Add MACRO for internal abort mode and description of internal abort API
John Garry (8):
hisi_sas: add internal abort main code
hisi_sas: for internal abort in hisi_sas_dev_gone()
hisi_sas: add internal abort to hisi_sas_abort_task()
hisi_sas: add prep_abort_v2_hw()
hisi_sas: add v2 hw slot complete internal abort support
hisi_sas: fail tmf task prep when port detached
hisi_sas: add TMF success check
hisi_sas: update version to 1.6
drivers/scsi/hisi_sas/hisi_sas.h | 10 +- drivers/scsi/hisi_sas/hisi_sas_main.c | 190 +++++++++++++++++++++++++++++++-- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 64 +++++++++++ 3 files changed, 256 insertions(+), 8 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/8 hisi_sas: add internal abort main code
Add main code for internal abort functionality.
The internal abort features allows the host controller to abort commands which are still active in the controller but have not yet been sent to the slave device.
Typically a command only spends a relatively short time in the controller when compared to the amount of the time after it is sent to the slave device.
Two modes of internal abort are supported:
- device
- individual command
For device, when the internal abort is issued all commands in the host for that device are aborted. For a single command, only that command is aborted if it is still in the host.
In HW the internal abort command is executed similar to any other sort of command, like SSP.
--- drivers/scsi/hisi_sas/hisi_sas.h | 8 ++ drivers/scsi/hisi_sas/hisi_sas_main.c | 163 ++++++++++++++++++++++++++++++++++ 2 files changed, 171 insertions(+)
drivers/scsi/hisi_sas/hisi_sas.h +8 -0
@@ -56,6 +56,11 @@ enum dev_status { HISI_SAS_DEV_EH, }; +enum { +HISI_SAS_INT_ABT_CMD =0 , +HISI_SAS_INT_ABT_DEV =1 , +}; +enum hisi_sas_dev_type {HISI_SAS_DEV_TYPE_STP =0 ,HISI_SAS_DEV_TYPE_SSP ,
@@ -146,6 +151,9 @@ struct hisi_sas_hw { struct hisi_sas_slot *slot);int (*prep_stp)(struct hisi_hba *hisi_hba,struct hisi_sas_slot *slot); +int (*prep_abort)(struct hisi_hba *hisi_hba, +struct hisi_sas_slot *slot, +int device_id,int abort_flag,int tag_to_abort);int (*slot_complete)(struct hisi_hba *hisi_hba,struct hisi_sas_slot *slot,int abort);void (*phy_enable)(struct hisi_hba *hisi_hba,int phy_no);
drivers/scsi/hisi_sas/hisi_sas_main.c +163 -0
181 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v2 1/8] hisi_sas: add internal abort main code
Quoted 20 lines · John Garry
Add main code for internal abort functionality.
The internal abort features allows the host controller to abort commands which are still active in the controller but have not yet been sent to the slave device.
Typically a command only spends a relatively short time in the controller when compared to the amount of the time after it is sent to the slave device.
Two modes of internal abort are supported:
- device
- individual commandFor device, when the internal abort is issued all commands in the host for that device are aborted. For a single command, only that command is aborted if it is still in the host.
Quoted 9 lines
In HW the internal abort command is executed similar to any other sort of command, like SSP.
Signed-off-by John Garry <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas.h | 8 ++ drivers/scsi/hisi_sas/hisi_sas_main.c | 163 ++++++++++++++++++++++++++++++++++ 2 files changed, 171 insertions(+)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH v2 2/8 hisi_sas: add internal abort in hisi_sas_dev_gone()
In reply to John GarryExecute an internal abort for that device when it is removed, so that commands for that device are not processed.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/scsi/hisi_sas/hisi_sas_main.c +3 -0
@@ -621,6 +621,9 @@ static void hisi_sas_dev_gone(struct domain_device *device)dev_info (dev,"found dev[%lld:%x] is gone\n" , sas_dev->device_id, sas_dev->dev_type); +hisi_sas_internal_task_abort (hisi_hba, device, +HISI_SAS_INT_ABT_DEV ,0 ); + hisi_hba->hw->free_device (hisi_hba, sas_dev); device->lldd_dev =NULL ;memset (sas_dev,0 ,sizeof (*sas_dev));
Signature · 1 line
1.9.1
Re: [PATCH v2 2/8] hisi_sas: add internal abort in hisi_sas_dev_gone()
Quoted 14 lines · John Garry
Execute an internal abort for that device when it is removed, so that commands for that device are not processed.
Signed-off-by John Garry <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_main.c | 3 +++ 1 file changed, 3 insertions(+)drivers/scsi/hisi_sas/hisi_sas_main.c +0
-0
drivers/scsi/hisi_sas/hisi_sas_main.c static void hisi_sas_dev_gone(struct domain_device *device) · line 629
Quoted 9 lines
drivers/scsi/hisi_sas/hisi_sas_main.c +3
-0@@ -621,6 +621,9 @@ static void hisi_sas_dev_gone(struct domain_device *device)dev_info (dev,"found dev[%lld:%x] is gone\n" , sas_dev->device_id, sas_dev->dev_type); +hisi_sas_internal_task_abort (hisi_hba, device, +HISI_SAS_INT_ABT_DEV ,0 ); + hisi_hba->hw->free_device (hisi_hba, sas_dev); device->lldd_dev =NULL ;memset (sas_dev,0 ,sizeof (*sas_dev));
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH v2 3/8 hisi_sas: add internal abort to hisi_sas_abort_task()
In reply to John GarryExecute an internal abort for executing a task abort. This is for case of the command still being present in host when abort is executed.
For a SATA internal abort, we set abort for all tasks associated with the device.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +10 -6
@@ -841,18 +841,22 @@ static int hisi_sas_abort_task(struct sas_task *task) } } +hisi_sas_internal_task_abort (hisi_hba, device, +HISI_SAS_INT_ABT_CMD , tag); }else if (task->task_proto &SAS_PROTOCOL_SATA || task->task_proto &SAS_PROTOCOL_STP ) {if (task->dev->dev_type ==SAS_SATA_DEV ) { -struct hisi_slot_info *slot = task->lldd_task; - -dev_notice (dev,"abort task: hba=%p task=%p slot=%p\n" , - hisi_hba, task, slot); - task->task_state_flags |=SAS_TASK_STATE_ABORTED ; +hisi_sas_internal_task_abort (hisi_hba, device, +HISI_SAS_INT_ABT_DEV ,0 ); rc =TMF_RESP_FUNC_COMPLETE ; - goto out; } + }else if (task->task_proto &SAS_PROTOCOL_SMP ) { +/* SMP */ +struct hisi_sas_slot *slot = task->lldd_task; +u32 tag = slot->idx; +hisi_sas_internal_task_abort (hisi_hba, device, +HISI_SAS_INT_ABT_CMD , tag); } out:
Signature · 1 line
1.9.1
Re: [PATCH v2 3/8] hisi_sas: add internal abort to hisi_sas_abort_task()
Quoted 4 lines · John Garry
Execute an internal abort for executing a task abort. This is for case of the command still being present in host when abort is executed.
Quoted 8 lines
For a SATA internal abort, we set abort for all tasks associated with the device.
Signed-off-by John Garry <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_main.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH v2 4/8 hisi_sas: add prep_abort_v2_hw()
In reply to John GarryAdd function to prepare the an internal abort
for v2 hw.
--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +33 -0
@@ -174,6 +174,10 @@/* HW dma structures */ /* Delivery queue header */ /* dw0 */ +#define CMD_HDR_ABORT_FLAG_OFF 0 +#define CMD_HDR_ABORT_FLAG_MSK (0x3 << CMD_HDR_ABORT_FLAG_OFF) +#define CMD_HDR_ABORT_DEVICE_TYPE_OFF 2 +#define CMD_HDR_ABORT_DEVICE_TYPE_MSK (0x1 << CMD_HDR_ABORT_DEVICE_TYPE_OFF)#define CMD_HDR_RESP_REPORT_OFF 5#define CMD_HDR_RESP_REPORT_MSK (0x1 << CMD_HDR_RESP_REPORT_OFF)#define CMD_HDR_TLR_CTRL_OFF 6
@@ -214,6 +218,8 @@#define CMD_HDR_DIF_SGL_LEN_MSK (0xffff << CMD_HDR_DIF_SGL_LEN_OFF)#define CMD_HDR_DATA_SGL_LEN_OFF 16#define CMD_HDR_DATA_SGL_LEN_MSK (0xffff << CMD_HDR_DATA_SGL_LEN_OFF) +#define CMD_HDR_ABORT_IPTT_OFF 16 +#define CMD_HDR_ABORT_IPTT_MSK (0xffff << CMD_HDR_ABORT_IPTT_OFF)/* Completion header */ /* dw0 */
@@ -1775,6 +1781,32 @@ static int prep_ata_v2_hw(struct hisi_hba *hisi_hba,return 0 ; } +static int prep_abort_v2_hw (struct hisi_hba *hisi_hba, +struct hisi_sas_slot *slot, +int device_id,int abort_flag,int tag_to_abort) +{ +struct sas_task *task = slot->task; +struct domain_device *dev = task->dev; +struct hisi_sas_cmd_hdr *hdr = slot->cmd_hdr; +struct hisi_sas_port *port = slot->port; + +/* dw0 */ + hdr->dw0 =cpu_to_le32 ((5 <<CMD_HDR_CMD_OFF ) |/*abort*/ + (port->id <<CMD_HDR_PORT_OFF ) | + ((dev_is_sata (dev) ?1 :0 ) << +CMD_HDR_ABORT_DEVICE_TYPE_OFF ) | + (abort_flag <<CMD_HDR_ABORT_FLAG_OFF )); + +/* dw1 */ + hdr->dw1 =cpu_to_le32 (device_id <<CMD_HDR_DEV_ID_OFF ); + +/* dw7 */ + hdr->dw7 =cpu_to_le32 (tag_to_abort <<CMD_HDR_ABORT_IPTT_OFF ); + hdr->transfer_tags =cpu_to_le32 (slot->idx); + +return 0 ; +} +static int phy_up_v2_hw (int phy_no,struct hisi_hba *hisi_hba) {int i, res =0 ;
@@ -2239,6 +2271,7 @@ static const struct hisi_sas_hw hisi_sas_v2_hw = { .prep_smp = prep_smp_v2_hw, .prep_ssp = prep_ssp_v2_hw, .prep_stp = prep_ata_v2_hw, + .prep_abort = prep_abort_v2_hw, .get_free_slot = get_free_slot_v2_hw, .start_delivery = start_delivery_v2_hw, .slot_complete = slot_complete_v2_hw,
Signature · 1 line
1.9.1
Re: [PATCH v2 4/8] hisi_sas: add prep_abort_v2_hw()
Quoted 8 lines · John Garry
Add function to prepare the an internal abort
for v2 hw.Signed-off-by John Garry <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH v2 5/8 hisi_sas: add v2 hw slot complete internal abort support
In reply to John GarryAdd code in slot_complete_v2_hw() to deal with the slots which have completed due to internal abort.
The status codes have the following meaning:
- STAT_IO_ABORTED: the IO has been aborted due to
internal abort, whether by device or individual
abort command
- STAT_IO_COMPLETE: internal abort command has
completed successfully for device or individual
abort command
- STAT_IO_NO_DEVICE: internal abort command has
completed for device but cannot find any IO
- STAT_IO_NOT_VALID: internal abort command has
completed for single command but could not
find the command
--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +31 -0
@@ -227,6 +227,13 @@#define CMPLT_HDR_RSPNS_XFRD_MSK (0x1 << CMPLT_HDR_RSPNS_XFRD_OFF)#define CMPLT_HDR_ERX_OFF 12#define CMPLT_HDR_ERX_MSK (0x1 << CMPLT_HDR_ERX_OFF) +#define CMPLT_HDR_ABORT_STAT_OFF 13 +#define CMPLT_HDR_ABORT_STAT_MSK (0x7 << CMPLT_HDR_ABORT_STAT_OFF) +/* abort_stat */ +#define STAT_IO_NOT_VALID 0x1 +#define STAT_IO_NO_DEVICE 0x2 +#define STAT_IO_COMPLETE 0x3 +#define STAT_IO_ABORTED 0x4/* dw1 */ #define CMPLT_HDR_IPTT_OFF 0#define CMPLT_HDR_IPTT_MSK (0xffff << CMPLT_HDR_IPTT_OFF)
@@ -1569,6 +1576,30 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot, goto out; } +/* Use SAS+TMF status codes */ +switch ((complete_hdr->dw0 &CMPLT_HDR_ABORT_STAT_MSK ) + >>CMPLT_HDR_ABORT_STAT_OFF ) { +case STAT_IO_ABORTED : +/* this io has been aborted by abort command */ + ts->stat =SAS_ABORTED_TASK ; + goto out; +case STAT_IO_COMPLETE : +/* internal abort command complete */ + ts->stat =TMF_RESP_FUNC_COMPLETE ; + goto out; +case STAT_IO_NO_DEVICE : + ts->stat =TMF_RESP_FUNC_COMPLETE ; + goto out; +case STAT_IO_NOT_VALID : +/* abort single io, controller don't find +* the io need to abort +*/ + ts->stat =TMF_RESP_FUNC_FAILED ; + goto out; +default : +break ; + } +if ((complete_hdr->dw0 &CMPLT_HDR_ERX_MSK ) && (!(complete_hdr->dw0 &CMPLT_HDR_RSPNS_XFRD_MSK ))) {
Signature · 1 line
1.9.1
Re: [PATCH v2 5/8] hisi_sas: add v2 hw slot complete internal abort support
Quoted 53 lines · John Garry
Add code in
slot_complete_v2_hw()to deal with the slots which have completed due to internal abort.The status codes have the following meaning:
-STAT_IO_ABORTED: the IO has been aborted due to
internal abort, whether by device or individual
abort command
-STAT_IO_COMPLETE: internal abort command has
completed successfully for device or individual
abort command
-STAT_IO_NO_DEVICE: internal abort command has
completed for device but cannot find any IO
-STAT_IO_NOT_VALID: internal abort command has
completed for single command but could not
find the commandSigned-off-by John Garry <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +17
-0@@ -227,6 +227,13 @@#define CMPLT_HDR_RSPNS_XFRD_MSK (0x1 << CMPLT_HDR_RSPNS_XFRD_OFF)#define CMPLT_HDR_ERX_OFF 12#define CMPLT_HDR_ERX_MSK (0x1 << CMPLT_HDR_ERX_OFF) +#define CMPLT_HDR_ABORT_STAT_OFF 13 +#define CMPLT_HDR_ABORT_STAT_MSK (0x7 << CMPLT_HDR_ABORT_STAT_OFF) +/* abort_stat */ +#define STAT_IO_NOT_VALID 0x1 +#define STAT_IO_NO_DEVICE 0x2 +#define STAT_IO_COMPLETE 0x3 +#define STAT_IO_ABORTED 0x4/* dw1 */ #define CMPLT_HDR_IPTT_OFF 0#define CMPLT_HDR_IPTT_MSK (0xffff << CMPLT_HDR_IPTT_OFF)@@ -1569,6 +1576,30 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot, goto out; } +/* Use SAS+TMF status codes */ +switch ((complete_hdr->dw0 &CMPLT_HDR_ABORT_STAT_MSK ) + >>CMPLT_HDR_ABORT_STAT_OFF ) { +case STAT_IO_ABORTED : +/* this io has been aborted by abort command */ + ts->stat =SAS_ABORTED_TASK ; + goto out; +case STAT_IO_COMPLETE : +/* internal abort command complete */ + ts->stat =TMF_RESP_FUNC_COMPLETE ;
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot, · line 1598
Quoted 10 lines
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +10
-0+ goto out; +case STAT_IO_NO_DEVICE : + ts->stat =TMF_RESP_FUNC_COMPLETE ; + goto out; +case STAT_IO_NOT_VALID : +/* abort single io, controller don't find +* the io need to abort +*/ + ts->stat =TMF_RESP_FUNC_FAILED ; + goto out;
Hmm. This will cause the SCSI EH to kick in.
And then, according to the description abort has succeeded, it's just that for some reason the associated command couldn't be found. So couldn't this be due to a race condition, and the command has in fact been aborted correctly (and the code is just too slow acknowledging it)?
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Re: [PATCH v2 5/8] hisi_sas: add v2 hw slot complete internal abort support
Quoted 61 lines · Hannes Reinecke
Quoted 60 lines · John Garry
Add code in
slot_complete_v2_hw()to deal with the slots which have completed due to internal abort.The status codes have the following meaning:
-STAT_IO_ABORTED: the IO has been aborted due to
internal abort, whether by device or individual
abort command
-STAT_IO_COMPLETE: internal abort command has
completed successfully for device or individual
abort command
-STAT_IO_NO_DEVICE: internal abort command has
completed for device but cannot find any IO
-STAT_IO_NOT_VALID: internal abort command has
completed for single command but could not
find the commandSigned-off-by John Garry <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +24
-0@@ -227,6 +227,13 @@#define CMPLT_HDR_RSPNS_XFRD_MSK (0x1 << CMPLT_HDR_RSPNS_XFRD_OFF)#define CMPLT_HDR_ERX_OFF 12#define CMPLT_HDR_ERX_MSK (0x1 << CMPLT_HDR_ERX_OFF) +#define CMPLT_HDR_ABORT_STAT_OFF 13 +#define CMPLT_HDR_ABORT_STAT_MSK (0x7 << CMPLT_HDR_ABORT_STAT_OFF) +/* abort_stat */ +#define STAT_IO_NOT_VALID 0x1 +#define STAT_IO_NO_DEVICE 0x2 +#define STAT_IO_COMPLETE 0x3 +#define STAT_IO_ABORTED 0x4/* dw1 */ #define CMPLT_HDR_IPTT_OFF 0#define CMPLT_HDR_IPTT_MSK (0xffff << CMPLT_HDR_IPTT_OFF)@@ -1569,6 +1576,30 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot, goto out; } +/* Use SAS+TMF status codes */ +switch ((complete_hdr->dw0 &CMPLT_HDR_ABORT_STAT_MSK ) + >>CMPLT_HDR_ABORT_STAT_OFF ) { +case STAT_IO_ABORTED : +/* this io has been aborted by abort command */ + ts->stat =SAS_ABORTED_TASK ; + goto out; +case STAT_IO_COMPLETE : +/* internal abort command complete */ + ts->stat =TMF_RESP_FUNC_COMPLETE ; + goto out; +case STAT_IO_NO_DEVICE : + ts->stat =TMF_RESP_FUNC_COMPLETE ; + goto out; +case STAT_IO_NOT_VALID : +/* abort single io, controller don't find +* the io need to abort
Quoted 9 lines
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot, · line 1598
Quoted 3 lines
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +3
-0+*/ + ts->stat =TMF_RESP_FUNC_FAILED ; + goto out;Hmm. This will cause the SCSI EH to kick in.
And then, according to the description abort has succeeded, it's just that for some reason the associated command couldn't be found. So couldn't this be due to a race condition, and the command has in fact been aborted correctly (and the code is just too slow acknowledging it)?
Hi Hannes,
I'm not sure I fully get your question.
The internal abort would happen from the SCSI error handling. An example would be when the disk was not safely removed and some IO is still in flight. In this case the IO will timeout, SCSI EH starts, and we try to abort the command in LLDD, by TMF (which would fail) and internal abort.
For internal abort, if the abort command succeeds then 2 things happen:
- abort task completes with status STAT_IO_COMPLETE
- task which was aborted completes with status STAT_IO_ABORTED
If the command does not abort successfully then:
- abort task completes with status STAT_IO_NOT_VALID
- task which we wanted to be aborted does not complete and is probably still in the slave device
I hope that this makes it clear.
Thanks,
John
Quoted 4 lines
Cheers,
Hannes
Hannes Reinecke
Reviewed-byRe: [PATCH v2 5/8] hisi_sas: add v2 hw slot complete internal abort support
Quoted 88 lines · John Garry
Quoted 64 lines · Hannes Reinecke
Quoted 63 lines · John Garry
Add code in
slot_complete_v2_hw()to deal with the slots which have completed due to internal abort.The status codes have the following meaning:
-STAT_IO_ABORTED: the IO has been aborted due to
internal abort, whether by device or individual
abort command
-STAT_IO_COMPLETE: internal abort command has
completed successfully for device or individual
abort command
-STAT_IO_NO_DEVICE: internal abort command has
completed for device but cannot find any IO
-STAT_IO_NOT_VALID: internal abort command has
completed for single command but could not
find the commandSigned-off-by John Garry <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +24
-0@@ -227,6 +227,13 @@#define CMPLT_HDR_RSPNS_XFRD_MSK (0x1 << CMPLT_HDR_RSPNS_XFRD_OFF)#define CMPLT_HDR_ERX_OFF 12#define CMPLT_HDR_ERX_MSK (0x1 << CMPLT_HDR_ERX_OFF) +#define CMPLT_HDR_ABORT_STAT_OFF 13 +#define CMPLT_HDR_ABORT_STAT_MSK (0x7 << CMPLT_HDR_ABORT_STAT_OFF) +/* abort_stat */ +#define STAT_IO_NOT_VALID 0x1 +#define STAT_IO_NO_DEVICE 0x2 +#define STAT_IO_COMPLETE 0x3 +#define STAT_IO_ABORTED 0x4/* dw1 */ #define CMPLT_HDR_IPTT_OFF 0#define CMPLT_HDR_IPTT_MSK (0xffff << CMPLT_HDR_IPTT_OFF)@@ -1569,6 +1576,30 @@ slot_complete_v2_hw(struct hisi_hba *hisi_hba,struct hisi_sas_slot *slot, goto out; } +/* Use SAS+TMF status codes */ +switch ((complete_hdr->dw0 &CMPLT_HDR_ABORT_STAT_MSK ) + >>CMPLT_HDR_ABORT_STAT_OFF ) { +case STAT_IO_ABORTED : +/* this io has been aborted by abort command */ + ts->stat =SAS_ABORTED_TASK ; + goto out; +case STAT_IO_COMPLETE : +/* internal abort command complete */ + ts->stat =TMF_RESP_FUNC_COMPLETE ; + goto out; +case STAT_IO_NO_DEVICE : + ts->stat =TMF_RESP_FUNC_COMPLETE ; + goto out; +case STAT_IO_NOT_VALID : +/* abort single io, controller don't find +* the io need to abort Quoted 9 lines
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c slot_complete_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_slot *slot, · line 1598
Quoted 3 lines
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +3
-0+*/ + ts->stat =TMF_RESP_FUNC_FAILED ; + goto out;Hmm. This will cause the SCSI EH to kick in.
And then, according to the description abort has succeeded, it's just that for some reason the associated command couldn't be found. So couldn't this be due to a race condition, and the command has in fact been aborted correctly (and the code is just too slow acknowledging it)?Hi Hannes,
I'm not sure I fully get your question.
The internal abort would happen from the SCSI error handling. An example would be when the disk was not safely removed and some IO is still in flight. In this case the IO will timeout, SCSI EH starts, and we try to abort the command in LLDD, by TMF (which would fail) and internal abort.
For internal abort, if the abort command succeeds then 2 things happen:
- abort task completes with statusSTAT_IO_COMPLETE
- task which was aborted completes with statusSTAT_IO_ABORTED
Quoted 7 lines
If the command does not abort successfully then:
- abort task completes with statusSTAT_IO_NOT_VALID
- task which we wanted to be aborted does not complete and is probably still in the slave deviceI hope that this makes it clear.
Right, that answers it.
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH v2 6/8 hisi_sas: fail tmf task prep when port detached
In reply to John GarryWhen the port is detached we cannot execute a TMF, as there can be no device attached to the port.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +1 -1
@@ -204,7 +204,7 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_hba *hisi_hba,return rc; } port = device->port->lldd_port; -if (port && !port->port_attached && !tmf) { +if (port && !port->port_attached) {if (sas_protocol_ata (task->task_proto)) {struct task_status_struct *ts = &task->task_status;
Signature · 1 line
1.9.1
Re: [PATCH v2 6/8] hisi_sas: fail tmf task prep when port detached
Quoted 14 lines · John Garry
When the port is detached we cannot execute a TMF, as there can be no device attached to the port.
Signed-off-by John Garry <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/hisi_sas/hisi_sas_main.c +0
-0
drivers/scsi/hisi_sas/hisi_sas_main.c static int hisi_sas_task_prep(struct sas_task *task, struct hisi_hba *hisi_hba, · line 210
Quoted 8 lines
drivers/scsi/hisi_sas/hisi_sas_main.c +1
-1@@ -204,7 +204,7 @@ static int hisi_sas_task_prep(struct sas_task *task, struct hisi_hba *hisi_hba,return rc; } port = device->port->lldd_port; -if (port && !port->port_attached && !tmf) { +if (port && !port->port_attached) {if (sas_protocol_ata (task->task_proto)) {struct task_status_struct *ts = &task->task_status;
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH v2 7/8 hisi_sas: add TMF success check
In reply to John GarryWhen a tmf is issued, various response codes can be returned from the target. For a query tmf the response may be TMF_RESP_FUNC_COMPLETE or TMF_RESP_FUNC_SUCC.
Add a condition for TMF_RESP_FUNC_SUCC to hisi_sas_exec_internal_tmf_task().
This affects query tmf, as the result is success the returned value was for failure.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/scsi/hisi_sas/hisi_sas_main.c +6 -0
@@ -744,6 +744,12 @@ static int hisi_sas_exec_internal_tmf_task(struct domain_device *device, }if (task->task_status.resp ==SAS_TASK_COMPLETE && + task->task_status.stat ==TMF_RESP_FUNC_SUCC ) { + res =TMF_RESP_FUNC_SUCC ; +break ; + } + +if (task->task_status.resp ==SAS_TASK_COMPLETE && task->task_status.stat ==SAS_DATA_UNDERRUN ) {/* no error, but return the number of bytes of * underrun
Signature · 1 line
1.9.1
Re: [PATCH v2 7/8] hisi_sas: add TMF success check
Quoted 22 lines · John Garry
When a tmf is issued, various response codes can be returned from the target. For a query tmf the response may be
TMF_RESP_FUNC_COMPLETEorTMF_RESP_FUNC_SUCC.
Add a condition forTMF_RESP_FUNC_SUCCtohisi_sas_exec_internal_tmf_task().
This affects query tmf, as the result is success the returned value was for failure.Signed-off-by John Garry <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas_main.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/scsi/hisi_sas/hisi_sas_main.c +0
-0@@ -744,6 +744,12 @@ static int hisi_sas_exec_internal_tmf_task(struct domain_device *device, }
drivers/scsi/hisi_sas/hisi_sas_main.c static int hisi_sas_exec_internal_tmf_task(struct domain_device *device, · line 755
Quoted 10 lines
drivers/scsi/hisi_sas/hisi_sas_main.c +6
-0if (task->task_status.resp ==SAS_TASK_COMPLETE && + task->task_status.stat ==TMF_RESP_FUNC_SUCC ) { + res =TMF_RESP_FUNC_SUCC ; +break ; + } + +if (task->task_status.resp ==SAS_TASK_COMPLETE && task->task_status.stat ==SAS_DATA_UNDERRUN ) {/* no error, but return the number of bytes of * underrun
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH v2 8/8 hisi_sas: update version to 1.6
In reply to John Garry--- drivers/scsi/hisi_sas/hisi_sas.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/hisi_sas/hisi_sas.h +1 -1
@@ -23,7 +23,7 @@#include <scsi/sas_ata.h> #include <scsi/libsas.h> -#define DRV_VERSION "v1.5" +#define DRV_VERSION "v1.6"#define HISI_SAS_MAX_PHYS 9#define HISI_SAS_MAX_QUEUES 32
Signature · 1 line
1.9.1
Re: [PATCH v2 8/8] hisi_sas: update version to 1.6
Quoted 11 lines · John Garry
Signed-off-by John Garry <[email protected]>--- drivers/scsi/hisi_sas/hisi_sas.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/hisi_sas/hisi_sas.h +0
-0
drivers/scsi/hisi_sas/hisi_sas.h line 29
Quoted 8 lines
drivers/scsi/hisi_sas/hisi_sas.h +1
-1@@ -23,7 +23,7 @@#include <scsi/sas_ata.h> #include <scsi/libsas.h> -#define DRV_VERSION "v1.5" +#define DRV_VERSION "v1.6"#define HISI_SAS_MAX_PHYS 9#define HISI_SAS_MAX_QUEUES 32
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Martin K. Petersen
AppliedQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"John" == John Garry <[email protected]> writes:
John> This patchset introduces support for the internal abort feature John> for the HiSilicon SAS controller.
John> The internal abort feature allows commands which are active in the John> controller to be aborted before being sent to the slave device.
John> Only support will be added for v2 HW since v1 HW has issues in John> supporting internal abort feature.
Applied to 4.9/scsi-queue.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering