Re: [lkp-robot] [scsi] ebc76736f2: fio.write_bw_MBps -4% regression

2017-06-19 Thread Christoph Hellwig
On Tue, Jun 20, 2017 at 10:16:36AM +0800, Ye Xiaolong wrote:
> Hi, Christoph
> 
> On 06/19, Christoph Hellwig wrote:
> >On Mon, Jun 19, 2017 at 04:52:36PM +0800, Ye Xiaolong wrote:
> >> >I've not seen a compile-time option for the MQ I/O scheduler (unlike
> >> >the legacy one), so the way to change it would be to echo the name to
> >> >/sys/block//queue/scheduler 
> >> 
> >> echo mq-deadline > /sys/block//queue/scheduler ?
> >> 
> >> I'll try and post the results once I get it.
> >
> >Thanks!
> 
> I've re-run the test and cat /sys/block/sda/queue/scheduler and
> /sys/block/sda/queue/scheduler, and both showed "[mq-deadline] kyber none",
> Does it mean they have already set as 'mq-deadline'?

Yes, it seems like you're already using mq-deadline, but bfq isn't even
available.


Re: [PATCH 3/6] qla2xxx: Add FC-NVMe F/W initialization and transport registration

2017-06-19 Thread Madhani, Himanshu

> On Jun 19, 2017, at 2:22 PM, James Smart  wrote:
> 
> On 6/16/2017 3:47 PM, Himanshu Madhani wrote:
>> From: Duane Grigsby 
>> 
>> This code provides the interfaces to register remote and local ports
>> of FC4 type 0x28 with the FC-NVMe transport and transports the
>> requests (FC-NVMe FC link services and FC-NVMe commands IUs) to the
>> fabric. It also provides the support for allocating h/w queues and
>> aborting FC-NVMe FC requests.
>> 
>> Signed-off-by: Darren Trapp 
>> Signed-off-by: Duane Grigsby 
>> Signed-off-by: Anil Gurumurthy 
>> Signed-off-by: Giridhar Malavali 
>> Signed-off-by: Himanshu Madhani 
>> 
>> +#if (IS_ENABLED(CONFIG_NVME_FC))
>> +extern int nvme_fc_register_remoteport(struct nvme_fc_local_port *,
>> +struct nvme_fc_port_info *, struct nvme_fc_remote_port **);
>> +extern int nvme_fc_register_localport(struct nvme_fc_port_info *,
>> +struct nvme_fc_port_template *, struct device *,
>> +struct nvme_fc_local_port **);
>> +extern int nvme_fc_unregister_localport(struct nvme_fc_local_port *);
>> +#endif
> 
> There should be no need for these. They are in the 
> include/linux/nvme-fc-driver.h header.
> 

Agree. Will remove it 

> 
>> +static void qla_nvme_sp_ls_done(void *ptr, int res)
>> +{
>> +srb_t *sp = ptr;
>> +struct srb_iocb *nvme;
>> +struct nvmefc_ls_req   *fd;
>> +struct nvme_private *priv;
>> +
>> +if (atomic_read(&sp->ref_count) == 0) {
>> +ql_log(ql_log_warn, sp->fcport->vha, 0x2123,
>> +"SP reference-count to ZERO on LS_done -- sp=%p.\n", sp);
>> +return;
>> +}
>> +
>> +if (!atomic_dec_and_test(&sp->ref_count))
>> +return;
>> +
>> +if (res)
>> +res = NVME_SC_FC_TRANSPORT_ERROR;
> 
> LS request failures status should be -Exxx values, not nvme status codes 
> (which don't apply to LS's).
> The api probably wasn't super clear on this.
> 

Will fix up in v2.

>> +
>> +nvme = &sp->u.iocb_cmd;
>> +fd = nvme->u.nvme.desc;
>> +priv = fd->private;
>> +priv->comp_status = res;
>> +schedule_work(&priv->ls_work);
>> +/* work schedule doesn't need the sp */
>> +qla2x00_rel_sp(sp);
>> +}
>> +
>> +static void qla_nvme_sp_done(void *ptr, int res)
>> +{
>> +srb_t *sp = ptr;
>> +struct srb_iocb *nvme;
>> +struct nvmefc_fcp_req *fd;
>> +
>> +nvme = &sp->u.iocb_cmd;
>> +fd = nvme->u.nvme.desc;
>> +
>> +if (!atomic_dec_and_test(&sp->ref_count))
>> +return;
>> +
>> +if (!(sp->fcport->nvme_flag & NVME_FLAG_REGISTERED))
>> +goto rel;
>> +
>> +if (unlikely((nvme->u.nvme.comp_status) || res))
>> +fd->status = NVME_SC_FC_TRANSPORT_ABORTED;
>> +else
>> +fd->status = 0;
> 
> FCP req failures status should be -Exxx values, not nvme status codes. This 
> is clear in the api header.
> 

Sure. Will fix this in v2. 

> -- james
> 





Re: [PATCH 2/6] qla2xxx: Add FC-NVMe command handling

2017-06-19 Thread Madhani, Himanshu

> On Jun 19, 2017, at 2:01 PM, James Smart  wrote:
> 
> On 6/16/2017 3:47 PM, Himanshu Madhani wrote:
>> @@ -615,8 +620,25 @@ struct sts_entry_24xx {
>>  uint32_t rsp_residual_count;/* FCP RSP residual count. */
>>  uint32_t sense_len; /* FCP SENSE length. */
>> -uint32_t rsp_data_len;  /* FCP response data length. */
>> -uint8_t data[28];   /* FCP response/sense information. */
>> +
>> +union {
>> +struct {
>> +uint32_t rsp_data_len;  /* FCP response data length  */
>> +uint8_t data[28];   /* FCP rsp/sense information */
>> +};
>> +struct {
>> +/* nvme ersp hdr */
>> +__u8status_code;
>> +__u8rsvd0;
>> +__be16  iu_len;
>> +__be32  rsn;
>> +__be32  xfrd_len;
>> +__be32  rsvd12;
>> +uint8_t cqe[16];
>> +};
>> +uint8_t nvme_ersp_data[32];
>> +};
>> +
> 
> rather than defining a new structure for ersp - can't you use the struct 
> nvme_fc_ersp_iu definition from include/linux/nvme-fc.h ?
> 

Sure. will remove this

> 
> 
>>  /*
>>   * If DIF Error is set in comp_status, these additional fields are
>>   * defined:
>> diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
>> index 40385bc1d1fa..0d60fd0da604 100644
>> --- a/drivers/scsi/qla2xxx/qla_isr.c
>> +++ b/drivers/scsi/qla2xxx/qla_isr.c
>> @@ -1799,6 +1799,86 @@ 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)
>> +{
>> +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;
>> +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)) {
>> +atomic_dec(&sp->vha->nvme_active_aen_cnt);
>> +/*
>> + * Needed right now since the transport doesn't cleanup
>> + * up AEN's IO's on remote port delete.
>> + * they could have gone away while we still have the *fd.
>> + */
>> +if (!atomic_read(&sp->fcport->nvme_ref_count)) {
>> +sp->done(sp, QLA_FUNCTION_FAILED);
>> +return;
> 
> The missing aen abort has been corrected for several months.. Should be no 
> need for it.
> 
Ack. Will remove it.

> 
>> @@ -5996,6 +5998,18 @@ qla2x00_timer(scsi_qla_host_t *vha)
>>  if (!list_empty(&vha->work_list))
>>  start_dpc++;
>>  +   /*
>> + * FC-NVME
>> + * see if the active AEN count has changed from what was last reported.
>> + */
>> +if (atomic_read(&vha->nvme_active_aen_cnt) != vha->nvme_last_rptd_aen) {
>> +vha->nvme_last_rptd_aen =
>> +atomic_read(&vha->nvme_active_aen_cnt);
>> +ql_log(ql_log_info, vha, 0x3002,
>> +"reporting new aen count of %d to the fw TBD\n",
>> +vha->nvme_last_rptd_aen);
>> +}
>> +
>>  /* Schedule the DPC routine if needed */
>>  if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
>>  test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) ||
> 
> Q: why does lldd need to track aen vs any other type of fcp operation ?

These are long lived exchanges and affect the adapter’s interrupt generation 
logic.

Thanks,
- Himanshu



Re: [PATCH 1/6] qla2xxx: Add FC-NVMe port discovery and PRLI handling

2017-06-19 Thread Madhani, Himanshu

> On Jun 19, 2017, at 1:26 PM, James Smart  wrote:
> 
> On 6/16/2017 3:47 PM, Himanshu Madhani wrote:
>>/* FCP-4 types */
>>  #define FC4_TYPE_FCP_SCSI   0x08
>> +#define FC4_TYPE_NVME   0x28
>>  #define FC4_TYPE_OTHER  0x0
>>  #define FC4_TYPE_UNKNOWN0xff
> 
> please use the types from include/uapi/scsi/fc/fc_fs.h

Sure.


Re: [lkp-robot] [scsi] ebc76736f2: fio.write_bw_MBps -4% regression

2017-06-19 Thread Ye Xiaolong
Hi, Christoph

On 06/19, Christoph Hellwig wrote:
>On Mon, Jun 19, 2017 at 04:52:36PM +0800, Ye Xiaolong wrote:
>> >I've not seen a compile-time option for the MQ I/O scheduler (unlike
>> >the legacy one), so the way to change it would be to echo the name to
>> >/sys/block//queue/scheduler 
>> 
>> echo mq-deadline > /sys/block//queue/scheduler ?
>> 
>> I'll try and post the results once I get it.
>
>Thanks!

I've re-run the test and cat /sys/block/sda/queue/scheduler and
/sys/block/sda/queue/scheduler, and both showed "[mq-deadline] kyber none",
Does it mean they have already set as 'mq-deadline'?

Thanks,
Xiaolong


Re: [PATCH 0/2] qedi: Remove unwanted warnings.

2017-06-19 Thread Martin K. Petersen

Manish,

> Please consider below patches for next 'scsi-fixes' submission.

Applied to 4.12/scsi-fixes, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH v6 00/22] hisi_sas: hip08 support

2017-06-19 Thread Martin K. Petersen

John,

> This patchset adds support for the HiSilicon SAS controller in the
> hip08 chipset.

Applied to 4.13/scsi-queue. Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 00/11] lpfc updates for 11.4.0.1

2017-06-19 Thread Martin K. Petersen

James,

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

Applied to 4.13/scsi-queue, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] tcmu: Add fifo type waiter list support to avoidstarvation

2017-06-19 Thread Xiubo Li

Hi Nic & Mike

I will update this just after the issue reported by Bryant on his 
environment been fixed later.


Thanks,
BRs
Xiubo


On 2017年06月04日 12:11, Mike Christie wrote:

On 05/04/2017 09:51 PM, lixi...@cmss.chinamobile.com wrote:

From: Xiubo Li 

The fifo type waiter list will hold the udevs who are waiting for the
blocks from the data global pool. The unmap thread will try to feed the
first udevs in waiter list, if the global free blocks available are
not enough, it will stop traversing the list and abort waking up the
others.

Signed-off-by: Xiubo Li 
---
  drivers/target/target_core_user.c | 82 +++
  1 file changed, 66 insertions(+), 16 deletions(-)

diff --git a/drivers/target/target_core_user.c 
b/drivers/target/target_core_user.c
index 9045837..10c99e7 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -97,6 +97,7 @@ struct tcmu_hba {
  
  struct tcmu_dev {

struct list_head node;
+   struct list_head waiter;
  
  	struct se_device se_dev;
  
@@ -123,7 +124,7 @@ struct tcmu_dev {

wait_queue_head_t wait_cmdr;
struct mutex cmdr_lock;
  
-	bool waiting_global;

+   uint32_t waiting_blocks;
uint32_t dbi_max;
uint32_t dbi_thresh;
DECLARE_BITMAP(data_bitmap, DATA_BLOCK_BITS);
@@ -165,6 +166,10 @@ struct tcmu_cmd {
  static DEFINE_MUTEX(root_udev_mutex);
  static LIST_HEAD(root_udev);
  
+/* The data blocks global pool waiter list */

+static DEFINE_MUTEX(root_udev_waiter_mutex);

Sorry for the delay.


Could you just add a comment about the lock ordering. It will be helpful
to new engineers/reviewers to check for errors.



+static LIST_HEAD(root_udev_waiter);
+
  static atomic_t global_db_count = ATOMIC_INIT(0);
  
  static struct kmem_cache *tcmu_cmd_cache;

@@ -195,6 +200,11 @@ enum tcmu_multicast_groups {
  #define tcmu_cmd_set_dbi(cmd, index) ((cmd)->dbi[(cmd)->dbi_cur++] = (index))
  #define tcmu_cmd_get_dbi(cmd) ((cmd)->dbi[(cmd)->dbi_cur++])
  
+static inline bool is_in_waiter_list(struct tcmu_dev *udev)

+{
+   return !!udev->waiting_blocks;
+}
+
  static void tcmu_cmd_free_data(struct tcmu_cmd *tcmu_cmd, uint32_t len)
  {
struct tcmu_dev *udev = tcmu_cmd->tcmu_dev;
@@ -250,8 +260,6 @@ static bool tcmu_get_empty_blocks(struct tcmu_dev *udev,
  {
int i;
  
-	udev->waiting_global = false;

-
for (i = tcmu_cmd->dbi_cur; i < tcmu_cmd->dbi_cnt; i++) {
if (!tcmu_get_empty_block(udev, tcmu_cmd))
goto err;
@@ -259,9 +267,7 @@ static bool tcmu_get_empty_blocks(struct tcmu_dev *udev,
return true;
  
  err:

-   udev->waiting_global = true;
-   /* Try to wake up the unmap thread */
-   wake_up(&unmap_wait);
+   udev->waiting_blocks += tcmu_cmd->dbi_cnt - i;
return false;
  }
  
@@ -671,6 +677,7 @@ static inline size_t tcmu_cmd_get_cmd_size(struct tcmu_cmd *tcmu_cmd,
  
  	while (!is_ring_space_avail(udev, tcmu_cmd, command_size, data_length)) {

int ret;
+   bool is_waiting_blocks = !!udev->waiting_blocks;

You can use your helper is_in_waiter_list().


DEFINE_WAIT(__wait);
  
  		prepare_to_wait(&udev->wait_cmdr, &__wait, TASK_INTERRUPTIBLE);

@@ -688,6 +695,18 @@ static inline size_t tcmu_cmd_get_cmd_size(struct tcmu_cmd 
*tcmu_cmd,
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
}
  
+		/*

+* Try to insert the current udev to waiter list and
+* then wake up the unmap thread
+*/
+   if (is_waiting_blocks) {
+   mutex_lock(&root_udev_waiter_mutex);
+   list_add_tail(&udev->waiter, &root_udev_waiter);
+   mutex_unlock(&root_udev_waiter_mutex);
+
+   wake_up(&unmap_wait);
+   }

Is this supposed to go before the schedule_timeout call?

If we are here and schedule_timeout returned non zero then our wait_cmdr
has been woken up from the unmap thread because it freed some space, so
we do not want to again add ourself and call unmap again.



+
mutex_lock(&udev->cmdr_lock);
  
  		/* We dropped cmdr_lock, cmd_head is stale */

@@ -902,8 +921,6 @@ static unsigned int tcmu_handle_completions(struct tcmu_dev 
*udev)
if (mb->cmd_tail == mb->cmd_head)
del_timer(&udev->timeout); /* no more pending cmds */
  
-	wake_up(&udev->wait_cmdr);

-
return handled;
  }
  
@@ -996,7 +1013,17 @@ static int tcmu_irqcontrol(struct uio_info *info, s32 irq_on)

struct tcmu_dev *tcmu_dev = container_of(info, struct tcmu_dev, 
uio_info);
  
  	mutex_lock(&tcmu_dev->cmdr_lock);

-   tcmu_handle_completions(tcmu_dev);
+   /*
+* If the current udev is also in waiter list, this will
+* make sure that the other waiters in list be feeded ahead
+* of it.
+*/
+   if (is_in_waite

Re: Reply Urgent

2017-06-19 Thread INFO

Hello,

How are you doing? I have been sent to inform you that, We have an  
inheritance of a deceased client with your surname. Contact Mr Andrew  
Bailey Reply Email To: myinf...@gmail.com with your "Full Names" for  
more info.  Thanks for your understanding.


Reply ASAP thank you.

Melissa.
--
Correo Corporativo Hospital Universitario del Valle E.S.E
***

"Estamos re-dimensionandonos para crecer!"

**




Re: [PATCH 6/6] qla2xxx: Update Driver version to 10.00.00.00-k

2017-06-19 Thread James Smart

On 6/16/2017 3:47 PM, Himanshu Madhani wrote:

Signed-off-by: Himanshu Madhani 



Reviewed-by: James Smart 



Re: [PATCH 5/6] qla2xxx: Use FC-NMVe FC4 type for FDMI registration

2017-06-19 Thread James Smart

On 6/16/2017 3:47 PM, Himanshu Madhani wrote:

From: Duane Grigsby 

Signed-off-by: Duane Grigsby 
Signed-off-by: Darren Trapp 
Signed-off-by: Anil Gurumurthy 
Signed-off-by: Giridhar Malavali 
Signed-off-by: Himanshu Madhani 
---



Reviewed-by: James Smart 



Re: [PATCH 4/6] qla2xxx: Send FC4 type NVMe to the management server

2017-06-19 Thread James Smart

On 6/16/2017 3:47 PM, Himanshu Madhani wrote:

From: Duane Grigsby 

This patch adds switch command support for FC-4 type of FC-NVMe (0x28)
for resgistering HBA port to the management server. RFT_ID command is
used to register FC-4 type of 0x28 and RFF_ID is used to register
FC-4 features bits for FC-NVMe port.

Signed-off-by: Darren Trapp 
Signed-off-by: Duane Grigsby 
Signed-off-by: Anil Gurumurthy 
Signed-off-by: Giridhar Malavali 
Signed-off-by: Himanshu Madhani 
---



Reviewed-By: James Smart 



Re: [PATCH 3/6] qla2xxx: Add FC-NVMe F/W initialization and transport registration

2017-06-19 Thread James Smart

On 6/16/2017 3:47 PM, Himanshu Madhani wrote:

From: Duane Grigsby 

This code provides the interfaces to register remote and local ports
of FC4 type 0x28 with the FC-NVMe transport and transports the
requests (FC-NVMe FC link services and FC-NVMe commands IUs) to the
fabric. It also provides the support for allocating h/w queues and
aborting FC-NVMe FC requests.

Signed-off-by: Darren Trapp 
Signed-off-by: Duane Grigsby 
Signed-off-by: Anil Gurumurthy 
Signed-off-by: Giridhar Malavali 
Signed-off-by: Himanshu Madhani 

+#if (IS_ENABLED(CONFIG_NVME_FC))
+extern int nvme_fc_register_remoteport(struct nvme_fc_local_port *,
+struct nvme_fc_port_info *, struct nvme_fc_remote_port **);
+extern int nvme_fc_register_localport(struct nvme_fc_port_info *,
+struct nvme_fc_port_template *, struct device *,
+struct nvme_fc_local_port **);
+extern int nvme_fc_unregister_localport(struct nvme_fc_local_port *);
+#endif


There should be no need for these. They are in the 
include/linux/nvme-fc-driver.h header.




+static void qla_nvme_sp_ls_done(void *ptr, int res)
+{
+   srb_t *sp = ptr;
+   struct srb_iocb *nvme;
+   struct nvmefc_ls_req   *fd;
+   struct nvme_private *priv;
+
+   if (atomic_read(&sp->ref_count) == 0) {
+   ql_log(ql_log_warn, sp->fcport->vha, 0x2123,
+   "SP reference-count to ZERO on LS_done -- sp=%p.\n", sp);
+   return;
+   }
+
+   if (!atomic_dec_and_test(&sp->ref_count))
+   return;
+
+   if (res)
+   res = NVME_SC_FC_TRANSPORT_ERROR;


LS request failures status should be -Exxx values, not nvme status codes 
(which don't apply to LS's).

The api probably wasn't super clear on this.


+
+   nvme = &sp->u.iocb_cmd;
+   fd = nvme->u.nvme.desc;
+   priv = fd->private;
+   priv->comp_status = res;
+   schedule_work(&priv->ls_work);
+   /* work schedule doesn't need the sp */
+   qla2x00_rel_sp(sp);
+}
+
+static void qla_nvme_sp_done(void *ptr, int res)
+{
+   srb_t *sp = ptr;
+   struct srb_iocb *nvme;
+   struct nvmefc_fcp_req *fd;
+
+   nvme = &sp->u.iocb_cmd;
+   fd = nvme->u.nvme.desc;
+
+   if (!atomic_dec_and_test(&sp->ref_count))
+   return;
+
+   if (!(sp->fcport->nvme_flag & NVME_FLAG_REGISTERED))
+   goto rel;
+
+   if (unlikely((nvme->u.nvme.comp_status) || res))
+   fd->status = NVME_SC_FC_TRANSPORT_ABORTED;
+   else
+   fd->status = 0;


FCP req failures status should be -Exxx values, not nvme status codes. 
This is clear in the api header.


-- james



Re: [PATCH 2/6] qla2xxx: Add FC-NVMe command handling

2017-06-19 Thread James Smart

On 6/16/2017 3:47 PM, Himanshu Madhani wrote:

@@ -615,8 +620,25 @@ struct sts_entry_24xx {
uint32_t rsp_residual_count;/* FCP RSP residual count. */
  
  	uint32_t sense_len;		/* FCP SENSE length. */

-   uint32_t rsp_data_len;  /* FCP response data length. */
-   uint8_t data[28];   /* FCP response/sense information. */
+
+   union {
+   struct {
+   uint32_t rsp_data_len;  /* FCP response data length  */
+   uint8_t data[28];   /* FCP rsp/sense information */
+   };
+   struct {
+   /* nvme ersp hdr */
+   __u8status_code;
+   __u8rsvd0;
+   __be16  iu_len;
+   __be32  rsn;
+   __be32  xfrd_len;
+   __be32  rsvd12;
+   uint8_t cqe[16];
+   };
+   uint8_t nvme_ersp_data[32];
+   };
+


rather than defining a new structure for ersp - can't you use the struct 
nvme_fc_ersp_iu definition from include/linux/nvme-fc.h ?





/*
 * If DIF Error is set in comp_status, these additional fields are
 * defined:
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 40385bc1d1fa..0d60fd0da604 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1799,6 +1799,86 @@ 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)
+{
+   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;
+   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)) {
+   atomic_dec(&sp->vha->nvme_active_aen_cnt);
+   /*
+* Needed right now since the transport doesn't cleanup
+* up AEN's IO's on remote port delete.
+* they could have gone away while we still have the *fd.
+*/
+   if (!atomic_read(&sp->fcport->nvme_ref_count)) {
+   sp->done(sp, QLA_FUNCTION_FAILED);
+   return;


The missing aen abort has been corrected for several months.. Should be 
no need for it.




@@ -5996,6 +5998,18 @@ qla2x00_timer(scsi_qla_host_t *vha)
if (!list_empty(&vha->work_list))
start_dpc++;
  
+	/*

+* FC-NVME
+* see if the active AEN count has changed from what was last reported.
+*/
+   if (atomic_read(&vha->nvme_active_aen_cnt) != vha->nvme_last_rptd_aen) {
+   vha->nvme_last_rptd_aen =
+   atomic_read(&vha->nvme_active_aen_cnt);
+   ql_log(ql_log_info, vha, 0x3002,
+   "reporting new aen count of %d to the fw TBD\n",
+   vha->nvme_last_rptd_aen);
+   }
+
/* Schedule the DPC routine if needed */
if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) ||


Q: why does lldd need to track aen vs any other type of fcp operation ?




Re: [PATCH 1/6] qla2xxx: Add FC-NVMe port discovery and PRLI handling

2017-06-19 Thread James Smart

On 6/16/2017 3:47 PM, Himanshu Madhani wrote:
  
  /* FCP-4 types */

  #define FC4_TYPE_FCP_SCSI 0x08
+#define FC4_TYPE_NVME  0x28
  #define FC4_TYPE_OTHER0x0
  #define FC4_TYPE_UNKNOWN  0xff


please use the types from include/uapi/scsi/fc/fc_fs.h





[Bug 176951] boot fails unless acpi=off Acer Travelmate X-349

2017-06-19 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=176951

--- Comment #27 from mus@gmail.com ---
Can confirm, this seems to be fixed in 4.12-rc5 mainline (Arch Linux x64).
Machine boots and works fine now, even in UEFI mode.

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


Re: [PATCH 3/6] qla2xxx: Add FC-NVMe F/W initialization and transport registration

2017-06-19 Thread Madhani, Himanshu

> On Jun 19, 2017, at 3:01 AM, Johannes Thumshirn  wrote:
> 
> On Fri, Jun 16, 2017 at 03:47:41PM -0700, Himanshu Madhani wrote:
> [...]
>> /*
>> + * Global functions prototype in qla_nvme.c source file.
>> + */
>> +extern void qla_nvme_register_hba(scsi_qla_host_t *);
>> +extern int  qla_nvme_register_remote(scsi_qla_host_t *, fc_port_t *);
>> +extern void qla_nvme_delete(scsi_qla_host_t *);
>> +extern void qla_nvme_abort(struct qla_hw_data *, srb_t *sp);
>> +extern void qla_nvme_unregister_remote_port(struct work_struct *);
>> +extern int qla_nvme_wait_on_rport_del(fc_port_t *);
>> +extern void qla_nvme_abort_all(fc_port_t *);
>> +extern int qla_nvme_post_cmd(struct nvme_fc_local_port *,
>> +struct nvme_fc_remote_port *, void *, struct nvmefc_fcp_req *);
>> +extern int qla_nvme_alloc_queue(struct nvme_fc_local_port *, unsigned int,
>> +u16, void **);
>> +extern int qla_nvme_hba_scan(scsi_qla_host_t *);
>> +extern void qla_nvme_ls_abort(struct nvme_fc_local_port *,
>> +struct nvme_fc_remote_port *, struct nvmefc_ls_req *);
>> +extern int qla_nvme_ls_req(struct nvme_fc_local_port *,
>> +struct nvme_fc_remote_port *, struct nvmefc_ls_req *);
>> +extern void qla_nvme_poll(struct nvme_fc_local_port *, void *);
>> +extern int qla2x00_start_nvme_mq(srb_t *);
>> +extern void qla_nvme_fcp_abort(struct nvme_fc_local_port *,
>> +struct nvme_fc_remote_port *, void *, struct nvmefc_fcp_req *);
>> +extern void qla24xx_nvme_ls4_iocb(scsi_qla_host_t *, struct pt_ls4_request 
>> *,
>> +struct req_que *);
> 
> Can't these go into a header instead of using extern?
> 

Sure.

> [...]
> 
>> @@ -4662,6 +4667,9 @@ qla2x00_configure_fabric(scsi_qla_host_t *vha)
>>  break;
>>  } while (0);
>> 
>> +if ((!vha->nvme_local_port) && (vha->flags.nvme_enabled))
> 
> 
> [...]
> 
>> +if ((ql2xnvmeenable) && IS_QLA27XX(ha))
>> +mcp->mb[4] |= NVME_ENABLE_FLAG;
>> +
> 
> [...]
> 
>> +
>> +/* bit 26 of fw_attributes */
>> +if ((ha->fw_attributes_h & 0x400) && (ql2xnvmeenable)) {
> 
> Superfluous parenthesis.
> 

Good catch. will fix in v2

> [...]
> 
>> +vha->flags.nvme_enabled = 1;
>> +icb->firmware_options_2 &=
>> +cpu_to_le32(~(BIT_0 | BIT_1 | BIT_2 | BIT_3));
> 
> 0xfff0 or maybe even ~0xf?
> 

will fix in v2

> [...]
> 
>> +ret = nvme_fc_register_remoteport(vha->nvme_local_port, &rport->req,
>> +&fcport->nvme_remote_port);
>> +if (ret) {
>> +ql_log(ql_log_warn, vha, 0x212e,
>> +"Failed to register remote port. Transport returned %d\n",
>> +ret);
>> +return ret;
>> +}
>> +
>> +fcport->nvme_remote_port->private = fcport;
> 
> A FC-NVMe remote port can be in used right after a call to
> nvme_fc_register_remoteport(), if I'm not mistaken. So you should add the
> fcport to the nvme_remote_port->private _before_ calling
> nvme_fc_register_remoteport().

Will check this out. 

> 
>> +fcport->nvme_flag |= NVME_FLAG_REGISTERED;
>> +atomic_set(&fcport->nvme_ref_count, 1);
>> +rport->fcport = fcport;
>> +list_add_tail(&rport->list, &vha->nvme_rport_list);
>> +#endif
>> +return 0;
>> +}
>> +
>> +/*
>> + * Perform a scan and register those ports with FC-NVMe transport
>> + * input:  HBA handle
>> + */
>> +int qla_nvme_hba_scan(scsi_qla_host_t *vha)
> 
> This should be bool.
> 
>> +{
>> +#if (IS_ENABLED(CONFIG_NVME_FC))
>> +fc_port_t   *fcport;
>> +uint8_t not_found = 1;
> 
> bool found = false;
> 
>> +
>> +/*
>> + * We are using the first HBA found
>> + * Find matching fcport
>> + */
>> +list_for_each_entry(fcport, &vha->vp_fcports, list) {
>> +if ((fcport->fc4f_nvme) &&
>> +(!(fcport->nvme_flag & NVME_FLAG_REGISTERED))) {
>> +qla_nvme_register_remote(vha, fcport);
>> +not_found = 0;
> 
> found = true;
> 
>> +}
>> +}
>> +
>> +return not_found;
> 
> return found;
> 
>> +#else
>> +return 1;
> 
> return false;
> 
>> +#endif
>> +}
> 
> And update the call-sites.
> 

Ack. 

> [...]
> 
>> +if (unlikely((nvme->u.nvme.comp_status) || res))
> 
> Parenthesis again.
> 

Ack. 

> [...]
> 
>> +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;
>> +fc_port_t *fcport = rport->private;
>> +srb_t *sp = priv->sp;
>> +int rval;
>> +struct qla_hw_data *ha;
>> +
>> +ql_log(ql_log_info, fcport->vha, 0x212b,
>> +"%s: aborting sp:%p on fcport:%p\n", __func__, sp, fcport);
>> +
>> +ha = fcport->vha->hw;
>> +rval = ha->isp_ops->abort_command(sp);
>> +if (rval != QLA_SUCCESS)
>> +ql_log(ql_log_warn, fcport->vha, 0x2125,
>> +"%s: failed to abort LS command for SP:%p rval=%x\n",
>> +   

Re: [PATCH 2/6] qla2xxx: Add FC-NVMe command handling

2017-06-19 Thread Madhani, Himanshu

> On Jun 19, 2017, at 1:20 AM, Johannes Thumshirn  wrote:
> 
> On Fri, Jun 16, 2017 at 03:47:40PM -0700, Himanshu Madhani wrote:
>> From: Duane Grigsby 
>> 
>> Signed-off-by: Darren Trapp 
>> Signed-off-by: Duane Grigsby 
>> Signed-off-by: Anil Gurumurthy 
>> Signed-off-by: Giridhar Malavali 
>> Signed-off-by: Himanshu Madhani 
>> ---
> 
> [...]
> 
>> +static void
>> +qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, void 
>> *tsk)
>> +{
>> +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;
> 
> No need to cast from void*
> 
> 

Thanks for Review. will fix this in v2.

> 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

Thanks,
- Himanshu



Re: [PATCH 1/6] qla2xxx: Add FC-NVMe port discovery and PRLI handling

2017-06-19 Thread Madhani, Himanshu

> On Jun 19, 2017, at 1:09 AM, Johannes Thumshirn  wrote:
> 
> On Fri, Jun 16, 2017 at 03:47:39PM -0700, Himanshu Madhani wrote:
>> From: Duane Grigsby 
>> 
>> Signed-off-by: Darren Trapp 
>> Signed-off-by: Duane Grigsby 
>> Signed-off-by: Anil Gurumurthy 
>> Signed-off-by: Giridhar Malavali 
>> Signed-off-by: Himanshu Madhani 
>> ---
> 
> [...]
> 
>> +
>> +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;
> 
> Minor nit, superfluous parenthesis.
> 
> 

Will fix it in v2

> Anyways,
> 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

Thanks,
- Himanshu



[PATCH] mpt3sas: Fix error "space prohibited before that ','"

2017-06-19 Thread Minwoo Im
It will fix the following error from checkpatch.pl.
ERROR: space prohibited before that ','

Signed-off-by: Minwoo Im 
---
 drivers/scsi/mpt3sas/mpt3sas_base.c |   18 +-
 drivers/scsi/mpt3sas/mpt3sas_ctl.c  |2 +-
 drivers/scsi/mpt3sas/mpt3sas_scsih.c|2 +-
 drivers/scsi/mpt3sas/mpt3sas_transport.c|4 ++--
 drivers/scsi/mpt3sas/mpt3sas_trigger_diag.c |6 +++---
 5 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 18039bb..45ef957 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -307,7 +307,7 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
  * Return nothing.
  */
 void
-mpt3sas_base_fault_info(struct MPT3SAS_ADAPTER *ioc , u16 fault_code)
+mpt3sas_base_fault_info(struct MPT3SAS_ADAPTER *ioc, u16 fault_code)
 {
pr_err(MPT3SAS_FMT "fault_state(0x%04x)!\n",
ioc->name, fault_code);
@@ -334,7 +334,7 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
 
doorbell = readl(&ioc->chip->Doorbell);
if ((doorbell & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT)
-   mpt3sas_base_fault_info(ioc , doorbell);
+   mpt3sas_base_fault_info(ioc, doorbell);
else {
writel(0xC0FFEE00, &ioc->chip->Doorbell);
pr_err(MPT3SAS_FMT "Firmware is halted due to command 
timeout\n",
@@ -673,7 +673,7 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
  * Return nothing.
  */
 static void
-_base_sas_log_info(struct MPT3SAS_ADAPTER *ioc , u32 log_info)
+_base_sas_log_info(struct MPT3SAS_ADAPTER *ioc, u32 log_info)
 {
union loginfo_type {
u32 loginfo;
@@ -749,7 +749,7 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
 
if ((ioc_status & MPI2_IOCSTATUS_MASK) &&
(ioc->logging_level & MPT_DEBUG_REPLY)) {
-   _base_sas_ioc_info(ioc , mpi_reply,
+   _base_sas_ioc_info(ioc, mpi_reply,
   mpt3sas_base_get_msg_frame(ioc, smid));
}
 
@@ -3586,7 +3586,7 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
}
for (i = 0; i < ioc->chain_depth; i++) {
ioc->chain_lookup[i].chain_buffer = pci_pool_alloc(
-   ioc->chain_dma_pool , GFP_KERNEL,
+   ioc->chain_dma_pool, GFP_KERNEL,
&ioc->chain_lookup[i].chain_buffer_dma);
if (!ioc->chain_lookup[i].chain_buffer) {
ioc->chain_depth = i;
@@ -3637,7 +3637,7 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
ioc->name);
goto out;
}
-   ioc->sense = pci_pool_alloc(ioc->sense_dma_pool , GFP_KERNEL,
+   ioc->sense = pci_pool_alloc(ioc->sense_dma_pool, GFP_KERNEL,
&ioc->sense_dma);
if (!ioc->sense) {
pr_err(MPT3SAS_FMT "sense pool: pci_pool_alloc failed\n",
@@ -3661,7 +3661,7 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
ioc->name);
goto out;
}
-   ioc->reply = pci_pool_alloc(ioc->reply_dma_pool , GFP_KERNEL,
+   ioc->reply = pci_pool_alloc(ioc->reply_dma_pool, GFP_KERNEL,
&ioc->reply_dma);
if (!ioc->reply) {
pr_err(MPT3SAS_FMT "reply pool: pci_pool_alloc failed\n",
@@ -3687,7 +3687,7 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
ioc->name);
goto out;
}
-   ioc->reply_free = pci_pool_alloc(ioc->reply_free_dma_pool , GFP_KERNEL,
+   ioc->reply_free = pci_pool_alloc(ioc->reply_free_dma_pool, GFP_KERNEL,
&ioc->reply_free_dma);
if (!ioc->reply_free) {
pr_err(MPT3SAS_FMT "reply_free pool: pci_pool_alloc failed\n",
@@ -3877,7 +3877,7 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
doorbell = readl(&ioc->chip->Doorbell);
if ((doorbell & MPI2_IOC_STATE_MASK) ==
MPI2_IOC_STATE_FAULT) {
-   mpt3sas_base_fault_info(ioc , doorbell);
+   mpt3sas_base_fault_info(ioc, doorbell);
return -EFAULT;
}
} else if (int_status == 0x)
diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c 
b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
index bdffb69..72af956 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
@@ -1074,7 +1074,7 @@ enum block_state {
dctlprintk(ioc, pr_info(MPT3SAS_FMT "%s: enter\n", ioc->name,
__func__));
 
-   memset(&karg, 0 , sizeof(karg));
+   memset(&karg, 0, sizeof(karg));
if (ioc->pfacts)
karg.port_number = ioc->pfacts[0].PortNumber;
karg.hw_rev = ioc->pdev->revision;
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/s

[PATCH 1/1] qedi: Add support for offload iSCSI Boot

2017-06-19 Thread Nilesh Javali
This patch adds support for offload iSCSI boot (Boot from SAN
over iSCSI offload).

The dependent qed patches for this support are,
- qed: Support NVM-image reading API
- qed: Share additional information with qedf

Signed-off-by: Arun Easi 
Signed-off-by: Andrew Vasquez 
Signed-off-by: Manish Rangankar 
Signed-off-by: Nilesh Javali 
---
 drivers/scsi/qedi/qedi.h   |  17 ++
 drivers/scsi/qedi/qedi_main.c  | 419 +
 drivers/scsi/qedi/qedi_nvm_iscsi_cfg.h | 210 +
 3 files changed, 646 insertions(+)
 create mode 100644 drivers/scsi/qedi/qedi_nvm_iscsi_cfg.h

diff --git a/drivers/scsi/qedi/qedi.h b/drivers/scsi/qedi/qedi.h
index 32632c9..91d2f51 100644
--- a/drivers/scsi/qedi/qedi.h
+++ b/drivers/scsi/qedi/qedi.h
@@ -23,11 +23,17 @@
 #include 
 #include 
 #include "qedi_version.h"
+#include "qedi_nvm_iscsi_cfg.h"
 
 #define QEDI_MODULE_NAME   "qedi"
 
 struct qedi_endpoint;
 
+#ifndef GET_FIELD2
+#define GET_FIELD2(value, name) \
+   (((value) & (name ## _MASK)) >> (name ## _OFFSET))
+#endif
+
 /*
  * PCI function probe defines
  */
@@ -66,6 +72,11 @@
 #define QEDI_HW_DMA_BOUNDARY   0xfff
 #define QEDI_PATH_HANDLE   0xFE000UL
 
+enum qedi_nvm_tgts {
+   QEDI_NVM_TGT_PRI,
+   QEDI_NVM_TGT_SEC,
+};
+
 struct qedi_uio_ctrl {
/* meta data */
u32 uio_hsi_version;
@@ -283,6 +294,8 @@ struct qedi_ctx {
void *bdq_pbl_list;
dma_addr_t bdq_pbl_list_dma;
u8 bdq_pbl_list_num_entries;
+   struct nvm_iscsi_cfg *iscsi_cfg;
+   dma_addr_t nvm_buf_dma;
void __iomem *bdq_primary_prod;
void __iomem *bdq_secondary_prod;
u16 bdq_prod_idx;
@@ -337,6 +350,10 @@ struct qedi_ctx {
bool use_fast_sge;
 
atomic_t num_offloads;
+#define SYSFS_FLAG_FW_SEL_BOOT 2
+#define IPV6_LEN   41
+#define IPV4_LEN   17
+   struct iscsi_boot_kset *boot_kset;
 };
 
 struct qedi_work {
diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
index 09a2946..f07ac1c 100644
--- a/drivers/scsi/qedi/qedi_main.c
+++ b/drivers/scsi/qedi/qedi_main.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -1143,6 +1144,30 @@ static int qedi_setup_int(struct qedi_ctx *qedi)
return rc;
 }
 
+static void qedi_free_nvm_iscsi_cfg(struct qedi_ctx *qedi)
+{
+   if (qedi->iscsi_cfg)
+   dma_free_coherent(&qedi->pdev->dev,
+ sizeof(struct nvm_iscsi_cfg),
+ qedi->iscsi_cfg, qedi->nvm_buf_dma);
+}
+
+static int qedi_alloc_nvm_iscsi_cfg(struct qedi_ctx *qedi)
+{
+   qedi->iscsi_cfg = dma_zalloc_coherent(&qedi->pdev->dev,
+sizeof(struct nvm_iscsi_cfg),
+&qedi->nvm_buf_dma, GFP_KERNEL);
+   if (!qedi->iscsi_cfg) {
+   QEDI_ERR(&qedi->dbg_ctx, "Could not allocate NVM BUF.\n");
+   return -ENOMEM;
+   }
+   QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO,
+ "NVM BUF addr=0x%p dma=0x%llx.\n", qedi->iscsi_cfg,
+ qedi->nvm_buf_dma);
+
+   return 0;
+}
+
 static void qedi_free_bdq(struct qedi_ctx *qedi)
 {
int i;
@@ -1183,6 +1208,7 @@ static void qedi_free_global_queues(struct qedi_ctx *qedi)
kfree(gl[i]);
}
qedi_free_bdq(qedi);
+   qedi_free_nvm_iscsi_cfg(qedi);
 }
 
 static int qedi_alloc_bdq(struct qedi_ctx *qedi)
@@ -1309,6 +1335,11 @@ static int qedi_alloc_global_queues(struct qedi_ctx 
*qedi)
if (rc)
goto mem_alloc_failure;
 
+   /* Allocate DMA coherent buffers for NVM_ISCSI_CFG */
+   rc = qedi_alloc_nvm_iscsi_cfg(qedi);
+   if (rc)
+   goto mem_alloc_failure;
+
/* Allocate a CQ and an associated PBL for each MSI-X
 * vector.
 */
@@ -1673,6 +1704,387 @@ void qedi_reset_host_mtu(struct qedi_ctx *qedi, u16 mtu)
qedi_ops->ll2->start(qedi->cdev, ¶ms);
 }
 
+/**
+ * qedi_get_nvram_block: - Scan through the iSCSI NVRAM block (while accounting
+ * for gaps) for the matching absolute-pf-id of the QEDI device.
+ */
+static struct nvm_iscsi_block *
+qedi_get_nvram_block(struct qedi_ctx *qedi)
+{
+   int i;
+   u8 pf;
+   u32 flags;
+   struct nvm_iscsi_block *block;
+
+   pf = qedi->dev_info.common.abs_pf_id;
+   block = &qedi->iscsi_cfg->block[0];
+   for (i = 0; i < NUM_OF_ISCSI_PF_SUPPORTED; i++, block++) {
+   flags = ((block->id) & NVM_ISCSI_CFG_BLK_CTRL_FLAG_MASK) >>
+   NVM_ISCSI_CFG_BLK_CTRL_FLAG_OFFSET;
+   if (flags & (NVM_ISCSI_CFG_BLK_CTRL_FLAG_IS_NOT_EMPTY |
+   NVM_ISCSI_CFG_BLK_CTRL_FLAG_PF_MAPPED) &&
+   (pf == (block->id & NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_MASK)
+   >> NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_OFFSET))
+  

[PATCH 0/1] qedi: Add iSCSI Boot-from-SAN support

2017-06-19 Thread Nilesh Javali
Martin,

Please consider below patch for next 'scsi-fixes' submission.

Thanks,
Nilesh

Nilesh Javali (1):
  qedi: Add support for offload iSCSI Boot

 drivers/scsi/qedi/qedi.h   |  17 ++
 drivers/scsi/qedi/qedi_main.c  | 419 +
 drivers/scsi/qedi/qedi_nvm_iscsi_cfg.h | 210 +
 3 files changed, 646 insertions(+)
 create mode 100644 drivers/scsi/qedi/qedi_nvm_iscsi_cfg.h

-- 
1.8.3.1



iscsi deadlock while login and logout 2 iscsi nodes in tight loop at unstable network environment

2017-06-19 Thread wangqiang (AY)
Hi all,

In the upstream 4.12.0-rc5 kernel, I encounter a deadlock problem while login 
and logout 2 iscsi nodes in tight loop at unstable network environment, the 
iscsid will be D state.

SysRq-w reported the following call stacks:
[10660.667133] sysrq: SysRq : Show Blocked State
[10660.671536]   task    PC stack   pid father
[10660.672137] iscsid  D    0 11415  1 0x
[10660.672139] Call Trace:
[10660.672141]  __schedule+0x1d9/0x780
[10660.672144]  schedule+0x36/0x80
[10660.672146]  async_synchronize_cookie_domain+0xaa/0x150
[10660.672149]  ? remove_wait_queue+0x60/0x60
[10660.672151]  async_synchronize_full_domain+0x18/0x20
[10660.672153]  sd_remove+0x4d/0xc0 [sd_mod]
[10660.672156]  device_release_driver_internal+0x141/0x200
[10660.672158]  device_release_driver+0x12/0x20
[10660.672159]  bus_remove_device+0xfd/0x170
[10660.672161]  device_del+0x1e8/0x330
[10660.672164]  __scsi_remove_device+0xc6/0xd0
[10660.672166]  scsi_remove_device+0x26/0x40
[10660.672168]  scsi_remove_target+0x165/0x1b0
[10660.672174]  __iscsi_unbind_session+0xbe/0x170 [scsi_transport_iscsi]
[10660.672180]  iscsi_remove_session+0xd6/0x190 [scsi_transport_iscsi]
[10660.672186]  iscsi_destroy_session+0x12/0x50 [scsi_transport_iscsi]
[10660.672192]  iscsi_session_teardown+0xd5/0xf0 [libiscsi]
[10660.672195]  iscsi_sw_tcp_session_destroy+0x48/0x70 [iscsi_tcp]
[10660.672202]  iscsi_if_recv_msg+0xbb1/0x1390 [scsi_transport_iscsi]
[10660.672205]  ? __kmalloc_node_track_caller+0x199/0x280
[10660.672211]  iscsi_if_rx+0x8e/0x1f0 [scsi_transport_iscsi]
[10660.672214]  netlink_unicast+0x181/0x240
[10660.672216]  netlink_sendmsg+0x2c2/0x3b0
[10660.672220]  sock_sendmsg+0x38/0x50
[10660.67]  ___sys_sendmsg+0x27a/0x290
[10660.672224]  ? kernfs_refresh_inode+0xc8/0xe0
[10660.672227]  ? _copy_to_user+0x26/0x40
[10660.672230]  __sys_sendmsg+0x54/0x90
[10660.672232]  SyS_sendmsg+0x12/0x20
[10660.672234]  entry_SYSCALL_64_fastpath+0x1a/0xa5
[10660.672325] kworker/u48:2   D    0 22364  2 0x
[10660.672332] Workqueue: scsi_wq_7 __iscsi_unbind_session 
[scsi_transport_iscsi]
[10660.672333] Call Trace:
[10660.672336]  __schedule+0x1d9/0x780
[10660.672350]  ? set_next_entity+0x7c/0x7a0
[10660.672353]  schedule+0x36/0x80
[10660.672354]  schedule_timeout+0x249/0x300
[10660.672356]  ? finish_task_switch+0xec/0x240
[10660.672359]  wait_for_completion+0x121/0x180
[10660.672361]  ? wake_up_q+0x80/0x80
[10660.672364]  flush_workqueue+0x16d/0x490
[10660.672366]  ? probe_sched_wakeup+0x1c/0x20
[10660.672369]  drain_workqueue+0x5b/0x130
[10660.672371]  destroy_workqueue+0x1a/0x200
[10660.672373]  scsi_host_dev_release+0x6f/0x130
[10660.672375]  device_release+0x32/0x90
[10660.672377]  kobject_cleanup+0x63/0x170
[10660.672379]  kobject_put+0x28/0x50
[10660.672381]  put_device+0x17/0x20
[10660.672383]  scsi_host_put+0x15/0x20
[10660.672389]  iscsi_session_release+0x3d/0x80 [scsi_transport_iscsi]
[10660.672390]  device_release+0x32/0x90
[10660.672393]  kobject_cleanup+0x63/0x170
[10660.672395]  kobject_put+0x28/0x50
[10660.672396]  put_device+0x17/0x20
[10660.672398]  scsi_target_dev_release+0x1f/0x30
[10660.672400]  device_release+0x32/0x90
[10660.672402]  kobject_cleanup+0x63/0x170
[10660.672404]  kobject_put+0x28/0x50
[10660.672406]  put_device+0x17/0x20
[10660.672407]  scsi_target_destroy+0xc5/0xe0
[10660.672409]  scsi_target_reap_ref_release+0x35/0x40
[10660.672411]  scsi_target_reap+0x2e/0x40
[10660.672413]  scsi_remove_target+0x197/0x1b0
[10660.672419]  __iscsi_unbind_session+0xbe/0x170 [scsi_transport_iscsi]
[10660.672421]  process_one_work+0x149/0x360
[10660.672423]  worker_thread+0x4d/0x3c0
[10660.672425]  kthread+0x109/0x140
[10660.672427]  ? rescuer_thread+0x380/0x380
[10660.672428]  ? kthread_park+0x60/0x60
[10660.672430]  ret_from_fork+0x25/0x30

sd_remove() waits for async_synchronize_cookie_domain which is defined in 
sd_probe() and relate to sd_probe_async(), but due to unstable network 
environment, the session which process sd_probe_async() became 
ISCSI_STATE_FAILED state, and IO corresponding to sd_probe_async() doesnt 
complete, iscsi_conn_failure() send event to iscsid and wait for respond to 
stop connection, iscsid cannot respond as the sd_remove() is waiting for 
completion of sd_probe_async(). Hence the deadlock.

So, is any method to fix this deadlock?
Any reply would be thankful.

Execute the shell scripts below at the initiator side and wait for 5 ~ 20 
minutes, the deadlock can be reproduced.(nodes need at least 10 luns 
respectively.)
#!/bin/bash
# discovery 2 nodes
iscsiadm -m discovery -p IP_A -t st
iscsiadm -m discovery -p IP_B -t st
# set network loss rate (eth1 connected to the ipsan)
tc qdisc add dev eth1 root netem loss 60%
# loop test
n=1
while [ 1 ]
do
 echo "$(date)  test loop $n "
 iscsiadm -m node -T iqn.:::IP_A --login
 sleep 5
 iscsiadm -m node -T iqn.:::IP_A --logout&
 iscsiadm -m node -T iqn.::yyyz:IP_B --login&
 slee

[PATCH] scsi/libata: Support variable-length cdb of ata pass-thru(32)-bug fixed.

2017-06-19 Thread Minwoo Im
Bug fixed in libata-scsi.c from previous patch.
Bit shifting of service action value in ata_scsi_var_len_cdb_xlat() was 
reversed.
I have tested a ata pass-thru(32) command with sg_io and it worked well.
I'm sorry for making a confusion.

Signed-off-by: Minwoo Im 
---
 drivers/ata/libata-core.c |2 +-
 drivers/ata/libata-scsi.c |   95 ++---
 include/scsi/scsi_proto.h |1 +
 3 files changed, 91 insertions(+), 7 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index e157a0e..f1d3ba4 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2587,7 +2587,7 @@ int ata_dev_configure(struct ata_device *dev)
}
ata_dev_config_sense_reporting(dev);
ata_dev_config_zac(dev);
-   dev->cdb_len = 16;
+   dev->cdb_len = 32;
}
 
/* ATAPI-specific feature tests */
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 49ba983..39f23e0 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -3127,7 +3127,7 @@ static struct ata_device *__ata_scsi_find_dev(struct 
ata_port *ap,
  * ata_scsi_pass_thru - convert ATA pass-thru CDB to taskfile
  * @qc: command structure to be initialized
  *
- * Handles either 12 or 16-byte versions of the CDB.
+ * Handles either 12, 16, or 32-byte versions of the CDB.
  *
  * RETURNS:
  * Zero on success, non-zero on failure.
@@ -3140,13 +3140,36 @@ static unsigned int ata_scsi_pass_thru(struct 
ata_queued_cmd *qc)
const u8 *cdb = scmd->cmnd;
u16 fp;
 
-   if ((tf->protocol = ata_scsi_map_proto(cdb[1])) == ATA_PROT_UNKNOWN) {
+   /*
+* if SCSI operation code in cdb[0] is ATA_12 or ATA_16,
+* then cdb[1] will contain protocol of ATA PASS-THROUGH.
+* otherwise, Its operation code shall be ATA_32(7Fh).
+* in this case, cdb[10] will contain protocol of it.
+* we call this command as a variable-length cdb.
+*/
+   if (cdb[0] == ATA_12 || cdb[0] == ATA_16)
+   tf->protocol = ata_scsi_map_proto(cdb[1]);
+   else
+   tf->protocol = ata_scsi_map_proto(cdb[10]);
+
+   if (tf->protocol == ATA_PROT_UNKNOWN) {
fp = 1;
goto invalid_fld;
}
 
-   if (ata_is_ncq(tf->protocol) && (cdb[2] & 0x3) == 0)
-   tf->protocol = ATA_PROT_NCQ_NODATA;
+   /*
+* if protocol has a NCQ property and transfer length is 0,
+* then the protocol will be marked as a NCQ_NODATA.
+* in case of ATA_12 and ATA_16, cdb[2] has a t_length field.
+* otherwise, cdb[11] will have a t_length field.
+*/
+   if (cdb[0] == ATA_12 || cdb[0] == ATA_16) {
+   if (ata_is_ncq(tf->protocol) && (cdb[2] & 0x3) == 0)
+   tf->protocol = ATA_PROT_NCQ_NODATA;
+   } else {
+   if (ata_is_ncq(tf->protocol) && (cdb[11] & 0x3) == 0)
+   tf->protocol = ATA_PROT_NCQ_NODATA;
+   }
 
/* enable LBA */
tf->flags |= ATA_TFLAG_LBA;
@@ -3181,7 +3204,7 @@ static unsigned int ata_scsi_pass_thru(struct 
ata_queued_cmd *qc)
tf->lbah = cdb[12];
tf->device = cdb[13];
tf->command = cdb[14];
-   } else {
+   } else if (cdb[0] == ATA_12) {
/*
 * 12-byte CDB - incapable of extended commands.
 */
@@ -3194,6 +3217,31 @@ static unsigned int ata_scsi_pass_thru(struct 
ata_queued_cmd *qc)
tf->lbah = cdb[7];
tf->device = cdb[8];
tf->command = cdb[9];
+   } else {
+   /*
+* 32-byte CDB - may contain extended command fields.
+*
+* If that is the case, copy the upper byte register values.
+*/
+   if (cdb[10] & 0x01) {
+   tf->hob_feature = cdb[20];
+   tf->hob_nsect = cdb[22];
+   tf->hob_lbal = cdb[16];
+   tf->hob_lbam = cdb[15];
+   tf->hob_lbah = cdb[14];
+   tf->flags |= ATA_TFLAG_LBA48;
+   } else
+   tf->flags &= ~ATA_TFLAG_LBA48;
+
+   tf->feature = cdb[21];
+   tf->nsect = cdb[23];
+   tf->lbal = cdb[19];
+   tf->lbam = cdb[18];
+   tf->lbah = cdb[17];
+   tf->device = cdb[24];
+   tf->command = cdb[25];
+   tf->auxiliary = (cdb[28] << 24) | (cdb[29] << 16)
+   | (cdb[30] << 8) | cdb[31];
}
 
/* For NCQ commands copy the tag value */
@@ -4068,6 +4116,33 @@ static unsigned int ata_scsi_mode_select_xlat(struct 
ata_queued_cmd *qc)
 }
 
 /**
+ * ata_scsi_var_len_cdb_xlat - SATL Variable Length CDB to Handler
+ * @qc: Command to

[PATCH 2/2] scsi_dh_alua: remove synchronous STPG support

2017-06-19 Thread Christoph Hellwig
Since 9c58b395 ("scsi: scsi_devinfo: remove synchronous ALUA for
NETAPP devices") this code is unused.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 27 +--
 include/scsi/scsi_device.h |  1 -
 2 files changed, 5 insertions(+), 23 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index c01b47e5b55a..0962fd544401 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -57,7 +57,6 @@
 /* device handler flags */
 #define ALUA_OPTIMIZE_STPG 0x01
 #define ALUA_RTPG_EXT_HDR_UNSUPP   0x02
-#define ALUA_SYNC_STPG 0x04
 /* State machine flags */
 #define ALUA_PG_RUN_RTPG   0x10
 #define ALUA_PG_RUN_STPG   0x20
@@ -70,7 +69,6 @@ MODULE_PARM_DESC(optimize_stpg, "Allow use of a non-optimized 
path, rather than
 static LIST_HEAD(port_group_list);
 static DEFINE_SPINLOCK(port_group_lock);
 static struct workqueue_struct *kaluad_wq;
-static struct workqueue_struct *kaluad_sync_wq;
 
 struct alua_port_group {
struct kref kref;
@@ -380,8 +378,6 @@ static int alua_check_vpd(struct scsi_device *sdev, struct 
alua_dh_data *h,
}
 
spin_lock_irqsave(&pg->lock, flags);
-   if (sdev->synchronous_alua)
-   pg->flags |= ALUA_SYNC_STPG;
if (pg_updated)
list_add_rcu(&h->node, &pg->dh_list);
spin_unlock_irqrestore(&pg->lock, flags);
@@ -785,7 +781,6 @@ static void alua_rtpg_work(struct work_struct *work)
int err = SCSI_DH_OK;
struct alua_queue_data *qdata, *tmp;
unsigned long flags;
-   struct workqueue_struct *alua_wq = kaluad_wq;
 
spin_lock_irqsave(&pg->lock, flags);
sdev = pg->rtpg_sdev;
@@ -796,8 +791,6 @@ static void alua_rtpg_work(struct work_struct *work)
kref_put(&pg->kref, release_port_group);
return;
}
-   if (pg->flags & ALUA_SYNC_STPG)
-   alua_wq = kaluad_sync_wq;
pg->flags |= ALUA_PG_RUNNING;
if (pg->flags & ALUA_PG_RUN_RTPG) {
int state = pg->state;
@@ -810,7 +803,7 @@ static void alua_rtpg_work(struct work_struct *work)
pg->flags &= ~ALUA_PG_RUNNING;
pg->flags |= ALUA_PG_RUN_RTPG;
spin_unlock_irqrestore(&pg->lock, flags);
-   queue_delayed_work(alua_wq, &pg->rtpg_work,
+   queue_delayed_work(kaluad_wq, &pg->rtpg_work,
   pg->interval * HZ);
return;
}
@@ -822,7 +815,7 @@ static void alua_rtpg_work(struct work_struct *work)
pg->flags &= ~ALUA_PG_RUNNING;
pg->flags |= ALUA_PG_RUN_RTPG;
spin_unlock_irqrestore(&pg->lock, flags);
-   queue_delayed_work(alua_wq, &pg->rtpg_work,
+   queue_delayed_work(kaluad_wq, &pg->rtpg_work,
   pg->interval * HZ);
return;
}
@@ -839,7 +832,7 @@ static void alua_rtpg_work(struct work_struct *work)
pg->interval = 0;
pg->flags &= ~ALUA_PG_RUNNING;
spin_unlock_irqrestore(&pg->lock, flags);
-   queue_delayed_work(alua_wq, &pg->rtpg_work,
+   queue_delayed_work(kaluad_wq, &pg->rtpg_work,
   pg->interval * HZ);
return;
}
@@ -874,8 +867,6 @@ static bool alua_rtpg_queue(struct alua_port_group *pg,
 {
int start_queue = 0;
unsigned long flags;
-   struct workqueue_struct *alua_wq = kaluad_wq;
-
if (WARN_ON_ONCE(!pg) || scsi_device_get(sdev))
return false;
 
@@ -900,12 +891,10 @@ static bool alua_rtpg_queue(struct alua_port_group *pg,
}
}
 
-   if (pg->flags & ALUA_SYNC_STPG)
-   alua_wq = kaluad_sync_wq;
spin_unlock_irqrestore(&pg->lock, flags);
 
if (start_queue) {
-   if (queue_delayed_work(alua_wq, &pg->rtpg_work,
+   if (queue_delayed_work(kaluad_wq, &pg->rtpg_work,
msecs_to_jiffies(ALUA_RTPG_DELAY_MSECS)))
sdev = NULL;
else
@@ -1166,16 +1155,11 @@ static int __init alua_init(void)
/* Temporary failure, bypass */
return SCSI_DH_DEV_TEMP_BUSY;
}
-   kaluad_sync_wq = create_workqueue("kaluad_sync");
-   if (!kaluad_sync_wq) {
-   destroy_workqueue(kaluad_wq);
-   return SCSI_DH_DEV_TEMP_BUSY;
-   }
+
r = scsi_register_device_handler(&alua_

[PATCH 1/2] scsi: remove various unused blist flags

2017-06-19 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/scsi_scan.c| 25 ++---
 include/scsi/scsi_devinfo.h |  9 -
 2 files changed, 2 insertions(+), 32 deletions(-)

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index e6de4eee97a3..3c4403210a1a 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -656,8 +656,6 @@ static int scsi_probe_lun(struct scsi_device *sdev, 
unsigned char *inq_result,
if (pass == 1) {
if (BLIST_INQUIRY_36 & *bflags)
next_inquiry_len = 36;
-   else if (BLIST_INQUIRY_58 & *bflags)
-   next_inquiry_len = 58;
else if (sdev->inquiry_len)
next_inquiry_len = sdev->inquiry_len;
else
@@ -927,15 +925,6 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned 
char *inq_result,
 
sdev->use_10_for_rw = 1;
 
-   if (*bflags & BLIST_MS_SKIP_PAGE_08)
-   sdev->skip_ms_page_8 = 1;
-
-   if (*bflags & BLIST_MS_SKIP_PAGE_3F)
-   sdev->skip_ms_page_3f = 1;
-
-   if (*bflags & BLIST_USE_10_BYTE_MS)
-   sdev->use_10_for_ms = 1;
-
/* some devices don't like REPORT SUPPORTED OPERATION CODES
 * and will simply timeout causing sd_mod init to take a very
 * very long time */
@@ -957,9 +946,6 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned 
char *inq_result,
return SCSI_SCAN_NO_RESPONSE;
}
 
-   if (*bflags & BLIST_MS_192_BYTES_FOR_3F)
-   sdev->use_192_bytes_for_3f = 1;
-
if (*bflags & BLIST_NOT_LOCKABLE)
sdev->lockable = 0;
 
@@ -969,9 +955,6 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned 
char *inq_result,
if (*bflags & BLIST_NO_DIF)
sdev->no_dif = 1;
 
-   if (*bflags & BLIST_SYNC_ALUA)
-   sdev->synchronous_alua = 1;
-
sdev->eh_timeout = SCSI_DEFAULT_EH_TIMEOUT;
 
if (*bflags & BLIST_TRY_VPD_PAGES)
@@ -1109,7 +1092,7 @@ static int scsi_probe_and_add_lun(struct scsi_target 
*starget,
/*
 * result contains valid SCSI INQUIRY data.
 */
-   if (((result[0] >> 5) == 3) && !(bflags & BLIST_ATTACH_PQ3)) {
+   if ((result[0] >> 5) == 3) {
/*
 * For a Peripheral qualifier 3 (011b), the SCSI
 * spec says: The device server is not capable of
@@ -1267,11 +1250,7 @@ static void scsi_sequential_lun_scan(struct scsi_target 
*starget,
 */
if (scsi_level < SCSI_3 && !(bflags & BLIST_LARGELUN))
max_dev_lun = min(8U, max_dev_lun);
-
-   /*
-* Stop scanning at 255 unless BLIST_SCSI3LUN
-*/
-   if (!(bflags & BLIST_SCSI3LUN))
+   else
max_dev_lun = min(256U, max_dev_lun);
 
/*
diff --git a/include/scsi/scsi_devinfo.h b/include/scsi/scsi_devinfo.h
index 9f750cb63b03..9592570e092a 100644
--- a/include/scsi/scsi_devinfo.h
+++ b/include/scsi/scsi_devinfo.h
@@ -15,12 +15,7 @@
 #define BLIST_ISROM0x100   /* Treat as (removable) CD-ROM */
 #define BLIST_LARGELUN 0x200   /* LUNs past 7 on a SCSI-2 device */
 #define BLIST_INQUIRY_36   0x400   /* override additional length field */
-#define BLIST_INQUIRY_58   0x800   /* ... for broken inquiry responses */
 #define BLIST_NOSTARTONADD 0x1000  /* do not do automatic start on add */
-#define BLIST_MS_SKIP_PAGE_08  0x2000  /* do not send ms page 0x08 */
-#define BLIST_MS_SKIP_PAGE_3F  0x4000  /* do not send ms page 0x3f */
-#define BLIST_USE_10_BYTE_MS   0x8000  /* use 10 byte ms before 6 byte ms */
-#define BLIST_MS_192_BYTES_FOR_3F  0x1 /*  192 byte ms page 0x3f 
request */
 #define BLIST_REPORTLUN2   0x2 /* try REPORT_LUNS even for SCSI-2 devs
   (if HBA supports more than 8 LUNs) */
 #define BLIST_NOREPORTLUN  0x4 /* don't try REPORT_LUNS scan (SCSI-3 
devs) */
@@ -29,14 +24,10 @@
 #define BLIST_SELECT_NO_ATN0x20 /* select without ATN */
 #define BLIST_RETRY_HWERROR0x40 /* retry HARDWARE_ERROR */
 #define BLIST_MAX_512  0x80 /* maximum 512 sector cdb length */
-#define BLIST_ATTACH_PQ3   0x100 /* Scan: Attach to PQ3 devices */
 #define BLIST_NO_DIF   0x200 /* Disable T10 PI (DIF) */
 #define BLIST_SKIP_VPD_PAGES   0x400 /* Ignore SBC-3 VPD pages */
-#define BLIST_SCSI3LUN 0x800 /* Scan more than 256 LUNs
-for sequential scan */
 #define BLIST_TRY_VPD_PAGES0x1000 /* Attempt to read VPD pages */
 #define BLIST_NO_RSOC  0x2000 /* don't try to issue RSOC */
 #define BLIST_MAX_1024 0x4000 /* maximum 1024 sector cdb length */
-#define BLIST_SYNC_ALUA0x8000 /* Synchronous ALUA commands 
*/

TCG Opal support for sd.c

2017-06-19 Thread Christoph Hellwig
Hi all,

this patch adds TCG Opal support to the scsi disk driver.  As far as I know
only SATA disks actually support OPAL, and as Martin fears RSOC-related
regressions the support is conditional in a flag in struct scsi_device,
which so far only libata sets.

Because of that we should merge the patch through the libata tree with ACKs
from the SCSI side.

Changes from the previous version:
  - add the new security_supported flag
  - add a call to opal_unlock_from_suspend


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

2017-06-19 Thread Christoph Hellwig
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/ata/libata-scsi.c  |  3 +++
 drivers/scsi/sd.c  | 53 +-
 drivers/scsi/sd.h  |  2 ++
 include/scsi/scsi_device.h |  1 +
 4 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 0f788ad6f2f6..3e5ca2e894a4 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1321,6 +1321,9 @@ static int ata_scsi_dev_config(struct scsi_device *sdev,
 
blk_queue_flush_queueable(q, false);
 
+   if (dev->flags & ATA_DFLAG_TRUSTED)
+   sdev->security_supported = 1;
+
dev->sdev = sdev;
return 0;
 }
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index f9d1432d7cc5..5d32fd7d3a3e 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -50,6 +50,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -643,6 +644,26 @@ static void scsi_disk_put(struct scsi_disk *sdkp)
mutex_unlock(&sd_ref_mutex);
 }
 
+#ifdef CONFIG_BLK_SED_OPAL
+static int sd_sec_submit(void *data, u16 spsp, u8 secp, void *buffer,
+   size_t len, bool send)
+{
+   struct scsi_device *sdev = data;
+   u8 cdb[12] = { 0, };
+   int ret;
+
+   cdb[0] = send ? SECURITY_PROTOCOL_OUT : SECURITY_PROTOCOL_IN;
+   cdb[1] = secp;
+   put_unaligned_be16(spsp, &cdb[2]);
+   put_unaligned_be32(len, &cdb[6]);
+
+   ret = scsi_execute_req(sdev, cdb,
+   send ? DMA_TO_DEVICE : DMA_FROM_DEVICE,
+   buffer, len, NULL, SD_TIMEOUT, SD_MAX_RETRIES, NULL);
+   return ret <= 0 ? ret : -EIO;
+}
+#endif /* CONFIG_BLK_SED_OPAL */
+
 static unsigned char sd_setup_protect_cmnd(struct scsi_cmnd *scmd,
   unsigned int dix, unsigned int dif)
 {
@@ -1439,6 +1460,9 @@ static int sd_ioctl(struct block_device *bdev, fmode_t 
mode,
if (error)
goto out;
 
+   if (is_sed_ioctl(cmd))
+   return sed_ioctl(sdkp->opal_dev, cmd, p);
+
/*
 * Send SCSI addressing ioctls directly to mid level, send other
 * ioctls to block level and then onto mid level if they can't be
@@ -2994,6 +3018,20 @@ static void sd_read_write_same(struct scsi_disk *sdkp, 
unsigned char *buffer)
sdkp->ws10 = 1;
 }
 
+static void sd_read_security(struct scsi_disk *sdkp, unsigned char *buffer)
+{
+   struct scsi_device *sdev = sdkp->device;
+
+   if (!sdev->security_supported)
+   return;
+
+   if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE,
+   SECURITY_PROTOCOL_IN) == 1 &&
+   scsi_report_opcode(sdev, buffer, SD_BUF_SIZE,
+   SECURITY_PROTOCOL_OUT) == 1)
+   sdkp->security = 1;
+}
+
 /**
  * sd_revalidate_disk - called the first time a new disk is seen,
  * performs disk spin up, read_capacity, etc.
@@ -3047,6 +3085,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
sd_read_cache_type(sdkp, buffer);
sd_read_app_tag_own(sdkp, buffer);
sd_read_write_same(sdkp, buffer);
+   sd_read_security(sdkp, buffer);
}
 
sdkp->first_scan = 0;
@@ -3207,6 +3246,12 @@ static void sd_probe_async(void *data, async_cookie_t 
cookie)
 
sd_revalidate_disk(gd);
 
+   if (sdkp->security) {
+   sdkp->opal_dev = init_opal_dev(sdp, &sd_sec_submit);
+   if (sdkp->opal_dev)
+   sd_printk(KERN_NOTICE, sdkp, "supports TCG Opal\n");
+   }
+
sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
  sdp->removable ? "removable " : "");
scsi_autopm_put_device(sdp);
@@ -3356,6 +3401,8 @@ static int sd_remove(struct device *dev)
 
sd_zbc_remove(sdkp);
 
+   free_opal_dev(sdkp->opal_dev);
+
blk_register_region(devt, SD_MINORS, NULL,
sd_default_probe, NULL, NULL);
 
@@ -3497,6 +3544,7 @@ static int sd_suspend_runtime(struct device *dev)
 static int sd_resume(struct device *dev)
 {
struct scsi_disk *sdkp = dev_get_drvdata(dev);
+   int ret;
 
if (!sdkp)  /* E.g.: runtime resume at the start of sd_probe() */
return 0;
@@ -3505,7 +3553,10 @@ static int sd_resume(struct device *dev)
return 0;
 
sd_printk(KERN_NOTICE, sdkp, "Starting disk\n");
-   return sd_start_stop_device(sdkp, 1);
+   ret = sd_start_stop_device(sdkp, 1);
+   if (!ret)
+   opal_unlock_from_suspend(sdkp->opal_dev);
+   return ret;
 }
 
 /**
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
index 61d02e

Re: [PATCH 03/11] au1100fb: remove a bogus dma_free_nonconsistent call

2017-06-19 Thread Bartlomiej Zolnierkiewicz
On Friday, June 16, 2017 09:17:08 AM Christoph Hellwig wrote:
> au1100fb is using managed dma allocations, so it doesn't need to
> explicitly free the dma memory in the error path (and if it did
> it would have to use the managed version).
> 
> Signed-off-by: Christoph Hellwig 

Acked-by: Bartlomiej Zolnierkiewicz 

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics



Re: [PATCH 6/6] qla2xxx: Update Driver version to 10.00.00.00-k

2017-06-19 Thread Johannes Thumshirn
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 5/6] qla2xxx: Use FC-NMVe FC4 type for FDMI registration

2017-06-19 Thread Johannes Thumshirn
On Fri, Jun 16, 2017 at 03:47:43PM -0700, Himanshu Madhani wrote:
> From: Duane Grigsby 
> 
> Signed-off-by: Duane Grigsby 
> Signed-off-by: Darren Trapp 
> Signed-off-by: Anil Gurumurthy 
> Signed-off-by: Giridhar Malavali 
> Signed-off-by: Himanshu Madhani 
> ---

A bit more of a change log would be highly apprechiated.

Other than that,
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 4/6] qla2xxx: Send FC4 type NVMe to the management server

2017-06-19 Thread Johannes Thumshirn
On Fri, Jun 16, 2017 at 03:47:42PM -0700, Himanshu Madhani wrote:
> From: Duane Grigsby 
> 
> This patch adds switch command support for FC-4 type of FC-NVMe (0x28)
> for resgistering HBA port to the management server. RFT_ID command is
> used to register FC-4 type of 0x28 and RFF_ID is used to register
> FC-4 features bits for FC-NVMe port.
> 
> Signed-off-by: Darren Trapp 
> Signed-off-by: Duane Grigsby 
> Signed-off-by: Anil Gurumurthy 
> Signed-off-by: Giridhar Malavali 
> Signed-off-by: Himanshu Madhani 
> ---

[...]

> +   ct_rsp = &fcport->ct_desc.ct_sns->p.rsp;
> +   /*
> + * FC-GS-7, 5.2.3.12 FC-4 Features - format
> + * The format of the FC-4 Features object, as defined by the FC-4,
> + * Shall be an array of 4-bit values, one for each type code value
> + */

Indentation looks a bit odd here. Did you run checkpatch.pl on the series?

> @@ -4634,6 +4637,12 @@ qla2x00_configure_fabric(scsi_qla_host_t *vha)
>   &vha->dpc_flags))
>   break;
>   }
> + if (vha->flags.nvme_enabled) {
> + if (qla2x00_rff_id(vha, FC4_TYPE_NVME)) {

if (vha->flags.nvme_enabled && 
qla2x00_rff_id(vha, FC4_TYPE_NVME)) 
ql_dbg(ql_dbg_disc, vha, 0x2049, )

> + ql_dbg(ql_dbg_disc, vha, 0x2049,
> + "Register NVME FC Type Features 
> failed.\n");
> + }
> + }

-- 
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 3/6] qla2xxx: Add FC-NVMe F/W initialization and transport registration

2017-06-19 Thread Johannes Thumshirn
On Fri, Jun 16, 2017 at 03:47:41PM -0700, Himanshu Madhani wrote:
[...]
>  /*
> + * Global functions prototype in qla_nvme.c source file.
> + */
> +extern void qla_nvme_register_hba(scsi_qla_host_t *);
> +extern int  qla_nvme_register_remote(scsi_qla_host_t *, fc_port_t *);
> +extern void qla_nvme_delete(scsi_qla_host_t *);
> +extern void qla_nvme_abort(struct qla_hw_data *, srb_t *sp);
> +extern void qla_nvme_unregister_remote_port(struct work_struct *);
> +extern int qla_nvme_wait_on_rport_del(fc_port_t *);
> +extern void qla_nvme_abort_all(fc_port_t *);
> +extern int qla_nvme_post_cmd(struct nvme_fc_local_port *,
> +struct nvme_fc_remote_port *, void *, struct nvmefc_fcp_req *);
> +extern int qla_nvme_alloc_queue(struct nvme_fc_local_port *, unsigned int,
> +u16, void **);
> +extern int qla_nvme_hba_scan(scsi_qla_host_t *);
> +extern void qla_nvme_ls_abort(struct nvme_fc_local_port *,
> +struct nvme_fc_remote_port *, struct nvmefc_ls_req *);
> +extern int qla_nvme_ls_req(struct nvme_fc_local_port *,
> +struct nvme_fc_remote_port *, struct nvmefc_ls_req *);
> +extern void qla_nvme_poll(struct nvme_fc_local_port *, void *);
> +extern int qla2x00_start_nvme_mq(srb_t *);
> +extern void qla_nvme_fcp_abort(struct nvme_fc_local_port *,
> +struct nvme_fc_remote_port *, void *, struct nvmefc_fcp_req *);
> +extern void qla24xx_nvme_ls4_iocb(scsi_qla_host_t *, struct pt_ls4_request *,
> +struct req_que *);

Can't these go into a header instead of using extern?

[...]

> @@ -4662,6 +4667,9 @@ qla2x00_configure_fabric(scsi_qla_host_t *vha)
>   break;
>   } while (0);
>  
> + if ((!vha->nvme_local_port) && (vha->flags.nvme_enabled))


[...]

> + if ((ql2xnvmeenable) && IS_QLA27XX(ha))
> + mcp->mb[4] |= NVME_ENABLE_FLAG;
> +

[...]

> +
> + /* bit 26 of fw_attributes */
> + if ((ha->fw_attributes_h & 0x400) && (ql2xnvmeenable)) {

Superfluous parenthesis.

[...]

> + vha->flags.nvme_enabled = 1;
> + icb->firmware_options_2 &=
> + cpu_to_le32(~(BIT_0 | BIT_1 | BIT_2 | BIT_3));

0xfff0 or maybe even ~0xf?

[...]

> + ret = nvme_fc_register_remoteport(vha->nvme_local_port, &rport->req,
> + &fcport->nvme_remote_port);
> + if (ret) {
> + ql_log(ql_log_warn, vha, 0x212e,
> + "Failed to register remote port. Transport returned %d\n",
> + ret);
> + return ret;
> + }
> +
> + fcport->nvme_remote_port->private = fcport;

A FC-NVMe remote port can be in used right after a call to
nvme_fc_register_remoteport(), if I'm not mistaken. So you should add the
fcport to the nvme_remote_port->private _before_ calling
nvme_fc_register_remoteport().

> + fcport->nvme_flag |= NVME_FLAG_REGISTERED;
> + atomic_set(&fcport->nvme_ref_count, 1);
> + rport->fcport = fcport;
> + list_add_tail(&rport->list, &vha->nvme_rport_list);
> +#endif
> + return 0;
> +}
> +
> +/*
> + * Perform a scan and register those ports with FC-NVMe transport
> + * input:  HBA handle
> + */
> +int qla_nvme_hba_scan(scsi_qla_host_t *vha)

This should be bool.

> +{
> +#if (IS_ENABLED(CONFIG_NVME_FC))
> + fc_port_t   *fcport;
> + uint8_t not_found = 1;

bool found = false;

> +
> + /*
> +  * We are using the first HBA found
> +  * Find matching fcport
> +  */
> + list_for_each_entry(fcport, &vha->vp_fcports, list) {
> + if ((fcport->fc4f_nvme) &&
> + (!(fcport->nvme_flag & NVME_FLAG_REGISTERED))) {
> + qla_nvme_register_remote(vha, fcport);
> + not_found = 0;

found = true;

> + }
> + }
> +
> + return not_found;

return found;

> +#else
> + return 1;

return false;

> +#endif
> +}

And update the call-sites.

[...]

> + if (unlikely((nvme->u.nvme.comp_status) || res))

Parenthesis again.

[...]

> +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;
> + fc_port_t *fcport = rport->private;
> + srb_t *sp = priv->sp;
> + int rval;
> + struct qla_hw_data *ha;
> +
> + ql_log(ql_log_info, fcport->vha, 0x212b,
> + "%s: aborting sp:%p on fcport:%p\n", __func__, sp, fcport);
> +
> + ha = fcport->vha->hw;
> + rval = ha->isp_ops->abort_command(sp);
> + if (rval != QLA_SUCCESS)
> + ql_log(ql_log_warn, fcport->vha, 0x2125,
> + "%s: failed to abort LS command for SP:%p rval=%x\n",
> + __func__, sp, rval);
> +}

I think qla_nvme_ls_abort() is a bit too verbose, it nearly only consists of
logging and thus hides the call to abort_command() from the reader.

> +
> +static void qla_nvme_ls_complete(struct work_struct *work)
> +{
> + struct nvme_private *priv =
> + container_of(

Re: [lkp-robot] [scsi] ebc76736f2: fio.write_bw_MBps -4% regression

2017-06-19 Thread Christoph Hellwig
On Mon, Jun 19, 2017 at 04:52:36PM +0800, Ye Xiaolong wrote:
> >I've not seen a compile-time option for the MQ I/O scheduler (unlike
> >the legacy one), so the way to change it would be to echo the name to
> >/sys/block//queue/scheduler 
> 
> echo mq-deadline > /sys/block//queue/scheduler ?
> 
> I'll try and post the results once I get it.

Thanks!


Re: [lkp-robot] [scsi] ebc76736f2: fio.write_bw_MBps -4% regression

2017-06-19 Thread Ye Xiaolong
On 06/19, Christoph Hellwig wrote:
>On Mon, Jun 19, 2017 at 03:49:43PM +0800, Ye Xiaolong wrote:
>> On 06/19, Christoph Hellwig wrote:
>> >On Mon, Jun 19, 2017 at 02:03:18PM +0800, kernel test robot wrote:
>> >> 
>> >> Greeting,
>> >> 
>> >> FYI, we noticed a -4% regression of fio.write_bw_MBps due to commit:
>> >
>> >What does cat /sys/block//queue/scheduler say for your test?
>> >Can you try with mq-deadline or bfq and see what the results are?
>> 
>> Could you tell me how to do it? via changing kernel config?
>
>BFQ doesn't seem to be enabled in the config, so it would have to be
>enabled.
>
>I've not seen a compile-time option for the MQ I/O scheduler (unlike
>the legacy one), so the way to change it would be to echo the name to
>/sys/block//queue/scheduler 

echo mq-deadline > /sys/block//queue/scheduler ?

I'll try and post the results once I get it.

Thanks,
Xiaolong



Re: [lkp-robot] [scsi] ebc76736f2: fio.write_bw_MBps -4% regression

2017-06-19 Thread Christoph Hellwig
On Mon, Jun 19, 2017 at 03:49:43PM +0800, Ye Xiaolong wrote:
> On 06/19, Christoph Hellwig wrote:
> >On Mon, Jun 19, 2017 at 02:03:18PM +0800, kernel test robot wrote:
> >> 
> >> Greeting,
> >> 
> >> FYI, we noticed a -4% regression of fio.write_bw_MBps due to commit:
> >
> >What does cat /sys/block//queue/scheduler say for your test?
> >Can you try with mq-deadline or bfq and see what the results are?
> 
> Could you tell me how to do it? via changing kernel config?

BFQ doesn't seem to be enabled in the config, so it would have to be
enabled.

I've not seen a compile-time option for the MQ I/O scheduler (unlike
the legacy one), so the way to change it would be to echo the name to
/sys/block//queue/scheduler 


Re: mptsas crash on expander hot-remove

2017-06-19 Thread Johannes Thumshirn
On Fri, Jun 16, 2017 at 07:57:08PM -0400, Will Simoneau wrote:
> Is this is a known / obvious issue, or should I try to bisect it?

This is a known issue with SAS (and FC) drivers, although no soulution exists
to this point.

Johannes

-- 
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] qla2xxx: Add FC-NVMe command handling

2017-06-19 Thread Johannes Thumshirn
On Fri, Jun 16, 2017 at 03:47:40PM -0700, Himanshu Madhani wrote:
> From: Duane Grigsby 
> 
> Signed-off-by: Darren Trapp 
> Signed-off-by: Duane Grigsby 
> Signed-off-by: Anil Gurumurthy 
> Signed-off-by: Giridhar Malavali 
> Signed-off-by: Himanshu Madhani 
> ---

[...]

> +static void
> +qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, void *tsk)
> +{
> + 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;

No need to cast from void*


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 1/6] qla2xxx: Add FC-NVMe port discovery and PRLI handling

2017-06-19 Thread Johannes Thumshirn
On Fri, Jun 16, 2017 at 03:47:39PM -0700, Himanshu Madhani wrote:
> From: Duane Grigsby 
> 
> Signed-off-by: Darren Trapp 
> Signed-off-by: Duane Grigsby 
> Signed-off-by: Anil Gurumurthy 
> Signed-off-by: Giridhar Malavali 
> Signed-off-by: Himanshu Madhani 
> ---

[...]

> +
> + 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;

Minor nit, superfluous parenthesis.


Anyways,
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