scsi: hisi_sas: Try wait commands before before controller reset
authorXiaofei Tan <tanxiaofei@huawei.com>
Mon, 21 May 2018 10:09:20 +0000 (18:09 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 29 May 2018 02:40:32 +0000 (22:40 -0400)
commita865ae14ff62797f14b760b2063b90c81d27d178
tree1007d145432328d4b4e263b7165e5c9d1161e511
parent6175abdeaeaf2602f3e92bd4eca5916e98efe996
scsi: hisi_sas: Try wait commands before before controller reset

We may reset the controller in many scenarios, such as SCSI EH and HW
errors. There should be no IO which returns from target when SCSI EH is
active. But for other scenarios, there may be.  It is not necessary to make
such IOs fail.

This patch adds an function of trying to wait for any commands, or IO, to
complete before host reset. If no more CQ returned from host controller in
100ms, we assume no more IO can return, and then stop waiting. We wait 5s
at most.

The HW has a register CQE_SEND_CNT to indicate the total number of CQs that
has been reported to driver. We can use this register and it is reliable to
resd this register in such scenarios that require host reset.

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/hisi_sas/hisi_sas.h
drivers/scsi/hisi_sas/hisi_sas_main.c
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c