qla2xxx: Bug fixes for driver
Subsystems (2)
PATCH 6/7 qla2xxx: Fix remoteport disconnect for FC-NVMe
In reply to Himanshu Madhani--- drivers/scsi/qla2xxx/qla_isr.c | 37 +++++++++++++++++++++++++++++++------ drivers/scsi/qla2xxx/qla_nvme.c | 11 ++++++++--- 2 files changed, 39 insertions(+), 9 deletions(-)
drivers/scsi/qla2xxx/qla_isr.c +31 -6
@@ -1856,17 +1856,42 @@ qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, void *tsk) fd->transferred_length = fd->payload_length -le32_to_cpu (sts->residual_len); +/* +* If transport error then Failure (HBA rejects request) +* otherwise transport will handle. +*/ if (sts->entry_status) {ql_log (ql_log_warn, fcport->vha,0x5038 ,"NVME-%s error - hdl=%x entry-status(%x).\n" , sp->name, sp->handle, sts->entry_status); ret =QLA_FUNCTION_FAILED ; - }else if (sts->comp_status !=cpu_to_le16 (CS_COMPLETE )) { -ql_log (ql_log_warn, fcport->vha,0x5039 , -"NVME-%s error - hdl=%x completion status(%x) resid=%x ox_id=%x\n" , - sp->name, sp->handle, sts->comp_status, -le32_to_cpu (sts->residual_len), sts->ox_id); - ret =QLA_FUNCTION_FAILED ; + }else { +switch (le16_to_cpu (sts->comp_status)) { +case CS_COMPLETE : + ret =0 ; +break ; + +case CS_ABORTED : +case CS_RESET : +case CS_PORT_UNAVAILABLE : +case CS_PORT_LOGGED_OUT : +case CS_PORT_BUSY : +ql_log (ql_log_warn, fcport->vha,0x5060 , +"NVME-%s ERR Handling - hdl=%x completion status(%x) resid=%x ox_id=%x\n" , + sp->name, sp->handle, sts->comp_status, +le32_to_cpu (sts->residual_len), sts->ox_id); + fd->transferred_length = fd->payload_length; + ret =QLA_ABORTED ; +break ; + +default : +ql_log (ql_log_warn, fcport->vha,0x5060 , +"NVME-%s error - hdl=%x completion status(%x) resid=%x ox_id=%x\n" , + sp->name, sp->handle, sts->comp_status, +le32_to_cpu (sts->residual_len), sts->ox_id); + ret =QLA_FUNCTION_FAILED ; +break ; + } } sp->done (sp, ret); }
drivers/scsi/qla2xxx/qla_nvme.c +8 -3
@@ -180,13 +180,13 @@ static void qla_nvme_sp_done(void *ptr, int res)if (!(sp->fcport->nvme_flag &NVME_FLAG_REGISTERED )) goto rel; -if (unlikely (nvme->u.nvme.comp_status || res)) - fd->status = -EINVAL ; +if (unlikely (res ==QLA_FUNCTION_FAILED )) + fd->status =NVME_SC_FC_TRANSPORT_ERROR ;else fd->status =0 ; fd->rcv_rsplen = nvme->u.nvme.rsp_pyld_len; -if (res ==QLA_FUNCTION_FAILED ) { +if (res) {INIT_WORK (&nvme->rq_work, qla_nvme_io_work);queue_work (sp->fcport->vha->nvme_io_wq, &nvme->rq_work);return ;
@@ -653,13 +653,18 @@ static void qla_nvme_unregister_remote_port(struct work_struct *work)if (!IS_ENABLED (CONFIG_NVME_FC ))return ; +ql_log (ql_log_warn,NULL ,0x2112 , +"%s: unregister remoteport on %p\n" ,__func__, fcport); +list_for_each_entry_safe (rport, trport, &fcport->vha->nvme_rport_list, list) {if (rport->fcport == fcport) {ql_log (ql_log_info, fcport->vha,0x2113 ,"%s: fcport=%p\n" , __func__, fcport); +init_completion (&fcport->nvme_del_done);nvme_fc_unregister_remoteport ( fcport->nvme_remote_port); +qla_nvme_wait_on_rport_del (fcport); } } }
Signature · 1 line
2.12.0
PATCH 2/7 qla2xxx: Move function prototype to correct header
In reply to Himanshu Madhani--- drivers/scsi/qla2xxx/qla_gbl.h | 11 ----------- drivers/scsi/qla2xxx/qla_isr.c | 4 ++-- drivers/scsi/qla2xxx/qla_nvme.c | 9 ++++----- drivers/scsi/qla2xxx/qla_nvme.h | 17 +++++++++++++++++ 4 files changed, 23 insertions(+), 18 deletions(-)
drivers/scsi/qla2xxx/qla_gbl.h +0 -11
@@ -10,17 +10,6 @@#include <linux/interrupt.h> /* -* Global functions prototype in qla_nvme.c source file. -*/ -extern void qla_nvme_register_hba (scsi_qla_host_t *); -extern int qla_nvme_register_remote (scsi_qla_host_t *,fc_port_t *); -extern void qla_nvme_delete (scsi_qla_host_t *); -extern void qla_nvme_abort (struct qla_hw_data *,srb_t *sp); -extern void qla24xx_nvme_ls4_iocb (scsi_qla_host_t *,struct pt_ls4_request *, -struct req_que *); -extern void qla24xx_async_gffid_sp_done (void *,int ); - -/* * Global Function Prototypes in qla_init.c source file. */ extern int qla2x00_initialize_adapter (scsi_qla_host_t *);
drivers/scsi/qla2xxx/qla_isr.c +2 -2
@@ -2827,8 +2827,8 @@ qla24xx_abort_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, sp->done (sp,0 ); } -void qla24xx_nvme_ls4_iocb (scsi_qla_host_t *vha,struct pt_ls4_request *pkt, -struct req_que *req) +void qla24xx_nvme_ls4_iocb (struct scsi_qla_host *vha, +struct pt_ls4_request *pkt,struct req_que *req) {srb_t *sp;const char func[] ="LS4_IOCB" ;
drivers/scsi/qla2xxx/qla_nvme.c +4 -5
@@ -5,7 +5,6 @@* See LICENSE.qla2xxx for copyright and licensing details. */ #include "qla_nvme.h" -#include "qla_def.h" #include <linux/scatterlist.h> #include <linux/delay.h> #include <linux/nvme.h>
@@ -15,7 +14,7 @@ static struct nvme_fc_port_template qla_nvme_fc_transport;static void qla_nvme_unregister_remote_port (struct work_struct *); -int qla_nvme_register_remote (scsi_qla_host_t *vha,fc_port_t *fcport) +int qla_nvme_register_remote (struct scsi_qla_host *vha,struct fc_port *fcport) {struct nvme_rport *rport;int ret;
@@ -616,7 +615,7 @@ static int qla_nvme_wait_on_rport_del(fc_port_t *fcport)return ret; } -void qla_nvme_abort (struct qla_hw_data *ha,srb_t *sp) +void qla_nvme_abort (struct qla_hw_data *ha,struct srb *sp) {int rval;
@@ -679,7 +678,7 @@ static void qla_nvme_unregister_remote_port(struct work_struct *work) } } -void qla_nvme_delete (scsi_qla_host_t *vha) +void qla_nvme_delete (struct scsi_qla_host *vha) {struct nvme_rport *rport, *trport;fc_port_t *fcport;
@@ -711,7 +710,7 @@ void qla_nvme_delete(scsi_qla_host_t *vha) } } -void qla_nvme_register_hba (scsi_qla_host_t *vha) +void qla_nvme_register_hba (struct scsi_qla_host *vha) {struct nvme_fc_port_template *tmpl;struct qla_hw_data *ha;
drivers/scsi/qla2xxx/qla_nvme.h +17 -0
@@ -12,12 +12,18 @@#include <uapi/scsi/fc/fc_els.h> #include <linux/nvme-fc-driver.h> +#include "qla_def.h" +#define NVME_ATIO_CMD_OFF 32#define NVME_FIRST_PACKET_CMDLEN (64 - NVME_ATIO_CMD_OFF)#define Q2T_NVME_NUM_TAGS 2048#define QLA_MAX_FC_SEGMENTS 64 +struct scsi_qla_host ; +struct qla_hw_data ; +struct req_que ;struct srb ; +struct nvme_private {struct srb *sp;struct nvmefc_ls_req *fd;
@@ -129,4 +135,15 @@ struct pt_ls4_rx_unsol {uint32_t desc_len; uint32_t payload[3]; }; + +/* +* Global functions prototype in qla_nvme.c source file. +*/ +void qla_nvme_register_hba (struct scsi_qla_host *); +int qla_nvme_register_remote (struct scsi_qla_host *,struct fc_port *); +void qla_nvme_delete (struct scsi_qla_host *); +void qla_nvme_abort (struct qla_hw_data *,struct srb *sp); +void qla24xx_nvme_ls4_iocb (struct scsi_qla_host *,struct pt_ls4_request *, +struct req_que *); +void qla24xx_async_gffid_sp_done (void *,int );#endif
Signature · 1 line
2.12.0
cover qla2xxx: Bug fixes for driver
Hi Martin,
This series addresses review comments for previously submitted series for Target MQ and FC-NVMe support.
Patch 1, 2 addresses review comments by Johannes for FC-NVMe series
(https://www.spinics.net/lists/linux-scsi/msg110077.html)
(https://www.spinics.net/lists/linux-scsi/msg109985.html)
Patch 3 adds completion wq for FC-NVMe error path.
Patch 4 adds ZIO support for FC-NVMe.
Patch 5 simplifies waiting for unregistration of local/remote FC-NVMe ports.
Patch 6 fixes handling of remote-port disconnect for FC-NVMe.
Patch 7 address review comments by Bart for Target Multi-queue.
(https://www.spinics.net/lists/target-devel/msg15563.html)
Please apply these patches to scsi-fixes for inclusion in 4.13.0-rc2.
Thanks,
Himanshu
Duane Grigsby (2):
qla2xxx: Add command completion wq for error path
qla2xxx: Added change to enable ZIO for FC-NVMe devices
Himanshu Madhani (4):
qla2xxx: Cleanup NVMe code.
qla2xxx: Move function prototype to correct header
qla2xxx: Simpify unregistration of FC-NVMe local/remote ports
qla2xxx: Fix remoteport disconnect for FC-NVMe
Quinn Tran (1):
qla2xxx: Refactor usage of Active command arrays
drivers/scsi/qla2xxx/qla_bsg.c | 51 ++++++------ drivers/scsi/qla2xxx/qla_dbg.c | 2 +- drivers/scsi/qla2xxx/qla_def.h | 45 +++++++---- drivers/scsi/qla2xxx/qla_gbl.h | 14 +--- drivers/scsi/qla2xxx/qla_init.c | 7 +- drivers/scsi/qla2xxx/qla_inline.h | 23 +++--- drivers/scsi/qla2xxx/qla_iocb.c | 16 ++-- drivers/scsi/qla2xxx/qla_isr.c | 74 ++++++++++++----- drivers/scsi/qla2xxx/qla_mbx.c | 82 +++++++++++++++---- drivers/scsi/qla2xxx/qla_mr.c | 19 ++--- drivers/scsi/qla2xxx/qla_nvme.c | 162 +++++++++++++++++--------------------- drivers/scsi/qla2xxx/qla_nvme.h | 17 ++++ drivers/scsi/qla2xxx/qla_nx.c | 6 +- drivers/scsi/qla2xxx/qla_os.c | 69 +++++++++++----- drivers/scsi/qla2xxx/qla_target.c | 18 +++-- drivers/scsi/qla2xxx/qla_target.h | 5 -- 16 files changed, 371 insertions(+), 239 deletions(-)
Signature · 1 line
2.12.0
PATCH 4/7 qla2xxx: Added change to enable ZIO for FC-NVMe devices
From: Duane Grigsby <[email protected]>
Add support to the driver to set the exchange threshold value for the number of outstanding AENs.
--- drivers/scsi/qla2xxx/qla_dbg.c | 2 +- drivers/scsi/qla2xxx/qla_def.h | 5 +++ drivers/scsi/qla2xxx/qla_gbl.h | 3 ++ drivers/scsi/qla2xxx/qla_isr.c | 2 +- drivers/scsi/qla2xxx/qla_mbx.c | 76 ++++++++++++++++++++++++++++++++++------- drivers/scsi/qla2xxx/qla_nvme.c | 14 ++++++-- drivers/scsi/qla2xxx/qla_os.c | 26 +++++++++++--- 7 files changed, 105 insertions(+), 23 deletions(-)
drivers/scsi/qla2xxx/qla_dbg.c +1 -1
@@ -14,7 +14,7 @@* | Module Init and Probe | 0x0193 | 0x0146 | * | | | 0x015b-0x0160 | * | | | 0x016e | -* | Mailbox commands | 0x1199 | 0x1193 | +* | Mailbox commands | 0x1205 | 0x11a2-0x11ff | * | Device Discovery | 0x2134 | 0x210e-0x2116 | * | | | 0x211a | * | | | 0x211c-0x2128 |
drivers/scsi/qla2xxx/qla_def.h +5 -0
@@ -978,6 +978,7 @@ struct mbx_cmd_32 {#define MBC_ABORT_TARGET 0x17/* Abort target (ID). */ #define MBC_RESET 0x18/* Reset. */ #define MBC_GET_ADAPTER_LOOP_ID 0x20/* Get loop id of ISP2200. */ +#define MBC_GET_SET_ZIO_THRESHOLD 0x21/* Get/SET ZIO THRESHOLD. */ #define MBC_GET_RETRY_COUNT 0x22/* Get f/w retry cnt/delay. */ #define MBC_DISABLE_VI 0x24/* Disable VI operation. */ #define MBC_ENABLE_VI 0x25/* Enable VI operation. */
@@ -4018,6 +4019,9 @@ struct qla_hw_data {struct qlt_hw_data tgt;int allow_cna_fw_dump; + +atomic_t nvme_active_aen_cnt; +uint16_t nvme_last_rptd_aen;/* Last recorded aen count */ };/*
@@ -4090,6 +4094,7 @@ typedef struct scsi_qla_host {#define FX00_CRITEMP_RECOVERY 25#define FX00_HOST_INFO_RESEND 26#define QPAIR_ONLINE_CHECK_NEEDED 27 +#define SET_ZIO_THRESHOLD_NEEDED 28unsigned long pci_flags;#define PFLG_DISCONNECTED 0/* PCI device removed */
drivers/scsi/qla2xxx/qla_gbl.h +3 -0
@@ -484,6 +484,9 @@ int qla24xx_gidlist_wait(struct scsi_qla_host *, void *, dma_addr_t,int __qla24xx_parse_gpdb (struct scsi_qla_host *,fc_port_t *,struct port_database_24xx *); +extern int qla27xx_get_zio_threshold (scsi_qla_host_t *,uint16_t *); +extern int qla27xx_set_zio_threshold (scsi_qla_host_t *,uint16_t ); +/* * Global Function Prototypes in qla_isr.c source file. */
drivers/scsi/qla2xxx/qla_isr.c +1 -1
@@ -1823,7 +1823,7 @@ qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, void *tsk) nvme = &sp->u.iocb_cmd;if (unlikely (nvme->u.nvme.aen_op)) -atomic_dec (&sp->vha->nvme_active_aen_cnt); +atomic_dec (&sp->vha->hw->nvme_active_aen_cnt);/* * State flags: Bit 6 and 0.
drivers/scsi/qla2xxx/qla_mbx.c +63 -13
86 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_nvme.c +11 -3
@@ -322,6 +322,7 @@ static int qla2x00_start_nvme_mq(srb_t *sp)uint16_t avail_dsds;uint32_t *cur_dsd;struct req_que *req =NULL ; +struct rsp_que *rsp =NULL ;struct scsi_qla_host *vha = sp->fcport->vha;struct qla_hw_data *ha = vha->hw;struct qla_qpair *qpair = sp->qpair;
@@ -330,13 +331,15 @@ static int qla2x00_start_nvme_mq(srb_t *sp)struct nvmefc_fcp_req *fd = nvme->u.nvme.desc;uint32_t rval =QLA_SUCCESS ; -/* Setup qpair pointers */ - req = qpair->req; tot_dsds = fd->sg_cnt;/* Acquire qpair specific lock */ spin_lock_irqsave (&qpair->qp_lock, flags); +/* Setup qpair pointers */ + req = qpair->req; + rsp = qpair->rsp; +/* Check for room in outstanding command list. */ handle = req->current_outstanding_cmd;for (index =1 ; index < req->num_outstanding_cmds; index++) {
@@ -371,7 +374,7 @@ static int qla2x00_start_nvme_mq(srb_t *sp)struct nvme_fc_cmd_iu *cmd = fd->cmdaddr;if (cmd->sqe.common.opcode == nvme_admin_async_event) { nvme->u.nvme.aen_op =1 ; -atomic_inc (&vha->nvme_active_aen_cnt); +atomic_inc (&vha->hw->nvme_active_aen_cnt); } }
@@ -484,6 +487,11 @@ static int qla2x00_start_nvme_mq(srb_t *sp)/* Set chip new ring index. */ WRT_REG_DWORD (req->req_q_in, req->ring_index); +/* Manage unprocessed RIO/ZIO commands in response queue. */ +if (vha->flags.process_response_queue && + rsp->ring_ptr->signature !=RESPONSE_PROCESSED ) +qla24xx_process_response_queue (vha, rsp); + queuing_error:spin_unlock_irqrestore (&qpair->qp_lock, flags);return rval;
drivers/scsi/qla2xxx/qla_os.c +21 -5
@@ -2751,6 +2751,8 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)spin_lock_init (&ha->tgt.sess_lock);spin_lock_init (&ha->tgt.atio_lock); +atomic_set (&ha->nvme_active_aen_cnt,0 ); +/* Clear our data area */ ha->bars = bars; ha->mem_only = mem_only;
@@ -5836,6 +5838,17 @@ qla2x00_do_dpc(void *data)mutex_unlock (&ha->mq_lock); } +if (test_and_clear_bit (SET_ZIO_THRESHOLD_NEEDED , &base_vha->dpc_flags)) { +ql_log (ql_log_info, base_vha,0xffffff , +"nvme: SET ZIO Activity exchange threshold to %d.\n" , + ha->nvme_last_rptd_aen); +if (qla27xx_set_zio_threshold (base_vha, ha->nvme_last_rptd_aen)) { +ql_log (ql_log_info, base_vha,0xffffff , +"nvme: Unable to SET ZIO Activity exchange threshold to %d.\n" , + ha->nvme_last_rptd_aen); + } + } +if (!IS_QLAFX00 (ha))qla2x00_do_dpc_all_vps (base_vha);
@@ -6033,12 +6046,15 @@ qla2x00_timer(scsi_qla_host_t *vha)* FC-NVME * see if the active AEN count has changed from what was last reported. */ -if (atomic_read (&vha->nvme_active_aen_cnt) != vha->nvme_last_rptd_aen) { - vha->nvme_last_rptd_aen = -atomic_read (&vha->nvme_active_aen_cnt); +if (!vha->vp_idx && +atomic_read (&ha->nvme_active_aen_cnt) != ha->nvme_last_rptd_aen && + ha->zio_mode ==QLA_ZIO_MODE_6 ) {ql_log (ql_log_info, vha,0x3002 , -"reporting new aen count of %d to the fw\n" , - vha->nvme_last_rptd_aen); +"nvme: Sched: Set ZIO exchange threshold to %d.\n" , + ha->nvme_last_rptd_aen); + ha->nvme_last_rptd_aen =atomic_read (&ha->nvme_active_aen_cnt); +set_bit (SET_ZIO_THRESHOLD_NEEDED , &vha->dpc_flags); + start_dpc++; }/* Schedule the DPC routine if needed */
Signature · 1 line
2.12.0
PATCH 1/7 qla2xxx: Cleanup NVMe code.
In reply to Himanshu MadhaniThis patch cleaned up code to make it more readable
--- drivers/scsi/qla2xxx/qla_def.h | 6 ++-- drivers/scsi/qla2xxx/qla_nvme.c | 61 ++++++++++++++++++----------------------- drivers/scsi/qla2xxx/qla_os.c | 6 ++-- 3 files changed, 33 insertions(+), 40 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +3 -3
@@ -470,7 +470,7 @@ typedef struct srb {uint8_t cmd_type;uint8_t pad[3 ];atomic_t ref_count; -wait_queue_head_t nvme_ls_waitQ; +wait_queue_head_t nvme_ls_waitq;struct fc_port *fcport;struct scsi_qla_host *vha;uint32_t handle;
@@ -2302,7 +2302,7 @@ typedef struct fc_port {struct work_struct nvme_del_work;atomic_t nvme_ref_count; -wait_queue_head_t nvme_waitQ; +wait_queue_head_t nvme_waitq;uint32_t nvme_prli_service_param;#define NVME_PRLI_SP_CONF BIT_7#define NVME_PRLI_SP_INITIATOR BIT_5
@@ -4130,7 +4130,7 @@ typedef struct scsi_qla_host {struct nvme_fc_local_port *nvme_local_port;atomic_t nvme_ref_count; -wait_queue_head_t nvme_waitQ; +wait_queue_head_t nvme_waitq;struct list_head nvme_rport_list;atomic_t nvme_active_aen_cnt;uint16_t nvme_last_rptd_aen;
drivers/scsi/qla2xxx/qla_nvme.c +27 -34
173 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_os.c +3 -3
@@ -710,7 +710,7 @@ qla2x00_sp_free_dma(void *ptr) } end: -if ((sp->type !=SRB_NVME_CMD ) && (sp->type !=SRB_NVME_LS )) { +if (sp->type !=SRB_NVME_CMD && sp->type !=SRB_NVME_LS ) {CMD_SP (cmd) =NULL ;qla2x00_rel_sp (sp); }
@@ -1715,8 +1715,8 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)if (sp) { req->outstanding_cmds[cnt] =NULL ;if (sp->cmd_type ==TYPE_SRB ) { -if ((sp->type ==SRB_NVME_CMD ) || - (sp->type ==SRB_NVME_LS )) { +if (sp->type ==SRB_NVME_CMD || + sp->type ==SRB_NVME_LS ) {sp_get (sp);spin_unlock_irqrestore ( &ha->hardware_lock, flags);
Signature · 1 line
2.12.0
PATCH 5/7 qla2xxx: Simpify unregistration of FC-NVMe local/remote ports
In reply to Himanshu MadhaniSimplified waiting for unregister local/remote FC-NVMe ports to complete cleanup.
--- drivers/scsi/qla2xxx/qla_def.h | 5 ++-- drivers/scsi/qla2xxx/qla_nvme.c | 59 +++++++---------------------------------- 2 files changed, 12 insertions(+), 52 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +2 -3
@@ -2304,7 +2304,7 @@ typedef struct fc_port {struct work_struct nvme_del_work;atomic_t nvme_ref_count; -wait_queue_head_t nvme_waitq; +struct completion nvme_del_done;uint32_t nvme_prli_service_param;#define NVME_PRLI_SP_CONF BIT_7#define NVME_PRLI_SP_INITIATOR BIT_5
@@ -4135,8 +4135,7 @@ typedef struct scsi_qla_host {uint8_t fabric_node_name[WWN_SIZE ];struct nvme_fc_local_port *nvme_local_port; -atomic_t nvme_ref_count; -wait_queue_head_t nvme_waitq; +struct completion nvme_del_done;struct list_head nvme_rport_list;struct workqueue_struct *nvme_io_wq;atomic_t nvme_active_aen_cnt;
drivers/scsi/qla2xxx/qla_nvme.c +10 -49
127 lines not on this page · raw message
Signature · 1 line
2.12.0
PATCH 3/7 qla2xxx: Add command completion wq for error path
In reply to Himanshu MadhaniFrom: Duane Grigsby <[email protected]>
When NVMe commands encounter error NVMe FC transport needs to teardown the connection. This patch adds worker thread to process these IO errors.
--- drivers/scsi/qla2xxx/qla_def.h | 2 ++ drivers/scsi/qla2xxx/qla_nvme.c | 20 +++++++++++++++++++- drivers/scsi/qla2xxx/qla_os.c | 10 +++++++++- 3 files changed, 30 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +2 -0
@@ -430,6 +430,7 @@ struct srb_iocb { } nvme; } u; +struct work_struct rq_work;struct timer_list timer;void (*timeout)(void *); };
@@ -4132,6 +4133,7 @@ typedef struct scsi_qla_host {atomic_t nvme_ref_count;wait_queue_head_t nvme_waitq;struct list_head nvme_rport_list; +struct workqueue_struct *nvme_io_wq;atomic_t nvme_active_aen_cnt;uint16_t nvme_last_rptd_aen;
drivers/scsi/qla2xxx/qla_nvme.c +19 -1
@@ -156,6 +156,17 @@ static void qla_nvme_sp_ls_done(void *ptr, int res)qla2x00_rel_sp (sp); } +static void qla_nvme_io_work (struct work_struct *work) +{ +srb_t *sp; + struct srb_iocb *nvme = container_of(work, struct srb_iocb, rq_work); +struct nvmefc_fcp_req *fd = nvme->u.nvme.desc; + sp =container_of (nvme, srb_t, u.iocb_cmd); + + fd->done (fd); +qla2xxx_rel_qpair_sp (sp->qpair, sp); +} +static void qla_nvme_sp_done (void *ptr,int res) {srb_t *sp = ptr;
@@ -177,7 +188,13 @@ static void qla_nvme_sp_done(void *ptr, int res) fd->status =0 ; fd->rcv_rsplen = nvme->u.nvme.rsp_pyld_len; - fd->done (fd); +if (res ==QLA_FUNCTION_FAILED ) { +INIT_WORK (&nvme->rq_work, qla_nvme_io_work); +queue_work (sp->fcport->vha->nvme_io_wq, &nvme->rq_work); +return ; + }else { + fd->done (fd); + } rel:qla2xxx_rel_qpair_sp (sp->qpair, sp); }
@@ -514,6 +531,7 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port *lport, sp->done = qla_nvme_sp_done; sp->qpair = qpair; nvme = &sp->u.iocb_cmd; +INIT_WORK (&nvme->rq_work, qla_nvme_io_work); nvme->u.nvme.desc = fd; rval =qla2x00_start_nvme_mq (sp);
drivers/scsi/qla2xxx/qla_os.c +9 -1
@@ -2751,7 +2751,6 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)spin_lock_init (&ha->tgt.sess_lock);spin_lock_init (&ha->tgt.atio_lock); -/* Clear our data area */ ha->bars = bars; ha->mem_only = mem_only;
@@ -3286,6 +3285,13 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) base_vha->flags.init_done =1 ; base_vha->flags.online =1 ; ha->prev_minidump_failed =0 ; +atomic_set (&base_vha->nvme_active_aen_cnt,0 ); + base_vha->nvme_io_wq =alloc_workqueue ("qlnvme-io-wq" ,0 ,0 ); +if (!base_vha->nvme_io_wq) { +ql_log (ql_log_fatal, base_vha,0x000b , +"Unable to allocate workqueue for nvme_io_wq\n" ); + goto disable_device; + }ql_dbg (ql_dbg_init, base_vha,0x00f2 ,"Init done and hba is online.\n" );
@@ -3559,6 +3565,8 @@ qla2x00_remove_one(struct pci_dev *pdev)set_bit (UNLOADING , &base_vha->dpc_flags);qla_nvme_delete (base_vha); +if (base_vha->nvme_io_wq) +destroy_workqueue (base_vha->nvme_io_wq);dma_free_coherent (&ha->pdev->dev, base_vha->gnl.size, base_vha->gnl.l, base_vha->gnl.ldma);
Signature · 1 line
2.12.0
PATCH 7/7 qla2xxx: Refactor usage of Active command arrays
In reply to Himanshu MadhaniFrom: Quinn Tran <[email protected]>
--- drivers/scsi/qla2xxx/qla_bsg.c | 51 ++++++++++++++++++++------------------- drivers/scsi/qla2xxx/qla_def.h | 31 +++++++++++++++--------- drivers/scsi/qla2xxx/qla_init.c | 7 +++--- drivers/scsi/qla2xxx/qla_inline.h | 23 +++++++++++------- drivers/scsi/qla2xxx/qla_iocb.c | 16 ++++++------ drivers/scsi/qla2xxx/qla_isr.c | 31 +++++++++++++++--------- drivers/scsi/qla2xxx/qla_mbx.c | 6 +++-- drivers/scsi/qla2xxx/qla_mr.c | 19 ++++++++------- drivers/scsi/qla2xxx/qla_nvme.c | 2 +- drivers/scsi/qla2xxx/qla_nx.c | 6 +++-- drivers/scsi/qla2xxx/qla_os.c | 29 +++++++++++++--------- drivers/scsi/qla2xxx/qla_target.c | 18 ++++++++------ drivers/scsi/qla2xxx/qla_target.h | 5 ---- 13 files changed, 139 insertions(+), 105 deletions(-)
drivers/scsi/qla2xxx/qla_bsg.c +26 -25
@@ -1920,7 +1920,7 @@ qla24xx_process_bidir_cmd(struct bsg_job *bsg_job)return rval; done_free_srb: -mempool_free (sp, ha->srb_mempool); +mempool_free (SRB_TO_U (sp), ha->srb_mempool); done_unmap_sg: dma_unmap_sg(&ha->pdev->dev, bsg_job->reply_payload.sg_list,
@@ -2043,7 +2043,7 @@ qlafx00_mgmt_cmd(struct bsg_job *bsg_job)if (rval !=QLA_SUCCESS ) {ql_log (ql_log_warn, vha,0x70cd ,"qla2x00_start_sp failed=%d.\n" , rval); -mempool_free (sp, ha->srb_mempool); +mempool_free (SRB_TO_U (sp), ha->srb_mempool); rval = -EIO ; goto done_free_fcport; }
@@ -2533,6 +2533,7 @@ qla24xx_bsg_timeout(struct bsg_job *bsg_job)int cnt, que;unsigned long flags;struct req_que *req; +struct unify_cmd *u;/* find the bsg job from the active list of commands */ spin_lock_irqsave (&ha->hardware_lock, flags);
@@ -2542,30 +2543,30 @@ qla24xx_bsg_timeout(struct bsg_job *bsg_job)continue ;for (cnt =1 ; cnt < req->num_outstanding_cmds; cnt++) { - sp = req->outstanding_cmds[cnt]; -if (sp) { -if (((sp->type ==SRB_CT_CMD ) || - (sp->type ==SRB_ELS_CMD_HST ) || - (sp->type ==SRB_FXIOCB_BCMD )) - && (sp->u.bsg_job == bsg_job)) { - req->outstanding_cmds[cnt] =NULL ; -spin_unlock_irqrestore (&ha->hardware_lock, flags); -if (ha->isp_ops->abort_command (sp)) { -ql_log (ql_log_warn, vha,0x7089 , -"mbx abort_command " -"failed.\n" ); -scsi_req (bsg_job->req)->result = - bsg_reply->result = -EIO ; - }else { -ql_dbg (ql_dbg_user, vha,0x708a , -"mbx abort_command " -"success.\n" ); -scsi_req (bsg_job->req)->result = - bsg_reply->result =0 ; - } -spin_lock_irqsave (&ha->hardware_lock, flags); - goto done; + u = req->outstanding_cmds[cnt]; +if (!u || u->cmd_type !=TYPE_SRB ) +continue ; + + sp = &u->srb; +if (((sp->type ==SRB_CT_CMD ) || + (sp->type ==SRB_ELS_CMD_HST ) || + (sp->type ==SRB_FXIOCB_BCMD )) + && (sp->u.bsg_job == bsg_job)) { + req->outstanding_cmds[cnt] =NULL ; +spin_unlock_irqrestore (&ha->hardware_lock, flags); +if (ha->isp_ops->abort_command (sp)) { +ql_log (ql_log_warn, vha,0x7089 , +"mbx abort_command failed.\n" ); +scsi_req (bsg_job->req)->result = + bsg_reply->result = -EIO ; + }else { +ql_dbg (ql_dbg_user, vha,0x708a , +"mbx abort_command success.\n" ); +scsi_req (bsg_job->req)->result = + bsg_reply->result =0 ; } +spin_lock_irqsave (&ha->hardware_lock, flags); + goto done; } } }
drivers/scsi/qla2xxx/qla_def.h +19 -12
@@ -291,6 +291,7 @@ struct name_list_extended {struct req_que ;struct qla_tgt_sess ; +struct unify_cmd ;/* * SCSI Request Block
@@ -458,18 +459,7 @@ struct srb_iocb {#define SRB_NVME_LS 20#define SRB_PRLI_CMD 21 -enum { -TYPE_SRB , -TYPE_TGT_CMD , -}; - typedef struct srb { - /* - * Do not move cmd_type field, it needs to - * line up with qla_tgt_cmd->cmd_type - */ - uint8_t cmd_type; - uint8_t pad[3]; atomic_t ref_count; wait_queue_head_t nvme_ls_waitq; struct fc_port *fcport;
@@ -3286,7 +3276,7 @@ struct req_que {uint16_t qos;uint16_t vp_idx;struct rsp_que *rsp; -srb_t **outstanding_cmds; +struct unify_cmd **outstanding_cmds;uint32_t current_outstanding_cmd;uint16_t num_outstanding_cmds;int max_q_depth;
@@ -4383,6 +4373,23 @@ enum nexus_wait_type { (IS_QLA27XX(_ha) || IS_QLA83XX(_ha)))#include "qla_target.h" + +typedef enum { +TYPE_SRB , +TYPE_TGT_CMD , +}cmd_type_t ; + +struct unify_cmd { +cmd_type_t cmd_type; +union { +struct srb srb; +struct qla_tgt_cmd tcmd; + }; +}; + +#define SRB_TO_U (_p) container_of(_p, struct unify_cmd, srb) +#define TCMD_TO_U (_p) container_of(_p, struct unify_cmd, tcmd) +#include "qla_gbl.h" #include "qla_dbg.h" #include "qla_inline.h"
drivers/scsi/qla2xxx/qla_init.c +4 -3
@@ -1404,10 +1404,11 @@ qla24xx_async_abort_command(srb_t *sp)struct scsi_qla_host *vha = fcport->vha;struct qla_hw_data *ha = vha->hw;struct req_que *req = vha->req; +struct unify_cmd *u =SRB_TO_U (sp);spin_lock_irqsave (&ha->hardware_lock, flags);for (handle =1 ; handle < req->num_outstanding_cmds; handle++) { -if (req->outstanding_cmds[handle] == sp) +if (req->outstanding_cmds[handle] == u)break ; }spin_unlock_irqrestore (&ha->hardware_lock, flags);
@@ -2799,7 +2800,7 @@ qla2x00_alloc_outstanding_cmds(struct qla_hw_data *ha, struct req_que *req) req->num_outstanding_cmds = ha->cur_fw_iocb_count; } - req->outstanding_cmds =kzalloc (sizeof (srb_t *) * + req->outstanding_cmds =kzalloc (sizeof (struct unify_cmd *) * req->num_outstanding_cmds,GFP_KERNEL );if (!req->outstanding_cmds) {
@@ -2808,7 +2809,7 @@ qla2x00_alloc_outstanding_cmds(struct qla_hw_data *ha, struct req_que *req)* initialization. */ req->num_outstanding_cmds =MIN_OUTSTANDING_COMMANDS ; - req->outstanding_cmds =kzalloc (sizeof (srb_t *) * + req->outstanding_cmds =kzalloc (sizeof (struct unify_cmd *) * req->num_outstanding_cmds,GFP_KERNEL );if (!req->outstanding_cmds) {
drivers/scsi/qla2xxx/qla_inline.h +14 -9
@@ -206,6 +206,7 @@ qla2x00_reset_active(scsi_qla_host_t *vha)static inline srb_t *qla2xxx_get_qpair_sp (struct qla_qpair *qpair,fc_port_t *fcport,gfp_t flag) { +struct unify_cmd *u;srb_t *sp =NULL ;uint8_t bail;
@@ -213,11 +214,13 @@ qla2xxx_get_qpair_sp(struct qla_qpair *qpair, fc_port_t *fcport, gfp_t flag)if (unlikely (bail))return NULL ; - sp =mempool_alloc (qpair->srb_mempool, flag); -if (!sp) + u =mempool_alloc (qpair->srb_mempool, flag); +if (!u) goto done; -memset (sp,0 ,sizeof (*sp)); +memset (u,0 ,sizeof (*u)); + u->cmd_type =TYPE_SRB ; + sp = &u->srb; sp->fcport = fcport; sp->iocbs =1 ; sp->vha = qpair->vha;
@@ -230,7 +233,7 @@ qla2xxx_get_qpair_sp(struct qla_qpair *qpair, fc_port_t *fcport, gfp_t flag)static inline void qla2xxx_rel_qpair_sp (struct qla_qpair *qpair,srb_t *sp) { -mempool_free (sp, qpair->srb_mempool); +mempool_free (SRB_TO_U (sp), qpair->srb_mempool);QLA_QPAIR_MARK_NOT_BUSY (qpair); }
@@ -238,19 +241,21 @@ static inline srb_t * qla2x00_get_sp(scsi_qla_host_t *vha, fc_port_t *fcport, gfp_t flag) {srb_t *sp =NULL ; +struct unify_cmd *u;uint8_t bail;QLA_VHA_MARK_BUSY (vha, bail);if (unlikely (bail))return NULL ; - sp =mempool_alloc (vha->hw->srb_mempool, flag); -if (!sp) + u =mempool_alloc (vha->hw->srb_mempool, flag); +if (!u) goto done; -memset (sp,0 ,sizeof (*sp)); +memset (u,0 ,sizeof (*u)); + u->cmd_type =TYPE_SRB ; + sp = &u->srb; sp->fcport = fcport; - sp->cmd_type =TYPE_SRB ; sp->iocbs =1 ; sp->vha = vha; done:
@@ -263,7 +268,7 @@ static inline void qla2x00_rel_sp(srb_t *sp) {QLA_VHA_MARK_NOT_BUSY (sp->vha); -mempool_free (sp, sp->vha->hw->srb_mempool); +mempool_free (SRB_TO_U (sp), sp->vha->hw->srb_mempool); } static inline void
drivers/scsi/qla2xxx/qla_iocb.c +8 -8
@@ -384,7 +384,7 @@ qla2x00_start_scsi(srb_t *sp)/* Build command packet */ req->current_outstanding_cmd = handle; - req->outstanding_cmds[handle] = sp; + req->outstanding_cmds[handle] =SRB_TO_U (sp); sp->handle = handle; cmd->host_scribble = (unsigned char *)(unsigned long )handle; req->cnt -= req_cnt;
@@ -1474,7 +1474,7 @@ qla24xx_start_scsi(srb_t *sp)/* Build command packet. */ req->current_outstanding_cmd = handle; - req->outstanding_cmds[handle] = sp; + req->outstanding_cmds[handle] =SRB_TO_U (sp); sp->handle = handle; cmd->host_scribble = (unsigned char *)(unsigned long )handle; req->cnt -= req_cnt;
@@ -1677,7 +1677,7 @@ qla24xx_dif_start_scsi(srb_t *sp)/* Build header part of command packet (excluding the OPCODE). */ req->current_outstanding_cmd = handle; - req->outstanding_cmds[handle] = sp; + req->outstanding_cmds[handle] =SRB_TO_U (sp); sp->handle = handle; cmd->host_scribble = (unsigned char *)(unsigned long )handle; req->cnt -= req_cnt;
@@ -1827,7 +1827,7 @@ qla2xxx_start_scsi_mq(srb_t *sp)/* Build command packet. */ req->current_outstanding_cmd = handle; - req->outstanding_cmds[handle] = sp; + req->outstanding_cmds[handle] =SRB_TO_U (sp); sp->handle = handle; cmd->host_scribble = (unsigned char *)(unsigned long )handle; req->cnt -= req_cnt;
@@ -2044,7 +2044,7 @@ qla2xxx_dif_start_scsi_mq(srb_t *sp)/* Build header part of command packet (excluding the OPCODE). */ req->current_outstanding_cmd = handle; - req->outstanding_cmds[handle] = sp; + req->outstanding_cmds[handle] =SRB_TO_U (sp); sp->handle = handle; cmd->host_scribble = (unsigned char *)(unsigned long )handle; req->cnt -= req_cnt;
@@ -2148,7 +2148,7 @@ __qla2x00_alloc_iocbs(struct qla_qpair *qpair, srb_t *sp)/* Prep command array. */ req->current_outstanding_cmd = handle; - req->outstanding_cmds[handle] = sp; + req->outstanding_cmds[handle] =SRB_TO_U (sp); sp->handle = handle;/* Adjust entry-counts as needed. */
@@ -3033,7 +3033,7 @@ qla82xx_start_scsi(srb_t *sp) }/* Build command packet. */ req->current_outstanding_cmd = handle; - req->outstanding_cmds[handle] = sp; + req->outstanding_cmds[handle] =SRB_TO_U (sp); sp->handle = handle; cmd->host_scribble = (unsigned char *)(unsigned long )handle; req->cnt -= req_cnt;
@@ -3459,7 +3459,7 @@ qla2x00_start_bidir(srb_t *sp, struct scsi_qla_host *vha, uint32_t tot_dsds) cmd_pkt->entry_status = (uint8_t ) rsp->id;/* Build command packet. */ req->current_outstanding_cmd = handle; - req->outstanding_cmds[handle] = sp; + req->outstanding_cmds[handle] =SRB_TO_U (sp); sp->handle = handle; req->cnt -= req_cnt;
drivers/scsi/qla2xxx/qla_isr.c +20 -11
@@ -1251,6 +1251,7 @@ qla2x00_process_completed_request(struct scsi_qla_host *vha, {srb_t *sp;struct qla_hw_data *ha = vha->hw; +struct unify_cmd *u;/* Validate handle. */ if (index >= req->num_outstanding_cmds) {
@@ -1264,8 +1265,9 @@ qla2x00_process_completed_request(struct scsi_qla_host *vha,return ; } - sp = req->outstanding_cmds[index]; -if (sp) { + u = req->outstanding_cmds[index]; +if (u) { + sp = &u->srb;/* Free outstanding command slot. */ req->outstanding_cmds[index] =NULL ;
@@ -1289,6 +1291,7 @@ qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func,sts_entry_t *pkt = iocb;srb_t *sp =NULL ;uint16_t index; +struct unify_cmd *u; index =LSW (pkt->handle);if (index >= req->num_outstanding_cmds) {
@@ -1301,12 +1304,14 @@ qla2x00_get_sp_from_handle(scsi_qla_host_t *vha, const char *func,set_bit (ISP_ABORT_NEEDED , &vha->dpc_flags); goto done; } - sp = req->outstanding_cmds[index]; -if (!sp) { + u = req->outstanding_cmds[index]; +if (!u) {ql_log (ql_log_warn, vha,0x5032 ,"Invalid completion handle (%x) -- timed-out.\n" , index); -return sp; +return NULL ; } + sp = &u->srb; +if (sp->handle != index) {ql_log (ql_log_warn, vha,0x5033 ,"SRB handle (%x) mismatch %x.\n" , sp->handle, index);
@@ -2165,6 +2170,7 @@ qla25xx_process_bidir_status_iocb(scsi_qla_host_t *vha, void *pkt,struct fc_bsg_reply *bsg_reply;sts_entry_t *sts;struct sts_entry_24xx *sts24; +struct unify_cmd *u; sts = (sts_entry_t *) pkt; sts24 = (struct sts_entry_24xx *) pkt;
@@ -2176,8 +2182,8 @@ qla25xx_process_bidir_status_iocb(scsi_qla_host_t *vha, void *pkt,return ; } - sp = req->outstanding_cmds[index]; -if (!sp) { + u = req->outstanding_cmds[index]; +if (!u) {ql_log (ql_log_warn, vha,0x70b0 ,"Req:%d: Invalid ISP SCSI completion handle(0x%x)\n" , req->id, index);
@@ -2188,6 +2194,7 @@ qla25xx_process_bidir_status_iocb(scsi_qla_host_t *vha, void *pkt,/* Free outstanding command slot. */ req->outstanding_cmds[index] =NULL ; + sp = &u->srb; bsg_job = sp->u.bsg_job; bsg_request = bsg_job->request; bsg_reply = bsg_job->reply;
@@ -2330,6 +2337,7 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)uint16_t state_flags =0 ;uint16_t retry_delay =0 ;uint8_t no_logout =0 ; +struct unify_cmd *u; sts = (sts_entry_t *) pkt; sts24 = (struct sts_entry_24xx *) pkt;
@@ -2356,8 +2364,8 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)/* Validate handle. */ if (handle < req->num_outstanding_cmds) { - sp = req->outstanding_cmds[handle]; -if (!sp) { + u = req->outstanding_cmds[handle]; +if (!u) {ql_dbg (ql_dbg_io, vha,0x3075 ,"%s(%ld): Already returned command for status handle (0x%x).\n" , __func__, vha->host_no, sts->handle);
@@ -2378,14 +2386,15 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)return ; } -if (sp->cmd_type !=TYPE_SRB ) { +if (u->cmd_type !=TYPE_SRB ) { req->outstanding_cmds[handle] =NULL ;ql_dbg (ql_dbg_io, vha,0x3015 ,"Unknown sp->cmd_type %x %p).\n" , - sp->cmd_type, sp); + u->cmd_type, u);return ; } + sp = &u->srb;/* NVME completion. */ if (sp->type ==SRB_NVME_CMD ) {qla24xx_nvme_iocb_entry (vha, req, pkt);
drivers/scsi/qla2xxx/qla_mbx.c +4 -2
@@ -1306,7 +1306,8 @@ qla2x00_abort_command(srb_t *sp)spin_lock_irqsave (&ha->hardware_lock, flags);for (handle =1 ; handle < req->num_outstanding_cmds; handle++) { -if (req->outstanding_cmds[handle] == sp) +struct unify_cmd *u =SRB_TO_U (sp); +if (req->outstanding_cmds[handle] == u)break ; }spin_unlock_irqrestore (&ha->hardware_lock, flags);
@@ -2923,7 +2924,8 @@ qla24xx_abort_command(srb_t *sp)spin_lock_irqsave (&ha->hardware_lock, flags);for (handle =1 ; handle < req->num_outstanding_cmds; handle++) { -if (req->outstanding_cmds[handle] == sp) +struct unify_cmd *u =SRB_TO_U (sp); +if (req->outstanding_cmds[handle] == u)break ; }spin_unlock_irqrestore (&ha->hardware_lock, flags);
drivers/scsi/qla2xxx/qla_mr.c +10 -9
@@ -2292,7 +2292,7 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)struct req_que *req;int logit =1 ;int res =0 ; - +struct unify_cmd *u; sts = (struct sts_entry_fx00 *) pkt; comp_status = sts->comp_status;
@@ -2305,11 +2305,11 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)/* Validate handle. */ if (handle < req->num_outstanding_cmds) - sp = req->outstanding_cmds[handle]; + u = req->outstanding_cmds[handle];else - sp =NULL ; + u =NULL ; -if (sp ==NULL ) { +if (u ==NULL ) {ql_dbg (ql_dbg_io, vha,0x3034 ,"Invalid status handle (0x%x).\n" , handle);
@@ -2317,6 +2317,7 @@ qlafx00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)qla2xxx_wake_dpc (vha);return ; } + sp = &u->srb;if (sp->type ==SRB_TM_CMD ) { req->outstanding_cmds[handle] =NULL ;
@@ -2626,7 +2627,7 @@ static void qlafx00_multistatus_entry(struct scsi_qla_host *vha, struct rsp_que *rsp, void *pkt) { - srb_t *sp; + struct unify_cmd *u;struct multi_sts_entry_fx00 *stsmfx;struct qla_hw_data *ha = vha->hw;uint32_t handle, hindex, handle_count, i;
@@ -2656,11 +2657,11 @@ qlafx00_multistatus_entry(struct scsi_qla_host *vha,/* Validate handle. */ if (handle < req->num_outstanding_cmds) - sp = req->outstanding_cmds[handle]; + u = req->outstanding_cmds[handle];else - sp =NULL ; + u =NULL ; -if (sp ==NULL ) { +if (u ==NULL ) {ql_dbg (ql_dbg_io, vha,0x3044 ,"Invalid status handle (0x%x).\n" , handle);set_bit (ISP_ABORT_NEEDED , &vha->dpc_flags);
@@ -3134,7 +3135,7 @@ qlafx00_start_scsi(srb_t *sp)/* Build command packet. */ req->current_outstanding_cmd = handle; - req->outstanding_cmds[handle] = sp; + req->outstanding_cmds[handle] =SRB_TO_U (sp); sp->handle = handle; cmd->host_scribble = (unsigned char *)(unsigned long )handle; req->cnt -= req_cnt;
drivers/scsi/qla2xxx/qla_nvme.c +1 -1
@@ -377,7 +377,7 @@ static int qla2x00_start_nvme_mq(srb_t *sp)/* Build command packet. */ req->current_outstanding_cmd = handle; - req->outstanding_cmds[handle] = sp; + req->outstanding_cmds[handle] =SRB_TO_U (sp); sp->handle = handle; req->cnt -= req_cnt;
drivers/scsi/qla2xxx/qla_nx.c +4 -2
@@ -3668,6 +3668,7 @@ qla82xx_chip_reset_cleanup(scsi_qla_host_t *vha)int cnt, que;srb_t *sp;struct req_que *req; +struct unify_cmd *u;spin_lock_irqsave (&ha->hardware_lock, flags);for (que =0 ; que < ha->max_req_queues; que++) {
@@ -3675,8 +3676,9 @@ qla82xx_chip_reset_cleanup(scsi_qla_host_t *vha)if (!req)continue ;for (cnt =1 ; cnt < req->num_outstanding_cmds; cnt++) { - sp = req->outstanding_cmds[cnt]; -if (sp) { + u = req->outstanding_cmds[cnt]; +if (u) { + sp = &u->srb; if ((!sp->u.scmd.ctx || (sp->flags & SRB_FCP_CMND_DMA_VALID)) &&
drivers/scsi/qla2xxx/qla_os.c +18 -11
@@ -1335,6 +1335,7 @@ qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *vha, unsigned int t,struct req_que *req;srb_t *sp;struct scsi_cmnd *cmd; +struct unify_cmd *u; status =QLA_SUCCESS ;
@@ -1342,9 +1343,11 @@ qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *vha, unsigned int t, req = vha->req;for (cnt =1 ; status ==QLA_SUCCESS && cnt < req->num_outstanding_cmds; cnt++) { - sp = req->outstanding_cmds[cnt]; -if (!sp) + u = req->outstanding_cmds[cnt]; +if (!u)continue ; + + sp = &u->srb;if (sp->type !=SRB_SCSI_CMD )continue ;if (vha->vp_idx != sp->vha->vp_idx)
@@ -1697,6 +1700,7 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)int que, cnt, status;unsigned long flags;srb_t *sp; +struct unify_cmd *u;struct qla_hw_data *ha = vha->hw;struct req_que *req;struct qla_tgt *tgt = vha->vha_tgt.qla_tgt;
@@ -1711,10 +1715,11 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)if (!req->outstanding_cmds)continue ;for (cnt =1 ; cnt < req->num_outstanding_cmds; cnt++) { - sp = req->outstanding_cmds[cnt]; -if (sp) { + u = req->outstanding_cmds[cnt]; +if (u) { req->outstanding_cmds[cnt] =NULL ; -if (sp->cmd_type ==TYPE_SRB ) { +if (u->cmd_type ==TYPE_SRB ) { + sp = &u->srb;if (sp->type ==SRB_NVME_CMD || sp->type ==SRB_NVME_LS ) {sp_get (sp);
@@ -1768,7 +1773,7 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) vha->dpc_flags);continue ; } - cmd = (struct qla_tgt_cmd *)sp; + cmd = &u->tcmd;qlt_abort_cmd_on_host_reset (cmd->vha, cmd); }
@@ -5926,6 +5931,7 @@ qla2x00_timer(scsi_qla_host_t *vha)uint16_t w;struct qla_hw_data *ha = vha->hw;struct req_que *req; +struct unify_cmd *u;if (ha->flags.eeh_busy) { ql_dbg(ql_dbg_timer, vha, 0x6000,
@@ -5986,11 +5992,12 @@ qla2x00_timer(scsi_qla_host_t *vha) index++) {fc_port_t *sfcp; - sp = req->outstanding_cmds[index]; -if (!sp) + u = req->outstanding_cmds[index]; +if (!u)continue ; -if (sp->cmd_type !=TYPE_SRB ) +if (u->cmd_type !=TYPE_SRB )continue ; + sp = &u->srb;if (sp->type !=SRB_SCSI_CMD )continue ; sfcp = sp->fcport;
@@ -6571,8 +6578,8 @@ qla2x00_module_init(void)int ret =0 ;/* Allocate cache for SRBs. */ - srb_cachep =kmem_cache_create ("qla2xxx_srbs" ,sizeof (srb_t),0 , -SLAB_HWCACHE_ALIGN ,NULL ); + srb_cachep =kmem_cache_create ("qla2xxx_srbs" ,sizeof (struct unify_cmd ), +0 ,SLAB_HWCACHE_ALIGN ,NULL );if (srb_cachep ==NULL ) {ql_log (ql_log_fatal,NULL ,0x0001 ,"Unable to allocate SRB cache...Failing load!.\n" );
drivers/scsi/qla2xxx/qla_target.c +11 -7
@@ -2379,7 +2379,7 @@ static int qlt_24xx_build_ctio_pkt(struct qla_qpair *qpair,*/ return -EAGAIN ; }else - qpair->req->outstanding_cmds[h] = (srb_t *)prm->cmd; + qpair->req->outstanding_cmds[h] =TCMD_TO_U (prm->cmd); pkt->handle =MAKE_HANDLE (qpair->req->id, h); pkt->handle |=CTIO_COMPLETION_HANDLE_MARK ;
@@ -2908,7 +2908,7 @@ qlt_build_ctio_crc2_pkt(struct qla_qpair *qpair, struct qla_tgt_prm *prm)*/ return -EAGAIN ; }else - qpair->req->outstanding_cmds[h] = (srb_t *)prm->cmd; + qpair->req->outstanding_cmds[h] =TCMD_TO_U (prm->cmd); pkt->handle =MAKE_HANDLE (qpair->req->id, h); pkt->handle |=CTIO_COMPLETION_HANDLE_MARK ;
@@ -3709,6 +3709,7 @@ static struct qla_tgt_cmd *qlt_ctio_to_cmd(struct scsi_qla_host *vha,struct req_que *req;int qid =GET_QID (handle);uint32_t h = handle & ~QLA_TGT_HANDLE_MASK ; +struct unify_cmd *u;if (unlikely (h ==QLA_TGT_SKIP_HANDLE ))return NULL ;
@@ -3734,13 +3735,14 @@ static struct qla_tgt_cmd *qlt_ctio_to_cmd(struct scsi_qla_host *vha,return NULL ; } - cmd = (struct qla_tgt_cmd *)req->outstanding_cmds[h]; -if (unlikely (cmd ==NULL )) { + u = req->outstanding_cmds[h]; +if (unlikely (u ==NULL )) {ql_dbg (ql_dbg_async, vha,0xe053 ,"qla_target(%d): Suspicious: unable to find the command with handle %x req->id %d rsp->id %d\n" , vha->vp_idx, handle, req->id, rsp->id);return NULL ; } + cmd = &u->tcmd; req->outstanding_cmds[h] =NULL ; }else if (ctio !=NULL ) {/* We can't get loop ID from CTIO7 */
@@ -4161,14 +4163,16 @@ static struct qla_tgt_cmd *qlt_get_tag(scsi_qla_host_t *vha,struct se_session *se_sess = sess->se_sess;struct qla_tgt_cmd *cmd;int tag; +struct unify_cmd *u; tag =percpu_ida_alloc (&se_sess->sess_tag_pool,TASK_RUNNING );if (tag <0 )return NULL ; - cmd = &((struct qla_tgt_cmd *)se_sess->sess_cmd_map)[tag]; -memset (cmd,0 ,sizeof (struct qla_tgt_cmd )); - cmd->cmd_type =TYPE_TGT_CMD ; + u = &((struct unify_cmd *)se_sess->sess_cmd_map)[tag]; +memset (u,0 ,sizeof (*u)); + u->cmd_type =TYPE_TGT_CMD ; + cmd = &u->tcmd;memcpy (&cmd->atio, atio,sizeof (*atio)); cmd->state =QLA_TGT_STATE_NEW ; cmd->tgt = vha->vha_tgt.qla_tgt;
drivers/scsi/qla2xxx/qla_target.h +0 -5
@@ -872,11 +872,6 @@ enum trace_flags { };struct qla_tgt_cmd { -/* -* Do not move cmd_type field. it needs to line up with srb->cmd_type -*/ -uint8_t cmd_type; -uint8_t pad[7 ];struct se_cmd se_cmd;struct fc_port *sess;struct qla_qpair *qpair;
Signature · 1 line
2.12.0
Re: [PATCH 1/7] qla2xxx: Cleanup NVMe code.
In reply to Himanshu MadhaniQuoted 1 line · Himanshu Madhani
This patch cleaned up code to make it more readable
Hello Himanshu,
"cleaned up code" is a very vague description. Please be more specific and please also mention in the patch description what functionality has been changed (if any).
Bart.
Re: [PATCH 3/7] qla2xxx: Add command completion wq for error path
In reply to Himanshu MadhaniQuoted 1 line · Himanshu Madhani
From: Duane Grigsby <[email protected]>
Hello Himanshu and Duane,
Too many drivers create workqueues for all kinds of purposes. Why is it necessary to execute qla_nvme_io_work() on the context of a new workqueue? If any of the existing system workqueues can be used please modify the patch accordingly. Otherwise please explain why it is necessary to introduce a new workqueue.
Bart.
Re: [PATCH 1/7] qla2xxx: Cleanup NVMe code.
In reply to Bart Van AsscheHi Bart,
Quoted 5 lines · Bart Van Assche
Quoted 1 line · Himanshu Madhani
This patch cleaned up code to make it more readable
Quoted 7 lines
Hello Himanshu,
"cleaned up code" is a very vague description. Please be more specific and please also mention in the patch description what functionality has been changed (if any).
Bart.
There is no functionality change in this patch, it addresses comments to make code readable.
for example,
Changing waitQ -> wait.
Combined multiple debug statements into single
Drop extra parenthesis in if() statements
I’ll add this into commit message for more clarity.
Thanks,
- Himanshu
Re: [PATCH 1/7] qla2xxx: Cleanup NVMe code.
In reply to Bart Van AsscheQuoted 3 lines · Bart Van Assche
"cleaned up code" is a very vague description. Please be more specific and please also mention in the patch description what functionality has been changed (if any).
Hi Bart,
These are just some style changes I requested when reviewing the last patchset. But I agree at least a "no functional changes introduced" would be very beneficial.
Thanks,
Johannes
Signature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Re: [PATCH 1/7] qla2xxx: Cleanup NVMe code.
In reply to Himanshu MadhaniWith an updated changelog,
Signature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Re: [PATCH 2/7] qla2xxx: Move function prototype to correct header
In reply to Himanshu MadhaniThanks Himanshu,
Signature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Re: [PATCH 4/7] qla2xxx: Added change to enable ZIO for FC-NVMe devices
In reply to Himanshu MadhaniReview
Quoted 2 lines · Himanshu Madhani
(quoted diff) +2
-0+ mcp->out_mb = MBX_2|MBX_1|MBX_0; + mcp->in_mb = MBX_2|MBX_0;
Please add spaces around the '|'. Checkpatch should've warned you about that.
drivers/scsi/qla2xxx/qla_mbx.c int qla24xx_gidlist_wait(struct scsi_qla_host *vha, · line 6105
Quoted 10 lines
drivers/scsi/qla2xxx/qla_mbx.c +10
-0+ mcp->tov =MBX_TOV_SECONDS ; + mcp->flags =0 ; + + rval =qla2x00_mailbox_command (vha, mcp); +if (rval !=QLA_SUCCESS ) { +ql_dbg (ql_dbg_mbx, vha,0x1201 ,"Failed=%x.\n" , rval); + }else { +ql_dbg (ql_dbg_mbx + ql_dbg_verbose, vha,0x1202 , +"Done %s.\n" , __func__); + }
In patch 1 you change all the
if (rval != QLA_SUCCESS) {
qla_dbg();
} else {
qla_dbg();
}into a single qla_dbg. Now you re-introduce the pattern here.
Quoted 1 line
+int
qla27xx_get_zio_threshold(scsi_qla_host_t *vha, uint16_t *value)
See above comment
Thanks,
Johannes
Signature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Re: [PATCH 5/7] qla2xxx: Simpify unregistration of FC-NVMe local/remote ports
In reply to Himanshu MadhaniQuoted 37 lines · Himanshu Madhani
drivers/scsi/qla2xxx/qla_nvme.c +0
-33-static void qla_nvme_abort_all (fc_port_t *fcport) -{ -int que, cnt; -unsigned long flags; -srb_t *sp; -struct qla_hw_data *ha = fcport->vha->hw; -struct req_que *req; - -spin_lock_irqsave (&ha->hardware_lock, flags); -for (que =0 ; que < ha->max_req_queues; que++) { - req = ha->req_q_map[que]; -if (!req) -continue ; -if (!req->outstanding_cmds) -continue ; -for (cnt =1 ; cnt < req->num_outstanding_cmds; cnt++) { - sp = req->outstanding_cmds[cnt]; -if ((sp) && ((sp->type ==SRB_NVME_CMD ) || - (sp->type ==SRB_NVME_LS )) && - (sp->fcport == fcport)) { -atomic_inc (&sp->ref_count); -spin_unlock_irqrestore (&ha->hardware_lock, - flags); -qla_nvme_abort (ha, sp); -spin_lock_irqsave (&ha->hardware_lock, flags); - req->outstanding_cmds[cnt] =NULL ; - sp->done (sp,1 ); - } - } - } -spin_unlock_irqrestore (&ha->hardware_lock, flags); -} -static void qla_nvme_unregister_remote_port (struct work_struct *work) { struct fc_port *fcport = container_of(work, struct fc_port,
drivers/scsi/qla2xxx/qla_nvme.c void qla_nvme_delete(struct scsi_qla_host *vha) · line 724
Quoted 7 lines
drivers/scsi/qla2xxx/qla_nvme.c +1
-1@@ -719,12 +679,13 @@ void qla_nvme_delete(struct scsi_qla_host *vha)ql_log (ql_log_info, fcport->vha,0x2114 ,"%s: fcport=%p\n" , __func__, fcport); +init_completion (&fcport->nvme_del_done);nvme_fc_unregister_remoteport (fcport->nvme_remote_port);qla_nvme_wait_on_rport_del (fcport); -qla_nvme_abort_all (fcport);
What changed the need to abort all outstanding commands?
Signature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Re: [PATCH 6/7] qla2xxx: Fix remoteport disconnect for FC-NVMe
In reply to Himanshu MadhaniLooks good,
Signature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Re: [PATCH 4/7] qla2xxx: Added change to enable ZIO for FC-NVMe devices
In reply to Johannes ThumshirnQuoted 9 lines · Johannes Thumshirn
Review
Quoted 2 lines · Himanshu Madhani
(quoted diff) +2
-0+ mcp->out_mb = MBX_2|MBX_1|MBX_0; + mcp->in_mb = MBX_2|MBX_0;Please add spaces around the '|'. Checkpatch should've warned you about that.
Sure.
Quoted 12 lines
drivers/scsi/qla2xxx/qla_mbx.c int qla24xx_gidlist_wait(struct scsi_qla_host *vha, · line 6105
Quoted 10 lines
drivers/scsi/qla2xxx/qla_mbx.c +10
-0+ mcp->tov =MBX_TOV_SECONDS ; + mcp->flags =0 ; + + rval =qla2x00_mailbox_command (vha, mcp); +if (rval !=QLA_SUCCESS ) { +ql_dbg (ql_dbg_mbx, vha,0x1201 ,"Failed=%x.\n" , rval); + }else { +ql_dbg (ql_dbg_mbx + ql_dbg_verbose, vha,0x1202 , +"Done %s.\n" , __func__); + }In patch 1 you change all the
Quoted 7 lines
if (rval != QLA_SUCCESS) { qla_dbg(); } else { qla_dbg(); }into a single
qla_dbg. Now you re-introduce the pattern here.
Good catch.. somehow this missed my eye. I’ll fix in v2 of this series.
Quoted 14 lines
Quoted 2 lines
+int
qla27xx_get_zio_threshold(scsi_qla_host_t *vha, uint16_t *value)See above comment
Thanks,
JohannesSignature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Thanks,
- Himanshu
Re: [PATCH 3/7] qla2xxx: Add command completion wq for error path
In reply to Bart Van AsscheHi Bart,
Quoted 7 lines · Bart Van Assche
Quoted 1 line · Himanshu Madhani
From: Duane Grigsby <[email protected]>
Hello Himanshu and Duane,
Quoted 7 lines
Too many drivers create workqueues for all kinds of purposes. Why is it necessary to execute
qla_nvme_io_work()on the context of a new workqueue? If any of the existing system workqueues can be used please modify the patch accordingly. Otherwise please explain why it is necessary to introduce a new workqueue.Bart.
Good point. We went with this approach so that we could release qpair lock on a particular queue when we get error. however, we’ll rework this patch and submit it again to use one of already existing work queue.
Thanks,
- Himanshu
Re: [PATCH 5/7] qla2xxx: Simpify unregistration of FC-NVMe local/remote ports
In reply to Johannes ThumshirnHi Johannes,
Quoted 43 lines · Johannes Thumshirn
Quoted 40 lines · Himanshu Madhani
drivers/scsi/qla2xxx/qla_nvme.c +0
-33-static void qla_nvme_abort_all (fc_port_t *fcport) -{ -int que, cnt; -unsigned long flags; -srb_t *sp; -struct qla_hw_data *ha = fcport->vha->hw; -struct req_que *req; - -spin_lock_irqsave (&ha->hardware_lock, flags); -for (que =0 ; que < ha->max_req_queues; que++) { - req = ha->req_q_map[que]; -if (!req) -continue ; -if (!req->outstanding_cmds) -continue ; -for (cnt =1 ; cnt < req->num_outstanding_cmds; cnt++) { - sp = req->outstanding_cmds[cnt]; -if ((sp) && ((sp->type ==SRB_NVME_CMD ) || - (sp->type ==SRB_NVME_LS )) && - (sp->fcport == fcport)) { -atomic_inc (&sp->ref_count); -spin_unlock_irqrestore (&ha->hardware_lock, - flags); -qla_nvme_abort (ha, sp); -spin_lock_irqsave (&ha->hardware_lock, flags); - req->outstanding_cmds[cnt] =NULL ; - sp->done (sp,1 ); - } - } - } -spin_unlock_irqrestore (&ha->hardware_lock, flags); -} -static void
qla_nvme_unregister_remote_port(struct work_struct *work){
structfc_port*fcport = container_of(work, structfc_port,drivers/scsi/qla2xxx/qla_nvme.c +0
-0@@ -719,12 +679,13 @@ void qla_nvme_delete(struct scsi_qla_host *vha)ql_log (ql_log_info, fcport->vha,0x2114 ,"%s: fcport=%p\n" , __func__, fcport);
Quoted 7 lines
drivers/scsi/qla2xxx/qla_nvme.c void qla_nvme_delete(struct scsi_qla_host *vha) · line 724
Quoted 4 lines
drivers/scsi/qla2xxx/qla_nvme.c +1
-1+init_completion (&fcport->nvme_del_done);nvme_fc_unregister_remoteport (fcport->nvme_remote_port);qla_nvme_wait_on_rport_del (fcport); -qla_nvme_abort_all (fcport);What changed the need to abort all outstanding commands?
FC NVMe transport now handles _abort_ so we do not need to call qla_nvme_abort_all()
Quoted 7 lines
Signature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Thanks,
- Himanshu