mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-19 10:14:23 +08:00
scsi: qla2xxx: Cleanup FC-NVMe code
This patch does not change any functionality. Following cleanups have been done as requested by reviewer - Changed waitQ --> waitq - Collapsed multiple debug statements into single - Remove extra parentheses in if-else as per operator precedence - Remove unnecessary casting Cc: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
e14a396772
commit
6fcd98fd2c
@ -470,7 +470,7 @@ typedef struct srb {
|
|||||||
uint8_t cmd_type;
|
uint8_t cmd_type;
|
||||||
uint8_t pad[3];
|
uint8_t pad[3];
|
||||||
atomic_t ref_count;
|
atomic_t ref_count;
|
||||||
wait_queue_head_t nvme_ls_waitQ;
|
wait_queue_head_t nvme_ls_waitq;
|
||||||
struct fc_port *fcport;
|
struct fc_port *fcport;
|
||||||
struct scsi_qla_host *vha;
|
struct scsi_qla_host *vha;
|
||||||
uint32_t handle;
|
uint32_t handle;
|
||||||
@ -2302,7 +2302,7 @@ typedef struct fc_port {
|
|||||||
|
|
||||||
struct work_struct nvme_del_work;
|
struct work_struct nvme_del_work;
|
||||||
atomic_t nvme_ref_count;
|
atomic_t nvme_ref_count;
|
||||||
wait_queue_head_t nvme_waitQ;
|
wait_queue_head_t nvme_waitq;
|
||||||
uint32_t nvme_prli_service_param;
|
uint32_t nvme_prli_service_param;
|
||||||
#define NVME_PRLI_SP_CONF BIT_7
|
#define NVME_PRLI_SP_CONF BIT_7
|
||||||
#define NVME_PRLI_SP_INITIATOR BIT_5
|
#define NVME_PRLI_SP_INITIATOR BIT_5
|
||||||
@ -4130,7 +4130,7 @@ typedef struct scsi_qla_host {
|
|||||||
|
|
||||||
struct nvme_fc_local_port *nvme_local_port;
|
struct nvme_fc_local_port *nvme_local_port;
|
||||||
atomic_t nvme_ref_count;
|
atomic_t nvme_ref_count;
|
||||||
wait_queue_head_t nvme_waitQ;
|
wait_queue_head_t nvme_waitq;
|
||||||
struct list_head nvme_rport_list;
|
struct list_head nvme_rport_list;
|
||||||
atomic_t nvme_active_aen_cnt;
|
atomic_t nvme_active_aen_cnt;
|
||||||
uint16_t nvme_last_rptd_aen;
|
uint16_t nvme_last_rptd_aen;
|
||||||
|
@ -77,15 +77,15 @@ int qla_nvme_register_remote(scsi_qla_host_t *vha, fc_port_t *fcport)
|
|||||||
fcport->nvme_remote_port->private = fcport;
|
fcport->nvme_remote_port->private = fcport;
|
||||||
fcport->nvme_flag |= NVME_FLAG_REGISTERED;
|
fcport->nvme_flag |= NVME_FLAG_REGISTERED;
|
||||||
atomic_set(&fcport->nvme_ref_count, 1);
|
atomic_set(&fcport->nvme_ref_count, 1);
|
||||||
init_waitqueue_head(&fcport->nvme_waitQ);
|
init_waitqueue_head(&fcport->nvme_waitq);
|
||||||
rport->fcport = fcport;
|
rport->fcport = fcport;
|
||||||
list_add_tail(&rport->list, &vha->nvme_rport_list);
|
list_add_tail(&rport->list, &vha->nvme_rport_list);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate a queue for NVMe traffic */
|
/* Allocate a queue for NVMe traffic */
|
||||||
static int qla_nvme_alloc_queue(struct nvme_fc_local_port *lport, unsigned int qidx,
|
static int qla_nvme_alloc_queue(struct nvme_fc_local_port *lport,
|
||||||
u16 qsize, void **handle)
|
unsigned int qidx, u16 qsize, void **handle)
|
||||||
{
|
{
|
||||||
struct scsi_qla_host *vha;
|
struct scsi_qla_host *vha;
|
||||||
struct qla_hw_data *ha;
|
struct qla_hw_data *ha;
|
||||||
@ -193,13 +193,11 @@ static void qla_nvme_ls_abort(struct nvme_fc_local_port *lport,
|
|||||||
struct qla_hw_data *ha = fcport->vha->hw;
|
struct qla_hw_data *ha = fcport->vha->hw;
|
||||||
|
|
||||||
rval = ha->isp_ops->abort_command(sp);
|
rval = ha->isp_ops->abort_command(sp);
|
||||||
if (rval != QLA_SUCCESS)
|
|
||||||
ql_log(ql_log_warn, fcport->vha, 0x2125,
|
|
||||||
"%s: failed to abort LS command for SP:%p rval=%x\n",
|
|
||||||
__func__, sp, rval);
|
|
||||||
|
|
||||||
ql_dbg(ql_dbg_io, fcport->vha, 0x212b,
|
ql_dbg(ql_dbg_io, fcport->vha, 0x212b,
|
||||||
"%s: aborted sp:%p on fcport:%p\n", __func__, sp, fcport);
|
"%s: %s LS command for sp=%p on fcport=%p rval=%x\n", __func__,
|
||||||
|
(rval != QLA_SUCCESS) ? "Failed to abort" : "Aborted",
|
||||||
|
sp, fcport, rval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qla_nvme_ls_complete(struct work_struct *work)
|
static void qla_nvme_ls_complete(struct work_struct *work)
|
||||||
@ -214,7 +212,7 @@ static void qla_nvme_ls_complete(struct work_struct *work)
|
|||||||
static int qla_nvme_ls_req(struct nvme_fc_local_port *lport,
|
static int qla_nvme_ls_req(struct nvme_fc_local_port *lport,
|
||||||
struct nvme_fc_remote_port *rport, struct nvmefc_ls_req *fd)
|
struct nvme_fc_remote_port *rport, struct nvmefc_ls_req *fd)
|
||||||
{
|
{
|
||||||
fc_port_t *fcport = (fc_port_t *)rport->private;
|
fc_port_t *fcport = rport->private;
|
||||||
struct srb_iocb *nvme;
|
struct srb_iocb *nvme;
|
||||||
struct nvme_private *priv = fd->private;
|
struct nvme_private *priv = fd->private;
|
||||||
struct scsi_qla_host *vha;
|
struct scsi_qla_host *vha;
|
||||||
@ -236,7 +234,7 @@ static int qla_nvme_ls_req(struct nvme_fc_local_port *lport,
|
|||||||
sp->name = "nvme_ls";
|
sp->name = "nvme_ls";
|
||||||
sp->done = qla_nvme_sp_ls_done;
|
sp->done = qla_nvme_sp_ls_done;
|
||||||
atomic_set(&sp->ref_count, 1);
|
atomic_set(&sp->ref_count, 1);
|
||||||
init_waitqueue_head(&sp->nvme_ls_waitQ);
|
init_waitqueue_head(&sp->nvme_ls_waitq);
|
||||||
nvme = &sp->u.iocb_cmd;
|
nvme = &sp->u.iocb_cmd;
|
||||||
priv->sp = sp;
|
priv->sp = sp;
|
||||||
priv->fd = fd;
|
priv->fd = fd;
|
||||||
@ -258,7 +256,7 @@ static int qla_nvme_ls_req(struct nvme_fc_local_port *lport,
|
|||||||
ql_log(ql_log_warn, vha, 0x700e,
|
ql_log(ql_log_warn, vha, 0x700e,
|
||||||
"qla2x00_start_sp failed = %d\n", rval);
|
"qla2x00_start_sp failed = %d\n", rval);
|
||||||
atomic_dec(&sp->ref_count);
|
atomic_dec(&sp->ref_count);
|
||||||
wake_up(&sp->nvme_ls_waitQ);
|
wake_up(&sp->nvme_ls_waitq);
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,20 +274,18 @@ static void qla_nvme_fcp_abort(struct nvme_fc_local_port *lport,
|
|||||||
struct qla_hw_data *ha = fcport->vha->hw;
|
struct qla_hw_data *ha = fcport->vha->hw;
|
||||||
|
|
||||||
rval = ha->isp_ops->abort_command(sp);
|
rval = ha->isp_ops->abort_command(sp);
|
||||||
if (!rval)
|
|
||||||
ql_log(ql_log_warn, fcport->vha, 0x2127,
|
|
||||||
"%s: failed to abort command for SP:%p rval=%x\n",
|
|
||||||
__func__, sp, rval);
|
|
||||||
|
|
||||||
ql_dbg(ql_dbg_io, fcport->vha, 0x2126,
|
ql_dbg(ql_dbg_io, fcport->vha, 0x2127,
|
||||||
"%s: aborted sp:%p on fcport:%p\n", __func__, sp, fcport);
|
"%s: %s command for sp=%p on fcport=%p rval=%x\n", __func__,
|
||||||
|
(rval != QLA_SUCCESS) ? "Failed to abort" : "Aborted",
|
||||||
|
sp, fcport, rval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qla_nvme_poll(struct nvme_fc_local_port *lport, void *hw_queue_handle)
|
static void qla_nvme_poll(struct nvme_fc_local_port *lport, void *hw_queue_handle)
|
||||||
{
|
{
|
||||||
struct scsi_qla_host *vha = lport->private;
|
struct scsi_qla_host *vha = lport->private;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
struct qla_qpair *qpair = (struct qla_qpair *)hw_queue_handle;
|
struct qla_qpair *qpair = hw_queue_handle;
|
||||||
|
|
||||||
/* Acquire ring specific lock */
|
/* Acquire ring specific lock */
|
||||||
spin_lock_irqsave(&qpair->qp_lock, flags);
|
spin_lock_irqsave(&qpair->qp_lock, flags);
|
||||||
@ -487,7 +483,7 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port *lport,
|
|||||||
struct scsi_qla_host *vha;
|
struct scsi_qla_host *vha;
|
||||||
int rval = QLA_FUNCTION_FAILED;
|
int rval = QLA_FUNCTION_FAILED;
|
||||||
srb_t *sp;
|
srb_t *sp;
|
||||||
struct qla_qpair *qpair = (struct qla_qpair *)hw_queue_handle;
|
struct qla_qpair *qpair = hw_queue_handle;
|
||||||
struct nvme_private *priv;
|
struct nvme_private *priv;
|
||||||
|
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
@ -496,7 +492,7 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port *lport,
|
|||||||
}
|
}
|
||||||
|
|
||||||
priv = fd->private;
|
priv = fd->private;
|
||||||
fcport = (fc_port_t *)rport->private;
|
fcport = rport->private;
|
||||||
if (!fcport) {
|
if (!fcport) {
|
||||||
ql_log(ql_log_warn, NULL, 0x210e, "No fcport ptr\n");
|
ql_log(ql_log_warn, NULL, 0x210e, "No fcport ptr\n");
|
||||||
return rval;
|
return rval;
|
||||||
@ -512,7 +508,7 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port *lport,
|
|||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
atomic_set(&sp->ref_count, 1);
|
atomic_set(&sp->ref_count, 1);
|
||||||
init_waitqueue_head(&sp->nvme_ls_waitQ);
|
init_waitqueue_head(&sp->nvme_ls_waitq);
|
||||||
priv->sp = sp;
|
priv->sp = sp;
|
||||||
sp->type = SRB_NVME_CMD;
|
sp->type = SRB_NVME_CMD;
|
||||||
sp->name = "nvme_cmd";
|
sp->name = "nvme_cmd";
|
||||||
@ -526,7 +522,7 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port *lport,
|
|||||||
ql_log(ql_log_warn, vha, 0x212d,
|
ql_log(ql_log_warn, vha, 0x212d,
|
||||||
"qla2x00_start_nvme_mq failed = %d\n", rval);
|
"qla2x00_start_nvme_mq failed = %d\n", rval);
|
||||||
atomic_dec(&sp->ref_count);
|
atomic_dec(&sp->ref_count);
|
||||||
wake_up(&sp->nvme_ls_waitQ);
|
wake_up(&sp->nvme_ls_waitq);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,7 +534,7 @@ static void qla_nvme_localport_delete(struct nvme_fc_local_port *lport)
|
|||||||
struct scsi_qla_host *vha = lport->private;
|
struct scsi_qla_host *vha = lport->private;
|
||||||
|
|
||||||
atomic_dec(&vha->nvme_ref_count);
|
atomic_dec(&vha->nvme_ref_count);
|
||||||
wake_up_all(&vha->nvme_waitQ);
|
wake_up_all(&vha->nvme_waitq);
|
||||||
|
|
||||||
ql_log(ql_log_info, vha, 0x210f,
|
ql_log(ql_log_info, vha, 0x210f,
|
||||||
"localport delete of %p completed.\n", vha->nvme_local_port);
|
"localport delete of %p completed.\n", vha->nvme_local_port);
|
||||||
@ -550,11 +546,11 @@ static void qla_nvme_remoteport_delete(struct nvme_fc_remote_port *rport)
|
|||||||
fc_port_t *fcport;
|
fc_port_t *fcport;
|
||||||
struct nvme_rport *r_port, *trport;
|
struct nvme_rport *r_port, *trport;
|
||||||
|
|
||||||
fcport = (fc_port_t *)rport->private;
|
fcport = rport->private;
|
||||||
fcport->nvme_remote_port = NULL;
|
fcport->nvme_remote_port = NULL;
|
||||||
fcport->nvme_flag &= ~NVME_FLAG_REGISTERED;
|
fcport->nvme_flag &= ~NVME_FLAG_REGISTERED;
|
||||||
atomic_dec(&fcport->nvme_ref_count);
|
atomic_dec(&fcport->nvme_ref_count);
|
||||||
wake_up_all(&fcport->nvme_waitQ);
|
wake_up_all(&fcport->nvme_waitq);
|
||||||
|
|
||||||
list_for_each_entry_safe(r_port, trport,
|
list_for_each_entry_safe(r_port, trport,
|
||||||
&fcport->vha->nvme_rport_list, list) {
|
&fcport->vha->nvme_rport_list, list) {
|
||||||
@ -594,7 +590,7 @@ static int qla_nvme_wait_on_command(srb_t *sp)
|
|||||||
{
|
{
|
||||||
int ret = QLA_SUCCESS;
|
int ret = QLA_SUCCESS;
|
||||||
|
|
||||||
wait_event_timeout(sp->nvme_ls_waitQ, (atomic_read(&sp->ref_count) > 1),
|
wait_event_timeout(sp->nvme_ls_waitq, (atomic_read(&sp->ref_count) > 1),
|
||||||
NVME_ABORT_POLLING_PERIOD*HZ);
|
NVME_ABORT_POLLING_PERIOD*HZ);
|
||||||
|
|
||||||
if (atomic_read(&sp->ref_count) > 1)
|
if (atomic_read(&sp->ref_count) > 1)
|
||||||
@ -607,7 +603,7 @@ static int qla_nvme_wait_on_rport_del(fc_port_t *fcport)
|
|||||||
{
|
{
|
||||||
int ret = QLA_SUCCESS;
|
int ret = QLA_SUCCESS;
|
||||||
|
|
||||||
wait_event_timeout(fcport->nvme_waitQ,
|
wait_event_timeout(fcport->nvme_waitq,
|
||||||
atomic_read(&fcport->nvme_ref_count),
|
atomic_read(&fcport->nvme_ref_count),
|
||||||
NVME_ABORT_POLLING_PERIOD*HZ);
|
NVME_ABORT_POLLING_PERIOD*HZ);
|
||||||
|
|
||||||
@ -625,12 +621,9 @@ void qla_nvme_abort(struct qla_hw_data *ha, srb_t *sp)
|
|||||||
int rval;
|
int rval;
|
||||||
|
|
||||||
rval = ha->isp_ops->abort_command(sp);
|
rval = ha->isp_ops->abort_command(sp);
|
||||||
if (!rval) {
|
if (!rval && !qla_nvme_wait_on_command(sp))
|
||||||
if (!qla_nvme_wait_on_command(sp))
|
ql_log(ql_log_warn, NULL, 0x2112,
|
||||||
ql_log(ql_log_warn, NULL, 0x2112,
|
"nvme_wait_on_comand timed out waiting on sp=%p\n", sp);
|
||||||
"nvme_wait_on_command timed out waiting on sp=%p\n",
|
|
||||||
sp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qla_nvme_abort_all(fc_port_t *fcport)
|
static void qla_nvme_abort_all(fc_port_t *fcport)
|
||||||
@ -757,5 +750,5 @@ void qla_nvme_register_hba(scsi_qla_host_t *vha)
|
|||||||
}
|
}
|
||||||
atomic_set(&vha->nvme_ref_count, 1);
|
atomic_set(&vha->nvme_ref_count, 1);
|
||||||
vha->nvme_local_port->private = vha;
|
vha->nvme_local_port->private = vha;
|
||||||
init_waitqueue_head(&vha->nvme_waitQ);
|
init_waitqueue_head(&vha->nvme_waitq);
|
||||||
}
|
}
|
||||||
|
@ -710,7 +710,7 @@ qla2x00_sp_free_dma(void *ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
end:
|
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;
|
CMD_SP(cmd) = NULL;
|
||||||
qla2x00_rel_sp(sp);
|
qla2x00_rel_sp(sp);
|
||||||
}
|
}
|
||||||
@ -1715,8 +1715,8 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)
|
|||||||
if (sp) {
|
if (sp) {
|
||||||
req->outstanding_cmds[cnt] = NULL;
|
req->outstanding_cmds[cnt] = NULL;
|
||||||
if (sp->cmd_type == TYPE_SRB) {
|
if (sp->cmd_type == TYPE_SRB) {
|
||||||
if ((sp->type == SRB_NVME_CMD) ||
|
if (sp->type == SRB_NVME_CMD ||
|
||||||
(sp->type == SRB_NVME_LS)) {
|
sp->type == SRB_NVME_LS) {
|
||||||
sp_get(sp);
|
sp_get(sp);
|
||||||
spin_unlock_irqrestore(
|
spin_unlock_irqrestore(
|
||||||
&ha->hardware_lock, flags);
|
&ha->hardware_lock, flags);
|
||||||
|
Loading…
Reference in New Issue
Block a user