Re: [PATCH 01/10] qla2xxx: Clean up qla24xx_iidma()

2013-06-12 Thread Saurav Kashyap


>On Wed, 2013-06-12 at 08:05 +, Saurav Kashyap wrote:
>> Hi Bart,
>> Missing msg ids needs to be updated in qla_dbg.c file. Here is an
>>updated
>> patch
>
>OK, so since you modified the first patch in the series, you need to be
>the one who sends it all to me (with proper signoffs).

 Sure, I will send all the patches in next scsi-misc submission.

Thanks,
~Saurav

>
>Thanks,
>
>James
>
>
>

<>

Re: [PATCH 2/2] scsi: ufs: Set fDeviceInit flag to initiate device initialization

2013-06-12 Thread Sujit Reddy Thumma

On 6/12/2013 11:04 AM, Santosh Y wrote:


  /**
+ *  ufshcd_query_request() - API for issuing query request to the device.
+ *  @hba: ufs driver context
+ *  @query: params for query request
+ *  @descriptor: buffer for sending/receiving descriptor
+ *  @retries: number of times to try executing the command
+ *
+ *   All necessary fields for issuing a query and receiving its response
+ *   are stored in the UFS hba struct. We can use this method since we know
+ *   there is only one active query request or any internal command at all
+ *   times.
+ */
+static int ufshcd_send_query_request(struct ufs_hba *hba,
+   struct ufs_query_req *query,
+   u8 *descriptor,
+   struct ufs_query_res *response)
+{
+   int ret;
+
+   BUG_ON(!hba);
+   if (!query || !response) {
+   dev_err(hba->dev,
+   "%s: NULL pointer query = %p, response = %p\n",
+   __func__, query, response);
+   return -EINVAL;
+   }
+
+   mutex_lock(&hba->i_cmd.dev_cmd_lock);
+   hba->i_cmd.query.request = query;
+   hba->i_cmd.query.response = response;
+   hba->i_cmd.query.descriptor = descriptor;
+
+   ret = ufshcd_exec_internal_cmd(hba, DEV_CMD_TYPE_QUERY,
+   QUERY_REQ_TIMEOUT);


Can this be generic, as external query commands might also use it?


External query commands can call ufshcd_send_query_request() directly, 
without going into hassle of taking mutex lock and filling internal cmd 
structure.





+
+   hba->i_cmd.query.request = NULL;
+   hba->i_cmd.query.response = NULL;
+   hba->i_cmd.query.descriptor = NULL;
+   mutex_unlock(&hba->i_cmd.dev_cmd_lock);
+
+   return ret;
+}
+
+/**





--
Regards,
Sujit
--
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/2] scsi: ufs: Add support for sending NOP OUT UPIU

2013-06-12 Thread Sujit Reddy Thumma

On 6/12/2013 11:00 AM, Santosh Y wrote:

+/*
+ * ufshcd_wait_for_register - wait for register value to change
+ * @hba - per-adapter interface
+ * @reg - mmio register offset
+ * @mask - mask to apply to read register value
+ * @val - wait condition
+ * @interval_us - polling interval in microsecs
+ * @timeout_ms - timeout in millisecs
+ *
+ * Returns final register value after iteration
+ */
+static u32 ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask,
+   u32 val, unsigned long interval_us, unsigned long timeout_ms)
+{
+   u32 tmp;
+   ktime_t start;
+   unsigned long diff;
+
+   tmp = ufshcd_readl(hba, reg);
+
+   start = ktime_get();
+   while ((tmp & mask) == val) {



...as now I notice it, 'val' is the wait condition and the loop
continues if the wait condition is met. I feel it's a bit confusing.
Wouldn't something like (x != wait_condition) be appropriate?


Makes sense.




+   /* wakeup within 50us of expiry */
+   usleep_range(interval_us, interval_us + 50);
+   tmp = ufshcd_readl(hba, reg);
+   diff = ktime_to_ms(ktime_sub(ktime_get(), start));
+   if (diff > timeout_ms) {
+   tmp = ufshcd_readl(hba, reg);


Why this extra read? The register value might have changed during the
execution of 2 previous statements, is that the assumption?


Yes, if there is a preemption between the last register read and the 
diff calculation and the CPU comes back after long time, it can happen 
that diff is greater than timeout and we enter the if condition. So, it 
is better to read the value after a timeout and return to the caller.





+   break;
+   }
+   }
+
+   return tmp;
+}
+
  /**
   * ufshcd_get_intr_mask - Get the interrupt bit mask
   * @hba - Pointer to adapter instance
@@ -223,18 +267,13 @@ static inline void ufshcd_free_hba_memory(struct ufs_hba 
*hba)
  }

  /**
- * ufshcd_is_valid_req_rsp - checks if controller TR response is valid
+ * ufshcd_get_req_rsp - returns the TR response
   * @ucd_rsp_ptr: pointer to response UPIU
- *
- * This function checks the response UPIU for valid transaction type in
- * response field
- * Returns 0 on success, non-zero on failure
   */
  static inline int
-ufshcd_is_valid_req_rsp(struct utp_upiu_rsp *ucd_rsp_ptr)
+ufshcd_get_req_rsp(struct utp_upiu_rsp *ucd_rsp_ptr)
  {
-   return ((be32_to_cpu(ucd_rsp_ptr->header.dword_0) >> 24) ==
-UPIU_TRANSACTION_RESPONSE) ? 0 : DID_ERROR << 16;
+   return be32_to_cpu(ucd_rsp_ptr->header.dword_0) >> 24;
  }

  /**
@@ -331,9 +370,9 @@ static inline void ufshcd_copy_sense_data(struct ufshcd_lrb 
*lrbp)
  {
 int len;
 if (lrbp->sense_buffer) {
-   len = be16_to_cpu(lrbp->ucd_rsp_ptr->sense_data_len);
+   len = be16_to_cpu(lrbp->ucd_rsp_ptr->sc.sense_data_len);
 memcpy(lrbp->sense_buffer,
-   lrbp->ucd_rsp_ptr->sense_data,
+   lrbp->ucd_rsp_ptr->sc.sense_data,
 min_t(int, len, SCSI_SENSE_BUFFERSIZE));
 }
  }
@@ -551,76 +590,128 @@ static void ufshcd_disable_intr(struct ufs_hba *hba, u32 
intrs)
  }

  /**
+ * ufshcd_prepare_req_desc() - Fills the requests header
+ * descriptor according to request
+ * @lrbp: pointer to local reference block
+ * @upiu_flags: flags required in the header
+ * @cmd_dir: requests data direction
+ */
+static void ufshcd_prepare_req_desc(struct ufshcd_lrb *lrbp, u32 *upiu_flags,
+   enum dma_data_direction cmd_dir)
+{
+   struct utp_transfer_req_desc *req_desc = lrbp->utr_descriptor_ptr;
+   u32 data_direction;
+   u32 dword_0;
+
+   if (cmd_dir == DMA_FROM_DEVICE) {
+   data_direction = UTP_DEVICE_TO_HOST;
+   *upiu_flags = UPIU_CMD_FLAGS_READ;
+   } else if (cmd_dir == DMA_TO_DEVICE) {
+   data_direction = UTP_HOST_TO_DEVICE;
+   *upiu_flags = UPIU_CMD_FLAGS_WRITE;
+   } else {
+   data_direction = UTP_NO_DATA_TRANSFER;
+   *upiu_flags = UPIU_CMD_FLAGS_NONE;
+   }
+
+   dword_0 = data_direction | (lrbp->command_type
+   << UPIU_COMMAND_TYPE_OFFSET);
+   if (lrbp->intr_cmd)
+   dword_0 |= UTP_REQ_DESC_INT_CMD;
+
+   /* Transfer request descriptor header fields */
+   req_desc->header.dword_0 = cpu_to_le32(dword_0);
+
+   /*
+* assigning invalid value for command status. Controller
+* updates OCS on command completion, with the command
+* status
+*/
+   req_desc->header.dword_2 =
+   cpu_to_le32(OCS_INVALID_COMMAND_STATUS);
+}
+
+/**
+ * ufshcd_prepare_utp_scsi_cmd_upiu() - fills the utp_transfer_req_desc,
+ * for scsi commands
+ * @lrbp - local reference block pointer
+ * @upiu_flags - flags
+ */
+static
+void ufshcd_prepare_utp_scsi_cmd_upiu(struct ufshcd_lrb *lrbp,

Re: [scsi] WARNING: at fs/sysfs/dir.c:530 sysfs_add_one()

2013-06-12 Thread Fengguang Wu
On Wed, Jun 12, 2013 at 07:34:43PM -0700, James Bottomley wrote:
> On Thu, 2013-06-13 at 09:30 +0800, Fengguang Wu wrote:
> > Greetings,
> > 
> > I got the below dmesg and the first bad commit is
> > 
> > commit a256ba092ec57213f96059d41ac5473ff92f5e7c
> > Author: Nicholas Bellinger 
> > Date:   Sat May 18 02:40:43 2013 -0700
> > 
> > scsi: Split scsi_dispatch_cmd into __scsi_dispatch_cmd setup
> > 
> > Signed-off-by: Nicholas Bellinger 
> 
> You may be evaluating a bogus branch because no such commit has darkened
> the SCSI list, so it obviously can't be on upstream track.

Yeah, sorry I should probably not CC linux-scsi.

The bug is still in a private tree:

git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git  scsi-mq

Thanks,
Fengguang
--
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: [scsi] WARNING: at fs/sysfs/dir.c:530 sysfs_add_one()

2013-06-12 Thread James Bottomley
On Thu, 2013-06-13 at 09:30 +0800, Fengguang Wu wrote:
> Greetings,
> 
> I got the below dmesg and the first bad commit is
> 
> commit a256ba092ec57213f96059d41ac5473ff92f5e7c
> Author: Nicholas Bellinger 
> Date:   Sat May 18 02:40:43 2013 -0700
> 
> scsi: Split scsi_dispatch_cmd into __scsi_dispatch_cmd setup
> 
> Signed-off-by: Nicholas Bellinger 

You may be evaluating a bogus branch because no such commit has darkened
the SCSI list, so it obviously can't be on upstream track.

James


--
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 4/9] virtio_scsi: Enable new EH timeout handler

2013-06-12 Thread Asias He
On Mon, Jun 10, 2013 at 09:40:53AM +0200, Hannes Reinecke wrote:
> Signed-off-by: Hannes Reinecke 

Reviewed-by: Asias He 

> ---
>  drivers/scsi/virtio_scsi.c | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index 2168258..1efd219 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -654,6 +654,11 @@ static int virtscsi_abort(struct scsi_cmnd *sc)
>   return virtscsi_tmf(vscsi, cmd);
>  }
>  
> +static enum blk_eh_timer_return virtscsi_timedout(struct scsi_cmnd *scmd)
> +{
> + return scsi_abort_command(scmd);
> +}
> +
>  static int virtscsi_target_alloc(struct scsi_target *starget)
>  {
>   struct virtio_scsi_target_state *tgt =
> @@ -683,6 +688,7 @@ static struct scsi_host_template 
> virtscsi_host_template_single = {
>   .queuecommand = virtscsi_queuecommand_single,
>   .eh_abort_handler = virtscsi_abort,
>   .eh_device_reset_handler = virtscsi_device_reset,
> + .eh_timed_out = virtscsi_timedout,
>  
>   .can_queue = 1024,
>   .dma_boundary = UINT_MAX,
> @@ -699,6 +705,7 @@ static struct scsi_host_template 
> virtscsi_host_template_multi = {
>   .queuecommand = virtscsi_queuecommand_multi,
>   .eh_abort_handler = virtscsi_abort,
>   .eh_device_reset_handler = virtscsi_device_reset,
> + .eh_timed_out = virtscsi_timedout,
>  
>   .can_queue = 1024,
>   .dma_boundary = UINT_MAX,
> -- 
> 1.7.12.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

-- 
Asias
--
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 5/9] virtio-scsi: Implement TMF timeout

2013-06-12 Thread Asias He
On Mon, Jun 10, 2013 at 09:40:54AM +0200, Hannes Reinecke wrote:
> Any TMF might be take longer as expected, or not return at all.
> So we need to use 'wait_for_completion_timeout' when sending
> a TMF to protect against these cases.
> 
> Cc: Paolo Bonzini 
> Signed-off-by: Hannes Reinecke 

Reviewed-by: Asias He 

> ---
>  drivers/scsi/virtio_scsi.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index 1efd219..abfc684 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -30,6 +30,7 @@
>  #define VIRTIO_SCSI_MEMPOOL_SZ 64
>  #define VIRTIO_SCSI_EVENT_LEN 8
>  #define VIRTIO_SCSI_VQ_BASE 2
> +#define VIRTIO_SCSI_TMF_TIMEOUT 30
>  
>  /* Command queue element */
>  struct virtio_scsi_cmd {
> @@ -597,8 +598,10 @@ static int virtscsi_tmf(struct virtio_scsi *vscsi, 
> struct virtio_scsi_cmd *cmd)
> GFP_NOIO) < 0)
>   goto out;
>  
> - wait_for_completion(&comp);
> - if (cmd->resp.tmf.response == VIRTIO_SCSI_S_OK ||
> + if (wait_for_completion_timeout(&comp,
> + VIRTIO_SCSI_TMF_TIMEOUT * HZ) == 0)
> + ret = FAILED;
> + else if (cmd->resp.tmf.response == VIRTIO_SCSI_S_OK ||
>   cmd->resp.tmf.response == VIRTIO_SCSI_S_FUNCTION_SUCCEEDED)
>   ret = SUCCESS;
>  
> -- 
> 1.7.12.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

-- 
Asias
--
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: WARNING: at drivers/scsi/scsi_lib.c:1196 scsi_setup_fs_cmnd during RAID5 startup.

2013-06-12 Thread Jens Axboe
On Wed, Jun 12 2013, Dave Jones wrote:
> On Wed, Jun 12, 2013 at 03:43:46PM -0400, Dave Jones wrote:
>  > 3.10 seems to have a problem with dirty RAID5 sets.
>  > 
>  > I've got a machine that panics on boot during RAID5 activation.
>  > After switching the BUG_ON to a WARN_ON, I was able to get this over 
> serial console..
>  > 
>  > md/raid:md0: not clean -- starting background reconstruction
>  > md/raid:md0: device sdd1 operational as raid disk 2
>  > md/raid:md0: device sdc1 operational as raid disk 1
>  > md/raid:md0: device sdb1 operational as raid disk 0
>  > md/raid:md0: allocated 3300kB
>  > md/raid:md0: raid level 5 active with 3 out of 3 devices, algorithm 2
>  > md0: detected capacity change from 0 to 499847790592
>  > md: resync of RAID array md0
>  > md: minimum _guaranteed_  speed: 1000 KB/sec/disk.
>  > md: using maximum available idle IO bandwidth (but not more than 20 
> KB/sec) for resync.
>  > md: using 128k window, over a total of 244066304k.
>  > md: resuming resync of md0 from checkpoint.
>  > WARNING: at drivers/scsi/scsi_lib.c:1196 scsi_setup_fs_cmnd+0xa3/0xb0()
> 
> https://lkml.org/lkml/2013/5/19/75
> 
> I think my favorite part of this month old thread is..
> 
> "in that case we could have waited for a long time"
> 
> Jens?

Sorry, travel ended up getting in the way. Will ship it out today.

-- 
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: WARNING: at drivers/scsi/scsi_lib.c:1196 scsi_setup_fs_cmnd during RAID5 startup.

2013-06-12 Thread Dave Jones
On Wed, Jun 12, 2013 at 03:43:46PM -0400, Dave Jones wrote:
 > 3.10 seems to have a problem with dirty RAID5 sets.
 > 
 > I've got a machine that panics on boot during RAID5 activation.
 > After switching the BUG_ON to a WARN_ON, I was able to get this over serial 
 > console..
 > 
 > md/raid:md0: not clean -- starting background reconstruction
 > md/raid:md0: device sdd1 operational as raid disk 2
 > md/raid:md0: device sdc1 operational as raid disk 1
 > md/raid:md0: device sdb1 operational as raid disk 0
 > md/raid:md0: allocated 3300kB
 > md/raid:md0: raid level 5 active with 3 out of 3 devices, algorithm 2
 > md0: detected capacity change from 0 to 499847790592
 > md: resync of RAID array md0
 > md: minimum _guaranteed_  speed: 1000 KB/sec/disk.
 > md: using maximum available idle IO bandwidth (but not more than 20 
 > KB/sec) for resync.
 > md: using 128k window, over a total of 244066304k.
 > md: resuming resync of md0 from checkpoint.
 > WARNING: at drivers/scsi/scsi_lib.c:1196 scsi_setup_fs_cmnd+0xa3/0xb0()

https://lkml.org/lkml/2013/5/19/75

I think my favorite part of this month old thread is..

"in that case we could have waited for a long time"

Jens?

Dave

--
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: WARNING: at drivers/scsi/scsi_lib.c:1196 scsi_setup_fs_cmnd during RAID5 startup.

2013-06-12 Thread Ilia Mirkin
On Wed, Jun 12, 2013 at 3:43 PM, Dave Jones  wrote:
> 3.10 seems to have a problem with dirty RAID5 sets.
>
> I've got a machine that panics on boot during RAID5 activation.
> After switching the BUG_ON to a WARN_ON, I was able to get this over serial 
> console..
>
> md/raid:md0: not clean -- starting background reconstruction
> md/raid:md0: device sdd1 operational as raid disk 2
> md/raid:md0: device sdc1 operational as raid disk 1
> md/raid:md0: device sdb1 operational as raid disk 0
> md/raid:md0: allocated 3300kB
> md/raid:md0: raid level 5 active with 3 out of 3 devices, algorithm 2
> md0: detected capacity change from 0 to 499847790592
> md: resync of RAID array md0
> md: minimum _guaranteed_  speed: 1000 KB/sec/disk.
> md: using maximum available idle IO bandwidth (but not more than 20 
> KB/sec) for resync.
> md: using 128k window, over a total of 244066304k.
> md: resuming resync of md0 from checkpoint.
> WARNING: at drivers/scsi/scsi_lib.c:1196 scsi_setup_fs_cmnd+0xa3/0xb0()
> Modules linked in: raid456 async_raid6_recov async_memcpy async_pq async_xor 
> async_tx kvm_amd xor kvm snd_hda_codec_realtek raid6_pq snd_hda_intel 
> snd_hda_codec btusb microcode snd_pcm bluetooth edac_core pcspkr serio_raw 
> snd_page_alloc snd_timer snd soundcore rfkill r8169 mii sr_mod cdrom 
> pata_atiixp radeon backlight drm_kms_helper ttm
> CPU: 1 PID: 160 Comm: kworker/1:1H Not tainted 3.10.0-rc5+ #2
> Hardware name: Gigabyte Technology Co., Ltd. GA-MA78GM-S2H/GA-MA78GM-S2H, 
> BIOS F12a 04/23/2010
> Workqueue: kblockd blk_delay_work
>  81a4499d 8801225f5bb8 816aeb63 8801225f5bf0
>  810432b0 880123039148 8801233e8b00 8801225f5fd8
>  880123039148 880123071290 8801225f5c00 8104339a
> Call Trace:
>  [] dump_stack+0x19/0x1b
>  [] warn_slowpath_common+0x70/0xa0
>  [] warn_slowpath_null+0x1a/0x20
>  [] scsi_setup_fs_cmnd+0xa3/0xb0
>  [] sd_prep_fn+0x330/0xf60
>  [] blk_peek_request+0x13c/0x320
>  [] scsi_request_fn+0x52/0x540
>  [] ? blk_delay_work+0x19/0x40
>  [] __blk_run_queue+0x32/0x40
>  [] blk_delay_work+0x25/0x40
>  [] process_one_work+0x211/0x6f0
>  [] ? process_one_work+0x1a5/0x6f0
>  [] worker_thread+0x11c/0x390
>  [] ? process_one_work+0x6f0/0x6f0
>  [] kthread+0xed/0x100
>  [] ? insert_kthread_work+0x80/0x80
>  [] ret_from_fork+0x7c/0xb0
>  [] ? insert_kthread_work+0x80/0x80
> ---[ end trace 22d5bd5ee9fceb9e ]---
>
>
> 3.9 boots fine, and puts it into recovery mode..
>
> $ cat /proc/mdstat
> Personalities : [raid6] [raid5] [raid4]
> md0 : active raid5 sdd1[2] sdb1[0] sdc1[1]
>   488132608 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]
>   [>]  resync =  0.7% (1762712/244066304) 
> finish=73.3min speed=55084K/sec
>
> unused devices: 
>

I had the same problem... I think you're looking for this patch:
https://lkml.org/lkml/2013/5/19/75

  -ilia
--
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


WARNING: at drivers/scsi/scsi_lib.c:1196 scsi_setup_fs_cmnd during RAID5 startup.

2013-06-12 Thread Dave Jones
3.10 seems to have a problem with dirty RAID5 sets.

I've got a machine that panics on boot during RAID5 activation.
After switching the BUG_ON to a WARN_ON, I was able to get this over serial 
console..

md/raid:md0: not clean -- starting background reconstruction
md/raid:md0: device sdd1 operational as raid disk 2
md/raid:md0: device sdc1 operational as raid disk 1
md/raid:md0: device sdb1 operational as raid disk 0
md/raid:md0: allocated 3300kB
md/raid:md0: raid level 5 active with 3 out of 3 devices, algorithm 2
md0: detected capacity change from 0 to 499847790592
md: resync of RAID array md0
md: minimum _guaranteed_  speed: 1000 KB/sec/disk.
md: using maximum available idle IO bandwidth (but not more than 20 KB/sec) 
for resync.
md: using 128k window, over a total of 244066304k.
md: resuming resync of md0 from checkpoint.
WARNING: at drivers/scsi/scsi_lib.c:1196 scsi_setup_fs_cmnd+0xa3/0xb0()
Modules linked in: raid456 async_raid6_recov async_memcpy async_pq async_xor 
async_tx kvm_amd xor kvm snd_hda_codec_realtek raid6_pq snd_hda_intel 
snd_hda_codec btusb microcode snd_pcm bluetooth edac_core pcspkr serio_raw 
snd_page_alloc snd_timer snd soundcore rfkill r8169 mii sr_mod cdrom 
pata_atiixp radeon backlight drm_kms_helper ttm
CPU: 1 PID: 160 Comm: kworker/1:1H Not tainted 3.10.0-rc5+ #2
Hardware name: Gigabyte Technology Co., Ltd. GA-MA78GM-S2H/GA-MA78GM-S2H, BIOS 
F12a 04/23/2010
Workqueue: kblockd blk_delay_work
 81a4499d 8801225f5bb8 816aeb63 8801225f5bf0
 810432b0 880123039148 8801233e8b00 8801225f5fd8
 880123039148 880123071290 8801225f5c00 8104339a
Call Trace:
 [] dump_stack+0x19/0x1b
 [] warn_slowpath_common+0x70/0xa0
 [] warn_slowpath_null+0x1a/0x20
 [] scsi_setup_fs_cmnd+0xa3/0xb0
 [] sd_prep_fn+0x330/0xf60
 [] blk_peek_request+0x13c/0x320
 [] scsi_request_fn+0x52/0x540
 [] ? blk_delay_work+0x19/0x40
 [] __blk_run_queue+0x32/0x40
 [] blk_delay_work+0x25/0x40
 [] process_one_work+0x211/0x6f0
 [] ? process_one_work+0x1a5/0x6f0
 [] worker_thread+0x11c/0x390
 [] ? process_one_work+0x6f0/0x6f0
 [] kthread+0xed/0x100
 [] ? insert_kthread_work+0x80/0x80
 [] ret_from_fork+0x7c/0xb0
 [] ? insert_kthread_work+0x80/0x80
---[ end trace 22d5bd5ee9fceb9e ]---


3.9 boots fine, and puts it into recovery mode..

$ cat /proc/mdstat 
Personalities : [raid6] [raid5] [raid4] 
md0 : active raid5 sdd1[2] sdb1[0] sdc1[1]
  488132608 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]
  [>]  resync =  0.7% (1762712/244066304) 
finish=73.3min speed=55084K/sec
  
unused devices: 


--
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: Check if the device support WRITE_SAME_10

2013-06-12 Thread Bernd Schubert

On 06/07/2013 04:15 AM, Martin K. Petersen wrote:

"Bernd" == Bernd Schubert  writes:



max_t(unsigned long, max, SD_MAX_WS10_BLOCKS);


Bernd> Max? Not min_t()?

Brain fart. Updated patch with a few other adjustments.

I have tested this on a couple of JBODs with a mishmash of SATA and SAS
drives, including a few specimens that report MAX WRITE SAME BLOCKS.



Thanks for the update!

I'm far too long at work again, but I managed to test it now and it 
works fine for the ancient areca controller (ARC-1260) of this test-lab. 
So you may add


Tested-by: Bernd Schubert 

and

Reviewed-by: Bernd Schubert 

(although the latter probably does not count much for linux-scsi).


Cheers,
Bernd
--
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 01/10] qla2xxx: Clean up qla24xx_iidma()

2013-06-12 Thread James Bottomley
On Wed, 2013-06-12 at 08:05 +, Saurav Kashyap wrote:
> Hi Bart,
> Missing msg ids needs to be updated in qla_dbg.c file. Here is an updated
> patch

OK, so since you modified the first patch in the series, you need to be
the one who sends it all to me (with proper signoffs).

Thanks,

James


--
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 5/9] virtio-scsi: Implement TMF timeout

2013-06-12 Thread Paolo Bonzini
Il 10/06/2013 03:40, Hannes Reinecke ha scritto:
> Any TMF might be take longer as expected, or not return at all.
> So we need to use 'wait_for_completion_timeout' when sending
> a TMF to protect against these cases.
> 
> Cc: Paolo Bonzini 
> Signed-off-by: Hannes Reinecke 
> ---
>  drivers/scsi/virtio_scsi.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index 1efd219..abfc684 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -30,6 +30,7 @@
>  #define VIRTIO_SCSI_MEMPOOL_SZ 64
>  #define VIRTIO_SCSI_EVENT_LEN 8
>  #define VIRTIO_SCSI_VQ_BASE 2
> +#define VIRTIO_SCSI_TMF_TIMEOUT 30
>  
>  /* Command queue element */
>  struct virtio_scsi_cmd {
> @@ -597,8 +598,10 @@ static int virtscsi_tmf(struct virtio_scsi *vscsi, 
> struct virtio_scsi_cmd *cmd)
> GFP_NOIO) < 0)
>   goto out;
>  
> - wait_for_completion(&comp);
> - if (cmd->resp.tmf.response == VIRTIO_SCSI_S_OK ||
> + if (wait_for_completion_timeout(&comp,
> + VIRTIO_SCSI_TMF_TIMEOUT * HZ) == 0)
> + ret = FAILED;
> + else if (cmd->resp.tmf.response == VIRTIO_SCSI_S_OK ||
>   cmd->resp.tmf.response == VIRTIO_SCSI_S_FUNCTION_SUCCEEDED)
>   ret = SUCCESS;
>  
> 


Acked-by: Paolo Bonzini 


--
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 4/9] virtio_scsi: Enable new EH timeout handler

2013-06-12 Thread Paolo Bonzini
Il 10/06/2013 03:40, Hannes Reinecke ha scritto:
> Signed-off-by: Hannes Reinecke 
> ---
>  drivers/scsi/virtio_scsi.c | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index 2168258..1efd219 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -654,6 +654,11 @@ static int virtscsi_abort(struct scsi_cmnd *sc)
>   return virtscsi_tmf(vscsi, cmd);
>  }
>  
> +static enum blk_eh_timer_return virtscsi_timedout(struct scsi_cmnd *scmd)
> +{
> + return scsi_abort_command(scmd);
> +}
> +
>  static int virtscsi_target_alloc(struct scsi_target *starget)
>  {
>   struct virtio_scsi_target_state *tgt =
> @@ -683,6 +688,7 @@ static struct scsi_host_template 
> virtscsi_host_template_single = {
>   .queuecommand = virtscsi_queuecommand_single,
>   .eh_abort_handler = virtscsi_abort,
>   .eh_device_reset_handler = virtscsi_device_reset,
> + .eh_timed_out = virtscsi_timedout,
>  
>   .can_queue = 1024,
>   .dma_boundary = UINT_MAX,
> @@ -699,6 +705,7 @@ static struct scsi_host_template 
> virtscsi_host_template_multi = {
>   .queuecommand = virtscsi_queuecommand_multi,
>   .eh_abort_handler = virtscsi_abort,
>   .eh_device_reset_handler = virtscsi_device_reset,
> + .eh_timed_out = virtscsi_timedout,
>  
>   .can_queue = 1024,
>   .dma_boundary = UINT_MAX,
> 

Acked-by: Paolo Bonzini 
--
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 07/14] scsi_transport_srp: Add transport layer error handling

2013-06-12 Thread Bart Van Assche
Add the necessary functions in the SRP transport module to allow
an SRP initiator driver to implement transport layer error handling
similar to the functionality already provided by the FC transport
layer. This includes:
- Support for implementing fast_io_fail_tmo, the time that should
  elapse after having detected a transport layer problem and
  before failing I/O.
- Support for implementing dev_loss_tmo, the time that should
  elapse after having detected a transport layer problem and
  before removing a remote port.

Signed-off-by: Bart Van Assche 
Cc: Roland Dreier 
Cc: James Bottomley 
Cc: David Dillow 
Cc: Vu Pham 
Cc: Sebastian Riemer 
---
 Documentation/ABI/stable/sysfs-transport-srp |   36 ++
 drivers/scsi/scsi_transport_srp.c|  489 +-
 include/scsi/scsi_transport_srp.h|   54 ++-
 3 files changed, 576 insertions(+), 3 deletions(-)

diff --git a/Documentation/ABI/stable/sysfs-transport-srp 
b/Documentation/ABI/stable/sysfs-transport-srp
index b36fb0d..b7759b1 100644
--- a/Documentation/ABI/stable/sysfs-transport-srp
+++ b/Documentation/ABI/stable/sysfs-transport-srp
@@ -5,6 +5,23 @@ Contact:   linux-scsi@vger.kernel.org, 
linux-r...@vger.kernel.org
 Description:   Instructs an SRP initiator to disconnect from a target and to
remove all LUNs imported from that target.
 
+What:  /sys/class/srp_remote_ports/port-:/dev_loss_tmo
+Date:  September 1, 2013
+KernelVersion: 3.11
+Contact:   linux-scsi@vger.kernel.org, linux-r...@vger.kernel.org
+Description:   Number of seconds the SCSI layer will wait after a transport
+   layer error has been observed before removing a target port.
+   Zero means immediate removal.
+
+What:  /sys/class/srp_remote_ports/port-:/fast_io_fail_tmo
+Date:  September 1, 2013
+KernelVersion: 3.11
+Contact:   linux-scsi@vger.kernel.org, linux-r...@vger.kernel.org
+Description:   Number of seconds the SCSI layer will wait after a transport
+   layer error has been observed before failing I/O. Zero means
+   immediate removal. A negative value will disable this
+   behavior.
+
 What:  /sys/class/srp_remote_ports/port-:/port_id
 Date:  June 27, 2007
 KernelVersion: 2.6.24
@@ -12,8 +29,27 @@ Contact: linux-scsi@vger.kernel.org
 Description:   16-byte local SRP port identifier in hexadecimal format. An
example: 4c:49:4e:55:58:20:56:49:4f:00:00:00:00:00:00:00.
 
+What:  /sys/class/srp_remote_ports/port-:/reconnect_delay
+Date:  September 1, 2013
+KernelVersion: 3.11
+Contact:   linux-scsi@vger.kernel.org, linux-r...@vger.kernel.org
+Description:   Number of seconds the SCSI layer will wait after a reconnect
+   attempt failed before retrying.
+
 What:  /sys/class/srp_remote_ports/port-:/roles
 Date:  June 27, 2007
 KernelVersion: 2.6.24
 Contact:   linux-scsi@vger.kernel.org
 Description:   Role of the remote port. Either "SRP Initiator" or "SRP Target".
+
+What:  /sys/class/srp_remote_ports/port-:/state
+Date:  September 1, 2013
+KernelVersion: 3.11
+Contact:   linux-scsi@vger.kernel.org, linux-r...@vger.kernel.org
+Description:   State of the transport layer to the remote port. "running" if
+   the transport layer is operational; "blocked" if a transport
+   layer error has been encountered but the fail_io_fast_tmo
+   timer has not yet fired; "fail-fast" after the
+   fail_io_fast_tmo timer has fired and before the "dev_loss_tmo"
+   timer has fired; "lost" after the "dev_loss_tmo" timer has
+   fired and before the port is finally removed.
diff --git a/drivers/scsi/scsi_transport_srp.c 
b/drivers/scsi/scsi_transport_srp.c
index f7ba94a..53b34b3 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -24,12 +24,15 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
+#include "scsi_priv.h"
 #include "scsi_transport_srp_internal.h"
 
 struct srp_host_attrs {
@@ -38,7 +41,7 @@ struct srp_host_attrs {
 #define to_srp_host_attrs(host)((struct srp_host_attrs 
*)(host)->shost_data)
 
 #define SRP_HOST_ATTRS 0
-#define SRP_RPORT_ATTRS 3
+#define SRP_RPORT_ATTRS 8
 
 struct srp_internal {
struct scsi_transport_template t;
@@ -54,6 +57,28 @@ struct srp_internal {
 
 #definedev_to_rport(d) container_of(d, struct srp_rport, dev)
 #define transport_class_to_srp_rport(dev) dev_to_rport((dev)->parent)
+static inline struct Scsi_Host *rport_to_shost(struct srp_rport *r)
+{
+   return dev_to_shost(r->dev.parent);
+}
+
+/**
+ * srp_tmo_valid() - check timeout combination validity
+ *
+ * If no fast I/O fail timeout has been configured then the device loss timeout
+ * must be below SCSI_DEVICE_BLOCK_MAX_TIMEOUT. If a fast I/O fail timeou

[PATCH 06/14] IB/srp: Keep rport as long as the IB transport layer

2013-06-12 Thread Bart Van Assche
Keep the rport data structure around after srp_remove_host() has
finished until cleanup of the IB transport layer has finished
completely. This is necessary because later patches use the rport
pointer inside the queuecommand callback. Without this patch
accessing the rport from inside a queuecommand callback is racy
because srp_remove_host() must be invoked before scsi_remove_host()
and because the queuecommand callback may get invoked after
srp_remove_host() has finished.

Signed-off-by: Bart Van Assche 
Cc: Roland Dreier 
Cc: James Bottomley 
Cc: David Dillow 
Cc: Vu Pham 
Cc: Sebastian Riemer 
---
 drivers/infiniband/ulp/srp/ib_srp.c |3 +++
 drivers/infiniband/ulp/srp/ib_srp.h |1 +
 drivers/scsi/scsi_transport_srp.c   |   18 ++
 include/scsi/scsi_transport_srp.h   |2 ++
 4 files changed, 24 insertions(+)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c 
b/drivers/infiniband/ulp/srp/ib_srp.c
index 1a73b24..2bd0587 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -526,11 +526,13 @@ static void srp_remove_target(struct srp_target_port 
*target)
WARN_ON_ONCE(target->state != SRP_TARGET_REMOVED);
 
srp_del_scsi_host_attr(target->scsi_host);
+   srp_rport_get(target->rport);
srp_remove_host(target->scsi_host);
scsi_remove_host(target->scsi_host);
srp_disconnect_target(target);
ib_destroy_cm_id(target->cm_id);
srp_free_target_ib(target);
+   srp_rport_put(target->rport);
srp_free_req_data(target);
scsi_host_put(target->scsi_host);
 }
@@ -2009,6 +2011,7 @@ static int srp_add_target(struct srp_host *host, struct 
srp_target_port *target)
}
 
rport->lld_data = target;
+   target->rport = rport;
 
spin_lock(&host->target_lock);
list_add_tail(&target->list, &host->target_list);
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h 
b/drivers/infiniband/ulp/srp/ib_srp.h
index 66fbedd..1817ed5 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -153,6 +153,7 @@ struct srp_target_port {
u16 io_class;
struct srp_host*srp_host;
struct Scsi_Host   *scsi_host;
+   struct srp_rport   *rport;
chartarget_name[32];
unsigned intscsi_id;
unsigned intsg_tablesize;
diff --git a/drivers/scsi/scsi_transport_srp.c 
b/drivers/scsi/scsi_transport_srp.c
index f379c7f..f7ba94a 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -185,6 +185,24 @@ static int srp_host_match(struct attribute_container 
*cont, struct device *dev)
 }
 
 /**
+ * srp_rport_get() - increment rport reference count
+ */
+void srp_rport_get(struct srp_rport *rport)
+{
+   get_device(&rport->dev);
+}
+EXPORT_SYMBOL(srp_rport_get);
+
+/**
+ * srp_rport_put() - decrement rport reference count
+ */
+void srp_rport_put(struct srp_rport *rport)
+{
+   put_device(&rport->dev);
+}
+EXPORT_SYMBOL(srp_rport_put);
+
+/**
  * srp_rport_add - add a SRP remote port to the device hierarchy
  * @shost: scsi host the remote port is connected to.
  * @ids:   The port id for the remote port.
diff --git a/include/scsi/scsi_transport_srp.h 
b/include/scsi/scsi_transport_srp.h
index ff0f04a..5a2d2d1 100644
--- a/include/scsi/scsi_transport_srp.h
+++ b/include/scsi/scsi_transport_srp.h
@@ -38,6 +38,8 @@ extern struct scsi_transport_template *
 srp_attach_transport(struct srp_function_template *);
 extern void srp_release_transport(struct scsi_transport_template *);
 
+extern void srp_rport_get(struct srp_rport *rport);
+extern void srp_rport_put(struct srp_rport *rport);
 extern struct srp_rport *srp_rport_add(struct Scsi_Host *,
   struct srp_rport_identifiers *);
 extern void srp_rport_del(struct srp_rport *);
-- 
1.7.10.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 0/14] IB SRP initiator patches for kernel 3.11

2013-06-12 Thread Bart Van Assche

The purpose of this InfiniBand SRP initiator patch series is as follows:
- Make the SRP initiator driver better suited for use in a H.A. setup.
  Speed up failover by reducing the IB RC retry count and by notifying
  multipathd faster about transport layer failures by adding
  fast_io_fail_tmo and dev_loss_tmo parameters.
- Make the SRP initiator better suited for use on NUMA systems by
  making the HCA completion vector configurable.

Some of the patches in this patch series were posted previously as "Make 
ib_srp better suited for H.A. purposes". The changes compared to version 
five of that patch series are:

- Left out patches that are already upstream.
- Made it possible to set dev_loss_tmo to "off". This is useful in a
  setup using initiator side mirroring to avoid that new /dev/sd* names
  are reassigned after a failover or cable pull and reinsert.
- Added kernel module parameters to ib_srp for configuring default
  values of the fast_io_fail_tmo and dev_loss_tmo parameters.
- Added a patch from Dotan Barak that fixes a kernel oops during rmmod
  triggered by resource allocation failure at module load time.
- Avoid duplicate connections by refusing relogins instead of dropping
  duplicate connections, as proposed by Sebastian Riemer.
- Added a patch from Sebastian Riemer for failing SCSI commands
  silently.
- Added a patch from Vu Pham to make the transport layer (IB RC) retry
  count configurable.
- Made HCA completion vector configurable.

Changes since v4:
- Added a patch for removing SCSI devices upon a port down event

Changes since v3:
- Restored the dev_loss_tmo and fast_io_fail_tmo sysfs attributes.
- Included a patch to fix an ib_srp crash that could be triggered by
  cable pulling.

Changes since v2:
- Addressed the v2 review comments.
- Dropped the patches that have already been merged.
- Dropped the patches for integration with multipathd.
- Dropped the micro-optimization of the IB completion handlers.

The individual patches in this series are as follows:
0001-IB-srp-Fix-remove_one-crash-due-to-resource-exhausti.patch
0002-IB-srp-Fix-race-between-srp_queuecommand-and-srp_cla.patch
0003-IB-srp-Avoid-that-srp_reset_host-is-skipped-after-a-.patch
0004-IB-srp-Skip-host-settle-delay.patch
0005-IB-srp-Maintain-a-single-connection-per-I_T-nexus.patch
0006-IB-srp-Keep-rport-as-long-as-the-IB-transport-layer.patch
0007-scsi_transport_srp-Add-transport-layer-error-handlin.patch
0008-IB-srp-Add-srp_terminate_io.patch
0009-IB-srp-Use-SRP-transport-layer-error-recovery.patch
0010-IB-srp-Start-timers-if-a-transport-layer-error-occur.patch
0011-IB-srp-Fail-SCSI-commands-silently.patch
0012-IB-srp-Make-HCA-completion-vector-configurable.patch
0013-IB-srp-Make-transport-layer-retry-count-configurable.patch
0014-IB-srp-Bump-driver-version-and-release-date.patch

--
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 v11 9/9] Avoid reenabling I/O after the transport became offline

2013-06-12 Thread Bart Van Assche
Disallow the SDEV_TRANSPORT_OFFLINE to SDEV_CANCEL transition such
that no I/O is sent to devices for which the transport is offline.
Notes:
- Functions like sd_shutdown() use scsi_execute_req() and hence
  set the REQ_PREEMPT flag. Such requests are passed to the LLD
  queuecommand callback in the SDEV_CANCEL state.
- This patch does not affect Fibre Channel LLD drivers since these
  drivers invoke fc_remote_port_chkready() before submitting a SCSI
  request to the HBA. That prevents a timeout to occur in state
  SDEV_CANCEL if the transport is offline.

Signed-off-by: Bart Van Assche 
Reviewed-by: Mike Christie 
Cc: James Bottomley 
Cc: Hannes Reinecke 
Cc: Tejun Heo 
---
 drivers/scsi/scsi_lib.c   |1 -
 drivers/scsi/scsi_sysfs.c |3 ++-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 10c054f..024e768 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2162,7 +2162,6 @@ scsi_device_set_state(struct scsi_device *sdev, enum 
scsi_device_state state)
case SDEV_RUNNING:
case SDEV_QUIESCE:
case SDEV_OFFLINE:
-   case SDEV_TRANSPORT_OFFLINE:
case SDEV_BLOCK:
break;
default:
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 11318cc..dd2005c 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -963,7 +963,8 @@ void __scsi_remove_device(struct scsi_device *sdev)
 
if (sdev->is_visible) {
spin_lock_irqsave(shost->host_lock, flags);
-   WARN(scsi_device_set_state(sdev, SDEV_CANCEL) != 0,
+   WARN(scsi_device_set_state(sdev, SDEV_CANCEL) != 0 &&
+sdev->sdev_state != SDEV_TRANSPORT_OFFLINE,
 "%s: unexpected state %d\n", dev_name(&sdev->sdev_gendev),
 sdev->sdev_state);
spin_unlock_irqrestore(shost->host_lock, flags);
-- 
1.7.10.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 v11 8/9] Save and restore host_scribble during error handling

2013-06-12 Thread Bart Van Assche
A SCSI LLD may overwrite host_scribble in its queuecommand()
implementation. Several drivers need that field to process
requests and aborts correctly. Hence this field must be saved
by scsi_eh_prep_cmnd() and must be restored by
scsi_eh_restore_cmnd().

Signed-off-by: Bart Van Assche 
Cc: James Bottomley 
Cc: Mike Christie 
Cc: Hannes Reinecke 
Cc: Tejun Heo 
---
 drivers/scsi/scsi_error.c |2 ++
 include/scsi/scsi_eh.h|1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 2c99eab..728d573 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -771,6 +771,7 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct 
scsi_eh_save *ses,
ses->result = scmd->result;
ses->underflow = scmd->underflow;
ses->prot_op = scmd->prot_op;
+   ses->host_scribble = scmd->host_scribble;
 
scmd->prot_op = SCSI_PROT_NORMAL;
scmd->cmnd = ses->eh_cmnd;
@@ -832,6 +833,7 @@ void scsi_eh_restore_cmnd(struct scsi_cmnd* scmd, struct 
scsi_eh_save *ses)
scmd->result = ses->result;
scmd->underflow = ses->underflow;
scmd->prot_op = ses->prot_op;
+   scmd->host_scribble = ses->host_scribble;
 }
 EXPORT_SYMBOL(scsi_eh_restore_cmnd);
 
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
index 06a8790..7bdb02f 100644
--- a/include/scsi/scsi_eh.h
+++ b/include/scsi/scsi_eh.h
@@ -83,6 +83,7 @@ struct scsi_eh_save {
/* new command support */
unsigned char eh_cmnd[BLK_MAX_CDB];
struct scatterlist sense_sgl;
+   unsigned char *host_scribble;
 };
 
 extern void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd,
-- 
1.7.10.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 v11 7/9] Avoid that scsi_device_set_state() triggers a race

2013-06-12 Thread Bart Van Assche
Make concurrent invocations of scsi_device_set_state() safe.

Signed-off-by: Bart Van Assche 
Acked-by: Hannes Reinecke 
Cc: James Bottomley 
Cc: Tejun Heo 
Cc: Mike Christie 
---
 drivers/scsi/scsi_error.c |4 
 drivers/scsi/scsi_lib.c   |   43 ++-
 drivers/scsi/scsi_scan.c  |   15 ---
 drivers/scsi/scsi_sysfs.c |   18 ++
 4 files changed, 60 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 1f2f593..2c99eab 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1448,7 +1448,11 @@ static void scsi_eh_offline_sdevs(struct list_head 
*work_q,
list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
sdev_printk(KERN_INFO, scmd->device, "Device offlined - "
"not ready after error recovery\n");
+
+   spin_lock_irq(scmd->device->host->host_lock);
scsi_device_set_state(scmd->device, SDEV_OFFLINE);
+   spin_unlock_irq(scmd->device->host->host_lock);
+
if (scmd->eh_eflags & SCSI_EH_CANCEL_CMD) {
/*
 * FIXME: Handle lost cmds.
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index e1cc1d1..10c054f 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2078,7 +2078,9 @@ EXPORT_SYMBOL(scsi_test_unit_ready);
  * @state: state to change to.
  *
  * Returns zero if unsuccessful or an error if the requested 
- * transition is illegal.
+ * transition is illegal. It is the responsibility of the caller to make
+ *  sure that a call of this function does not race with other code that
+ *  accesses the device state, e.g. by holding the host lock.
  */
 int
 scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state)
@@ -2359,7 +2361,13 @@ EXPORT_SYMBOL_GPL(sdev_evt_send_simple);
 int
 scsi_device_quiesce(struct scsi_device *sdev)
 {
-   int err = scsi_device_set_state(sdev, SDEV_QUIESCE);
+   struct Scsi_Host *host = sdev->host;
+   int err;
+
+   spin_lock_irq(host->host_lock);
+   err = scsi_device_set_state(sdev, SDEV_QUIESCE);
+   spin_unlock_irq(host->host_lock);
+
if (err)
return err;
 
@@ -2383,13 +2391,21 @@ EXPORT_SYMBOL(scsi_device_quiesce);
  */
 void scsi_device_resume(struct scsi_device *sdev)
 {
+   struct Scsi_Host *host = sdev->host;
+   int err;
+
/* check if the device state was mutated prior to resume, and if
 * so assume the state is being managed elsewhere (for example
 * device deleted during suspend)
 */
-   if (sdev->sdev_state != SDEV_QUIESCE ||
-   scsi_device_set_state(sdev, SDEV_RUNNING))
+   spin_lock_irq(host->host_lock);
+   err = sdev->sdev_state == SDEV_QUIESCE ?
+   scsi_device_set_state(sdev, SDEV_RUNNING) : -EINVAL;
+   spin_unlock_irq(host->host_lock);
+
+   if (err)
return;
+
scsi_run_queue(sdev->request_queue);
 }
 EXPORT_SYMBOL(scsi_device_resume);
@@ -2439,17 +2455,19 @@ EXPORT_SYMBOL(scsi_target_resume);
 int
 scsi_internal_device_block(struct scsi_device *sdev)
 {
+   struct Scsi_Host *host = sdev->host;
struct request_queue *q = sdev->request_queue;
unsigned long flags;
int err = 0;
 
+   spin_lock_irqsave(host->host_lock, flags);
err = scsi_device_set_state(sdev, SDEV_BLOCK);
-   if (err) {
+   if (err)
err = scsi_device_set_state(sdev, SDEV_CREATED_BLOCK);
+   spin_unlock_irqrestore(host->host_lock, flags);
 
-   if (err)
-   return err;
-   }
+   if (err)
+   return err;
 
/* 
 * The device has transitioned to SDEV_BLOCK.  Stop the
@@ -2484,13 +2502,16 @@ int
 scsi_internal_device_unblock(struct scsi_device *sdev,
 enum scsi_device_state new_state)
 {
+   struct Scsi_Host *host = sdev->host;
struct request_queue *q = sdev->request_queue; 
unsigned long flags;
+   int ret = 0;
 
/*
 * Try to transition the scsi device to SDEV_RUNNING or one of the
 * offlined states and goose the device queue if successful.
 */
+   spin_lock_irqsave(host->host_lock, flags);
if ((sdev->sdev_state == SDEV_BLOCK) ||
(sdev->sdev_state == SDEV_TRANSPORT_OFFLINE))
sdev->sdev_state = new_state;
@@ -2502,7 +2523,11 @@ scsi_internal_device_unblock(struct scsi_device *sdev,
sdev->sdev_state = SDEV_CREATED;
} else if (sdev->sdev_state != SDEV_CANCEL &&
 sdev->sdev_state != SDEV_OFFLINE)
-   return -EINVAL;
+   ret = -EINVAL;
+   spin_unlock_irqrestore(host->host_lock, flags);
+
+   if (ret)
+   return ret;
 
spin_lock_irqsave(q->queue_

[PATCH v11 6/9] Make scsi_remove_host() wait until error handling finished

2013-06-12 Thread Bart Van Assche
A SCSI LLD may start cleaning up host resources as soon as
scsi_remove_host() returns. These host resources may be needed by
the LLD in an implementation of one of the eh_* functions. So if
one of the eh_* functions is in progress when scsi_remove_host()
is invoked, wait until the eh_* function has finished. Also, do
not invoke any of the eh_* functions after scsi_remove_host() has
started. Remove Scsi_Host.tmf_in_progress because it is now
superfluous.

Signed-off-by: Bart Van Assche 
Cc: Hannes Reinecke 
Cc: Mike Christie 
Cc: Tejun Heo 
---
 drivers/scsi/hosts.c  |6 
 drivers/scsi/scsi_error.c |   86 ++---
 include/scsi/scsi_host.h  |6 ++--
 3 files changed, 81 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 034a567..17e2ccb 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -176,6 +176,12 @@ void scsi_remove_host(struct Scsi_Host *shost)
BUG_ON(scsi_host_set_state(shost, SHOST_DEL_RECOVERY));
spin_unlock_irq(shost->host_lock);
 
+   /*
+* Wait until the error handler has finished invoking LLD callbacks
+* before allowing the LLD to proceed.
+*/
+   wait_event(shost->host_wait, shost->eh_active == 0);
+
transport_unregister_device(&shost->shost_gendev);
device_unregister(&shost->shost_dev);
device_del(&shost->shost_gendev);
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index f43de1e..1f2f593 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -537,8 +537,53 @@ static void scsi_eh_done(struct scsi_cmnd *scmd)
 }
 
 /**
+ * scsi_begin_eh - start host-related error handling
+ *
+ * Must be called before invoking an LLD callback function to avoid that
+ * scsi_remove_host() returns while one of these callback functions is in
+ * progress.
+ *
+ * Returns 0 if invoking an eh_* function is allowed and a negative value if
+ * not. If this function returns 0 then scsi_end_eh() must be called
+ * eventually.
+ */
+static int scsi_begin_eh(struct Scsi_Host *host)
+{
+   int res;
+
+   spin_lock_irq(host->host_lock);
+   switch (host->shost_state) {
+   case SHOST_DEL:
+   case SHOST_DEL_RECOVERY:
+   res = -ENODEV;
+   break;
+   default:
+   WARN_ON_ONCE(host->eh_active < 0);
+   host->eh_active++;
+   res = 0;
+   break;
+   }
+   spin_unlock_irq(host->host_lock);
+
+   return res;
+}
+
+/**
+ * scsi_end_eh - finish host-related error handling
+ */
+static void scsi_end_eh(struct Scsi_Host *host)
+{
+   spin_lock_irq(host->host_lock);
+   host->eh_active--;
+   WARN_ON_ONCE(host->eh_active < 0);
+   if (host->eh_active == 0)
+   wake_up(&host->host_wait);
+   spin_unlock_irq(host->host_lock);
+}
+
+/**
  * scsi_try_host_reset - ask host adapter to reset itself
- * @scmd:  SCSI cmd to send hsot reset.
+ * @scmd:  SCSI cmd to send host reset.
  */
 static int scsi_try_host_reset(struct scsi_cmnd *scmd)
 {
@@ -553,6 +598,9 @@ static int scsi_try_host_reset(struct scsi_cmnd *scmd)
if (!hostt->eh_host_reset_handler)
return FAILED;
 
+   if (scsi_begin_eh(host))
+   return FAST_IO_FAIL;
+
rtn = hostt->eh_host_reset_handler(scmd);
 
if (rtn == SUCCESS) {
@@ -562,6 +610,7 @@ static int scsi_try_host_reset(struct scsi_cmnd *scmd)
scsi_report_bus_reset(host, scmd_channel(scmd));
spin_unlock_irqrestore(host->host_lock, flags);
}
+   scsi_end_eh(host);
 
return rtn;
 }
@@ -583,6 +632,9 @@ static int scsi_try_bus_reset(struct scsi_cmnd *scmd)
if (!hostt->eh_bus_reset_handler)
return FAILED;
 
+   if (scsi_begin_eh(host))
+   return FAST_IO_FAIL;
+
rtn = hostt->eh_bus_reset_handler(scmd);
 
if (rtn == SUCCESS) {
@@ -592,6 +644,7 @@ static int scsi_try_bus_reset(struct scsi_cmnd *scmd)
scsi_report_bus_reset(host, scmd_channel(scmd));
spin_unlock_irqrestore(host->host_lock, flags);
}
+   scsi_end_eh(host);
 
return rtn;
 }
@@ -622,6 +675,9 @@ static int scsi_try_target_reset(struct scsi_cmnd *scmd)
if (!hostt->eh_target_reset_handler)
return FAILED;
 
+   if (scsi_begin_eh(host))
+   return FAST_IO_FAIL;
+
rtn = hostt->eh_target_reset_handler(scmd);
if (rtn == SUCCESS) {
spin_lock_irqsave(host->host_lock, flags);
@@ -629,6 +685,7 @@ static int scsi_try_target_reset(struct scsi_cmnd *scmd)
  __scsi_report_device_reset);
spin_unlock_irqrestore(host->host_lock, flags);
}
+   scsi_end_eh(host);
 
return rtn;
 }
@@ -646,14 +703,20 @@ static int scsi_try_target_reset(struct scsi_cmnd *scmd)
 stat

[PATCH v11 5/9] Avoid saving/restoring interrupt state inside scsi_remove_host()

2013-06-12 Thread Bart Van Assche
Since it is not allowed to invoke scsi_remove_host() with interrupts
disabled, avoid saving and restoring the interrupt state inside
scsi_remove_host(). This patch does not change the functionality of
the function scsi_remove_host().

Signed-off-by: Bart Van Assche 
Acked-by: Tejun Heo 
Acked-by: Hannes Reinecke 
Cc: Mike Christie 
Cc: James Bottomley 
---
 drivers/scsi/hosts.c |   12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index df0c3c7..034a567 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -156,27 +156,25 @@ EXPORT_SYMBOL(scsi_host_set_state);
  **/
 void scsi_remove_host(struct Scsi_Host *shost)
 {
-   unsigned long flags;
-
mutex_lock(&shost->scan_mutex);
-   spin_lock_irqsave(shost->host_lock, flags);
+   spin_lock_irq(shost->host_lock);
if (scsi_host_set_state(shost, SHOST_CANCEL))
if (scsi_host_set_state(shost, SHOST_CANCEL_RECOVERY)) {
-   spin_unlock_irqrestore(shost->host_lock, flags);
+   spin_unlock_irq(shost->host_lock);
mutex_unlock(&shost->scan_mutex);
return;
}
-   spin_unlock_irqrestore(shost->host_lock, flags);
+   spin_unlock_irq(shost->host_lock);
 
scsi_autopm_get_host(shost);
scsi_forget_host(shost);
mutex_unlock(&shost->scan_mutex);
scsi_proc_host_rm(shost);
 
-   spin_lock_irqsave(shost->host_lock, flags);
+   spin_lock_irq(shost->host_lock);
if (scsi_host_set_state(shost, SHOST_DEL))
BUG_ON(scsi_host_set_state(shost, SHOST_DEL_RECOVERY));
-   spin_unlock_irqrestore(shost->host_lock, flags);
+   spin_unlock_irq(shost->host_lock);
 
transport_unregister_device(&shost->shost_gendev);
device_unregister(&shost->shost_dev);
-- 
1.7.10.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 v11 4/9] Disallow changing the device state via sysfs into "deleted"

2013-06-12 Thread Bart Van Assche
Changing the state of a SCSI device via sysfs into "cancel" or
"deleted" prevents removal of these devices by scsi_remove_host().
Hence do not allow this. Also, introduce the symbolic name
INVALID_SDEV_STATE, representing a value different from any valid
SCSI device state. Update scsi_device_set_state() such that gcc
does not issue a warning about an enumeration value not being
handled inside a switch statement.

Signed-off-by: Bart Van Assche 
Cc: Tejun Heo 
Cc: James Bottomley 
Cc: Mike Christie 
Cc: Hannes Reinecke 
Cc: David Milburn 
---
 drivers/scsi/scsi_lib.c|2 ++
 drivers/scsi/scsi_sysfs.c  |5 +++--
 include/scsi/scsi_device.h |6 +-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index d57b5e1..e1cc1d1 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2183,6 +2183,8 @@ scsi_device_set_state(struct scsi_device *sdev, enum 
scsi_device_state state)
}
break;
 
+   case INVALID_SDEV_STATE:
+   goto illegal;
}
sdev->sdev_state = state;
return 0;
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index f869ef85..fe3ea686 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -594,7 +594,7 @@ store_state_field(struct device *dev, struct 
device_attribute *attr,
 {
int i;
struct scsi_device *sdev = to_scsi_device(dev);
-   enum scsi_device_state state = 0;
+   enum scsi_device_state state = INVALID_SDEV_STATE;
 
for (i = 0; i < ARRAY_SIZE(sdev_states); i++) {
const int len = strlen(sdev_states[i].name);
@@ -604,7 +604,8 @@ store_state_field(struct device *dev, struct 
device_attribute *attr,
break;
}
}
-   if (!state)
+   if (state == INVALID_SDEV_STATE || state == SDEV_CANCEL ||
+   state == SDEV_DEL)
return -EINVAL;
 
if (scsi_device_set_state(sdev, state))
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index cc64587..cc1b52a 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -29,7 +29,11 @@ struct scsi_mode_data {
  * scsi_lib:scsi_device_set_state().
  */
 enum scsi_device_state {
-   SDEV_CREATED = 1,   /* device created but not added to sysfs
+   INVALID_SDEV_STATE, /* Not a valid SCSI device state but a
+* symbolic name that can be used wherever
+* a value is needed that is different from
+* any valid SCSI device state. */
+   SDEV_CREATED,   /* device created but not added to sysfs
 * Only internal commands allowed (for inq) */
SDEV_RUNNING,   /* device properly configured
 * All commands allowed */
-- 
1.7.10.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 v11 3/9] Avoid calling __scsi_remove_device() twice

2013-06-12 Thread Bart Van Assche
SCSI devices are added to the shost->__devices list from inside
scsi_alloc_sdev(). If something goes wrong during LUN scanning,
e.g. a transport layer failure occurs, then __scsi_remove_device()
can get invoked by the LUN scanning code for a SCSI device in
state SDEV_CREATED_BLOCK or SDEV_BLOCKED. If this happens then
the SCSI device has not yet been added to sysfs (is_visible == 0).
Make sure that if this happens these devices are transitioned
into state SDEV_DEL. This avoids that __scsi_remove_device()
gets invoked a second time by scsi_forget_host().

Signed-off-by: Bart Van Assche 
Cc: James Bottomley 
Cc: Mike Christie 
Cc: Hannes Reinecke 
Cc: Tejun Heo 
---
 drivers/scsi/scsi_lib.c   |2 ++
 drivers/scsi/scsi_sysfs.c |7 ---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 03d4165..d57b5e1 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2175,6 +2175,8 @@ scsi_device_set_state(struct scsi_device *sdev, enum 
scsi_device_state state)
case SDEV_OFFLINE:
case SDEV_TRANSPORT_OFFLINE:
case SDEV_CANCEL:
+   case SDEV_BLOCK:
+   case SDEV_CREATED_BLOCK:
break;
default:
goto illegal;
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 34f1b39..f869ef85 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -956,8 +956,9 @@ void __scsi_remove_device(struct scsi_device *sdev)
unsigned long flags;
 
if (sdev->is_visible) {
-   if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0)
-   return;
+   WARN(scsi_device_set_state(sdev, SDEV_CANCEL) != 0,
+"%s: unexpected state %d\n", dev_name(&sdev->sdev_gendev),
+sdev->sdev_state);
 
bsg_unregister_queue(sdev->request_queue);
device_unregister(&sdev->sdev_dev);
@@ -971,7 +972,7 @@ void __scsi_remove_device(struct scsi_device *sdev)
 * scsi_run_queue() invocations have finished before tearing down the
 * device.
 */
-   scsi_device_set_state(sdev, SDEV_DEL);
+   WARN_ON_ONCE(scsi_device_set_state(sdev, SDEV_DEL) != 0);
blk_cleanup_queue(sdev->request_queue);
cancel_work_sync(&sdev->requeue_work);
 
-- 
1.7.10.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 v11 2/9] Remove get_device() / put_device() pair from scsi_request_fn()

2013-06-12 Thread Bart Van Assche
Now that all scsi_request_fn() callers hold a reference on the
SCSI device that function is invoked for and since
blk_cleanup_queue() waits until scsi_request_fn() has finished
it is safe to remove the get_device() / put_device() pair from
scsi_request_fn().

Signed-off-by: Bart Van Assche 
Acked-by: Tejun Heo 
Cc: James Bottomley 
Cc: Hannes Reinecke 
Cc: Mike Christie 
---
 drivers/scsi/scsi_lib.c |   14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index d6ca072..03d4165 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1533,16 +1533,14 @@ static void scsi_softirq_done(struct request *rq)
  * Lock status: IO request lock assumed to be held when called.
  */
 static void scsi_request_fn(struct request_queue *q)
+   __releases(q->queue_lock)
+   __acquires(q->queue_lock)
 {
struct scsi_device *sdev = q->queuedata;
struct Scsi_Host *shost;
struct scsi_cmnd *cmd;
struct request *req;
 
-   if(!get_device(&sdev->sdev_gendev))
-   /* We must be tearing the block queue down already */
-   return;
-
/*
 * To start with, we keep looping until the queue is empty, or until
 * the host is no longer able to accept any more requests.
@@ -1631,7 +1629,7 @@ static void scsi_request_fn(struct request_queue *q)
goto out_delay;
}
 
-   goto out;
+   return;
 
  not_ready:
spin_unlock_irq(shost->host_lock);
@@ -1650,12 +1648,6 @@ static void scsi_request_fn(struct request_queue *q)
 out_delay:
if (sdev->device_busy == 0)
blk_delay_queue(q, SCSI_QUEUE_DELAY);
-out:
-   /* must be careful here...if we trigger the ->remove() function
-* we cannot be holding the q lock */
-   spin_unlock_irq(q->queue_lock);
-   put_device(&sdev->sdev_gendev);
-   spin_lock_irq(q->queue_lock);
 }
 
 u64 scsi_calculate_bounce_limit(struct Scsi_Host *shost)
-- 
1.7.10.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 v11 1/9] Fix race between starved list and device removal

2013-06-12 Thread Bart Van Assche
scsi_run_queue() examines all SCSI devices that are present on
the starved list. Since scsi_run_queue() unlocks the SCSI host
lock before running a queue a SCSI device can get removed after
it has been removed from the starved list and before its queue
is run. Protect against that race condition by increasing the
sdev refcount before running the sdev queue. Also, remove a
SCSI device from the starved list before __scsi_remove_device()
decreases the sdev refcount such that the get_device() call
added in scsi_run_queue() is guaranteed to succeed.

Signed-off-by: Bart Van Assche 
Reported-and-tested-by: Chanho Min 
Reference: http://lkml.org/lkml/2012/8/2/96
Acked-by: Tejun Heo 
Reviewed-by: Mike Christie 
Cc: Hannes Reinecke 
Cc: 
---
 drivers/scsi/scsi_lib.c   |   16 +++-
 drivers/scsi/scsi_sysfs.c |   14 +-
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 86d5220..d6ca072 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -456,11 +456,17 @@ static void scsi_run_queue(struct request_queue *q)
continue;
}
 
-   spin_unlock(shost->host_lock);
-   spin_lock(sdev->request_queue->queue_lock);
-   __blk_run_queue(sdev->request_queue);
-   spin_unlock(sdev->request_queue->queue_lock);
-   spin_lock(shost->host_lock);
+   /*
+* Obtain a reference before unlocking the host_lock such that
+* the sdev can't disappear before blk_run_queue() is invoked.
+*/
+   get_device(&sdev->sdev_gendev);
+   spin_unlock_irqrestore(shost->host_lock, flags);
+
+   blk_run_queue(sdev->request_queue);
+   put_device(&sdev->sdev_gendev);
+
+   spin_lock_irqsave(shost->host_lock, flags);
}
/* put any unprocessed entries back */
list_splice(&starved_list, &shost->starved_list);
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 931a7d9..34f1b39 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -345,7 +345,6 @@ static void scsi_device_dev_release_usercontext(struct 
work_struct *work)
starget->reap_ref++;
list_del(&sdev->siblings);
list_del(&sdev->same_target_siblings);
-   list_del(&sdev->starved_entry);
spin_unlock_irqrestore(sdev->host->host_lock, flags);
 
cancel_work_sync(&sdev->event_work);
@@ -953,6 +952,8 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
 void __scsi_remove_device(struct scsi_device *sdev)
 {
struct device *dev = &sdev->sdev_gendev;
+   struct Scsi_Host *shost = sdev->host;
+   unsigned long flags;
 
if (sdev->is_visible) {
if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0)
@@ -974,6 +975,17 @@ void __scsi_remove_device(struct scsi_device *sdev)
blk_cleanup_queue(sdev->request_queue);
cancel_work_sync(&sdev->requeue_work);
 
+   /*
+* Remove a SCSI device from the starved list after blk_cleanup_queue()
+* finished such that scsi_request_fn() can't add it back to that list.
+* Also remove an sdev from the starved list before invoking
+* put_device() such that get_device() is guaranteed to succeed for an
+* sdev present on the starved list.
+*/
+   spin_lock_irqsave(shost->host_lock, flags);
+   list_del(&sdev->starved_entry);
+   spin_unlock_irqrestore(shost->host_lock, flags);
+
if (sdev->host->hostt->slave_destroy)
sdev->host->hostt->slave_destroy(sdev);
transport_destroy_device(dev);
-- 
1.7.10.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 v11 0/9] More device removal fixes

2013-06-12 Thread Bart Van Assche


Fix a few issues that can be triggered by removing a SCSI device:
- Fix a race between starved list processing and device removal that
  can trigger a kernel oops.
- Avoid that a SCSI LLD callback can get invoked after
  scsi_remove_host() finished.
- Speed up device removal by stopping error handling as soon as
  the SHOST_DEL or SHOST_DEL_RECOVERY state has been reached.
- Save and restore the host_scribble field during error handling.

Changes compared to v10:
- Rebased and retested on top of Linux kernel v3.10-rc5.

Changes compared to v9:
- Changed one WARN_ON() statement into a WARN() statement.

Changes compared to v8:
- Addressed the feedback from Joe Lawrence - dropped the patch that
  makes scsi_remove_host() wait until the last sdev user is gone.
- Eliminated Scsi_Host.tmf_in_progress since it duplicates state
  information available in Scsi_Host.eh_active.
- Added a patch to avoid reenabling I/O after the transport layer
  became offline.

Changes compared to v7:
- Addressed the review comments posted by Hannes Reinecke and Rolf Eike
  Beer.
- Modified patch "Make scsi_remove_host() wait until error handling
  finished" such that it is also safe for SCSI timeout values below
  the maximum LLD response time by modifying scsi_send_eh_cmnd() such
  that it does not invoke any LLD code after scsi_remove_host() started.
- Added a patch to save and restore the host_scribble field.
- Refined / clarified several patch descriptions.
- Rebased and retested on top of kernel v3.8-rc6.

Changes compared to v6:
- Dropped the first six patches since Jens queued these for 3.8.
- Added patch to avoid that __scsi_remove_device() is invoked twice.
- Restore error recovery in the SHOST_CANCEL state.

Changes compared to v5:
- Avoid that block layer work can be scheduled on a dead queue.
- Do not invoke any SCSI LLD callback after scsi_remove_host() finished.
- Stop error handling as soon as scsi_remove_host() started.
- Remove the unused function bsg_goose_queue().
- Avoid that scsi_device_set_state() triggers a race condition.

Changes compared to v4:
- Moved queue_flag_set(QUEUE_FLAG_DEAD, q) from blk_drain_queue() into
  blk_cleanup_queue().
- Declared the new __blk_run_queue_uncond() function inline. Checked in
  the generated assembler code that this function is really inlined in
  __blk_run_queue().
- Elaborated several patch descriptions.
- Added sparse annotations to scsi_request_fn().
- Split several patches.

Changes compared to v3:
- Fixed a race condition by setting QUEUE_FLAG_DEAD earlier.
- Added a patch for fixing a race between starved list processing
  and device removal to this series.

Changes compared to v2:
- Split second patch into two patches.
- Refined patch descriptions.

Changes compared to v1:
- Included a patch to rename QUEUE_FLAG_DEAD.
- Refined the descriptions of the __blk_run_queue_uncond() and
  blk_cleanup_queue() functions.
--
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


eh_abort_handler implementations

2013-06-12 Thread Hannes Reinecke
Hi all,

as you might know, I'm trying to revamp the eh_abort_handler
implementation by sending command aborts directly whenever
the timeout triggers, without entering SCSI EH.

So, during testing where the remote port is disabled I've seen this:

[  864.734937] qla2xxx [:41:00.0]-8802:1: Aborting from RISC
nexus=1:0:0 sp=880225b0dd40 cmd=8802248d76c0
[  864.737274] qla2xxx [:41:00.0]-1800:1: Entered
qla2x00_mailbox_command.
[  864.738720] qla2xxx [:41:00.0]-1806:1: Prepare to issue mbox
cmd=0x54.
[  864.740268] qla2xxx [:41:00.0]-180f:1: Going to unlock irq &
waiting for interrupts. jiffies=100022781.
[  864.740574] qla2xxx [:41:00.0]-1814:1: Cmd=54 completed.
[  864.740596] qla2xxx [:41:00.0]-3822:1: FCP command status:
0x5-0x0 (0x8) nexus=1:0:0 portid=691400 oxid=0x38e
cdb=28000800 len=0x1000 rsp_info=0x0 resid=0x0 fw_resid=0x0.
[  864.740608] qla2xxx [:41:00.0]-1821:1: Done
qla2x00_mailbox_command.
[  864.740615] qla2xxx [:41:00.0]-8804:1: Abort command mbx
success cmd=8802248d76c0.
[  864.740631] qla2xxx [:41:00.0]-801c:1: Abort command issued
nexus=1:0:0 --  2002.

Again, the port is disabled, so the TMF _cannot_ be received by the
remote port, let alone processed.
But still the command abort is processed correctly and the command
is returned to the upper layers.
So with the current thinking the command abort was successful, and
EH would exit, as the remote port was assumed to be working.
But most evidently the remote port is _still_ not reachable, so the
TMF _should_ have returned 'FAILED'.
At least that's what we expect.
But it looks as if this expectation is slightly skewed, as most
likely a successful ABORT TASK TMF just means that the command was
terminated, not that the remote port itself was working.

If _that_ should be the case it looks as if we _always_ should be
issuing a RESET LUN TMF whenever command aborts have been processed.
Would that be correct?

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 10/10] qla2xxx: Fix a memory leak in an error path of qla2x00_process_els()

2013-06-12 Thread Saurav Kashyap
Hi Bart,
In this case online check is move to far, the vha is still not
dereferenced. The right patch is moving online flag just after getting vha.

diff --git a/drivers/scsi/qla2xxx/qla_bsg.c
b/drivers/scsi/qla2xxx/qla_bsg.c
index 9520b1f..11f84dc 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -269,6 +269,12 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
type = "FC_BSG_HST_ELS_NOLOGIN";
}
 
+   if (!vha->flags.online) {
+   ql_log(ql_log_warn, vha, 0x7005, "Host not online.\n");
+   rval = -EIO;
+   goto done;
+   }
+
/* pass through is supported only for ISP 4Gb or higher */
if (!IS_FWI2_CAPABLE(ha)) {
ql_dbg(ql_dbg_user, vha, 0x7001,
@@ -326,12 +332,6 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
NPH_FABRIC_CONTROLLER : NPH_F_PORT;
}
 
-   if (!vha->flags.online) {
-   ql_log(ql_log_warn, vha, 0x7005, "Host not online.\n");
-   rval = -EIO;
-   goto done;
-   }
-
req_sg_cnt =
dma_map_sg(&ha->pdev->dev,
bsg_job->request_payload.sg_list,
bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
@@ -399,7 +399,7 @@ done_unmap_sg:
goto done_free_fcport;
 
 done_free_fcport:
-   if (bsg_job->request->msgcode == FC_BSG_HST_ELS_NOLOGIN)
+   if (bsg_job->request->msgcode == FC_BSG_RPT_ELS)
kfree(fcport);
 done:
return rval;


Thanks,
~Saurav



-Original Message-
From: Bart Van Assche 
Date: Wed, 5 Jun 2013 15:09:59 +0200
To: linux-scsi 
Cc: Chad Dupuis , Saurav Kashyap

Subject: [PATCH 10/10] qla2xxx: Fix a memory leak in an error path of
qla2x00_process_els()

>Avoid that the fcport structure gets leaked if
>bsg_job->request->msgcode == FC_BSG_HST_ELS_NOLOGIN, the fcport
>allocation succeeds and the !vha->flags.online branch is taken.
>This was detected by Coverity. However, Coverity does not recognize
>that all qla2x00_process_els() callers specify either
>FC_BSG_RPT_ELS or FC_BSG_HST_ELS_NOLOGIN in the field
>bsg_job->request->msgcode and that the value of that field is not
>modified inside that function. This results in a false positive
>report about a possible memory leak in an error path for
>bsg_job->request->msgcode values other than the two mentioned
>values.  Make it easy for Coverity (and for humans) to recognize
>that there is no fcport leak in the error path by changing the
>bsg_job->request->msgcode == FC_BSG_HST_ELS_NOLOGIN test into
>bsg_job->request->msgcode != FC_BSG_RPT_ELS.
>
>Signed-off-by: Bart Van Assche 
>Cc: Chad Dupuis 
>Cc: Saurav Kashyap 
>---
> drivers/scsi/qla2xxx/qla_bsg.c |   14 +++---
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
>diff --git a/drivers/scsi/qla2xxx/qla_bsg.c
>b/drivers/scsi/qla2xxx/qla_bsg.c
>index cf07491..f8a2634 100644
>--- a/drivers/scsi/qla2xxx/qla_bsg.c
>+++ b/drivers/scsi/qla2xxx/qla_bsg.c
>@@ -255,6 +255,12 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
>   int rval =  (DRIVER_ERROR << 16);
>   uint16_t nextlid = 0;
> 
>+  if (!vha->flags.online) {
>+  ql_log(ql_log_warn, vha, 0x7005, "Host not online.\n");
>+  rval = -EIO;
>+  goto done;
>+  }
>+
>   if (bsg_job->request->msgcode == FC_BSG_RPT_ELS) {
>   rport = bsg_job->rport;
>   fcport = *(fc_port_t **) rport->dd_data;
>@@ -326,12 +332,6 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job)
>   NPH_FABRIC_CONTROLLER : NPH_F_PORT;
>   }
> 
>-  if (!vha->flags.online) {
>-  ql_log(ql_log_warn, vha, 0x7005, "Host not online.\n");
>-  rval = -EIO;
>-  goto done;
>-  }
>-
>   req_sg_cnt =
>   dma_map_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list,
>   bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
>@@ -399,7 +399,7 @@ done_unmap_sg:
>   goto done_free_fcport;
> 
> done_free_fcport:
>-  if (bsg_job->request->msgcode == FC_BSG_HST_ELS_NOLOGIN)
>+  if (bsg_job->request->msgcode != FC_BSG_RPT_ELS)
>   kfree(fcport);
> done:
>   return rval;
>-- 
>1.7.10.4
>

<>

Re: [PATCH 07/10] qla2xxx: Help Coverity with analyzing ct_sns_pkt initialization

2013-06-12 Thread Saurav Kashyap
Acked-by: Saurav Kashyap 



>Coverity reports "Overrunning struct type ct_sns_req of 1228 bytes
>by passing it to a function which accesses it at byte offset 8207"
>for each qla2x00_prep_ct_req(), qla2x00_prep_ct_fdmi_req() and
>qla24xx_prep_ct_fm_req() call. Help Coverity to recognize that
>these calls do not trigger a buffer overflow by making it explicit
>that these three functions initializes both the request and reply
>structures. This patch does not change any functionality.
>
>Signed-off-by: Bart Van Assche 
>Cc: Chad Dupuis 
>Cc: Saurav Kashyap 
>---
> drivers/scsi/qla2xxx/qla_gs.c |   86
>++---
> 1 file changed, 38 insertions(+), 48 deletions(-)
>
>diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
>index f26442a..1ad361b 100644
>--- a/drivers/scsi/qla2xxx/qla_gs.c
>+++ b/drivers/scsi/qla2xxx/qla_gs.c
>@@ -99,17 +99,17 @@ qla24xx_prep_ms_iocb(scsi_qla_host_t *vha, uint32_t
>req_size, uint32_t rsp_size)
>  * Returns a pointer to the intitialized @ct_req.
>  */
> static inline struct ct_sns_req *
>-qla2x00_prep_ct_req(struct ct_sns_req *ct_req, uint16_t cmd, uint16_t
>rsp_size)
>+qla2x00_prep_ct_req(struct ct_sns_pkt *p, uint16_t cmd, uint16_t
>rsp_size)
> {
>-  memset(ct_req, 0, sizeof(struct ct_sns_pkt));
>+  memset(p, 0, sizeof(struct ct_sns_pkt));
> 
>-  ct_req->header.revision = 0x01;
>-  ct_req->header.gs_type = 0xFC;
>-  ct_req->header.gs_subtype = 0x02;
>-  ct_req->command = cpu_to_be16(cmd);
>-  ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4);
>+  p->p.req.header.revision = 0x01;
>+  p->p.req.header.gs_type = 0xFC;
>+  p->p.req.header.gs_subtype = 0x02;
>+  p->p.req.command = cpu_to_be16(cmd);
>+  p->p.req.max_rsp_size = cpu_to_be16((rsp_size - 16) / 4);
> 
>-  return (ct_req);
>+  return &p->p.req;
> }
> 
> static int
>@@ -188,8 +188,7 @@ qla2x00_ga_nxt(scsi_qla_host_t *vha, fc_port_t
>*fcport)
>   GA_NXT_RSP_SIZE);
> 
>   /* Prepare CT request */
>-  ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GA_NXT_CMD,
>-  GA_NXT_RSP_SIZE);
>+  ct_req = qla2x00_prep_ct_req(ha->ct_sns, GA_NXT_CMD, GA_NXT_RSP_SIZE);
>   ct_rsp = &ha->ct_sns->p.rsp;
> 
>   /* Prepare CT arguments -- port_id */
>@@ -284,8 +283,7 @@ qla2x00_gid_pt(scsi_qla_host_t *vha, sw_info_t *list)
>   gid_pt_rsp_size);
> 
>   /* Prepare CT request */
>-  ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GID_PT_CMD,
>-  gid_pt_rsp_size);
>+  ct_req = qla2x00_prep_ct_req(ha->ct_sns, GID_PT_CMD, gid_pt_rsp_size);
>   ct_rsp = &ha->ct_sns->p.rsp;
> 
>   /* Prepare CT arguments -- port_type */
>@@ -359,7 +357,7 @@ qla2x00_gpn_id(scsi_qla_host_t *vha, sw_info_t *list)
>   GPN_ID_RSP_SIZE);
> 
>   /* Prepare CT request */
>-  ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GPN_ID_CMD,
>+  ct_req = qla2x00_prep_ct_req(ha->ct_sns, GPN_ID_CMD,
>   GPN_ID_RSP_SIZE);
>   ct_rsp = &ha->ct_sns->p.rsp;
> 
>@@ -421,7 +419,7 @@ qla2x00_gnn_id(scsi_qla_host_t *vha, sw_info_t *list)
>   GNN_ID_RSP_SIZE);
> 
>   /* Prepare CT request */
>-  ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GNN_ID_CMD,
>+  ct_req = qla2x00_prep_ct_req(ha->ct_sns, GNN_ID_CMD,
>   GNN_ID_RSP_SIZE);
>   ct_rsp = &ha->ct_sns->p.rsp;
> 
>@@ -495,7 +493,7 @@ qla2x00_rft_id(scsi_qla_host_t *vha)
>   RFT_ID_RSP_SIZE);
> 
>   /* Prepare CT request */
>-  ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFT_ID_CMD,
>+  ct_req = qla2x00_prep_ct_req(ha->ct_sns, RFT_ID_CMD,
>   RFT_ID_RSP_SIZE);
>   ct_rsp = &ha->ct_sns->p.rsp;
> 
>@@ -551,8 +549,7 @@ qla2x00_rff_id(scsi_qla_host_t *vha)
>   RFF_ID_RSP_SIZE);
> 
>   /* Prepare CT request */
>-  ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFF_ID_CMD,
>-  RFF_ID_RSP_SIZE);
>+  ct_req = qla2x00_prep_ct_req(ha->ct_sns, RFF_ID_CMD, RFF_ID_RSP_SIZE);
>   ct_rsp = &ha->ct_sns->p.rsp;
> 
>   /* Prepare CT arguments -- port_id, FC-4 feature, FC-4 type */
>@@ -606,8 +603,7 @@ qla2x00_rnn_id(scsi_qla_host_t *vha)
>   RNN_ID_RSP_SIZE);
> 
>   /* Prepare CT request */
>-  ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RNN_ID_CMD,
>-  RNN_ID_RSP_SIZE);
>+  ct_req = qla2x00_prep_ct_req(ha->ct_sns, RNN_ID_CMD, RNN_ID_RSP_SIZE);
>   ct_rsp = &ha->ct_sns->p.rsp;
> 
>   /* Prepare CT arguments -- port_id, node_name */
>@@ -676,8 +672,7 @@ qla2x00_rsnn_nn(scsi_qla_host_t *vha)
>   ms_pkt = ha->isp_ops->prep_ms_iocb(vha, 0, RSNN_NN_RSP_SIZE);
> 
>   /* Prepare CT request */
>-  ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RSNN_NN_CMD,
>-  RSNN_NN_RSP_SIZE);
>+  ct_req = qla2x00_prep_ct_req(ha->ct_sns, RSNN_NN_CMD, RSNN_NN_RSP_SIZE);
>   ct_rsp = &ha->ct_sns->p.r

Re: [PATCH 06/10] qla2xxx: Remove redundant assignments

2013-06-12 Thread Saurav Kashyap
Acked-by: Saurav Kashyap 



>The value of the pointer called "nxt" is not used after the
>"nxt = qla24xx_copy_eft(ha, nxt)" statement. Hence keep the function
>call but remove the assignment.
>
>Signed-off-by: Bart Van Assche 
>Cc: Chad Dupuis 
>Cc: Saurav Kashyap 
>---
> drivers/scsi/qla2xxx/qla_dbg.c |6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/scsi/qla2xxx/qla_dbg.c
>b/drivers/scsi/qla2xxx/qla_dbg.c
>index cfa2a20..c612785 100644
>--- a/drivers/scsi/qla2xxx/qla_dbg.c
>+++ b/drivers/scsi/qla2xxx/qla_dbg.c
>@@ -1468,7 +1468,7 @@ qla25xx_fw_dump(scsi_qla_host_t *vha, int
>hardware_locked)
> 
>   nxt = qla2xxx_copy_queues(ha, nxt);
> 
>-  nxt = qla24xx_copy_eft(ha, nxt);
>+  qla24xx_copy_eft(ha, nxt);
> 
>   /* Chain entries -- started with MQ. */
>   nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain);
>@@ -1787,7 +1787,7 @@ qla81xx_fw_dump(scsi_qla_host_t *vha, int
>hardware_locked)
> 
>   nxt = qla2xxx_copy_queues(ha, nxt);
> 
>-  nxt = qla24xx_copy_eft(ha, nxt);
>+  qla24xx_copy_eft(ha, nxt);
> 
>   /* Chain entries -- started with MQ. */
>   nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain);
>@@ -2289,7 +2289,7 @@ qla83xx_fw_dump(scsi_qla_host_t *vha, int
>hardware_locked)
> copy_queue:
>   nxt = qla2xxx_copy_queues(ha, nxt);
> 
>-  nxt = qla24xx_copy_eft(ha, nxt);
>+  qla24xx_copy_eft(ha, nxt);
> 
>   /* Chain entries -- started with MQ. */
>   nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain);
>-- 
>1.7.10.4
>
>

<>

Re: [PATCH 09/10] qla2xxx: Remove an unused variable from qla2x00_remove_one()

2013-06-12 Thread Saurav Kashyap
Acked-by: Saurav Kashyap 



>Signed-off-by: Bart Van Assche 
>Cc: Chad Dupuis 
>Cc: Saurav Kashyap 
>---
> drivers/scsi/qla2xxx/qla_os.c |4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
>diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
>index 1d97626..2176cc9 100644
>--- a/drivers/scsi/qla2xxx/qla_os.c
>+++ b/drivers/scsi/qla2xxx/qla_os.c
>@@ -2980,14 +2980,12 @@ qla2x00_remove_one(struct pci_dev *pdev)
>   set_bit(UNLOADING, &base_vha->dpc_flags);
>   mutex_lock(&ha->vport_lock);
>   while (ha->cur_vport_count) {
>-  struct Scsi_Host *scsi_host;
>-
>   spin_lock_irqsave(&ha->vport_slock, flags);
> 
>   BUG_ON(base_vha->list.next == &ha->vp_list);
>   /* This assumes first entry in ha->vp_list is always base vha */
>   vha = list_first_entry(&base_vha->list, scsi_qla_host_t, list);
>-  scsi_host = scsi_host_get(vha->host);
>+  scsi_host_get(vha->host);
> 
>   spin_unlock_irqrestore(&ha->vport_slock, flags);
>   mutex_unlock(&ha->vport_lock);
>-- 
>1.7.10.4
>
>

<>

Re: [PATCH 08/10] qla2xxx: Fix qla2xxx_check_risc_status()

2013-06-12 Thread Saurav Kashyap
Acked-by: Saurav Kashyap 



>Change the 'rval' variable from QLA_FUNCTION_TIMEOUT into QLA_SUCCESS
>before starting a loop that is only executed if rval is initialized
>to QLA_SUCCESS. Coverity reported that loop as "dead code".
>
>Signed-off-by: Bart Van Assche 
>Cc: Chad Dupuis 
>Cc: Saurav Kashyap 
>---
> drivers/scsi/qla2xxx/qla_isr.c |1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/drivers/scsi/qla2xxx/qla_isr.c
>b/drivers/scsi/qla2xxx/qla_isr.c
>index 259d920..bd0e2fa 100644
>--- a/drivers/scsi/qla2xxx/qla_isr.c
>+++ b/drivers/scsi/qla2xxx/qla_isr.c
>@@ -2495,6 +2495,7 @@ qla2xxx_check_risc_status(scsi_qla_host_t *vha)
>   if (rval == QLA_SUCCESS)
>   goto next_test;
> 
>+  rval = QLA_SUCCESS;
>   WRT_REG_DWORD(®->iobase_window, 0x0003);
>   for (cnt = 100; (RD_REG_DWORD(®->iobase_window) & BIT_0) == 0 &&
>   rval == QLA_SUCCESS; cnt--) {
>-- 
>1.7.10.4
>
>

<>

Re: [PATCH 05/10] qla2xxx: Remove a dead assignment in qla24xx_build_scsi_crc_2_iocbs()

2013-06-12 Thread Saurav Kashyap
Acked-by: Saurav Kashyap 




>Since the value of cur_seg is not used and since scsi_prot_sglist()
>has no side effects it is safe to remove the statement
>"cur_seg = scsi_prot_sglist(cmd)". Detected by Coverity.
>
>Signed-off-by: Bart Van Assche 
>Cc: Chad Dupuis 
>Cc: Saurav Kashyap 
>---
> drivers/scsi/qla2xxx/qla_iocb.c |2 --
> 1 file changed, 2 deletions(-)
>
>diff --git a/drivers/scsi/qla2xxx/qla_iocb.c
>b/drivers/scsi/qla2xxx/qla_iocb.c
>index 15e4080..b589d24 100644
>--- a/drivers/scsi/qla2xxx/qla_iocb.c
>+++ b/drivers/scsi/qla2xxx/qla_iocb.c
>@@ -1189,7 +1189,6 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct
>cmd_type_crc_2 *cmd_pkt,
>   uint32_t*cur_dsd, *fcp_dl;
>   scsi_qla_host_t *vha;
>   struct scsi_cmnd*cmd;
>-  struct scatterlist  *cur_seg;
>   int sgc;
>   uint32_ttotal_bytes = 0;
>   uint32_tdata_bytes;
>@@ -1396,7 +1395,6 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct
>cmd_type_crc_2 *cmd_pkt,
> 
>   if (bundling && tot_prot_dsds) {
>   /* Walks dif segments */
>-  cur_seg = scsi_prot_sglist(cmd);
>   cmd_pkt->control_flags |=
>   __constant_cpu_to_le16(CF_DIF_SEG_DESCR_ENABLE);
>   cur_dsd = (uint32_t *) &crc_ctx_pkt->u.bundling.dif_address;
>-- 
>1.7.10.4
>
>

<>

Re: [PATCH 04/10] qla2xxx: Remove two superfluous tests

2013-06-12 Thread Saurav Kashyap
Acked-by: Saurav Kashyap 


>Since ha->model_desc is an array comparing it against NULL is
>superfluous. Hence remove these tests.
>
>Signed-off-by: Bart Van Assche 
>Cc: Chad Dupuis 
>Cc: Saurav Kashyap 
>---
> drivers/scsi/qla2xxx/qla_gs.c |3 +--
> drivers/scsi/qla2xxx/qla_os.c |3 +--
> 2 files changed, 2 insertions(+), 4 deletions(-)
>
>diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
>index d0ea8b9..f26442a 100644
>--- a/drivers/scsi/qla2xxx/qla_gs.c
>+++ b/drivers/scsi/qla2xxx/qla_gs.c
>@@ -1370,8 +1370,7 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *vha)
>   /* Model description. */
>   eiter = (struct ct_fdmi_hba_attr *) (entries + size);
>   eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION);
>-  if (ha->model_desc)
>-  strncpy(eiter->a.model_desc, ha->model_desc, 80);
>+  strncpy(eiter->a.model_desc, ha->model_desc, 80);
>   alen = strlen(eiter->a.model_desc);
>   alen += (alen & 3) ? (4 - (alen & 3)) : 4;
>   eiter->len = cpu_to_be16(4 + alen);
>diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
>index ad72c1d..1d97626 100644
>--- a/drivers/scsi/qla2xxx/qla_os.c
>+++ b/drivers/scsi/qla2xxx/qla_os.c
>@@ -2840,8 +2840,7 @@ skip_dpc:
>   qla2x00_dfs_setup(base_vha);
> 
>   ql_log(ql_log_info, base_vha, 0x00fb,
>-  "QLogic %s - %s.\n",
>-  ha->model_number, ha->model_desc ? ha->model_desc : "");
>+  "QLogic %s - %s.\n", ha->model_number, ha->model_desc);
>   ql_log(ql_log_info, base_vha, 0x00fc,
>   "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n",
>   pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info),
>-- 
>1.7.10.4
>
>

<>

Re: [PATCH 03/10] qla2xxx: Remove dead code in qla2x00_configure_hba()

2013-06-12 Thread Saurav Kashyap
Hi Bart,
I removed the success message also and updated the qla_dbg.c file.


diff --git a/drivers/scsi/qla2xxx/qla_dbg.c
b/drivers/scsi/qla2xxx/qla_dbg.c
index 1c1972b..dc227fa 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -15,6 +15,7 @@
  * | Mailbox commands |   0x117a   | 0x111a-0x111b  |
  * |  || 0x1155-0x1158  |
  * | Device Discovery |   0x2095   | 0x2020-0x2022, |
+ * |  || 0x2011-0x2012, |
  * |  || 0x2016 |
  * | Queue Command and IO tracing |   0x3058   | 0x3006-0x300b  |
  * |  || 0x3027-0x3028  |
diff --git a/drivers/scsi/qla2xxx/qla_init.c
b/drivers/scsi/qla2xxx/qla_init.c
index 8c7a123..c4fc8a2 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -2320,14 +2320,6 @@ qla2x00_configure_hba(scsi_qla_host_t *vha)
"Topology - %s, Host Loop address 0x%x.\n",
connect_type, vha->loop_id);
 
-   if (rval) {
-   ql_log(ql_log_warn, vha, 0x2011,
-   "%s FAILED\n", __func__);
-   } else {
-   ql_dbg(ql_dbg_disc, vha, 0x2012,
-   "%s success\n", __func__);
-   }
-
return(rval);
 }

Thanks,
~Saurav


>At the end of qla2x00_configure_hba() we know that rval == QLA_SUCCESS.
>Hence remove the code that depends on rval != QLA_SUCCESS.
>
>Signed-off-by: Bart Van Assche 
>Cc: Chad Dupuis 
>Cc: Saurav Kashyap 
>---
> drivers/scsi/qla2xxx/qla_init.c |8 +---
> 1 file changed, 1 insertion(+), 7 deletions(-)
>
>diff --git a/drivers/scsi/qla2xxx/qla_init.c
>b/drivers/scsi/qla2xxx/qla_init.c
>index 3565dfd..c68bb01 100644
>--- a/drivers/scsi/qla2xxx/qla_init.c
>+++ b/drivers/scsi/qla2xxx/qla_init.c
>@@ -2309,13 +2309,7 @@ qla2x00_configure_hba(scsi_qla_host_t *vha)
>   "Topology - %s, Host Loop address 0x%x.\n",
>   connect_type, vha->loop_id);
> 
>-  if (rval) {
>-  ql_log(ql_log_warn, vha, 0x2011,
>-  "%s FAILED\n", __func__);
>-  } else {
>-  ql_dbg(ql_dbg_disc, vha, 0x2012,
>-  "%s success\n", __func__);
>-  }
>+  ql_dbg(ql_dbg_disc, vha, 0x2012, "%s success\n", __func__);
> 
>   return(rval);
> }
>-- 
>1.7.10.4
>

<>

Re: [PATCH 02/10] qla2xxx: Clean up qla84xx_mgmt_cmd()

2013-06-12 Thread Saurav Kashyap
HI Bart,
Missing msg ids need to be updated on qla_dbg.c file. Here is an updated
patch.

diff --git a/drivers/scsi/qla2xxx/qla_bsg.c
b/drivers/scsi/qla2xxx/qla_bsg.c
index 25ded57..9520b1f 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -1084,14 +1084,6 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
return -EINVAL;
}
 
-   ql84_mgmt = (struct qla_bsg_a84_mgmt *)((char *)bsg_job->request +
-   sizeof(struct fc_bsg_request));
-   if (!ql84_mgmt) {
-   ql_log(ql_log_warn, vha, 0x703b,
-   "MGMT header not provided, exiting.\n");
-   return -EINVAL;
-   }
-
mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma);
if (!mn) {
ql_log(ql_log_warn, vha, 0x703c,
@@ -1102,7 +1094,7 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
memset(mn, 0, sizeof(struct access_chip_84xx));
mn->entry_type = ACCESS_CHIP_IOCB_TYPE;
mn->entry_count = 1;
-
+   ql84_mgmt = (void *)bsg_job->request + sizeof(struct
fc_bsg_request);
switch (ql84_mgmt->mgmt.cmd) {
case QLA84_MGMT_READ_MEM:
case QLA84_MGMT_GET_INFO:
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c
b/drivers/scsi/qla2xxx/qla_dbg.c
index 980dcbc..1c1972b 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -36,7 +36,7 @@
  * |  || 0x70a8,0x70ab, |
  * |  || 0x70ad-0x70ae, |
  * |  || 0x70d1-0x70da, |
- * |  || 0x7047
 |
+ * |  || 0x7047,0x703b |
  * | Task Management  |   0x803c   | 0x8025-0x8026  |
  * |  || 0x800b,0x8039  |
  * | AER/EEH  |   0x9011   |   |


Thanks,
~Saurav



>Remove dead code, simplify a pointer computation and move the
>ql84_mgmt assignment to just before its first use.
>
>Signed-off-by: Bart Van Assche 
>Cc: Chad Dupuis 
>Cc: Saurav Kashyap 
>---
> drivers/scsi/qla2xxx/qla_bsg.c |9 +
> 1 file changed, 1 insertion(+), 8 deletions(-)
>
>diff --git a/drivers/scsi/qla2xxx/qla_bsg.c
>b/drivers/scsi/qla2xxx/qla_bsg.c
>index 7221521..cf07491 100644
>--- a/drivers/scsi/qla2xxx/qla_bsg.c
>+++ b/drivers/scsi/qla2xxx/qla_bsg.c
>@@ -1084,14 +1084,6 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
>   return -EINVAL;
>   }
> 
>-  ql84_mgmt = (struct qla_bsg_a84_mgmt *)((char *)bsg_job->request +
>-  sizeof(struct fc_bsg_request));
>-  if (!ql84_mgmt) {
>-  ql_log(ql_log_warn, vha, 0x703b,
>-  "MGMT header not provided, exiting.\n");
>-  return -EINVAL;
>-  }
>-
>   mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma);
>   if (!mn) {
>   ql_log(ql_log_warn, vha, 0x703c,
>@@ -1103,6 +1095,7 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
>   mn->entry_type = ACCESS_CHIP_IOCB_TYPE;
>   mn->entry_count = 1;
> 
>+  ql84_mgmt = (void *)bsg_job->request + sizeof(struct fc_bsg_request);
>   switch (ql84_mgmt->mgmt.cmd) {
>   case QLA84_MGMT_READ_MEM:
>   case QLA84_MGMT_GET_INFO:
>-- 
>1.7.10.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 01/10] qla2xxx: Clean up qla24xx_iidma()

2013-06-12 Thread Saurav Kashyap
Hi Bart,
Missing msg ids needs to be updated in qla_dbg.c file. Here is an updated
patch

diff --git a/drivers/scsi/qla2xxx/qla_bsg.c
b/drivers/scsi/qla2xxx/qla_bsg.c
index 89dd050..25ded57 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -1282,14 +1282,7 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job)
return -EINVAL;
}
 
-   port_param = (struct qla_port_param *)((char *)bsg_job->request +
-   sizeof(struct fc_bsg_request));
-   if (!port_param) {
-   ql_log(ql_log_warn, vha, 0x7047,
-   "port_param header not provided.\n");
-   return -EINVAL;
-   }
-
+   port_param = (void *)bsg_job->request + sizeof(struct
fc_bsg_request);
if (port_param->fc_scsi_addr.dest_type != EXT_DEF_TYPE_WWPN) {
ql_log(ql_log_warn, vha, 0x7048,
"Invalid destination type.\n");
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c
b/drivers/scsi/qla2xxx/qla_dbg.c
index 94f3a25..980dcbc 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -35,7 +35,8 @@
  * |  || 0x70a5,0x70a6, |
  * |  || 0x70a8,0x70ab, |
  * |  || 0x70ad-0x70ae, |
- * |  || 0x70d1-0x70da  |
+ * |  || 0x70d1-0x70da, |
+ * |  || 0x7047
 |
  * | Task Management  |   0x803c   | 0x8025-0x8026  |
  * |  || 0x800b,0x8039  |
  * | AER/EEH  |   0x9011   |   |


Thanks,
~Saurav



>Remove dead code and simplify a pointer computation.
>
>Signed-off-by: Bart Van Assche 
>Cc: Chad Dupuis 
>Cc: Saurav Kashyap 
>---
> drivers/scsi/qla2xxx/qla_bsg.c |9 +
> 1 file changed, 1 insertion(+), 8 deletions(-)
>
>diff --git a/drivers/scsi/qla2xxx/qla_bsg.c
>b/drivers/scsi/qla2xxx/qla_bsg.c
>index 39719f8..7221521 100644
>--- a/drivers/scsi/qla2xxx/qla_bsg.c
>+++ b/drivers/scsi/qla2xxx/qla_bsg.c
>@@ -1282,14 +1282,7 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job)
>   return -EINVAL;
>   }
> 
>-  port_param = (struct qla_port_param *)((char *)bsg_job->request +
>-  sizeof(struct fc_bsg_request));
>-  if (!port_param) {
>-  ql_log(ql_log_warn, vha, 0x7047,
>-  "port_param header not provided.\n");
>-  return -EINVAL;
>-  }
>-
>+  port_param = (void *)bsg_job->request + sizeof(struct fc_bsg_request);
>   if (port_param->fc_scsi_addr.dest_type != EXT_DEF_TYPE_WWPN) {
>   ql_log(ql_log_warn, vha, 0x7048,
>   "Invalid destination type.\n");
>-- 
>1.7.10.4
>

<>

Re: [PATCH 0/10] qla2xxx: Reduce the number of Coverity warnings

2013-06-12 Thread Saurav Kashyap
Hi Bart,
Thanks for patchset. There are minor issue with some patches like updating
the missing msg_ids in qla_dbg.c file. I am replying to each of the patch.

Thanks,
~Saurav


>On 06/07/13 21:06, Saurav Kashyap wrote:
>> Thanks for the patches. Please share the warnings reported by Coverity,
>>so
>> that its easy for us to review the patches.
>
>Hello Saurav,
>
>The Coverity warnings that led me to developing this patch series are as
>follows:
>- For patches 1, 2, 3, 8: Logically dead code - execution cannot reach
>this statement.
>- For patch 4: Array compared against 0 (NO_EFFECT) array_null:
>Comparing an array to null is not useful: "ha->model_desc".
>- For patch 5, 6 and 9: Unused pointer value.
>- For patch 7: Overrunning struct type ct_sns_req of 1228 bytes by
>passing it to a function which accesses it at byte offset 8207.
>- For patch 10: Resource leak (RESOURCE_LEAK) leaked_storage: Variable
>"fcport" going out of scope leaks the storage it points to.
>
>Hope this helps,
>
>Bart.
>

<>

Re: [PATCH 1/2] [SCSI] ufshcd-pltfrm: remove unnecessary dma_set_coherent_mask() call

2013-06-12 Thread Santosh Y
On Sun, Jun 9, 2013 at 4:49 PM, Akinobu Mita  wrote:
> Changing the device coherent dma mask to the value that currently set
> has no effect.
>
> Signed-off-by: Akinobu Mita 
> Cc: Vinayak Holikatti 
> Cc: Santosh Y 
> Cc: "James E.J. Bottomley" 
> Cc: linux-scsi@vger.kernel.org
> ---
>  drivers/scsi/ufs/ufshcd-pltfrm.c | 7 ---
>  1 file changed, 7 deletions(-)
>
> diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c 
> b/drivers/scsi/ufs/ufshcd-pltfrm.c
> index 0014e28..969c9bc 100644
> --- a/drivers/scsi/ufs/ufshcd-pltfrm.c
> +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
> @@ -100,7 +100,6 @@ static int ufshcd_pltfrm_probe(struct platform_device 
> *pdev)
> struct resource *irq_res;
> resource_size_t mem_size;
> int err;
> -   struct device *dev = &pdev->dev;
>
> mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> if (!mem_res) {
> @@ -132,12 +131,6 @@ static int ufshcd_pltfrm_probe(struct platform_device 
> *pdev)
> goto out_iounmap;
> }
>
> -   err = dma_set_coherent_mask(dev, dev->coherent_dma_mask);
> -   if (err) {
> -   dev_err(&pdev->dev, "set dma mask failed\n");
> -   goto out_iounmap;
> -   }
> -
> err = ufshcd_init(&pdev->dev, &hba, mmio_base, irq_res->start);
> if (err) {
> dev_err(&pdev->dev, "Intialization failed\n");
> --
> 1.8.1.4
>

Acked-by: Santosh Y 

-- 
~Santosh
--
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/2] [SCSI] ufs: fix DMA mask setting

2013-06-12 Thread Santosh Y
On Sun, Jun 9, 2013 at 4:49 PM, Akinobu Mita  wrote:
> If the controller doesn't support 64-bit addressing mode, it must not
> set the DMA mask to 64-bit.  But it's unconditionally trying to set to
> 64-bit without checking 64-bit addressing support in the controller
> capabilities.
>
> It was correctly checked before commit 
> 3b1d05807a9a68c6d0580e9248247a774a4d3be6
> ("[SCSI] ufs: Segregate PCI Specific Code"), this aims to restores
> the correct behaviour.
>
> To achieve this in a generic way, firstly we should push down the DMA
> mask setting routine ufshcd_set_dma_mask() from PCI glue driver to core
> driver in order to do it for both PCI glue driver and Platform glue
> driver.  Secondly, we should change pci_ DMA mapping API to dma_ DMA
> mapping API because core driver is independent of glue drivers.
>
> Lastly, we need to relax dma_set_mask(dev, DMA_BIT_MASK(32)) error check
> for platform devices on ARM, which do not have a valid dma_mask pointer.
>
> Signed-off-by: Akinobu Mita 
> Cc: Vinayak Holikatti 
> Cc: Santosh Y 
> Cc: "James E.J. Bottomley" 
> Cc: linux-scsi@vger.kernel.org
> ---
>  drivers/scsi/ufs/ufshcd-pci.c | 26 --
>  drivers/scsi/ufs/ufshcd.c | 25 +
>  2 files changed, 25 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
> index 5cb1d75..6835520 100644
> --- a/drivers/scsi/ufs/ufshcd-pci.c
> +++ b/drivers/scsi/ufs/ufshcd-pci.c
> @@ -101,26 +101,6 @@ static void ufshcd_pci_remove(struct pci_dev *pdev)
>  }
>
>  /**
> - * ufshcd_set_dma_mask - Set dma mask based on the controller
> - *  addressing capability
> - * @pdev: PCI device structure
> - *
> - * Returns 0 for success, non-zero for failure
> - */
> -static int ufshcd_set_dma_mask(struct pci_dev *pdev)
> -{
> -   int err;
> -
> -   if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))
> -   && !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)))
> -   return 0;
> -   err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
> -   if (!err)
> -   err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
> -   return err;
> -}
> -
> -/**
>   * ufshcd_pci_probe - probe routine of the driver
>   * @pdev: pointer to PCI device handle
>   * @id: PCI device id
> @@ -156,12 +136,6 @@ ufshcd_pci_probe(struct pci_dev *pdev, const struct 
> pci_device_id *id)
> goto out_release_regions;
> }
>
> -   err = ufshcd_set_dma_mask(pdev);
> -   if (err) {
> -   dev_err(&pdev->dev, "set dma mask failed\n");
> -   goto out_iounmap;
> -   }
> -
> err = ufshcd_init(&pdev->dev, &hba, mmio_base, pdev->irq);
> if (err) {
> dev_err(&pdev->dev, "Initialization failed\n");
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 492f2b7..7f5399c 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -1598,6 +1598,25 @@ void ufshcd_remove(struct ufs_hba *hba)
>  EXPORT_SYMBOL_GPL(ufshcd_remove);
>
>  /**
> + * ufshcd_set_dma_mask - Set dma mask based on the controller
> + *  addressing capability
> + * @hba: per adapter instance
> + *
> + * Returns 0 for success, non-zero for failure
> + */
> +static int ufshcd_set_dma_mask(struct ufs_hba *hba)
> +{
> +   if (hba->capabilities & MASK_64_ADDRESSING_SUPPORT) {
> +   if (!dma_set_mask(hba->dev, DMA_BIT_MASK(64)) &&
> +   !dma_set_coherent_mask(hba->dev, DMA_BIT_MASK(64)))
> +   return 0;
> +   }
> +   dma_set_mask(hba->dev, DMA_BIT_MASK(32));
> +
> +   return dma_set_coherent_mask(hba->dev, DMA_BIT_MASK(32));
> +}
> +
> +/**
>   * ufshcd_init - Driver initialization routine
>   * @dev: pointer to device handle
>   * @hba_handle: driver private handle
> @@ -1645,6 +1664,12 @@ int ufshcd_init(struct device *dev, struct ufs_hba 
> **hba_handle,
> /* Get UFS version supported by the controller */
> hba->ufs_version = ufshcd_get_ufs_version(hba);
>
> +   err = ufshcd_set_dma_mask(hba);
> +   if (err) {
> +   dev_err(hba->dev, "set dma mask failed\n");
> +   goto out_disable;
> +   }
> +
> /* Allocate memory for host memory space */
> err = ufshcd_memory_alloc(hba);
> if (err) {
> --
> 1.8.1.4
>

Acked-by: Santosh Y 

-- 
~Santosh
--
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: [SCSI] ufs: Add missing dependency on CONFIG_HAS_IOMEM

2013-06-12 Thread Santosh Y
On Mon, Jun 10, 2013 at 1:34 AM, Ben Hutchings  wrote:
> The ufs driver doesn't build on s390 with CONFIG_PCI disabled as it
> requires MMIO functions.
>
> Marking for 3.9-stable only as CONFIG_SCSI_UFSHCD was previously
> dependent on CONFIG_PCI.
>
> Signed-off-by: Ben Hutchings 
> Cc: sta...@vger.kernel.org # 3.9
> ---
> --- a/drivers/scsi/ufs/Kconfig
> +++ b/drivers/scsi/ufs/Kconfig
> @@ -34,7 +34,7 @@
>
>  config SCSI_UFSHCD
> tristate "Universal Flash Storage Controller Driver Core"
> -   depends on SCSI
> +   depends on SCSI && HAS_IOMEM
> ---help---
> This selects the support for UFS devices in Linux, say Y and make
>   sure that you know the name of your UFS host adapter (the card
>

Acked-by: Santosh Y 

-- 
~Santosh
--
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