[PATCH v3 04/13] qla2xxx: Restore ZIO threshold setting

2018-03-19 Thread Himanshu Madhani
From: Darren Trapp 

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/qla2xxx/qla_nvme.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index a8e81fc14c44..5ee447680ddd 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -464,11 +464,6 @@ 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;
-- 
2.14.1



[PATCH v3 06/13] qla2xxx: Fix n2n_ae flag to prevent dev_loss on PDB change

2018-03-19 Thread Himanshu Madhani
From: Darren Trapp 

On a port db changes, this patch will set n2n_ae flag for N2N
connection when requesting for Report ID Acquition MBX, instead
of Loop Initialization or point to point asynchronous events.

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/qla2xxx/qla_def.h | 2 --
 drivers/scsi/qla2xxx/qla_isr.c | 3 ---
 drivers/scsi/qla2xxx/qla_mbx.c | 3 +++
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 56f78dce4d3c..cba749d27154 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -4281,8 +4281,6 @@ typedef struct scsi_qla_host {
struct  nvme_fc_local_port *nvme_local_port;
struct completion nvme_del_done;
struct list_head nvme_rport_list;
-   atomic_tnvme_active_aen_cnt;
-   uint16_tnvme_last_rptd_aen;
 
uint16_tfcoe_vlan_id;
uint16_tfcoe_fcf_idx;
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 93f2f1df7168..913cd6cf5907 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -767,7 +767,6 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que 
*rsp, uint16_t *mb)
 
case MBA_LIP_OCCURRED:  /* Loop Initialization Procedure */
ha->flags.lip_ae = 1;
-   ha->flags.n2n_ae = 0;
 
ql_dbg(ql_dbg_async, vha, 0x5009,
"LIP occurred (%x).\n", mb[1]);
@@ -811,7 +810,6 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que 
*rsp, uint16_t *mb)
 
case MBA_LOOP_DOWN: /* Loop Down Event */
SAVE_TOPO(ha);
-   ha->flags.n2n_ae = 0;
ha->flags.lip_ae = 0;
ha->current_topology = 0;
 
@@ -885,7 +883,6 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que 
*rsp, uint16_t *mb)
/* case MBA_DCBX_COMPLETE: */
case MBA_POINT_TO_POINT:/* Point-to-Point */
ha->flags.lip_ae = 0;
-   ha->flags.n2n_ae = 1;
 
if (IS_QLA2100(ha))
break;
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 41b0ee47c6a1..735079ba691c 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -3747,6 +3747,7 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
id.b.area   = rptid_entry->port_id[1];
id.b.al_pa  = rptid_entry->port_id[0];
id.b.rsvd_1 = 0;
+   ha->flags.n2n_ae = 0;
 
if (rptid_entry->format == 0) {
/* loop */
@@ -3799,6 +3800,7 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
set_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags);
set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags);
set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags);
+   ha->flags.n2n_ae = 1;
return;
}
 
@@ -3875,6 +3877,7 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
vha->d_id.b.area = rptid_entry->port_id[1];
vha->d_id.b.al_pa = rptid_entry->port_id[0];
 
+   ha->flags.n2n_ae = 1;
spin_lock_irqsave(&ha->vport_slock, flags);
qlt_update_vp_map(vha, SET_AL_PA);
spin_unlock_irqrestore(&ha->vport_slock, flags);
-- 
2.14.1



[PATCH v3 02/13] qla2xxx: Set IIDMA and fcport state before qla_nvme_register_remote()

2018-03-19 Thread Himanshu Madhani
From: Darren Trapp 

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/qla2xxx/qla_init.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 590aa904fdef..1878a6f24ddb 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -5107,13 +5107,14 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t 
*fcport)
fcport->deleted = 0;
fcport->logout_on_delete = 1;
 
+   qla2x00_set_fcport_state(fcport, FCS_ONLINE);
+   qla2x00_iidma_fcport(vha, fcport);
+
if (fcport->fc4f_nvme) {
qla_nvme_register_remote(vha, fcport);
return;
}
 
-   qla2x00_set_fcport_state(fcport, FCS_ONLINE);
-   qla2x00_iidma_fcport(vha, fcport);
qla24xx_update_fcport_fcp_prio(vha, fcport);
 
 reg_port:
-- 
2.14.1



[PATCH v3 01/13] qla2xxx: Remove unneeded message and minor cleanup for FC-NVMe

2018-03-19 Thread Himanshu Madhani
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/qla2xxx/qla_nvme.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index 6b33a1f24f56..162a523b985e 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -113,8 +113,6 @@ static int qla_nvme_alloc_queue(struct nvme_fc_local_port 
*lport,
return 0;
}
 
-   ql_log(ql_log_warn, vha, 0x,
-   "allocating q for idx=%x w/o cpu mask\n", qidx);
qpair = qla2xxx_create_qpair(vha, 5, vha->vp_idx, true);
if (qpair == NULL) {
ql_log(ql_log_warn, vha, 0x2122,
@@ -313,7 +311,6 @@ static int qla2x00_start_nvme_mq(srb_t *sp)
uint16_tavail_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;
@@ -322,15 +319,13 @@ static int qla2x00_start_nvme_mq(srb_t *sp)
struct nvmefc_fcp_req *fd = nvme->u.nvme.desc;
uint32_trval = 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++) {
@@ -365,7 +360,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->hw->nvme_active_aen_cnt);
+   atomic_inc(&ha->nvme_active_aen_cnt);
}
}
 
-- 
2.14.1



[PATCH v3 13/13] qla2xxx: Update driver version to 10.00.00.06-k

2018-03-19 Thread Himanshu Madhani
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qla2xxx/qla_version.h 
b/drivers/scsi/qla2xxx/qla_version.h
index 549bef9afddd..0c55d7057280 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,7 +7,7 @@
 /*
  * Driver version
  */
-#define QLA2XXX_VERSION  "10.00.00.05-k"
+#define QLA2XXX_VERSION  "10.00.00.06-k"
 
 #define QLA_DRIVER_MAJOR_VER   10
 #define QLA_DRIVER_MINOR_VER   0
-- 
2.14.1



[PATCH v3 11/13] qla2xxx: Cleanup code to improve FC-NVMe error handling

2018-03-19 Thread Himanshu Madhani
From: Darren Trapp 

This patch cleans up ABTS handling for FC-NVMe by

- Removing allocation of sp, instead pass the sp pointer for abort IOCB
- Fix error handling from Trasport failure
- set outstanding_cmds array to NULL for nvme completion

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/qla2xxx/qla_isr.c  | 78 +++--
 drivers/scsi/qla2xxx/qla_nvme.c |  2 +-
 2 files changed, 29 insertions(+), 51 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index bc2c7ded6949..5fbb8f4b4dc7 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1837,31 +1837,23 @@ qla24xx_tm_iocb_entry(scsi_qla_host_t *vha, struct 
req_que *req, void *tsk)
sp->done(sp, 0);
 }
 
-static void
-qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, void *tsk)
+static void qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
+void *tsk, srb_t *sp)
 {
-   const char func[] = "NVME-IOCB";
fc_port_t *fcport;
-   srb_t *sp;
struct srb_iocb *iocb;
struct sts_entry_24xx *sts = (struct sts_entry_24xx *)tsk;
uint16_tstate_flags;
struct nvmefc_fcp_req *fd;
uint16_tret = 0;
-   struct srb_iocb *nvme;
-
-   sp = qla2x00_get_sp_from_handle(vha, func, req, tsk);
-   if (!sp)
-   return;
 
iocb = &sp->u.iocb_cmd;
fcport = sp->fcport;
iocb->u.nvme.comp_status = le16_to_cpu(sts->comp_status);
state_flags  = le16_to_cpu(sts->state_flags);
fd = iocb->u.nvme.desc;
-   nvme = &sp->u.iocb_cmd;
 
-   if (unlikely(nvme->u.nvme.aen_op))
+   if (unlikely(iocb->u.nvme.aen_op))
atomic_dec(&sp->vha->hw->nvme_active_aen_cnt);
 
/*
@@ -1895,45 +1887,30 @@ 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);
+   switch (le16_to_cpu(sts->comp_status)) {
+   case CS_COMPLETE:
+   ret = QLA_SUCCESS;
+   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 = 0;
+   iocb->u.nvme.rsp_pyld_len = 0;
+   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;
-   } else  {
-   switch (le16_to_cpu(sts->comp_status)) {
-   case CS_COMPLETE:
-   ret = QLA_SUCCESS;
-   break;
-
-   case CS_RESET:
-   case CS_PORT_UNAVAILABLE:
-   fcport->nvme_flag |= NVME_FLAG_RESETTING;
-   /* fall through */
-   case CS_ABORTED:
-   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 = 0;
-   iocb->u.nvme.rsp_pyld_len = 0;
-   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;

[PATCH v3 07/13] qla2xxx: Return busy if rport going away

2018-03-19 Thread Himanshu Madhani
From: Darren Trapp 

This patch adds mechanism to return EBUSY if rport is going away
to prevent exhausting FC-NVMe layer's retry counter.

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/qla2xxx/qla_def.h  |  1 +
 drivers/scsi/qla2xxx/qla_isr.c  |  4 +++-
 drivers/scsi/qla2xxx/qla_nvme.c | 31 ---
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index cba749d27154..59c449b141cd 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2356,6 +2356,7 @@ typedef struct fc_port {
uint8_t nvme_flag;
 #define NVME_FLAG_REGISTERED 4
 #define NVME_FLAG_DELETING 2
+#define NVME_FLAG_RESETTING 1
 
struct fc_port *conflict;
unsigned char logout_completed;
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 913cd6cf5907..bc2c7ded6949 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1910,9 +1910,11 @@ qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct 
req_que *req, void *tsk)
ret = QLA_SUCCESS;
break;
 
-   case CS_ABORTED:
case CS_RESET:
case CS_PORT_UNAVAILABLE:
+   fcport->nvme_flag |= NVME_FLAG_RESETTING;
+   /* fall through */
+   case CS_ABORTED:
case CS_PORT_LOGGED_OUT:
case CS_PORT_BUSY:
ql_log(ql_log_warn, fcport->vha, 0x5060,
diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index 951fbbab961f..adeda6a4e4fd 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -36,6 +36,7 @@ int qla_nvme_register_remote(struct scsi_qla_host *vha, 
struct fc_port *fcport)
return 0;
 
INIT_WORK(&fcport->nvme_del_work, qla_nvme_unregister_remote_port);
+   fcport->nvme_flag &= ~NVME_FLAG_RESETTING;
 
memset(&req, 0, sizeof(struct nvme_fc_port_info));
req.port_name = wwn_to_u64(fcport->port_name);
@@ -193,9 +194,9 @@ static void qla_nvme_abort_work(struct work_struct *work)
rval = ha->isp_ops->abort_command(sp);
 
ql_dbg(ql_dbg_io, fcport->vha, 0x212b,
-   "%s: %s command for sp=%p on fcport=%p rval=%x\n", __func__,
-   (rval != QLA_SUCCESS) ? "Failed to abort" : "Aborted",
-   sp, fcport, rval);
+   "%s: %s command for sp=%p, handle=%x on fcport=%p rval=%x\n",
+   __func__, (rval != QLA_SUCCESS) ? "Failed to abort" : "Aborted",
+   sp, sp->handle, fcport, rval);
 }
 
 static void qla_nvme_ls_abort(struct nvme_fc_local_port *lport,
@@ -327,7 +328,7 @@ static int qla2x00_start_nvme_mq(srb_t *sp)
}
 
if (index == req->num_outstanding_cmds) {
-   rval = -1;
+   rval = -EBUSY;
goto queuing_error;
}
req_cnt = qla24xx_calc_iocbs(vha, tot_dsds);
@@ -341,7 +342,7 @@ static int qla2x00_start_nvme_mq(srb_t *sp)
req->cnt = req->length - (req->ring_index - cnt);
 
if (req->cnt < (req_cnt + 2)){
-   rval = -1;
+   rval = -EBUSY;
goto queuing_error;
}
}
@@ -476,14 +477,15 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port 
*lport,
fc_port_t *fcport;
struct srb_iocb *nvme;
struct scsi_qla_host *vha;
-   int rval = QLA_FUNCTION_FAILED;
+   int rval = -ENODEV;
srb_t *sp;
struct qla_qpair *qpair = hw_queue_handle;
struct nvme_private *priv;
struct qla_nvme_rport *qla_rport = rport->private;
 
-   if (!fd) {
-   ql_log(ql_log_warn, NULL, 0x2134, "NO NVMe FCP request\n");
+   if (!fd || !qpair) {
+   ql_log(ql_log_warn, NULL, 0x2134,
+   "NO NVMe request or Queue Handle\n");
return rval;
}
 
@@ -495,13 +497,21 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port 
*lport,
}
 
vha = fcport->vha;
-   if (!qpair)
+
+   /*
+* If we know the dev is going away while the transport is still sending
+* IO's return busy back to stall the IO Q.  This happens when the
+* link goes away and fw hasn't notified us yet, but IO's are being
+* returned. If the dev comes back quickly we won't exhaust the IO
+* retry count at the core.
+*/
+   if (fcport->nvme_flag & NVME_FLAG_RESETTING)
return -EBUSY;
 
/* Alloc SRB structure */
sp = qla2xxx_get_qpair_sp(qpair, fcport, GFP_ATOMIC);
if (!sp)
-   return -EIO;
+   return -EBUSY;
 
  

[PATCH v3 10/13] qla2xxx: Fix FC-NVMe IO abort during driver reset

2018-03-19 Thread Himanshu Madhani
From: Darren Trapp 

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/qla2xxx/qla_nvme.c | 17 -
 drivers/scsi/qla2xxx/qla_nvme.h |  2 +-
 drivers/scsi/qla2xxx/qla_os.c   |  2 +-
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index 8c05df30c083..57275bc9fe14 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -489,6 +489,9 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port 
*lport,
 
vha = fcport->vha;
 
+   if (test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))
+   return rval;
+
/*
 * If we know the dev is going away while the transport is still sending
 * IO's return busy back to stall the IO Q.  This happens when the
@@ -597,14 +600,18 @@ static int qla_nvme_wait_on_command(srb_t *sp)
return ret;
 }
 
-void qla_nvme_abort(struct qla_hw_data *ha, struct srb *sp)
+void qla_nvme_abort(struct qla_hw_data *ha, struct srb *sp, int res)
 {
int rval;
 
-   rval = ha->isp_ops->abort_command(sp);
-   if (!rval && !qla_nvme_wait_on_command(sp))
-   ql_log(ql_log_warn, NULL, 0x2112,
-   "nvme_wait_on_comand timed out waiting on sp=%p\n", sp);
+   if (!test_bit(ABORT_ISP_ACTIVE, &sp->vha->dpc_flags)) {
+   rval = ha->isp_ops->abort_command(sp);
+   if (!rval && !qla_nvme_wait_on_command(sp))
+   ql_log(ql_log_warn, NULL, 0x2112,
+   "timed out waiting on sp=%p\n", sp);
+   } else {
+   sp->done(sp, res);
+   }
 }
 
 static void qla_nvme_unregister_remote_port(struct work_struct *work)
diff --git a/drivers/scsi/qla2xxx/qla_nvme.h b/drivers/scsi/qla2xxx/qla_nvme.h
index 8df379478269..816854ada654 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.h
+++ b/drivers/scsi/qla2xxx/qla_nvme.h
@@ -145,7 +145,7 @@ struct pt_ls4_rx_unsol {
 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 qla_nvme_abort(struct qla_hw_data *, struct srb *sp, int res);
 void qla24xx_nvme_ls4_iocb(struct scsi_qla_host *, struct pt_ls4_request *,
 struct req_que *);
 void qla24xx_async_gffid_sp_done(void *, int);
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index bd37a243c0bd..54f93f9cba48 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -1734,7 +1734,7 @@ __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res)
sp_get(sp);
spin_unlock_irqrestore(qp->qp_lock_ptr,
flags);
-   qla_nvme_abort(ha, sp);
+   qla_nvme_abort(ha, sp, res);
spin_lock_irqsave(qp->qp_lock_ptr,
flags);
} else if (GET_CMD_SP(sp) &&
-- 
2.14.1



[PATCH v3 12/13] qla2xxx: Fix Async GPN_FT for FCP and FC-NVMe scan

2018-03-19 Thread Himanshu Madhani
From: Quinn Tran 

This patch combines FCP and FC-NVMe scan into single scan when
driver detects FC-NVMe capability on same port.

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h  |   8 ++
 drivers/scsi/qla2xxx/qla_gbl.h  |   2 +-
 drivers/scsi/qla2xxx/qla_gs.c   | 272 ++--
 drivers/scsi/qla2xxx/qla_init.c |   8 +-
 drivers/scsi/qla2xxx/qla_os.c   |  10 +-
 5 files changed, 229 insertions(+), 71 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 6aae126add0c..54625eb2904f 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2217,6 +2217,7 @@ typedef struct {
 
 /* FCP-4 types */
 #define FC4_TYPE_FCP_SCSI  0x08
+#define FC4_TYPE_NVME  0x28
 #define FC4_TYPE_OTHER 0x0
 #define FC4_TYPE_UNKNOWN   0xff
 
@@ -2982,8 +2983,14 @@ enum scan_flags_t {
SF_QUEUED = BIT_1,
 };
 
+enum fc4type_t {
+   FS_FC4TYPE_FCP  = BIT_0,
+   FS_FC4TYPE_NVME = BIT_1,
+};
+
 struct fab_scan_rp {
port_id_t id;
+   enum fc4type_t fc4type;
u8 port_name[8];
u8 node_name[8];
 };
@@ -3275,6 +3282,7 @@ struct qla_work_evt {
} nack;
struct {
u8 fc4_type;
+   srb_t *sp;
} gpnft;
 } u;
 };
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 19f44e12926b..3c4c84ed0f0f 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -658,7 +658,7 @@ void qla24xx_handle_gpsc_event(scsi_qla_host_t *, struct 
event_arg *);
 int qla2x00_mgmt_svr_login(scsi_qla_host_t *);
 void qla24xx_handle_gffid_event(scsi_qla_host_t *vha, struct event_arg *ea);
 int qla24xx_async_gffid(scsi_qla_host_t *vha, fc_port_t *fcport);
-int qla24xx_async_gpnft(scsi_qla_host_t *, u8);
+int qla24xx_async_gpnft(scsi_qla_host_t *, u8, srb_t *);
 void qla24xx_async_gpnft_done(scsi_qla_host_t *, srb_t *);
 void qla24xx_async_gnnft_done(scsi_qla_host_t *, srb_t *);
 int qla24xx_async_gnnid(scsi_qla_host_t *, fc_port_t *);
diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index e4d404c24506..39dd62b8c649 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -3858,7 +3858,6 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t 
*sp)
fc_port_t *fcport;
u32 i, rc;
bool found;
-   u8 fc4type = sp->gen2;
struct fab_scan_rp *rp;
unsigned long flags;
 
@@ -3931,7 +3930,7 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t 
*sp)
"%s %d %8phC post new sess\n",
__func__, __LINE__, rp->port_name);
qla24xx_post_newsess_work(vha, &rp->id, rp->port_name,
-   rp->node_name, NULL, fc4type);
+   rp->node_name, NULL, rp->fc4type);
}
}
 
@@ -3971,19 +3970,112 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, 
srb_t *sp)
spin_unlock_irqrestore(&vha->work_lock, flags);
 }
 
-static void qla2x00_async_gpnft_gnnft_sp_done(void *s, int res)
+static void qla2x00_find_free_fcp_nvme_slot(struct scsi_qla_host *vha,
+   struct srb *sp)
 {
-   struct srb *sp = s;
-   struct scsi_qla_host *vha = sp->vha;
-   struct qla_work_evt *e;
+   struct qla_hw_data *ha = vha->hw;
+   int num_fibre_dev = ha->max_fibre_devices;
struct ct_sns_req *ct_req =
(struct ct_sns_req *)sp->u.iocb_cmd.u.ctarg.req;
struct ct_sns_gpnft_rsp *ct_rsp =
(struct ct_sns_gpnft_rsp *)sp->u.iocb_cmd.u.ctarg.rsp;
struct ct_sns_gpn_ft_data *d;
struct fab_scan_rp *rp;
+   u16 cmd = be16_to_cpu(ct_req->command);
+   u8 fc4_type = sp->gen2;
int i, j, k;
+   port_id_t id;
+   u8 found;
+   u64 wwn;
+
+   j = 0;
+   for (i = 0; i < num_fibre_dev; i++) {
+   d  = &ct_rsp->entries[i];
+
+   id.b.rsvd_1 = 0;
+   id.b.domain = d->port_id[0];
+   id.b.area   = d->port_id[1];
+   id.b.al_pa  = d->port_id[2];
+   wwn = wwn_to_u64(d->port_name);
+
+   if (id.b24 == 0 || wwn == 0)
+   continue;
+
+   if (fc4_type == FC4_TYPE_FCP_SCSI) {
+   if (cmd == GPN_FT_CMD) {
+   rp = &vha->scan.l[j];
+   rp->id = id;
+   memcpy(rp->port_name, d->port_name, 8);
+   j++;
+   rp->fc4type = FS_FC4TYPE_FCP;
+   } else {
+   for (k = 0; k < num_fibre_dev; k++) {
+   rp = &vha->scan.l[k];
+   if (id.b24 == rp->id.b24) {

[PATCH v3 03/13] qla2xxx: Add changes for devloss timeout in driver

2018-03-19 Thread Himanshu Madhani
From: Darren Trapp 

Add support for error recovery within devloss timeout, now that
FC-NVMe transport support devloss timeout.

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/qla2xxx/qla_def.h|   1 +
 drivers/scsi/qla2xxx/qla_init.c   |   8 +++
 drivers/scsi/qla2xxx/qla_isr.c|   5 +-
 drivers/scsi/qla2xxx/qla_nvme.c   | 142 +-
 drivers/scsi/qla2xxx/qla_nvme.h   |   6 +-
 drivers/scsi/qla2xxx/qla_target.c |  13 ++--
 drivers/scsi/qla2xxx/qla_target.h |   2 +-
 7 files changed, 87 insertions(+), 90 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index be7d6824581a..56f78dce4d3c 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2355,6 +2355,7 @@ typedef struct fc_port {
 #define NVME_PRLI_SP_DISCOVERY  BIT_3
uint8_t nvme_flag;
 #define NVME_FLAG_REGISTERED 4
+#define NVME_FLAG_DELETING 2
 
struct fc_port *conflict;
unsigned char logout_completed;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 1878a6f24ddb..7f8bfa0454d2 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -5517,6 +5517,14 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha)
break;
}
 
+   if (fcport->fc4f_nvme) {
+   if (fcport->disc_state == DSC_DELETE_PEND) {
+   fcport->disc_state = DSC_GNL;
+   vha->fcport_count--;
+   fcport->login_succ = 0;
+   }
+   }
+
if (found) {
spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags);
continue;
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 16c43bd9bb83..93f2f1df7168 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1910,7 +1910,7 @@ qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct 
req_que *req, void *tsk)
} else  {
switch (le16_to_cpu(sts->comp_status)) {
case CS_COMPLETE:
-   ret = 0;
+   ret = QLA_SUCCESS;
break;
 
case CS_ABORTED:
@@ -1922,7 +1922,8 @@ qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct 
req_que *req, void *tsk)
"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;
+   fd->transferred_length = 0;
+   iocb->u.nvme.rsp_pyld_len = 0;
ret = QLA_ABORTED;
break;
 
diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index 162a523b985e..a8e81fc14c44 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -16,15 +16,13 @@ static void qla_nvme_unregister_remote_port(struct 
work_struct *);
 
 int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport)
 {
-   struct nvme_rport *rport;
+   struct qla_nvme_rport *rport;
+   struct nvme_fc_port_info req;
int ret;
 
if (!IS_ENABLED(CONFIG_NVME_FC))
return 0;
 
-   if (fcport->nvme_flag & NVME_FLAG_REGISTERED)
-   return 0;
-
if (!vha->flags.nvme_enabled) {
ql_log(ql_log_info, vha, 0x2100,
"%s: Not registering target since Host NVME is not 
enabled\n",
@@ -33,38 +31,35 @@ int qla_nvme_register_remote(struct scsi_qla_host *vha, 
struct fc_port *fcport)
}
 
if (!(fcport->nvme_prli_service_param &
-   (NVME_PRLI_SP_TARGET | NVME_PRLI_SP_DISCOVERY)))
+   (NVME_PRLI_SP_TARGET | NVME_PRLI_SP_DISCOVERY)) ||
+   (fcport->nvme_flag & NVME_FLAG_REGISTERED))
return 0;
 
INIT_WORK(&fcport->nvme_del_work, qla_nvme_unregister_remote_port);
-   rport = kzalloc(sizeof(*rport), GFP_KERNEL);
-   if (!rport) {
-   ql_log(ql_log_warn, vha, 0x2101,
-   "%s: unable to alloc memory\n", __func__);
-   return -ENOMEM;
-   }
 
-   rport->req.port_name = wwn_to_u64(fcport->port_name);
-   rport->req.node_name = wwn_to_u64(fcport->node_name);
-   rport->req.port_role = 0;
+   memset(&req, 0, sizeof(struct nvme_fc_port_info));
+   req.port_name = wwn_to_u64(fcport->port_name);
+   req.node_name = wwn_to_u64(fcport->node_name);
+   req.port_role = 0;
+   req.dev_loss_tmo = NVME_FC_D

[PATCH v3 00/13] qla2xxx: Fixes for FC-NVMe

2018-03-19 Thread Himanshu Madhani
Hi Martin,

This patch series addresses issue with FC-NVMe abort handling in the
driver. Code has been cleaned up and devloss timeout support has been
added in qla2xxx.

Please apply this series to 4.17/scsi-queue at your earliest convenience.

Hi Christoph, Sagi, Johannes, James,

Please review this series. I would however like this to be merged via
Martin's SCSI tree.

Changes from v2 -> v3
- Added reviewed-by tags for Johannes.
- Rebased on 4.17/scsi-queue.

Note: Patch 12 did not apply cleanly becuase it depends on commit
 2b5b96473efce ("scsi: qla2xxx: Fix FC-NVMe LUN discovery"), present in
 4.16/scsi-fixes.

Changes from v1 -> v2
- Added reviewed-by tags for Hannes.
- Fixes build warning reported by kbuild robot.

Thanks,
Himanshu


Darren Trapp (10):
  qla2xxx: Set IIDMA and fcport state before qla_nvme_register_remote()
  qla2xxx: Add changes for devloss timeout in driver
  qla2xxx: Restore ZIO threshold setting
  qla2xxx: Add FC-NVMe abort processing
  qla2xxx: Fix n2n_ae flag to prevent dev_loss on PDB change
  qla2xxx: Return busy if rport going away
  qla2xxx: Remove nvme_done_list
  qla2xxx: Fix retry for PRLI RJT with reason of BUSY
  qla2xxx: Fix FC-NVMe IO abort during driver reset
  qla2xxx: Cleanup code to improve FC-NVMe error handling

Himanshu Madhani (2):
  qla2xxx: Remove unneeded message and minor cleanup for FC-NVMe
  qla2xxx: Update driver version to 10.00.00.06-k

Quinn Tran (1):
  qla2xxx: Fix Async GPN_FT for FCP and FC-NVMe scan

 drivers/scsi/qla2xxx/qla_dbg.c |   2 +-
 drivers/scsi/qla2xxx/qla_def.h |  13 +-
 drivers/scsi/qla2xxx/qla_gbl.h |   4 +-
 drivers/scsi/qla2xxx/qla_gs.c  | 272 -
 drivers/scsi/qla2xxx/qla_init.c|  35 +++--
 drivers/scsi/qla2xxx/qla_isr.c |  78 ---
 drivers/scsi/qla2xxx/qla_mbx.c |  10 +-
 drivers/scsi/qla2xxx/qla_mid.c |   6 -
 drivers/scsi/qla2xxx/qla_nvme.c| 245 +++--
 drivers/scsi/qla2xxx/qla_nvme.h|   9 +-
 drivers/scsi/qla2xxx/qla_os.c  |  13 +-
 drivers/scsi/qla2xxx/qla_target.c  |  13 +-
 drivers/scsi/qla2xxx/qla_target.h  |   2 +-
 drivers/scsi/qla2xxx/qla_version.h |   2 +-
 14 files changed, 420 insertions(+), 284 deletions(-)

-- 
2.14.1



[PATCH v3 09/13] qla2xxx: Fix retry for PRLI RJT with reason of BUSY

2018-03-19 Thread Himanshu Madhani
From: Darren Trapp 

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/qla2xxx/qla_dbg.c  |  2 +-
 drivers/scsi/qla2xxx/qla_init.c | 13 -
 drivers/scsi/qla2xxx/qla_mbx.c  |  7 +--
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index 7e9d8f08b9d5..1abc8a9064b3 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -60,7 +60,7 @@
  * |  || 0xb13c-0xb140  |
  * |  || 0xb149
|
  * | MultiQ   |   0xc010   |   |
- * | Misc |   0xd302   | 0xd031-0xd0ff |
+ * | Misc |   0xd303   | 0xd031-0xd0ff |
  * |  || 0xd101-0xd1fe |
  * |  || 0xd214-0xd2fe |
  * | Target Mode |   0xe081   ||
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 33823d74c782..15a96dc205d0 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -880,7 +880,6 @@ qla24xx_async_prli(struct scsi_qla_host *vha, fc_port_t 
*fcport)
return rval;
 
if (fcport->fw_login_state == DSC_LS_PLOGI_PEND ||
-   fcport->fw_login_state == DSC_LS_PLOGI_COMP ||
fcport->fw_login_state == DSC_LS_PRLI_PEND)
return rval;
 
@@ -1238,6 +1237,11 @@ int qla24xx_fcport_handle_login(struct scsi_qla_host 
*vha, fc_port_t *fcport)
qla2x00_post_async_adisc_work(vha, fcport, data);
break;
 
+   case DSC_LOGIN_PEND:
+   if (fcport->fw_login_state == DSC_LS_PLOGI_COMP)
+   qla24xx_post_prli_work(vha, fcport);
+   break;
+
default:
break;
}
@@ -1640,6 +1644,13 @@ qla24xx_handle_prli_done_event(struct scsi_qla_host 
*vha, struct event_arg *ea)
qla24xx_post_gpdb_work(vha, ea->fcport, 0);
break;
default:
+   if ((ea->iop[0] == LSC_SCODE_ELS_REJECT) &&
+   (ea->iop[1] == 0x5)) {   /* reson 5=busy expl:0x0 */
+   set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
+   ea->fcport->fw_login_state = DSC_LS_PLOGI_COMP;
+   break;
+   }
+
if (ea->fcport->n2n_flag) {
ql_dbg(ql_dbg_disc, vha, 0x2118,
"%s %d %8phC post fc4 prli\n",
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 735079ba691c..c9a134ae0d2b 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -1025,9 +1025,12 @@ qla2x00_get_fw_version(scsi_qla_host_t *vha)
 * FW supports nvme and driver load parameter requested nvme.
 * BIT 26 of fw_attributes indicates NVMe support.
 */
-   if ((ha->fw_attributes_h & 0x400) && ql2xnvmeenable)
+   if ((ha->fw_attributes_h & 0x400) && ql2xnvmeenable) {
vha->flags.nvme_enabled = 1;
-
+   ql_log(ql_log_info, vha, 0xd302,
+   "%s: FC-NVMe is Enabled (0x%x)\n",
+__func__, ha->fw_attributes_h);
+   }
}
 
if (IS_QLA27XX(ha)) {
-- 
2.14.1



[PATCH v3 05/13] qla2xxx: Add FC-NVMe abort processing

2018-03-19 Thread Himanshu Madhani
From: Darren Trapp 

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/qla2xxx/qla_nvme.c | 36 ++--
 drivers/scsi/qla2xxx/qla_nvme.h |  1 +
 2 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index 5ee447680ddd..951fbbab961f 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -181,24 +181,32 @@ static void qla_nvme_sp_done(void *ptr, int res)
return;
 }
 
-static void qla_nvme_ls_abort(struct nvme_fc_local_port *lport,
-struct nvme_fc_remote_port *rport, struct nvmefc_ls_req *fd)
+static void qla_nvme_abort_work(struct work_struct *work)
 {
-   struct nvme_private *priv = fd->private;
-   struct qla_nvme_rport *qla_rport = rport->private;
-   fc_port_t *fcport = qla_rport->fcport;
+   struct nvme_private *priv =
+   container_of(work, struct nvme_private, abort_work);
srb_t *sp = priv->sp;
-   int rval;
+   fc_port_t *fcport = sp->fcport;
struct qla_hw_data *ha = fcport->vha->hw;
+   int rval;
 
rval = ha->isp_ops->abort_command(sp);
 
ql_dbg(ql_dbg_io, fcport->vha, 0x212b,
-   "%s: %s LS command for sp=%p on fcport=%p rval=%x\n", __func__,
+   "%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_ls_abort(struct nvme_fc_local_port *lport,
+struct nvme_fc_remote_port *rport, struct nvmefc_ls_req *fd)
+{
+   struct nvme_private *priv = fd->private;
+
+   INIT_WORK(&priv->abort_work, qla_nvme_abort_work);
+   schedule_work(&priv->abort_work);
+}
+
 static void qla_nvme_ls_complete(struct work_struct *work)
 {
struct nvme_private *priv =
@@ -264,18 +272,9 @@ static void qla_nvme_fcp_abort(struct nvme_fc_local_port 
*lport,
 struct nvmefc_fcp_req *fd)
 {
struct nvme_private *priv = fd->private;
-   srb_t *sp = priv->sp;
-   int rval;
-   struct qla_nvme_rport *qla_rport = rport->private;
-   fc_port_t *fcport = qla_rport->fcport;
-   struct qla_hw_data *ha = fcport->vha->hw;
-
-   rval = ha->isp_ops->abort_command(sp);
 
-   ql_dbg(ql_dbg_io, fcport->vha, 0x2127,
-   "%s: %s command for sp=%p on fcport=%p rval=%x\n", __func__,
-   (rval != QLA_SUCCESS) ? "Failed to abort" : "Aborted",
-   sp, fcport, rval);
+   INIT_WORK(&priv->abort_work, qla_nvme_abort_work);
+   schedule_work(&priv->abort_work);
 }
 
 static void qla_nvme_poll(struct nvme_fc_local_port *lport, void 
*hw_queue_handle)
@@ -650,6 +649,7 @@ void qla_nvme_delete(struct scsi_qla_host *vha)
ql_log(ql_log_info, fcport->vha, 0x2114, "%s: fcport=%p\n",
__func__, fcport);
 
+   nvme_fc_set_remoteport_devloss(fcport->nvme_remote_port, 0);
init_completion(&fcport->nvme_del_done);
nvme_fc_unregister_remoteport(fcport->nvme_remote_port);
wait_for_completion(&fcport->nvme_del_done);
diff --git a/drivers/scsi/qla2xxx/qla_nvme.h b/drivers/scsi/qla2xxx/qla_nvme.h
index 7becfc1b3e69..8df379478269 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.h
+++ b/drivers/scsi/qla2xxx/qla_nvme.h
@@ -31,6 +31,7 @@ struct nvme_private {
struct srb  *sp;
struct nvmefc_ls_req *fd;
struct work_struct ls_work;
+   struct work_struct abort_work;
int comp_status;
 };
 
-- 
2.14.1



[PATCH v3 08/13] qla2xxx: Remove nvme_done_list

2018-03-19 Thread Himanshu Madhani
From: Darren Trapp 

Signed-off-by: Darren Trapp 
Signed-off-by: Himanshu Madhani 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/qla2xxx/qla_def.h  |  1 -
 drivers/scsi/qla2xxx/qla_gbl.h  |  2 --
 drivers/scsi/qla2xxx/qla_init.c |  1 -
 drivers/scsi/qla2xxx/qla_mid.c  |  6 --
 drivers/scsi/qla2xxx/qla_nvme.c | 13 ++---
 drivers/scsi/qla2xxx/qla_os.c   |  1 -
 6 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 59c449b141cd..6aae126add0c 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -3464,7 +3464,6 @@ struct qla_qpair {
struct work_struct q_work;
struct list_head qp_list_elem; /* vha->qp_list */
struct list_head hints_list;
-   struct list_head nvme_done_list;
uint16_t cpuid;
struct qla_tgt_counters tgt_counters;
 };
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index e9295398050c..19f44e12926b 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -896,6 +896,4 @@ void qlt_update_host_map(struct scsi_qla_host *, port_id_t);
 void qlt_remove_target_resources(struct qla_hw_data *);
 void qlt_clr_qp_table(struct scsi_qla_host *vha);
 
-void qla_nvme_cmpl_io(struct srb_iocb *);
-
 #endif /* _QLA_GBL_H */
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 7f8bfa0454d2..33823d74c782 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -8405,7 +8405,6 @@ struct qla_qpair *qla2xxx_create_qpair(struct 
scsi_qla_host *vha, int qos,
qpair->vp_idx = vp_idx;
qpair->fw_started = ha->flags.fw_started;
INIT_LIST_HEAD(&qpair->hints_list);
-   INIT_LIST_HEAD(&qpair->nvme_done_list);
qpair->chip_reset = ha->base_qpair->chip_reset;
qpair->enable_class_2 = ha->base_qpair->enable_class_2;
qpair->enable_explicit_conf =
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index e965b16f21e3..da85cd89639f 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -778,18 +778,12 @@ static void qla_do_work(struct work_struct *work)
struct qla_qpair *qpair = container_of(work, struct qla_qpair, q_work);
struct scsi_qla_host *vha;
struct qla_hw_data *ha = qpair->hw;
-   struct srb_iocb *nvme, *nxt_nvme;
 
spin_lock_irqsave(&qpair->qp_lock, flags);
vha = pci_get_drvdata(ha->pdev);
qla24xx_process_response_queue(vha, qpair->rsp);
spin_unlock_irqrestore(&qpair->qp_lock, flags);
 
-   list_for_each_entry_safe(nvme, nxt_nvme, &qpair->nvme_done_list,
-   u.nvme.entry) {
-   list_del_init(&nvme->u.nvme.entry);
-   qla_nvme_cmpl_io(nvme);
-   }
 }
 
 /* create response queue */
diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
index adeda6a4e4fd..8c05df30c083 100644
--- a/drivers/scsi/qla2xxx/qla_nvme.c
+++ b/drivers/scsi/qla2xxx/qla_nvme.c
@@ -149,16 +149,6 @@ static void qla_nvme_sp_ls_done(void *ptr, int res)
qla2x00_rel_sp(sp);
 }
 
-void qla_nvme_cmpl_io(struct srb_iocb *nvme)
-{
-   srb_t *sp;
-   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 +167,8 @@ static void qla_nvme_sp_done(void *ptr, int res)
fd->status = NVME_SC_INTERNAL;
 
fd->rcv_rsplen = nvme->u.nvme.rsp_pyld_len;
-   list_add_tail(&nvme->u.nvme.entry, &sp->qpair->nvme_done_list);
+   fd->done(fd);
+   qla2xxx_rel_qpair_sp(sp->qpair, sp);
 
return;
 }
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 12ee6e02d146..bd37a243c0bd 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -397,7 +397,6 @@ static void qla_init_base_qpair(struct scsi_qla_host *vha, 
struct req_que *req,
ha->base_qpair->use_shadow_reg = IS_SHADOW_REG_CAPABLE(ha) ? 1 : 0;
ha->base_qpair->msix = &ha->msix_entries[QLA_MSIX_RSP_Q];
INIT_LIST_HEAD(&ha->base_qpair->hints_list);
-   INIT_LIST_HEAD(&ha->base_qpair->nvme_done_list);
ha->base_qpair->enable_class_2 = ql2xenableclass2;
/* init qpair to this cpu. Will adjust at run time. */
qla_cpu_update(rsp->qpair, raw_smp_processor_id());
-- 
2.14.1



Re: [PATCH 2/3] qla2xxx: fx00 copypaste typo

2018-03-19 Thread Madhani, Himanshu

> On Mar 8, 2018, at 5:44 AM, Meelis Roos  wrote:
> 
> Fix an obvious copy-paste error in freeing QLAFX00 response queue - the code
> checked for rsp->ring but freed rsp->ring_fx00.
> 
> Signed-off-by: Meelis Roos 
> 
> ---
> drivers/scsi/qla2xxx/qla_os.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
> index afcb5567..3c7bc2d 100644
> --- a/drivers/scsi/qla2xxx/qla_os.c
> +++ b/drivers/scsi/qla2xxx/qla_os.c
> @@ -490,7 +490,7 @@ static void qla2x00_free_req_que(struct qla_hw_data *ha, 
> struct req_que *req)
> static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp)
> {
>   if (IS_QLAFX00(ha)) {
> - if (rsp && rsp->ring)
> + if (rsp && rsp->ring_fx00)
>   dma_free_coherent(&ha->pdev->dev,
>   (rsp->length_fx00 + 1) * sizeof(request_t),
>   rsp->ring_fx00, rsp->dma_fx00);
> -- 
> 2.1.4
> 

Looks good

Acked-by: Himanshu Madhani 

Thanks,
- Himanshu



Re: [PATCH 1/3] qla2xxx: fix error message on

2018-03-19 Thread Madhani, Himanshu

> On Mar 8, 2018, at 5:44 AM, Meelis Roos  wrote:
> 
> This patch fixes IO traps caught by hardware when mailbox command fails on
> qla2200. The error handler assumes newer firmware that is available on 2400 
> and
> newer HBA-s.
> 
> This causes ugly crashes on sparc64.
> 
> Fix it with separate debug prints on different firmware generations like most
> other places do.
> 
> Note: the debug line identifier is the same 0x1198 for both cases. Maybe it
> needs to be renumbered in the new case?
> 
> Signed-off-by: Meelis Roos 
> 
> ---
> drivers/scsi/qla2xxx/qla_mbx.c | 18 +-
> 1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
> index 7397aed..3a81555 100644
> --- a/drivers/scsi/qla2xxx/qla_mbx.c
> +++ b/drivers/scsi/qla2xxx/qla_mbx.c
> @@ -503,11 +503,19 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t 
> *mcp)
>   }
>   pr_warn(" cmd=%x \n", command);
>   }
> - ql_dbg(ql_dbg_mbx, vha, 0x1198,
> - "host_status=%#x intr_ctrl=%#x intr_status=%#x\n",
> - RD_REG_DWORD(®->isp24.host_status),
> - RD_REG_DWORD(®->isp24.ictrl),
> - RD_REG_DWORD(®->isp24.istatus));
> + if (IS_FWI2_CAPABLE(ha) && !(IS_P3P_TYPE(ha))) {
> + ql_dbg(ql_dbg_mbx, vha, 0x1198,
> + "host_status=%#x intr_ctrl=%#x intr_status=%#x\n",
> + RD_REG_DWORD(®->isp24.host_status),
> + RD_REG_DWORD(®->isp24.ictrl),
> + RD_REG_DWORD(®->isp24.istatus));
> + } else {
> + ql_dbg(ql_dbg_mbx, vha, 0x1198,

use 0x1206 here for numbering. 

> + "ctrl_status=%#x ictrl=%#x istatus=%#x\n",
> + RD_REG_WORD(®->isp.ctrl_status),
> + RD_REG_WORD(®->isp.ictrl),
> + RD_REG_WORD(®->isp.istatus));
> + }
>   } else {
>   ql_dbg(ql_dbg_mbx, base_vha, 0x1021, "Done %s.\n", __func__);
>   }
> -- 
> 2.1.4
> 

Also, you need to update qla_dbg.c with this number

Here’s diff will look like 

diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index 1abc8a9064b3..5fd44c50bbac 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -14,7 +14,7 @@
  * | Module Init and Probe|   0x0193   | 0x0146 |
  * |  || 0x015b-0x0160 |
  * |  || 0x016e
|
- * | Mailbox commands |   0x1205   | 0x11a2-0x11ff |
+ * | Mailbox commands |   0x1206   | 0x11a2-0x11ff |
  * | Device Discovery |   0x2134   | 0x210e-0x2116  |
  * | || 0x211a |
  * |  || 0x211c-0x2128  |


With these changes, you can add 

Acked-by: Himanshu Madhani 

Thanks,
- Himanshu



Re: [PATCH 1/3] qla2xxx: fix error message on

2018-03-19 Thread Martin K. Petersen

Meelis,

> This patch fixes IO traps caught by hardware when mailbox command fails on
> qla2200. The error handler assumes newer firmware that is available on 2400 
> and
> newer HBA-s.
>
> This causes ugly crashes on sparc64.
>
> Fix it with separate debug prints on different firmware generations like most
> other places do.
>
> Note: the debug line identifier is the same 0x1198 for both cases. Maybe it
> needs to be renumbered in the new case?

QLogic folks: Please review the following patches.

https://patchwork.kernel.org/patch/10268119/
https://patchwork.kernel.org/patch/10268121/

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH resend] scsi: devinfo: add HP DISK-SUBSYSTEM device, for HP XP arrays

2018-03-19 Thread Martin K. Petersen

Xose,

> "The DISK-SUBSYSTEM is a special model name returned when LUs
> are not installed. For example, when LU#0 is not installed in "OPEN-"
> models, LU#0 is detected as the DISK-SUBSYSTEM model":
> https://marc.info/?l=linux-scsi&m=125424006417825

Applied to 4.17/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: devinfo: remove DF arrays from HP

2018-03-19 Thread Martin K. Petersen

Xose,

> Matthias did confirm that there are no such devices.

Applied to 4.17/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH RFC] scsi: devinfo: remove dasd devices from the scsi subsystem

2018-03-19 Thread Martin K. Petersen

Xose,

> Only present through ccw bus.

Applied to 4.17/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH v2 17/21] scsi: hisi_sas: Remove depends on HAS_DMA in case of platform dependency

2018-03-19 Thread Martin K. Petersen

Geert,

> Remove dependencies on HAS_DMA where a Kconfig symbol depends on another
> symbol that implies HAS_DMA, and, optionally, on "|| COMPILE_TEST".
> In most cases this other symbol is an architecture or platform specific
> symbol, or PCI.
>
> Generic symbols and drivers without platform dependencies keep their
> dependencies on HAS_DMA, to prevent compiling subsystems or drivers that
> cannot work anyway.
>
> This simplifies the dependencies, and allows to improve compile-testing.

Applied to 4.17/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: iscsi_tcp: set BDI_CAP_STABLE_WRITES when data digest enabled

2018-03-19 Thread Martin K. Petersen

Jianchao,

> iscsi tcp will first send out data, then calculate and send data
> digest. If we don't have BDI_CAP_STABLE_WRITES, the page cache will
> be written in spite of the on going writeback. Consequently, wrong
> digest will be got and sent to target.
>
> To fix this, set BDI_CAP_STABLE_WRITES when data digest is enabled
> in iscsi_tcp .slave_configure callback.

Applied to 4.16/scsi-fixes. Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH v2 00/13] qla2xxx: Fixes for FC-NVMe

2018-03-19 Thread Martin K. Petersen

Himanshu,

> Please apply this series to 4.17/scsi-queue at your earliest
> convenience.

Patch 12 does not apply to 4.17/scsi-queue. Please fix and resubmit.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH V5 1/5] scsi: hpsa: fix selection of reply queue

2018-03-19 Thread Martin K. Petersen

Artem,

> we have this patch-set and it fixes megaraid regression in v4.16. Do
> you plan to mege it to v4.16-rcX? I am worried - there seem to be no
> sight that this is going to me merged. They are not in the linux-next.

I merged them into scsi-fixes last week.

It happens push a combined fixes+queue to linux-next to get more zeroday
coverage. However, most of the time linux-next is one 4.x+1 material
only.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: qla2xxx: fix spelling mistake: "existant" -> "existent"

2018-03-19 Thread Martin K. Petersen

Colin,

> Trivial fix to spelling mistake in debug message text

Applied to 4.17/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 1/2] scsi: dpt_i2o: use after free in adpt_release()

2018-03-19 Thread Martin K. Petersen

Dan,

> The scsi_host_put() function frees "pHba" and then we dereference it on
> the next line when we do "scsi_host_put(pHba->host);".

Applied to 4.17/scsi-queue, thank you.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: remove obsolete drivers and scsi_module.c V2

2018-03-19 Thread Martin K. Petersen

Christoph,

> this series removes the obsolete scsi_module.c infratructure that has
> been obsolete for 15 years, and the remaining drivers that depend on
> them.

Applied to 4.17/scsi-queue. Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 2/2] scsi: dpt_i2o: use after free in __adpt_reset()

2018-03-19 Thread Martin K. Petersen

Dan,

> In __adpt_reset() the problem is that adpt_hba_reset() frees "pHba" on
> error but we dereference it to print the name in the error message.

Applied to 4.17/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: unexport scsi_host_set_state

2018-03-19 Thread Martin K. Petersen

Christoph,

> This function is only used inside the SCSI midlayer, so remove the
> export for it.

Applied to 4.17/scsi-queue. Thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering


[PATCH v4 3/7] scsi: dpt_i2o: eliminate duplicate barriers on weakly-ordered archs

2018-03-19 Thread Sinan Kaya
Code includes barrier() followed by writel(). writel() already has a
barrier
on some architectures like arm64.

This ends up CPU observing two barriers back to back before executing the
register write.

Since code already has an explicit barrier call, changing writel() to
writel_relaxed().

Signed-off-by: Sinan Kaya 
---
 drivers/scsi/dpt_i2o.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index fd172b0..3c1e64a 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -1300,7 +1300,7 @@ static s32 adpt_i2o_post_this(adpt_hba* pHba, u32* data, 
int len)
wmb();
 
//post message
-   writel(m, pHba->post_port);
+   writel_relaxed(m, pHba->post_port);
wmb();
 
return 0;
@@ -1390,7 +1390,7 @@ static s32 adpt_i2o_reset_hba(adpt_hba* pHba)
 
memcpy_toio(pHba->msg_addr_virt+m, msg, sizeof(msg));
wmb();
-   writel(m, pHba->post_port);
+   writel_relaxed(m, pHba->post_port);
wmb();
 
while(*status == 0){
@@ -2797,7 +2797,7 @@ static s32 adpt_send_nop(adpt_hba*pHba,u32 m)
writel( 0,&msg[2]);
wmb();
 
-   writel(m, pHba->post_port);
+   writel_relaxed(m, pHba->post_port);
wmb();
return 0;
 }
-- 
2.7.4



[PATCH v4 2/7] scsi: megaraid: eliminate duplicate barriers on weakly-ordered archs

2018-03-19 Thread Sinan Kaya
Code includes barrier() followed by writel(). writel() already has a
barrier
on some architectures like arm64.

This ends up CPU observing two barriers back to back before executing the
register write.

Create a new wrapper function with relaxed write operator. Use the new
wrapper when a write is following a barrier().

Since code already has an explicit barrier call, changing writel() to
writel_relaxed().

Signed-off-by: Sinan Kaya 
---
 drivers/scsi/megaraid/megaraid_mbox.c   | 8 
 drivers/scsi/megaraid/megaraid_mbox.h   | 2 ++
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 4 ++--
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_mbox.c 
b/drivers/scsi/megaraid/megaraid_mbox.c
index 530358c..8c4fc6e 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -1439,7 +1439,7 @@ mbox_post_cmd(adapter_t *adapter, scb_t *scb)
mbox->ack   = 0;
wmb();
 
-   WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1);
+   WRINDOOR_RELAXED(raid_dev, raid_dev->mbox_dma | 0x1);
 
spin_unlock_irqrestore(MAILBOX_LOCK(raid_dev), flags);
 
@@ -2752,7 +2752,7 @@ mbox_post_sync_cmd(adapter_t *adapter, uint8_t raw_mbox[])
mbox->status= 0xFF;
 
wmb();
-   WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1);
+   WRINDOOR_RELAXED(raid_dev, raid_dev->mbox_dma | 0x1);
 
// wait for maximum 1 second for status to post. If the status is not
// available within 1 second, assume FW is initializing and wait
@@ -2877,7 +2877,7 @@ mbox_post_sync_cmd_fast(adapter_t *adapter, uint8_t 
raw_mbox[])
mbox->status= 0xFF;
 
wmb();
-   WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1);
+   WRINDOOR_RELAXED(raid_dev, raid_dev->mbox_dma | 0x1);
 
for (i = 0; i < MBOX_SYNC_WAIT_CNT; i++) {
if (mbox->numstatus != 0xFF) break;
@@ -3329,7 +3329,7 @@ megaraid_mbox_fire_sync_cmd(adapter_t *adapter)
mbox->status= 0;
 
wmb();
-   WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1);
+   WRINDOOR_RELAXED(raid_dev, raid_dev->mbox_dma | 0x1);
 
/* Wait for maximum 1 min for status to post.
 * If the Firmware SUPPORTS the ABOVE COMMAND,
diff --git a/drivers/scsi/megaraid/megaraid_mbox.h 
b/drivers/scsi/megaraid/megaraid_mbox.h
index c1d86d9..641cbd4 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.h
+++ b/drivers/scsi/megaraid/megaraid_mbox.h
@@ -230,6 +230,8 @@ typedef struct {
 
 #define RDINDOOR(rdev) readl((rdev)->baseaddr + 0x20)
 #define RDOUTDOOR(rdev)readl((rdev)->baseaddr + 0x2C)
+#define WRINDOOR_RELAXED(rdev, value)  \
+   writel_relaxed(value, (rdev)->baseaddr + 0x20)
 #define WRINDOOR(rdev, value)  writel(value, (rdev)->baseaddr + 0x20)
 #define WROUTDOOR(rdev, value) writel(value, (rdev)->baseaddr + 0x2C)
 
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 073ced0..f560496 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -3479,11 +3479,11 @@ complete_cmd_fusion(struct megasas_instance *instance, 
u32 MSIxIndex)
 
wmb();
if (instance->msix_combined)
-   writel(((MSIxIndex & 0x7) << 24) |
+   writel_relaxed(((MSIxIndex & 0x7) << 24) |
fusion->last_reply_idx[MSIxIndex],
instance->reply_post_host_index_addr[MSIxIndex/8]);
else
-   writel((MSIxIndex << 24) |
+   writel_relaxed((MSIxIndex << 24) |
fusion->last_reply_idx[MSIxIndex],
instance->reply_post_host_index_addr[0]);
megasas_check_and_restore_queue_depth(instance);
-- 
2.7.4



[PATCH v4 6/7] scsi: bnx2i: Eliminate duplicate barriers on weakly-ordered archs

2018-03-19 Thread Sinan Kaya
Code includes barrier() followed by writel(). writel() already has a
barrier
on some architectures like arm64.

This ends up CPU observing two barriers back to back before executing the
register write.

Since code already has an explicit barrier call, changing writel() to
writel_relaxed().

Signed-off-by: Sinan Kaya 
---
 drivers/scsi/bnx2i/bnx2i_hwi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 8f03a86..075735b 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -278,7 +278,7 @@ static void bnx2i_ring_sq_dbell(struct bnx2i_conn 
*bnx2i_conn, int count)
sq_db->prod_idx = ep->qp.sq_prod_idx;
bnx2i_ring_577xx_doorbell(bnx2i_conn);
} else
-   writew(count, ep->qp.ctx_base + CNIC_SEND_DOORBELL);
+   writew_relaxed(count, ep->qp.ctx_base + CNIC_SEND_DOORBELL);
 
mmiowb(); /* flush posted PCI writes */
 }
-- 
2.7.4



[PATCH v4 7/7] scsi: csiostor: Eliminate duplicate barriers on weakly-ordered archs

2018-03-19 Thread Sinan Kaya
Code includes barrier() followed by writel(). writel() already has a
barrier
on some architectures like arm64.

This ends up CPU observing two barriers back to back before executing the
register write.

Create a new wrapper function with relaxed write operator. Use the new
wrapper when a write is following a barrier().

Signed-off-by: Sinan Kaya 
---
 drivers/scsi/csiostor/csio_hw.h | 4 
 drivers/scsi/csiostor/csio_wr.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/csiostor/csio_hw.h b/drivers/scsi/csiostor/csio_hw.h
index 30f5f52..9fd8b00 100644
--- a/drivers/scsi/csiostor/csio_hw.h
+++ b/drivers/scsi/csiostor/csio_hw.h
@@ -512,6 +512,10 @@ struct csio_hw {
csio_reg((_h)->regstart, (_r)))
 #definecsio_wr_reg16(_h, _v, _r)   writew((_v), \
csio_reg((_h)->regstart, (_r)))
+
+#definecsio_wr_reg32_relaxed(_h, _v, _r) \
+   writel_relaxed((_v), csio_reg((_h)->regstart, (_r)))
+
 #definecsio_wr_reg32(_h, _v, _r)   writel((_v), \
csio_reg((_h)->regstart, (_r)))
 #definecsio_wr_reg64(_h, _v, _r)   writeq((_v), \
diff --git a/drivers/scsi/csiostor/csio_wr.c b/drivers/scsi/csiostor/csio_wr.c
index c0a1778..db26222 100644
--- a/drivers/scsi/csiostor/csio_wr.c
+++ b/drivers/scsi/csiostor/csio_wr.c
@@ -984,7 +984,7 @@ csio_wr_issue(struct csio_hw *hw, int qidx, bool prio)
 
wmb();
/* Ring SGE Doorbell writing q->pidx into it */
-   csio_wr_reg32(hw, DBPRIO_V(prio) | QID_V(q->un.eq.physeqid) |
+   csio_wr_reg32_relaxed(hw, DBPRIO_V(prio) | QID_V(q->un.eq.physeqid) |
  PIDX_T5_V(q->inc_idx) | DBTYPE_F,
  MYPF_REG(SGE_PF_KDOORBELL_A));
q->inc_idx = 0;
-- 
2.7.4



[PATCH v4 5/7] scsi: ipr: Eliminate duplicate barriers on weakly-ordered archs

2018-03-19 Thread Sinan Kaya
Code includes barrier() followed by writel(). writel() already has a
barrier
on some architectures like arm64.

This ends up CPU observing two barriers back to back before executing the
register write.

Since code already has an explicit barrier call, changing writeX() to
writeX_relaxed().

Signed-off-by: Sinan Kaya 
---
 drivers/scsi/ipr.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index e07dd99..209adac 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -762,9 +762,9 @@ static void ipr_mask_and_clear_interrupts(struct 
ipr_ioa_cfg *ioa_cfg,
 
/* Set interrupt mask to stop all new interrupts */
if (ioa_cfg->sis64)
-   writeq(~0, ioa_cfg->regs.set_interrupt_mask_reg);
+   writeq_relaxed(~0, ioa_cfg->regs.set_interrupt_mask_reg);
else
-   writel(~0, ioa_cfg->regs.set_interrupt_mask_reg);
+   writel_relaxed(~0, ioa_cfg->regs.set_interrupt_mask_reg);
 
/* Clear any pending interrupts */
if (ioa_cfg->sis64)
@@ -8435,7 +8435,8 @@ static int ipr_reset_enable_ioa(struct ipr_cmnd *ipr_cmd)
wmb();
if (ioa_cfg->sis64) {
/* Set the adapter to the correct endian mode. */
-   writel(IPR_ENDIAN_SWAP_KEY, ioa_cfg->regs.endian_swap_reg);
+   writel_relaxed(IPR_ENDIAN_SWAP_KEY,
+  ioa_cfg->regs.endian_swap_reg);
int_reg = readl(ioa_cfg->regs.endian_swap_reg);
}
 
-- 
2.7.4



[PATCH v4 4/7] scsi: lpfc: Eliminate duplicate barriers on weakly-ordered archs

2018-03-19 Thread Sinan Kaya
Code includes barrier() followed by writel(). writel() already has a
barrier
on some architectures like arm64.

This ends up CPU observing two barriers back to back before executing the
register write.

Since code already has an explicit barrier call, changing writel() to
writel_relaxed().

Signed-off-by: Sinan Kaya 
---
 drivers/scsi/lpfc/lpfc_sli.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 5f5528a..7dae7d3 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -1647,7 +1647,7 @@ lpfc_sli_update_full_ring(struct lpfc_hba *phba, struct 
lpfc_sli_ring *pring)
 * Set ring 'ringno' to SET R0CE_REQ in Chip Att register.
 * The HBA will tell us when an IOCB entry is available.
 */
-   writel((CA_R0ATT|CA_R0CE_REQ) << (ringno*4), phba->CAregaddr);
+   writel_relaxed((CA_R0ATT|CA_R0CE_REQ) << (ringno*4), phba->CAregaddr);
readl(phba->CAregaddr); /* flush */
 
pring->stats.iocb_cmd_full++;
@@ -1672,7 +1672,7 @@ lpfc_sli_update_ring(struct lpfc_hba *phba, struct 
lpfc_sli_ring *pring)
 */
if (!(phba->sli3_options & LPFC_SLI3_CRP_ENABLED)) {
wmb();
-   writel(CA_R0ATT << (ringno * 4), phba->CAregaddr);
+   writel_relaxed(CA_R0ATT << (ringno * 4), phba->CAregaddr);
readl(phba->CAregaddr); /* flush */
}
 }
-- 
2.7.4



[PATCH v4 1/7] scsi: hpsa: Eliminate duplicate barriers on weakly-ordered archs

2018-03-19 Thread Sinan Kaya
Code includes wmb() followed by writel(). writel() already has a
barrier on some architectures like arm64.

This ends up CPU observing two barriers back to back before executing
the register write.

Since code already has an explicit barrier call, changing writel() to
writel_relaxed().

Signed-off-by: Sinan Kaya 
---
 drivers/scsi/hpsa.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index 018f980..c7d7e6a 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -599,7 +599,7 @@ static unsigned long SA5_ioaccel_mode1_completed(struct 
ctlr_info *h, u8 q)
 * but with current driver design this is easiest.
 */
wmb();
-   writel((q << 24) | rq->current_entry, h->vaddr +
+   writel_relaxed((q << 24) | rq->current_entry, h->vaddr +
IOACCEL_MODE1_CONSUMER_INDEX);
atomic_dec(&h->commands_outstanding);
}
-- 
2.7.4



[PATCH v4 0/7] scsi: Eliminate duplicate barriers on weakly-ordered archs

2018-03-19 Thread Sinan Kaya
Code includes wmb() followed by writel() in multiple places. writel()
already has a barrier on some architectures like arm64.

This ends up CPU observing two barriers back to back before executing the
register write.

Since code already has an explicit barrier call, changing writel() to
writel_relaxed().

I did a regex search for wmb() followed by writel() in each drivers
directory.
I scrubbed the ones I care about in this series.

I considered "ease of change", "popular usage" and "performance critical
path" as the determining criteria for my filtering.

We used relaxed API heavily on ARM for a long time but
it did not exist on other architectures. For this reason, relaxed
architectures have been paying double penalty in order to use the common
drivers.

Now that relaxed API is present on all architectures, we can go and scrub
all drivers to see what needs to change and what can remain.

We start with mostly used ones and hope to increase the coverage over time.
It will take a while to cover all drivers.

Feel free to apply patches individually.

Changes since v3:
- https://www.spinics.net/lists/arm-kernel/msg641851.html
- group patches together into subsystems scsi:...
- collect reviewed and tested bys
- scrub barrier()

Sinan Kaya (7):
  scsi: hpsa: Eliminate duplicate barriers on weakly-ordered archs
  scsi: megaraid: eliminate duplicate barriers on weakly-ordered archs
  scsi: dpt_i2o: eliminate duplicate barriers on weakly-ordered archs
  scsi: lpfc: Eliminate duplicate barriers on weakly-ordered archs
  scsi: ipr: Eliminate duplicate barriers on weakly-ordered archs
  scsi: bnx2i: Eliminate duplicate barriers on weakly-ordered archs
  scsi: csiostor: Eliminate duplicate barriers on weakly-ordered archs

 drivers/scsi/bnx2i/bnx2i_hwi.c  | 2 +-
 drivers/scsi/csiostor/csio_hw.h | 4 
 drivers/scsi/csiostor/csio_wr.c | 2 +-
 drivers/scsi/dpt_i2o.c  | 6 +++---
 drivers/scsi/hpsa.h | 2 +-
 drivers/scsi/ipr.c  | 7 ---
 drivers/scsi/lpfc/lpfc_sli.c| 4 ++--
 drivers/scsi/megaraid/megaraid_mbox.c   | 8 
 drivers/scsi/megaraid/megaraid_mbox.h   | 2 ++
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 4 ++--
 10 files changed, 24 insertions(+), 17 deletions(-)

-- 
2.7.4



[PATCH 3.18 53/68] scsi: devinfo: apply to HP XP the same flags as Hitachi VSP

2018-03-19 Thread Greg Kroah-Hartman
3.18-stable review patch.  If anyone has any objections, please let me know.

--

From: Xose Vazquez Perez 


[ Upstream commit b369a0471503130cfc74f9f62071db97f48948c3 ]

Commit 56f3d383f37b ("scsi: scsi_devinfo: Add TRY_VPD_PAGES to HITACHI
OPEN-V blacklist entry") modified some Hitachi entries:

HITACHI is always supporting VPD pages, even though it's claiming to
support SCSI Revision 3 only.

The same should have been done also for HP-rebranded.

[mkp: checkpatch and tweaked commit message]

Cc: Hannes Reinecke 
Cc: Takahiro Yasui 
Cc: Matthias Rudolph 
Cc: Martin K. Petersen 
Cc: James E.J. Bottomley 
Cc: SCSI ML 
Signed-off-by: Xose Vazquez Perez 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/scsi/scsi_devinfo.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -180,7 +180,7 @@ static struct {
{"HITACHI", "6586-", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
{"HITACHI", "6588-", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
{"HP", "A6189A", NULL, BLIST_SPARSELUN | BLIST_LARGELUN},   /* HP 
VA7400 */
-   {"HP", "OPEN-", "*", BLIST_REPORTLUN2}, /* HP XP Arrays */
+   {"HP", "OPEN-", "*", BLIST_REPORTLUN2 | BLIST_TRY_VPD_PAGES}, /* HP XP 
Arrays */
{"HP", "NetRAID-4M", NULL, BLIST_FORCELUN},
{"HP", "HSV100", NULL, BLIST_REPORTLUN2 | BLIST_NOSTARTONADD},
{"HP", "C1557A", NULL, BLIST_FORCELUN},




Re: [PATCH] Change synchronize_rcu() in scsi_device_quiesce() into synchronize_sched()

2018-03-19 Thread Bart Van Assche
On Mon, 2018-03-19 at 10:02 -0700, t...@kernel.org wrote:
> On Mon, Mar 19, 2018 at 04:57:45PM +, Bart Van Assche wrote:
> > For synchronization primitives that wait having a stronger synchronization
> > primitive nested inside a more relaxed one can lead to a deadlock. But since
> > the rcu read lock primitives do not wait it could be safe to use that kind
> > of nesting with RCU. Do you perhaps know whether any documentation is
> > available about that kind of nesting or whether it is already used elsewhere
> > in the kernel?
> 
> Oh, we nest them all the time.  They're like (and sometimes literally
> are) preempt_disable() and don't care about nest ordering.

Hello Martin,

This was probably already clear to you, but anyway: please drop the patch at the
start of this thread.

Thanks,

Bart.




[PATCH 4.4 098/134] scsi: devinfo: apply to HP XP the same flags as Hitachi VSP

2018-03-19 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Xose Vazquez Perez 


[ Upstream commit b369a0471503130cfc74f9f62071db97f48948c3 ]

Commit 56f3d383f37b ("scsi: scsi_devinfo: Add TRY_VPD_PAGES to HITACHI
OPEN-V blacklist entry") modified some Hitachi entries:

HITACHI is always supporting VPD pages, even though it's claiming to
support SCSI Revision 3 only.

The same should have been done also for HP-rebranded.

[mkp: checkpatch and tweaked commit message]

Cc: Hannes Reinecke 
Cc: Takahiro Yasui 
Cc: Matthias Rudolph 
Cc: Martin K. Petersen 
Cc: James E.J. Bottomley 
Cc: SCSI ML 
Signed-off-by: Xose Vazquez Perez 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/scsi/scsi_devinfo.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -180,7 +180,7 @@ static struct {
{"HITACHI", "6586-", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
{"HITACHI", "6588-", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
{"HP", "A6189A", NULL, BLIST_SPARSELUN | BLIST_LARGELUN},   /* HP 
VA7400 */
-   {"HP", "OPEN-", "*", BLIST_REPORTLUN2}, /* HP XP Arrays */
+   {"HP", "OPEN-", "*", BLIST_REPORTLUN2 | BLIST_TRY_VPD_PAGES}, /* HP XP 
Arrays */
{"HP", "NetRAID-4M", NULL, BLIST_FORCELUN},
{"HP", "HSV100", NULL, BLIST_REPORTLUN2 | BLIST_NOSTARTONADD},
{"HP", "C1557A", NULL, BLIST_FORCELUN},




[PATCH 4.4 099/134] scsi: dh: add new rdac devices

2018-03-19 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Xose Vazquez Perez 


[ Upstream commit 4b3aec2bbbce1c35f50e7475a9fd78d24b9ea4ea ]

Add IBM 3542 and 3552, arrays: FAStT200 and FAStT500.

Add full STK OPENstorage family, arrays: 9176, D173, D178, D210, D220,
D240 and D280.

Add STK BladeCtlr family, arrays: B210, B220, B240 and B280.

These changes were done in multipath-tools time ago.

Cc: NetApp RDAC team 
Cc: Hannes Reinecke 
Cc: Christophe Varoqui 
Cc: Martin K. Petersen 
Cc: James E.J. Bottomley 
Cc: SCSI ML 
Cc: device-mapper development 
Signed-off-by: Xose Vazquez Perez 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/scsi/scsi_dh.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/drivers/scsi/scsi_dh.c
+++ b/drivers/scsi/scsi_dh.c
@@ -56,10 +56,13 @@ static const struct scsi_dh_blist scsi_d
{"IBM", "1815", "rdac", },
{"IBM", "1818", "rdac", },
{"IBM", "3526", "rdac", },
+   {"IBM", "3542", "rdac", },
+   {"IBM", "3552", "rdac", },
{"SGI", "TP9",  "rdac", },
{"SGI", "IS",   "rdac", },
-   {"STK", "OPENstorage D280", "rdac", },
+   {"STK", "OPENstorage",  "rdac", },
{"STK", "FLEXLINE 380", "rdac", },
+   {"STK", "BladeCtlr","rdac", },
{"SUN", "CSM",  "rdac", },
{"SUN", "LCSM100",  "rdac", },
{"SUN", "STK6580_6780", "rdac", },




[PATCH 4.9 195/241] scsi: devinfo: apply to HP XP the same flags as Hitachi VSP

2018-03-19 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Xose Vazquez Perez 


[ Upstream commit b369a0471503130cfc74f9f62071db97f48948c3 ]

Commit 56f3d383f37b ("scsi: scsi_devinfo: Add TRY_VPD_PAGES to HITACHI
OPEN-V blacklist entry") modified some Hitachi entries:

HITACHI is always supporting VPD pages, even though it's claiming to
support SCSI Revision 3 only.

The same should have been done also for HP-rebranded.

[mkp: checkpatch and tweaked commit message]

Cc: Hannes Reinecke 
Cc: Takahiro Yasui 
Cc: Matthias Rudolph 
Cc: Martin K. Petersen 
Cc: James E.J. Bottomley 
Cc: SCSI ML 
Signed-off-by: Xose Vazquez Perez 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/scsi/scsi_devinfo.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -180,7 +180,7 @@ static struct {
{"HITACHI", "6586-", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
{"HITACHI", "6588-", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
{"HP", "A6189A", NULL, BLIST_SPARSELUN | BLIST_LARGELUN},   /* HP 
VA7400 */
-   {"HP", "OPEN-", "*", BLIST_REPORTLUN2}, /* HP XP Arrays */
+   {"HP", "OPEN-", "*", BLIST_REPORTLUN2 | BLIST_TRY_VPD_PAGES}, /* HP XP 
Arrays */
{"HP", "NetRAID-4M", NULL, BLIST_FORCELUN},
{"HP", "HSV100", NULL, BLIST_REPORTLUN2 | BLIST_NOSTARTONADD},
{"HP", "C1557A", NULL, BLIST_FORCELUN},




[PATCH 4.9 196/241] scsi: dh: add new rdac devices

2018-03-19 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Xose Vazquez Perez 


[ Upstream commit 4b3aec2bbbce1c35f50e7475a9fd78d24b9ea4ea ]

Add IBM 3542 and 3552, arrays: FAStT200 and FAStT500.

Add full STK OPENstorage family, arrays: 9176, D173, D178, D210, D220,
D240 and D280.

Add STK BladeCtlr family, arrays: B210, B220, B240 and B280.

These changes were done in multipath-tools time ago.

Cc: NetApp RDAC team 
Cc: Hannes Reinecke 
Cc: Christophe Varoqui 
Cc: Martin K. Petersen 
Cc: James E.J. Bottomley 
Cc: SCSI ML 
Cc: device-mapper development 
Signed-off-by: Xose Vazquez Perez 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/scsi/scsi_dh.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/drivers/scsi/scsi_dh.c
+++ b/drivers/scsi/scsi_dh.c
@@ -56,10 +56,13 @@ static const struct scsi_dh_blist scsi_d
{"IBM", "1815", "rdac", },
{"IBM", "1818", "rdac", },
{"IBM", "3526", "rdac", },
+   {"IBM", "3542", "rdac", },
+   {"IBM", "3552", "rdac", },
{"SGI", "TP9",  "rdac", },
{"SGI", "IS",   "rdac", },
-   {"STK", "OPENstorage D280", "rdac", },
+   {"STK", "OPENstorage",  "rdac", },
{"STK", "FLEXLINE 380", "rdac", },
+   {"STK", "BladeCtlr","rdac", },
{"SUN", "CSM",  "rdac", },
{"SUN", "LCSM100",  "rdac", },
{"SUN", "STK6580_6780", "rdac", },




Re: [PATCH] scsi: unexport scsi_host_set_state

2018-03-19 Thread Bart Van Assche
On Mon, 2018-03-19 at 08:34 +0100, Christoph Hellwig wrote:
> This function is only used inside the SCSI midlayer, so remove the
> export for it.

Reviewed-by: Bart Van Assche 




Re: How to Locate drive directly attached to mpt3sas HBA

2018-03-19 Thread James Bottomley
On Mon, 2018-03-19 at 17:30 +0100, Jack Wang wrote:
> > 
> > 
> > > 
> > > And I think either mpt2sas and/or mpt3sas HBAs (I don't have my
> > > hardware
> > > nearby) have a SMP target hidden away somewhere. Perhaps someone
> > > from
> > > LSI/Avago/Broadcom could supply more information about that.
> 
> Indeed, mpt3sas has internal enclosure some how.
> snip from  "sas3ircu 0 display" output:
> Device is a Hard disk
>   Enclosure # : 1
>   Slot #  : 4
>   SAS Address : 4433221-1-0400-
>   State   : Ready (RDY)
> 
> And it's possible to locate it using "sas3ircu 0 locate 1:4 ON" to
> locate the drive.

The fat firmware eats pretty much all trace of the enclosure.  I think
it could be exposed as a device, but that would disrupt the mpt3sas
internal handling if our Linux enclosure service also binds to it.

James



Re: [PATCH] Change synchronize_rcu() in scsi_device_quiesce() into synchronize_sched()

2018-03-19 Thread t...@kernel.org
Hey,

On Mon, Mar 19, 2018 at 04:57:45PM +, Bart Van Assche wrote:
> For synchronization primitives that wait having a stronger synchronization
> primitive nested inside a more relaxed one can lead to a deadlock. But since
> the rcu read lock primitives do not wait it could be safe to use that kind
> of nesting with RCU. Do you perhaps know whether any documentation is
> available about that kind of nesting or whether it is already used elsewhere
> in the kernel?

Oh, we nest them all the time.  They're like (and sometimes literally
are) preempt_disable() and don't care about nest ordering.

Thanks.

-- 
tejun


Re: [PATCH] Change synchronize_rcu() in scsi_device_quiesce() into synchronize_sched()

2018-03-19 Thread Bart Van Assche
On Mon, 2018-03-19 at 09:29 -0700, t...@kernel.org wrote:
> This could be me being slow but can you explain how what
> percpu_ref_tryget_live() uses internally affects whether we can use
> regular RCU around it?

Hello Tejun,

For synchronization primitives that wait having a stronger synchronization
primitive nested inside a more relaxed one can lead to a deadlock. But since
the rcu read lock primitives do not wait it could be safe to use that kind
of nesting with RCU. Do you perhaps know whether any documentation is
available about that kind of nesting or whether it is already used elsewhere
in the kernel?

Thanks,

Bart.



Re: How to Locate drive directly attached to mpt3sas HBA

2018-03-19 Thread Jack Wang
>
>> And I think either mpt2sas and/or mpt3sas HBAs (I don't have my hardware
>> nearby) have a SMP target hidden away somewhere. Perhaps someone from
>> LSI/Avago/Broadcom could supply more information about that.

Indeed, mpt3sas has internal enclosure some how.
snip from  "sas3ircu 0 display" output:
Device is a Hard disk
  Enclosure # : 1
  Slot #  : 4
  SAS Address : 4433221-1-0400-
  State   : Ready (RDY)

And it's possible to locate it using "sas3ircu 0 locate 1:4 ON" to
locate the drive.

Thanks,
Jack


Re: [PATCH] Change synchronize_rcu() in scsi_device_quiesce() into synchronize_sched()

2018-03-19 Thread t...@kernel.org
Hello,

On Mon, Mar 19, 2018 at 04:18:54PM +, Bart Van Assche wrote:
> The algorithm explained above does not depend on sched-rcu. But because
> percpu_ref_tryget_live() uses sched-rcu and because we need to add an RCU lock
> around that call we are forced to use sched-rcu. I hope this makes it clear.

This could be me being slow but can you explain how what
percpu_ref_tryget_live() uses internally affects whether we can use
regular RCU around it?

Thanks.

-- 
tejun


Re: [PATCH] Change synchronize_rcu() in scsi_device_quiesce() into synchronize_sched()

2018-03-19 Thread Bart Van Assche
On Mon, 2018-03-19 at 08:21 -0700, t...@kernel.org wrote:
> On Mon, Mar 19, 2018 at 03:16:07PM +, Bart Van Assche wrote:
> > As explained in the comment in scsi_device_quiesce(), the effect of
> > blk_set_preempt_only() must be visible for percpu_ref_tryget() calls that
> > occur after the queue unfreeze triggered by scsi_device_quiesce(). Hence the
> > RCU read lock calls in blk_queue_enter(). Since these RCU read lock calls
> > surround a function call that uses rcu_read_lock_sched(), namely
> > percpu_ref_tryget_live(), we have to use sched-RCU in both blk_queue_enter()
> > and scsi_device_quiesce().
> 
> Let's please not depend on rcu_read_lock_sched() in
> percpu_ref_tryget_live().  That's an implementation detail.  If the
> code needs RCU based synchronization, it should perform them
> explicitly.

Hello Tejun,

The algorithm explained above does not depend on sched-rcu. But because
percpu_ref_tryget_live() uses sched-rcu and because we need to add an RCU lock
around that call we are forced to use sched-rcu. I hope this makes it clear.

Bart.




Re: [PATCH V5 1/5] scsi: hpsa: fix selection of reply queue

2018-03-19 Thread Ming Lei
On Mon, Mar 19, 2018 at 04:42:09PM +0200, Artem Bityutskiy wrote:
> On Mon, 2018-03-19 at 08:31 -0600, Jens Axboe wrote:
> > I'm assuming that Martin will eventually queue this up. But probably
> > for 4.17, then we can always flag it for a backport to stable once
> > it's been thoroughly tested.
> 
> Jens, thanks for reply.
> 
> I wonder if folks agree that in this case we should revert 
> 
> 84676c1f21e8 genirq/affinity: assign vectors to all possible CPUs
> 
> for v4.16.

Even 84676c1f21e8 is reverted, IO failure or hang can still be triggered
easily when doing CPU online/offline test.

So this patchset is really needed.

Thanks,
Ming


Re: [PATCH] Change synchronize_rcu() in scsi_device_quiesce() into synchronize_sched()

2018-03-19 Thread t...@kernel.org
Hello,

On Mon, Mar 19, 2018 at 03:16:07PM +, Bart Van Assche wrote:
> As explained in the comment in scsi_device_quiesce(), the effect of
> blk_set_preempt_only() must be visible for percpu_ref_tryget() calls that
> occur after the queue unfreeze triggered by scsi_device_quiesce(). Hence the
> RCU read lock calls in blk_queue_enter(). Since these RCU read lock calls
> surround a function call that uses rcu_read_lock_sched(), namely
> percpu_ref_tryget_live(), we have to use sched-RCU in both blk_queue_enter()
> and scsi_device_quiesce().

Let's please not depend on rcu_read_lock_sched() in
percpu_ref_tryget_live().  That's an implementation detail.  If the
code needs RCU based synchronization, it should perform them
explicitly.

Thanks.

-- 
tejun


Re: [PATCH] Change synchronize_rcu() in scsi_device_quiesce() into synchronize_sched()

2018-03-19 Thread Bart Van Assche
On Mon, 2018-03-19 at 07:31 -0700, Tejun Heo wrote:
> On Fri, Mar 16, 2018 at 10:35:16AM -0700, Bart Van Assche wrote:
> > Since blk_queue_enter() uses rcu_read_lock_sched() scsi_device_quiesce()
> > must use synchronize_sched().
> 
> Is there a reason to use sched-RCU here instead of the regular one?
> If not, it'd be better to switch to regular RCU than the other way
> around.

Hello Tejun,

As explained in the comment in scsi_device_quiesce(), the effect of
blk_set_preempt_only() must be visible for percpu_ref_tryget() calls that
occur after the queue unfreeze triggered by scsi_device_quiesce(). Hence the
RCU read lock calls in blk_queue_enter(). Since these RCU read lock calls
surround a function call that uses rcu_read_lock_sched(), namely
percpu_ref_tryget_live(), we have to use sched-RCU in both blk_queue_enter()
and scsi_device_quiesce().

Bart.





RE: [PATCH V5 1/5] scsi: hpsa: fix selection of reply queue

2018-03-19 Thread Kashyap Desai
> -Original Message-
> From: Artem Bityutskiy [mailto:dedeki...@gmail.com]
> Sent: Monday, March 19, 2018 8:12 PM
> To: h...@lst.de; Thomas Gleixner
> Cc: linux-bl...@vger.kernel.org; snit...@redhat.com; h...@suse.de;
> mr...@linux.ee; linux-scsi@vger.kernel.org; don.br...@microsemi.com;
> pbonz...@redhat.com; lober...@redhat.com;
> kashyap.de...@broadcom.com; Jens Axboe; martin.peter...@oracle.com;
> james.bottom...@hansenpartnership.com; ming@redhat.com
> Subject: Re: [PATCH V5 1/5] scsi: hpsa: fix selection of reply queue
>
> On Mon, 2018-03-19 at 08:31 -0600, Jens Axboe wrote:
> > I'm assuming that Martin will eventually queue this up. But probably
> > for 4.17, then we can always flag it for a backport to stable once
> > it's been thoroughly tested.
>
> Jens, thanks for reply.
>
> I wonder if folks agree that in this case we should revert
>
> 84676c1f21e8 genirq/affinity: assign vectors to all possible CPUs
>
> for v4.16.
>
> If this was a minor niche use-case regression the -stable scenario would
> probably be OK. But the patch seem to miss the fact that kernel's
> "possible
> CPUs" notion may be way off and side effects are bad.

Also it is performance issue as posted at below link, if we just use
"84676c1f21e8 genirq/affinity: assign vectors to all possible CPUs".

https://www.spinics.net/lists/linux-scsi/msg118301.html

Performance drop was resolved using patch set (available at below link)under
discussion posted by Ming.

https://marc.info/?l=linux-block&m=152050646332092&w=2

Kashyap

>
> Christoph, Thomas, what do you think?
>
> Thanks,
> Artem.


Re: How to Locate drive directly attached to mpt3sas HBA

2018-03-19 Thread Jack Wang
2018-03-19 15:20 GMT+01:00 Douglas Gilbert :
> On 2018-03-19 11:40 AM, Jack Wang wrote:
>>
>> Hi list,
>>
>> Any one knows how can I locate a HDD directly attached to mpt3sas,
>> sas3ircu only supports LOCATE commd to locates driver installed in a
>> disk enclosure, but not directly attached.
>>
>> I know microsemi/PMCs supports SGPIO interface to locate drive eg:
>>   Adp80xxapp sgpio 0 set 0 1
>>
>> I searched in latest upstream mpt3sas code, didn't find such
>> interface. Do I miss something?
>
>
> Hi,
> If its a SAS disk, it might have an onboard LED.
>
> In the sdparm package there is a script called "sas_disk_blink"
> that will flash that LED.
>
>

> And I think either mpt2sas and/or mpt3sas HBAs (I don't have my hardware
> nearby) have a SMP target hidden away somewhere. Perhaps someone from
> LSI/Avago/Broadcom could supply more information about that.
>
> Doug Gilbert
>
Thanks Doug for your information, we're interested mainly on SATA  SSD
from Intel.
I hope Broadcom could shed some light.

The HBA is Serial Attached SCSI controller: LSI Logic / Symbios Logic
SAS3008 PCI-Express Fusion-MPT SAS-3 (rev 02)

Regards,
Jack


Re: How to Locate drive directly attached to mpt3sas HBA

2018-03-19 Thread James Bottomley
On Mon, 2018-03-19 at 15:20 +0100, Douglas Gilbert wrote:
> On 2018-03-19 11:40 AM, Jack Wang wrote:
> > 
> > Hi list,
> > 
> > Any one knows how can I locate a HDD directly attached to mpt3sas,
> > sas3ircu only supports LOCATE commd to locates driver installed in
> > a
> > disk enclosure, but not directly attached.
> > 
> > I know microsemi/PMCs supports SGPIO interface to locate drive eg:
> >   Adp80xxapp sgpio 0 set 0 1
> > 
> > I searched in latest upstream mpt3sas code, didn't find such
> > interface. Do I miss something?
> 
> Hi,
> If its a SAS disk, it might have an onboard LED.
> 
> In the sdparm package there is a script called "sas_disk_blink"
> that will flash that LED.
> 
> 
> And I think either mpt2sas and/or mpt3sas HBAs (I don't have my
> hardware nearby) have a SMP target hidden away somewhere. Perhaps
> someone from LSI/Avago/Broadcom could supply more information about
> that.

And if mpt3sas just used the standard Linux SES infrastructure, you'd
find the disk in sysfs linked to the slot along with a nice sysfs file
you can write to to flash the locator light.

James



Re: [PATCH V5 1/5] scsi: hpsa: fix selection of reply queue

2018-03-19 Thread Artem Bityutskiy
On Mon, 2018-03-19 at 08:31 -0600, Jens Axboe wrote:
> I'm assuming that Martin will eventually queue this up. But probably
> for 4.17, then we can always flag it for a backport to stable once
> it's been thoroughly tested.

Jens, thanks for reply.

I wonder if folks agree that in this case we should revert 

84676c1f21e8 genirq/affinity: assign vectors to all possible CPUs

for v4.16.

If this was a minor niche use-case regression the -stable scenario
would probably be OK. But the patch seem to miss the fact that kernel's
"possible CPUs" notion may be way off and side effects are bad.

Christoph, Thomas, what do you think?

Thanks,
Artem.


Re: [PATCH V5 1/5] scsi: hpsa: fix selection of reply queue

2018-03-19 Thread Jens Axboe
On 3/19/18 5:48 AM, Bityutskiy, Artem wrote:
> On Tue, 2018-03-13 at 17:42 +0800, Ming Lei wrote:
>> From 84676c1f21 (genirq/affinity: assign vectors to all possible CPUs),
>> one msix vector can be created without any online CPU mapped, then one
>> command's completion may not be notified.
> 
> Hello Martin, James,
> 
> we have this patch-set and it fixes megaraid regression in v4.16. Do
> you plan to mege it to v4.16-rcX? I am worried - there seem to be no
> sight that this is going to me merged. They are not in the linux-next.

I'm assuming that Martin will eventually queue this up. But probably
for 4.17, then we can always flag it for a backport to stable once
it's been thoroughly tested.

-- 
Jens Axboe



Re: [PATCH] Change synchronize_rcu() in scsi_device_quiesce() into synchronize_sched()

2018-03-19 Thread Tejun Heo
On Fri, Mar 16, 2018 at 10:35:16AM -0700, Bart Van Assche wrote:
> Since blk_queue_enter() uses rcu_read_lock_sched() scsi_device_quiesce()
> must use synchronize_sched().

Is there a reason to use sched-RCU here instead of the regular one?
If not, it'd be better to switch to regular RCU than the other way
around.

Thanks.

-- 
tejun


Re: How to Locate drive directly attached to mpt3sas HBA

2018-03-19 Thread Douglas Gilbert

On 2018-03-19 11:40 AM, Jack Wang wrote:

Hi list,

Any one knows how can I locate a HDD directly attached to mpt3sas,
sas3ircu only supports LOCATE commd to locates driver installed in a
disk enclosure, but not directly attached.

I know microsemi/PMCs supports SGPIO interface to locate drive eg:
  Adp80xxapp sgpio 0 set 0 1

I searched in latest upstream mpt3sas code, didn't find such
interface. Do I miss something?


Hi,
If its a SAS disk, it might have an onboard LED.

In the sdparm package there is a script called "sas_disk_blink"
that will flash that LED.


And I think either mpt2sas and/or mpt3sas HBAs (I don't have my hardware
nearby) have a SMP target hidden away somewhere. Perhaps someone from
LSI/Avago/Broadcom could supply more information about that.

Doug Gilbert



Re: mpt3sas: sleeping function called from invalid context

2018-03-19 Thread Jaco Kroon
Hi All,

On 14/03/2018 03:29, Bart Van Assche wrote:
> (+Jaco)
Bart, thanks for adding me.
>
> On Tue, 2018-03-13 at 16:18 +0530, Suganath Prabu Subramani wrote:
>> We have root caused the issue and it is same as you mentioned.
>> "_scsih_get_enclosure_logicalid_chassis_slot()" is called with interrupts
>> disabled and this function
>> "_scsih_get_enclosure_logicalid_chassis_slot" again calls
>> _config_request(), with mutex_lock().
>>
>> We have patch ready along with few other change and we ll be posting
>> it by tomorrow after covering BST.
Has there been any progress?  We're currently seeing our server going
down again, and we'd like to eliminate this as the cause.  Currently IO
is still flowing but some IO has started to deadlock.

Kind Regards,
Jaco


Re: [PATCH V5 1/5] scsi: hpsa: fix selection of reply queue

2018-03-19 Thread Bityutskiy, Artem
On Tue, 2018-03-13 at 17:42 +0800, Ming Lei wrote:
> From 84676c1f21 (genirq/affinity: assign vectors to all possible CPUs),
> one msix vector can be created without any online CPU mapped, then one
> command's completion may not be notified.

Hello Martin, James,

we have this patch-set and it fixes megaraid regression in v4.16. Do
you plan to mege it to v4.16-rcX? I am worried - there seem to be no
sight that this is going to me merged. They are not in the linux-next.

-- 
Best Regards,
Artem Bityutskiy
-
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


[PATCH] scsi: qla2xxx: fix spelling mistake: "existant" -> "existent"

2018-03-19 Thread Colin King
From: Colin Ian King 

Trivial fix to spelling mistake in debug message text

Signed-off-by: Colin Ian King 
---
 drivers/scsi/qla2xxx/qla_target.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index 245005f1e93e..e002dd61e110 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -2023,7 +2023,7 @@ static void qlt_24xx_handle_abts(struct scsi_qla_host 
*vha,
sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha, s_id);
if (!sess) {
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf012,
-   "qla_target(%d): task abort for non-existant session\n",
+   "qla_target(%d): task abort for non-existent session\n",
vha->vp_idx);
spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
 
-- 
2.15.1



How to Locate drive directly attached to mpt3sas HBA

2018-03-19 Thread Jack Wang
Hi list,

Any one knows how can I locate a HDD directly attached to mpt3sas,
sas3ircu only supports LOCATE commd to locates driver installed in a
disk enclosure, but not directly attached.

I know microsemi/PMCs supports SGPIO interface to locate drive eg:
 Adp80xxapp sgpio 0 set 0 1

I searched in latest upstream mpt3sas code, didn't find such
interface. Do I miss something?

Thanks,
Jack


[PATCH 2/2] scsi: dpt_i2o: use after free in __adpt_reset()

2018-03-19 Thread Dan Carpenter
In __adpt_reset() the problem is that adpt_hba_reset() frees "pHba" on
error but we dereference it to print the name in the error message.

Signed-off-by: Dan Carpenter 

diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 3c667b23a801..ac2f40d9963b 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -797,14 +797,17 @@ static int __adpt_reset(struct scsi_cmnd* cmd)
 {
adpt_hba* pHba;
int rcode;
+   char name[32];
+
pHba = (adpt_hba*)cmd->device->host->hostdata[0];
-   printk(KERN_WARNING"%s: Hba Reset: scsi id %d: tid: 
%d\n",pHba->name,cmd->device->channel,pHba->channel[cmd->device->channel].tid );
+   strncpy(name, pHba->name, sizeof(name));
+   printk(KERN_WARNING"%s: Hba Reset: scsi id %d: tid: %d\n", name, 
cmd->device->channel, pHba->channel[cmd->device->channel].tid);
rcode =  adpt_hba_reset(pHba);
if(rcode == 0){
-   printk(KERN_WARNING"%s: HBA reset complete\n",pHba->name);
+   printk(KERN_WARNING"%s: HBA reset complete\n", name);
return SUCCESS;
} else {
-   printk(KERN_WARNING"%s: HBA reset failed (%x)\n",pHba->name, 
rcode);
+   printk(KERN_WARNING"%s: HBA reset failed (%x)\n", name, rcode);
return FAILED;
}
 }


[PATCH 1/2] scsi: dpt_i2o: use after free in adpt_release()

2018-03-19 Thread Dan Carpenter
The scsi_host_put() function frees "pHba" and then we dereference it on
the next line when we do "scsi_host_put(pHba->host);".

Fixes: 38e09e3bb056 ("scsi: dpt_i2o: stop using scsi_unregister")
Signed-off-by: Dan Carpenter 

diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 3c667b23a801..ac2f40d9963b 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -306,8 +306,8 @@ static void adpt_release(adpt_hba *pHba)
 {
scsi_remove_host(pHba->host);
 // adpt_i2o_quiesce_hba(pHba);
-   adpt_i2o_delete_hba(pHba);
scsi_host_put(pHba->host);
+   adpt_i2o_delete_hba(pHba);
 }
 
 


Patch "scsi: devinfo: apply to HP XP the same flags as Hitachi VSP" has been added to the 3.18-stable tree

2018-03-19 Thread gregkh

This is a note to let you know that I've just added the patch titled

scsi: devinfo: apply to HP XP the same flags as Hitachi VSP

to the 3.18-stable tree which can be found at:

http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
 scsi-devinfo-apply-to-hp-xp-the-same-flags-as-hitachi-vsp.patch
and it can be found in the queue-3.18 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let  know about it.


>From foo@baz Mon Mar 19 10:11:52 CET 2018
From: Xose Vazquez Perez 
Date: Fri, 17 Nov 2017 21:31:36 +0100
Subject: scsi: devinfo: apply to HP XP the same flags as Hitachi VSP

From: Xose Vazquez Perez 


[ Upstream commit b369a0471503130cfc74f9f62071db97f48948c3 ]

Commit 56f3d383f37b ("scsi: scsi_devinfo: Add TRY_VPD_PAGES to HITACHI
OPEN-V blacklist entry") modified some Hitachi entries:

HITACHI is always supporting VPD pages, even though it's claiming to
support SCSI Revision 3 only.

The same should have been done also for HP-rebranded.

[mkp: checkpatch and tweaked commit message]

Cc: Hannes Reinecke 
Cc: Takahiro Yasui 
Cc: Matthias Rudolph 
Cc: Martin K. Petersen 
Cc: James E.J. Bottomley 
Cc: SCSI ML 
Signed-off-by: Xose Vazquez Perez 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/scsi/scsi_devinfo.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -180,7 +180,7 @@ static struct {
{"HITACHI", "6586-", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
{"HITACHI", "6588-", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
{"HP", "A6189A", NULL, BLIST_SPARSELUN | BLIST_LARGELUN},   /* HP 
VA7400 */
-   {"HP", "OPEN-", "*", BLIST_REPORTLUN2}, /* HP XP Arrays */
+   {"HP", "OPEN-", "*", BLIST_REPORTLUN2 | BLIST_TRY_VPD_PAGES}, /* HP XP 
Arrays */
{"HP", "NetRAID-4M", NULL, BLIST_FORCELUN},
{"HP", "HSV100", NULL, BLIST_REPORTLUN2 | BLIST_NOSTARTONADD},
{"HP", "C1557A", NULL, BLIST_FORCELUN},


Patches currently in stable-queue which might be from xose.vazq...@gmail.com are

queue-3.18/scsi-devinfo-apply-to-hp-xp-the-same-flags-as-hitachi-vsp.patch


Patch "scsi: dh: add new rdac devices" has been added to the 4.4-stable tree

2018-03-19 Thread gregkh

This is a note to let you know that I've just added the patch titled

scsi: dh: add new rdac devices

to the 4.4-stable tree which can be found at:

http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
 scsi-dh-add-new-rdac-devices.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let  know about it.


>From foo@baz Mon Mar 19 09:58:12 CET 2018
From: Xose Vazquez Perez 
Date: Fri, 17 Nov 2017 22:05:13 +0100
Subject: scsi: dh: add new rdac devices

From: Xose Vazquez Perez 


[ Upstream commit 4b3aec2bbbce1c35f50e7475a9fd78d24b9ea4ea ]

Add IBM 3542 and 3552, arrays: FAStT200 and FAStT500.

Add full STK OPENstorage family, arrays: 9176, D173, D178, D210, D220,
D240 and D280.

Add STK BladeCtlr family, arrays: B210, B220, B240 and B280.

These changes were done in multipath-tools time ago.

Cc: NetApp RDAC team 
Cc: Hannes Reinecke 
Cc: Christophe Varoqui 
Cc: Martin K. Petersen 
Cc: James E.J. Bottomley 
Cc: SCSI ML 
Cc: device-mapper development 
Signed-off-by: Xose Vazquez Perez 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/scsi/scsi_dh.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/drivers/scsi/scsi_dh.c
+++ b/drivers/scsi/scsi_dh.c
@@ -56,10 +56,13 @@ static const struct scsi_dh_blist scsi_d
{"IBM", "1815", "rdac", },
{"IBM", "1818", "rdac", },
{"IBM", "3526", "rdac", },
+   {"IBM", "3542", "rdac", },
+   {"IBM", "3552", "rdac", },
{"SGI", "TP9",  "rdac", },
{"SGI", "IS",   "rdac", },
-   {"STK", "OPENstorage D280", "rdac", },
+   {"STK", "OPENstorage",  "rdac", },
{"STK", "FLEXLINE 380", "rdac", },
+   {"STK", "BladeCtlr","rdac", },
{"SUN", "CSM",  "rdac", },
{"SUN", "LCSM100",  "rdac", },
{"SUN", "STK6580_6780", "rdac", },


Patches currently in stable-queue which might be from xose.vazq...@gmail.com are

queue-4.4/scsi-devinfo-apply-to-hp-xp-the-same-flags-as-hitachi-vsp.patch
queue-4.4/scsi-dh-add-new-rdac-devices.patch


Patch "scsi: devinfo: apply to HP XP the same flags as Hitachi VSP" has been added to the 4.4-stable tree

2018-03-19 Thread gregkh

This is a note to let you know that I've just added the patch titled

scsi: devinfo: apply to HP XP the same flags as Hitachi VSP

to the 4.4-stable tree which can be found at:

http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
 scsi-devinfo-apply-to-hp-xp-the-same-flags-as-hitachi-vsp.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let  know about it.


>From foo@baz Mon Mar 19 09:58:12 CET 2018
From: Xose Vazquez Perez 
Date: Fri, 17 Nov 2017 21:31:36 +0100
Subject: scsi: devinfo: apply to HP XP the same flags as Hitachi VSP

From: Xose Vazquez Perez 


[ Upstream commit b369a0471503130cfc74f9f62071db97f48948c3 ]

Commit 56f3d383f37b ("scsi: scsi_devinfo: Add TRY_VPD_PAGES to HITACHI
OPEN-V blacklist entry") modified some Hitachi entries:

HITACHI is always supporting VPD pages, even though it's claiming to
support SCSI Revision 3 only.

The same should have been done also for HP-rebranded.

[mkp: checkpatch and tweaked commit message]

Cc: Hannes Reinecke 
Cc: Takahiro Yasui 
Cc: Matthias Rudolph 
Cc: Martin K. Petersen 
Cc: James E.J. Bottomley 
Cc: SCSI ML 
Signed-off-by: Xose Vazquez Perez 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/scsi/scsi_devinfo.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -180,7 +180,7 @@ static struct {
{"HITACHI", "6586-", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
{"HITACHI", "6588-", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
{"HP", "A6189A", NULL, BLIST_SPARSELUN | BLIST_LARGELUN},   /* HP 
VA7400 */
-   {"HP", "OPEN-", "*", BLIST_REPORTLUN2}, /* HP XP Arrays */
+   {"HP", "OPEN-", "*", BLIST_REPORTLUN2 | BLIST_TRY_VPD_PAGES}, /* HP XP 
Arrays */
{"HP", "NetRAID-4M", NULL, BLIST_FORCELUN},
{"HP", "HSV100", NULL, BLIST_REPORTLUN2 | BLIST_NOSTARTONADD},
{"HP", "C1557A", NULL, BLIST_FORCELUN},


Patches currently in stable-queue which might be from xose.vazq...@gmail.com are

queue-4.4/scsi-devinfo-apply-to-hp-xp-the-same-flags-as-hitachi-vsp.patch
queue-4.4/scsi-dh-add-new-rdac-devices.patch


Re: [PATCH] scsi: unexport scsi_host_set_state

2018-03-19 Thread Johannes Thumshirn
Looks good,
Reviewed-by: Johannes Thumshirn 
-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+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] Change synchronize_rcu() in scsi_device_quiesce() into synchronize_sched()

2018-03-19 Thread Martin Steigerwald
Hi Bart.

Bart Van Assche - 16.03.18, 22:51:
> On 03/16/18 14:42, Martin Steigerwald wrote:
> > What is this one about?
> > 
> > Fix for the regression I (and others?) reported?¹
> > 
> > [1] [Bug 199077] [Possible REGRESSION, 4.16-rc4] Error updating SMART data
> > during runtime and boot failures with blk_mq_terminate_expired in
> > backtrace
> > 
> > https://bugzilla.kernel.org/show_bug.cgi?id=199077
[…]
> This patch is a fix for the fix for the bug that you and others had
> reported. See also "I/O hangs after resuming from suspend-to-ram"
> (https://marc.info/?l=linux-block&m=150340235201348).
> 
> This patch fixes an API violation. For those users for which suspend and
> resume works fine with commit 3a0a529971ec applied it should still work
> fine with this patch applied since this patch may cause
> scsi_device_quiesce() to wait longer.

Okay, so if I understand you correctly, this is not related to the regression 
I mentioned above.

Testing anyway.

Thanks,
-- 
Martin


Re: [PATCH v2 3/6] scsi_io_completion_nz_result function added

2018-03-19 Thread Johannes Thumshirn
Looks good,
Reviewed-by: Johannes Thumshirn 
-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+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 v2 6/6] scsi_io_completion convert BUGs to WARNs

2018-03-19 Thread Johannes Thumshirn
Looks good,
Reviewed-by: Johannes Thumshirn 
-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+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/6] mvme147: stop using scsi_module.c

2018-03-19 Thread John Paul Adrian Glaubitz
Hi Christoph!

On 03/19/2018 04:37 PM, Christoph Hellwig wrote:
> Convert the driver to modern style probing.  Given that there only is a
> single instance for a given board that can be done using a global
> struct Scsi_Host instance easily.
> 
> Also fix the removal path by passing the correct cookie to free_irq, and
> enable it unconditionally.

Thanks a lot for this work, much appreciated. I wish I could have been more
helpful with this driver. I will hopefully have the time to test it soon
with my VME system.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


[PATCH V2 1/1] scsi: ufs: Add support for Auto-Hibernate Idle Timer

2018-03-19 Thread Adrian Hunter
UFS host controllers may support an autonomous power management feature
called the Auto-Hibernate Idle Timer. The timer is set to the number of
microseconds of idle time before the UFS host controller will autonomously
put the link into Hibernate state. That will save power at the expense of
increased latency. Any access to the host controller interface registers
will automatically put the link out of Hibernate state. So once configured,
the feature is transparent to the driver.

Expose the Auto-Hibernate Idle Timer value via SysFS to allow users to
choose between power efficiency or lower latency. Set a default value of
150 ms.

Signed-off-by: Adrian Hunter 
---
 Documentation/ABI/testing/sysfs-driver-ufs | 15 ++
 drivers/scsi/ufs/ufs-sysfs.c   | 77 ++
 drivers/scsi/ufs/ufshcd.c  | 26 ++
 drivers/scsi/ufs/ufshcd.h  |  3 ++
 drivers/scsi/ufs/ufshci.h  |  7 +++
 5 files changed, 128 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-driver-ufs 
b/Documentation/ABI/testing/sysfs-driver-ufs
index 83735f79e572..a4142329cc34 100644
--- a/Documentation/ABI/testing/sysfs-driver-ufs
+++ b/Documentation/ABI/testing/sysfs-driver-ufs
@@ -1,3 +1,18 @@
+What:  /sys/bus/*/drivers/ufshcd/*/auto_hibern8
+Date:  February 2018
+Contact:   linux-scsi@vger.kernel.org
+Description:
+   This file contains the auto-hibernate idle timer setting of a
+   UFS host controller. A value of '-1' means auto-hibernate is not
+   supported. A value of '0' means auto-hibernate is not enabled.
+   Otherwise the value is the number of microseconds of idle time
+   before the UFS host controller will autonomously put the link
+   into hibernate state. That will save power at the expense of
+   increased latency. Note that the hardware supports 10-bit values
+   with a power-of-ten multiplier which allows a maximum value of
+   10230. Refer to the UFS Host Controller Interface
+   specification for more details.
+
 What:  /sys/bus/platform/drivers/ufshcd/*/device_descriptor/device_type
 Date:  February 2018
 Contact:   Stanislav Nijnikov 
diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
index 4ff9e0b7eba1..17ad661b1cb5 100644
--- a/drivers/scsi/ufs/ufs-sysfs.c
+++ b/drivers/scsi/ufs/ufs-sysfs.c
@@ -3,6 +3,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include "ufs.h"
@@ -117,12 +118,87 @@ static ssize_t spm_target_link_state_show(struct device 
*dev,
ufs_pm_lvl_states[hba->spm_lvl].link_state));
 }
 
+static void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit)
+{
+   unsigned long flags;
+
+   if (!(hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT))
+   return;
+
+   spin_lock_irqsave(hba->host->host_lock, flags);
+   if (hba->ahit == ahit)
+   goto out_unlock;
+   hba->ahit = ahit;
+   if (!pm_runtime_suspended(hba->dev))
+   ufshcd_writel(hba, hba->ahit, REG_AUTO_HIBERNATE_IDLE_TIMER);
+out_unlock:
+   spin_unlock_irqrestore(hba->host->host_lock, flags);
+}
+
+/* Convert Auto-Hibernate Idle Timer register value to microseconds */
+static int ufshcd_ahit_to_us(u32 ahit)
+{
+   int timer = FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK, ahit);
+   int scale = FIELD_GET(UFSHCI_AHIBERN8_SCALE_MASK, ahit);
+
+   for (; scale > 0; --scale)
+   timer *= UFSHCI_AHIBERN8_SCALE_FACTOR;
+
+   return timer;
+}
+
+/* Convert microseconds to Auto-Hibernate Idle Timer register value */
+static u32 ufshcd_us_to_ahit(unsigned int timer)
+{
+   unsigned int scale;
+
+   for (scale = 0; timer > UFSHCI_AHIBERN8_TIMER_MASK; ++scale)
+   timer /= UFSHCI_AHIBERN8_SCALE_FACTOR;
+
+   return FIELD_PREP(UFSHCI_AHIBERN8_TIMER_MASK, timer) |
+  FIELD_PREP(UFSHCI_AHIBERN8_SCALE_MASK, scale);
+}
+
+static ssize_t auto_hibern8_show(struct device *dev,
+struct device_attribute *attr, char *buf)
+{
+   struct ufs_hba *hba = dev_get_drvdata(dev);
+   int timer = -1;
+
+   if (hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT)
+   timer = ufshcd_ahit_to_us(hba->ahit);
+
+   return snprintf(buf, PAGE_SIZE, "%d\n", timer);
+}
+
+static ssize_t auto_hibern8_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+   struct ufs_hba *hba = dev_get_drvdata(dev);
+   unsigned int timer;
+
+   if (!(hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT))
+   return -EOPNOTSUPP;
+
+   if (kstrtouint(buf, 0, &timer))
+   return -EINVAL;
+
+   if (timer > UFSHCI_AHIBERN8_MAX)
+   return -EINVAL;
+
+   ufshcd_auto_hibern8_updat

[PATCH V2 0/1] scsi: ufs: Add support for Auto-Hibernate Idle Timer

2018-03-19 Thread Adrian Hunter
Hi

Here is V2, now re-based on top of patch "scsi: ufs: sysfs:reworking of the
rpm_lvl and spm_lvl entries".

Michał Potomski has previously sent a patch for Auto-Hibernate, but this
patch is slightly different, based on the latest ufs-sysfs changes, it also
takes care to restore auto-hibernate during resume, and otherwise avoids
updating the register if the device is runtime suspended.  Also a default
value of 150ms is set.


Changes in V2:

Re-based on top of (yet to be applied) patch "scsi: ufs: sysfs:
reworking of the rpm_lvl and spm_lvl entries"


Adrian Hunter (1):
  scsi: ufs: Add support for Auto-Hibernate Idle Timer

 Documentation/ABI/testing/sysfs-driver-ufs | 15 ++
 drivers/scsi/ufs/ufs-sysfs.c   | 77 ++
 drivers/scsi/ufs/ufshcd.c  | 26 ++
 drivers/scsi/ufs/ufshcd.h  |  3 ++
 drivers/scsi/ufs/ufshci.h  |  7 +++
 5 files changed, 128 insertions(+)


Regards
Adrian


[PATCH 2/6] mvme147: stop using scsi_module.c

2018-03-19 Thread Christoph Hellwig
Convert the driver to modern style probing.  Given that there only is a
single instance for a given board that can be done using a global
struct Scsi_Host instance easily.

Also fix the removal path by passing the correct cookie to free_irq, and
enable it unconditionally.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/mvme147.c | 107 ++---
 1 file changed, 57 insertions(+), 50 deletions(-)

diff --git a/drivers/scsi/mvme147.c b/drivers/scsi/mvme147.c
index e6b2b681fda3..7d1ab414b78f 100644
--- a/drivers/scsi/mvme147.c
+++ b/drivers/scsi/mvme147.c
@@ -3,6 +3,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -14,9 +17,6 @@
 #include "wd33c93.h"
 #include "mvme147.h"
 
-#include 
-
-
 static irqreturn_t mvme147_intr(int irq, void *data)
 {
struct Scsi_Host *instance = data;
@@ -65,40 +65,57 @@ static void dma_stop(struct Scsi_Host *instance, struct 
scsi_cmnd *SCpnt,
m147_pcc->dma_cntrl = 0;
 }
 
-int mvme147_detect(struct scsi_host_template *tpnt)
+static struct scsi_host_template mvme147_host_template = {
+   .module = THIS_MODULE,
+   .proc_name  = "MVME147",
+   .name   = "MVME147 built-in SCSI",
+   .queuecommand   = wd33c93_queuecommand,
+   .eh_abort_handler   = wd33c93_abort,
+   .eh_host_reset_handler  = wd33c93_host_reset,
+   .show_info  = wd33c93_show_info,
+   .write_info = wd33c93_write_info,
+   .can_queue  = CAN_QUEUE,
+   .this_id= 7,
+   .sg_tablesize   = SG_ALL,
+   .cmd_per_lun= CMD_PER_LUN,
+   .use_clustering = ENABLE_CLUSTERING
+};
+
+static struct Scsi_Host *mvme147_shost;
+
+static int __init mvme147_init(void)
 {
-   static unsigned char called = 0;
-   struct Scsi_Host *instance;
wd33c93_regs regs;
struct WD33C93_hostdata *hdata;
+   int error = -ENOMEM;
 
-   if (!MACH_IS_MVME147 || called)
+   if (!MACH_IS_MVME147)
return 0;
-   called++;
 
-   tpnt->proc_name = "MVME147";
-   tpnt->show_info = wd33c93_show_info,
-   tpnt->write_info = wd33c93_write_info,
-
-   instance = scsi_register(tpnt, sizeof(struct WD33C93_hostdata));
-   if (!instance)
+   mvme147_shost = scsi_host_alloc(&mvme147_host_template,
+   sizeof(struct WD33C93_hostdata));
+   if (!mvme147_shost)
goto err_out;
+   mvme147_shost->base = 0xfffe4000;
+   mvme147_shost->irq = MVME147_IRQ_SCSI_PORT;
 
-   instance->base = 0xfffe4000;
-   instance->irq = MVME147_IRQ_SCSI_PORT;
regs.SASR = (volatile unsigned char *)0xfffe4000;
regs.SCMD = (volatile unsigned char *)0xfffe4001;
-   hdata = shost_priv(instance);
+
+   hdata = shost_priv(mvme147_shost);
hdata->no_sync = 0xff;
hdata->fast = 0;
hdata->dma_mode = CTRL_DMA;
-   wd33c93_init(instance, regs, dma_setup, dma_stop, WD33C93_FS_8_10);
 
-   if (request_irq(MVME147_IRQ_SCSI_PORT, mvme147_intr, 0,
-   "MVME147 SCSI PORT", instance))
+   wd33c93_init(mvme147_shost, regs, dma_setup, dma_stop, WD33C93_FS_8_10);
+
+   error = request_irq(MVME147_IRQ_SCSI_PORT, mvme147_intr, 0,
+   "MVME147 SCSI PORT", mvme147_shost);
+   if (error)
goto err_unregister;
-   if (request_irq(MVME147_IRQ_SCSI_DMA, mvme147_intr, 0,
-   "MVME147 SCSI DMA", instance))
+   error = request_irq(MVME147_IRQ_SCSI_DMA, mvme147_intr, 0,
+   "MVME147 SCSI DMA", mvme147_shost);
+   if (error)
goto err_free_irq;
 #if 0  /* Disabled; causes problems booting */
m147_pcc->scsi_interrupt = 0x10;/* Assert SCSI bus reset */
@@ -112,40 +129,30 @@ int mvme147_detect(struct scsi_host_template *tpnt)
m147_pcc->dma_cntrl = 0x00; /* ensure DMA is stopped */
m147_pcc->dma_intr = 0x89;  /* Ack and enable ints */
 
-   return 1;
+   error = scsi_add_host(mvme147_shost, NULL);
+   if (error)
+   goto err_free_irq;
+   scsi_scan_host(mvme147_shost);
+   return 0;
 
 err_free_irq:
-   free_irq(MVME147_IRQ_SCSI_PORT, mvme147_intr);
+   free_irq(MVME147_IRQ_SCSI_PORT, mvme147_shost);
 err_unregister:
-   scsi_unregister(instance);
+   scsi_host_put(mvme147_shost);
 err_out:
-   return 0;
+   return error;
 }
 
-static struct scsi_host_template driver_template = {
-   .proc_name  = "MVME147",
-   .name   = "MVME147 built-in SCSI",
-   .detect = mvme147_detect,
-   .release= mvme147_release,
-   .queuecommand   = wd33c93_queuecommand,
-   .eh_abort_handler   = wd33c93_abort,
-   .eh_host_reset_handler  = wd33c93_host_re

[PATCH 6/6] scsi: remove the old scsi_module.c initialization model

2018-03-19 Thread Christoph Hellwig
After more than 15 years all users of this legacy interface are finally
gone.  Rest in peace!

Signed-off-by: Christoph Hellwig 
---
 Documentation/driver-api/scsi.rst   |   6 --
 Documentation/scsi/scsi_mid_low_api.txt | 122 +---
 drivers/scsi/hosts.c|  23 --
 drivers/scsi/scsi_module.c  |  73 ---
 include/scsi/scsi_host.h|  36 --
 5 files changed, 1 insertion(+), 259 deletions(-)
 delete mode 100644 drivers/scsi/scsi_module.c

diff --git a/Documentation/driver-api/scsi.rst 
b/Documentation/driver-api/scsi.rst
index 3ae337929721..31ad0fed6763 100644
--- a/Documentation/driver-api/scsi.rst
+++ b/Documentation/driver-api/scsi.rst
@@ -154,12 +154,6 @@ lists).
 .. kernel-doc:: drivers/scsi/scsi_lib_dma.c
:export:
 
-drivers/scsi/scsi_module.c
-~~~
-
-The file drivers/scsi/scsi_module.c contains legacy support for
-old-style host templates. It should never be used by any new driver.
-
 drivers/scsi/scsi_proc.c
 ~
 
diff --git a/Documentation/scsi/scsi_mid_low_api.txt 
b/Documentation/scsi/scsi_mid_low_api.txt
index 2c31d9ee6776..177c031763c0 100644
--- a/Documentation/scsi/scsi_mid_low_api.txt
+++ b/Documentation/scsi/scsi_mid_low_api.txt
@@ -114,9 +114,7 @@ called "xxx" could be defined as
 "static int xxx_slave_alloc(struct scsi_device * sdev) { /* code */ }"
 
 ** the scsi_host_alloc() function is a replacement for the rather vaguely
-named scsi_register() function in most situations. The scsi_register()
-and scsi_unregister() functions remain to support legacy LLDs that use
-the passive initialization model.
+named scsi_register() function in most situations.
 
 
 Hotplug initialization model
@@ -228,79 +226,6 @@ slave_configure() callbacks). Such instances are "owned" 
by the mid-level.
 struct scsi_device instances are freed after slave_destroy().
 
 
-Passive initialization model
-
-These older LLDs include a file called "scsi_module.c" [yes the ".c" is a
-little surprising] in their source code. For that file to work an
-instance of struct scsi_host_template with the name "driver_template"
-needs to be defined. Here is a typical code sequence used in this model:
-static struct scsi_host_template driver_template = {
-...
-};
-#include "scsi_module.c"
-
-The scsi_module.c file contains two functions:
-  - init_this_scsi_driver() which is executed when the LLD is
-initialized (i.e. boot time or module load time)
-  - exit_this_scsi_driver() which is executed when the LLD is shut
-down (i.e. module unload time)
-Note: since these functions are tagged with __init and __exit qualifiers
-an LLD should not call them explicitly (since the kernel does that).
-
-Here is an example of an initialization sequence when two hosts are
-detected (so detect() returns 2) and the SCSI bus scan on each host
-finds 1 SCSI device (and a second device does not respond).
-
-LLD  mid level LLD
-===--=-===--
-init_this_scsi_driver() +
-|
- detect()  -+
-|   |
-|scsi_register()
-|scsi_register()
-|
-  slave_alloc()
-  slave_configure()  -->  scsi_change_queue_depth()
-  slave_alloc()   ***
-  slave_destroy() ***
-|
-  slave_alloc()
-  slave_configure()
-  slave_alloc()   ***
-  slave_destroy() ***
-
-
-The mid level invokes scsi_change_queue_depth() with "cmd_per_lun" for that
-host as the queue length. These settings can be overridden by a
-slave_configure() supplied by the LLD.
-
-*** For scsi devices that the mid level tries to scan but do not
-respond, a slave_alloc(), slave_destroy() pair is called.
-
-Here is an LLD shutdown sequence:
-
-LLD  mid level LLD
-===--=-===--
-exit_this_scsi_driver() +
-|
- slave_destroy()
-release()   -->   scsi_unregister()
-|
- slave_destroy()
-release()   -->   scsi_unregister()
-
-
-An LLD need not define slave_destroy() (i.e. it is optional). 
-
-The shortcoming of the "passive initialization model" is that host
-registration and de-registration are (typically) tied to LLD initialization
-and shutdown. Once the LLD is initialized th

[PATCH 4/6] scsi: remove the NCR53c406a driver

2018-03-19 Thread Christoph Hellwig
This driver hasn't seen any recent bug fixing and is one of the last
drivers using the scsi_module.c infrastruture that has been deprecated
15 years ago.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/Kconfig  |   12 -
 drivers/scsi/Makefile |1 -
 drivers/scsi/NCR53c406a.c | 1090 -
 3 files changed, 1103 deletions(-)
 delete mode 100644 drivers/scsi/NCR53c406a.c

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 117c2fb41b77..9fa0cfd5a068 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -841,18 +841,6 @@ config SCSI_IZIP_SLOW_CTR
 
  Generally, saying N is fine.
 
-config SCSI_NCR53C406A
-   tristate "NCR53c406a SCSI support"
-   depends on ISA && SCSI
-   help
- This is support for the NCR53c406a SCSI host adapter.  For user
- configurable parameters, check out 
- in the kernel source.  Also read the SCSI-HOWTO, available from
- .
-
- To compile this driver as a module, choose M here: the
- module will be called NCR53c406.
-
 config SCSI_NCR_D700
tristate "NCR Dual 700 MCA SCSI support"
depends on MCA && SCSI
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 77bb0017bb02..192a58d7d9d9 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -75,7 +75,6 @@ obj-$(CONFIG_SCSI_PM8001) += pm8001/
 obj-$(CONFIG_SCSI_ISCI)+= isci/
 obj-$(CONFIG_SCSI_IPS) += ips.o
 obj-$(CONFIG_SCSI_GENERIC_NCR5380) += g_NCR5380.o
-obj-$(CONFIG_SCSI_NCR53C406A)  += NCR53c406a.o
 obj-$(CONFIG_SCSI_NCR_D700)+= 53c700.o NCR_D700.o
 obj-$(CONFIG_SCSI_NCR_Q720)+= NCR_Q720_mod.o
 obj-$(CONFIG_SCSI_SYM53C416)   += sym53c416.o
diff --git a/drivers/scsi/NCR53c406a.c b/drivers/scsi/NCR53c406a.c
deleted file mode 100644
index 44b09870bf51..
--- a/drivers/scsi/NCR53c406a.c
+++ /dev/null
@@ -1,1090 +0,0 @@
-/* 
- *  NCR53c406.c
- *  Low-level SCSI driver for NCR53c406a chip.
- *  Copyright (C) 1994, 1995, 1996 Normunds Saumanis (normu...@fi.ibm.com)
- * 
- *  LILO command line usage: ncr53c406a=[,[,]]
- *  Specify IRQ = 0 for non-interrupt driven mode.
- *  FASTPIO = 1 for fast pio mode, 0 for slow mode.
- *
- *  This program is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License as published by the
- *  Free Software Foundation; either version 2, or (at your option) any
- *  later version.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  General Public License for more details.
- *
- */
-
-#define NCR53C406A_DEBUG 0
-#define VERBOSE_NCR53C406A_DEBUG 0
-
-/* Set this to 1 for PIO mode (recommended) or to 0 for DMA mode */
-#define USE_PIO 1
-
-#define USE_BIOS 0
-   /* #define BIOS_ADDR 0xD8000 *//* define this 
if autoprobe fails */
-   /* #define PORT_BASE 0x330 *//* define this if 
autoprobe fails */
-   /* #define IRQ_LEV   0  *//* define this if 
autoprobe fails */
-#define DMA_CHAN  5/* this is ignored if DMA is disabled */
-
-/* Set this to 0 if you encounter kernel lockups while transferring 
- * data in PIO mode */
-#define USE_FAST_PIO 1
-
-/* = End of user configurable parameters = */
-
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include "scsi.h"
-#include 
-
-/* = */
-
-#define WATCHDOG 500
-
-#define SYNC_MODE 0/* Synchronous transfer mode */
-
-#ifdef DEBUG
-#undef NCR53C406A_DEBUG
-#define NCR53C406A_DEBUG 1
-#endif
-
-#if USE_PIO
-#define USE_DMA 0
-#else
-#define USE_DMA 1
-#endif
-
-/* Default configuration */
-#define C1_IMG   0x07  /* ID=7 */
-#define C2_IMG   0x48  /* FE SCSI2 */
-#if USE_DMA
-#define C3_IMG   0x21  /* CDB TE */
-#else
-#define C3_IMG   0x20  /* CDB */
-#endif
-#define C4_IMG   0x04  /* ANE */
-#define C5_IMG   0xb6  /* AA PI SIE POL */
-
-#define REG0 (outb(C4_IMG, CONFIG4))
-#define REG1 (outb(C5_IMG, CONFIG5))
-
-#if NCR53C406A_DEBUG
-#define DEB(x) x
-#else
-#define DEB(x)
-#endif
-
-#if VERBOSE_NCR53C406A_DEBUG
-#define VDEB(x) x
-#else
-#define VDEB(x)
-#endif
-
-#define LOAD_DMA_COUNT(count) \
-  outb(count & 0xff, TC_LSB); \
-  outb((count >> 8) & 0xff, TC_MSB); \
-  outb((count >> 16) & 0xff, TC_HIGH);
-
-/* Chip commands */
-#define DMA_OP   0x80
-
-#define SCSI_NOP 0x00
-#define FLUSH_FIFO   0x01
-#define CHIP_RESET   0x02
-#define SCSI_RESET   0x03
-#define RESELECT 0x40
-#define SELECT_NO_AT

remove obsolete drivers and scsi_module.c V2

2018-03-19 Thread Christoph Hellwig
Hi all,

this series removes the obsolete scsi_module.c infratructure that
has been obsolete for 15 years, and the remaining drivers that depend
on them.

Changes since V1:
 - drop already merged patches
 - convert mvme147 to new-style probing instead of removing it


[PATCH 3/6] scsi: remove the fdomain and fdomain_cs drivers

2018-03-19 Thread Christoph Hellwig
These drivers haven't seen any recent bug fixing and are two of the last
drivers using the scsi_module.c infrastruture that has been deprecated
15 years ago.

Signed-off-by: Christoph Hellwig 
---
 MAINTAINERS|6 -
 arch/powerpc/configs/c2k_defconfig |1 -
 drivers/scsi/Kconfig   |   20 -
 drivers/scsi/Makefile  |1 -
 drivers/scsi/fdomain.c | 1783 
 drivers/scsi/fdomain.h |   24 -
 drivers/scsi/pcmcia/Kconfig|9 -
 drivers/scsi/pcmcia/Makefile   |2 -
 drivers/scsi/pcmcia/fdomain_core.c |2 -
 drivers/scsi/pcmcia/fdomain_stub.c |  209 -
 10 files changed, 2057 deletions(-)
 delete mode 100644 drivers/scsi/fdomain.c
 delete mode 100644 drivers/scsi/fdomain.h
 delete mode 100644 drivers/scsi/pcmcia/fdomain_core.c
 delete mode 100644 drivers/scsi/pcmcia/fdomain_stub.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 36eb73238cf5..ccde214bb82d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5842,12 +5842,6 @@ F:   tools/testing/selftests/futex/
 F: tools/perf/bench/futex*
 F: Documentation/*futex*
 
-FUTURE DOMAIN TMC-16x0 SCSI DRIVER (16-bit)
-M: Rik Faith 
-L: linux-scsi@vger.kernel.org
-S: Odd Fixes (e.g., new signatures)
-F: drivers/scsi/fdomain.*
-
 GCC PLUGINS
 M: Kees Cook 
 R: Emese Revfy 
diff --git a/arch/powerpc/configs/c2k_defconfig 
b/arch/powerpc/configs/c2k_defconfig
index 4bb832a41d55..6c1196b0f81e 100644
--- a/arch/powerpc/configs/c2k_defconfig
+++ b/arch/powerpc/configs/c2k_defconfig
@@ -184,7 +184,6 @@ CONFIG_MEGARAID_NEWGEN=y
 CONFIG_MEGARAID_MM=m
 CONFIG_MEGARAID_MAILBOX=m
 CONFIG_MEGARAID_SAS=m
-CONFIG_SCSI_FUTURE_DOMAIN=m
 CONFIG_SCSI_GDTH=m
 CONFIG_SCSI_IPS=m
 CONFIG_SCSI_INITIO=m
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index b18dfa1c14a1..117c2fb41b77 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -640,26 +640,6 @@ config SCSI_DMX3191D
  To compile this driver as a module, choose M here: the
  module will be called dmx3191d.
 
-config SCSI_FUTURE_DOMAIN
-   tristate "Future Domain 16xx SCSI/AHA-2920A support"
-   depends on (ISA || PCI) && SCSI
-   select CHECK_SIGNATURE
-   ---help---
- This is support for Future Domain's 16-bit SCSI host adapters
- (TMC-1660/1680, TMC-1650/1670, TMC-3260, TMC-1610M/MER/MEX) and
- other adapters based on the Future Domain chipsets (Quantum
- ISA-200S, ISA-250MG; Adaptec AHA-2920A; and at least one IBM board).
- It is explained in section 3.7 of the SCSI-HOWTO, available from
- .
-
- NOTE: Newer Adaptec AHA-2920C boards use the Adaptec AIC-7850 chip
- and should use the aic7xxx driver ("Adaptec AIC7xxx chipset SCSI
- controller support"). This Future Domain driver works with the older
- Adaptec AHA-2920A boards with a Future Domain chip on them.
-
- To compile this driver as a module, choose M here: the
- module will be called fdomain.
-
 config SCSI_GDTH
tristate "Intel/ICP (former GDT SCSI Disk Array) RAID Controller 
support"
depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 46f1c1033f0e..77bb0017bb02 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -74,7 +74,6 @@ obj-$(CONFIG_SCSI_AIC94XX)+= aic94xx/
 obj-$(CONFIG_SCSI_PM8001)  += pm8001/
 obj-$(CONFIG_SCSI_ISCI)+= isci/
 obj-$(CONFIG_SCSI_IPS) += ips.o
-obj-$(CONFIG_SCSI_FUTURE_DOMAIN)+= fdomain.o
 obj-$(CONFIG_SCSI_GENERIC_NCR5380) += g_NCR5380.o
 obj-$(CONFIG_SCSI_NCR53C406A)  += NCR53c406a.o
 obj-$(CONFIG_SCSI_NCR_D700)+= 53c700.o NCR_D700.o
diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c
deleted file mode 100644
index ebbe5a3e665d..
--- a/drivers/scsi/fdomain.c
+++ /dev/null
@@ -1,1783 +0,0 @@
-/* fdomain.c -- Future Domain TMC-16x0 SCSI driver
- * Created: Sun May  3 18:53:19 1992 by fa...@cs.unc.edu
- * Revised: Mon Dec 28 21:59:02 1998 by fa...@acm.org
- * Author: Rickard E. Faith, fa...@cs.unc.edu
- * Copyright 1992-1996, 1998 Rickard E. Faith (fa...@acm.org)
- * Shared IRQ supported added 7/7/2001  Alan Cox 
-
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
-
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
-
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave

[PATCH 5/6] scsi: remove the sym53c416 driver

2018-03-19 Thread Christoph Hellwig
This driver hasn't seen any recent bug fixing and is one of the last
drivers using the scsi_module.c infrastruture that has been deprecated
15 years ago.

Signed-off-by: Christoph Hellwig 
---
 Documentation/scsi/scsi-parameters.txt |   3 -
 drivers/scsi/Kconfig   |  18 -
 drivers/scsi/Makefile  |   1 -
 drivers/scsi/sym53c416.c   | 844 -
 drivers/scsi/sym53c416.h   |  33 --
 5 files changed, 899 deletions(-)
 delete mode 100644 drivers/scsi/sym53c416.c
 delete mode 100644 drivers/scsi/sym53c416.h

diff --git a/Documentation/scsi/scsi-parameters.txt 
b/Documentation/scsi/scsi-parameters.txt
index 8f7be8a05642..2dc7f11179d1 100644
--- a/Documentation/scsi/scsi-parameters.txt
+++ b/Documentation/scsi/scsi-parameters.txt
@@ -108,9 +108,6 @@ parameters may be changed at runtime by the command
st= [HW,SCSI] SCSI tape parameters (buffers, etc.)
See Documentation/scsi/st.txt.
 
-   sym53c416=  [HW,SCSI]
-   See header of drivers/scsi/sym53c416.c.
-
tmscsim=[HW,SCSI]
See comment before function dc390_setup() in
drivers/scsi/tmscsim.c.
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 9fa0cfd5a068..11e89e56b865 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -1172,24 +1172,6 @@ config SCSI_SIM710
 
  It currently supports Compaq EISA cards and NCR MCA cards
 
-config SCSI_SYM53C416
-   tristate "Symbios 53c416 SCSI support"
-   depends on ISA && SCSI
-   ---help---
- This is support for the sym53c416 SCSI host adapter, the SCSI
- adapter that comes with some HP scanners. This driver requires that
- the sym53c416 is configured first using some sort of PnP
- configuration program (e.g. isapnp) or by a PnP aware BIOS. If you
- are using isapnp then you need to compile this driver as a module
- and then load it using insmod after isapnp has run. The parameters
- of the configured card(s) should be passed to the driver. The format
- is:
-
- insmod sym53c416 sym53c416=, [sym53c416_1=,]
-
- To compile this driver as a module, choose M here: the
- module will be called sym53c416.
-
 config SCSI_DC395x
tristate "Tekram DC395(U/UW/F) and DC315(U) SCSI support"
depends on PCI && SCSI
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 192a58d7d9d9..d5135efbf9cd 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -77,7 +77,6 @@ obj-$(CONFIG_SCSI_IPS)+= ips.o
 obj-$(CONFIG_SCSI_GENERIC_NCR5380) += g_NCR5380.o
 obj-$(CONFIG_SCSI_NCR_D700)+= 53c700.o NCR_D700.o
 obj-$(CONFIG_SCSI_NCR_Q720)+= NCR_Q720_mod.o
-obj-$(CONFIG_SCSI_SYM53C416)   += sym53c416.o
 obj-$(CONFIG_SCSI_QLOGIC_FAS)  += qlogicfas408.o   qlogicfas.o
 obj-$(CONFIG_PCMCIA_QLOGIC)+= qlogicfas408.o
 obj-$(CONFIG_SCSI_QLOGIC_1280) += qla1280.o 
diff --git a/drivers/scsi/sym53c416.c b/drivers/scsi/sym53c416.c
deleted file mode 100644
index e68bcdc75bc3..
--- a/drivers/scsi/sym53c416.c
+++ /dev/null
@@ -1,844 +0,0 @@
-/*
- *  sym53c416.c
- *  Low-level SCSI driver for sym53c416 chip.
- *  Copyright (C) 1998 Lieven Willems (lw_li...@hotmail.com)
- * 
- *  Changes : 
- * 
- *  Marcelo Tosatti  : Added io_request_lock locking
- *  Alan Cox  : Cleaned up code formatting
- *  Fixed an irq locking bug
- *  Added ISAPnP support
- *  Bjoern A. Zeeb  : Initial irq locking updates
- *   Added another card with ISAPnP support
- * 
- *  LILO command line usage: sym53c416=[,]
- *
- *  This program is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License as published by the
- *  Free Software Foundation; either version 2, or (at your option) any
- *  later version.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  General Public License for more details.
- *
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include "scsi.h"
-#include 
-#include "sym53c416.h"
-
-#define VERSION_STRING"Version 1.0.0-ac"
-
-#define TC_LOW   0x00 /* Transfer counter low*/
-#define TC_MID   0x01 /* Transfer counter mid*/
-#define SCSI_FIFO0x02 /* SCSI FIFO register  */
-#define COMMAND_REG  0x03 /* Command Register*/
-#define STATUS_REG   0x04 /* Status Register (READ)  */
-#define DEST_BUS_ID  0x04 /* Destination Bus ID (WRITE)  */
-#define INT_REG  0x05 

[PATCH 1/6] esas2r: remove initialization / cleanup dead wood

2018-03-19 Thread Christoph Hellwig
esas2r has been converted to hotplug style initialization long ago, but
kept various remant of the old-style scsi_module.c initialization around.
Remove those.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/esas2r/esas2r.h  |  2 --
 drivers/scsi/esas2r/esas2r_init.c | 21 
 drivers/scsi/esas2r/esas2r_main.c | 72 +++
 3 files changed, 4 insertions(+), 91 deletions(-)

diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h
index 1da6407ee142..858c3b33db78 100644
--- a/drivers/scsi/esas2r/esas2r.h
+++ b/drivers/scsi/esas2r/esas2r.h
@@ -962,7 +962,6 @@ struct esas2r_adapter {
  * Function Declarations
  * SCSI functions
  */
-int esas2r_release(struct Scsi_Host *);
 const char *esas2r_info(struct Scsi_Host *);
 int esas2r_write_params(struct esas2r_adapter *a, struct esas2r_request *rq,
struct esas2r_sas_nvram *data);
@@ -984,7 +983,6 @@ int esas2r_target_reset(struct scsi_cmnd *cmd);
 /* Internal functions */
 int esas2r_init_adapter(struct Scsi_Host *host, struct pci_dev *pcid,
int index);
-int esas2r_cleanup(struct Scsi_Host *host);
 int esas2r_read_fw(struct esas2r_adapter *a, char *buf, long off, int count);
 int esas2r_write_fw(struct esas2r_adapter *a, const char *buf, long off,
int count);
diff --git a/drivers/scsi/esas2r/esas2r_init.c 
b/drivers/scsi/esas2r/esas2r_init.c
index 5b14dd29b764..9dffcb28c9b7 100644
--- a/drivers/scsi/esas2r/esas2r_init.c
+++ b/drivers/scsi/esas2r/esas2r_init.c
@@ -661,27 +661,6 @@ void esas2r_kill_adapter(int i)
}
 }
 
-int esas2r_cleanup(struct Scsi_Host *host)
-{
-   struct esas2r_adapter *a;
-   int index;
-
-   if (host == NULL) {
-   int i;
-
-   esas2r_debug("esas2r_cleanup everything");
-   for (i = 0; i < MAX_ADAPTERS; i++)
-   esas2r_kill_adapter(i);
-   return -1;
-   }
-
-   esas2r_debug("esas2r_cleanup called for host %p", host);
-   a = (struct esas2r_adapter *)host->hostdata;
-   index = a->index;
-   esas2r_kill_adapter(index);
-   return index;
-}
-
 int esas2r_suspend(struct pci_dev *pdev, pm_message_t state)
 {
struct Scsi_Host *host = pci_get_drvdata(pdev);
diff --git a/drivers/scsi/esas2r/esas2r_main.c 
b/drivers/scsi/esas2r/esas2r_main.c
index 4eb14301a497..e07eac5be087 100644
--- a/drivers/scsi/esas2r/esas2r_main.c
+++ b/drivers/scsi/esas2r/esas2r_main.c
@@ -235,7 +235,6 @@ static struct scsi_host_template driver_template = {
.module = THIS_MODULE,
.show_info  = esas2r_show_info,
.name   = ESAS2R_LONGNAME,
-   .release= esas2r_release,
.info   = esas2r_info,
.ioctl  = esas2r_ioctl,
.queuecommand   = esas2r_queuecommand,
@@ -520,44 +519,16 @@ static int esas2r_probe(struct pci_dev *pcid,
 
 static void esas2r_remove(struct pci_dev *pdev)
 {
-   struct Scsi_Host *host;
-   int index;
-
-   if (pdev == NULL) {
-   esas2r_log(ESAS2R_LOG_WARN, "esas2r_remove pdev==NULL");
-   return;
-   }
-
-   host = pci_get_drvdata(pdev);
-
-   if (host == NULL) {
-   /*
-* this can happen if pci_set_drvdata was already called
-* to clear the host pointer.  if this is the case, we
-* are okay; this channel has already been cleaned up.
-*/
-
-   return;
-   }
+   struct Scsi_Host *host = pci_get_drvdata(pdev);
+   struct esas2r_adapter *a = (struct esas2r_adapter *)host->hostdata;
 
esas2r_log_dev(ESAS2R_LOG_INFO, &(pdev->dev),
   "esas2r_remove(%p) called; "
   "host:%p", pdev,
   host);
 
-   index = esas2r_cleanup(host);
-
-   if (index < 0)
-   esas2r_log_dev(ESAS2R_LOG_WARN, &(pdev->dev),
-  "unknown host in %s",
-  __func__);
-
+   esas2r_kill_adapter(a->index);
found_adapters--;
-
-   /* if this was the last adapter, clean up the rest of the driver */
-
-   if (found_adapters == 0)
-   esas2r_cleanup(NULL);
 }
 
 static int __init esas2r_init(void)
@@ -638,30 +609,7 @@ static int __init esas2r_init(void)
for (i = 0; i < MAX_ADAPTERS; i++)
esas2r_adapters[i] = NULL;
 
-   /* initialize */
-
-   driver_template.module = THIS_MODULE;
-
-   if (pci_register_driver(&esas2r_pci_driver) != 0)
-   esas2r_log(ESAS2R_LOG_CRIT, "pci_register_driver FAILED");
-   else
-   esas2r_log(ESAS2R_LOG_INFO, "pci_register_driver() OK");
-
-   if (!found_adapters) {
-   pci_unregister_driver(&esas2r_pci_driver);
-  

[PATCH] scsi: unexport scsi_host_set_state

2018-03-19 Thread Christoph Hellwig
This function is only used inside the SCSI midlayer, so remove the
export for it.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/hosts.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index a0a7e4ff255c..0a5362822ed6 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -154,7 +154,6 @@ int scsi_host_set_state(struct Scsi_Host *shost, enum 
scsi_host_state state)
 scsi_host_state_name(state)));
return -EINVAL;
 }
-EXPORT_SYMBOL(scsi_host_set_state);
 
 /**
  * scsi_remove_host - remove a scsi host
-- 
2.14.2



Re: [PATCH v4] m68k/amiga - Amiga Zorro NCR53C9x boards: new zorro_esp.c

2018-03-19 Thread Michael Schmitz
Hi Kars,

thanks, I've fixed that typo.

Cheers,

Michael


Am 19.03.2018 um 03:51 schrieb Kars de Jong:
> Hi Michael,
> 
> 2018-03-17 2:16 GMT+01:00 Michael Schmitz :
>> From: Michael Schmitz 
>>
>> New combined SCSI driver for all ESP based Zorro SCSI boards for
>> m68k Amiga.
>>
>> Code largely based on board specific parts of the old drivers (blz1230.c,
>> blz2060.c, cyberstorm.c, cyberstormII.c, fastlane.c which were removed
>> after the 2.6 kernel series for lack of maintenance) with contributions
>> by Tuomas Vainikka (TCQ bug tests and workaround) and Finn Thain (TCQ
>> bugfix by use of PIO in extended message in transfer).
>>
>> New Kconfig option and Makefile entries for new Amiga Zorro ESP SCSI
>> driver included in this patch.
>>
>> Use DMA transfers wherever possible, with board-specific DMA set-up
>> functions copied from the old driver code. Three byte reselection messages
>> do appear to cause DMA timeouts. So wire up a PIO transfer routine for
>> these instead. esp_reselect_with_tag explicitly sets esp->cmd_block_dma as
>> target address for the message bytes but PIO requires a virtual address.
>> Substiute kernel virtual address esp->cmd_block in PIO transfer call if
>> DMA address is esp->cmd_block_dma and phase is message in.
>>
>> PIO code taken from mac_esp.c where the reselection timeout issue was
>> debugged and fixed first, with minor macro and function rename.
>>
>> Signed-off-by: Michael Schmitz 
>> Reviewed-by: Finn Thain 
>> ---
>>
>> Changes since v1:
>>
>> Fixed issues raised by Finn Thain in initial code review:
>>
>> - use KBUILD_MODNAME for driver name string.
>> - use pr_fmt() for pr_* format prefix.
>> - clean up DMA error reporting: clear error flag before each DMA
>>   operation, set error flag on PIO error. Don't test phase in dma_err hook.
>> - change confusing comment about semantics of read flag, add comments
>>   indicating DMA direction to DMA setup hooks.
>> - drop spurious braces around switch clauses.
>> - lift cfreq setting out of ID switch clauses.
>> - fix indentation.
>> - fix error codes on probe fail.
>> - drop check for board ID when unmapping DMA regs in error handling:
>>   the ioaddr > 0xff test already catches all cases where the DMA
>>   registers were ioremapped.
>> - dynamically alloc zorro_private_data.
>> - fix use of driver_data field (don't mix host and zorro_esp_priv
>>   pointers). Note: require esp pointer in zorro_esp_priv to find host
>>   pointer!
>> - back out phase bits changes to pio_cmd !write branch introduced
>>   to cope with ESP SELAS command. We don't use that code so keep
>>   it in sync with Finn's version.
>> - use esp_ops.dma_length_limit() to limit transfer size. After review
>>   of old driver code, use 0xff max transfer size throughout.
>>
>> Fixed issues raised by Geert Uytterhoven:
>>
>> - dynamically alloc zorro_private_data, store as device drvdata.
>> - store ctrl_data for CyberStormI in driver private data.
>> - use dma_sync_single_for_device() instead of cache_push/clear.
>> - handle case of duplicate board identity - check whether board is
>>   Zorro III or Zorro II (use ROM resource data for this). Also fix
>>   up DMA mask for Zorro II boards to 32 bits (these are really CPU
>>   expansion slot boards).
>> - remove zorro3 field from driver_data struct (now in private data).
>> - add braces around ambiguous if - else construct.
>> - use named structs instead of array for board config data.
>> - use scsi_option driver data flag for boards with optional ESP.
>>
>> Other improvements and bugfixes
>>
>> - fix Zorro device table error (duplicate ID used, also raised
>>   by Kars de Jong).
>> - error code fixup in error handling path.
>> - add separate DMA setup for Blizzard 1230 II board.
>> - add support for Cyberstorm II board.
>> - add register structs and DMA setup for Zorro III Fastlane board,
>>   following logic from old fastlane.c driver. Wire up Fastlane DMA
>>   and interrupt status routines, map the necessary low 24 bit board
>>   address space used for DMA target address setting. Clean up DMA
>>   register space ioremap() branch for Zorro III boards (currently
>>   Fastlane only) to end confusion about what to do in error recovery.
>> - use esp_ops.fastlane_esp_dma_invalidate() on Fastlane (and skip
>>   fastlane_esp_reset_dma() in DMA setup).
>> - credit Tuomas Vainikka for contributing Blizzard 1230 code (and
>>   testing).
>> - clarify comment about unsupported Oktagon SCSI board.
>> - remove unused const definitions carried over from old driver.
>>
>> Changes since v2:
>>
>> - add SPDX-License-Identifier.
>> - remove unused ratelimit.h.
>> - drop phys_to_virt() in PIO transfer routine, after ensuring PIO is only
>>   used for message in transfers to esp->command_block. This obviates any
>>   need for finding the virtual address corresponding to a DMA handle.
>> - drop BUG_ON(!(cmd & ESP_CMD_DMA)) assertion in DMA setup. Short of changes
>>   to the core ESP driver, this can never trigg