Re: [PATCH 0/3] target: Add TARGET_SCF_LOOKUP_LUN_FROM_TAG support

2017-06-06 Thread Madhani, Himanshu

> On Jun 3, 2017, at 3:10 PM, Nicholas A. Bellinger  
> wrote:
> 
> From: Nicholas Bellinger 
> 
> Hi Himanshu + Quinn,
> 
> Here is a small series to introduce proper percpu se_lun->lun_ref
> counting for TMR, and add common code in target_submit_tmr() to
> do tag lookup for unpacked_lun in order to drop the original
> driver specific lookup within __qlt_24xx_handle_abts().
> 
> It's rather straight-forward, so review and test as a v4.13 item.
> 
> Thanks!
> 
> Nicholas Bellinger (3):
>  target: Add support for TMR percpu reference counting
>  target: Add TARGET_SCF_LOOKUP_LUN_FROM_TAG support for ABORT_TASK
>  qla2xxx: Convert QLA_TGT_ABTS to TARGET_SCF_LOOKUP_LUN_FROM_TAG
> 
> drivers/scsi/qla2xxx/qla_target.c  | 39 ++-
> drivers/scsi/qla2xxx/tcm_qla2xxx.c |  4 ++-
> drivers/target/target_core_device.c| 14 ++---
> drivers/target/target_core_transport.c | 56 --
> include/target/target_core_base.h  |  3 +-
> 5 files changed, 71 insertions(+), 45 deletions(-)
> 
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe target-devel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Series looks good. 

Acked-by: Himanshu Madhani 

Thanks,
- Himanshu



Re: [PATCH v2 00/17] lpfc updates for 11.4.0.0

2017-06-06 Thread James Smart

On 6/5/2017 6:13 PM, Martin K. Petersen wrote:


Hi James,


This patch set provides a number of bug fixes, code cleanups, and
error handling in lpfc.

The patches were cut against the Martin's 4.12/scsi-fixes tree.  There
are no outside dependencies. The patches should merge via Martin's
tree.


We're approaching rc5 and there are several hundred-liners in this
submission. The EQ delay logic patch in particular looks like a feature
rather than a bug fix.

How many of these are critical to get into 4.12 vs. 4.13?




What can be excluded: patch 04 and 16.

All others I'd like to get in 4.12

-- james




Re: [PATCH 1/3] target: Add support for TMR percpu reference counting

2017-06-06 Thread Tran, Quinn
Looks good.

Regards,
Quinn Tran

-Original Message-
From: Nicholas Bellinger 
Date: Saturday, June 3, 2017 at 3:10 PM
To: target-devel 
Cc: linux-scsi , lkml 
, Nicholas Bellinger , 
"Madhani, Himanshu" , "Tran, Quinn" 
, Mike Christie , Hannes Reinecke 
, Christoph Hellwig 
Subject: [PATCH 1/3] target: Add support for TMR percpu reference counting

From: Nicholas Bellinger 

This patch introduces TMR percpu reference counting using
se_lun->lun_ref in transport_lookup_tmr_lun(), following
how existing non TMR per se_lun reference counting works
within transport_lookup_cmd_lun().

It also adds explicit transport_lun_remove_cmd() calls to
drop the reference in the three tmr related locations that
invoke transport_cmd_check_stop_to_fabric();

   - target_tmr_work() during normal ->queue_tm_rsp()
   - target_complete_tmr_failure() during error ->queue_tm_rsp()
   - transport_generic_handle_tmr() during early failure

Also, note the exception paths in transport_generic_free_cmd()
and transport_cmd_finish_abort() already check SCF_SE_LUN_CMD,
and will invoke transport_lun_remove_cmd() when necessary.

Cc: Himanshu Madhani 
Cc: Quinn Tran 
Cc: Mike Christie 
Cc: Hannes Reinecke 
Cc: Christoph Hellwig 
Signed-off-by: Nicholas Bellinger 
---
 drivers/target/target_core_device.c| 14 ++
 drivers/target/target_core_transport.c |  3 +++
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/target/target_core_device.c 
b/drivers/target/target_core_device.c
index 8f0e0e3..11c80c4 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -168,11 +168,20 @@ int transport_lookup_tmr_lun(struct se_cmd *se_cmd, 
u64 unpacked_lun)
rcu_read_lock();
deve = target_nacl_find_deve(nacl, unpacked_lun);
if (deve) {
-   se_cmd->se_lun = rcu_dereference(deve->se_lun);
se_lun = rcu_dereference(deve->se_lun);
+
+   if (!percpu_ref_tryget_live(_lun->lun_ref)) {
+   se_lun = NULL;
+   goto out_unlock;
+   }
+
+   se_cmd->se_lun = rcu_dereference(deve->se_lun);
se_cmd->pr_res_key = deve->pr_res_key;
se_cmd->orig_fe_lun = unpacked_lun;
+   se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD;
+   se_cmd->lun_ref_active = true;
}
+out_unlock:
rcu_read_unlock();
 
if (!se_lun) {
@@ -182,9 +191,6 @@ int transport_lookup_tmr_lun(struct se_cmd *se_cmd, u64 
unpacked_lun)
unpacked_lun);
return -ENODEV;
}
-   /*
-* XXX: Add percpu se_lun->lun_ref reference count for TMR
-*/
se_cmd->se_dev = rcu_dereference_raw(se_lun->lun_se_dev);
se_tmr->tmr_dev = rcu_dereference_raw(se_lun->lun_se_dev);
 
diff --git a/drivers/target/target_core_transport.c 
b/drivers/target/target_core_transport.c
index f16a789..83bfc97 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1588,6 +1588,7 @@ static void target_complete_tmr_failure(struct 
work_struct *work)
se_cmd->se_tmr_req->response = TMR_LUN_DOES_NOT_EXIST;
se_cmd->se_tfo->queue_tm_rsp(se_cmd);
 
+   transport_lun_remove_cmd(se_cmd);
transport_cmd_check_stop_to_fabric(se_cmd);
 }
 
@@ -3199,6 +3200,7 @@ static void target_tmr_work(struct work_struct *work)
cmd->se_tfo->queue_tm_rsp(cmd);
 
 check_stop:
+   transport_lun_remove_cmd(cmd);
transport_cmd_check_stop_to_fabric(cmd);
 }
 
@@ -3221,6 +3223,7 @@ int transport_generic_handle_tmr(
pr_warn_ratelimited("handle_tmr caught CMD_T_ABORTED TMR %d"
"ref_tag: %llu tag: %llu\n", cmd->se_tmr_req->function,
cmd->se_tmr_req->ref_task_tag, cmd->tag);
+   transport_lun_remove_cmd(cmd);
transport_cmd_check_stop_to_fabric(cmd);
return 0;
}
-- 
1.9.1





Re: [PATCH 2/3] target: Add TARGET_SCF_LOOKUP_LUN_FROM_TAG support for ABORT_TASK

2017-06-06 Thread Tran, Quinn
Looks Good.

Regards,
Quinn Tran

-Original Message-
From: Nicholas Bellinger 
Date: Saturday, June 3, 2017 at 3:10 PM
To: target-devel 
Cc: linux-scsi , lkml 
, Nicholas Bellinger , 
"Madhani, Himanshu" , "Tran, Quinn" 
, Mike Christie , Hannes Reinecke 
, Christoph Hellwig 
Subject: [PATCH 2/3] target: Add TARGET_SCF_LOOKUP_LUN_FROM_TAG support for 
ABORT_TASK

From: Nicholas Bellinger 

This patch introduces support in target_submit_tmr() for locating a
unpacked_lun from an existing se_cmd->tag during ABORT_TASK.

When TARGET_SCF_LOOKUP_LUN_FROM_TAG is set, target_submit_tmr()
will do the extra lookup via target_lookup_lun_from_tag() and
subsequently invoke transport_lookup_tmr_lun() so a proper
percpu se_lun->lun_ref is taken before workqueue dispatch into
se_device->tmr_wq happens.

Aside from the extra target_lookup_lun_from_tag(), the existing
code-path remains unchanged.

Cc: Himanshu Madhani 
Cc: Quinn Tran 
Cc: Mike Christie 
Cc: Hannes Reinecke 
Cc: Christoph Hellwig 
Signed-off-by: Nicholas Bellinger 
---
 drivers/target/target_core_transport.c | 53 
--
 include/target/target_core_base.h  |  3 +-
 2 files changed, 46 insertions(+), 10 deletions(-)

diff --git a/drivers/target/target_core_transport.c 
b/drivers/target/target_core_transport.c
index 83bfc97..dbb8101 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1592,6 +1592,29 @@ static void target_complete_tmr_failure(struct 
work_struct *work)
transport_cmd_check_stop_to_fabric(se_cmd);
 }
 
+static bool target_lookup_lun_from_tag(struct se_session *se_sess, u64 tag,
+  u64 *unpacked_lun)
+{
+   struct se_cmd *se_cmd;
+   unsigned long flags;
+   bool ret = false;
+
+   spin_lock_irqsave(_sess->sess_cmd_lock, flags);
+   list_for_each_entry(se_cmd, _sess->sess_cmd_list, se_cmd_list) {
+   if (se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)
+   continue;
+
+   if (se_cmd->tag == tag) {
+   *unpacked_lun = se_cmd->orig_fe_lun;
+   ret = true;
+   break;
+   }
+   }
+   spin_unlock_irqrestore(_sess->sess_cmd_lock, flags);
+
+   return ret;
+}
+
 /**
  * target_submit_tmr - lookup unpacked lun and submit uninitialized se_cmd
  * for TMR CDBs
@@ -1639,19 +1662,31 @@ int target_submit_tmr(struct se_cmd *se_cmd, struct 
se_session *se_sess,
core_tmr_release_req(se_cmd->se_tmr_req);
return ret;
}
+   /*
+* If this is ABORT_TASK with no explicit fabric provided LUN,
+* go ahead and search active session tags for a match to figure
+* out unpacked_lun for the original se_cmd.
+*/
+   if (tm_type == TMR_ABORT_TASK && (flags & 
TARGET_SCF_LOOKUP_LUN_FROM_TAG)) {
+   if (!target_lookup_lun_from_tag(se_sess, tag, _lun))
+   goto failure;
+   }
 
ret = transport_lookup_tmr_lun(se_cmd, unpacked_lun);
-   if (ret) {
-   /*
-* For callback during failure handling, push this work off
-* to process context with TMR_LUN_DOES_NOT_EXIST status.
-*/
-   INIT_WORK(_cmd->work, target_complete_tmr_failure);
-   schedule_work(_cmd->work);
-   return 0;
-   }
+   if (ret)
+   goto failure;
+
transport_generic_handle_tmr(se_cmd);
return 0;
+
+   /*
+* For callback during failure handling, push this work off
+* to process context with TMR_LUN_DOES_NOT_EXIST status.
+*/
+failure:
+   INIT_WORK(_cmd->work, target_complete_tmr_failure);
+   schedule_work(_cmd->work);
+   return 0;
 }
 EXPORT_SYMBOL(target_submit_tmr);
 
diff --git a/include/target/target_core_base.h 
b/include/target/target_core_base.h
index db2c7b3..a3af69f 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -188,7 +188,8 @@ enum target_sc_flags_table {
TARGET_SCF_BIDI_OP  = 0x01,
TARGET_SCF_ACK_KREF = 0x02,
TARGET_SCF_UNKNOWN_SIZE = 0x04,
-   TARGET_SCF_USE_CPUID= 0x08,
+   TARGET_SCF_USE_CPUID= 0x08,
+   

Re: [PATCH 3/3] qla2xxx: Convert QLA_TGT_ABTS to TARGET_SCF_LOOKUP_LUN_FROM_TAG

2017-06-06 Thread Tran, Quinn
Nic,

Thanks.  It looks good.

Regards,
Quinn Tran

-Original Message-
From: Nicholas Bellinger 
Date: Saturday, June 3, 2017 at 3:10 PM
To: target-devel 
Cc: linux-scsi , lkml 
, Nicholas Bellinger , 
"Madhani, Himanshu" , "Tran, Quinn" 
, Mike Christie , Hannes Reinecke 
, Christoph Hellwig 
Subject: [PATCH 3/3] qla2xxx: Convert QLA_TGT_ABTS to 
TARGET_SCF_LOOKUP_LUN_FROM_TAG

From: Nicholas Bellinger 

Following Himanshu's earlier patch to drop the redundant tag
lookup within __qlt_24xx_handle_abts(), go ahead and drop this
now QLA_TGT_ABTS can use TARGET_SCF_LOOKUP_LUN_FROM_TAG and
have target_submit_tmr() do this from common code.

Cc: Himanshu Madhani 
Cc: Quinn Tran 
Cc: Mike Christie 
Cc: Hannes Reinecke 
Cc: Christoph Hellwig 
Signed-off-by: Nicholas Bellinger 
---
 drivers/scsi/qla2xxx/qla_target.c  | 39 
+-
 drivers/scsi/qla2xxx/tcm_qla2xxx.c |  4 +++-
 2 files changed, 12 insertions(+), 31 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index 0e03ca2..401e245 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -1847,38 +1847,13 @@ static int __qlt_24xx_handle_abts(struct 
scsi_qla_host *vha,
struct abts_recv_from_24xx *abts, struct fc_port *sess)
 {
struct qla_hw_data *ha = vha->hw;
-   struct se_session *se_sess = sess->se_sess;
struct qla_tgt_mgmt_cmd *mcmd;
-   struct se_cmd *se_cmd;
-   u32 lun = 0;
int rc;
-   bool found_lun = false;
-   unsigned long flags;
-
-   spin_lock_irqsave(_sess->sess_cmd_lock, flags);
-   list_for_each_entry(se_cmd, _sess->sess_cmd_list, se_cmd_list) {
-   struct qla_tgt_cmd *cmd =
-   container_of(se_cmd, struct qla_tgt_cmd, se_cmd);
-   if (se_cmd->tag == abts->exchange_addr_to_abort) {
-   lun = cmd->unpacked_lun;
-   found_lun = true;
-   break;
-   }
-   }
-   spin_unlock_irqrestore(_sess->sess_cmd_lock, flags);
 
-   /* cmd not in LIO lists, look in qla list */
-   if (!found_lun) {
-   if (abort_cmd_for_tag(vha, abts->exchange_addr_to_abort)) {
-   /* send TASK_ABORT response immediately */
-   qlt_24xx_send_abts_resp(vha, abts, FCP_TMF_CMPL, false);
-   return 0;
-   } else {
-   ql_dbg(ql_dbg_tgt_mgt, vha, 0xf081,
-   "unable to find cmd in driver or LIO for tag 
0x%x\n",
-   abts->exchange_addr_to_abort);
-   return -ENOENT;
-   }
+   if (abort_cmd_for_tag(vha, abts->exchange_addr_to_abort)) {
+   /* send TASK_ABORT response immediately */
+   qlt_24xx_send_abts_resp(vha, abts, FCP_TMF_CMPL, false);
+   return 0;
}
 
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf00f,
@@ -1899,7 +1874,11 @@ static int __qlt_24xx_handle_abts(struct 
scsi_qla_host *vha,
mcmd->reset_count = vha->hw->chip_reset;
mcmd->tmr_func = QLA_TGT_ABTS;
 
-   rc = ha->tgt.tgt_ops->handle_tmr(mcmd, lun, mcmd->tmr_func,
+   /*
+* LUN is looked up by target-core internally based on the passed
+* abts->exchange_addr_to_abort tag.
+*/
+   rc = ha->tgt.tgt_ops->handle_tmr(mcmd, 0, mcmd->tmr_func,
abts->exchange_addr_to_abort);
if (rc != 0) {
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf052,
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c 
b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 7443e4e..75aeb9f 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -601,11 +601,13 @@ static int tcm_qla2xxx_handle_tmr(struct 
qla_tgt_mgmt_cmd *mcmd, uint32_t lun,
struct fc_port *sess = mcmd->sess;
struct se_cmd *se_cmd = >se_cmd;
int transl_tmr_func = 0;
+   int flags = TARGET_SCF_ACK_KREF;
 
switch (tmr_func) {
case QLA_TGT_ABTS:
pr_debug("%ld: ABTS received\n", sess->vha->host_no);
transl_tmr_func = TMR_ABORT_TASK;
+   flags |= TARGET_SCF_LOOKUP_LUN_FROM_TAG;
break;
case QLA_TGT_2G_ABORT_TASK:
pr_debug("%ld: 2G Abort Task received\n", sess->vha->host_no);
@@ -638,7 +640,7 @@ static int tcm_qla2xxx_handle_tmr(struct 

Re: next build: 113 warnings 0 failures (next/next-20170605)

2017-06-06 Thread Wolfram Sang

> >   2 drivers/i2c/i2c-stub.c:18:0: warning: "DEBUG" redefined
> 
> Caused by 6c42778780c4 ("i2c: stub: use pr_fmt"): "#define DEBUG"
> now conflicts with "ccflags-$(CONFIG_I2C_DEBUG_CORE) := -DDEBUG"
> in the Makefile.

I'll fix it tomorrow!



signature.asc
Description: PGP signature


Re: [PATCH 6/6] sd: add support for TCG OPAL self encrypting disks

2017-06-06 Thread Scott Bauer
On Tue, Jun 06, 2017 at 11:59:55AM +0200, Christoph Hellwig wrote:
> On Mon, Jun 05, 2017 at 03:15:31PM -0600, Scott Bauer wrote:
> > I'm not familiar at all with ATA, but I noticed there was no unlock from 
> > suspend support
> > in the series. Does ATA not have a way to determine if we're coming out of 
> > a suspend?
> 
> I don't know, and not having a test system with a OPAL capable driver
> and suspend support I could not even test the code.
> 
> > I see there are some power-ops in scsi/sd.c, if you do want to add it you 
> > can mabe toss a
> > 
> > if (sdkp->security)
> >opal_unlock_from_suspend(sdpk->opal_dev)
> > 
> > somewhere in the resume path? We handle null opal_devs and no unlock from 
> > suspend list
> > so calling it when nothing is set up is just a no-op.
> 
> Yeah, maybe.  We'll just need someone who could test it first.

I was given a sata drive that apparently has opal enabled on it. If it actually 
has opal
I can run some tests.


[PATCH] qla2xxx: Fix compile warning

2017-06-06 Thread Himanshu Madhani
Fixes following 0-day kernel build warnings

drivers/scsi/qla2xxx/qla_init.c:6407:50: warning: format '%lx' expects
argument of type 'long unsigned int', but argument 5 has type 'unsigned
int' [-Wformat=]
drivers/scsi/qla2xxx/qla_init.c:6709:50: warning: format '%lx'
expects argument of type 'long unsigned int', but argument 5 has
type 'unsigned int' [-Wformat=]

Fixes: b95b9452aacf ("scsi: qla2xxx: Fix crash due to mismatch mumber of Q-pair 
creation for Multi queue")
Signed-off-by: Himanshu Madhani 
Signed-off-by: Giridhar Malavali 
---
 drivers/scsi/qla2xxx/qla_init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 436968ad4484..730e7fe4344a 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -6404,7 +6404,7 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t 
*srisc_addr,
"-> template size %x bytes\n", dlen);
if (dlen > risc_size * sizeof(*dcode)) {
ql_log(ql_log_warn, vha, 0x0167,
-   "Failed fwdump template exceeds array by %lx bytes\n",
+   "Failed fwdump template exceeds array by %zx bytes\n",
(size_t)(dlen - risc_size * sizeof(*dcode)));
goto default_template;
}
@@ -6706,7 +6706,7 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t 
*srisc_addr)
"-> template size %x bytes\n", dlen);
if (dlen > risc_size * sizeof(*fwcode)) {
ql_log(ql_log_warn, vha, 0x0177,
-   "Failed fwdump template exceeds array by %lx bytes\n",
+   "Failed fwdump template exceeds array by %zx bytes\n",
(size_t)(dlen - risc_size * sizeof(*fwcode)));
goto default_template;
}
-- 
2.12.0



[PATCH v1] ibmvscsis: Use tpgt passed in by user

2017-06-06 Thread Bryant G. Ly
ibmvscsis always returned 0 for the tpg/tag, since it did not
parse the value passed in by the user.

When functions like ALUA members exports the value, it will
be incorrect because targetcli/rtslib starts the tpg numbering
at 1.

Signed-off-by: Bryant G. Ly 
Signed-off-by: Mike Christie 
---
 drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c 
b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
index 3571052..522d547 100644
--- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
+++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
@@ -3914,8 +3914,16 @@ static struct se_portal_group *ibmvscsis_make_tpg(struct 
se_wwn *wwn,
 {
struct ibmvscsis_tport *tport =
container_of(wwn, struct ibmvscsis_tport, tport_wwn);
+   u16 tpgt;
int rc;
 
+   if (strstr(name, "tpgt_") != name)
+   return ERR_PTR(-EINVAL);
+   rc = kstrtou16(name + 5, 0, );
+   if (rc)
+   return ERR_PTR(rc);
+   tport->tport_tpgt = tpgt;
+
tport->releasing = false;
 
rc = core_tpg_register(>tport_wwn, >se_tpg,
-- 
2.5.4 (Apple Git-61)



[PATCH] Pass iface for connection

2017-06-06 Thread Robert LeBlanc
---
 usr/netlink.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/usr/netlink.c b/usr/netlink.c
index 1a0bf80..c474375 100644
--- a/usr/netlink.c
+++ b/usr/netlink.c
@@ -848,10 +848,13 @@ krecv_pdu_end(struct iscsi_conn *conn)
 int
 ktransport_ep_connect(iscsi_conn_t *conn, int non_blocking)
 {
-   int rc, addrlen;
+   int rc, addrlen = sizeof(struct sockaddr_storage);
struct iscsi_uevent *ev;
-   struct sockaddr *dst_addr = (struct sockaddr *)>saddr;
+   struct sockaddr_storage *dst_addr = (struct sockaddr_storage 
*)>saddr;
struct iovec iov[2];
+   struct iscsi_session *tmp_session = (struct iscsi_session 
*)conn->session;
+   node_rec_t *tmp_rec = (node_rec_t *)_session->nrec;
+   iface_rec_t *tmp_iface = (iface_rec_t *)_rec->iface;
 
log_debug(7, "in %s", __FUNCTION__);
 
@@ -868,19 +871,16 @@ ktransport_ep_connect(iscsi_conn_t *conn, int 
non_blocking)
ev->u.ep_connect.non_blocking = non_blocking;
}
 
-   if (dst_addr->sa_family == PF_INET)
-   addrlen = sizeof(struct sockaddr_in);
-   else if (dst_addr->sa_family == PF_INET6)
-   addrlen = sizeof(struct sockaddr_in6);
-   else {
+   if (dst_addr->ss_family != AF_INET && dst_addr->ss_family != AF_INET6) {
log_error("%s unknown addr family %d",
-__FUNCTION__, dst_addr->sa_family);
+__FUNCTION__, dst_addr->ss_family);
return -EINVAL;
}
memcpy(setparam_buf + sizeof(*ev), dst_addr, addrlen);
+   iface_copy(setparam_buf + sizeof(*ev) + addrlen, tmp_iface);
 
iov[1].iov_base = ev;
-   iov[1].iov_len = sizeof(*ev) + addrlen;
+   iov[1].iov_len = sizeof(*ev) + addrlen + sizeof(iface_rec_t);
rc = __kipc_call(iov, 2);
if (rc < 0)
return rc;
-- 
2.11.0



[PATCH 4/7] scsi/be2iscsi: Update beiscsi_ep_connect to accept iface and sockaddr_storage.

2017-06-06 Thread Robert LeBlanc
Update Emulex BladeEngine driver to accept the session iface for
creating the iSCSI connection. Also accept dst_addr as sockaddr_storage
instead of sockaddr.

Signed-off-by: Robert LeBlanc 
---
 drivers/scsi/be2iscsi/be_cmds.c  | 1 +
 drivers/scsi/be2iscsi/be_iscsi.c | 8 +---
 drivers/scsi/be2iscsi/be_iscsi.h | 5 +++--
 drivers/scsi/be2iscsi/be_main.c  | 1 +
 drivers/scsi/be2iscsi/be_mgmt.c  | 1 +
 5 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index a79a5e72c777..6617f2add9c6 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -13,6 +13,7 @@
  */
 
 #include 
+#include 
 
 #include "be_main.h"
 #include "be.h"
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index 97dca4681784..90adf20dc373 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -12,6 +12,7 @@
  *
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -1161,8 +1162,8 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep,
  * This routines first asks chip to create a connection and then allocates an 
EP
  */
 struct iscsi_endpoint *
-beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,
-  int non_blocking)
+beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr_storage *dst_addr,
+  int non_blocking, struct iface_rec *iface)
 {
struct beiscsi_hba *phba;
struct beiscsi_endpoint *beiscsi_ep;
@@ -1198,7 +1199,8 @@ beiscsi_ep_connect(struct Scsi_Host *shost, struct 
sockaddr *dst_addr,
beiscsi_ep = ep->dd_data;
beiscsi_ep->phba = phba;
beiscsi_ep->openiscsi_ep = ep;
-   ret = beiscsi_open_conn(ep, NULL, dst_addr, non_blocking);
+   ret = beiscsi_open_conn(ep, NULL, (struct sockaddr *)dst_addr,
+   non_blocking);
if (ret) {
beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
"BS_%d : Failed in beiscsi_open_conn\n");
diff --git a/drivers/scsi/be2iscsi/be_iscsi.h b/drivers/scsi/be2iscsi/be_iscsi.h
index b9d459a21f25..68616f81a12f 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.h
+++ b/drivers/scsi/be2iscsi/be_iscsi.h
@@ -68,8 +68,9 @@ int beiscsi_set_param(struct iscsi_cls_conn *cls_conn,
 int beiscsi_conn_start(struct iscsi_cls_conn *cls_conn);
 
 struct iscsi_endpoint *beiscsi_ep_connect(struct Scsi_Host *shost,
- struct sockaddr *dst_addr,
- int non_blocking);
+ struct sockaddr_storage *dst_addr,
+ int non_blocking,
+ struct iface_rec *iface);
 
 int beiscsi_ep_poll(struct iscsi_endpoint *ep, int timeout_ms);
 
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index f862332261f8..aab7772e2678 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index c73775368d09..926afa4ddb9d 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -13,6 +13,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include "be_mgmt.h"
-- 
2.11.0



[PATCH 6/7] scsi/cxgbi: Update cxgbi_ep_connect to accept iface and sockaddr_storage.

2017-06-06 Thread Robert LeBlanc
Update Chelsio iSCSI driver to accept the session iface for creating the
iSCSI connection. Also accept dst_addr as sockaddr_storage instead of
sockaddr.

Signed-off-by: Robert LeBlanc 
---
 drivers/scsi/cxgbi/libcxgbi.c | 15 ---
 drivers/scsi/cxgbi/libcxgbi.h |  2 +-
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index bd7d39ecbd24..62f62305be49 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -2499,8 +2499,9 @@ int cxgbi_get_host_param(struct Scsi_Host *shost, enum 
iscsi_host_param param,
 EXPORT_SYMBOL_GPL(cxgbi_get_host_param);
 
 struct iscsi_endpoint *cxgbi_ep_connect(struct Scsi_Host *shost,
-   struct sockaddr *dst_addr,
-   int non_blocking)
+   struct sockaddr_storage *dst_addr,
+   int non_blocking,
+   struct iface_rec *iface)
 {
struct iscsi_endpoint *ep;
struct cxgbi_endpoint *cep;
@@ -2520,15 +2521,15 @@ struct iscsi_endpoint *cxgbi_ep_connect(struct 
Scsi_Host *shost,
}
}
 
-   if (dst_addr->sa_family == AF_INET) {
-   csk = cxgbi_check_route(dst_addr);
+   if (dst_addr->ss_family == AF_INET) {
+   csk = cxgbi_check_route((struct sockaddr *)dst_addr);
 #if IS_ENABLED(CONFIG_IPV6)
-   } else if (dst_addr->sa_family == AF_INET6) {
-   csk = cxgbi_check_route6(dst_addr);
+   } else if (dst_addr->ss_family == AF_INET6) {
+   csk = cxgbi_check_route6((struct sockaddr *)dst_addr);
 #endif
} else {
pr_info("address family 0x%x NOT supported.\n",
-   dst_addr->sa_family);
+   dst_addr->ss_family);
err = -EAFNOSUPPORT;
return (struct iscsi_endpoint *)ERR_PTR(err);
}
diff --git a/drivers/scsi/cxgbi/libcxgbi.h b/drivers/scsi/cxgbi/libcxgbi.h
index 18e0ea83d361..e2e0c4dc7abc 100644
--- a/drivers/scsi/cxgbi/libcxgbi.h
+++ b/drivers/scsi/cxgbi/libcxgbi.h
@@ -596,7 +596,7 @@ int cxgbi_set_host_param(struct Scsi_Host *,
enum iscsi_host_param, char *, int);
 int cxgbi_get_host_param(struct Scsi_Host *, enum iscsi_host_param, char *);
 struct iscsi_endpoint *cxgbi_ep_connect(struct Scsi_Host *,
-   struct sockaddr *, int);
+   struct sockaddr_storage *, int, struct iface_rec *);
 int cxgbi_ep_poll(struct iscsi_endpoint *, int);
 void cxgbi_ep_disconnect(struct iscsi_endpoint *);
 
-- 
2.11.0



[PATCH 3/7] ib/iSER: Add binding to source IP address.

2017-06-06 Thread Robert LeBlanc
If the iface passed in has ip address set, then attept to create an RDMA
connection using it as the source IP address. This allows iSER to use
multiple ports on the same network or in more complex routing
configurations. Also update to accepting sockaddr_storage.

Signed-off-by: Robert LeBlanc 
---
 drivers/infiniband/ulp/iser/iscsi_iser.c | 33 
 drivers/infiniband/ulp/iser/iscsi_iser.h |  4 ++--
 drivers/infiniband/ulp/iser/iser_initiator.c |  1 +
 drivers/infiniband/ulp/iser/iser_memory.c|  1 +
 drivers/infiniband/ulp/iser/iser_verbs.c |  8 ---
 5 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c 
b/drivers/infiniband/ulp/iser/iscsi_iser.c
index 5a887efb4bdf..7ba5ed9afe05 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -59,6 +59,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -808,12 +809,16 @@ static int iscsi_iser_get_ep_param(struct iscsi_endpoint 
*ep,
  * if fails.
  */
 static struct iscsi_endpoint *
-iscsi_iser_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,
- int non_blocking)
+iscsi_iser_ep_connect(struct Scsi_Host *shost, struct sockaddr_storage 
*dst_addr,
+ int non_blocking, struct iface_rec *iface)
 {
int err;
struct iser_conn *iser_conn;
struct iscsi_endpoint *ep;
+   struct sockaddr_storage src_addr;
+   struct sockaddr_in *tmp_addr;
+   struct sockaddr_in6 *tmp_addr6;
+   memset(_addr, 0, sizeof(src_addr));
 
ep = iscsi_create_endpoint(0);
if (!ep)
@@ -828,8 +833,28 @@ iscsi_iser_ep_connect(struct Scsi_Host *shost, struct 
sockaddr *dst_addr,
ep->dd_data = iser_conn;
iser_conn->ep = ep;
iser_conn_init(iser_conn);
-
-   err = iser_connect(iser_conn, NULL, dst_addr, non_blocking);
+   if (iface && iface->ipaddress[0]) {
+   if (strchr(iface->ipaddress, ':')) {
+   tmp_addr6 = (struct sockaddr_in6 *)_addr;
+   tmp_addr6->sin6_family = AF_INET6;
+   if(!in6_pton(iface->ipaddress, -1,
+tmp_addr6->sin6_addr.s6_addr,
+-1, NULL)) {
+   err = -EINVAL;
+   goto failure;
+   }
+   } else {
+   tmp_addr = (struct sockaddr_in *)_addr;
+   tmp_addr->sin_family = AF_INET;
+   if (!in4_pton(iface->ipaddress, -1,
+(u8 *)_addr->sin_addr.s_addr,
+-1, NULL)) {
+   err = -EINVAL;
+   goto failure;
+   }
+   }
+   }
+   err = iser_connect(iser_conn, _addr, dst_addr, non_blocking);
if (err)
goto failure;
 
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h 
b/drivers/infiniband/ulp/iser/iscsi_iser.h
index c1ae4aeae2f9..1eda6ff49bdc 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.h
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.h
@@ -628,8 +628,8 @@ void iser_unreg_rdma_mem(struct iscsi_iser_task *task,
 enum iser_data_dir dir);
 
 int  iser_connect(struct iser_conn *iser_conn,
- struct sockaddr *src_addr,
- struct sockaddr *dst_addr,
+ struct sockaddr_storage *src_addr,
+ struct sockaddr_storage *dst_addr,
  int non_blocking);
 
 void iser_unreg_mem_fmr(struct iscsi_iser_task *iser_task,
diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c 
b/drivers/infiniband/ulp/iser/iser_initiator.c
index 12ed62ce9ff7..361d5e411fe7 100644
--- a/drivers/infiniband/ulp/iser/iser_initiator.c
+++ b/drivers/infiniband/ulp/iser/iser_initiator.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
diff --git a/drivers/infiniband/ulp/iser/iser_memory.c 
b/drivers/infiniband/ulp/iser/iser_memory.c
index 9c3e9ab53a41..c9d95b997820 100644
--- a/drivers/infiniband/ulp/iser/iser_memory.c
+++ b/drivers/infiniband/ulp/iser/iser_memory.c
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "iscsi_iser.h"
 static
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c 
b/drivers/infiniband/ulp/iser/iser_verbs.c
index c538a38c91ce..0a43009296b6 100644
--- a/drivers/infiniband/ulp/iser/iser_verbs.c
+++ b/drivers/infiniband/ulp/iser/iser_verbs.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "iscsi_iser.h"
 
@@ -941,8 +942,8 @@ void iser_conn_init(struct iser_conn *iser_conn)
  * sleeps until the connection is established or rejected
  */
 int iser_connect(struct iser_conn   *iser_conn,
-struct sockaddr*src_addr,
-

[PATCH 7/7] scsi/qla4xxx: Update qla4xxx_ep_connect to accept iface and sockaddr_storage.

2017-06-06 Thread Robert LeBlanc
Update QLogic ISP4XXX and ISP82XX drivers to accept the session iface for
creating the iSCSI connection. Also accept dst_addr as sockaddr_storage
instead of sockaddr.

Signed-off-by: Robert LeBlanc 
---
 drivers/scsi/qla4xxx/ql4_os.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 64c6fa563fdb..4fccb580bd48 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -119,8 +119,9 @@ static int qla4xxx_get_iface_param(struct iscsi_iface 
*iface,
   int param, char *buf);
 static enum blk_eh_timer_return qla4xxx_eh_cmd_timed_out(struct scsi_cmnd *sc);
 static struct iscsi_endpoint *qla4xxx_ep_connect(struct Scsi_Host *shost,
-struct sockaddr *dst_addr,
-int non_blocking);
+struct sockaddr_storage 
*dst_addr,
+int non_blocking,
+struct iface_rec *iface);
 static int qla4xxx_ep_poll(struct iscsi_endpoint *ep, int timeout_ms);
 static void qla4xxx_ep_disconnect(struct iscsi_endpoint *ep);
 static int qla4xxx_get_ep_param(struct iscsi_endpoint *ep,
@@ -1656,8 +1657,8 @@ static int qla4xxx_get_iface_param(struct iscsi_iface 
*iface,
 }
 
 static struct iscsi_endpoint *
-qla4xxx_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr,
-  int non_blocking)
+qla4xxx_ep_connect(struct Scsi_Host *shost, struct sockaddr_storage *dst_addr,
+  int non_blocking, struct iface_rec *iface)
 {
int ret;
struct iscsi_endpoint *ep;
@@ -1681,12 +1682,12 @@ qla4xxx_ep_connect(struct Scsi_Host *shost, struct 
sockaddr *dst_addr,
 
qla_ep = ep->dd_data;
memset(qla_ep, 0, sizeof(struct qla_endpoint));
-   if (dst_addr->sa_family == AF_INET) {
+   if (dst_addr->ss_family == AF_INET) {
memcpy(_ep->dst_addr, dst_addr, sizeof(struct sockaddr_in));
addr = (struct sockaddr_in *)_ep->dst_addr;
DEBUG2(ql4_printk(KERN_INFO, ha, "%s: %pI4\n", __func__,
  (char *)>sin_addr));
-   } else if (dst_addr->sa_family == AF_INET6) {
+   } else if (dst_addr->ss_family == AF_INET6) {
memcpy(_ep->dst_addr, dst_addr,
   sizeof(struct sockaddr_in6));
addr6 = (struct sockaddr_in6 *)_ep->dst_addr;
@@ -6569,7 +6570,7 @@ static struct iscsi_endpoint *qla4xxx_get_ep_fwdb(struct 
scsi_qla_host *ha,
addr->sin_port = htons(le16_to_cpu(fw_ddb_entry->port));
}
 
-   ep = qla4xxx_ep_connect(ha->host, (struct sockaddr *)dst_addr, 0);
+   ep = qla4xxx_ep_connect(ha->host, dst_addr, 0, NULL);
vfree(dst_addr);
return ep;
 }
-- 
2.11.0



[PATCH 5/7] scsi/bnx2i: Update bnx2i_ep_connect to accept iface and sockaddr_storage.

2017-06-06 Thread Robert LeBlanc
Update QLogic NetXtreme II driver to accept the session iface for creating
the iSCSI connection. Also accept dst_addr as sockaddr_storage instead of
sockaddr.

Signed-off-by: Robert LeBlanc 
---
 drivers/scsi/bnx2i/bnx2i_hwi.c   |  1 +
 drivers/scsi/bnx2i/bnx2i_iscsi.c | 13 -
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 42921dbba927..ce87ce2c2dc1 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -15,6 +15,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include "bnx2i.h"
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index f32a66f89d25..515106367426 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -16,8 +16,10 @@
  */
 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include "bnx2i.h"
 
 struct scsi_transport_template *bnx2i_scsi_xport_template;
@@ -1771,8 +1773,9 @@ static int bnx2i_tear_down_conn(struct bnx2i_hba *hba,
  * sending down option-2 request to complete TCP 3-way handshake
  */
 static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
-  struct sockaddr *dst_addr,
-  int non_blocking)
+  struct sockaddr_storage 
*dst_addr,
+  int non_blocking,
+  struct iface_rec *iface)
 {
u32 iscsi_cid = BNX2I_CID_RESERVED;
struct sockaddr_in *desti = (struct sockaddr_in *) dst_addr;
@@ -1792,7 +1795,7 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct 
Scsi_Host *shost,
 * check if the given destination can be reached through
 * a iscsi capable NetXtreme2 device
 */
-   hba = bnx2i_check_route(dst_addr);
+   hba = bnx2i_check_route((struct sockaddr *)dst_addr);
 
if (!hba) {
rc = -EINVAL;
@@ -1887,11 +1890,11 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct 
Scsi_Host *shost,
clear_bit(SK_TCP_TIMESTAMP, _ep->cm_sk->tcp_flags);
 
memset(, 0, sizeof(saddr));
-   if (dst_addr->sa_family == AF_INET) {
+   if (dst_addr->ss_family == AF_INET) {
desti = (struct sockaddr_in *) dst_addr;
saddr.remote.v4 = *desti;
saddr.local.v4.sin_family = desti->sin_family;
-   } else if (dst_addr->sa_family == AF_INET6) {
+   } else if (dst_addr->ss_family == AF_INET6) {
desti6 = (struct sockaddr_in6 *) dst_addr;
saddr.remote.v6 = *desti6;
saddr.local.v6.sin6_family = desti6->sin6_family;
-- 
2.11.0



[PATCH 0/7] Enable iSCSI offload drivers to use information from iface.

2017-06-06 Thread Robert LeBlanc
This patchset enables iSCSI offload drivers to have access to the iface
information provided by iscsid. This allows users to have more control
of how the driver connects to the iSCSI target. iSER is updated to use
iface.ipaddress to set the source IP address if configured. This allows
iSER to use multiple ports on the same network or in more complicated
routed configurations.

Since there is already a change to the function parameters, dst_addr
is upgraded to sockaddr_storage so that it is more future proof and makes
the size of the struct static and not dependent on checking the SA_FAMILY.

This is dependent on updates to Open-iSCSI.

Robert LeBlanc (7):
  scsi/scsi_transport_iscsi: Add iface struct to kernel.
  scsi/scsi_transport_iscsi: Update ep_connect to include iface.
  ib/iSER: Add binding to source IP address.
  scsi/be2iscsi: Update beiscsi_ep_connect to accept iface and
sockaddr_storage.
  scsi/bnx2i: Update bnx2i_ep_connect to accept iface and
sockaddr_storage.
  scsi/cxgbi: Update cxgbi_ep_connect to accept iface and
sockaddr_storage.
  scsi/qla4xxx: Update qla4xxx_ep_connect to accept iface and
sockaddr_storage.

 drivers/infiniband/ulp/iser/iscsi_iser.c |  33 +++--
 drivers/infiniband/ulp/iser/iscsi_iser.h |   4 +-
 drivers/infiniband/ulp/iser/iser_initiator.c |   1 +
 drivers/infiniband/ulp/iser/iser_memory.c|   1 +
 drivers/infiniband/ulp/iser/iser_verbs.c |   8 ++-
 drivers/scsi/be2iscsi/be_cmds.c  |   1 +
 drivers/scsi/be2iscsi/be_iscsi.c |   8 ++-
 drivers/scsi/be2iscsi/be_iscsi.h |   5 +-
 drivers/scsi/be2iscsi/be_main.c  |   1 +
 drivers/scsi/be2iscsi/be_mgmt.c  |   1 +
 drivers/scsi/bnx2i/bnx2i_hwi.c   |   1 +
 drivers/scsi/bnx2i/bnx2i_iscsi.c |  13 ++--
 drivers/scsi/cxgbi/libcxgbi.c|  15 ++--
 drivers/scsi/cxgbi/libcxgbi.h|   2 +-
 drivers/scsi/qla4xxx/ql4_os.c|  15 ++--
 drivers/scsi/scsi_transport_iscsi.c  |   9 ++-
 include/scsi/scsi_transport_iscsi.h  | 100 ++-
 17 files changed, 179 insertions(+), 39 deletions(-)

-- 
2.11.0



[PATCH 1/7] scsi/scsi_transport_iscsi: Add iface struct to kernel.

2017-06-06 Thread Robert LeBlanc
Allow the userspace iscsiadm to pass the iface struct of the connection
so that the underlying driver can use what is most appropriate to create
the iSCSI connection.

Signed-off-by: Robert LeBlanc 
---
 include/scsi/scsi_transport_iscsi.h | 95 +
 1 file changed, 95 insertions(+)

diff --git a/include/scsi/scsi_transport_iscsi.h 
b/include/scsi/scsi_transport_iscsi.h
index 6183d20a01fb..26fe284daf9a 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -37,6 +37,7 @@ struct iscsi_cls_conn;
 struct iscsi_conn;
 struct iscsi_task;
 struct sockaddr;
+struct iface_rec;
 struct iscsi_iface;
 struct bsg_job;
 struct iscsi_bus_flash_session;
@@ -291,6 +292,100 @@ struct iscsi_endpoint {
struct iscsi_cls_conn *conn;
 };
 
+/* max len of interface */
+#define ISCSI_MAX_IFACE_LEN65
+#define NI_MAXHOST 1025
+#define ISCSI_HWADDRESS_BUF_SIZE 18
+#define ISCSI_TRANSPORT_NAME_MAXLEN 16
+#define ISCSI_MAX_STR_LEN 80
+
+struct iface_rec {
+   struct list_headlist;
+   /* iscsi iface record name */
+   charname[ISCSI_MAX_IFACE_LEN];
+   uint32_tiface_num;
+   /* network layer iface name (eth0) */
+   charnetdev[IFNAMSIZ];
+   charipaddress[NI_MAXHOST];
+   charsubnet_mask[NI_MAXHOST];
+   chargateway[NI_MAXHOST];
+   charbootproto[ISCSI_MAX_STR_LEN];
+   charipv6_linklocal[NI_MAXHOST];
+   charipv6_router[NI_MAXHOST];
+   charipv6_autocfg[NI_MAXHOST];
+   charlinklocal_autocfg[NI_MAXHOST];
+   charrouter_autocfg[NI_MAXHOST];
+   uint16_tvlan_id;
+   uint8_t vlan_priority;
+   charvlan_state[ISCSI_MAX_STR_LEN];
+   charstate[ISCSI_MAX_STR_LEN]; /* 0 = disable,
+  * 1 = enable */
+   uint16_tmtu;
+   uint16_tport;
+   chardelayed_ack[ISCSI_MAX_STR_LEN];
+   charnagle[ISCSI_MAX_STR_LEN];
+   chartcp_wsf_state[ISCSI_MAX_STR_LEN];
+   uint8_t tcp_wsf;
+   uint8_t tcp_timer_scale;
+   chartcp_timestamp[ISCSI_MAX_STR_LEN];
+   chardhcp_dns[ISCSI_MAX_STR_LEN];
+   chardhcp_slp_da[ISCSI_MAX_STR_LEN];
+   chartos_state[ISCSI_MAX_STR_LEN];
+   uint8_t tos;
+   chargratuitous_arp[ISCSI_MAX_STR_LEN];
+   chardhcp_alt_client_id_state[ISCSI_MAX_STR_LEN];
+   chardhcp_alt_client_id[ISCSI_MAX_STR_LEN];
+   chardhcp_req_vendor_id_state[ISCSI_MAX_STR_LEN];
+   chardhcp_vendor_id_state[ISCSI_MAX_STR_LEN];
+   chardhcp_vendor_id[ISCSI_MAX_STR_LEN];
+   chardhcp_learn_iqn[ISCSI_MAX_STR_LEN];
+   charfragmentation[ISCSI_MAX_STR_LEN];
+   charincoming_forwarding[ISCSI_MAX_STR_LEN];
+   uint8_t ttl;
+   chargratuitous_neighbor_adv[ISCSI_MAX_STR_LEN];
+   charredirect[ISCSI_MAX_STR_LEN];
+   charmld[ISCSI_MAX_STR_LEN];
+   uint32_tflow_label;
+   uint32_ttraffic_class;
+   uint8_t hop_limit;
+   uint32_tnd_reachable_tmo;
+   uint32_tnd_rexmit_time;
+   uint32_tnd_stale_tmo;
+   uint8_t dup_addr_detect_cnt;
+   uint32_trouter_adv_link_mtu;
+   uint16_tdef_task_mgmt_tmo;
+   charheader_digest[ISCSI_MAX_STR_LEN];
+   chardata_digest[ISCSI_MAX_STR_LEN];
+   charimmediate_data[ISCSI_MAX_STR_LEN];
+   charinitial_r2t[ISCSI_MAX_STR_LEN];
+   chardata_seq_inorder[ISCSI_MAX_STR_LEN];
+   chardata_pdu_inorder[ISCSI_MAX_STR_LEN];
+   uint8_t erl;
+   uint32_tmax_recv_dlength;
+   uint32_tfirst_burst_len;
+   uint16_tmax_out_r2t;
+   uint32_tmax_burst_len;
+   charchap_auth[ISCSI_MAX_STR_LEN];
+   charbidi_chap[ISCSI_MAX_STR_LEN];
+   charstrict_login_comp[ISCSI_MAX_STR_LEN];
+   chardiscovery_auth[ISCSI_MAX_STR_LEN];
+   char

RE: Application stops due to ext4 filesytsem IO error

2017-06-06 Thread Sumit Saxena
Gentle ping..

>-Original Message-
>From: Sumit Saxena [mailto:sumit.sax...@broadcom.com]
>Sent: Monday, June 05, 2017 12:59 PM
>To: 'Jens Axboe'
>Cc: 'linux-bl...@vger.kernel.org'; 'linux-scsi@vger.kernel.org'
>Subject: Application stops due to ext4 filesytsem IO error
>
>Jens,
>
>We am observing  application stops while running ext4 filesystem IOs
along
>with target reset in parallel.
>Our suspect is this behavior can be attributed to linux block layer. See
below
>for details-
>
>Problem statement - " Application stops due to IO error from file system
>buffered IO. (Note - It is always a FS meta data read failure)"
>Issue is reproducible - "Yes. It is consistently reproducible."
>Brief about setup -
>Latest 4.11 kernel. Issue hits irrespective of whether SCSI MQ is enabled
or
>disabled. use_blk_mq=Y and use_blk_mq=N has similar issue.
>Direct attached 4 SAS/SATA drives connected to MegaRAID Invader
>controller.
>
>Reproduction steps -
>-Create ext4 FS on 4 JBODs(non RAID volumes) behind MegaRAID SAS
>controller.
>-Start Data integrity test on all four ext4 mounted partition. (Tool
should be
>configured to send Buffered FS IO).
>-Send Target Reset  (have some delay between next reset to allow some IO
>on device) on each JBOD to simulate error condition. (sg_reset -d
/dev/sdX).
>
>End result -
>Combination of target resets and FS IOs in parallel causes application
halt
>with ext4 Filesystem IO error.
>We are able to restart  application without cleaning and unmounting
>filesystem.
>Below are the error logs at the time of application stop-
>
>--
>sd 0:0:53:0: target reset called for
>scmd(88003cf25148)
>sd 0:0:53:0: attempting target reset!
>scmd(88003cf25148) tm_dev_handle 0xb
>sd 0:0:53:0: [sde] tag#519 BRCM Debug: request->cmd_flags: 0x80700   bio-
>>bi_flags: 0x2  bio->bi_opf: 0x3000 rq_flags 0x20e3
>..
>sd 0:0:53:0: [sde] tag#519 CDB: Read(10) 28 00 15 00 11 10 00 00 f8 00
>EXT4-fs error (device sde): __ext4_get_inode_loc:4465: inode #11018287:
>block 44040738: comm chaos: unable to read itable block
>---
>
>We debug further to understand what is happening above LLD. See below-
>
>During target reset,  there may be IO coming from target with CHECK
>CONDITION with below sense information-.
>Sense Key : Aborted Command [current]
>Add. Sense: No additional sense information
>
>Such Aborted command should be retried by SML/Block layer. This happens
>from SML expect for FS Meta data read.
>From driver level debug, we found IOs with REQ_FAILFAST_DEV bit set in
>scmd->request->cmd_flags are not retried by SML and that is also as
>expected.
>
>Below is the code in scsi_error.c(function- scsi_noretry_cmd) which
causes
>IOs with REQ_FAILFAST_DEV enabled not getting retried bit completed back
>to upper layer-
>
>/*
> * assume caller has checked sense and determined
> * the check condition was retryable.
> */
>if (scmd->request->cmd_flags & REQ_FAILFAST_DEV ||
>scmd->request->cmd_type == REQ_TYPE_BLOCK_PC)
>return 1;
>else
>return 0;
>
>
>IO which causes application to stop has REQ_FAILFAST_DEV enabled inside
>"scmd->request->cmd_flags". We noticed that this bit will be set for
>filesystem Read ahead meta data IOs. In order to confirm the same, we
>mounted with option inode_readahead_blks=0 to disable ext4's inode table
>readahead algorithm and did not observe the issue. Issue does not hit
with
>DIRECT IOs but only with cached/buffered IOs.
>
>2. From driver level debug prints, we also noticed - There are many IO
>failures with REQ_FAILFAST_DEV handled gracefully by filesystem.
>Application level failure happens only If IO has RQF_MIXED_MERGE set.
>If IO merging is disabled through sysfs parameter for SCSI device in
question-
>nomerges set to 2, we are not seeing the issue.
>
>3. We added few prints in driver to dump "scmd->request->cmd_flags" and
>"scmd->request->rq_flags" for IOs completed with CHECK CONDITION and
>culprit IOs has all these bits- REQ_FAILFAST_DEV and REQ_RAHEAD bit set
in
>"scmd->request->cmd_flags" and RQF_MIXED_MERGE bit set in "scmd-
>>request->rq_flags". Also it's not necessarily true that all IOs with
these
>three bits set will cause issue but whenever issue hits, these three bits
are
>set for IO causing failure.
>
>
>In summary,
>FS mechanism of using READ AHEAD for meta data works fine (in case of IO
>failure) if there is no mix/merge at block layer.
>FS mechanism of using READ AHEAD for meta data has some corner case
>which is not handled properly (in case of IO failure) if  there was
mix/merge
>at block layer.
>megaraid_sas driver's behavior seems correct here. Aborted IO goes to SML
>with CHECK CONDITION settings and SML decided to fail fast IO as it was
>requested.
>
>Query -  Is this block layer (page cache) issue?  What should be the
ideal fix ?
>
>Thanks,
>Sumit


[PATCH v5 06/12] blk-mq: use the introduced blk_mq_unquiesce_queue()

2017-06-06 Thread Ming Lei
blk_mq_unquiesce_queue() is used for unquiescing the
queue explicitly, so replace blk_mq_start_stopped_hw_queues()
with it.

For the scsi part, this patch takes Bart's suggestion to
switch to block quiesce/unquiesce API completely.

Cc: linux-n...@lists.infradead.org
Cc: linux-scsi@vger.kernel.org
Cc: dm-de...@redhat.com
Reviewed-by: Bart Van Assche 
Signed-off-by: Ming Lei 
---
 drivers/md/dm-rq.c   | 2 +-
 drivers/nvme/host/core.c | 2 +-
 drivers/scsi/scsi_lib.c  | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
index b639fa7246ee..ea4029de077f 100644
--- a/drivers/md/dm-rq.c
+++ b/drivers/md/dm-rq.c
@@ -71,7 +71,7 @@ static void dm_old_start_queue(struct request_queue *q)
 
 static void dm_mq_start_queue(struct request_queue *q)
 {
-   blk_mq_start_stopped_hw_queues(q, true);
+   blk_mq_unquiesce_queue(q);
blk_mq_kick_requeue_list(q);
 }
 
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index a60926410438..c3f189e54d10 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2526,7 +2526,7 @@ void nvme_start_queues(struct nvme_ctrl *ctrl)
 
mutex_lock(>namespaces_mutex);
list_for_each_entry(ns, >namespaces, list) {
-   blk_mq_start_stopped_hw_queues(ns->queue, true);
+   blk_mq_unquiesce_queue(ns->queue);
blk_mq_kick_requeue_list(ns->queue);
}
mutex_unlock(>namespaces_mutex);
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 884aaa84c2dd..d6df1dafdc9f 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2979,7 +2979,7 @@ scsi_internal_device_block(struct scsi_device *sdev, bool 
wait)
if (wait)
blk_mq_quiesce_queue(q);
else
-   blk_mq_stop_hw_queues(q);
+   blk_mq_quiesce_queue_nowait(q);
} else {
spin_lock_irqsave(q->queue_lock, flags);
blk_stop_queue(q);
@@ -3033,7 +3033,7 @@ scsi_internal_device_unblock(struct scsi_device *sdev,
return -EINVAL;
 
if (q->mq_ops) {
-   blk_mq_start_stopped_hw_queues(q, false);
+   blk_mq_unquiesce_queue(q);
} else {
spin_lock_irqsave(q->queue_lock, flags);
blk_start_queue(q);
-- 
2.9.4



[PATCH v4 3/5] tcmu: Make dev_size configurable via userspace

2017-06-06 Thread Bryant G. Ly
Allow tcmu backstores to be able to set the device size
after it has been configured via set attribute.

Part of support in userspace to support certain backstores
changing device size.

Signed-off-by: Bryant G. Ly 
---
 drivers/target/target_core_user.c | 59 +++
 1 file changed, 54 insertions(+), 5 deletions(-)

diff --git a/drivers/target/target_core_user.c 
b/drivers/target/target_core_user.c
index ae91822..c8c84b7 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1548,6 +1548,44 @@ static ssize_t tcmu_cmd_time_out_store(struct 
config_item *item, const char *pag
 }
 CONFIGFS_ATTR(tcmu_, cmd_time_out);
 
+static ssize_t tcmu_dev_size_show(struct config_item *item, char *page)
+{
+   struct se_dev_attrib *da = container_of(to_config_group(item),
+   struct se_dev_attrib, da_group);
+   struct tcmu_dev *udev = TCMU_DEV(da->da_dev);
+
+   return snprintf(page, PAGE_SIZE, "%zu\n", udev->dev_size);
+}
+
+static ssize_t tcmu_dev_size_store(struct config_item *item, const char *page,
+  size_t count)
+{
+   struct se_dev_attrib *da = container_of(to_config_group(item),
+   struct se_dev_attrib, da_group);
+   struct tcmu_dev *udev = TCMU_DEV(da->da_dev);
+   unsigned long val;
+   int ret;
+
+   ret = kstrtoul(page, 0, );
+   if (ret < 0)
+   return ret;
+   udev->dev_size = val;
+
+   /* Check if device has been configured before */
+   if (tcmu_dev_configured(udev)) {
+   ret = tcmu_netlink_event(TCMU_CMD_RECONFIG_DEVICE,
+udev->uio_info.name,
+udev->uio_info.uio_dev->minor);
+   if (ret) {
+   pr_err("Unable to reconfigure device\n");
+   return ret;
+   }
+   }
+
+   return count;
+}
+CONFIGFS_ATTR(tcmu_, dev_size);
+
 static ssize_t tcmu_emulate_write_cache_show(struct config_item *item,
 char *page)
 {
@@ -1586,6 +1624,13 @@ static ssize_t tcmu_emulate_write_cache_store(struct 
config_item *item,
 }
 CONFIGFS_ATTR(tcmu_, emulate_write_cache);
 
+struct configfs_attribute *tcmu_attrib_attrs[] = {
+   _attr_cmd_time_out,
+   _attr_dev_size,
+   _attr_emulate_write_cache,
+   NULL,
+};
+
 static struct configfs_attribute **tcmu_attrs;
 
 static struct target_backend_ops tcmu_ops = {
@@ -1685,7 +1730,7 @@ static int unmap_thread_fn(void *data)
 
 static int __init tcmu_module_init(void)
 {
-   int ret, i, len = 0;
+   int ret, i, k, len = 0;
 
BUILD_BUG_ON((sizeof(struct tcmu_cmd_entry) % TCMU_OP_ALIGN_SIZE) != 0);
 
@@ -1710,7 +1755,10 @@ static int __init tcmu_module_init(void)
for (i = 0; passthrough_attrib_attrs[i] != NULL; i++) {
len += sizeof(struct configfs_attribute *);
}
-   len += sizeof(struct configfs_attribute *) * 2;
+   for (i = 0; tcmu_attrib_attrs[i] != NULL; i++) {
+   len += sizeof(struct configfs_attribute *);
+   }
+   len += sizeof(struct configfs_attribute *);
 
tcmu_attrs = kzalloc(len, GFP_KERNEL);
if (!tcmu_attrs) {
@@ -1721,9 +1769,10 @@ static int __init tcmu_module_init(void)
for (i = 0; passthrough_attrib_attrs[i] != NULL; i++) {
tcmu_attrs[i] = passthrough_attrib_attrs[i];
}
-   tcmu_attrs[i] = _attr_cmd_time_out;
-   i++;
-   tcmu_attrs[i] = _attr_emulate_write_cache;
+   for (k = 0; tcmu_attrib_attrs[k] != NULL; k++) {
+   tcmu_attrs[i] = tcmu_attrib_attrs[k];
+   i++;
+   }
tcmu_ops.tb_dev_attrib_attrs = tcmu_attrs;
 
ret = transport_backend_register(_ops);
-- 
2.5.4 (Apple Git-61)



[PATCH v4 5/5] tcmu: Add Type of reconfig into netlink

2017-06-06 Thread Bryant G. Ly
This patch adds more info about the attribute being changed,
so that usersapce can easily figure out what is happening.

Signed-off-by: Bryant G. Ly 
---
 drivers/target/target_core_user.c | 20 ++--
 include/uapi/linux/target_core_user.h |  8 
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/target/target_core_user.c 
b/drivers/target/target_core_user.c
index 7c64757..afc1fd6 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1176,7 +1176,8 @@ static int tcmu_release(struct uio_info *info, struct 
inode *inode)
return 0;
 }
 
-static int tcmu_netlink_event(enum tcmu_genl_cmd cmd, const char *name, int 
minor)
+static int tcmu_netlink_event(enum tcmu_genl_cmd cmd, const char *name,
+ int minor, int type)
 {
struct sk_buff *skb;
void *msg_header;
@@ -1198,6 +1199,10 @@ static int tcmu_netlink_event(enum tcmu_genl_cmd cmd, 
const char *name, int mino
if (ret < 0)
goto free_skb;
 
+   ret = nla_put_u32(skb, TCMU_ATTR_TYPE, type);
+   if (ret < 0)
+   goto free_skb;
+
genlmsg_end(skb, msg_header);
 
ret = genlmsg_multicast_allns(_genl_family, skb, 0,
@@ -1301,7 +1306,7 @@ static int tcmu_configure_device(struct se_device *dev)
kref_get(>kref);
 
ret = tcmu_netlink_event(TCMU_CMD_ADDED_DEVICE, udev->uio_info.name,
-udev->uio_info.uio_dev->minor);
+udev->uio_info.uio_dev->minor, NO_RECONFIG);
if (ret)
goto err_netlink;
 
@@ -1383,7 +1388,7 @@ static void tcmu_free_device(struct se_device *dev)
 
if (tcmu_dev_configured(udev)) {
tcmu_netlink_event(TCMU_CMD_REMOVED_DEVICE, udev->uio_info.name,
-  udev->uio_info.uio_dev->minor);
+  udev->uio_info.uio_dev->minor, NO_RECONFIG);
 
uio_unregister_device(>uio_info);
}
@@ -1577,7 +1582,8 @@ static ssize_t tcmu_dev_path_store(struct config_item 
*item, const char *page,
if (tcmu_dev_configured(udev)) {
ret = tcmu_netlink_event(TCMU_CMD_RECONFIG_DEVICE,
 udev->uio_info.name,
-udev->uio_info.uio_dev->minor);
+udev->uio_info.uio_dev->minor,
+CONFIG_PATH);
if (ret) {
pr_err("Unable to reconfigure device\n");
return ret;
@@ -1615,7 +1621,8 @@ static ssize_t tcmu_dev_size_store(struct config_item 
*item, const char *page,
if (tcmu_dev_configured(udev)) {
ret = tcmu_netlink_event(TCMU_CMD_RECONFIG_DEVICE,
 udev->uio_info.name,
-udev->uio_info.uio_dev->minor);
+udev->uio_info.uio_dev->minor,
+CONFIG_SIZE);
if (ret) {
pr_err("Unable to reconfigure device\n");
return ret;
@@ -1654,7 +1661,8 @@ static ssize_t tcmu_emulate_write_cache_store(struct 
config_item *item,
if (tcmu_dev_configured(udev)) {
ret = tcmu_netlink_event(TCMU_CMD_RECONFIG_DEVICE,
 udev->uio_info.name,
-udev->uio_info.uio_dev->minor);
+udev->uio_info.uio_dev->minor,
+CONFIG_WRITECACHE);
if (ret) {
pr_err("Unable to reconfigure device\n");
return ret;
diff --git a/include/uapi/linux/target_core_user.h 
b/include/uapi/linux/target_core_user.h
index 403a61f..5b00e35 100644
--- a/include/uapi/linux/target_core_user.h
+++ b/include/uapi/linux/target_core_user.h
@@ -139,8 +139,16 @@ enum tcmu_genl_attr {
TCMU_ATTR_UNSPEC,
TCMU_ATTR_DEVICE,
TCMU_ATTR_MINOR,
+   TCMU_ATTR_TYPE,
__TCMU_ATTR_MAX,
 };
 #define TCMU_ATTR_MAX (__TCMU_ATTR_MAX - 1)
 
+enum tcmu_reconfig_types {
+   NO_RECONFIG,
+   CONFIG_PATH,
+   CONFIG_SIZE,
+   CONFIG_WRITECACHE,
+};
+
 #endif
-- 
2.5.4 (Apple Git-61)



[PATCH v4 4/5] tcmu: Make dev_config configurable

2017-06-06 Thread Bryant G. Ly
This allows for userspace to change the device path after
it has been created. Thus giving the user the ability to change
the path. The use case for this is to allow for virtual optical
to have media change.

Signed-off-by: Bryant G. Ly 
---
 drivers/target/target_core_user.c | 41 +++
 1 file changed, 41 insertions(+)

diff --git a/drivers/target/target_core_user.c 
b/drivers/target/target_core_user.c
index c8c84b7..7c64757 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1548,6 +1548,46 @@ static ssize_t tcmu_cmd_time_out_store(struct 
config_item *item, const char *pag
 }
 CONFIGFS_ATTR(tcmu_, cmd_time_out);
 
+static ssize_t tcmu_dev_path_show(struct config_item *item, char *page)
+{
+   struct se_dev_attrib *da = container_of(to_config_group(item),
+   struct se_dev_attrib, da_group);
+   struct tcmu_dev *udev = TCMU_DEV(da->da_dev);
+
+   return snprintf(page, PAGE_SIZE, "%s\n", udev->dev_config);
+}
+
+static ssize_t tcmu_dev_path_store(struct config_item *item, const char *page,
+  size_t count)
+{
+   struct se_dev_attrib *da = container_of(to_config_group(item),
+   struct se_dev_attrib, da_group);
+   struct tcmu_dev *udev = TCMU_DEV(da->da_dev);
+   char *copy = NULL;
+   int ret;
+
+   copy = kstrdup(page, GFP_KERNEL);
+   if (!copy) {
+   kfree(copy);
+   return -EINVAL;
+   }
+   strlcpy(udev->dev_config, copy, TCMU_CONFIG_LEN);
+
+   /* Check if device has been configured before */
+   if (tcmu_dev_configured(udev)) {
+   ret = tcmu_netlink_event(TCMU_CMD_RECONFIG_DEVICE,
+udev->uio_info.name,
+udev->uio_info.uio_dev->minor);
+   if (ret) {
+   pr_err("Unable to reconfigure device\n");
+   return ret;
+   }
+   }
+
+   return count;
+}
+CONFIGFS_ATTR(tcmu_, dev_path);
+
 static ssize_t tcmu_dev_size_show(struct config_item *item, char *page)
 {
struct se_dev_attrib *da = container_of(to_config_group(item),
@@ -1626,6 +1666,7 @@ CONFIGFS_ATTR(tcmu_, emulate_write_cache);
 
 struct configfs_attribute *tcmu_attrib_attrs[] = {
_attr_cmd_time_out,
+   _attr_dev_path,
_attr_dev_size,
_attr_emulate_write_cache,
NULL,
-- 
2.5.4 (Apple Git-61)



[PATCH v4 2/5] tcmu: Add netlink for device reconfiguration

2017-06-06 Thread Bryant G. Ly
This gives tcmu the ability to handle events that can cause
reconfiguration, such as resize, path changes, write_cache, etc...

Signed-off-by: Bryant G. Ly 
Reviewed-By: Mike Christie 
---
 drivers/target/target_core_user.c | 12 
 include/uapi/linux/target_core_user.h |  1 +
 2 files changed, 13 insertions(+)

diff --git a/drivers/target/target_core_user.c 
b/drivers/target/target_core_user.c
index 0c797cc..ae91822 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1562,6 +1562,7 @@ static ssize_t tcmu_emulate_write_cache_store(struct 
config_item *item,
 {
struct se_dev_attrib *da = container_of(to_config_group(item),
struct se_dev_attrib, da_group);
+   struct tcmu_dev *udev = TCMU_DEV(da->da_dev);
int val;
int ret;
 
@@ -1570,6 +1571,17 @@ static ssize_t tcmu_emulate_write_cache_store(struct 
config_item *item,
return ret;
 
da->emulate_write_cache = val;
+
+   /* Check if device has been configured before */
+   if (tcmu_dev_configured(udev)) {
+   ret = tcmu_netlink_event(TCMU_CMD_RECONFIG_DEVICE,
+udev->uio_info.name,
+udev->uio_info.uio_dev->minor);
+   if (ret) {
+   pr_err("Unable to reconfigure device\n");
+   return ret;
+   }
+   }
return count;
 }
 CONFIGFS_ATTR(tcmu_, emulate_write_cache);
diff --git a/include/uapi/linux/target_core_user.h 
b/include/uapi/linux/target_core_user.h
index af17b41..403a61f 100644
--- a/include/uapi/linux/target_core_user.h
+++ b/include/uapi/linux/target_core_user.h
@@ -130,6 +130,7 @@ enum tcmu_genl_cmd {
TCMU_CMD_UNSPEC,
TCMU_CMD_ADDED_DEVICE,
TCMU_CMD_REMOVED_DEVICE,
+   TCMU_CMD_RECONFIG_DEVICE,
__TCMU_CMD_MAX,
 };
 #define TCMU_CMD_MAX (__TCMU_CMD_MAX - 1)
-- 
2.5.4 (Apple Git-61)



[PATCH v4 0/5] tcmu: Add Type of reconfig into netlink

2017-06-06 Thread Bryant G. Ly
From: "Bryant G. Ly" 

This patch consists of adding a netlink to allow for reconfiguration
of a device in tcmu.

It also changes and adds some attributes that are reconfigurable:
write_cache, device size, and device path.

V2 - Fixes kfree in tcmu: Make dev_config configurable
V3 - Fixes spelling error
V4 - change strcpy to strlcpy for tcmu_dev_path_store and move
 tcmu_reconfig_type into target_core_user.h


Bryant G. Ly (5):
  tcmu: Support emulate_write_cache
  tcmu: Add netlink for device reconfiguration
  tcmu: Make dev_size configurable via userspace
  tcmu: Make dev_config configurable
  tcmu: Add Type of reconfig into netlink

 drivers/target/target_core_user.c | 152 --
 include/uapi/linux/target_core_user.h |   9 ++
 2 files changed, 155 insertions(+), 6 deletions(-)

-- 
2.5.4 (Apple Git-61)



[PATCH v4 1/5] tcmu: Support emulate_write_cache

2017-06-06 Thread Bryant G. Ly
This will enable the toggling of write_cache in tcmu through targetcli-fb

Signed-off-by: Bryant G. Ly 
Reviewed-By: Mike Christie 
---
 drivers/target/target_core_user.c | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/drivers/target/target_core_user.c 
b/drivers/target/target_core_user.c
index beb5f09..0c797cc 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1290,6 +1290,8 @@ static int tcmu_configure_device(struct se_device *dev)
/* Other attributes can be configured in userspace */
if (!dev->dev_attrib.hw_max_sectors)
dev->dev_attrib.hw_max_sectors = 128;
+   if (!dev->dev_attrib.emulate_write_cache)
+   dev->dev_attrib.emulate_write_cache = 0;
dev->dev_attrib.hw_queue_depth = 128;
 
/*
@@ -1546,6 +1548,32 @@ static ssize_t tcmu_cmd_time_out_store(struct 
config_item *item, const char *pag
 }
 CONFIGFS_ATTR(tcmu_, cmd_time_out);
 
+static ssize_t tcmu_emulate_write_cache_show(struct config_item *item,
+char *page)
+{
+   struct se_dev_attrib *da = container_of(to_config_group(item),
+   struct se_dev_attrib, da_group);
+
+   return snprintf(page, PAGE_SIZE, "%i\n", da->emulate_write_cache);
+}
+
+static ssize_t tcmu_emulate_write_cache_store(struct config_item *item,
+ const char *page, size_t count)
+{
+   struct se_dev_attrib *da = container_of(to_config_group(item),
+   struct se_dev_attrib, da_group);
+   int val;
+   int ret;
+
+   ret = kstrtouint(page, 0, );
+   if (ret < 0)
+   return ret;
+
+   da->emulate_write_cache = val;
+   return count;
+}
+CONFIGFS_ATTR(tcmu_, emulate_write_cache);
+
 static struct configfs_attribute **tcmu_attrs;
 
 static struct target_backend_ops tcmu_ops = {
@@ -1682,6 +1710,8 @@ static int __init tcmu_module_init(void)
tcmu_attrs[i] = passthrough_attrib_attrs[i];
}
tcmu_attrs[i] = _attr_cmd_time_out;
+   i++;
+   tcmu_attrs[i] = _attr_emulate_write_cache;
tcmu_ops.tb_dev_attrib_attrs = tcmu_attrs;
 
ret = transport_backend_register(_ops);
-- 
2.5.4 (Apple Git-61)



Re: next build: 113 warnings 0 failures (next/next-20170605)

2017-06-06 Thread Arnd Bergmann
On Mon, Jun 5, 2017 at 11:02 AM, Olof's autobuilder  wrote:
> Here are the build results from automated periodic testing.
>
> The tree being built was next, found at:
>
> http://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git (master 
> branch)
>
> Topmost commit:
>
> f0090bf Add linux-next specific files for 20170605
>
> Build logs (stderr only) can be found at the following link (experimental):
>
> http://arm-soc.lixom.net/buildlogs/next/next-20170605/
> Warnings:
>
>   1 drivers/scsi/qla2xxx/qla_init.c:6407:50: warning: format '%lx' 
> expects argument of type 'long unsigned int', but argument 5 has type 
> 'unsigned int' [-Wformat=]
>   1 drivers/scsi/qla2xxx/qla_init.c:6709:50: warning: format '%lx' 
> expects argument of type 'long unsigned int', but argument 5 has type 
> 'unsigned int' [-Wformat=]

Caused by b95b9452aacf ("scsi: qla2xxx: Fix crash due to mismatch mumber
of Q-pair creation for Multi queue"): Need to use %zx instead of %lx for
printing a size_t

>   2 drivers/i2c/i2c-stub.c:18:0: warning: "DEBUG" redefined

Caused by 6c42778780c4 ("i2c: stub: use pr_fmt"): "#define DEBUG"
now conflicts with "ccflags-$(CONFIG_I2C_DEBUG_CORE) := -DDEBUG"
in the Makefile.

> 109 drivers/usb/dwc2/hw.h:230:0: warning: "GUID" redefined

This was introduced yesterday, but appears to be fixed again already.

   Arnd


[PATCH V4 1/2] scsi: ufshcd-pci: Fix PM config

2017-06-06 Thread Adrian Hunter
Put PM functions under correct config options and use standard PM macros
to set callbacks.

Signed-off-by: Adrian Hunter 
---
 drivers/scsi/ufs/ufshcd-pci.c | 22 +-
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
index 5dd4122cbd85..0dcff829f8b6 100644
--- a/drivers/scsi/ufs/ufshcd-pci.c
+++ b/drivers/scsi/ufs/ufshcd-pci.c
@@ -37,7 +37,7 @@
 #include 
 #include 
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 /**
  * ufshcd_pci_suspend - suspend power management function
  * @pdev: pointer to PCI device handle
@@ -62,7 +62,9 @@ static int ufshcd_pci_resume(struct device *dev)
 {
return ufshcd_system_resume(dev_get_drvdata(dev));
 }
+#endif /* !CONFIG_PM_SLEEP */
 
+#ifdef CONFIG_PM
 static int ufshcd_pci_runtime_suspend(struct device *dev)
 {
return ufshcd_runtime_suspend(dev_get_drvdata(dev));
@@ -75,13 +77,7 @@ static int ufshcd_pci_runtime_idle(struct device *dev)
 {
return ufshcd_runtime_idle(dev_get_drvdata(dev));
 }
-#else /* !CONFIG_PM */
-#define ufshcd_pci_suspend NULL
-#define ufshcd_pci_resume  NULL
-#define ufshcd_pci_runtime_suspend NULL
-#define ufshcd_pci_runtime_resume  NULL
-#define ufshcd_pci_runtime_idleNULL
-#endif /* CONFIG_PM */
+#endif /* !CONFIG_PM */
 
 /**
  * ufshcd_pci_shutdown - main function to put the controller in reset state
@@ -158,11 +154,11 @@ static void ufshcd_pci_remove(struct pci_dev *pdev)
 }
 
 static const struct dev_pm_ops ufshcd_pci_pm_ops = {
-   .suspend= ufshcd_pci_suspend,
-   .resume = ufshcd_pci_resume,
-   .runtime_suspend = ufshcd_pci_runtime_suspend,
-   .runtime_resume  = ufshcd_pci_runtime_resume,
-   .runtime_idle= ufshcd_pci_runtime_idle,
+   SET_SYSTEM_SLEEP_PM_OPS(ufshcd_pci_suspend,
+   ufshcd_pci_resume)
+   SET_RUNTIME_PM_OPS(ufshcd_pci_runtime_suspend,
+  ufshcd_pci_runtime_resume,
+  ufshcd_pci_runtime_idle)
 };
 
 static const struct pci_device_id ufshcd_pci_tbl[] = {
-- 
1.9.1



[PATCH V4 2/2] scsi: ufshcd-pci: Add Intel CNL support

2017-06-06 Thread Adrian Hunter
Add PCI id and variant ops for Intel CNL UFS host controller.

Signed-off-by: Adrian Hunter 
---
 drivers/scsi/ufs/ufshcd-pci.c | 38 ++
 1 file changed, 38 insertions(+)

diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
index 0dcff829f8b6..925b0ec7ec54 100644
--- a/drivers/scsi/ufs/ufshcd-pci.c
+++ b/drivers/scsi/ufs/ufshcd-pci.c
@@ -37,6 +37,41 @@
 #include 
 #include 
 
+static int ufs_intel_disable_lcc(struct ufs_hba *hba)
+{
+   u32 attr = UIC_ARG_MIB(PA_LOCAL_TX_LCC_ENABLE);
+   u32 lcc_enable = 0;
+
+   ufshcd_dme_get(hba, attr, _enable);
+   if (lcc_enable)
+   ufshcd_dme_set(hba, attr, 0);
+
+   return 0;
+}
+
+static int ufs_intel_link_startup_notify(struct ufs_hba *hba,
+enum ufs_notify_change_status status)
+{
+   int err = 0;
+
+   switch (status) {
+   case PRE_CHANGE:
+   err = ufs_intel_disable_lcc(hba);
+   break;
+   case POST_CHANGE:
+   break;
+   default:
+   break;
+   }
+
+   return err;
+}
+
+static struct ufs_hba_variant_ops ufs_intel_cnl_hba_vops = {
+   .name   = "intel-pci",
+   .link_startup_notify= ufs_intel_link_startup_notify,
+};
+
 #ifdef CONFIG_PM_SLEEP
 /**
  * ufshcd_pci_suspend - suspend power management function
@@ -139,6 +174,8 @@ static void ufshcd_pci_remove(struct pci_dev *pdev)
return err;
}
 
+   hba->vops = (struct ufs_hba_variant_ops *)id->driver_data;
+
err = ufshcd_init(hba, mmio_base, pdev->irq);
if (err) {
dev_err(>dev, "Initialization failed\n");
@@ -163,6 +200,7 @@ static void ufshcd_pci_remove(struct pci_dev *pdev)
 
 static const struct pci_device_id ufshcd_pci_tbl[] = {
{ PCI_VENDOR_ID_SAMSUNG, 0xC00C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+   { PCI_VDEVICE(INTEL, 0x9DFA), (kernel_ulong_t)_intel_cnl_hba_vops },
{ } /* terminate list */
 };
 
-- 
1.9.1



[PATCH V4 0/2] scsi: ufshcd-pci: Add Intel CNL support

2017-06-06 Thread Adrian Hunter
Hi

Here is V4 of patches to add support for Intel UFS host controllers.


Changes in V4:

New patch "scsi: ufshcd-pci: Fix PM config"
Do not use a separate driver for Intel

Changes in V3:

Remove UFSHCI class code and match on PCI device ID

Changes in V2:

Change variant name from intel to intel-pci


Adrian Hunter (2):
  scsi: ufshcd-pci: Fix PM config
  scsi: ufshcd-pci: Add Intel CNL support

 drivers/scsi/ufs/ufshcd-pci.c | 60 +--
 1 file changed, 47 insertions(+), 13 deletions(-)


Regards
Adrian


Re: [PATCH V3 2/2] scsi: ufshcd-intel-pci: Add PCI driver for Intel Host controllers

2017-06-06 Thread Christoph Hellwig

This looks much better.  But the new file still looks almost like
a copy and paste of tc-dwc-g210-pci.c.  Wouldnt it make more sense to
start with a common ufshcd-pci driver that sets up the ufs_hba_variant_opsA
based on the PCI ID table?

Also given that this almost entitrely a copy & paste job of
tc-dwc-g210-pci.c. you should add the copyrights and following their
license.


Re: [PATCH 6/6] sd: add support for TCG OPAL self encrypting disks

2017-06-06 Thread Christoph Hellwig
On Mon, Jun 05, 2017 at 03:15:31PM -0600, Scott Bauer wrote:
> I'm not familiar at all with ATA, but I noticed there was no unlock from 
> suspend support
> in the series. Does ATA not have a way to determine if we're coming out of a 
> suspend?

I don't know, and not having a test system with a OPAL capable driver
and suspend support I could not even test the code.

> I see there are some power-ops in scsi/sd.c, if you do want to add it you can 
> mabe toss a
> 
> if (sdkp->security)
>opal_unlock_from_suspend(sdpk->opal_dev)
> 
> somewhere in the resume path? We handle null opal_devs and no unlock from 
> suspend list
> so calling it when nothing is set up is just a no-op.

Yeah, maybe.  We'll just need someone who could test it first.


Re: [PATCH 6/6] sd: add support for TCG OPAL self encrypting disks

2017-06-06 Thread Christoph Hellwig
On Mon, Jun 05, 2017 at 08:48:00PM -0400, Martin K. Petersen wrote:
> For WRITE SAME, scsi_report_opcode() is gated not only by
> sdev->no_report_opcodes but by sdev->no_write_same.
> 
> I'm concerned about firing off REPORT OPCODES to random devices without
> a sufficiently good heuristic. Doesn't look like SAT has anything to
> offer in this department, though. Maybe it's time to consider a
> vendor-specific Linux VPD page...

Eww.  Given that as far as I can tell only ATA devices implement
OPAL we could key it off that for now.  But that's only going to
defer the problem until support for other security protocols comes
along for real SCSI devices.

But as we already set no_report_opcodes for all usb-storage and
quirked uas devices I think the worst offenders are already covered
anyway.


[PATCH V3 2/2] scsi: ufshcd-intel-pci: Add PCI driver for Intel Host controllers

2017-06-06 Thread Adrian Hunter
From: Szymon Mielczarek 

This patch adds a glue pci driver for Intel UFS Host controllers.

Signed-off-by: Szymon Mielczarek 
Signed-off-by: Adrian Hunter 
---

Changes in V3:

Remove UFSHCI class code and match on PCI device ID

Changes in V2:

Change variant name from intel to intel-pci


 drivers/scsi/ufs/Kconfig|  11 +++
 drivers/scsi/ufs/Makefile   |   1 +
 drivers/scsi/ufs/ufshcd-intel-pci.c | 174 
 3 files changed, 186 insertions(+)
 create mode 100644 drivers/scsi/ufs/ufshcd-intel-pci.c

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index e27b4d4e6ae2..702420bc0fac 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -69,6 +69,17 @@ config SCSI_UFS_DWC_TC_PCI
 
  If unsure, say N.
 
+config SCSI_UFSHCD_INTEL_PCI
+   tristate "Intel PCI bus based UFS Controller support"
+   depends on SCSI_UFSHCD && PCI
+   ---help---
+   This selects the Intel PCI UFS Host Controller Interface. Select this if
+   you have Intel UFS Host Controller with PCI Interface.
+
+ If you have a controller with this interface, say Y or M here.
+
+ If unsure, say N.
+
 config SCSI_UFSHCD_PLATFORM
tristate "Platform bus based UFS Controller support"
depends on SCSI_UFSHCD
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index 6e77cb0bfee9..be817e1a 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -4,4 +4,5 @@ obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o 
ufshcd-dwc.o tc-d
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
+obj-$(CONFIG_SCSI_UFSHCD_INTEL_PCI) += ufshcd-intel-pci.o
 obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
diff --git a/drivers/scsi/ufs/ufshcd-intel-pci.c 
b/drivers/scsi/ufs/ufshcd-intel-pci.c
new file mode 100644
index ..4112bba666b4
--- /dev/null
+++ b/drivers/scsi/ufs/ufshcd-intel-pci.c
@@ -0,0 +1,174 @@
+/*
+ * Universal Flash Storage Intel Host controller PCI driver
+ *
+ * Copyright (c) 2017, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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 "ufshcd.h"
+#include 
+#include 
+
+#define PCI_DEVICE_ID_INTEL_UFS_CNL0x9dfa
+
+static int ufs_intel_disable_lcc(struct ufs_hba *hba)
+{
+   u32 attr = UIC_ARG_MIB(PA_LOCAL_TX_LCC_ENABLE);
+   u32 lcc_enable = 0;
+
+   ufshcd_dme_get(hba, attr, _enable);
+   if (lcc_enable)
+   ufshcd_dme_set(hba, attr, 0);
+
+   return 0;
+}
+
+static int ufs_intel_link_startup_notify(struct ufs_hba *hba,
+enum ufs_notify_change_status status)
+{
+   int err = 0;
+
+   switch (status) {
+   case PRE_CHANGE:
+   err = ufs_intel_disable_lcc(hba);
+   break;
+   case POST_CHANGE:
+   break;
+   default:
+   break;
+   }
+
+   return err;
+}
+
+static struct ufs_hba_variant_ops ufs_intel_hba_vops = {
+   .name   = "intel-pci",
+   .link_startup_notify= ufs_intel_link_startup_notify,
+};
+
+#ifdef CONFIG_PM_SLEEP
+static int ufs_intel_suspend(struct device *dev)
+{
+   return ufshcd_system_suspend(dev_get_drvdata(dev));
+}
+
+static int ufs_intel_resume(struct device *dev)
+{
+   return ufshcd_system_resume(dev_get_drvdata(dev));
+}
+#endif /* !CONFIG_PM_SLEEP */
+
+#ifdef CONFIG_PM
+static int ufs_intel_runtime_suspend(struct device *dev)
+{
+   return ufshcd_runtime_suspend(dev_get_drvdata(dev));
+}
+
+static int ufs_intel_runtime_resume(struct device *dev)
+{
+   return ufshcd_runtime_resume(dev_get_drvdata(dev));
+}
+
+static int ufs_intel_runtime_idle(struct device *dev)
+{
+   return ufshcd_runtime_idle(dev_get_drvdata(dev));
+}
+#endif /* !CONFIG_PM */
+
+static void ufs_intel_shutdown(struct pci_dev *pdev)
+{
+   ufshcd_shutdown((struct ufs_hba *)pci_get_drvdata(pdev));
+}
+
+static void ufs_intel_remove(struct pci_dev *pdev)
+{
+   struct ufs_hba *hba = pci_get_drvdata(pdev);
+
+   pm_runtime_forbid(>dev);
+   pm_runtime_get_noresume(>dev);
+   ufshcd_remove(hba);
+   ufshcd_dealloc_host(hba);
+}
+
+static int ufs_intel_probe(struct pci_dev *pdev, const struct pci_device_id 
*id)
+{
+   struct ufs_hba *hba;
+   void __iomem *mmio_base;
+   int err;
+
+   dev_info(>dev, "UFS controller found 

[no subject]

2017-06-06 Thread From Lori J. Robinson
Hello,

I am General Lori J. Robinson, I am presently in Afghanistan serving
the UN/NATO military assignment here,i have an important discussion
with you  kindly respond to me through my private  box
lori_robinson@hotmail.com  so that we can know ourselves better. I
hope to read from you if your are also interested. Thanks and hoping
to hear from you soonest.


Re: [PATCH 2/2] scsi: ufshcd-intel-pci: Add PCI driver for Intel Host controllers

2017-06-06 Thread Christoph Hellwig
> +#define PCI_CLASS_STORAGE_UFSHCI 0x010901

should me move to pci_ids.h

> +
> +#define UFSHCD_INTEL_PCI_UFSHCI_DEVICE() { \
> + .vendor  = PCI_VENDOR_ID_INTEL, \
> + .device  = PCI_ANY_ID, \
> + .subvendor   = PCI_ANY_ID, \
> + .subdevice   = PCI_ANY_ID, \
> + .class   = PCI_CLASS_STORAGE_UFSHCI, \
> + .class_mask  = ~0, \
> +}

Please don't use a macro for this.  And matching for any possible
future intel device with the classcode looks a little sketchy to
me to be honest.



Re: [PATCH V2 1/2] scsi: ufs: Tidy clocks list head usage

2017-06-06 Thread Adrian Hunter
Oops, sorry, didn't mean to send this one again, since it has been applied.



[PATCH V2 1/2] scsi: ufs: Tidy clocks list head usage

2017-06-06 Thread Adrian Hunter
From: Szymon Mielczarek 

Move the initialization of clocks list head to ufshcd_alloc_host so that
every driver doesn't have to do it. Remove checks for the list head being
NULL because that is not possible.

Signed-off-by: Szymon Mielczarek 
Signed-off-by: Adrian Hunter 
---
 drivers/scsi/ufs/tc-dwc-g210-pci.c |  2 --
 drivers/scsi/ufs/ufshcd-pci.c  |  2 --
 drivers/scsi/ufs/ufshcd-pltfrm.c   |  2 --
 drivers/scsi/ufs/ufshcd.c  | 12 +++-
 4 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/ufs/tc-dwc-g210-pci.c 
b/drivers/scsi/ufs/tc-dwc-g210-pci.c
index c09a0fef0fe6..325d5e14fc0d 100644
--- a/drivers/scsi/ufs/tc-dwc-g210-pci.c
+++ b/drivers/scsi/ufs/tc-dwc-g210-pci.c
@@ -130,8 +130,6 @@ static void tc_dwc_g210_pci_remove(struct pci_dev *pdev)
return err;
}
 
-   INIT_LIST_HEAD(>clk_list_head);
-
hba->vops = _dwc_g210_pci_hba_vops;
 
err = ufshcd_init(hba, mmio_base, pdev->irq);
diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
index 52b546fb509b..5dd4122cbd85 100644
--- a/drivers/scsi/ufs/ufshcd-pci.c
+++ b/drivers/scsi/ufs/ufshcd-pci.c
@@ -143,8 +143,6 @@ static void ufshcd_pci_remove(struct pci_dev *pdev)
return err;
}
 
-   INIT_LIST_HEAD(>clk_list_head);
-
err = ufshcd_init(hba, mmio_base, pdev->irq);
if (err) {
dev_err(>dev, "Initialization failed\n");
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index 8e5e6c04c035..e82bde077296 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -58,8 +58,6 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
if (!np)
goto out;
 
-   INIT_LIST_HEAD(>clk_list_head);
-
cnt = of_property_count_strings(np, "clock-names");
if (!cnt || (cnt == -EINVAL)) {
dev_info(dev, "%s: Unable to find clocks, assuming enabled\n",
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index ffe8d8608818..88ccd63f83c1 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -314,7 +314,7 @@ static void ufshcd_print_clk_freqs(struct ufs_hba *hba)
struct ufs_clk_info *clki;
struct list_head *head = >clk_list_head;
 
-   if (!head || list_empty(head))
+   if (list_empty(head))
return;
 
list_for_each_entry(clki, head, list) {
@@ -869,7 +869,7 @@ static int ufshcd_scale_clks(struct ufs_hba *hba, bool 
scale_up)
ktime_t start = ktime_get();
bool clk_state_changed = false;
 
-   if (!head || list_empty(head))
+   if (list_empty(head))
goto out;
 
ret = ufshcd_vops_clk_scale_notify(hba, scale_up, PRE_CHANGE);
@@ -943,7 +943,7 @@ static bool ufshcd_is_devfreq_scaling_required(struct 
ufs_hba *hba,
struct ufs_clk_info *clki;
struct list_head *head = >clk_list_head;
 
-   if (!head || list_empty(head))
+   if (list_empty(head))
return false;
 
list_for_each_entry(clki, head, list) {
@@ -6752,7 +6752,7 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, 
bool on,
ktime_t start = ktime_get();
bool clk_state_changed = false;
 
-   if (!head || list_empty(head))
+   if (list_empty(head))
goto out;
 
ret = ufshcd_vops_setup_clocks(hba, on, PRE_CHANGE);
@@ -6818,7 +6818,7 @@ static int ufshcd_init_clocks(struct ufs_hba *hba)
struct device *dev = hba->dev;
struct list_head *head = >clk_list_head;
 
-   if (!head || list_empty(head))
+   if (list_empty(head))
goto out;
 
list_for_each_entry(clki, head, list) {
@@ -7811,6 +7811,8 @@ int ufshcd_alloc_host(struct device *dev, struct ufs_hba 
**hba_handle)
hba->dev = dev;
*hba_handle = hba;
 
+   INIT_LIST_HEAD(>clk_list_head);
+
 out_error:
return err;
 }
-- 
1.9.1



[PATCH V2 2/2] scsi: ufshcd-intel-pci: Add PCI driver for Intel Host controllers

2017-06-06 Thread Adrian Hunter
From: Szymon Mielczarek 

This patch adds a glue pci driver for Intel UFS Host controllers.

Signed-off-by: Szymon Mielczarek 
Signed-off-by: Adrian Hunter 
---


Changes in V2:

Change variant name from intel to intel-pci


 drivers/scsi/ufs/Kconfig|  11 +++
 drivers/scsi/ufs/Makefile   |   1 +
 drivers/scsi/ufs/ufshcd-intel-pci.c | 183 
 3 files changed, 195 insertions(+)
 create mode 100644 drivers/scsi/ufs/ufshcd-intel-pci.c

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index e27b4d4e6ae2..702420bc0fac 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -69,6 +69,17 @@ config SCSI_UFS_DWC_TC_PCI
 
  If unsure, say N.
 
+config SCSI_UFSHCD_INTEL_PCI
+   tristate "Intel PCI bus based UFS Controller support"
+   depends on SCSI_UFSHCD && PCI
+   ---help---
+   This selects the Intel PCI UFS Host Controller Interface. Select this if
+   you have Intel UFS Host Controller with PCI Interface.
+
+ If you have a controller with this interface, say Y or M here.
+
+ If unsure, say N.
+
 config SCSI_UFSHCD_PLATFORM
tristate "Platform bus based UFS Controller support"
depends on SCSI_UFSHCD
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index 6e77cb0bfee9..be817e1a 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -4,4 +4,5 @@ obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o 
ufshcd-dwc.o tc-d
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
+obj-$(CONFIG_SCSI_UFSHCD_INTEL_PCI) += ufshcd-intel-pci.o
 obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
diff --git a/drivers/scsi/ufs/ufshcd-intel-pci.c 
b/drivers/scsi/ufs/ufshcd-intel-pci.c
new file mode 100644
index ..0b8dcce5ee3b
--- /dev/null
+++ b/drivers/scsi/ufs/ufshcd-intel-pci.c
@@ -0,0 +1,183 @@
+/*
+ * Universal Flash Storage Intel Host controller PCI driver
+ *
+ * Copyright (c) 2017, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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 "ufshcd.h"
+#include 
+#include 
+
+static int ufs_intel_disable_lcc(struct ufs_hba *hba)
+{
+   u32 attr = UIC_ARG_MIB(PA_LOCAL_TX_LCC_ENABLE);
+   u32 lcc_enable = 0;
+
+   ufshcd_dme_get(hba, attr, _enable);
+   if (lcc_enable)
+   ufshcd_dme_set(hba, attr, 0);
+
+   return 0;
+}
+
+static int ufs_intel_link_startup_notify(struct ufs_hba *hba,
+enum ufs_notify_change_status status)
+{
+   int err = 0;
+
+   switch (status) {
+   case PRE_CHANGE:
+   err = ufs_intel_disable_lcc(hba);
+   break;
+   case POST_CHANGE:
+   break;
+   default:
+   break;
+   }
+
+   return err;
+}
+
+static struct ufs_hba_variant_ops ufs_intel_hba_vops = {
+   .name   = "intel-pci",
+   .link_startup_notify= ufs_intel_link_startup_notify,
+};
+
+#ifdef CONFIG_PM_SLEEP
+static int ufs_intel_suspend(struct device *dev)
+{
+   return ufshcd_system_suspend(dev_get_drvdata(dev));
+}
+
+static int ufs_intel_resume(struct device *dev)
+{
+   return ufshcd_system_resume(dev_get_drvdata(dev));
+}
+#endif /* !CONFIG_PM_SLEEP */
+
+#ifdef CONFIG_PM
+static int ufs_intel_runtime_suspend(struct device *dev)
+{
+   return ufshcd_runtime_suspend(dev_get_drvdata(dev));
+}
+
+static int ufs_intel_runtime_resume(struct device *dev)
+{
+   return ufshcd_runtime_resume(dev_get_drvdata(dev));
+}
+
+static int ufs_intel_runtime_idle(struct device *dev)
+{
+   return ufshcd_runtime_idle(dev_get_drvdata(dev));
+}
+#endif /* !CONFIG_PM */
+
+static void ufs_intel_shutdown(struct pci_dev *pdev)
+{
+   ufshcd_shutdown((struct ufs_hba *)pci_get_drvdata(pdev));
+}
+
+static void ufs_intel_remove(struct pci_dev *pdev)
+{
+   struct ufs_hba *hba = pci_get_drvdata(pdev);
+
+   pm_runtime_forbid(>dev);
+   pm_runtime_get_noresume(>dev);
+   ufshcd_remove(hba);
+   ufshcd_dealloc_host(hba);
+}
+
+static int ufs_intel_probe(struct pci_dev *pdev, const struct pci_device_id 
*id)
+{
+   struct ufs_hba *hba;
+   void __iomem *mmio_base;
+   int err;
+
+   dev_info(>dev, "UFS controller found [%04x:%04x]\n",
+(int)pdev->vendor, (int)pdev->device);
+
+   err = pcim_enable_device(pdev);
+   if 

Re: [PATCH 6/6] sd: add support for TCG OPAL self encrypting disks

2017-06-06 Thread Hannes Reinecke
On 06/04/2017 02:42 PM, Christoph Hellwig wrote:
> Just wire up the generic TCG OPAL infrastructure to the SCSI disk driver
> and the Security In/Out commands.
> 
> Note that I don't know of any actual SCSI disks that do support TCG OPAL,
> but this is required to support ATA disks through libata.
> 
> Signed-off-by: Christoph Hellwig 
> ---
>  drivers/scsi/sd.c | 44 
>  drivers/scsi/sd.h |  2 ++
>  2 files changed, 46 insertions(+)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH 5/6] libata: implement SECURITY PROTOCOL IN/OUT

2017-06-06 Thread Hannes Reinecke
On 06/04/2017 02:42 PM, Christoph Hellwig wrote:
> This allows us to use the generic OPAL code with ATA devices.
> 
> Signed-off-by: Christoph Hellwig 
> ---
>  drivers/ata/libata-core.c | 32 
>  drivers/ata/libata-scsi.c | 76 
> +++
>  include/linux/ata.h   |  1 +
>  include/linux/libata.h|  1 +
>  4 files changed, 110 insertions(+)
> Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH 4/6] libata: factor out a ata_identify_page_supported helper

2017-06-06 Thread Hannes Reinecke
On 06/04/2017 02:42 PM, Christoph Hellwig wrote:
> Signed-off-by: Christoph Hellwig 
> ---
>  drivers/ata/libata-core.c | 59 
> +--
>  1 file changed, 32 insertions(+), 27 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH 3/6] libata: clarify log page naming / grouping

2017-06-06 Thread Hannes Reinecke
On 06/04/2017 02:42 PM, Christoph Hellwig wrote:
> Signed-off-by: Christoph Hellwig 
> ---
>  drivers/ata/libata-core.c | 10 +-
>  include/linux/ata.h   | 10 +++---
>  2 files changed, 12 insertions(+), 8 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH 1/6] libata: move ata_read_log_page to libata-core.c

2017-06-06 Thread Hannes Reinecke
On 06/04/2017 02:42 PM, Christoph Hellwig wrote:
> It is core functionality, and only one of the users is in the EH code.
> 
> Signed-off-by: Christoph Hellwig 
> ---
>  drivers/ata/libata-core.c | 64 
> +++
>  drivers/ata/libata-eh.c   | 64 
> ---
>  drivers/ata/libata.h  |  4 +--
>  3 files changed, 66 insertions(+), 66 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH 2/6] libata: factor out a ata_log_supported helper

2017-06-06 Thread Hannes Reinecke
On 06/04/2017 02:42 PM, Christoph Hellwig wrote:
> Signed-off-by: Christoph Hellwig 
> ---
>  drivers/ata/libata-core.c | 59 
> +--
>  1 file changed, 16 insertions(+), 43 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)