Re: [PATCH v5 07/14] blk-mq: Introduce blk_mq_quiesce_queue()

2016-11-01 Thread Ming Lei
On Wed, Nov 2, 2016 at 12:02 AM, Sagi Grimberg  wrote:
> Reviewed-by: Sagi Grimberg 

Reviewed-by: Ming Lei 


--
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [SCSI] mpt3sas: Fix secure erase premature termination (v2)

2016-11-01 Thread Hannes Reinecke

On 11/02/2016 01:09 AM, Andrey Grodzovsky wrote:

Problem:
This is a work around for a bug with LSI Fusion MPT SAS2 when
pefroming secure erase. Due to the very long time the operation
takes commands issued during the erase will time out and will trigger
execution of abort hook. Even though the abort hook is called for
the specifc command which timed out this leads to entire device halt
(scsi_state terminated) and premature termination of the secured erase.

Fix:
Set device state to busy while erase in progress to reject any incoming
commands until the erase is done. The device is blocked any way during
this time and cannot execute any other command.
More data and logs can be found here -
https://drive.google.com/file/d/0B9ocOHYHbbS1Q3VMdkkzeWFkTjg/view

v2: Update according to example patch by Hannes Reinecke to apply
the blocking logic to any ATA 12/16 command.

Signed-off-by: Andrey Grodzovsky 
Cc: 
Cc: Sathya Prakash 
Cc: Chaitra P B 
Cc: Suganath Prabu Subramani 
Cc: Sreekanth Reddy 
Cc: Hannes Reinecke 
Cc: 
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 5a97e32..43ab0cc 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -3500,6 +3500,20 @@ _scsih_eedp_error_handling(struct scsi_cmnd *scmd, u16 
ioc_status)
SAM_STAT_CHECK_CONDITION;
 }

+/**
+ * This is a work around for a bug with LSI Fusion MPT SAS2 when
+ * pefroming secure erase. Due to the verly long time the operation
+ * takes commands issued during the erase will time out and will trigger
+ * execution of abort hook. This leads to device reset and premature
+ * termination of the secured erase.
+ *
+ */
+static inline bool ata_12_16_cmd(struct scsi_cmnd *scmd)
+{
+   return (scmd->cmnd[0] == 0xa1 || scmd->cmnd[0] == 0x85);
+}
+
+

 /**
  * _scsih_qcmd - main scsi request entry point
@@ -3528,6 +3542,14 @@ _scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd 
*scmd)
scsi_print_command(scmd);
 #endif

+   /**
+   * Lock the device for any subsequent command until
+   * command is done.
+   */
+   if (ata_12_16_cmd(scmd))
+   scsi_internal_device_block(scmd->device);
+
+
sas_device_priv_data = scmd->device->hostdata;
if (!sas_device_priv_data || !sas_device_priv_data->sas_target) {
scmd->result = DID_NO_CONNECT << 16;
@@ -4062,6 +4084,10 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 
msix_index, u32 reply)
if (scmd == NULL)
return 1;

+   if (ata_12_16_cmd(scmd))
+   scsi_internal_device_unblock(scmd->device, SDEV_RUNNING);
+
+
mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);

if (mpi_reply == NULL) {


Yeah, it's ugly, but I can't think of a better solution for the moment.
Thanks for debugging this.

Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
--
Dr. Hannes Reinecke   zSeries & Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [SCSI] mpt3sas: Fix secure erase premature termination (v2)

2016-11-01 Thread Andrey Grodzovsky
Problem:
This is a work around for a bug with LSI Fusion MPT SAS2 when
pefroming secure erase. Due to the very long time the operation
takes commands issued during the erase will time out and will trigger
execution of abort hook. Even though the abort hook is called for
the specifc command which timed out this leads to entire device halt
(scsi_state terminated) and premature termination of the secured erase.

Fix:
Set device state to busy while erase in progress to reject any incoming
commands until the erase is done. The device is blocked any way during
this time and cannot execute any other command.
More data and logs can be found here -
https://drive.google.com/file/d/0B9ocOHYHbbS1Q3VMdkkzeWFkTjg/view

v2: Update according to example patch by Hannes Reinecke to apply
the blocking logic to any ATA 12/16 command.

Signed-off-by: Andrey Grodzovsky 
Cc: 
Cc: Sathya Prakash 
Cc: Chaitra P B 
Cc: Suganath Prabu Subramani 
Cc: Sreekanth Reddy 
Cc: Hannes Reinecke 
Cc: 
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 5a97e32..43ab0cc 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -3500,6 +3500,20 @@ _scsih_eedp_error_handling(struct scsi_cmnd *scmd, u16 
ioc_status)
SAM_STAT_CHECK_CONDITION;
 }
 
+/**
+ * This is a work around for a bug with LSI Fusion MPT SAS2 when
+ * pefroming secure erase. Due to the verly long time the operation
+ * takes commands issued during the erase will time out and will trigger
+ * execution of abort hook. This leads to device reset and premature
+ * termination of the secured erase.
+ *
+ */
+static inline bool ata_12_16_cmd(struct scsi_cmnd *scmd)
+{
+   return (scmd->cmnd[0] == 0xa1 || scmd->cmnd[0] == 0x85);
+}
+
+
 
 /**
  * _scsih_qcmd - main scsi request entry point
@@ -3528,6 +3542,14 @@ _scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd 
*scmd)
scsi_print_command(scmd);
 #endif
 
+   /**
+   * Lock the device for any subsequent command until
+   * command is done.
+   */
+   if (ata_12_16_cmd(scmd))
+   scsi_internal_device_block(scmd->device);
+
+
sas_device_priv_data = scmd->device->hostdata;
if (!sas_device_priv_data || !sas_device_priv_data->sas_target) {
scmd->result = DID_NO_CONNECT << 16;
@@ -4062,6 +4084,10 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 
msix_index, u32 reply)
if (scmd == NULL)
return 1;
 
+   if (ata_12_16_cmd(scmd))
+   scsi_internal_device_unblock(scmd->device, SDEV_RUNNING);
+
+
mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
 
if (mpi_reply == NULL) {
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Bug 121531] Adaptec 7805H SAS HBA (pm80xx): hangs when writing >80MB at once

2016-11-01 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=121531

--- Comment #23 from Chloé Desoutter  ---
I can trigger crashes after a long while in a heavy workload, quite randomly,
with 256.

Out of curiosity I checked the pmspcv driver from FreeBSD and they use a lower
value still :


#define MPI_MAX_INBOUND_QUEUES  64 /**< Maximum number of inbound
queues */
#define MPI_MAX_OUTBOUND_QUEUES 64 /**< Maximum number of outbound
queues */

   /**< Max # of memory chunks
supported */
#define MPI_MAX_MEM_REGIONS (MPI_MAX_INBOUND_QUEUES +
MPI_MAX_OUTBOUND_QUEUES) + 4
#define MPI_LOGSIZE 4096  /**< default size */

so I'll try with this value and give feedback for stability and performance.

-- 
You are receiving this mail because:
You are the assignee for the bug.--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] scsi_dh_rdac: switch to scsi_execute_req_flags()

2016-11-01 Thread Hannes Reinecke
Switch to scsi_execute_req_flags() instead of
using the block interface directly. This will set
REQ_QUIET and REQ_PREEMPT, but this is okay as
we're evaluating the errors anyway and should be
able to send the command even if the device is
quiesced.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/device_handler/scsi_dh_rdac.c | 172 -
 1 file changed, 49 insertions(+), 123 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c 
b/drivers/scsi/device_handler/scsi_dh_rdac.c
index 06fbd0b..6cd113b 100644
--- a/drivers/scsi/device_handler/scsi_dh_rdac.c
+++ b/drivers/scsi/device_handler/scsi_dh_rdac.c
@@ -205,7 +205,6 @@ struct rdac_dh_data {
 #define RDAC_NON_PREFERRED 1
charpreferred;
 
-   unsigned char   sense[SCSI_SENSE_BUFFERSIZE];
union   {
struct c2_inquiry c2;
struct c4_inquiry c4;
@@ -262,40 +261,12 @@ do { \
sdev_printk(KERN_INFO, sdev, RDAC_NAME ": " f "\n", ## arg); \
 } while (0);
 
-static struct request *get_rdac_req(struct scsi_device *sdev,
-   void *buffer, unsigned buflen, int rw)
+static unsigned int rdac_failover_get(struct rdac_controller *ctlr,
+ struct list_head *list,
+ unsigned char *cdb)
 {
-   struct request *rq;
-   struct request_queue *q = sdev->request_queue;
-
-   rq = blk_get_request(q, rw, GFP_NOIO);
-
-   if (IS_ERR(rq)) {
-   sdev_printk(KERN_INFO, sdev,
-   "get_rdac_req: blk_get_request failed.\n");
-   return NULL;
-   }
-   blk_rq_set_block_pc(rq);
-
-   if (buflen && blk_rq_map_kern(q, rq, buffer, buflen, GFP_NOIO)) {
-   blk_put_request(rq);
-   sdev_printk(KERN_INFO, sdev,
-   "get_rdac_req: blk_rq_map_kern failed.\n");
-   return NULL;
-   }
-
-   rq->cmd_flags |= REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
-REQ_FAILFAST_DRIVER;
-   rq->retries = RDAC_RETRIES;
-   rq->timeout = RDAC_TIMEOUT;
-
-   return rq;
-}
-
-static struct request *rdac_failover_get(struct scsi_device *sdev,
-   struct rdac_dh_data *h, struct list_head *list)
-{
-   struct request *rq;
+   struct scsi_device *sdev = ctlr->ms_sdev;
+   struct rdac_dh_data *h = sdev->handler_data;
struct rdac_mode_common *common;
unsigned data_size;
struct rdac_queue_data *qdata;
@@ -332,27 +303,17 @@ static struct request *rdac_failover_get(struct 
scsi_device *sdev,
lun_table[qdata->h->lun] = 0x81;
}
 
-   /* get request for block layer packet command */
-   rq = get_rdac_req(sdev, >ctlr->mode_select, data_size, WRITE);
-   if (!rq)
-   return NULL;
-
/* Prepare the command. */
if (h->ctlr->use_ms10) {
-   rq->cmd[0] = MODE_SELECT_10;
-   rq->cmd[7] = data_size >> 8;
-   rq->cmd[8] = data_size & 0xff;
+   cdb[0] = MODE_SELECT_10;
+   cdb[7] = data_size >> 8;
+   cdb[8] = data_size & 0xff;
} else {
-   rq->cmd[0] = MODE_SELECT;
-   rq->cmd[4] = data_size;
+   cdb[0] = MODE_SELECT;
+   cdb[4] = data_size;
}
-   rq->cmd_len = COMMAND_SIZE(rq->cmd[0]);
-
-   rq->sense = h->sense;
-   memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE);
-   rq->sense_len = 0;
 
-   return rq;
+   return data_size;
 }
 
 static void release_controller(struct kref *kref)
@@ -400,46 +361,14 @@ static struct rdac_controller *get_controller(int index, 
char *array_name,
return ctlr;
 }
 
-static int submit_inquiry(struct scsi_device *sdev, int page_code,
- unsigned int len, struct rdac_dh_data *h)
-{
-   struct request *rq;
-   struct request_queue *q = sdev->request_queue;
-   int err = SCSI_DH_RES_TEMP_UNAVAIL;
-
-   rq = get_rdac_req(sdev, >inq, len, READ);
-   if (!rq)
-   goto done;
-
-   /* Prepare the command. */
-   rq->cmd[0] = INQUIRY;
-   rq->cmd[1] = 1;
-   rq->cmd[2] = page_code;
-   rq->cmd[4] = len;
-   rq->cmd_len = COMMAND_SIZE(INQUIRY);
-
-   rq->sense = h->sense;
-   memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE);
-   rq->sense_len = 0;
-
-   err = blk_execute_rq(q, NULL, rq, 1);
-   if (err == -EIO)
-   err = SCSI_DH_IO;
-
-   blk_put_request(rq);
-done:
-   return err;
-}
-
 static int get_lun_info(struct scsi_device *sdev, struct rdac_dh_data *h,
char *array_name, u8 *array_id)
 {
-   int err, i;
-   struct c8_inquiry *inqp;
+   int err = SCSI_DH_IO, i;
+   struct c8_inquiry *inqp = >inq.c8;
 
-   err = submit_inquiry(sdev, 0xC8, 

[PATCH 3/3] scsi_dh_hp_sw: switch to scsi_execute_req_flags()

2016-11-01 Thread Hannes Reinecke
Switch to scsi_execute_req_flags() instead of
using the block interface directly. This will set
REQ_QUIET and REQ_PREEMPT, but this is okay as
we're evaluating the errors anyway and should be
able to send the command even if the device is
quiesced.
Switch to scsi_execute_req_flags() instead of
using the block interface directly.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/device_handler/scsi_dh_hp_sw.c | 218 
 1 file changed, 61 insertions(+), 157 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c 
b/drivers/scsi/device_handler/scsi_dh_hp_sw.c
index 9406d5f..84afe2f 100644
--- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c
+++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c
@@ -38,13 +38,10 @@
 #define HP_SW_PATH_PASSIVE 1
 
 struct hp_sw_dh_data {
-   unsigned char sense[SCSI_SENSE_BUFFERSIZE];
int path_state;
int retries;
int retry_cnt;
struct scsi_device *sdev;
-   activate_complete   callback_fn;
-   void*callback_data;
 };
 
 static int hp_sw_start_stop(struct hp_sw_dh_data *);
@@ -56,43 +53,34 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *);
  *
  * Returns SCSI_DH_DEV_OFFLINED if the sdev is on the passive path
  */
-static int tur_done(struct scsi_device *sdev, unsigned char *sense)
+static int tur_done(struct scsi_device *sdev, struct hp_sw_dh_data *h,
+   struct scsi_sense_hdr *sshdr)
 {
-   struct scsi_sense_hdr sshdr;
-   int ret;
+   int ret = SCSI_DH_IO;
 
-   ret = scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, );
-   if (!ret) {
-   sdev_printk(KERN_WARNING, sdev,
-   "%s: sending tur failed, no sense available\n",
-   HP_SW_NAME);
-   ret = SCSI_DH_IO;
-   goto done;
-   }
-   switch (sshdr.sense_key) {
+   switch (sshdr->sense_key) {
case UNIT_ATTENTION:
ret = SCSI_DH_IMM_RETRY;
break;
case NOT_READY:
-   if ((sshdr.asc == 0x04) && (sshdr.ascq == 2)) {
+   if ((sshdr->asc == 0x04) && (sshdr->ascq == 2)) {
/*
 * LUN not ready - Initialization command required
 *
 * This is the passive path
 */
-   ret = SCSI_DH_DEV_OFFLINED;
+   h->path_state = HP_SW_PATH_PASSIVE;
+   ret = SCSI_DH_OK;
break;
}
/* Fallthrough */
default:
sdev_printk(KERN_WARNING, sdev,
   "%s: sending tur failed, sense %x/%x/%x\n",
-  HP_SW_NAME, sshdr.sense_key, sshdr.asc,
-  sshdr.ascq);
+  HP_SW_NAME, sshdr->sense_key, sshdr->asc,
+  sshdr->ascq);
break;
}
-
-done:
return ret;
 }
 
@@ -105,131 +93,34 @@ static int tur_done(struct scsi_device *sdev, unsigned 
char *sense)
  */
 static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)
 {
-   struct request *req;
-   int ret;
+   unsigned char cmd[6] = { TEST_UNIT_READY };
+   struct scsi_sense_hdr sshdr;
+   int ret = SCSI_DH_OK, res;
 
 retry:
-   req = blk_get_request(sdev->request_queue, WRITE, GFP_NOIO);
-   if (IS_ERR(req))
-   return SCSI_DH_RES_TEMP_UNAVAIL;
-
-   blk_rq_set_block_pc(req);
-   req->cmd_flags |= REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
- REQ_FAILFAST_DRIVER;
-   req->cmd_len = COMMAND_SIZE(TEST_UNIT_READY);
-   req->cmd[0] = TEST_UNIT_READY;
-   req->timeout = HP_SW_TIMEOUT;
-   req->sense = h->sense;
-   memset(req->sense, 0, SCSI_SENSE_BUFFERSIZE);
-   req->sense_len = 0;
-
-   ret = blk_execute_rq(req->q, NULL, req, 1);
-   if (ret == -EIO) {
-   if (req->sense_len > 0) {
-   ret = tur_done(sdev, h->sense);
-   } else {
+   res = scsi_execute_req_flags(sdev, cmd, DMA_NONE, NULL, 0, ,
+HP_SW_TIMEOUT, HP_SW_RETRIES,
+NULL, REQ_FAILFAST_MASK);
+   if (res) {
+   if (scsi_sense_valid())
+   ret = tur_done(sdev, h, );
+   else {
sdev_printk(KERN_WARNING, sdev,
"%s: sending tur failed with %x\n",
-   HP_SW_NAME, req->errors);
+   HP_SW_NAME, res);
ret = SCSI_DH_IO;
}
} else {
h->path_state = HP_SW_PATH_ACTIVE;
ret = SCSI_DH_OK;
}
-   if (ret == SCSI_DH_IMM_RETRY) {
-   

[PATCH 2/3] scsi_dh_emc: switch to scsi_execute_req_flags()

2016-11-01 Thread Hannes Reinecke
Switch to scsi_execute_req_flags() instead of
using the block interface directly. This will set
REQ_QUIET and REQ_PREEMPT, but this is okay as
we're evaluating the errors anyway and should be
able to send the command even if the device is
quiesced.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/device_handler/scsi_dh_emc.c | 245 +++---
 1 file changed, 54 insertions(+), 191 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_emc.c 
b/drivers/scsi/device_handler/scsi_dh_emc.c
index 375d818..a7da109 100644
--- a/drivers/scsi/device_handler/scsi_dh_emc.c
+++ b/drivers/scsi/device_handler/scsi_dh_emc.c
@@ -88,12 +88,6 @@ struct clariion_dh_data {
 */
unsigned char buffer[CLARIION_BUFFER_SIZE];
/*
-* SCSI sense buffer for commands -- assumes serial issuance
-* and completion sequence of all commands for same multipath.
-*/
-   unsigned char sense[SCSI_SENSE_BUFFERSIZE];
-   unsigned int senselen;
-   /*
 * LUN state
 */
int lun_state;
@@ -116,44 +110,38 @@ struct clariion_dh_data {
 /*
  * Parse MODE_SELECT cmd reply.
  */
-static int trespass_endio(struct scsi_device *sdev, char *sense)
+static int trespass_endio(struct scsi_device *sdev,
+ struct scsi_sense_hdr *sshdr)
 {
int err = SCSI_DH_IO;
-   struct scsi_sense_hdr sshdr;
-
-   if (!scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, )) {
-   sdev_printk(KERN_ERR, sdev, "%s: Found valid sense data 0x%2x, "
-   "0x%2x, 0x%2x while sending CLARiiON trespass "
-   "command.\n", CLARIION_NAME, sshdr.sense_key,
-   sshdr.asc, sshdr.ascq);
 
-   if ((sshdr.sense_key == 0x05) && (sshdr.asc == 0x04) &&
-(sshdr.ascq == 0x00)) {
-   /*
-* Array based copy in progress -- do not send
-* mode_select or copy will be aborted mid-stream.
-*/
-   sdev_printk(KERN_INFO, sdev, "%s: Array Based Copy in "
-   "progress while sending CLARiiON trespass "
-   "command.\n", CLARIION_NAME);
-   err = SCSI_DH_DEV_TEMP_BUSY;
-   } else if ((sshdr.sense_key == 0x02) && (sshdr.asc == 0x04) &&
-   (sshdr.ascq == 0x03)) {
-   /*
-* LUN Not Ready - Manual Intervention Required
-* indicates in-progress ucode upgrade (NDU).
-*/
-   sdev_printk(KERN_INFO, sdev, "%s: Detected in-progress "
-   "ucode upgrade NDU operation while sending "
-   "CLARiiON trespass command.\n", 
CLARIION_NAME);
-   err = SCSI_DH_DEV_TEMP_BUSY;
-   } else
-   err = SCSI_DH_DEV_FAILED;
-   } else {
-   sdev_printk(KERN_INFO, sdev,
-   "%s: failed to send MODE SELECT, no sense 
available\n",
-   CLARIION_NAME);
-   }
+   sdev_printk(KERN_ERR, sdev, "%s: Found valid sense data 0x%2x, "
+   "0x%2x, 0x%2x while sending CLARiiON trespass "
+   "command.\n", CLARIION_NAME, sshdr->sense_key,
+   sshdr->asc, sshdr->ascq);
+
+   if ((sshdr->sense_key == 0x05) && (sshdr->asc == 0x04) &&
+   (sshdr->ascq == 0x00)) {
+   /*
+* Array based copy in progress -- do not send
+* mode_select or copy will be aborted mid-stream.
+*/
+   sdev_printk(KERN_INFO, sdev, "%s: Array Based Copy in "
+   "progress while sending CLARiiON trespass "
+   "command.\n", CLARIION_NAME);
+   err = SCSI_DH_DEV_TEMP_BUSY;
+   } else if ((sshdr->sense_key == 0x02) && (sshdr->asc == 0x04) &&
+  (sshdr->ascq == 0x03)) {
+   /*
+* LUN Not Ready - Manual Intervention Required
+* indicates in-progress ucode upgrade (NDU).
+*/
+   sdev_printk(KERN_INFO, sdev, "%s: Detected in-progress "
+   "ucode upgrade NDU operation while sending "
+   "CLARiiON trespass command.\n", CLARIION_NAME);
+   err = SCSI_DH_DEV_TEMP_BUSY;
+   } else
+   err = SCSI_DH_DEV_FAILED;
return err;
 }
 
@@ -257,103 +245,13 @@ static char * parse_sp_model(struct scsi_device *sdev, 
unsigned char *buffer)
return sp_model;
 }
 
-/*
- * Get block request for REQ_BLOCK_PC command issued to path.  Currently
- * limited to MODE_SELECT (trespass) and INQUIRY (VPD page 0xC0) commands.
- *
- * Uses data and sense 

[PATCHv2 0/3] scsi_dh: switch to scsi_execute_req_flags()

2016-11-01 Thread Hannes Reinecke
Hi all,

here's a patchset to switch to scsi_execute_req_flags() for
all SCSI device handlers. Originally we would be using
blk_execute_rq_nowait to allow the 'activate' function
to run asynchronously.
However, as we're now calling the 'activate' function
synchronously there's no point in using the blk_execute_rq()
interface and we should be using scsi_execute_req_flags()
instead.

As usual, comments and reviews are welcome.

Changes to v1:
- Integrate reviews from hch

Hannes Reinecke (3):
  scsi_dh_rdac: switch to scsi_execute_req_flags()
  scsi_dh_emc: switch to scsi_execute_req_flags()
  scsi_dh_hp_sw: switch to scsi_execute_req_flags()

 drivers/scsi/device_handler/scsi_dh_emc.c   | 245 ++--
 drivers/scsi/device_handler/scsi_dh_hp_sw.c | 218 +++--
 drivers/scsi/device_handler/scsi_dh_rdac.c  | 172 ++-
 3 files changed, 164 insertions(+), 471 deletions(-)

-- 
2.6.6

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] qla2xxx: Fix scsi scan hang triggered if adapter fails during init

2016-11-01 Thread Martin K. Petersen
> "Bill" == Bill Kuzeja  writes:

Bill> A system can get hung task timeouts if a qlogic board fails during
Bill> initialization (if the board breaks again or fails the init). The
Bill> hang involves the scsi scan.

Bill> In a nutshell, since commit beb9e315e6e0 ("qla2xxx: Prevent
Bill> removal and board_disable race"):

Applied to 4.9/scsi-fixes.

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] scsi_dh_rdac: switch to scsi_execute_req_flags()

2016-11-01 Thread Hannes Reinecke

On 11/01/2016 03:47 PM, Christoph Hellwig wrote:

On Mon, Oct 31, 2016 at 06:59:28PM +0100, Hannes Reinecke wrote:

Switch to using scsi_execute_req_flags() instead of using the
block primitives.


__scsi_execute adds RQF_QUIET and RQF_PREEMPT to the request flags, which
would be a change in behavior.  A little analysis on why that's safe or
even desireable would be nice.  (This also applies to the other two patches
I think).


Hmm. Yeah, guess I'll need to reconcile that.



 static void release_controller(struct kref *kref)
 static int get_lun_info(struct scsi_device *sdev, struct rdac_dh_data *h,
char *array_name, u8 *array_id)
 {
+   int err = SCSI_DH_IO, i;
struct c8_inquiry *inqp;

+   if (!scsi_get_vpd_page(sdev, 0xC8, (unsigned char *)h,
+  sizeof(struct c8_inquiry))) {


This looks completely bogus to me - h is a struct rdac_dh_data pointer,
which is an in-kernel data structure that scsi_get_vpd_page would
scramble over.


Indeed, you are right. I'll be fixing it up.

Cheers,

Hannes
--
Dr. Hannes Reinecke   zSeries & Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 09/12] ufs-qcom: phy/hcd: Refactoring phy clock handling

2016-11-01 Thread Subhash Jadavani

On 2016-10-29 13:22, Vivek Gautam wrote:

Add phy clock enable code to phy_power_on/off callbacks, and
remove explicit calls to enable these phy clocks from the
ufs-qcom hcd driver.

Signed-off-by: Vivek Gautam 
---

Changes since v2:
 - Added phy_power_on() and phy_power_off() calls to
   power-cycle the PHY during aggressive clk gating.

Changes since v1:
 - staticized ufs_qcom_phy_enable(/disable)_ref_clk(),
 - staticized ufs_qcom_phy_enable(/disable)_iface_clk()
 - removed function declaration and export symbol for these APIs.

 drivers/phy/phy-qcom-ufs.c   | 36 
++--

 drivers/scsi/ufs/ufs-qcom.c  | 18 +++---
 include/linux/phy/phy-qcom-ufs.h | 18 --
 3 files changed, 21 insertions(+), 51 deletions(-)

diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index 1ec64d5..9dff4c2 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -366,10 +366,9 @@ int ufs_qcom_phy_enable_vreg(struct device *dev,
return ret;
 }

-int ufs_qcom_phy_enable_ref_clk(struct phy *generic_phy)
+static int ufs_qcom_phy_enable_ref_clk(struct ufs_qcom_phy *phy)
 {
int ret = 0;
-   struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);

if (phy->is_ref_clk_enabled)
goto out;
@@ -416,7 +415,6 @@ int ufs_qcom_phy_enable_ref_clk(struct phy 
*generic_phy)

 out:
return ret;
 }
-EXPORT_SYMBOL_GPL(ufs_qcom_phy_enable_ref_clk);

 static
 int ufs_qcom_phy_disable_vreg(struct device *dev,
@@ -441,10 +439,8 @@ int ufs_qcom_phy_disable_vreg(struct device *dev,
return ret;
 }

-void ufs_qcom_phy_disable_ref_clk(struct phy *generic_phy)
+static void ufs_qcom_phy_disable_ref_clk(struct ufs_qcom_phy *phy)
 {
-   struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
-
if (phy->is_ref_clk_enabled) {
clk_disable_unprepare(phy->ref_clk);
/*
@@ -457,7 +453,6 @@ void ufs_qcom_phy_disable_ref_clk(struct phy 
*generic_phy)

phy->is_ref_clk_enabled = false;
}
 }
-EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_ref_clk);

 #define UFS_REF_CLK_EN (1 << 5)

@@ -510,9 +505,8 @@ void ufs_qcom_phy_disable_dev_ref_clk(struct phy
*generic_phy)
 EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_dev_ref_clk);

 /* Turn ON M-PHY RMMI interface clocks */
-int ufs_qcom_phy_enable_iface_clk(struct phy *generic_phy)
+static int ufs_qcom_phy_enable_iface_clk(struct ufs_qcom_phy *phy)
 {
-   struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
int ret = 0;

if (phy->is_iface_clk_enabled)
@@ -536,20 +530,16 @@ int ufs_qcom_phy_enable_iface_clk(struct phy 
*generic_phy)

 out:
return ret;
 }
-EXPORT_SYMBOL_GPL(ufs_qcom_phy_enable_iface_clk);

 /* Turn OFF M-PHY RMMI interface clocks */
-void ufs_qcom_phy_disable_iface_clk(struct phy *generic_phy)
+void ufs_qcom_phy_disable_iface_clk(struct ufs_qcom_phy *phy)
 {
-   struct ufs_qcom_phy *phy = get_ufs_qcom_phy(generic_phy);
-
if (phy->is_iface_clk_enabled) {
clk_disable_unprepare(phy->tx_iface_clk);
clk_disable_unprepare(phy->rx_iface_clk);
phy->is_iface_clk_enabled = false;
}
 }
-EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_iface_clk);

 int ufs_qcom_phy_start_serdes(struct phy *generic_phy)
 {
@@ -667,13 +657,20 @@ int ufs_qcom_phy_power_on(struct phy 
*generic_phy)

goto out_disable_phy;
}

-   err = ufs_qcom_phy_enable_ref_clk(generic_phy);
+   err = ufs_qcom_phy_enable_iface_clk(phy_common);
if (err) {
-   dev_err(dev, "%s enable phy ref clock failed, err=%d\n",
+   dev_err(dev, "%s enable phy iface clock failed, err=%d\n",
__func__, err);
goto out_disable_pll;
}

+   err = ufs_qcom_phy_enable_ref_clk(phy_common);
+   if (err) {
+   dev_err(dev, "%s enable phy ref clock failed, err=%d\n",
+   __func__, err);
+   goto out_disable_iface_clk;
+   }
+
/* enable device PHY ref_clk pad rail */
if (phy_common->vddp_ref_clk.reg) {
err = ufs_qcom_phy_enable_vreg(dev,
@@ -689,7 +686,9 @@ int ufs_qcom_phy_power_on(struct phy *generic_phy)
goto out;

 out_disable_ref_clk:
-   ufs_qcom_phy_disable_ref_clk(generic_phy);
+   ufs_qcom_phy_disable_ref_clk(phy_common);
+out_disable_iface_clk:
+   ufs_qcom_phy_disable_iface_clk(phy_common);
 out_disable_pll:
ufs_qcom_phy_disable_vreg(dev, _common->vdda_pll);
 out_disable_phy:
@@ -708,7 +707,8 @@ int ufs_qcom_phy_power_off(struct phy *generic_phy)
if (phy_common->vddp_ref_clk.reg)
ufs_qcom_phy_disable_vreg(phy_common->dev,
  _common->vddp_ref_clk);
-   ufs_qcom_phy_disable_ref_clk(generic_phy);
+   ufs_qcom_phy_disable_ref_clk(phy_common);
+   

Re: [PATCH v3 05/12] phy: qcom-ufs: Skip obtaining rx/tx_iface_clk for msm8996 based phy

2016-11-01 Thread Subhash Jadavani

On 2016-10-29 13:22, Vivek Gautam wrote:

The tx_iface_clk and rx_iface_clk no longer exist with UFS Phy
present on msm8996. So skip obtaining these clocks using
compatible match.

Signed-off-by: Vivek Gautam 
---

New patch in v3 of this cleanup series.
Comes in place of the following patch in v2 -
 phy: qcom-ufs: remove failure when rx/tx_iface_clk are absent

 drivers/phy/phy-qcom-ufs.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index a173b30..11c8cae 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -184,6 +184,10 @@ int ufs_qcom_phy_clk_get(struct device *dev,
 {
int err;

+   if (of_device_is_compatible(phy_common->dev->of_node,
+   "qcom,msm8996-ufs-phy-qmp-14nm"))


Vivek, This change looks good but you might need a minor change if we 
agree to change the compatible string name 
("qcom,msm8996-ufs-phy-qmp-14nm") as commented on patch #4.



+   goto skip_txrx_clk;
+
err = ufs_qcom_phy_clk_get(phy_common->dev, "tx_iface_clk",
   _common->tx_iface_clk);
if (err)
@@ -199,6 +203,7 @@ int ufs_qcom_phy_clk_get(struct device *dev,
if (err)
goto out;

+skip_txrx_clk:
/*
 * "ref_clk_parent" is optional hence don't abort init if it's not
 * found.


--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] block: Fix kernel panic occurs while creating second raid disk

2016-11-01 Thread Douglas Miller

On 10/24/2016 01:54 PM, Sreekanth Reddy wrote:

Observing below kernel panic while creating second raid disk
on LSI SAS3008 HBA card.

[  +0.55] [ cut here ]
[  +0.07] WARNING: CPU: 2 PID: 281 at fs/sysfs/dir.c:31 
sysfs_warn_dup+0x62/0x80
[  +0.02] sysfs: cannot create duplicate filename 
'/devices/virtual/bdi/8:32'
[  +0.01] Modules linked in: mptctl mptbase xt_CHECKSUM 
iptable_mangle ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat 
nf_conntrack tun bridge stp llc ebtable_filter ebtables 
ip6table_filter ip6_tables intel_rapl sb_edac edac_core 
x86_pkg_temp_pclmul joydev ghash_clmulni_intel iTCO_wdt ipmi_ssif 
mei_me pcspkr mei iTCO_vendor_support ipmi_si i2c_i801 lpc_ich 
mfd_corema acpi_pad wmi acpi_power_meter nfsd auth_rpcgss nfs_acl 
lockd grace binfmt_misc sunrpc xfs libcrc32c ast i2c_algo_bit drm_kore 
raid_class nvme_core scsi_transport_sas dca
[  +0.67] CPU: 2 PID: 281 Comm: kworker/u49:5 Not tainted 
4.9.0-rc2 #1
[  +0.02] Hardware name: Supermicro SYS-2028U-TNRT+/X10DRU-i+, 
BIOS 1.1 07/22/2015

[  +0.05] Workqueue: events_unbound async_run_entry_fn
[  +0.04] Call Trace:
[  +0.09]  [] dump_stack+0x63/0x85
[  +0.05]  [] __warn+0xcb/0xf0
[  +0.04]  [] warn_slowpath_fmt+0x5f/0x80
[  +0.06]  [] ? kernfs_path_from_node+0x4f/0x60
[  +0.02]  [] sysfs_warn_dup+0x62/0x80
[  +0.02]  [] sysfs_create_dir_ns+0x77/0x90
[  +0.04]  [] kobject_add_internal+0x99/0x330
[  +0.03]  [] ? vsnprintf+0x35b/0x4c0
[  +0.03]  [] kobject_add+0x75/0xd0
[  +0.06]  [] ? device_private_init+0x23/0x70
[  +0.07]  [] ? mutex_lock+0x12/0x30
[  +0.03]  [] device_add+0x119/0x670
[  +0.04]  [] device_create_groups_vargs+0xe0/0xf0
[  +0.03]  [] device_create_vargs+0x1c/0x20
[  +0.06]  [] bdi_register+0x8c/0x180
[  +0.03]  [] bdi_register_owner+0x36/0x60
[  +0.06]  [] device_add_disk+0x168/0x480
[  +0.05]  [] ? update_autosuspend+0x51/0x60
[  +0.05]  [] sd_probe_async+0x110/0x1c0
[  +0.02]  [] async_run_entry_fn+0x39/0x140
[  +0.03]  [] process_one_work+0x15f/0x430
[  +0.02]  [] worker_thread+0x4e/0x490
[  +0.02]  [] ? process_one_work+0x430/0x430
[  +0.03]  [] kthread+0xd9/0xf0
[  +0.03]  [] ? kthread_park+0x60/0x60
[  +0.03]  [] ret_from_fork+0x25/0x30
[  +0.02] [ cut here ]
[  +0.04] WARNING: CPU: 2 PID: 281 at lib/kobject.c:240 
kobject_add_internal+0x2bd/0x330
[  +0.01] kobject_add_internal failed for 8:32 with -EEXIST, don't 
try to register things with the same name in the same
[  +0.01] Modules linked in: mptctl mptbase xt_CHECKSUM 
iptable_mangle ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat 
nf_conntrack tun bridge stp llc ebtable_filter ebtables 
ip6table_filter ip6_tables intel_rapl sb_edac edac_core 
x86_pkg_temp_pclmul joydev ghash_clmulni_intel iTCO_wdt ipmi_ssif 
mei_me pcspkr mei iTCO_vendor_support ipmi_si i2c_i801 lpc_ich 
mfd_corema acpi_pad wmi acpi_power_meter nfsd auth_rpcgss nfs_acl 
lockd grace binfmt_misc sunrpc xfs libcrc32c ast i2c_algo_bit drm_kore 
raid_class nvme_core scsi_transport_sas dca
[  +0.43] CPU: 2 PID: 281 Comm: kworker/u49:5 Tainted: G
W   4.9.0-rc2 #1
[  +0.01] Hardware name: Supermicro SYS-2028U-TNRT+/X10DRU-i+, 
BIOS 1.1 07/22/2015

[  +0.02] Workqueue: events_unbound async_run_entry_fn
[  +0.03] Call Trace:
[  +0.03]  [] dump_stack+0x63/0x85
[  +0.03]  [] __warn+0xcb/0xf0
[  +0.04]  [] warn_slowpath_fmt+0x5f/0x80
[  +0.02]  [] ? sysfs_warn_dup+0x6a/0x80
[  +0.03]  [] kobject_add_internal+0x2bd/0x330
[  +0.03]  [] ? vsnprintf+0x35b/0x4c0
[  +0.03]  [] kobject_add+0x75/0xd0
[  +0.03]  [] ? device_private_init+0x23/0x70
[  +0.04]  [] ? mutex_lock+0x12/0x30
[  +0.02]  [] device_add+0x119/0x670
[  +0.04]  [] device_create_groups_vargs+0xe0/0xf0
[  +0.03]  [] device_create_vargs+0x1c/0x20
[  +0.03]  [] bdi_register+0x8c/0x180
[  +0.03]  [] bdi_register_owner+0x36/0x60
[  +0.04]  [] device_add_disk+0x168/0x480
[  +0.03]  [] ? update_autosuspend+0x51/0x60
[  +0.02]  [] sd_probe_async+0x110/0x1c0
[  +0.02]  [] async_run_entry_fn+0x39/0x140
[  +0.02]  [] process_one_work+0x15f/0x430
[  +0.02]  [] worker_thread+0x4e/0x490
[  +0.02]  [] ? process_one_work+0x430/0x430
[  +0.03]  [] kthread+0xd9/0xf0
[  +0.03]  [] ? kthread_park+0x60/0x60
[  +0.03]  [] ret_from_fork+0x25/0x30
[  +0.000949] BUG: unable to handle kernel
[  +0.005263] NULL pointer dereference
[  +0.002853] IP: [] 
sysfs_do_create_link_sd.isra.2+0x34/0xb0

[  +0.008584] PGD 0

[  +0.006115] Oops:  [#1] SMP
[  +0.004531] Modules linked in: mptctl mptbase xt_CHECKSUM 
iptable_mangle ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat 
nf_conntrack tun bridge stp llc ebtable_filter ebtables 
ip6table_filter ip6_tables intel_rapl sb_edac edac_core 
x86_pkg_temp_pclmul joydev ghash_clmulni_intel iTCO_wdt ipmi_ssif 

Re: expose queue the queue mapping for SCSI drivers V2

2016-11-01 Thread Martin K. Petersen
> "Christoph" == Christoph Hellwig  writes:

Christoph> In 4.9 I've added support in the interrupt layer to
Christoph> automatically assign the interrupt affinity at interrupt
Christoph> allocation time, and expose that information to blk-mq.

Christoph> This series extents that so that SCSI driver can pass on the
Christoph> information as well.  The SCSI part is fairly trivial,
Christoph> although we need to also export the default queue mapping
Christoph> function in blk-mq to keep things simple.

Christoph> I've also converted over the smartpqi driver as an example as
Christoph> it's the easiest of the multiqueue SCSI drivers to convert.

Applied to 4.10/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mvsas: fix error return code in mvs_task_prep()

2016-11-01 Thread Tejun Heo
On Mon, Oct 31, 2016 at 10:29:26AM -0600, Tejun Heo wrote:
> On Mon, Oct 31, 2016 at 03:04:10PM +, Wei Yongjun wrote:
> > From: Wei Yongjun 
> > 
> > Fix to return error code -ENOMEM from the error handling
> > case instead of 0, as done elsewhere in this function.
> > 
> > Signed-off-by: Wei Yongjun 
> 
> Applied to libata/for-4.9-fixes.

I messed up.  This should have gone through scsi, not libata.  Chatted
with Martin and as the patch is a small obvious fix decided to leave
it in libata tree.  My apologies for the confusion.

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi_dh_alua: Fix a reference counting bug

2016-11-01 Thread Martin K. Petersen
> "Bart" == Bart Van Assche  writes:

Bart> The code at the end of alua_rtpg_work() is as follows:
Bart>   scsi_device_put(sdev);
Bart>   kref_put(>kref, release_port_group);

Bart> In other words, alua_rtpg_queue() must hold an sdev reference and
Bart> a pg reference before queueing rtpg work. If no rtpg work is
Bart> queued no additional references should be held when
Bart> alua_rtpg_queue() returns. If no rtpg work is queued, ensure that
Bart> alua_rtpg_queue() only gives up the sdev reference if that
Bart> reference was obtained by the same alua_rtpg_queue() call.

Applied to 4.9/scsi-fixes.

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/3] scsi_dh: switch to scsi_execute_req_flags()

2016-11-01 Thread Hannes Reinecke

On 11/01/2016 03:41 PM, Christoph Hellwig wrote:

A little warning: scsi_execute_req_flags grew a new argument in the block
tree to be able to specify the request-only flags.  So any of these
patches would create a (mostly harmless) conflict in linux-next.


I don't mind creating the patches against the block tree.
Martin? Jens? What's the preferred way here?

Cheers,

Hannes
--
Dr. Hannes Reinecke   zSeries & Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi_dh_alua: Fix a reference counting bug

2016-11-01 Thread Hannes Reinecke

On 11/01/2016 03:19 PM, Bart Van Assche wrote:

The code at the end of alua_rtpg_work() is as follows:

scsi_device_put(sdev);
kref_put(>kref, release_port_group);

In other words, alua_rtpg_queue() must hold an sdev reference and
a pg reference before queueing rtpg work. If no rtpg work is queued
no additional references should be held when alua_rtpg_queue()
returns. If no rtpg work is queued, ensure that alua_rtpg_queue()
only gives up the sdev reference if that reference was obtained by
the same alua_rtpg_queue() call.

Signed-off-by: Bart Van Assche 
Cc: Hannes Reinecke 
Cc: Tang Junhui 
Cc: 
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index f375167..7bb2068 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -891,6 +891,7 @@ static void alua_rtpg_queue(struct alua_port_group *pg,
/* Do not queue if the worker is already running */
if (!(pg->flags & ALUA_PG_RUNNING)) {
kref_get(>kref);
+   sdev = NULL;
start_queue = 1;
}
}
@@ -902,7 +903,8 @@ static void alua_rtpg_queue(struct alua_port_group *pg,
if (start_queue &&
!queue_delayed_work(alua_wq, >rtpg_work,
msecs_to_jiffies(ALUA_RTPG_DELAY_MSECS))) {
-   scsi_device_put(sdev);
+   if (sdev)
+   scsi_device_put(sdev);
kref_put(>kref, release_port_group);
}
 }


Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
--
Dr. Hannes Reinecke   zSeries & Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] fnic: remove a pointless test

2016-11-01 Thread Tomas Henzl
rport can't be null here, it would have failed already in
fc_remote_port_chkready

Signed-off-by: Tomas Henzl 
---
 drivers/scsi/fnic/fnic_scsi.c | 20 +---
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index d9fd2f8415..1d3ecaee56 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -441,6 +441,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void 
(*done)(struct scsi_
unsigned long ptr;
spinlock_t *io_lock = NULL;
int io_lock_acquired = 0;
+   struct fc_rport_libfc_priv *rp;
 
if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_IO_BLOCKED)))
return SCSI_MLQUEUE_HOST_BUSY;
@@ -454,17 +455,14 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, 
void (*done)(struct scsi_
return 0;
}
 
-   if (rport) {
-   struct fc_rport_libfc_priv *rp = rport->dd_data;
-
-   if (!rp || rp->rp_state != RPORT_ST_READY) {
-   FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
-   "returning DID_NO_CONNECT for IO as rport is 
removed\n");
-   atomic64_inc(_stats->misc_stats.rport_not_ready);
-   sc->result = DID_NO_CONNECT<<16;
-   done(sc);
-   return 0;
-   }
+   rp = rport->dd_data;
+   if (!rp || rp->rp_state != RPORT_ST_READY) {
+   FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
+   "returning DID_NO_CONNECT for IO as rport is 
removed\n");
+   atomic64_inc(_stats->misc_stats.rport_not_ready);
+   sc->result = DID_NO_CONNECT<<16;
+   done(sc);
+   return 0;
}
 
if (lp->state != LPORT_ST_READY || !(lp->link_up))
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] megaraid-sas: request irqs later

2016-11-01 Thread Tomas Henzl
It is not good when an irq arrives before
driver structures are allocated.

Signed-off-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index c3efcc7255..e207410150 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -5155,11 +5155,6 @@ static int megasas_init_fw(struct megasas_instance 
*instance)
tasklet_init(>isr_tasklet, instance->instancet->tasklet,
(unsigned long)instance);
 
-   if (instance->msix_vectors ?
-   megasas_setup_irqs_msix(instance, 1) :
-   megasas_setup_irqs_ioapic(instance))
-   goto fail_setup_irqs;
-
instance->ctrl_info = kzalloc(sizeof(struct megasas_ctrl_info),
GFP_KERNEL);
if (instance->ctrl_info == NULL)
@@ -5175,6 +5170,10 @@ static int megasas_init_fw(struct megasas_instance 
*instance)
if (instance->instancet->init_adapter(instance))
goto fail_init_adapter;
 
+   if (instance->msix_vectors ?
+   megasas_setup_irqs_msix(instance, 1) :
+   megasas_setup_irqs_ioapic(instance))
+   goto fail_init_adapter;
 
instance->instancet->enable_intr(instance);
 
@@ -5314,9 +5313,8 @@ static int megasas_init_fw(struct megasas_instance 
*instance)
 
 fail_get_pd_list:
instance->instancet->disable_intr(instance);
-fail_init_adapter:
megasas_destroy_irqs(instance);
-fail_setup_irqs:
+fail_init_adapter:
if (instance->msix_vectors)
pci_disable_msix(instance->pdev);
instance->msix_vectors = 0;
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 12/14] SRP transport, scsi-mq: Wait for .queue_rq() if necessary

2016-11-01 Thread Martin K. Petersen
> "Bart" == Bart Van Assche  writes:

Bart> Ensure that if scsi-mq is enabled that
Bart> scsi_internal_device_block() waits until ongoing
Bart> shost->hostt->queuecommand() calls have finished.

Reviewed-by: Martin K. Petersen 

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 11/14] SRP transport: Move queuecommand() wait code to SCSI core

2016-11-01 Thread Martin K. Petersen
> "Bart" == Bart Van Assche  writes:

Bart> Additionally, rename srp_wait_for_queuecommand() into
Bart> scsi_wait_for_queuecommand() and add a comment about the
Bart> queuecommand() call from scsi_send_eh_cmnd().

Reviewed-by: Martin K. Petersen 

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 12/14] SRP transport, scsi-mq: Wait for .queue_rq() if necessary

2016-11-01 Thread Sagi Grimberg

and again,

Reviewed-by: Sagi Grimberg 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 13/14] nvme: Fix a race condition related to stopping queues

2016-11-01 Thread Sagi Grimberg

Reviewed-by: Sagi Grimberg 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] blk-mq: export blk_mq_map_queues

2016-11-01 Thread Jens Axboe
On Tue, Nov 01 2016, Martin K. Petersen wrote:
> > "Christoph" == Christoph Hellwig  writes:
> 
> Christoph> This will allow SCSI to have a single blk_mq_ops structure
> Christoph> that either lets the LLDD map the queues to PCIe MSIx vectors
> Christoph> or use the default.
> 
> Jens, any objection to me funneling this change through the SCSI tree?

No, that's fine, you can add my reviewed-by.

-- 
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 11/14] SRP transport: Move queuecommand() wait code to SCSI core

2016-11-01 Thread Sagi Grimberg

Again,

Reviewed-by: Sagi Grimberg 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 08/14] blk-mq: Add a kick_requeue_list argument to blk_mq_requeue_request()

2016-11-01 Thread Sagi Grimberg

Looks useful,

Reviewed-by: Sagi Grimberg 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 07/14] blk-mq: Introduce blk_mq_quiesce_queue()

2016-11-01 Thread Sagi Grimberg

Reviewed-by: Sagi Grimberg 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 06/14] blk-mq: Remove blk_mq_cancel_requeue_work()

2016-11-01 Thread Sagi Grimberg

Reviewed-by: Sagi Grimberg 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 05/14] blk-mq: Avoid that requeueing starts stopped queues

2016-11-01 Thread Sagi Grimberg

Reviewed-by: Sagi Grimberg 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] scsi: allow LLDDs to expose the queue mapping to blk-mq

2016-11-01 Thread Sagi Grimberg

Reviewed-by: Sagi Grimberg 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] blk-mq: export blk_mq_map_queues

2016-11-01 Thread Martin K. Petersen
> "Christoph" == Christoph Hellwig  writes:

Christoph> This will allow SCSI to have a single blk_mq_ops structure
Christoph> that either lets the LLDD map the queues to PCIe MSIx vectors
Christoph> or use the default.

Jens, any objection to me funneling this change through the SCSI tree?

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] scsi_dh_rdac: switch to scsi_execute_req_flags()

2016-11-01 Thread Christoph Hellwig
On Mon, Oct 31, 2016 at 06:59:28PM +0100, Hannes Reinecke wrote:
> Switch to using scsi_execute_req_flags() instead of using the
> block primitives.

__scsi_execute adds RQF_QUIET and RQF_PREEMPT to the request flags, which
would be a change in behavior.  A little analysis on why that's safe or
even desireable would be nice.  (This also applies to the other two patches
I think).

>  
>  static void release_controller(struct kref *kref)
>  static int get_lun_info(struct scsi_device *sdev, struct rdac_dh_data *h,
>   char *array_name, u8 *array_id)
>  {
> + int err = SCSI_DH_IO, i;
>   struct c8_inquiry *inqp;
>  
> + if (!scsi_get_vpd_page(sdev, 0xC8, (unsigned char *)h,
> +sizeof(struct c8_inquiry))) {

This looks completely bogus to me - h is a struct rdac_dh_data pointer,
which is an in-kernel data structure that scsi_get_vpd_page would
scramble over.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/3] scsi_dh: switch to scsi_execute_req_flags()

2016-11-01 Thread Christoph Hellwig
A little warning: scsi_execute_req_flags grew a new argument in the block
tree to be able to specify the request-only flags.  So any of these
patches would create a (mostly harmless) conflict in linux-next.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] scsi_dh_alua: Fix a reference counting bug

2016-11-01 Thread Bart Van Assche
The code at the end of alua_rtpg_work() is as follows:

scsi_device_put(sdev);
kref_put(>kref, release_port_group);

In other words, alua_rtpg_queue() must hold an sdev reference and
a pg reference before queueing rtpg work. If no rtpg work is queued
no additional references should be held when alua_rtpg_queue()
returns. If no rtpg work is queued, ensure that alua_rtpg_queue()
only gives up the sdev reference if that reference was obtained by
the same alua_rtpg_queue() call.

Signed-off-by: Bart Van Assche 
Cc: Hannes Reinecke 
Cc: Tang Junhui 
Cc: 
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index f375167..7bb2068 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -891,6 +891,7 @@ static void alua_rtpg_queue(struct alua_port_group *pg,
/* Do not queue if the worker is already running */
if (!(pg->flags & ALUA_PG_RUNNING)) {
kref_get(>kref);
+   sdev = NULL;
start_queue = 1;
}
}
@@ -902,7 +903,8 @@ static void alua_rtpg_queue(struct alua_port_group *pg,
if (start_queue &&
!queue_delayed_work(alua_wq, >rtpg_work,
msecs_to_jiffies(ALUA_RTPG_DELAY_MSECS))) {
-   scsi_device_put(sdev);
+   if (sdev)
+   scsi_device_put(sdev);
kref_put(>kref, release_port_group);
}
 }
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] blk-mq: export blk_mq_map_queues

2016-11-01 Thread Christoph Hellwig
This will allow SCSI to have a single blk_mq_ops structure that either
lets the LLDD map the queues to PCIe MSIx vectors or use the default.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Johannes Thumshirn 
---
 block/blk-mq-cpumap.c  | 1 +
 block/blk-mq.h | 1 -
 include/linux/blk-mq.h | 1 +
 3 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/blk-mq-cpumap.c b/block/blk-mq-cpumap.c
index 19b1d9c..8e61e86 100644
--- a/block/blk-mq-cpumap.c
+++ b/block/blk-mq-cpumap.c
@@ -87,6 +87,7 @@ int blk_mq_map_queues(struct blk_mq_tag_set *set)
free_cpumask_var(cpus);
return 0;
 }
+EXPORT_SYMBOL_GPL(blk_mq_map_queues);
 
 /*
  * We have no quick way of doing reverse lookups. This is only used at
diff --git a/block/blk-mq.h b/block/blk-mq.h
index e5d2524..5347f01 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -38,7 +38,6 @@ void blk_mq_disable_hotplug(void);
 /*
  * CPU -> queue mappings
  */
-int blk_mq_map_queues(struct blk_mq_tag_set *set);
 extern int blk_mq_hw_queue_to_node(unsigned int *map, unsigned int);
 
 static inline struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *q,
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 535ab2e..6c0fb25 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -237,6 +237,7 @@ void blk_mq_unfreeze_queue(struct request_queue *q);
 void blk_mq_freeze_queue_start(struct request_queue *q);
 int blk_mq_reinit_tagset(struct blk_mq_tag_set *set);
 
+int blk_mq_map_queues(struct blk_mq_tag_set *set);
 void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues);
 
 /*
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] scsi: allow LLDDs to expose the queue mapping to blk-mq

2016-11-01 Thread Christoph Hellwig
Just hand through the blk-mq map_queues method in the host template.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/scsi_lib.c  | 10 ++
 include/scsi/scsi_host.h |  8 
 2 files changed, 18 insertions(+)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 2cca9cf..f23ec24 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1990,6 +1990,15 @@ static void scsi_exit_request(void *data, struct request 
*rq,
kfree(cmd->sense_buffer);
 }
 
+static int scsi_map_queues(struct blk_mq_tag_set *set)
+{
+   struct Scsi_Host *shost = container_of(set, struct Scsi_Host, tag_set);
+
+   if (shost->hostt->map_queues)
+   return shost->hostt->map_queues(shost);
+   return blk_mq_map_queues(set);
+}
+
 static u64 scsi_calculate_bounce_limit(struct Scsi_Host *shost)
 {
struct device *host_dev;
@@ -2082,6 +2091,7 @@ static struct blk_mq_ops scsi_mq_ops = {
.timeout= scsi_timeout,
.init_request   = scsi_init_request,
.exit_request   = scsi_exit_request,
+   .map_queues = scsi_map_queues,
 };
 
 struct request_queue *scsi_mq_alloc_queue(struct scsi_device *sdev)
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 7e4cd53..36680f1 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -278,6 +278,14 @@ struct scsi_host_template {
int (* change_queue_depth)(struct scsi_device *, int);
 
/*
+* This functions lets the driver expose the queue mapping
+* to the block layer.
+*
+* Status: OPTIONAL
+*/
+   int (* map_queues)(struct Scsi_Host *shost);
+
+   /*
 * This function determines the BIOS parameters for a given
 * harddisk.  These tend to be numbers that are made up by
 * the host adapter.  Parameters:
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] smartpqi: switch to pci_alloc_irq_vectors

2016-11-01 Thread Christoph Hellwig
Which cleans up a lot of the MSI-X handling, and allows us to use the
PCI IRQ layer provided vector mapping, which we can then expose to blk-mq.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Johannes Thumshirn 
Acked-by: Don Brace 
Tested-by: Don Brace 
---
 drivers/scsi/smartpqi/smartpqi.h  |   2 -
 drivers/scsi/smartpqi/smartpqi_init.c | 102 +++---
 2 files changed, 32 insertions(+), 72 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi.h b/drivers/scsi/smartpqi/smartpqi.h
index 07b6444..b673825 100644
--- a/drivers/scsi/smartpqi/smartpqi.h
+++ b/drivers/scsi/smartpqi/smartpqi.h
@@ -929,8 +929,6 @@ struct pqi_ctrl_info {
int max_msix_vectors;
int num_msix_vectors_enabled;
int num_msix_vectors_initialized;
-   u32 msix_vectors[PQI_MAX_MSIX_VECTORS];
-   void*intr_data[PQI_MAX_MSIX_VECTORS];
int event_irq;
struct Scsi_Host *scsi_host;
 
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c 
b/drivers/scsi/smartpqi/smartpqi_init.c
index a535b26..8702d9c 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2887,19 +2888,19 @@ static irqreturn_t pqi_irq_handler(int irq, void *data)
 
 static int pqi_request_irqs(struct pqi_ctrl_info *ctrl_info)
 {
+   struct pci_dev *pdev = ctrl_info->pci_dev;
int i;
int rc;
 
-   ctrl_info->event_irq = ctrl_info->msix_vectors[0];
+   ctrl_info->event_irq = pci_irq_vector(pdev, 0);
 
for (i = 0; i < ctrl_info->num_msix_vectors_enabled; i++) {
-   rc = request_irq(ctrl_info->msix_vectors[i],
-   pqi_irq_handler, 0,
-   DRIVER_NAME_SHORT, ctrl_info->intr_data[i]);
+   rc = request_irq(pci_irq_vector(pdev, i), pqi_irq_handler, 0,
+   DRIVER_NAME_SHORT, _info->queue_groups[i]);
if (rc) {
-   dev_err(_info->pci_dev->dev,
+   dev_err(>dev,
"irq %u init failed with error %d\n",
-   ctrl_info->msix_vectors[i], rc);
+   pci_irq_vector(pdev, i), rc);
return rc;
}
ctrl_info->num_msix_vectors_initialized++;
@@ -2908,72 +2909,23 @@ static int pqi_request_irqs(struct pqi_ctrl_info 
*ctrl_info)
return 0;
 }
 
-static void pqi_free_irqs(struct pqi_ctrl_info *ctrl_info)
-{
-   int i;
-
-   for (i = 0; i < ctrl_info->num_msix_vectors_initialized; i++)
-   free_irq(ctrl_info->msix_vectors[i],
-   ctrl_info->intr_data[i]);
-}
-
 static int pqi_enable_msix_interrupts(struct pqi_ctrl_info *ctrl_info)
 {
-   unsigned int i;
-   int max_vectors;
-   int num_vectors_enabled;
-   struct msix_entry msix_entries[PQI_MAX_MSIX_VECTORS];
-
-   max_vectors = ctrl_info->num_queue_groups;
-
-   for (i = 0; i < max_vectors; i++)
-   msix_entries[i].entry = i;
-
-   num_vectors_enabled = pci_enable_msix_range(ctrl_info->pci_dev,
-   msix_entries, PQI_MIN_MSIX_VECTORS, max_vectors);
+   int ret;
 
-   if (num_vectors_enabled < 0) {
+   ret = pci_alloc_irq_vectors(ctrl_info->pci_dev,
+   PQI_MIN_MSIX_VECTORS, ctrl_info->num_queue_groups,
+   PCI_IRQ_MSIX | PCI_IRQ_AFFINITY);
+   if (ret < 0) {
dev_err(_info->pci_dev->dev,
-   "MSI-X init failed with error %d\n",
-   num_vectors_enabled);
-   return num_vectors_enabled;
-   }
-
-   ctrl_info->num_msix_vectors_enabled = num_vectors_enabled;
-   for (i = 0; i < num_vectors_enabled; i++) {
-   ctrl_info->msix_vectors[i] = msix_entries[i].vector;
-   ctrl_info->intr_data[i] = _info->queue_groups[i];
+   "MSI-X init failed with error %d\n", ret);
+   return ret;
}
 
+   ctrl_info->num_msix_vectors_enabled = ret;
return 0;
 }
 
-static void pqi_irq_set_affinity_hint(struct pqi_ctrl_info *ctrl_info)
-{
-   int i;
-   int rc;
-   int cpu;
-
-   cpu = cpumask_first(cpu_online_mask);
-   for (i = 0; i < ctrl_info->num_msix_vectors_initialized; i++) {
-   rc = irq_set_affinity_hint(ctrl_info->msix_vectors[i],
-   get_cpu_mask(cpu));
-   if (rc)
-   dev_err(_info->pci_dev->dev,
-   "error %d setting affinity hint for irq vector 
%u\n",
-   rc, ctrl_info->msix_vectors[i]);
-   cpu = 

expose queue the queue mapping for SCSI drivers V2

2016-11-01 Thread Christoph Hellwig
In 4.9 I've added support in the interrupt layer to automatically
assign the interrupt affinity at interrupt allocation time, and
expose that information to blk-mq.

This series extents that so that SCSI driver can pass on the information
as well.  The SCSI part is fairly trivial, although we need to also
export the default queue mapping function in blk-mq to keep things simple.

I've also converted over the smartpqi driver as an example as it's the
easiest of the multiqueue SCSI drivers to convert.

Changes since V1:
 - move the EXPORT_SYMBOL of blk_mq_map_queues to the right patch
 - added Reviewed-by, Acked-by and Tested-by tags
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 0/4] scsi: ufs: bug fixes patch series #2

2016-11-01 Thread Martin K. Petersen
> "Subhash" == Subhash Jadavani  writes:

Subhash> This patch series contains not reviewed changes from patch
Subhash> series #1 ([PATCH v1 00/11] scsi: ufs: bug fixes patch series
Subhash> #1).  These bug fixes patch series are intended to bring in
Subhash> important bug fixes required for UFS stability and
Subhash> functionality.

Applied to 4.10/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] vmw_pvscsi: return SUCCESS for successful command aborts

2016-11-01 Thread Martin K. Petersen
> "Jim" == Jim Gill  writes:

Jim> VMware prefers to update the module's version number as the driver
Jim> is updated. Would you please update the
Jim> PVSCSI_DRIVER_VERSION_STRING in vmx_pvscsi.h from 1.0.6.0-k to
Jim> 1.0.7.0-k?  Otherwise the patch looks fine to us.

Applied to 4.9/scsi-fixes with a bumped version number.

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 00/12] ufs-qcom: phy/hcd: Clean up qcom-ufs phy and ufs-qcom hcd

2016-11-01 Thread Martin K. Petersen
> "Vivek" == Vivek Gautam  writes:

Vivek> These patches cleanup the ufs phy driver to an extent.
Vivek> Subsequent patches will target to clean the phy_init() of these
Vivek> qcom-ufs phy drivers in order to get rid of a number of exported
Vivek> APIs that phy drivers expose for ufs-qcom hcd driver to use.

Vivek: Please address the comments to patch 4.

Subhash: Please review patches 5 and 9.

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH RESEND] mpt3sas: Fix for block device of raid exists even after deleting raid disk

2016-11-01 Thread Martin K. Petersen
> "Sreekanth" == Sreekanth Reddy  writes:

Sreekanth> While merging mpt3sas & mpt2sas code, we posted below patch
Sreekanth> for WarpDrive support,

[...]

Sreekanth> Due to above hunk, we are not initializing raid_device's
Sreekanth> starget for raid volumes, and so during raid disk deletion
Sreekanth> driver is not calling scsi_remove_target() API as driver
Sreekanth> observes starget field of raid_device's structure as NULL.

Applied to 4.9/scsi-fixes.

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi_dh_alua: fix wrong scsi_device_put() in alua_rtpg_queue()

2016-11-01 Thread Martin K. Petersen
> "Bart" == Bart Van Assche  writes:

Bart,

Bart> Personally I prefer the patch below because that patch does not
Bart> introduce a new variable. This is a patch I started testing four
Bart> weeks ago and it has survived all my ALUA tests so far. Please
Bart> note that I do not know whether my tests hit the !(pg->flags &
Bart> ALUA_PG_RUNNING) code path.

Please submit a real patch with a suitable description for this.

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi_dh_alua: fix missing kref_put() in alua_rtpg_work()

2016-11-01 Thread Martin K. Petersen
> "tang" == tang junhui  writes:

tang> Reference count of pg leaks in alua_rtpg_work() since kref_put()
tang> is not called to decrease the reference count of pg when the
tang> condition
tang> pg->rtpg_sdev==NULL satisfied (actually it is easy to satisfy), it
tang> would cause memory of pg leakage.

Applied to 4.9/scsi-fixes.

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: esp_scsi QTAG in FAS216

2016-11-01 Thread Finn Thain

On Tue, 1 Nov 2016, Michael Schmitz wrote:

> Hi Finn,
> 
> Am 01.11.2016 um 12:47 schrieb Finn Thain:
> > 
> > On Tue, 1 Nov 2016, Michael Schmitz wrote:
> > 
> >>> I had tried to set that bit in zorro_esp_slave_configure but had not 
> >>> done a proper job of it - I'd only set esp->config3 and forgot to 
> >>> set tp->esp_config3. Time to retest this ...
> >>
> >> I don't think it's quite that easy - the ESP_CONFIG3_TENB bit needs 
> >> to be set for all targets if at least one SCSI-2 target is on the bus 
> >> and we allow dosconnecting, no?
> > 
> > I think ESP_CONFIG3_TENB is for FAS100A and FASHME. The bug here is on 
> > ESP236 and FAS236, so ESP_CONFIG3_TBMS would be the relevant bit.
> 
> I stand corrected. Err... confused.
> 
> When setting ESP_CONFIG3_TBMS, should we set ESP_CONFIG3_GTM as well?

I think that depends entirely on the target. But it isn't relevant to the 
bug at hand AFAICS.

-- 

> 
> > The bit gets set when ESP_CONFIG2_SCSI2ENAB gets set (as in David's 
> > patch) so we then need to avoid clobbering it, since ESP_CONFIG3_TBMS 
> > == ESP_CONFIG3_EWIDE. I think we have to test for HME to avoid this 
> > clash.
> 
> I'd want to set these bits for ESP236 and FAS236 only, so no clash with 
> HME. As you found out, ESP_CONFIG3_TBMS aka ESP_CONFIG3_EWIDE gets 
> clobbered on bus reset cleanup unconditionally.
> 
> Cheers,
> 
>   Michael
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: esp_scsi QTAG in FAS216

2016-11-01 Thread Michael Schmitz
Hi Finn,

Am 01.11.2016 um 12:47 schrieb Finn Thain:
> 
> On Tue, 1 Nov 2016, Michael Schmitz wrote:
> 
>>> I had tried to set that bit in zorro_esp_slave_configure but had not 
>>> done a proper job of it - I'd only set esp->config3 and forgot to set 
>>> tp->esp_config3. Time to retest this ...
>>
>> I don't think it's quite that easy - the ESP_CONFIG3_TENB bit needs to 
>> be set for all targets if at least one SCSI-2 target is on the bus and 
>> we allow dosconnecting, no?
> 
> I think ESP_CONFIG3_TENB is for FAS100A and FASHME. The bug here is on 
> ESP236 and FAS236, so ESP_CONFIG3_TBMS would be the relevant bit.

I stand corrected. Err... confused.

When setting ESP_CONFIG3_TBMS, should we set ESP_CONFIG3_GTM as well?

> The bit gets set when ESP_CONFIG2_SCSI2ENAB gets set (as in David's 
> patch) so we then need to avoid clobbering it, since ESP_CONFIG3_TBMS == 
> ESP_CONFIG3_EWIDE. I think we have to test for HME to avoid this clash.

I'd want to set these bits for ESP236 and FAS236 only, so no clash with
HME. As you found out, ESP_CONFIG3_TBMS aka ESP_CONFIG3_EWIDE gets
clobbered on bus reset cleanup unconditionally.

Cheers,

Michael

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html