Re: [PATCH 05/12] blk-mq: Introduce blk_mq_quiesce_queue()

2016-10-26 Thread Hannes Reinecke
On 10/27/2016 12:53 AM, Bart Van Assche wrote:
> blk_mq_quiesce_queue() waits until ongoing .queue_rq() invocations
> have finished. This function does *not* wait until all outstanding
> requests have finished (this means invocation of request.end_io()).
> The algorithm used by blk_mq_quiesce_queue() is as follows:
> * Hold either an RCU read lock or an SRCU read lock around
>   .queue_rq() calls. The former is used if .queue_rq() does not
>   block and the latter if .queue_rq() may block.
> * blk_mq_quiesce_queue() calls synchronize_srcu() or
>   synchronize_rcu() to wait for .queue_rq() invocations that
>   started before blk_mq_quiesce_queue() was called.
> * The blk_mq_hctx_stopped() calls that control whether or not
>   .queue_rq() will be called are called with the (S)RCU read lock
>   held. This is necessary to avoid race conditions against
>   the "blk_mq_stop_hw_queues(q); blk_mq_quiesce_queue(q);"
>   sequence from another thread.
> 
> Signed-off-by: Bart Van Assche 
> Cc: Christoph Hellwig 
> Cc: Ming Lei 
> Cc: Hannes Reinecke 
> Cc: Johannes Thumshirn 
> ---
>  block/Kconfig  |  1 +
>  block/blk-mq.c | 69 
> +-
>  include/linux/blk-mq.h |  3 +++
>  include/linux/blkdev.h |  1 +
>  4 files changed, 67 insertions(+), 7 deletions(-)
> 
Hmm. Can't say I like having to have two RCU structure for the same
purpose, but I guess that can't be helped.

Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
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 04/12] blk-mq: Move more code into blk_mq_direct_issue_request()

2016-10-26 Thread Hannes Reinecke
On 10/27/2016 12:52 AM, Bart Van Assche wrote:
> Move the "hctx stopped" test and the insert request calls into
> blk_mq_direct_issue_request(). Rename that function into
> blk_mq_try_issue_directly() to reflect its new semantics. Pass
> the hctx pointer to that function instead of looking it up a
> second time. These changes avoid that code has to be duplicated
> in the next patch.
> 
> Signed-off-by: Bart Van Assche 
> Cc: Christoph Hellwig 
> Cc: Hannes Reinecke 
> Cc: Sagi Grimberg 
> Cc: Johannes Thumshirn 
> ---
>  block/blk-mq.c | 18 ++
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
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 03/12] blk-mq: Introduce blk_mq_queue_stopped()

2016-10-26 Thread Hannes Reinecke
On 10/27/2016 12:52 AM, Bart Van Assche wrote:
> The function blk_queue_stopped() allows to test whether or not a
> traditional request queue has been stopped. Introduce a helper
> function that allows block drivers to query easily whether or not
> one or more hardware contexts of a blk-mq queue have been stopped.
> 
> Signed-off-by: Bart Van Assche 
> Reviewed-by: Hannes Reinecke 
> Reviewed-by: Johannes Thumshirn 
> Reviewed-by: Sagi Grimberg 
> Reviewed-by: Christoph Hellwig 
> ---
>  block/blk-mq.c | 20 
>  include/linux/blk-mq.h |  1 +
>  2 files changed, 21 insertions(+)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
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/12] blk-mq: Do not invoke .queue_rq() for a stopped queue

2016-10-26 Thread Hannes Reinecke
On 10/27/2016 12:50 AM, Bart Van Assche wrote:
> The meaning of the BLK_MQ_S_STOPPED flag is "do not call
> .queue_rq()". Hence modify blk_mq_make_request() such that requests
> are queued instead of issued if a queue has been stopped.
> 
> Reported-by: Ming Lei 
> Signed-off-by: Bart Van Assche 
> Reviewed-by: Christoph Hellwig 
> Reviewed-by: Ming Lei 
> Cc: Hannes Reinecke 
> Cc: Sagi Grimberg 
> Cc: Johannes Thumshirn 
> Cc: 
> ---
>  block/blk-mq.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index ddc2eed..b5dcafb 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -1332,9 +1332,9 @@ static blk_qc_t blk_mq_make_request(struct 
> request_queue *q, struct bio *bio)
>   blk_mq_put_ctx(data.ctx);
>   if (!old_rq)
>   goto done;
> - if (!blk_mq_direct_issue_request(old_rq, ))
> - goto done;
> - blk_mq_insert_request(old_rq, false, true, true);
> + if (test_bit(BLK_MQ_S_STOPPED, >state) ||
> + blk_mq_direct_issue_request(old_rq, ) != 0)
> + blk_mq_insert_request(old_rq, false, true, true);
>   goto done;
>   }
>  
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
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 05/12] blk-mq: Introduce blk_mq_quiesce_queue()

2016-10-26 Thread Bart Van Assche

On 10/26/16 19:31, Ming Lei wrote:

On Thu, Oct 27, 2016 at 10:04 AM, Bart Van Assche  wrote:

On 10/26/16 18:30, Ming Lei wrote:


On Thu, Oct 27, 2016 at 6:53 AM, Bart Van Assche
 wrote:


blk_mq_quiesce_queue() waits until ongoing .queue_rq() invocations
have finished. This function does *not* wait until all outstanding
requests have finished (this means invocation of request.end_io()).
The algorithm used by blk_mq_quiesce_queue() is as follows:
* Hold either an RCU read lock or an SRCU read lock around
  .queue_rq() calls. The former is used if .queue_rq() does not
  block and the latter if .queue_rq() may block.
* blk_mq_quiesce_queue() calls synchronize_srcu() or
  synchronize_rcu() to wait for .queue_rq() invocations that
  started before blk_mq_quiesce_queue() was called.
* The blk_mq_hctx_stopped() calls that control whether or not
  .queue_rq() will be called are called with the (S)RCU read lock
  held. This is necessary to avoid race conditions against
  the "blk_mq_stop_hw_queues(q); blk_mq_quiesce_queue(q);"
  sequence from another thread.

Signed-off-by: Bart Van Assche 
Cc: Christoph Hellwig 
Cc: Ming Lei 
Cc: Hannes Reinecke 
Cc: Johannes Thumshirn 
---
 block/Kconfig  |  1 +
 block/blk-mq.c | 69
+-
 include/linux/blk-mq.h |  3 +++
 include/linux/blkdev.h |  1 +
 4 files changed, 67 insertions(+), 7 deletions(-)

diff --git a/block/Kconfig b/block/Kconfig
index 1d4d624..0562ef9 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -5,6 +5,7 @@ menuconfig BLOCK
bool "Enable the block layer" if EXPERT
default y
select SBITMAP
+   select SRCU
help
 Provide block layer support for the kernel.

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 0cf21c2..4945437 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -115,6 +115,31 @@ void blk_mq_unfreeze_queue(struct request_queue *q)
 }
 EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue);

+/**
+ * blk_mq_quiesce_queue() - wait until all ongoing queue_rq calls have
finished
+ * @q: request queue.
+ *
+ * Note: this function does not prevent that the struct request end_io()
+ * callback function is invoked. Additionally, it is not prevented that
+ * new queue_rq() calls occur unless the queue has been stopped first.
+ */
+void blk_mq_quiesce_queue(struct request_queue *q)
+{
+   struct blk_mq_hw_ctx *hctx;
+   unsigned int i;
+   bool rcu = false;



Before synchronizing SRCU/RCU, we have to set a per-hctx flag
or per-queue flag to block comming .queue_rq(), seems I mentioned
that before:

   https://www.spinics.net/lists/linux-rdma/msg41389.html



Hello Ming,

Thanks for having included an URL to an archived version of that discussion.
What I remember about that discussion is that I proposed to use the existing
flag BLK_MQ_S_STOPPED instead of introducing a
new QUEUE_FLAG_QUIESCING flag and that you agreed with that proposal. See
also https://www.spinics.net/lists/linux-rdma/msg41430.html.


Yes, I am fine with either one, but the flag need to set in
blk_mq_quiesce_queue(), doesnt't it?


Hello Ming,

If you have a look at the later patches in this series then you will see 
that the dm core and the NVMe driver have been modified such that
blk_mq_stop_hw_queues(q) is called immediately before 
blk_mq_quiesce_queue(q) is called.


Bart.
--
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 05/12] blk-mq: Introduce blk_mq_quiesce_queue()

2016-10-26 Thread Bart Van Assche

On 10/26/16 18:30, Ming Lei wrote:

On Thu, Oct 27, 2016 at 6:53 AM, Bart Van Assche
 wrote:

blk_mq_quiesce_queue() waits until ongoing .queue_rq() invocations
have finished. This function does *not* wait until all outstanding
requests have finished (this means invocation of request.end_io()).
The algorithm used by blk_mq_quiesce_queue() is as follows:
* Hold either an RCU read lock or an SRCU read lock around
  .queue_rq() calls. The former is used if .queue_rq() does not
  block and the latter if .queue_rq() may block.
* blk_mq_quiesce_queue() calls synchronize_srcu() or
  synchronize_rcu() to wait for .queue_rq() invocations that
  started before blk_mq_quiesce_queue() was called.
* The blk_mq_hctx_stopped() calls that control whether or not
  .queue_rq() will be called are called with the (S)RCU read lock
  held. This is necessary to avoid race conditions against
  the "blk_mq_stop_hw_queues(q); blk_mq_quiesce_queue(q);"
  sequence from another thread.

Signed-off-by: Bart Van Assche 
Cc: Christoph Hellwig 
Cc: Ming Lei 
Cc: Hannes Reinecke 
Cc: Johannes Thumshirn 
---
 block/Kconfig  |  1 +
 block/blk-mq.c | 69 +-
 include/linux/blk-mq.h |  3 +++
 include/linux/blkdev.h |  1 +
 4 files changed, 67 insertions(+), 7 deletions(-)

diff --git a/block/Kconfig b/block/Kconfig
index 1d4d624..0562ef9 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -5,6 +5,7 @@ menuconfig BLOCK
bool "Enable the block layer" if EXPERT
default y
select SBITMAP
+   select SRCU
help
 Provide block layer support for the kernel.

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 0cf21c2..4945437 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -115,6 +115,31 @@ void blk_mq_unfreeze_queue(struct request_queue *q)
 }
 EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue);

+/**
+ * blk_mq_quiesce_queue() - wait until all ongoing queue_rq calls have finished
+ * @q: request queue.
+ *
+ * Note: this function does not prevent that the struct request end_io()
+ * callback function is invoked. Additionally, it is not prevented that
+ * new queue_rq() calls occur unless the queue has been stopped first.
+ */
+void blk_mq_quiesce_queue(struct request_queue *q)
+{
+   struct blk_mq_hw_ctx *hctx;
+   unsigned int i;
+   bool rcu = false;


Before synchronizing SRCU/RCU, we have to set a per-hctx flag
or per-queue flag to block comming .queue_rq(), seems I mentioned
that before:

   https://www.spinics.net/lists/linux-rdma/msg41389.html


Hello Ming,

Thanks for having included an URL to an archived version of that 
discussion. What I remember about that discussion is that I proposed to 
use the existing flag BLK_MQ_S_STOPPED instead of introducing a
new QUEUE_FLAG_QUIESCING flag and that you agreed with that proposal. 
See also https://www.spinics.net/lists/linux-rdma/msg41430.html.


Bart.
--
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 05/12] blk-mq: Introduce blk_mq_quiesce_queue()

2016-10-26 Thread Bart Van Assche

On 10/26/16 19:48, Ming Lei wrote:

On Thu, Oct 27, 2016 at 10:40 AM, Bart Van Assche  wrote:

If you have a look at the later patches in this series then you will see
that the dm core and the NVMe driver have been modified such that
blk_mq_stop_hw_queues(q) is called immediately before
blk_mq_quiesce_queue(q) is called.


Cause any current and future users of blk_mq_quiesce_queue(q)
have to set the flag via blk_mq_stop_hw_queues(q), why not set
the flag explicitly in blk_mq_quiesce_queue(q)?


Hello Ming,

I'll leave it to Jens to decide whether I should repost the patch series 
with this change integrated or whether to realize this change with a 
follow-up patch.


Bart.

--
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 05/12] blk-mq: Introduce blk_mq_quiesce_queue()

2016-10-26 Thread Ming Lei
On Thu, Oct 27, 2016 at 10:40 AM, Bart Van Assche  wrote:
> On 10/26/16 19:31, Ming Lei wrote:
>>
>> On Thu, Oct 27, 2016 at 10:04 AM, Bart Van Assche 
>> wrote:
>>>
>>> On 10/26/16 18:30, Ming Lei wrote:


 On Thu, Oct 27, 2016 at 6:53 AM, Bart Van Assche
  wrote:
>
>
> blk_mq_quiesce_queue() waits until ongoing .queue_rq() invocations
> have finished. This function does *not* wait until all outstanding
> requests have finished (this means invocation of request.end_io()).
> The algorithm used by blk_mq_quiesce_queue() is as follows:
> * Hold either an RCU read lock or an SRCU read lock around
>   .queue_rq() calls. The former is used if .queue_rq() does not
>   block and the latter if .queue_rq() may block.
> * blk_mq_quiesce_queue() calls synchronize_srcu() or
>   synchronize_rcu() to wait for .queue_rq() invocations that
>   started before blk_mq_quiesce_queue() was called.
> * The blk_mq_hctx_stopped() calls that control whether or not
>   .queue_rq() will be called are called with the (S)RCU read lock
>   held. This is necessary to avoid race conditions against
>   the "blk_mq_stop_hw_queues(q); blk_mq_quiesce_queue(q);"
>   sequence from another thread.
>
> Signed-off-by: Bart Van Assche 
> Cc: Christoph Hellwig 
> Cc: Ming Lei 
> Cc: Hannes Reinecke 
> Cc: Johannes Thumshirn 
> ---
>  block/Kconfig  |  1 +
>  block/blk-mq.c | 69
> +-
>  include/linux/blk-mq.h |  3 +++
>  include/linux/blkdev.h |  1 +
>  4 files changed, 67 insertions(+), 7 deletions(-)
>
> diff --git a/block/Kconfig b/block/Kconfig
> index 1d4d624..0562ef9 100644
> --- a/block/Kconfig
> +++ b/block/Kconfig
> @@ -5,6 +5,7 @@ menuconfig BLOCK
> bool "Enable the block layer" if EXPERT
> default y
> select SBITMAP
> +   select SRCU
> help
>  Provide block layer support for the kernel.
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 0cf21c2..4945437 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -115,6 +115,31 @@ void blk_mq_unfreeze_queue(struct request_queue
> *q)
>  }
>  EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue);
>
> +/**
> + * blk_mq_quiesce_queue() - wait until all ongoing queue_rq calls have
> finished
> + * @q: request queue.
> + *
> + * Note: this function does not prevent that the struct request
> end_io()
> + * callback function is invoked. Additionally, it is not prevented
> that
> + * new queue_rq() calls occur unless the queue has been stopped first.
> + */
> +void blk_mq_quiesce_queue(struct request_queue *q)
> +{
> +   struct blk_mq_hw_ctx *hctx;
> +   unsigned int i;
> +   bool rcu = false;



 Before synchronizing SRCU/RCU, we have to set a per-hctx flag
 or per-queue flag to block comming .queue_rq(), seems I mentioned
 that before:

https://www.spinics.net/lists/linux-rdma/msg41389.html
>>>
>>>
>>>
>>> Hello Ming,
>>>
>>> Thanks for having included an URL to an archived version of that
>>> discussion.
>>> What I remember about that discussion is that I proposed to use the
>>> existing
>>> flag BLK_MQ_S_STOPPED instead of introducing a
>>> new QUEUE_FLAG_QUIESCING flag and that you agreed with that proposal. See
>>> also https://www.spinics.net/lists/linux-rdma/msg41430.html.
>>
>>
>> Yes, I am fine with either one, but the flag need to set in
>> blk_mq_quiesce_queue(), doesnt't it?
>
>
> Hello Ming,
>
> If you have a look at the later patches in this series then you will see
> that the dm core and the NVMe driver have been modified such that
> blk_mq_stop_hw_queues(q) is called immediately before
> blk_mq_quiesce_queue(q) is called.

Cause any current and future users of blk_mq_quiesce_queue(q)
have to set the flag via blk_mq_stop_hw_queues(q), why not set
the flag explicitly in blk_mq_quiesce_queue(q)?


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


Re: [PATCH 05/12] blk-mq: Introduce blk_mq_quiesce_queue()

2016-10-26 Thread Ming Lei
On Thu, Oct 27, 2016 at 10:04 AM, Bart Van Assche  wrote:
> On 10/26/16 18:30, Ming Lei wrote:
>>
>> On Thu, Oct 27, 2016 at 6:53 AM, Bart Van Assche
>>  wrote:
>>>
>>> blk_mq_quiesce_queue() waits until ongoing .queue_rq() invocations
>>> have finished. This function does *not* wait until all outstanding
>>> requests have finished (this means invocation of request.end_io()).
>>> The algorithm used by blk_mq_quiesce_queue() is as follows:
>>> * Hold either an RCU read lock or an SRCU read lock around
>>>   .queue_rq() calls. The former is used if .queue_rq() does not
>>>   block and the latter if .queue_rq() may block.
>>> * blk_mq_quiesce_queue() calls synchronize_srcu() or
>>>   synchronize_rcu() to wait for .queue_rq() invocations that
>>>   started before blk_mq_quiesce_queue() was called.
>>> * The blk_mq_hctx_stopped() calls that control whether or not
>>>   .queue_rq() will be called are called with the (S)RCU read lock
>>>   held. This is necessary to avoid race conditions against
>>>   the "blk_mq_stop_hw_queues(q); blk_mq_quiesce_queue(q);"
>>>   sequence from another thread.
>>>
>>> Signed-off-by: Bart Van Assche 
>>> Cc: Christoph Hellwig 
>>> Cc: Ming Lei 
>>> Cc: Hannes Reinecke 
>>> Cc: Johannes Thumshirn 
>>> ---
>>>  block/Kconfig  |  1 +
>>>  block/blk-mq.c | 69
>>> +-
>>>  include/linux/blk-mq.h |  3 +++
>>>  include/linux/blkdev.h |  1 +
>>>  4 files changed, 67 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/block/Kconfig b/block/Kconfig
>>> index 1d4d624..0562ef9 100644
>>> --- a/block/Kconfig
>>> +++ b/block/Kconfig
>>> @@ -5,6 +5,7 @@ menuconfig BLOCK
>>> bool "Enable the block layer" if EXPERT
>>> default y
>>> select SBITMAP
>>> +   select SRCU
>>> help
>>>  Provide block layer support for the kernel.
>>>
>>> diff --git a/block/blk-mq.c b/block/blk-mq.c
>>> index 0cf21c2..4945437 100644
>>> --- a/block/blk-mq.c
>>> +++ b/block/blk-mq.c
>>> @@ -115,6 +115,31 @@ void blk_mq_unfreeze_queue(struct request_queue *q)
>>>  }
>>>  EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue);
>>>
>>> +/**
>>> + * blk_mq_quiesce_queue() - wait until all ongoing queue_rq calls have
>>> finished
>>> + * @q: request queue.
>>> + *
>>> + * Note: this function does not prevent that the struct request end_io()
>>> + * callback function is invoked. Additionally, it is not prevented that
>>> + * new queue_rq() calls occur unless the queue has been stopped first.
>>> + */
>>> +void blk_mq_quiesce_queue(struct request_queue *q)
>>> +{
>>> +   struct blk_mq_hw_ctx *hctx;
>>> +   unsigned int i;
>>> +   bool rcu = false;
>>
>>
>> Before synchronizing SRCU/RCU, we have to set a per-hctx flag
>> or per-queue flag to block comming .queue_rq(), seems I mentioned
>> that before:
>>
>>https://www.spinics.net/lists/linux-rdma/msg41389.html
>
>
> Hello Ming,
>
> Thanks for having included an URL to an archived version of that discussion.
> What I remember about that discussion is that I proposed to use the existing
> flag BLK_MQ_S_STOPPED instead of introducing a
> new QUEUE_FLAG_QUIESCING flag and that you agreed with that proposal. See
> also https://www.spinics.net/lists/linux-rdma/msg41430.html.

Yes, I am fine with either one, but the flag need to set in
blk_mq_quiesce_queue(), doesnt't it?


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


Re: [PATCH] scsi_debug: Fix memory leak if LBP enabled and module is unloaded

2016-10-26 Thread Martin K. Petersen
> "Ewan" == Ewan D Milne  writes:

Ewan> map_storep was not being vfree()'d in the module_exit call.

Applied to 4.9/scsi-fixes.

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


Re: [PATCH 4/7] megaraid_sas: Send SYNCHRONIZE_CACHE command to firmware

2016-10-26 Thread Martin K. Petersen
> "ching" == 黃清隆   writes:

ching,

ching> Yes. Passing SYNCHRONIZE_CACHE command to firmware is safe for
ching> all Areca Raid controllers, even the oldest.

I applied your patch to 4.9/scsi-fixes.

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


Re: [PATCH v2 00/11] mpt3sas driver Enhancements and

2016-10-26 Thread Martin K. Petersen
> "Suganath" == Suganath Prabu S  
> writes:

Suganath> Here is the change list: Posting 11 patches for mpt3sas driver
Suganath> enhancements and few fixes.
Suganath>   * Added Device ID's for SAS35 devices and updated MPI
Suganath> Header.
Suganath>   * Support "EEDP Escape flag" for SAS35 devices.
Suganath>   * fixed improper printk statement.
Suganath>   * Regardless of whether RDPQ disabled card is enumerated
Suganath> first or RDPQ enabled card is enumerated first, MSIX
Suganath> vectors depends on the cards capability.
Suganath>   * device_remove_in_progress bit check has been added in
Suganath> IOCTL path. If bit is set, then IOCTL will be failed
Suganath> printing failure message.
Suganath>   * Started using the Atomic Request Descriptors for
Suganath> SAS35 devices.
Suganath>   * For SAS35 devices MSIX vectors are inceased to 128 from
Suganath> 96.
Suganath>   * Fixing Endianness issue.
Suganath>   * Updated driver version to 14.100.00.00 at the end of SAS3
Suganath> changes and updated driver minor version to 14.101.00.00
Suganath> after SAS35 changes.

Applied to 4.10/scsi-queue.

Thanks!

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


Re: [PATCH] advansys: fix build warning for PCI=n

2016-10-26 Thread Martin K. Petersen
> "Arnd" == Arnd Bergmann  writes:

Arnd> The advansys probe function tries to handle both ISA and PCI
Arnd> cases, each hidden in an #ifdef when unused. This leads to a
Arnd> warning indicating that when PCI is disabled we could be using
Arnd> uninitialized data:

Arnd> drivers/scsi/advansys.c: In function ‘advansys_board_found’:
Arnd> drivers/scsi/advansys.c:11036:5: error: ‘ret’ may be used
Arnd> uninitialized in this function [-Werror=maybe-uninitialized]
Arnd> drivers/scsi/advansys.c:10928:28: note: ‘ret’ was declared here
Arnd> drivers/scsi/advansys.c:11309:8: error: ‘share_irq’ may be used
Arnd> uninitialized in this function [-Werror=maybe-uninitialized]
Arnd> drivers/scsi/advansys.c:10928:6: note: ‘share_irq’ was declared
Arnd> here

Arnd> This cannot happen in practice because the hardware in question
Arnd> only exists for PCI, but changing the code to just error out here
Arnd> is better for consistency and avoids the warning.

Applied to 4.10/scsi-queue.

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


Re: [PATCH 1/1] libfc: don't have fc_exch_find log errors on a new exchange

2016-10-26 Thread Martin K. Petersen
> "Chris" == Chris Leech  writes:

Chris> With the error message I added in "libfc: sanity check cpu number
Chris> extracted from xid" I didn't account for the fact that
Chris> fc_exch_find is called with FC_XID_UNKNOWN at the start of a new
Chris> exchange if we are the responder.

Chris> It doesn't come up with the initiator much, but that's basically
Chris> every exchange for a target.  By checking the xid for
Chris> FC_XID_UNKNOWN first, we not only prevent the erroneous error
Chris> message, but skip the unnecessary lookup attempt as well.

Applied to 4.10/scsi-queue by hand as a result of all the libfc
changes. Please verify.

Thanks!

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


Re: [PATCH 02/12] blk-mq: Introduce blk_mq_hctx_stopped()

2016-10-26 Thread Ming Lei
On Thu, Oct 27, 2016 at 6:51 AM, Bart Van Assche
 wrote:
> Multiple functions test the BLK_MQ_S_STOPPED bit so introduce
> a helper function that performs this test.
>
> Signed-off-by: Bart Van Assche 
> Cc: Christoph Hellwig 
> Cc: Hannes Reinecke 
> Cc: Sagi Grimberg 
> Cc: Johannes Thumshirn 

Reviewed-by: Ming Lei 

> ---
>  block/blk-mq.c | 12 ++--
>  block/blk-mq.h |  5 +
>  2 files changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index b5dcafb..b52b3a6 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -787,7 +787,7 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx 
> *hctx)
> struct list_head *dptr;
> int queued;
>
> -   if (unlikely(test_bit(BLK_MQ_S_STOPPED, >state)))
> +   if (unlikely(blk_mq_hctx_stopped(hctx)))
> return;
>
> WARN_ON(!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask) &&
> @@ -912,8 +912,8 @@ static int blk_mq_hctx_next_cpu(struct blk_mq_hw_ctx 
> *hctx)
>
>  void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async)
>  {
> -   if (unlikely(test_bit(BLK_MQ_S_STOPPED, >state) ||
> -   !blk_mq_hw_queue_mapped(hctx)))
> +   if (unlikely(blk_mq_hctx_stopped(hctx) ||
> +!blk_mq_hw_queue_mapped(hctx)))
> return;
>
> if (!async && !(hctx->flags & BLK_MQ_F_BLOCKING)) {
> @@ -938,7 +938,7 @@ void blk_mq_run_hw_queues(struct request_queue *q, bool 
> async)
> queue_for_each_hw_ctx(q, hctx, i) {
> if ((!blk_mq_hctx_has_pending(hctx) &&
> list_empty_careful(>dispatch)) ||
> -   test_bit(BLK_MQ_S_STOPPED, >state))
> +   blk_mq_hctx_stopped(hctx))
> continue;
>
> blk_mq_run_hw_queue(hctx, async);
> @@ -988,7 +988,7 @@ void blk_mq_start_stopped_hw_queues(struct request_queue 
> *q, bool async)
> int i;
>
> queue_for_each_hw_ctx(q, hctx, i) {
> -   if (!test_bit(BLK_MQ_S_STOPPED, >state))
> +   if (!blk_mq_hctx_stopped(hctx))
> continue;
>
> clear_bit(BLK_MQ_S_STOPPED, >state);
> @@ -1332,7 +1332,7 @@ static blk_qc_t blk_mq_make_request(struct 
> request_queue *q, struct bio *bio)
> blk_mq_put_ctx(data.ctx);
> if (!old_rq)
> goto done;
> -   if (test_bit(BLK_MQ_S_STOPPED, >state) ||
> +   if (blk_mq_hctx_stopped(data.hctx) ||
> blk_mq_direct_issue_request(old_rq, ) != 0)
> blk_mq_insert_request(old_rq, false, true, true);
> goto done;
> diff --git a/block/blk-mq.h b/block/blk-mq.h
> index e5d2524..ac772da 100644
> --- a/block/blk-mq.h
> +++ b/block/blk-mq.h
> @@ -100,6 +100,11 @@ static inline void blk_mq_set_alloc_data(struct 
> blk_mq_alloc_data *data,
> data->hctx = hctx;
>  }
>
> +static inline bool blk_mq_hctx_stopped(struct blk_mq_hw_ctx *hctx)
> +{
> +   return test_bit(BLK_MQ_S_STOPPED, >state);
> +}
> +
>  static inline bool blk_mq_hw_queue_mapped(struct blk_mq_hw_ctx *hctx)
>  {
> return hctx->nr_ctx && hctx->tags;
> --
> 2.10.1
>



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


Re: [PATCH 05/12] blk-mq: Introduce blk_mq_quiesce_queue()

2016-10-26 Thread Ming Lei
On Thu, Oct 27, 2016 at 6:53 AM, Bart Van Assche
 wrote:
> blk_mq_quiesce_queue() waits until ongoing .queue_rq() invocations
> have finished. This function does *not* wait until all outstanding
> requests have finished (this means invocation of request.end_io()).
> The algorithm used by blk_mq_quiesce_queue() is as follows:
> * Hold either an RCU read lock or an SRCU read lock around
>   .queue_rq() calls. The former is used if .queue_rq() does not
>   block and the latter if .queue_rq() may block.
> * blk_mq_quiesce_queue() calls synchronize_srcu() or
>   synchronize_rcu() to wait for .queue_rq() invocations that
>   started before blk_mq_quiesce_queue() was called.
> * The blk_mq_hctx_stopped() calls that control whether or not
>   .queue_rq() will be called are called with the (S)RCU read lock
>   held. This is necessary to avoid race conditions against
>   the "blk_mq_stop_hw_queues(q); blk_mq_quiesce_queue(q);"
>   sequence from another thread.
>
> Signed-off-by: Bart Van Assche 
> Cc: Christoph Hellwig 
> Cc: Ming Lei 
> Cc: Hannes Reinecke 
> Cc: Johannes Thumshirn 
> ---
>  block/Kconfig  |  1 +
>  block/blk-mq.c | 69 
> +-
>  include/linux/blk-mq.h |  3 +++
>  include/linux/blkdev.h |  1 +
>  4 files changed, 67 insertions(+), 7 deletions(-)
>
> diff --git a/block/Kconfig b/block/Kconfig
> index 1d4d624..0562ef9 100644
> --- a/block/Kconfig
> +++ b/block/Kconfig
> @@ -5,6 +5,7 @@ menuconfig BLOCK
> bool "Enable the block layer" if EXPERT
> default y
> select SBITMAP
> +   select SRCU
> help
>  Provide block layer support for the kernel.
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 0cf21c2..4945437 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -115,6 +115,31 @@ void blk_mq_unfreeze_queue(struct request_queue *q)
>  }
>  EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue);
>
> +/**
> + * blk_mq_quiesce_queue() - wait until all ongoing queue_rq calls have 
> finished
> + * @q: request queue.
> + *
> + * Note: this function does not prevent that the struct request end_io()
> + * callback function is invoked. Additionally, it is not prevented that
> + * new queue_rq() calls occur unless the queue has been stopped first.
> + */
> +void blk_mq_quiesce_queue(struct request_queue *q)
> +{
> +   struct blk_mq_hw_ctx *hctx;
> +   unsigned int i;
> +   bool rcu = false;

Before synchronizing SRCU/RCU, we have to set a per-hctx flag
or per-queue flag to block comming .queue_rq(), seems I mentioned
that before:

   https://www.spinics.net/lists/linux-rdma/msg41389.html

> +
> +   queue_for_each_hw_ctx(q, hctx, i) {
> +   if (hctx->flags & BLK_MQ_F_BLOCKING)
> +   synchronize_srcu(>queue_rq_srcu);
> +   else
> +   rcu = true;
> +   }
> +   if (rcu)
> +   synchronize_rcu();
> +}
> +EXPORT_SYMBOL_GPL(blk_mq_quiesce_queue);
> +
>  void blk_mq_wake_waiters(struct request_queue *q)
>  {
> struct blk_mq_hw_ctx *hctx;
> @@ -778,7 +803,7 @@ static inline unsigned int queued_to_index(unsigned int 
> queued)
>   * of IO. In particular, we'd like FIFO behaviour on handling existing
>   * items on the hctx->dispatch list. Ignore that for now.
>   */
> -static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)
> +static void blk_mq_process_rq_list(struct blk_mq_hw_ctx *hctx)
>  {
> struct request_queue *q = hctx->queue;
> struct request *rq;
> @@ -790,9 +815,6 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx 
> *hctx)
> if (unlikely(blk_mq_hctx_stopped(hctx)))
> return;
>
> -   WARN_ON(!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask) &&
> -   cpu_online(hctx->next_cpu));
> -
> hctx->run++;
>
> /*
> @@ -883,6 +905,24 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx 
> *hctx)
> }
>  }
>
> +static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)
> +{
> +   int srcu_idx;
> +
> +   WARN_ON(!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask) &&
> +   cpu_online(hctx->next_cpu));
> +
> +   if (!(hctx->flags & BLK_MQ_F_BLOCKING)) {
> +   rcu_read_lock();
> +   blk_mq_process_rq_list(hctx);
> +   rcu_read_unlock();
> +   } else {
> +   srcu_idx = srcu_read_lock(>queue_rq_srcu);
> +   blk_mq_process_rq_list(hctx);
> +   srcu_read_unlock(>queue_rq_srcu, srcu_idx);
> +   }
> +}
> +
>  /*
>   * It'd be great if the workqueue API had a way to pass
>   * in a mask and had some smarts for more clever placement.
> @@ -1293,7 +1333,7 @@ static blk_qc_t blk_mq_make_request(struct 
> request_queue *q, struct bio *bio)
> const int is_flush_fua = bio->bi_opf & 

Re: [PATCH 2/2] be2iscsi: Replace _bh with _irqsave/irqrestore

2016-10-26 Thread Lee Duncan


On 10/12/2016 11:38 PM, Jitendra Bhivare wrote:
> [ 3843.132217] WARNING: CPU: 20 PID: 1227 at kernel/softirq.c:150 
> __local_bh_enable_ip+0x6b/0x90
> [ 3843.142815] Modules linked in:
> ...
> [ 3843.294328] CPU: 20 PID: 1227 Comm: kworker/20:1H Tainted: GE  
>  4.8.0-rc1+ #3
> [ 3843.304944] Hardware name: Dell Inc. PowerEdge R720/0X6H47, BIOS 1.4.8 
> 10/25/2012
> [ 3843.314798] Workqueue: kblockd blk_timeout_work
> [ 3843.321350]  0086 a32f4533 8802216d7bd8 
> 8135c3cf
> [ 3843.331146]    8802216d7c18 
> 8108d661
> [ 3843.340918]  0096216d7c50 0200 8802d07cc828 
> 8801b3632550
> [ 3843.350687] Call Trace:
> [ 3843.354866]  [] dump_stack+0x63/0x84
> [ 3843.362061]  [] __warn+0xd1/0xf0
> [ 3843.368851]  [] warn_slowpath_null+0x1d/0x20
> [ 3843.376791]  [] __local_bh_enable_ip+0x6b/0x90
> [ 3843.384903]  [] _raw_spin_unlock_bh+0x1e/0x20
> [ 3843.392940]  [] beiscsi_alloc_pdu+0x2f0/0x6e0 [be2iscsi]
> [ 3843.402076]  [] __iscsi_conn_send_pdu+0xf8/0x370 
> [libiscsi]
> [ 3843.411549]  [] iscsi_send_nopout+0xbe/0x110 [libiscsi]
> [ 3843.420639]  [] iscsi_eh_cmd_timed_out+0x29b/0x2b0 
> [libiscsi]
> [ 3843.430339]  [] scsi_times_out+0x5e/0x250
> [ 3843.438119]  [] blk_rq_timed_out+0x1f/0x60
> [ 3843.446009]  [] blk_timeout_work+0xad/0x150
> [ 3843.454010]  [] process_one_work+0x152/0x400
> [ 3843.462114]  [] worker_thread+0x125/0x4b0
> [ 3843.469961]  [] ? rescuer_thread+0x380/0x380
> [ 3843.478116]  [] kthread+0xd8/0xf0
> [ 3843.485212]  [] ret_from_fork+0x1f/0x40
> [ 3843.492908]  [] ? kthread_park+0x60/0x60
> [ 3843.500715] ---[ end trace 57ec0a1d8f0dd3a0 ]---
> [ 3852.328667] NMI watchdog: Watchdog detected hard LOCKUP on cpu 1Kernel 
> panic - not syncing: Hard LOCKUP
> 
> blk_timeout_work takes queue_lock spin_lock with interrupts disabled
> before invoking iscsi_eh_cmd_timed_out. This causes a WARN_ON_ONCE in
> spin_unlock_bh for wrb_lock/io_sgl_lock/mgmt_sgl_lock.
> 
> CPU was kept busy in lot of bottom half work with interrupts disabled
> thus causing hard lock up.
> 
> Signed-off-by: Jitendra Bhivare 
> ---
>  drivers/scsi/be2iscsi/be_main.c | 37 +++--
>  1 file changed, 23 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
> index 68138a6..d9239c2 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -900,8 +900,9 @@ void hwi_ring_cq_db(struct beiscsi_hba *phba,
>  static struct sgl_handle *alloc_io_sgl_handle(struct beiscsi_hba *phba)
>  {
>   struct sgl_handle *psgl_handle;
> + unsigned long flags;
>  
> - spin_lock_bh(>io_sgl_lock);
> + spin_lock_irqsave(>io_sgl_lock, flags);
>   if (phba->io_sgl_hndl_avbl) {
>   beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO,
>   "BM_%d : In alloc_io_sgl_handle,"
> @@ -919,14 +920,16 @@ static struct sgl_handle *alloc_io_sgl_handle(struct 
> beiscsi_hba *phba)
>   phba->io_sgl_alloc_index++;
>   } else
>   psgl_handle = NULL;
> - spin_unlock_bh(>io_sgl_lock);
> + spin_unlock_irqrestore(>io_sgl_lock, flags);
>   return psgl_handle;
>  }
>  
>  static void
>  free_io_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle)
>  {
> - spin_lock_bh(>io_sgl_lock);
> + unsigned long flags;
> +
> + spin_lock_irqsave(>io_sgl_lock, flags);
>   beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO,
>   "BM_%d : In free_,io_sgl_free_index=%d\n",
>   phba->io_sgl_free_index);
> @@ -941,7 +944,7 @@ free_io_sgl_handle(struct beiscsi_hba *phba, struct 
> sgl_handle *psgl_handle)
>"value there=%p\n", phba->io_sgl_free_index,
>phba->io_sgl_hndl_base
>[phba->io_sgl_free_index]);
> -  spin_unlock_bh(>io_sgl_lock);
> +  spin_unlock_irqrestore(>io_sgl_lock, flags);
>   return;
>   }
>   phba->io_sgl_hndl_base[phba->io_sgl_free_index] = psgl_handle;
> @@ -950,7 +953,7 @@ free_io_sgl_handle(struct beiscsi_hba *phba, struct 
> sgl_handle *psgl_handle)
>   phba->io_sgl_free_index = 0;
>   else
>   phba->io_sgl_free_index++;
> - spin_unlock_bh(>io_sgl_lock);
> + spin_unlock_irqrestore(>io_sgl_lock, flags);
>  }
>  
>  static inline struct wrb_handle *
> @@ -958,15 +961,16 @@ beiscsi_get_wrb_handle(struct hwi_wrb_context 
> *pwrb_context,
>  unsigned int wrbs_per_cxn)
>  {
>   struct wrb_handle *pwrb_handle;
> + unsigned long flags;
>  
> - spin_lock_bh(_context->wrb_lock);
> + spin_lock_irqsave(_context->wrb_lock, flags);
>   pwrb_handle = pwrb_context->pwrb_handle_base[pwrb_context->alloc_index];
>   pwrb_context->wrb_handles_available--;
>   if 

Re: [PATCH 1/2] libiscsi: Fix locking in __iscsi_conn_send_pdu

2016-10-26 Thread Lee Duncan
On 10/12/2016 11:38 PM, Jitendra Bhivare wrote:
> The code at free_task label in __iscsi_conn_send_pdu can get executed
> from blk_timeout_work which takes queue_lock using spin_lock_irq.
> back_lock taken with spin_unlock_bh will cause WARN_ON_ONCE.
> The code gets executed either with bottom half or IRQ disabled hence
> using spin_lock/spin_unlock for back_lock is safe.
> 
> Signed-off-by: Jitendra Bhivare 
> ---
>  drivers/scsi/libiscsi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index c051694..f9b6fba 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -791,9 +791,9 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct 
> iscsi_hdr *hdr,
>  
>  free_task:
>   /* regular RX path uses back_lock */
> - spin_lock_bh(>back_lock);
> + spin_lock(>back_lock);
>   __iscsi_put_task(task);
> - spin_unlock_bh(>back_lock);
> + spin_unlock(>back_lock);
>   return NULL;
>  }
>  
> 

Reviewed-by: Lee Duncan 
--
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 v4 0/12] Fix race conditions related to stopping block layer queues

2016-10-26 Thread Jens Axboe

On 10/26/2016 04:49 PM, Bart Van Assche wrote:

Hello Jens,

Multiple block drivers need the functionality to stop a request queue
and to wait until all ongoing request_fn() / queue_rq() calls have
finished without waiting until all outstanding requests have finished.
Hence this patch series that introduces the blk_mq_quiesce_queue()
function. The dm-mq, SRP and NVMe patches in this patch series are three
examples of where these functions are useful. These patches have been
tested on top of kernel v4.9-rc1. The following tests have been run to
verify this patch series:
- Mike's mptest suite that stress-tests dm-multipath.
- My own srp-test suite that stress-tests SRP on top of dm-multipath.
- fio on top of the NVMeOF host driver that was connected to the NVMeOF
  target driver on the same host.
- Laurence verified the previous version (v3) of this patch series by
  running it through the Red Hat SRP and NVMe test suites.


This looks pretty good, I'll run some testing on it tomorrow and do a
full review, hopefully we can get it applied sooner rather than later
for the next series.

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


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

2016-10-26 Thread Bart Van Assche
Ensure that if scsi-mq is enabled that scsi_wait_for_queuecommand()
waits until ongoing shost->hostt->queuecommand() calls have finished.

Signed-off-by: Bart Van Assche 
Reviewed-by: Christoph Hellwig 
Cc: James Bottomley 
Cc: Martin K. Petersen 
Cc: Doug Ledford 
---
 drivers/scsi/scsi_lib.c | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index c1561e7..9b8b19e 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2724,8 +2724,6 @@ EXPORT_SYMBOL_GPL(sdev_evt_send_simple);
 /**
  * scsi_request_fn_active() - number of kernel threads inside scsi_request_fn()
  * @shost: SCSI host for which to count the number of scsi_request_fn() 
callers.
- *
- * To do: add support for scsi-mq in this function.
  */
 static int scsi_request_fn_active(struct Scsi_Host *shost)
 {
@@ -2744,12 +2742,20 @@ static int scsi_request_fn_active(struct Scsi_Host 
*shost)
return request_fn_active;
 }
 
+static void scsi_mq_wait_for_queuecommand(struct Scsi_Host *shost)
+{
+   struct scsi_device *sdev;
+
+   shost_for_each_device(sdev, shost)
+   blk_mq_quiesce_queue(sdev->request_queue);
+}
+
 /**
  * scsi_wait_for_queuecommand() - wait for ongoing queuecommand() calls
  * @shost: SCSI host pointer.
  *
  * Wait until the ongoing shost->hostt->queuecommand() calls that are
- * invoked from scsi_request_fn() have finished.
+ * invoked from either scsi_request_fn() or scsi_queue_rq() have finished.
  *
  * To do: avoid that scsi_send_eh_cmnd() calls queuecommand() after
  * scsi_internal_device_block() has blocked a SCSI device and remove and also
@@ -2757,8 +2763,12 @@ static int scsi_request_fn_active(struct Scsi_Host 
*shost)
  */
 void scsi_wait_for_queuecommand(struct Scsi_Host *shost)
 {
-   while (scsi_request_fn_active(shost))
-   msleep(20);
+   if (shost->use_blk_mq) {
+   scsi_mq_wait_for_queuecommand(shost);
+   } else {
+   while (scsi_request_fn_active(shost))
+   msleep(20);
+   }
 }
 EXPORT_SYMBOL(scsi_wait_for_queuecommand);
 
-- 
2.10.1

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


[PATCH 06/12] blk-mq: Add a kick_requeue_list argument to blk_mq_requeue_request()

2016-10-26 Thread Bart Van Assche
Most blk_mq_requeue_request() and blk_mq_add_to_requeue_list() calls
are followed by kicking the requeue list. Hence add an argument to
these two functions that allows to kick the requeue list. This was
proposed by Christoph Hellwig.

Signed-off-by: Bart Van Assche 
Cc: Christoph Hellwig 
Cc: Hannes Reinecke 
Cc: Sagi Grimberg 
Cc: Johannes Thumshirn 
---
 block/blk-flush.c|  5 +
 block/blk-mq.c   | 10 +++---
 drivers/block/xen-blkfront.c |  2 +-
 drivers/md/dm-rq.c   |  2 +-
 drivers/nvme/host/core.c |  2 +-
 drivers/scsi/scsi_lib.c  |  4 +---
 include/linux/blk-mq.h   |  5 +++--
 7 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/block/blk-flush.c b/block/blk-flush.c
index 6a14b68..a834aed 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -134,10 +134,7 @@ static void blk_flush_restore_request(struct request *rq)
 static bool blk_flush_queue_rq(struct request *rq, bool add_front)
 {
if (rq->q->mq_ops) {
-   struct request_queue *q = rq->q;
-
-   blk_mq_add_to_requeue_list(rq, add_front);
-   blk_mq_kick_requeue_list(q);
+   blk_mq_add_to_requeue_list(rq, add_front, true);
return false;
} else {
if (add_front)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 4945437..688bcc3 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -492,12 +492,12 @@ static void __blk_mq_requeue_request(struct request *rq)
}
 }
 
-void blk_mq_requeue_request(struct request *rq)
+void blk_mq_requeue_request(struct request *rq, bool kick_requeue_list)
 {
__blk_mq_requeue_request(rq);
 
BUG_ON(blk_queued_rq(rq));
-   blk_mq_add_to_requeue_list(rq, true);
+   blk_mq_add_to_requeue_list(rq, true, kick_requeue_list);
 }
 EXPORT_SYMBOL(blk_mq_requeue_request);
 
@@ -535,7 +535,8 @@ static void blk_mq_requeue_work(struct work_struct *work)
blk_mq_start_hw_queues(q);
 }
 
-void blk_mq_add_to_requeue_list(struct request *rq, bool at_head)
+void blk_mq_add_to_requeue_list(struct request *rq, bool at_head,
+   bool kick_requeue_list)
 {
struct request_queue *q = rq->q;
unsigned long flags;
@@ -554,6 +555,9 @@ void blk_mq_add_to_requeue_list(struct request *rq, bool 
at_head)
list_add_tail(>queuelist, >requeue_list);
}
spin_unlock_irqrestore(>requeue_lock, flags);
+
+   if (kick_requeue_list)
+   blk_mq_kick_requeue_list(q);
 }
 EXPORT_SYMBOL(blk_mq_add_to_requeue_list);
 
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 9908597..1ca702d 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -2043,7 +2043,7 @@ static int blkif_recover(struct blkfront_info *info)
/* Requeue pending requests (flush or discard) */
list_del_init(>queuelist);
BUG_ON(req->nr_phys_segments > segs);
-   blk_mq_requeue_request(req);
+   blk_mq_requeue_request(req, false);
}
blk_mq_kick_requeue_list(info->rq);
 
diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
index dc75bea..fbd37b4 100644
--- a/drivers/md/dm-rq.c
+++ b/drivers/md/dm-rq.c
@@ -354,7 +354,7 @@ EXPORT_SYMBOL(dm_mq_kick_requeue_list);
 
 static void dm_mq_delay_requeue_request(struct request *rq, unsigned long 
msecs)
 {
-   blk_mq_requeue_request(rq);
+   blk_mq_requeue_request(rq, false);
__dm_mq_kick_requeue_list(rq->q, msecs);
 }
 
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 79e679d..7bb73ba 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -203,7 +203,7 @@ void nvme_requeue_req(struct request *req)
 {
unsigned long flags;
 
-   blk_mq_requeue_request(req);
+   blk_mq_requeue_request(req, false);
spin_lock_irqsave(req->q->queue_lock, flags);
if (!blk_queue_stopped(req->q))
blk_mq_kick_requeue_list(req->q);
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 2cca9cf..ab5b06f 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -86,10 +86,8 @@ scsi_set_blocked(struct scsi_cmnd *cmd, int reason)
 static void scsi_mq_requeue_cmd(struct scsi_cmnd *cmd)
 {
struct scsi_device *sdev = cmd->device;
-   struct request_queue *q = cmd->request->q;
 
-   blk_mq_requeue_request(cmd->request);
-   blk_mq_kick_requeue_list(q);
+   blk_mq_requeue_request(cmd->request, true);
put_device(>sdev_gendev);
 }
 
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 61be48b..76f6319 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -218,8 +218,9 @@ void blk_mq_start_request(struct request *rq);
 void blk_mq_end_request(struct request *rq, int error);
 void __blk_mq_end_request(struct 

[PATCH 02/12] blk-mq: Introduce blk_mq_hctx_stopped()

2016-10-26 Thread Bart Van Assche
Multiple functions test the BLK_MQ_S_STOPPED bit so introduce
a helper function that performs this test.

Signed-off-by: Bart Van Assche 
Cc: Christoph Hellwig 
Cc: Hannes Reinecke 
Cc: Sagi Grimberg 
Cc: Johannes Thumshirn 
---
 block/blk-mq.c | 12 ++--
 block/blk-mq.h |  5 +
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index b5dcafb..b52b3a6 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -787,7 +787,7 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx 
*hctx)
struct list_head *dptr;
int queued;
 
-   if (unlikely(test_bit(BLK_MQ_S_STOPPED, >state)))
+   if (unlikely(blk_mq_hctx_stopped(hctx)))
return;
 
WARN_ON(!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask) &&
@@ -912,8 +912,8 @@ static int blk_mq_hctx_next_cpu(struct blk_mq_hw_ctx *hctx)
 
 void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async)
 {
-   if (unlikely(test_bit(BLK_MQ_S_STOPPED, >state) ||
-   !blk_mq_hw_queue_mapped(hctx)))
+   if (unlikely(blk_mq_hctx_stopped(hctx) ||
+!blk_mq_hw_queue_mapped(hctx)))
return;
 
if (!async && !(hctx->flags & BLK_MQ_F_BLOCKING)) {
@@ -938,7 +938,7 @@ void blk_mq_run_hw_queues(struct request_queue *q, bool 
async)
queue_for_each_hw_ctx(q, hctx, i) {
if ((!blk_mq_hctx_has_pending(hctx) &&
list_empty_careful(>dispatch)) ||
-   test_bit(BLK_MQ_S_STOPPED, >state))
+   blk_mq_hctx_stopped(hctx))
continue;
 
blk_mq_run_hw_queue(hctx, async);
@@ -988,7 +988,7 @@ void blk_mq_start_stopped_hw_queues(struct request_queue 
*q, bool async)
int i;
 
queue_for_each_hw_ctx(q, hctx, i) {
-   if (!test_bit(BLK_MQ_S_STOPPED, >state))
+   if (!blk_mq_hctx_stopped(hctx))
continue;
 
clear_bit(BLK_MQ_S_STOPPED, >state);
@@ -1332,7 +1332,7 @@ static blk_qc_t blk_mq_make_request(struct request_queue 
*q, struct bio *bio)
blk_mq_put_ctx(data.ctx);
if (!old_rq)
goto done;
-   if (test_bit(BLK_MQ_S_STOPPED, >state) ||
+   if (blk_mq_hctx_stopped(data.hctx) ||
blk_mq_direct_issue_request(old_rq, ) != 0)
blk_mq_insert_request(old_rq, false, true, true);
goto done;
diff --git a/block/blk-mq.h b/block/blk-mq.h
index e5d2524..ac772da 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -100,6 +100,11 @@ static inline void blk_mq_set_alloc_data(struct 
blk_mq_alloc_data *data,
data->hctx = hctx;
 }
 
+static inline bool blk_mq_hctx_stopped(struct blk_mq_hw_ctx *hctx)
+{
+   return test_bit(BLK_MQ_S_STOPPED, >state);
+}
+
 static inline bool blk_mq_hw_queue_mapped(struct blk_mq_hw_ctx *hctx)
 {
return hctx->nr_ctx && hctx->tags;
-- 
2.10.1

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


[PATCH 12/12] nvme: Fix a race condition related to stopping queues

2016-10-26 Thread Bart Van Assche
Avoid that nvme_queue_rq() is still running when nvme_stop_queues()
returns.

Signed-off-by: Bart Van Assche 
Reviewed-by: Sagi Grimberg 
Reviewed-by: Christoph Hellwig 
Cc: Keith Busch 
---
 drivers/nvme/host/core.c | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index b662416..d6ab9a0 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -201,13 +201,7 @@ static struct nvme_ns *nvme_get_ns_from_disk(struct 
gendisk *disk)
 
 void nvme_requeue_req(struct request *req)
 {
-   unsigned long flags;
-
-   blk_mq_requeue_request(req, false);
-   spin_lock_irqsave(req->q->queue_lock, flags);
-   if (!blk_mq_queue_stopped(req->q))
-   blk_mq_kick_requeue_list(req->q);
-   spin_unlock_irqrestore(req->q->queue_lock, flags);
+   blk_mq_requeue_request(req, !blk_mq_queue_stopped(req->q));
 }
 EXPORT_SYMBOL_GPL(nvme_requeue_req);
 
@@ -2079,8 +2073,11 @@ void nvme_stop_queues(struct nvme_ctrl *ctrl)
 
mutex_lock(>namespaces_mutex);
list_for_each_entry(ns, >namespaces, list) {
-   blk_mq_cancel_requeue_work(ns->queue);
-   blk_mq_stop_hw_queues(ns->queue);
+   struct request_queue *q = ns->queue;
+
+   blk_mq_cancel_requeue_work(q);
+   blk_mq_stop_hw_queues(q);
+   blk_mq_quiesce_queue(q);
}
mutex_unlock(>namespaces_mutex);
 }
-- 
2.10.1

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


[PATCH v4 0/12] Fix race conditions related to stopping block layer queues

2016-10-26 Thread Bart Van Assche

Hello Jens,

Multiple block drivers need the functionality to stop a request queue 
and to wait until all ongoing request_fn() / queue_rq() calls have 
finished without waiting until all outstanding requests have finished. 
Hence this patch series that introduces the blk_mq_quiesce_queue() 
function. The dm-mq, SRP and NVMe patches in this patch series are three 
examples of where these functions are useful. These patches have been 
tested on top of kernel v4.9-rc1. The following tests have been run to 
verify this patch series:

- Mike's mptest suite that stress-tests dm-multipath.
- My own srp-test suite that stress-tests SRP on top of dm-multipath.
- fio on top of the NVMeOF host driver that was connected to the NVMeOF
  target driver on the same host.
- Laurence verified the previous version (v3) of this patch series by
  running it through the Red Hat SRP and NVMe test suites.

The changes compared to the third version of this patch series are:
- Left out the dm changes from the patch that introduces
  blk_mq_hctx_stopped() because a later patch deletes the changed code
  from the dm core.
- Moved the blk_mq_hctx_stopped() declaration from a public to a
  private block layer header file.
- Added a new patch that moves more code into
  blk_mq_direct_issue_request(). This patch avoids that a new function
  has to be introduced to avoid code duplication.
- Explained the implemented algorithm in the patch that introduces
  blk_mq_quiesce_queue() in the description of the patch that
  introduces this function.
- Added "select SRCU" to the patch that introduces
  blk_mq_quiesce_queue() to avoid build failures.
- Documented the shost argument in the scsi_wait_for_queuecommand()
  kerneldoc header.
- Fixed an unintended behavior change in the last patch of this series.

Changes between v3 and v2:
- Changed the order of the patches in this patch series.
- Added several new patches: a patch that avoids that .queue_rq() gets
  invoked from the direct submission path if a queue has been stopped
  and also a patch that introduces the helper function
  blk_mq_hctx_stopped().
- blk_mq_quiesce_queue() has been reworked (thanks to Ming Lin and Sagi
  for their feedback).
- A bool 'kick' argument has been added to blk_mq_requeue_request().
- As proposed by Christoph, the code that waits for queuecommand() has
  been moved from the SRP transport driver to the SCSI core.

Changes between v2 and v1:
- Dropped the non-blk-mq changes from this patch series.
- Added support for harware queues with BLK_MQ_F_BLOCKING set.
- Added a call stack to the description of the dm race fix patch.
- Dropped the non-scsi-mq changes from the SRP patch.
- Added a patch that introduces blk_mq_queue_stopped() in the dm driver.

The individual patches in this series are:

0001-blk-mq-Do-not-invoke-.queue_rq-for-a-stopped-queue.patch
0002-blk-mq-Introduce-blk_mq_hctx_stopped.patch
0003-blk-mq-Introduce-blk_mq_queue_stopped.patch
0004-blk-mq-Move-more-code-into-blk_mq_direct_issue_reque.patch
0005-blk-mq-Introduce-blk_mq_quiesce_queue.patch
0006-blk-mq-Add-a-kick_requeue_list-argument-to-blk_mq_re.patch
0007-dm-Use-BLK_MQ_S_STOPPED-instead-of-QUEUE_FLAG_STOPPE.patch
0008-dm-Fix-a-race-condition-related-to-stopping-and-star.patch
0009-SRP-transport-Move-queuecommand-wait-code-to-SCSI-co.patch
0010-SRP-transport-scsi-mq-Wait-for-.queue_rq-if-necessar.patch
0011-nvme-Use-BLK_MQ_S_STOPPED-instead-of-QUEUE_FLAG_STOP.patch
0012-nvme-Fix-a-race-condition-related-to-stopping-queues.patch

Thanks,

Bart.
--
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 11/12] nvme: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code

2016-10-26 Thread Bart Van Assche
Make nvme_requeue_req() check BLK_MQ_S_STOPPED instead of
QUEUE_FLAG_STOPPED. Remove the QUEUE_FLAG_STOPPED manipulations
that became superfluous because of this change. Change
blk_queue_stopped() tests into blk_mq_queue_stopped().

This patch fixes a race condition: using queue_flag_clear_unlocked()
is not safe if any other function that manipulates the queue flags
can be called concurrently, e.g. blk_cleanup_queue().

Signed-off-by: Bart Van Assche 
Reviewed-by: Christoph Hellwig 
Cc: Keith Busch 
Cc: Christoph Hellwig 
Cc: Sagi Grimberg 
---
 drivers/nvme/host/core.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 7bb73ba..b662416 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -205,7 +205,7 @@ void nvme_requeue_req(struct request *req)
 
blk_mq_requeue_request(req, false);
spin_lock_irqsave(req->q->queue_lock, flags);
-   if (!blk_queue_stopped(req->q))
+   if (!blk_mq_queue_stopped(req->q))
blk_mq_kick_requeue_list(req->q);
spin_unlock_irqrestore(req->q->queue_lock, flags);
 }
@@ -2079,10 +2079,6 @@ void nvme_stop_queues(struct nvme_ctrl *ctrl)
 
mutex_lock(>namespaces_mutex);
list_for_each_entry(ns, >namespaces, list) {
-   spin_lock_irq(ns->queue->queue_lock);
-   queue_flag_set(QUEUE_FLAG_STOPPED, ns->queue);
-   spin_unlock_irq(ns->queue->queue_lock);
-
blk_mq_cancel_requeue_work(ns->queue);
blk_mq_stop_hw_queues(ns->queue);
}
@@ -2096,7 +2092,6 @@ void nvme_start_queues(struct nvme_ctrl *ctrl)
 
mutex_lock(>namespaces_mutex);
list_for_each_entry(ns, >namespaces, list) {
-   queue_flag_clear_unlocked(QUEUE_FLAG_STOPPED, ns->queue);
blk_mq_start_stopped_hw_queues(ns->queue, true);
blk_mq_kick_requeue_list(ns->queue);
}
-- 
2.10.1

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


[PATCH 09/12] SRP transport: Move queuecommand() wait code to SCSI core

2016-10-26 Thread Bart Van Assche
Additionally, rename srp_wait_for_queuecommand() into
scsi_wait_for_queuecommand() and add a comment about the
queuecommand() call from scsi_send_eh_cmnd().

Signed-off-by: Bart Van Assche 
Reviewed-by: Christoph Hellwig 
Cc: James Bottomley 
Cc: Martin K. Petersen 
Cc: Sagi Grimberg 
Cc: Doug Ledford 
---
 drivers/scsi/scsi_lib.c   | 41 +++
 drivers/scsi/scsi_transport_srp.c | 35 ++---
 include/scsi/scsi_host.h  |  1 +
 3 files changed, 44 insertions(+), 33 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index ab5b06f..c1561e7 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2722,6 +2722,47 @@ void sdev_evt_send_simple(struct scsi_device *sdev,
 EXPORT_SYMBOL_GPL(sdev_evt_send_simple);
 
 /**
+ * scsi_request_fn_active() - number of kernel threads inside scsi_request_fn()
+ * @shost: SCSI host for which to count the number of scsi_request_fn() 
callers.
+ *
+ * To do: add support for scsi-mq in this function.
+ */
+static int scsi_request_fn_active(struct Scsi_Host *shost)
+{
+   struct scsi_device *sdev;
+   struct request_queue *q;
+   int request_fn_active = 0;
+
+   shost_for_each_device(sdev, shost) {
+   q = sdev->request_queue;
+
+   spin_lock_irq(q->queue_lock);
+   request_fn_active += q->request_fn_active;
+   spin_unlock_irq(q->queue_lock);
+   }
+
+   return request_fn_active;
+}
+
+/**
+ * scsi_wait_for_queuecommand() - wait for ongoing queuecommand() calls
+ * @shost: SCSI host pointer.
+ *
+ * Wait until the ongoing shost->hostt->queuecommand() calls that are
+ * invoked from scsi_request_fn() have finished.
+ *
+ * To do: avoid that scsi_send_eh_cmnd() calls queuecommand() after
+ * scsi_internal_device_block() has blocked a SCSI device and remove and also
+ * remove the rport mutex lock and unlock calls from srp_queuecommand().
+ */
+void scsi_wait_for_queuecommand(struct Scsi_Host *shost)
+{
+   while (scsi_request_fn_active(shost))
+   msleep(20);
+}
+EXPORT_SYMBOL(scsi_wait_for_queuecommand);
+
+/**
  * scsi_device_quiesce - Block user issued commands.
  * @sdev:  scsi device to quiesce.
  *
diff --git a/drivers/scsi/scsi_transport_srp.c 
b/drivers/scsi/scsi_transport_srp.c
index e3cd3ec..8b190dc 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -24,7 +24,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -402,36 +401,6 @@ static void srp_reconnect_work(struct work_struct *work)
}
 }
 
-/**
- * scsi_request_fn_active() - number of kernel threads inside scsi_request_fn()
- * @shost: SCSI host for which to count the number of scsi_request_fn() 
callers.
- *
- * To do: add support for scsi-mq in this function.
- */
-static int scsi_request_fn_active(struct Scsi_Host *shost)
-{
-   struct scsi_device *sdev;
-   struct request_queue *q;
-   int request_fn_active = 0;
-
-   shost_for_each_device(sdev, shost) {
-   q = sdev->request_queue;
-
-   spin_lock_irq(q->queue_lock);
-   request_fn_active += q->request_fn_active;
-   spin_unlock_irq(q->queue_lock);
-   }
-
-   return request_fn_active;
-}
-
-/* Wait until ongoing shost->hostt->queuecommand() calls have finished. */
-static void srp_wait_for_queuecommand(struct Scsi_Host *shost)
-{
-   while (scsi_request_fn_active(shost))
-   msleep(20);
-}
-
 static void __rport_fail_io_fast(struct srp_rport *rport)
 {
struct Scsi_Host *shost = rport_to_shost(rport);
@@ -446,7 +415,7 @@ static void __rport_fail_io_fast(struct srp_rport *rport)
/* Involve the LLD if possible to terminate all I/O on the rport. */
i = to_srp_internal(shost->transportt);
if (i->f->terminate_rport_io) {
-   srp_wait_for_queuecommand(shost);
+   scsi_wait_for_queuecommand(shost);
i->f->terminate_rport_io(rport);
}
 }
@@ -576,7 +545,7 @@ int srp_reconnect_rport(struct srp_rport *rport)
if (res)
goto out;
scsi_target_block(>shost_gendev);
-   srp_wait_for_queuecommand(shost);
+   scsi_wait_for_queuecommand(shost);
res = rport->state != SRP_RPORT_LOST ? i->f->reconnect(rport) : -ENODEV;
pr_debug("%s (state %d): transport.reconnect() returned %d\n",
 dev_name(>shost_gendev), rport->state, res);
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 7e4cd53..0e2c361 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -789,6 +789,7 @@ extern void scsi_remove_host(struct Scsi_Host *);
 extern struct Scsi_Host *scsi_host_get(struct Scsi_Host *);
 extern void scsi_host_put(struct 

[PATCH 08/12] dm: Fix a race condition related to stopping and starting queues

2016-10-26 Thread Bart Van Assche
Ensure that all ongoing dm_mq_queue_rq() and dm_mq_requeue_request()
calls have stopped before setting the "queue stopped" flag. This
allows to remove the "queue stopped" test from dm_mq_queue_rq() and
dm_mq_requeue_request(). This patch fixes a race condition because
dm_mq_queue_rq() is called without holding the queue lock and hence
BLK_MQ_S_STOPPED can be set at any time while dm_mq_queue_rq() is
in progress. This patch prevents that the following hang occurs
sporadically when using dm-mq:

INFO: task systemd-udevd:10111 blocked for more than 480 seconds.
Call Trace:
 [] schedule+0x37/0x90
 [] schedule_timeout+0x27f/0x470
 [] io_schedule_timeout+0x9f/0x110
 [] bit_wait_io+0x16/0x60
 [] __wait_on_bit_lock+0x49/0xa0
 [] __lock_page+0xb9/0xc0
 [] truncate_inode_pages_range+0x3e0/0x760
 [] truncate_inode_pages+0x10/0x20
 [] kill_bdev+0x30/0x40
 [] __blkdev_put+0x71/0x360
 [] blkdev_put+0x49/0x170
 [] blkdev_close+0x20/0x30
 [] __fput+0xe8/0x1f0
 [] fput+0x9/0x10
 [] task_work_run+0x83/0xb0
 [] do_exit+0x3ee/0xc40
 [] do_group_exit+0x4b/0xc0
 [] get_signal+0x2ca/0x940
 [] do_signal+0x23/0x660
 [] exit_to_usermode_loop+0x73/0xb0
 [] syscall_return_slowpath+0xb0/0xc0
 [] entry_SYSCALL_64_fastpath+0xa6/0xa8

Signed-off-by: Bart Van Assche 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Johannes Thumshirn 
Reviewed-by: Christoph Hellwig 
Cc: Mike Snitzer 
---
 drivers/md/dm-rq.c | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
index d47a504..107ed19 100644
--- a/drivers/md/dm-rq.c
+++ b/drivers/md/dm-rq.c
@@ -105,6 +105,8 @@ static void dm_mq_stop_queue(struct request_queue *q)
/* Avoid that requeuing could restart the queue. */
blk_mq_cancel_requeue_work(q);
blk_mq_stop_hw_queues(q);
+   /* Wait until dm_mq_queue_rq() has finished. */
+   blk_mq_quiesce_queue(q);
 }
 
 void dm_stop_queue(struct request_queue *q)
@@ -887,17 +889,6 @@ static int dm_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
dm_put_live_table(md, srcu_idx);
}
 
-   /*
-* On suspend dm_stop_queue() handles stopping the blk-mq
-* request_queue BUT: even though the hw_queues are marked
-* BLK_MQ_S_STOPPED at that point there is still a race that
-* is allowing block/blk-mq.c to call ->queue_rq against a
-* hctx that it really shouldn't.  The following check guards
-* against this rarity (albeit _not_ race-free).
-*/
-   if (unlikely(test_bit(BLK_MQ_S_STOPPED, >state)))
-   return BLK_MQ_RQ_QUEUE_BUSY;
-
if (ti->type->busy && ti->type->busy(ti))
return BLK_MQ_RQ_QUEUE_BUSY;
 
-- 
2.10.1

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


Re: [RFC] libata-scsi: introducing SANITIZE translation

2016-10-26 Thread Mark Lord

On 16-07-11 02:35 AM, Tom Yan wrote:

I don't suppose there would be any problem doing it in userspace /
with ATA PASS-THROUGH anyway.

..

On 8 July 2016 at 17:29, James Bottomley
 wrote:

..

Not really.  The point is that you've proposed something as an addition
to the kernel that can also be done in userspace.  Checking if it can
work easily there is like a barrier to entry.  If it works, then fine,
we're done.  If it throws up problems then we reconsider the kernel
route.


hdparm has full support for the SANITIZE commands in userspace.

-ml
--
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/12] dm: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code

2016-10-26 Thread Bart Van Assche
Instead of manipulating both QUEUE_FLAG_STOPPED and BLK_MQ_S_STOPPED
in the dm start and stop queue functions, only manipulate the latter
flag. Change blk_queue_stopped() tests into blk_mq_queue_stopped().

Signed-off-by: Bart Van Assche 
Reviewed-by: Christoph Hellwig 
Cc: Mike Snitzer 
---
 drivers/md/dm-rq.c | 18 ++
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
index fbd37b4..d47a504 100644
--- a/drivers/md/dm-rq.c
+++ b/drivers/md/dm-rq.c
@@ -75,12 +75,6 @@ static void dm_old_start_queue(struct request_queue *q)
 
 static void dm_mq_start_queue(struct request_queue *q)
 {
-   unsigned long flags;
-
-   spin_lock_irqsave(q->queue_lock, flags);
-   queue_flag_clear(QUEUE_FLAG_STOPPED, q);
-   spin_unlock_irqrestore(q->queue_lock, flags);
-
blk_mq_start_stopped_hw_queues(q, true);
blk_mq_kick_requeue_list(q);
 }
@@ -105,16 +99,8 @@ static void dm_old_stop_queue(struct request_queue *q)
 
 static void dm_mq_stop_queue(struct request_queue *q)
 {
-   unsigned long flags;
-
-   spin_lock_irqsave(q->queue_lock, flags);
-   if (blk_queue_stopped(q)) {
-   spin_unlock_irqrestore(q->queue_lock, flags);
+   if (blk_mq_queue_stopped(q))
return;
-   }
-
-   queue_flag_set(QUEUE_FLAG_STOPPED, q);
-   spin_unlock_irqrestore(q->queue_lock, flags);
 
/* Avoid that requeuing could restart the queue. */
blk_mq_cancel_requeue_work(q);
@@ -341,7 +327,7 @@ static void __dm_mq_kick_requeue_list(struct request_queue 
*q, unsigned long mse
unsigned long flags;
 
spin_lock_irqsave(q->queue_lock, flags);
-   if (!blk_queue_stopped(q))
+   if (!blk_mq_queue_stopped(q))
blk_mq_delay_kick_requeue_list(q, msecs);
spin_unlock_irqrestore(q->queue_lock, flags);
 }
-- 
2.10.1

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


[PATCH 05/12] blk-mq: Introduce blk_mq_quiesce_queue()

2016-10-26 Thread Bart Van Assche
blk_mq_quiesce_queue() waits until ongoing .queue_rq() invocations
have finished. This function does *not* wait until all outstanding
requests have finished (this means invocation of request.end_io()).
The algorithm used by blk_mq_quiesce_queue() is as follows:
* Hold either an RCU read lock or an SRCU read lock around
  .queue_rq() calls. The former is used if .queue_rq() does not
  block and the latter if .queue_rq() may block.
* blk_mq_quiesce_queue() calls synchronize_srcu() or
  synchronize_rcu() to wait for .queue_rq() invocations that
  started before blk_mq_quiesce_queue() was called.
* The blk_mq_hctx_stopped() calls that control whether or not
  .queue_rq() will be called are called with the (S)RCU read lock
  held. This is necessary to avoid race conditions against
  the "blk_mq_stop_hw_queues(q); blk_mq_quiesce_queue(q);"
  sequence from another thread.

Signed-off-by: Bart Van Assche 
Cc: Christoph Hellwig 
Cc: Ming Lei 
Cc: Hannes Reinecke 
Cc: Johannes Thumshirn 
---
 block/Kconfig  |  1 +
 block/blk-mq.c | 69 +-
 include/linux/blk-mq.h |  3 +++
 include/linux/blkdev.h |  1 +
 4 files changed, 67 insertions(+), 7 deletions(-)

diff --git a/block/Kconfig b/block/Kconfig
index 1d4d624..0562ef9 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -5,6 +5,7 @@ menuconfig BLOCK
bool "Enable the block layer" if EXPERT
default y
select SBITMAP
+   select SRCU
help
 Provide block layer support for the kernel.
 
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 0cf21c2..4945437 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -115,6 +115,31 @@ void blk_mq_unfreeze_queue(struct request_queue *q)
 }
 EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue);
 
+/**
+ * blk_mq_quiesce_queue() - wait until all ongoing queue_rq calls have finished
+ * @q: request queue.
+ *
+ * Note: this function does not prevent that the struct request end_io()
+ * callback function is invoked. Additionally, it is not prevented that
+ * new queue_rq() calls occur unless the queue has been stopped first.
+ */
+void blk_mq_quiesce_queue(struct request_queue *q)
+{
+   struct blk_mq_hw_ctx *hctx;
+   unsigned int i;
+   bool rcu = false;
+
+   queue_for_each_hw_ctx(q, hctx, i) {
+   if (hctx->flags & BLK_MQ_F_BLOCKING)
+   synchronize_srcu(>queue_rq_srcu);
+   else
+   rcu = true;
+   }
+   if (rcu)
+   synchronize_rcu();
+}
+EXPORT_SYMBOL_GPL(blk_mq_quiesce_queue);
+
 void blk_mq_wake_waiters(struct request_queue *q)
 {
struct blk_mq_hw_ctx *hctx;
@@ -778,7 +803,7 @@ static inline unsigned int queued_to_index(unsigned int 
queued)
  * of IO. In particular, we'd like FIFO behaviour on handling existing
  * items on the hctx->dispatch list. Ignore that for now.
  */
-static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)
+static void blk_mq_process_rq_list(struct blk_mq_hw_ctx *hctx)
 {
struct request_queue *q = hctx->queue;
struct request *rq;
@@ -790,9 +815,6 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx 
*hctx)
if (unlikely(blk_mq_hctx_stopped(hctx)))
return;
 
-   WARN_ON(!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask) &&
-   cpu_online(hctx->next_cpu));
-
hctx->run++;
 
/*
@@ -883,6 +905,24 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx 
*hctx)
}
 }
 
+static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)
+{
+   int srcu_idx;
+
+   WARN_ON(!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask) &&
+   cpu_online(hctx->next_cpu));
+
+   if (!(hctx->flags & BLK_MQ_F_BLOCKING)) {
+   rcu_read_lock();
+   blk_mq_process_rq_list(hctx);
+   rcu_read_unlock();
+   } else {
+   srcu_idx = srcu_read_lock(>queue_rq_srcu);
+   blk_mq_process_rq_list(hctx);
+   srcu_read_unlock(>queue_rq_srcu, srcu_idx);
+   }
+}
+
 /*
  * It'd be great if the workqueue API had a way to pass
  * in a mask and had some smarts for more clever placement.
@@ -1293,7 +1333,7 @@ static blk_qc_t blk_mq_make_request(struct request_queue 
*q, struct bio *bio)
const int is_flush_fua = bio->bi_opf & (REQ_PREFLUSH | REQ_FUA);
struct blk_map_ctx data;
struct request *rq;
-   unsigned int request_count = 0;
+   unsigned int request_count = 0, srcu_idx;
struct blk_plug *plug;
struct request *same_queue_rq = NULL;
blk_qc_t cookie;
@@ -1336,7 +1376,7 @@ static blk_qc_t blk_mq_make_request(struct request_queue 
*q, struct bio *bio)
blk_mq_bio_to_request(rq, bio);
 
/*
-* We do limited pluging. If the bio can be merged, do that.
+ 

[PATCH 04/12] blk-mq: Move more code into blk_mq_direct_issue_request()

2016-10-26 Thread Bart Van Assche
Move the "hctx stopped" test and the insert request calls into
blk_mq_direct_issue_request(). Rename that function into
blk_mq_try_issue_directly() to reflect its new semantics. Pass
the hctx pointer to that function instead of looking it up a
second time. These changes avoid that code has to be duplicated
in the next patch.

Signed-off-by: Bart Van Assche 
Cc: Christoph Hellwig 
Cc: Hannes Reinecke 
Cc: Sagi Grimberg 
Cc: Johannes Thumshirn 
---
 block/blk-mq.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 4643fa8..0cf21c2 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1243,11 +1243,11 @@ static struct request *blk_mq_map_request(struct 
request_queue *q,
return rq;
 }
 
-static int blk_mq_direct_issue_request(struct request *rq, blk_qc_t *cookie)
+static void blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
+ struct request *rq, blk_qc_t *cookie)
 {
int ret;
struct request_queue *q = rq->q;
-   struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, rq->mq_ctx->cpu);
struct blk_mq_queue_data bd = {
.rq = rq,
.list = NULL,
@@ -1255,6 +1255,9 @@ static int blk_mq_direct_issue_request(struct request 
*rq, blk_qc_t *cookie)
};
blk_qc_t new_cookie = blk_tag_to_qc_t(rq->tag, hctx->queue_num);
 
+   if (blk_mq_hctx_stopped(hctx))
+   goto insert;
+
/*
 * For OK queue, we are done. For error, kill it. Any other
 * error (busy), just add it to our list as we previously
@@ -1263,7 +1266,7 @@ static int blk_mq_direct_issue_request(struct request 
*rq, blk_qc_t *cookie)
ret = q->mq_ops->queue_rq(hctx, );
if (ret == BLK_MQ_RQ_QUEUE_OK) {
*cookie = new_cookie;
-   return 0;
+   return;
}
 
__blk_mq_requeue_request(rq);
@@ -1272,10 +1275,11 @@ static int blk_mq_direct_issue_request(struct request 
*rq, blk_qc_t *cookie)
*cookie = BLK_QC_T_NONE;
rq->errors = -EIO;
blk_mq_end_request(rq, rq->errors);
-   return 0;
+   return;
}
 
-   return -1;
+insert:
+   blk_mq_insert_request(rq, false, true, true);
 }
 
 /*
@@ -1352,9 +1356,7 @@ static blk_qc_t blk_mq_make_request(struct request_queue 
*q, struct bio *bio)
blk_mq_put_ctx(data.ctx);
if (!old_rq)
goto done;
-   if (blk_mq_hctx_stopped(data.hctx) ||
-   blk_mq_direct_issue_request(old_rq, ) != 0)
-   blk_mq_insert_request(old_rq, false, true, true);
+   blk_mq_try_issue_directly(data.hctx, old_rq, );
goto done;
}
 
-- 
2.10.1

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


[PATCH 03/12] blk-mq: Introduce blk_mq_queue_stopped()

2016-10-26 Thread Bart Van Assche
The function blk_queue_stopped() allows to test whether or not a
traditional request queue has been stopped. Introduce a helper
function that allows block drivers to query easily whether or not
one or more hardware contexts of a blk-mq queue have been stopped.

Signed-off-by: Bart Van Assche 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Johannes Thumshirn 
Reviewed-by: Sagi Grimberg 
Reviewed-by: Christoph Hellwig 
---
 block/blk-mq.c | 20 
 include/linux/blk-mq.h |  1 +
 2 files changed, 21 insertions(+)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index b52b3a6..4643fa8 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -946,6 +946,26 @@ void blk_mq_run_hw_queues(struct request_queue *q, bool 
async)
 }
 EXPORT_SYMBOL(blk_mq_run_hw_queues);
 
+/**
+ * blk_mq_queue_stopped() - check whether one or more hctxs have been stopped
+ * @q: request queue.
+ *
+ * The caller is responsible for serializing this function against
+ * blk_mq_{start,stop}_hw_queue().
+ */
+bool blk_mq_queue_stopped(struct request_queue *q)
+{
+   struct blk_mq_hw_ctx *hctx;
+   int i;
+
+   queue_for_each_hw_ctx(q, hctx, i)
+   if (blk_mq_hctx_stopped(hctx))
+   return true;
+
+   return false;
+}
+EXPORT_SYMBOL(blk_mq_queue_stopped);
+
 void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx)
 {
cancel_work(>run_work);
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 535ab2e..aa93000 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -223,6 +223,7 @@ void blk_mq_delay_kick_requeue_list(struct request_queue 
*q, unsigned long msecs
 void blk_mq_abort_requeue_list(struct request_queue *q);
 void blk_mq_complete_request(struct request *rq, int error);
 
+bool blk_mq_queue_stopped(struct request_queue *q);
 void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx);
 void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx);
 void blk_mq_stop_hw_queues(struct request_queue *q);
-- 
2.10.1

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


[PATCH 01/12] blk-mq: Do not invoke .queue_rq() for a stopped queue

2016-10-26 Thread Bart Van Assche
The meaning of the BLK_MQ_S_STOPPED flag is "do not call
.queue_rq()". Hence modify blk_mq_make_request() such that requests
are queued instead of issued if a queue has been stopped.

Reported-by: Ming Lei 
Signed-off-by: Bart Van Assche 
Reviewed-by: Christoph Hellwig 
Reviewed-by: Ming Lei 
Cc: Hannes Reinecke 
Cc: Sagi Grimberg 
Cc: Johannes Thumshirn 
Cc: 
---
 block/blk-mq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index ddc2eed..b5dcafb 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1332,9 +1332,9 @@ static blk_qc_t blk_mq_make_request(struct request_queue 
*q, struct bio *bio)
blk_mq_put_ctx(data.ctx);
if (!old_rq)
goto done;
-   if (!blk_mq_direct_issue_request(old_rq, ))
-   goto done;
-   blk_mq_insert_request(old_rq, false, true, true);
+   if (test_bit(BLK_MQ_S_STOPPED, >state) ||
+   blk_mq_direct_issue_request(old_rq, ) != 0)
+   blk_mq_insert_request(old_rq, false, true, true);
goto done;
}
 
-- 
2.10.1

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


[PATCH 0/4] hpsa updates

2016-10-26 Thread Don Brace
These patches are based on Linus's tree

The changes are:
 - do not call pci_disable_device on an already
   disabled device.
 - add a new lockup condition to lockup handler.
 - remove coalescing settings for ioaccel2
 - update driver version.

---

Don Brace (4):
  hpsa: correct lockup detector pci_disable_device
  hpsa: add generate controller NMI on lockup
  hpsa: remove coalescing settings for ioaccel2
  hpsa: bump driver version


 drivers/scsi/hpsa.c |   19 +++
 drivers/scsi/hpsa_cmd.h |1 +
 2 files changed, 12 insertions(+), 8 deletions(-)

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


[PATCH 1/4] hpsa: correct lockup detector pci_disable_device

2016-10-26 Thread Don Brace
need to check if the device is already disabled first

Reviewed-by: Scott Benesh 
Reviewed-by: Scott Teel 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index d007ec1..798fb20 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -8456,7 +8456,8 @@ static void controller_lockup_detected(struct ctlr_info 
*h)
spin_unlock_irqrestore(>lock, flags);
dev_warn(>pdev->dev, "Controller lockup detected: 0x%08x after %d\n",
lockup_detected, h->heartbeat_sample_interval / HZ);
-   pci_disable_device(h->pdev);
+   if (pci_is_enabled(h->pdev))
+   pci_disable_device(h->pdev);
fail_all_outstanding_cmds(h);
 }
 

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


[PATCH 3/4] hpsa: remove coalescing settings for ioaccel2

2016-10-26 Thread Don Brace
- Setting coalescing has a significant negative
  impact on low queue-depth performance.
- Does not help high queue-depth performance.

Reviewed-by: Scott Benesh 
Reviewed-by: Scott Teel 
Reviewed-by: Kevin Barnett 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 9fb739c..810c300 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -9277,13 +9277,9 @@ static int hpsa_enter_performant_mode(struct ctlr_info 
*h, u32 trans_support)
access = SA5_ioaccel_mode1_access;
writel(10, >cfgtable->HostWrite.CoalIntDelay);
writel(4, >cfgtable->HostWrite.CoalIntCount);
-   } else {
-   if (trans_support & CFGTBL_Trans_io_accel2) {
+   } else
+   if (trans_support & CFGTBL_Trans_io_accel2)
access = SA5_ioaccel_mode2_access;
-   writel(10, >cfgtable->HostWrite.CoalIntDelay);
-   writel(4, >cfgtable->HostWrite.CoalIntCount);
-   }
-   }
writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL);
if (hpsa_wait_for_mode_change_ack(h)) {
dev_err(>pdev->dev,

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


[PATCH 2/4] hpsa: add generate controller NMI on lockup

2016-10-26 Thread Don Brace
Tell the controller to NMI when the controller deadlocks.

Reviewed-by: Scott Benesh 
Reviewed-by: Scott Teel 
Reviewed-by: Kevin Barnett 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |6 ++
 drivers/scsi/hpsa_cmd.h |1 +
 2 files changed, 7 insertions(+)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 798fb20..9fb739c 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -8451,6 +8451,12 @@ static void controller_lockup_detected(struct ctlr_info 
*h)
"lockup detected after %d but scratchpad register is 
zero\n",
h->heartbeat_sample_interval / HZ);
lockup_detected = 0x;
+   } else if (lockup_detected == 0x) {
+   /*
+* Ring controller NMI doorbell
+*/
+   dev_warn(>pdev->dev, "Telling controller to do an NMI\n");
+   writel(DOORBELL_GENERATE_NMI, h->vaddr + SA5_DOORBELL);
}
set_lockup_detected_for_all_cpus(h, lockup_detected);
spin_unlock_irqrestore(>lock, flags);
diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
index a584cdf..d186f80 100644
--- a/drivers/scsi/hpsa_cmd.h
+++ b/drivers/scsi/hpsa_cmd.h
@@ -142,6 +142,7 @@
 #define DOORBELL_CTLR_RESET0x0004l
 #define DOORBELL_CTLR_RESET2   0x0020l
 #define DOORBELL_CLEAR_EVENTS  0x0040l
+#define DOORBELL_GENERATE_NMI  0x0080l
 
 #define CFGTBL_Trans_Simple 0x0002l
 #define CFGTBL_Trans_Performant 0x0004l

--
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 4/4] hpsa: bump driver version

2016-10-26 Thread Don Brace
Reviewed-by: Scott Benesh 
Reviewed-by: Scott Teel 
Signed-off-by: Don Brace 
---
 drivers/scsi/hpsa.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 810c300..0b6eb5a 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -60,7 +60,7 @@
  * HPSA_DRIVER_VERSION must be 3 byte values (0-255) separated by '.'
  * with an optional trailing '-' followed by a byte value (0-255).
  */
-#define HPSA_DRIVER_VERSION "3.4.16-0"
+#define HPSA_DRIVER_VERSION "3.4.16-145"
 #define DRIVER_NAME "HP HPSA Driver (v " HPSA_DRIVER_VERSION ")"
 #define HPSA "hpsa"
 

--
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: Device or HBA level QD throttling creates randomness in sequetial workload

2016-10-26 Thread Omar Sandoval
On Tue, Oct 25, 2016 at 12:24:24AM +0530, Kashyap Desai wrote:
> > -Original Message-
> > From: Omar Sandoval [mailto:osan...@osandov.com]
> > Sent: Monday, October 24, 2016 9:11 PM
> > To: Kashyap Desai
> > Cc: linux-scsi@vger.kernel.org; linux-ker...@vger.kernel.org; linux-
> > bl...@vger.kernel.org; ax...@kernel.dk; Christoph Hellwig;
> > paolo.vale...@linaro.org
> > Subject: Re: Device or HBA level QD throttling creates randomness in
> sequetial
> > workload
> >
> > On Mon, Oct 24, 2016 at 06:35:01PM +0530, Kashyap Desai wrote:
> > > >
> > > > On Fri, Oct 21, 2016 at 05:43:35PM +0530, Kashyap Desai wrote:
> > > > > Hi -
> > > > >
> > > > > I found below conversation and it is on the same line as I wanted
> > > > > some input from mailing list.
> > > > >
> > > > > http://marc.info/?l=linux-kernel=147569860526197=2
> > > > >
> > > > > I can do testing on any WIP item as Omar mentioned in above
> > > discussion.
> > > > > https://github.com/osandov/linux/tree/blk-mq-iosched
> > >
> > > I tried build kernel using this repo, but looks like it is not allowed
> > > to reboot due to some changes in  layer.
> >
> > Did you build the most up-to-date version of that branch? I've been
> force
> > pushing to it, so the commit id that you built would be useful.
> > What boot failure are you seeing?
> 
> Below  is latest commit on repo.
> commit b077a9a5149f17ccdaa86bc6346fa256e3c1feda
> Author: Omar Sandoval 
> Date:   Tue Sep 20 11:20:03 2016 -0700
> 
> [WIP] blk-mq: limit bio queue depth
> 
> I have latest repo from 4.9/scsi-next maintained by Martin which boots
> fine.  Only Delta is  " CONFIG_SBITMAP" is enabled in WIP blk-mq-iosched
> branch. I could not see any meaningful data on boot hang, so going to try
> one more time tomorrow.

The blk-mq-bio-queueing branch has the latest work there separated out.
Not sure that it'll help in this case.

> >
> > > >
> > > > Are you using blk-mq for this disk? If not, then the work there
> > > > won't
> > > affect you.
> > >
> > > YES. I am using blk-mq for my test. I also confirm if use_blk_mq is
> > > disable, Sequential work load issue is not seen and  scheduling
> > > works well.
> >
> > Ah, okay, perfect. Can you send the fio job file you're using? Hard to
> tell exactly
> > what's going on without the details. A sequential workload with just one
> > submitter is about as easy as it gets, so this _should_ be behaving
> nicely.
> 
> 
> 
> ; setup numa policy for each thread
> ; 'numactl --show' to determine the maximum numa nodes
> [global]
> ioengine=libaio
> buffered=0
> rw=write
> bssplit=4K/100
> iodepth=256
> numjobs=1
> direct=1
> runtime=60s
> allow_mounted_write=0
> 
> [job1]
> filename=/dev/sdd
> ..
> [job24]
> filename=/dev/sdaa

Okay, so you have one high-iodepth job per disk, got it.

> When I tune /sys/module/scsi_mod/parameters/use_blk_mq = 1, below is a
> ioscheduler detail. (It is in blk-mq mode. )
> /sys/devices/pci:00/:00:02.0/:02:00.0/host10/target10:2:13/10:
> 2:13:0/block/sdq/queue/scheduler:none
> 
> When I have set /sys/module/scsi_mod/parameters/use_blk_mq = 0,
> ioscheduler picked by SML is .
> /sys/devices/pci:00/:00:02.0/:02:00.0/host10/target10:2:13/10:
> 2:13:0/block/sdq/queue/scheduler:noop deadline [cfq]
> 
> I see in blk-mq performance is very low for Sequential Write work load and
> I confirm that blk-mq convert Sequential work load into random stream due
> to  io-scheduler change in blk-mq vs legacy block layer.

Since this happens when the fio iodepth exceeds the per-device QD, my
best guess is that this is that requests are getting requeued and
scrambled when that happens. Do you have the blktrace lying around?

> > > > > Is there any workaround/alternative in latest upstream kernel, if
> > > > > user wants to see limited penalty  for Sequential Work load on HDD
> ?
> > > > >
> > > > > ` Kashyap
> > > > >
> >
> > P.S., your emails are being marked as spam by Gmail. Actually, Gmail
> seems to
> > mark just about everything I get from Broadcom as spam due to failed
> DMARC.
> >
> > --
> > Omar

-- 
Omar
--
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 v2 04/10] phy: qcom-ufs-qmp-xx: Discard remove callback for drivers.

2016-10-26 Thread Kishon Vijay Abraham I


On Tuesday 18 October 2016 07:58 PM, Vivek Gautam wrote:
> remove() callback does a phy_exit() only and nothing else now.

remove callback calls a phy_power_off() ;-)

-Kishon

> The phy_exit() over the generic phy is called from the phy
> consumer, and phy provider driver should not explicitly need to
> call any phy_exit().
> So discard the remove callback for qcom-ufs phy platform drivers.
> 
> Signed-off-by: Vivek Gautam 
> Reviewed-by: Subhash Jadavani 
> ---
> 
> No change since v1.
> 
>  drivers/phy/phy-qcom-ufs-qmp-14nm.c | 16 
>  drivers/phy/phy-qcom-ufs-qmp-20nm.c | 16 
>  drivers/phy/phy-qcom-ufs.c  |  9 -
>  3 files changed, 41 deletions(-)
> 
> diff --git a/drivers/phy/phy-qcom-ufs-qmp-14nm.c 
> b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
> index 6ee5149..a305016 100644
> --- a/drivers/phy/phy-qcom-ufs-qmp-14nm.c
> +++ b/drivers/phy/phy-qcom-ufs-qmp-14nm.c
> @@ -163,21 +163,6 @@ out:
>   return err;
>  }
>  
> -static int ufs_qcom_phy_qmp_14nm_remove(struct platform_device *pdev)
> -{
> - struct device *dev = >dev;
> - struct phy *generic_phy = to_phy(dev);
> - struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(generic_phy);
> - int err = 0;
> -
> - err = ufs_qcom_phy_remove(generic_phy, ufs_qcom_phy);
> - if (err)
> - dev_err(dev, "%s: ufs_qcom_phy_remove failed = %d\n",
> - __func__, err);
> -
> - return err;
> -}
> -
>  static const struct of_device_id ufs_qcom_phy_qmp_14nm_of_match[] = {
>   {.compatible = "qcom,ufs-phy-qmp-14nm"},
>   {},
> @@ -186,7 +171,6 @@ MODULE_DEVICE_TABLE(of, ufs_qcom_phy_qmp_14nm_of_match);
>  
>  static struct platform_driver ufs_qcom_phy_qmp_14nm_driver = {
>   .probe = ufs_qcom_phy_qmp_14nm_probe,
> - .remove = ufs_qcom_phy_qmp_14nm_remove,
>   .driver = {
>   .of_match_table = ufs_qcom_phy_qmp_14nm_of_match,
>   .name = "ufs_qcom_phy_qmp_14nm",
> diff --git a/drivers/phy/phy-qcom-ufs-qmp-20nm.c 
> b/drivers/phy/phy-qcom-ufs-qmp-20nm.c
> index 770087a..2db1fbb 100644
> --- a/drivers/phy/phy-qcom-ufs-qmp-20nm.c
> +++ b/drivers/phy/phy-qcom-ufs-qmp-20nm.c
> @@ -219,21 +219,6 @@ out:
>   return err;
>  }
>  
> -static int ufs_qcom_phy_qmp_20nm_remove(struct platform_device *pdev)
> -{
> - struct device *dev = >dev;
> - struct phy *generic_phy = to_phy(dev);
> - struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(generic_phy);
> - int err = 0;
> -
> - err = ufs_qcom_phy_remove(generic_phy, ufs_qcom_phy);
> - if (err)
> - dev_err(dev, "%s: ufs_qcom_phy_remove failed = %d\n",
> - __func__, err);
> -
> - return err;
> -}
> -
>  static const struct of_device_id ufs_qcom_phy_qmp_20nm_of_match[] = {
>   {.compatible = "qcom,ufs-phy-qmp-20nm"},
>   {},
> @@ -242,7 +227,6 @@ MODULE_DEVICE_TABLE(of, ufs_qcom_phy_qmp_20nm_of_match);
>  
>  static struct platform_driver ufs_qcom_phy_qmp_20nm_driver = {
>   .probe = ufs_qcom_phy_qmp_20nm_probe,
> - .remove = ufs_qcom_phy_qmp_20nm_remove,
>   .driver = {
>   .of_match_table = ufs_qcom_phy_qmp_20nm_of_match,
>   .name = "ufs_qcom_phy_qmp_20nm",
> diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
> index f639a7c..b8f9286 100644
> --- a/drivers/phy/phy-qcom-ufs.c
> +++ b/drivers/phy/phy-qcom-ufs.c
> @@ -645,15 +645,6 @@ int ufs_qcom_phy_calibrate_phy(struct phy *generic_phy, 
> bool is_rate_B)
>  }
>  EXPORT_SYMBOL_GPL(ufs_qcom_phy_calibrate_phy);
>  
> -int ufs_qcom_phy_remove(struct phy *generic_phy,
> - struct ufs_qcom_phy *ufs_qcom_phy)
> -{
> - phy_power_off(generic_phy);
> -
> - return 0;
> -}
> -EXPORT_SYMBOL_GPL(ufs_qcom_phy_remove);
> -
>  int ufs_qcom_phy_exit(struct phy *generic_phy)
>  {
>   struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(generic_phy);
> 
--
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] Avoid that SCSI device removal through sysfs triggers a deadlock

2016-10-26 Thread Bart Van Assche
The solution I prefer is to modify the SCSI scanning code such that
the scan_mutex is only held while performing the actual LUN scanning
and while ensuring that no SCSI device has been created yet for a
certain LUN number but not while the Linux device and its sysfs
attributes are created. Since that approach would require extensive
changes in the SCSI scanning code, another approach has been chosen,
namely to make self-removal asynchronous. This patch avoids that
self-removal triggers the following deadlock:

==
[ INFO: possible circular locking dependency detected ]
4.9.0-rc1-dbg+ #4 Not tainted
---
test_02_sdev_de/12586 is trying to acquire lock:
 (>scan_mutex){+.+.+.}, at: [] 
scsi_remove_device+0x1e/0x40
but task is already holding lock:
 (s_active#336){.+}, at: [] kernfs_remove_self+0xde/0x140
which lock already depends on the new lock.

the existing dependency chain (in reverse order) is:
-> #1 (s_active#336){.+}:
[] lock_acquire+0xe9/0x1d0
[] __kernfs_remove+0x24a/0x310
[] kernfs_remove_by_name_ns+0x40/0x90
[] remove_files.isra.1+0x30/0x70
[] sysfs_remove_group+0x3f/0x90
[] sysfs_remove_groups+0x29/0x40
[] device_remove_attrs+0x59/0x80
[] device_del+0x125/0x240
[] __scsi_remove_device+0x143/0x180
[] scsi_forget_host+0x64/0x70
[] scsi_remove_host+0x75/0x120
[] 0xa035dbbb
[] process_one_work+0x1f5/0x690
[] worker_thread+0x49/0x490
[] kthread+0xeb/0x110
[] ret_from_fork+0x27/0x40

-> #0 (>scan_mutex){+.+.+.}:
[] __lock_acquire+0x10fc/0x1270
[] lock_acquire+0xe9/0x1d0
[] mutex_lock_nested+0x5f/0x360
[] scsi_remove_device+0x1e/0x40
[] sdev_store_delete+0x22/0x30
[] dev_attr_store+0x13/0x20
[] sysfs_kf_write+0x40/0x50
[] kernfs_fop_write+0x137/0x1c0
[] __vfs_write+0x23/0x140
[] vfs_write+0xb0/0x190
[] SyS_write+0x44/0xa0
[] entry_SYSCALL_64_fastpath+0x18/0xad

other info that might help us debug this:

 Possible unsafe locking scenario:
   CPU0CPU1
   
  lock(s_active#336);
   lock(>scan_mutex);
   lock(s_active#336);
  lock(>scan_mutex);

 *** DEADLOCK ***
3 locks held by test_02_sdev_de/12586:
 #0:  (sb_writers#4){.+.+.+}, at: [] vfs_write+0x178/0x190
 #1:  (>mutex){+.+.+.}, at: [] 
kernfs_fop_write+0x101/0x1c0
 #2:  (s_active#336){.+}, at: [] 
kernfs_remove_self+0xde/0x140

stack backtrace:
CPU: 4 PID: 12586 Comm: test_02_sdev_de Not tainted 4.9.0-rc1-dbg+ #4
Call Trace:
 [] dump_stack+0x68/0x93
 [] print_circular_bug+0x1be/0x210
 [] __lock_acquire+0x10fc/0x1270
 [] lock_acquire+0xe9/0x1d0
 [] mutex_lock_nested+0x5f/0x360
 [] scsi_remove_device+0x1e/0x40
 [] sdev_store_delete+0x22/0x30
 [] dev_attr_store+0x13/0x20
 [] sysfs_kf_write+0x40/0x50
 [] kernfs_fop_write+0x137/0x1c0
 [] __vfs_write+0x23/0x140
 [] vfs_write+0xb0/0x190
 [] SyS_write+0x44/0xa0
 [] entry_SYSCALL_64_fastpath+0x18/0xad

References: http://www.spinics.net/lists/linux-scsi/msg86551.html
Signed-off-by: Bart Van Assche 
Cc: Hannes Reinecke 
Cc: Johannes Thumshirn 
Cc: Sagi Grimberg 
Cc: 
---
 drivers/scsi/scsi_priv.h   |  1 +
 drivers/scsi/scsi_scan.c   |  1 +
 drivers/scsi/scsi_sysfs.c  | 19 ++-
 include/scsi/scsi_device.h |  2 ++
 4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index 77bf611..66646c7 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -142,6 +142,7 @@ extern void scsi_sysfs_device_initialize(struct scsi_device 
*);
 extern int scsi_sysfs_target_initialize(struct scsi_device *);
 extern struct scsi_transport_template blank_transport_template;
 extern void __scsi_remove_device(struct scsi_device *);
+extern void scsi_remove_device_work(struct work_struct *work);
 
 extern struct bus_type scsi_bus_type;
 extern const struct attribute_group *scsi_sysfs_shost_attr_groups[];
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 6f7128f..2b11061 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -241,6 +241,7 @@ static struct scsi_device *scsi_alloc_sdev(struct 
scsi_target *starget,
mutex_init(>inquiry_mutex);
INIT_WORK(>event_work, scsi_evt_thread);
INIT_WORK(>requeue_work, scsi_requeue_run_queue);
+   INIT_WORK(>remove_work, scsi_remove_device_work);
 
sdev->sdev_gendev.parent = get_device(>dev);
sdev->sdev_target = starget;
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 0af9c91..d5a7a92 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -705,12 +705,20 @@ store_rescan_field (struct device *dev, struct 
device_attribute *attr,
 }
 static DEVICE_ATTR(rescan, S_IWUSR, NULL, store_rescan_field);
 
+static void scsi_remove_device_async(struct scsi_device *sdev)

Re: [PATCH v3 1/2] scsi: Handle Unit Attention when issuing SCSI command

2016-10-26 Thread Brian King
On 10/26/2016 11:15 AM, Bart Van Assche wrote:
> On Wed, 2016-10-26 at 08:52 -0700, James Bottomley wrote:
>> On Wed, 2016-10-26 at 08:42 -0700, Bart Van Assche wrote:
>>> Can you elaborate on this? Since the sense buffer is available in 
>>> scsi_io_completion() and since that function already calls 
>>> scsi_command_normalize_sense() this function seems like a good 
>>> candidate to me to add retry logic for REQ_TYPE_BLOCK_PC requests.
>>
>> UAs are used to signal AENs to userspace control processes that use
>> BLOCK_PC, like CD changers, burners and scanners.  If we eat UAs
>> inside scsi_io_completion(), we could potentially break any userspace
>> control system that relies on AENs.
> 
> Ignoring the SCSI error handler, the call sequence for reporting UAs to
> user space is as follows: scsi_softirq_done() ->
> scsi_decide_disposition() -> scsi_check_sense() -> scsi_report_sense().
> This means that scsi_report_sense() is called before
> scsi_io_completion() is called. I think this means that what
> scsi_io_completion() decides cannot affect UA reporting to user space?

I think what would break if we just started eating UAs in scsi_io_completion
for BLOCK_PC is applications that are building BLOCK_PC requests and then
checking the sense data in the completed command for a UA. I think this is what
James was referring to. If we wanted to collapse some of this retry logic,
it seems like we might need a way to differentiate between different types of 
BLOCK_PC
requests. A new cmd_flag on struct request, or more generally, a way for scsi
or any user of struct request to pass driver specific data along with the 
request.
This is something I've wanted for ipr, which I've sort of worked around 
currently.

-Brian

-- 
Brian King
Power Linux I/O
IBM Linux Technology Center

--
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: Use the resource-managed function to add devfreq device

2016-10-26 Thread Subhash Jadavani

On 2016-10-26 00:38, Chanwoo Choi wrote:

This patch uses the resource-managed to add the devfreq device.
This function will make it easy to handle the devfreq device.

- struct devfreq *devm_devfreq_add_device(struct device *dev,
  struct devfreq_dev_profile *profile,
  const char *governor_name,
  void *data);
Cc: Vinayak Holikatti 
Cc: James E.J. Bottomley 
Cc: Martin K. Petersen 
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Chanwoo Choi 
---
 drivers/scsi/ufs/ufshcd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index f08d41a2d70b..e639071fd3a1 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -6198,8 +6198,6 @@ void ufshcd_remove(struct ufs_hba *hba)
scsi_host_put(hba->host);

ufshcd_exit_clk_gating(hba);
-   if (ufshcd_is_clkscaling_enabled(hba))
-   devfreq_remove_device(hba->devfreq);
ufshcd_hba_exit(hba);
 }
 EXPORT_SYMBOL_GPL(ufshcd_remove);
@@ -6495,7 +6493,7 @@ int ufshcd_init(struct ufs_hba *hba, void
__iomem *mmio_base, unsigned int irq)
}

if (ufshcd_is_clkscaling_enabled(hba)) {
-   hba->devfreq = devfreq_add_device(dev, _devfreq_profile,
+   hba->devfreq = devm_devfreq_add_device(dev, 
_devfreq_profile,
   "simple_ondemand", NULL);
if (IS_ERR(hba->devfreq)) {
dev_err(hba->dev, "Unable to register with devfreq 
%ld\n",


This change looks good to me but this will have merge conflicts if this 
gets in after my patch series "	[PATCH v1 00/11] scsi: ufs: bug fixes 
patch series #1" (due to "[PATCH v1 06/11] scsi: ufs: suspend clock 
scaling for failed runtime_resume"). so if you can, please pull in my 
patch series and rebase your change on top of it and send it out again.


Thanks,
Subhash

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


Re: [PATCH] scsi_debug: Fix memory leak if LBP enabled and module is unloaded

2016-10-26 Thread Laurence Oberman


- Original Message -
> From: "Ewan D. Milne" 
> To: linux-scsi@vger.kernel.org
> Sent: Wednesday, October 26, 2016 11:22:53 AM
> Subject: [PATCH] scsi_debug: Fix memory leak if LBP enabled and module is 
> unloaded
> 
> From: "Ewan D. Milne" 
> 
> map_storep was not being vfree()'d in the module_exit call.
> 
> Signed-off-by: Ewan D. Milne 
> ---
>  drivers/scsi/scsi_debug.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index c905709..cf04a36 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -5134,6 +5134,7 @@ static void __exit scsi_debug_exit(void)
>   bus_unregister(_lld_bus);
>   root_device_unregister(pseudo_primary);
>  
> + vfree(map_storep);
>   vfree(dif_storep);
>   vfree(fake_storep);
>   kfree(sdebug_q_arr);
> --
> 2.1.0
> 
> --
> 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
> 

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


Re: [PATCH v3 1/2] scsi: Handle Unit Attention when issuing SCSI command

2016-10-26 Thread Bart Van Assche
On Wed, 2016-10-26 at 08:52 -0700, James Bottomley wrote:
> On Wed, 2016-10-26 at 08:42 -0700, Bart Van Assche wrote:
> > Can you elaborate on this? Since the sense buffer is available in 
> > scsi_io_completion() and since that function already calls 
> > scsi_command_normalize_sense() this function seems like a good 
> > candidate to me to add retry logic for REQ_TYPE_BLOCK_PC requests.
> 
> UAs are used to signal AENs to userspace control processes that use
> BLOCK_PC, like CD changers, burners and scanners.  If we eat UAs
> inside scsi_io_completion(), we could potentially break any userspace
> control system that relies on AENs.

Ignoring the SCSI error handler, the call sequence for reporting UAs to
user space is as follows: scsi_softirq_done() ->
scsi_decide_disposition() -> scsi_check_sense() -> scsi_report_sense().
This means that scsi_report_sense() is called before
scsi_io_completion() is called. I think this means that what
scsi_io_completion() decides cannot affect UA reporting to user space?

Bart.

Re: [PATCH v3 1/2] scsi: Handle Unit Attention when issuing SCSI command

2016-10-26 Thread James Bottomley
On Wed, 2016-10-26 at 08:42 -0700, Bart Van Assche wrote:
> On 10/25/2016 04:50 PM, James Bottomley wrote:
> > On Tue, 2016-10-25 at 23:18 +, Bart Van Assche wrote:
> > > Anyway, currently the following functions interpret the SCSI 
> > > sense buffer:
> > > * scsi_io_completion() in scsi_lib.c.
> > > * scsi_mode_sense() in scsi_lib.c.
> > > * scsi_test_unit_ready_flags() in scsi_lib.c.
> > > * scsi_probe_lun() in scsi_scan.c.
> > > * scsi_report_lun_scan() in scsi_scan.c.
> > > * ioctl_internal_command() in scsi_ioctl.c.
> > > * sg_rq_end_io() in sg.c.
> > > * scsi_check_sense() in scsi_error.c.
> > > * spi_execute() in scsi_transport_spi.c.
> > > 
> > > Are you sure we should add sense code interpretation code in a 
> > > tenth function in the SCSI core?
> > 
> > In the absence of a better proposal, yes.  I originally looked into
> > better BLOCK_PC error handling in scsi_io_completion, but that has 
> > some knock on problems, so it seems best to leave it alone.
> 
> Can you elaborate on this? Since the sense buffer is available in 
> scsi_io_completion() and since that function already calls 
> scsi_command_normalize_sense() this function seems like a good 
> candidate to me to add retry logic for REQ_TYPE_BLOCK_PC requests.

UAs are used to signal AENs to userspace control processes that use
BLOCK_PC, like CD changers, burners and scanners.  If we eat UAs inside
scsi_io_completion(), we could potentially break any userspace control
system that relies on AENs.

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 v3 1/2] scsi: Handle Unit Attention when issuing SCSI command

2016-10-26 Thread Bart Van Assche

On 10/25/2016 04:50 PM, James Bottomley wrote:

On Tue, 2016-10-25 at 23:18 +, Bart Van Assche wrote:

Anyway, currently the following functions interpret the SCSI sense
buffer:
* scsi_io_completion() in scsi_lib.c.
* scsi_mode_sense() in scsi_lib.c.
* scsi_test_unit_ready_flags() in scsi_lib.c.
* scsi_probe_lun() in scsi_scan.c.
* scsi_report_lun_scan() in scsi_scan.c.
* ioctl_internal_command() in scsi_ioctl.c.
* sg_rq_end_io() in sg.c.
* scsi_check_sense() in scsi_error.c.
* spi_execute() in scsi_transport_spi.c.

Are you sure we should add sense code interpretation code in a tenth
function in the SCSI core?


In the absence of a better proposal, yes.  I originally looked into
better BLOCK_PC error handling in scsi_io_completion, but that has some
knock on problems, so it seems best to leave it alone.


Can you elaborate on this? Since the sense buffer is available in 
scsi_io_completion() and since that function already calls 
scsi_command_normalize_sense() this function seems like a good candidate 
to me to add retry logic for REQ_TYPE_BLOCK_PC requests.


Thanks,

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


[PATCH] scsi_debug: Fix memory leak if LBP enabled and module is unloaded

2016-10-26 Thread Ewan D. Milne
From: "Ewan D. Milne" 

map_storep was not being vfree()'d in the module_exit call.

Signed-off-by: Ewan D. Milne 
---
 drivers/scsi/scsi_debug.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index c905709..cf04a36 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -5134,6 +5134,7 @@ static void __exit scsi_debug_exit(void)
bus_unregister(_lld_bus);
root_device_unregister(pseudo_primary);
 
+   vfree(map_storep);
vfree(dif_storep);
vfree(fake_storep);
kfree(sdebug_q_arr);
-- 
2.1.0

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


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

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

Chloé Desoutter  changed:

   What|Removed |Added

 Attachment #242701|0   |1
is obsolete||

--- Comment #21 from Chloé Desoutter  ---
Created attachment 242801
  --> https://bugzilla.kernel.org/attachment.cgi?id=242801=edit
pm8001_defs.h patch [2]

Set PM8001_MPI_QUEUE to 256, as in the MicroSemi driver.

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


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

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

--- Comment #20 from Chloé Desoutter  ---
Currently testing w/ PM8001_MPI_QUEUE = 256.

Prospective patch attached.

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


Re: Kernel 4.8.4: INFO: task kworker/u16:8:289 blocked for more than 120 seconds.

2016-10-26 Thread TomK

On 10/26/2016 3:20 AM, Nicholas A. Bellinger wrote:

Hello TomK & Co,

Comments below.

On Tue, 2016-10-25 at 22:05 -0400, TomK wrote:

On 10/25/2016 1:28 AM, TomK wrote:

On 10/24/2016 2:36 AM, Nicholas A. Bellinger wrote:

Hi TomK,

Thanks for reporting this bug.  Comments inline below.

On Mon, 2016-10-24 at 00:45 -0400, TomK wrote:

On 10/24/2016 12:32 AM, TomK wrote:

On 10/23/2016 10:03 PM, TomK wrote:





Including the full log:

http://microdevsys.com/linux-lio/messages-mailing-list





Thanks for posting with qla2xxx verbose debug enabled on your setup.



When tryint to shut down target using /etc/init.d/target stop, the
following is printed repeatedly:

Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-e837:20:
ABTS_RECV_24XX: instance 0
Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-f811:20:
qla_target(0): task abort (s_id=1:5:0, tag=1177068, param=0)
Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-f812:20:
qla_target(0): task abort for non-existant session
Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-f80e:20:
Scheduling work (type 1, prm 880093365680) to find session for param
88010f8c7680 (size 64, tgt 880111f06600)
Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-f800:20: Sess
work (tgt 880111f06600)
Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-e806:20: Sending
task mgmt ABTS response (ha=88010fae, atio=880093365694,
status=4
Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-e838:20:
ABTS_RESP_24XX: compl_status 31
Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-e807:20: Sending
retry TERM EXCH CTIO7 (ha=88010fae)
Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-e806:20: Sending
task mgmt ABTS response (ha=88010fae, atio=88010f8c76c0,
status=0
Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-e838:20:
ABTS_RESP_24XX: compl_status 0
Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-e872:20:
qlt_24xx_atio_pkt_all_vps: qla_target(0): type 6 ox_id 029c
Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-3861:20: New
command while device 880111f06600 is shutting down
Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-e859:20:
qla_target: Unable to send command to target for req, ignoring.




At your earliest convenience, please verify the patch using v4.8.y with
the above ABORT_TASK + shutdown scenario.

Also, it would be helpful to understand why this ESX FC host is
generating ABORT_TASKs.

Eg: Is ABORT_TASK generated due to FC target response packet loss..?
Or due to target backend I/O latency, that ultimately triggers FC host
side timeouts...?



Ok, so the specific hung task warnings reported earlier above are
ABORT_TASK due to the target-core backend md array holding onto
outstanding I/O long enough, for ESX host side SCSI timeouts to begin to
trigger.



+ when I disable the ports on the brocade switch that we're using then
try to stop target, the following is printed:



Oct 24 00:41:31 mbpc-pc kernel: qla2xxx [:04:00.1]-680a:21: Loop
down - seconds remaining 231.
Oct 24 00:41:32 mbpc-pc kernel: qla2xxx [:04:00.0]-680a:20: Loop
down - seconds remaining 153.
Oct 24 00:41:32 mbpc-pc kernel: [ cut here ]
Oct 24 00:41:32 mbpc-pc kernel: WARNING: CPU: 2 PID: 8615 at
lib/list_debug.c:33 __list_add+0xbe/0xd0
Oct 24 00:41:32 mbpc-pc kernel: list_add corruption. prev->next should
be next (88009e83b330), but was 88011fc972a0.
(prev=880118ada4c0).
Oct 24 00:41:32 mbpc-pc kernel: Modules linked in: tcm_qla2xxx tcm_fc
tcm_loop target_core_file target_core_iblock target_core_pscsi
target_core_mod configfs ip6table_filter ip6_tables ebtable_nat ebtables
nf_conntrack_ipv4 nf_defrag_ipv4 xt_state nf_conntrack xt_CHECKSUM
iptable_mangle bridge nfsd lockd grace nfs_acl auth_rpcgss autofs4 it87
hwmon_vid bnx2fc cnic uio fcoe libfcoe libfc 8021q garp stp llc ppdev
parport_pc parport sunrpc cpufreq_ondemand bonding ipv6 crc_ccitt
ipt_REJECT nf_reject_ipv4 xt_multiport iptable_filter ip_tables fuse
vfat fat xfs vhost_net macvtap macvlan vhost tun uinput raid456
async_raid6_recov async_pq async_xor xor async_memcpy async_tx raid6_pq
libcrc32c joydev sg serio_raw e1000 kvm_amd kvm irqbypass r8169 mii
pcspkr k10temp snd_hda_codec_realtek snd_hda_codec_generic snd_hda_intel
snd_hda_codec snd_hda_core snd_hwdep snd_seq snd_seq_device snd_pcm
snd_timer snd soundcore i2c_piix4 i2c_core wmi acpi_cpufreq shpchp ext4
mbcache jbd2 qla2xxx scsi_transport_fc floppy firewire_ohci f
Oct 24 00:41:32 mbpc-pc kernel: irewire_core crc_itu_t sd_mod pata_acpi
ata_generic pata_jmicron ahci libahci usb_storage dm_mirror
dm_region_hash dm_log dm_mod
Oct 24 00:41:32 mbpc-pc kernel: CPU: 2 PID: 8615 Comm: kworker/2:3 Not
tainted 4.8.4 #2
Oct 24 00:41:32 mbpc-pc kernel: Hardware name: Gigabyte Technology Co.,
Ltd. GA-890XA-UD3/GA-890XA-UD3, BIOS FC 08/02/2010
Oct 24 00:41:32 mbpc-pc kernel:  880092b83b48
812e88e9 8130753e

RE: Crash in TCM-LIO

2016-10-26 Thread Gurumurthy, Anil
Hello Nicholas,

-Original Message-
From: Nicholas A. Bellinger [mailto:n...@linux-iscsi.org] 
Sent: 26 October 2016 11:49
To: Gurumurthy, Anil 
Cc: Anil Gurumurthy ; linux-scsi 
; Malavali, Giridhar 
; Tran, Quinn ; TomK 

Subject: Re: Crash in TCM-LIO

Hello Anil & Co,

On Tue, 2016-10-25 at 05:33 +, Gurumurthy, Anil wrote:
> On Mon, 2016-10-24 at 06:36 +, Anil Gurumurthy wrote:



> > 
> > [71884.588748] BUG: unable to handle kernel NULL pointer dereference 
> > at 00e0
> > 
> > [71884.51] IP: [] kmem_cache_free+0x11a/0x200
> > 
> > [71884.588981] PGD 0
> > 
> > [71884.589017] Oops:  [#1] SMP
> > 
> > [71884.589041] [ cut here ]
> > 
> > [71884.589048] WARNING: CPU: 2 PID: 20783 at lib/list_debug.c:62
> > __list_del_entry+0x86/0xd0
> > 
> > [71884.589049] list_del corruption. next->prev should be 
> > 8806f8daeb68, but was 8806f8db79e8
> > 
> > [71884.589075] Modules linked in: target_core_pscsi tcm_qla2xxx(OE)
> > qla2xxx(OE) iscsi_target_mod target_core_file target_core_iblock 
> > target_core_mod netconsole ebtable_nat ebtables ipt_MASQUERADE
> > nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 nf_nat xt_CHECKSUM 
> > iptable_mangle bridge 8021q mrp garp stp llc ipt_REJECT 
> > nf_reject_ipv4
> > nf_conntrack_ipv4 nf_defrag_ipv4 iptable_filter ip_tables 
> > ip6t_REJECT
> > nf_reject_ipv6 nf_conntrack_ipv6 nf_defrag_ipv6 xt_state 
> > nf_conntrack ip6table_filter ip6_tables binfmt_misc vhost_net 
> > macvtap macvlan vhost tun uinput sg serio_raw iTCO_wdt 
> > iTCO_vendor_support ipmi_ssif ipmi_si ipmi_msghandler hpilo hpwdt 
> > bnx2 intel_powerclamp coretemp kvm_intel kvm irqbypass 
> > crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel 
> > pcspkr acpi_power_meter lpc_ich mfd_core i7core_edac edac_core 
> > shpchp ext4(E) mbcache(E) jbd2(E) sd_mod(E)
> > sr_mod(E) cdrom(E) scsi_transport_fc(E) hpsa(E) 
> > scsi_transport_sas(E)
> > aesni_intel(E) ablk_helper(E) cryptd(E) lrw(E) gf128mul(E)
> > glue_helper(E) pata_acpi(E) ata_generic(E) ata_piix(E) libata(E)
> > radeon(E) ttm(E) drm_kms_helper(E) drm(E) fb_sys_fops(E) 
> > sysimgblt(E)
> > sysfillrect(E) syscopyarea(E) i2c_algo_bit(E) i2c_core(E) 
> > dm_mirror(E)
> > dm_region_hash(E) dm_log(E) dm_mod(E) [last unloaded: qla2xxx]
> > 
> > [71884.589091] CPU: 2 PID: 20783 Comm: kworker/2:0 Tainted: GW
> > IOE   4.7.0-rc1+ #2
> > 
> > [71884.589092] Hardware name: HP ProLiant DL380 G7, BIOS P67
> > 05/05/2011
> > 
> > [71884.589107] Workqueue: target_completion target_complete_ok_work 
> > [target_core_mod]
> > 
> > [71884.589109]   880408d1fae8 81352197
> > 81370ef6
> > 
> > [71884.589110]  880408d1fb48 880408d1fb48 
> > 880408d1fb38
> > 
> > [71884.589111]  8108a12d 07c3 003e0246
> > 0246
> > 
> > [71884.589112] Call Trace:
> > 
> > [71884.589115]  [] dump_stack+0x67/0x90
> > 
> > [71884.589117]  [] ? __list_del_entry+0x86/0xd0
> > 
> > [71884.589119]  [] __warn+0xfd/0x120
> > 
> > [71884.589120]  [] warn_slowpath_fmt+0x49/0x50
> > 
> > [71884.589122]  [] __list_del_entry+0x86/0xd0
> > 
> > [71884.589123]  [] list_del+0x11/0x40
> > 
> > [71884.589132]  [] target_remove_from_state_list
> > +0x6e/0x80 [target_core_mod]
> > 
> > [71884.589140]  [] transport_cmd_check_stop
> > +0xe4/0x120 [target_core_mod]
> > 
> > [71884.589151]  []
> > transport_cmd_check_stop_to_fabric+0x15/0x20 [target_core_mod]
> > 
> > [71884.589160]  [] target_complete_ok_work
> > +0x14e/0x280 [target_core_mod]
> > 
> > [71884.589162]  [] ? 
> > pwq_dec_nr_in_flight+0x50/0xa0
> > 
> > [71884.589164]  [] process_one_work+0x183/0x4d0
> > 
> > [71884.589166]  [] ? __schedule+0x1ff/0x5c0
> > 
> > [71884.589167]  [] ? schedule+0x40/0xb0
> > 
> > [71884.589169]  [] worker_thread+0x16d/0x530
> > 
> > [71884.589171]  [] ? __switch_to+0x1cd/0x5e0
> > 
> > [71884.589173]  [] ? __schedule+0x1ff/0x5c0
> > 
> > [71884.589175]  [] ? __wake_up_common+0x56/0x90
> > 
> > [71884.589177]  [] ? 
> > maybe_create_worker+0x120/0x120
> > 
> > [71884.589178]  [] ? schedule+0x40/0xb0
> > 
> > [71884.589179]  [] ? 
> > maybe_create_worker+0x120/0x120
> > 
> > [71884.589180]  [] kthread+0xcc/0xf0
> > 
> > [71884.589183]  [] ? do_syscall_64+0x78/0x1d0
> > 
> > [71884.589185]  [] ? schedule_tail+0x1e/0xc0
> > 
> > [71884.589188]  [] ret_from_fork+0x1f/0x40
> > 
> > [71884.589189]  [] ? kthread_freezable_should_stop
> > +0x70/0x70
> > 
> > [71884.589190] ---[ end trace 7f24d6c863b6e35b ]---
> > 
> > [71884.589204] [ cut here ]
> > 
> > [71884.589206] WARNING: CPU: 2 PID: 20783 at lib/list_debug.c:59
> > __list_del_entry+0xa5/0xd0
> > 
> >  
> 
> Was list corruption preceded by hung kernel task warnings..?
> 
> No. The only messages prior to them 

[PATCH v2 09/11] mpt3sas: Use the new MPI 2.6 32-bit Atomic Request Descriptors for SAS35 devices.

2016-10-26 Thread Suganath Prabu S
Support Atomic Request Descriptors for Ventura/SAS35 devices.

Signed-off-by: Chaitra P B 
Signed-off-by: Sathya Prakash 
Signed-off-by: Suganath Prabu S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/mpt3sas/mpt3sas_base.c  | 141 +++
 drivers/scsi/mpt3sas/mpt3sas_base.h  |  18 ++--
 drivers/scsi/mpt3sas/mpt3sas_config.c|   2 +-
 drivers/scsi/mpt3sas/mpt3sas_ctl.c   |  22 ++---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c |  24 +++---
 drivers/scsi/mpt3sas/mpt3sas_transport.c |   8 +-
 6 files changed, 161 insertions(+), 54 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 43cdc02..f00ef88 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -849,7 +849,7 @@ _base_async_event(struct MPT3SAS_ADAPTER *ioc, u8 
msix_index, u32 reply)
ack_request->EventContext = mpi_reply->EventContext;
ack_request->VF_ID = 0;  /* TODO */
ack_request->VP_ID = 0;
-   mpt3sas_base_put_smid_default(ioc, smid);
+   ioc->put_smid_default(ioc, smid);
 
  out:
 
@@ -2464,15 +2464,15 @@ _base_writeq(__u64 b, volatile void __iomem *addr, 
spinlock_t *writeq_lock)
 #endif
 
 /**
- * mpt3sas_base_put_smid_scsi_io - send SCSI_IO request to firmware
+ * _base_put_smid_scsi_io - send SCSI_IO request to firmware
  * @ioc: per adapter object
  * @smid: system request message index
  * @handle: device handle
  *
  * Return nothing.
  */
-void
-mpt3sas_base_put_smid_scsi_io(struct MPT3SAS_ADAPTER *ioc, u16 smid, u16 
handle)
+static void
+_base_put_smid_scsi_io(struct MPT3SAS_ADAPTER *ioc, u16 smid, u16 handle)
 {
Mpi2RequestDescriptorUnion_t descriptor;
u64 *request = (u64 *)
@@ -2488,15 +2488,15 @@ mpt3sas_base_put_smid_scsi_io(struct MPT3SAS_ADAPTER 
*ioc, u16 smid, u16 handle)
 }
 
 /**
- * mpt3sas_base_put_smid_fast_path - send fast path request to firmware
+ * _base_put_smid_fast_path - send fast path request to firmware
  * @ioc: per adapter object
  * @smid: system request message index
  * @handle: device handle
  *
  * Return nothing.
  */
-void
-mpt3sas_base_put_smid_fast_path(struct MPT3SAS_ADAPTER *ioc, u16 smid,
+static void
+_base_put_smid_fast_path(struct MPT3SAS_ADAPTER *ioc, u16 smid,
u16 handle)
 {
Mpi2RequestDescriptorUnion_t descriptor;
@@ -2513,14 +2513,14 @@ mpt3sas_base_put_smid_fast_path(struct MPT3SAS_ADAPTER 
*ioc, u16 smid,
 }
 
 /**
- * mpt3sas_base_put_smid_hi_priority - send Task Managment request to firmware
+ * _base_put_smid_hi_priority - send Task Management request to firmware
  * @ioc: per adapter object
  * @smid: system request message index
  * @msix_task: msix_task will be same as msix of IO incase of task abort else 
0.
  * Return nothing.
  */
-void
-mpt3sas_base_put_smid_hi_priority(struct MPT3SAS_ADAPTER *ioc, u16 smid,
+static void
+_base_put_smid_hi_priority(struct MPT3SAS_ADAPTER *ioc, u16 smid,
u16 msix_task)
 {
Mpi2RequestDescriptorUnion_t descriptor;
@@ -2537,14 +2537,14 @@ mpt3sas_base_put_smid_hi_priority(struct 
MPT3SAS_ADAPTER *ioc, u16 smid,
 }
 
 /**
- * mpt3sas_base_put_smid_default - Default, primarily used for config pages
+ * _base_put_smid_default - Default, primarily used for config pages
  * @ioc: per adapter object
  * @smid: system request message index
  *
  * Return nothing.
  */
-void
-mpt3sas_base_put_smid_default(struct MPT3SAS_ADAPTER *ioc, u16 smid)
+static void
+_base_put_smid_default(struct MPT3SAS_ADAPTER *ioc, u16 smid)
 {
Mpi2RequestDescriptorUnion_t descriptor;
u64 *request = (u64 *)
@@ -2559,6 +2559,95 @@ mpt3sas_base_put_smid_default(struct MPT3SAS_ADAPTER 
*ioc, u16 smid)
 }
 
 /**
+* _base_put_smid_scsi_io_atomic - send SCSI_IO request to firmware using
+*   Atomic Request Descriptor
+* @ioc: per adapter object
+* @smid: system request message index
+* @handle: device handle, unused in this function, for function type match
+*
+* Return nothing.
+*/
+static void
+_base_put_smid_scsi_io_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid,
+   u16 handle)
+{
+   Mpi26AtomicRequestDescriptor_t descriptor;
+   u32 *request = (u32 *)
+
+   descriptor.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO;
+   descriptor.MSIxIndex = _base_get_msix_index(ioc);
+   descriptor.SMID = cpu_to_le16(smid);
+
+   writel(cpu_to_le32(*request), >chip->AtomicRequestDescriptorPost);
+}
+
+/**
+ * _base_put_smid_fast_path_atomic - send fast path request to firmware
+ * using Atomic Request Descriptor
+ * @ioc: per adapter object
+ * @smid: system request message index
+ * @handle: device handle, unused in this function, for function type match
+ * Return nothing
+ */
+static void
+_base_put_smid_fast_path_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid,
+   u16 handle)
+{
+  

[PATCH v2 04/11] mpt3sas: Removing unused macro "MPT_DEVICE_TLR_ON"

2016-10-26 Thread Suganath Prabu S
Removing macro "MPT_DEVICE_TLR_ON" defined in header file as its unused

Signed-off-by: Chaitra P B 
Signed-off-by: Sathya Prakash 
Signed-off-by: Suganath Prabu S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/mpt3sas/mpt3sas_base.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
b/drivers/scsi/mpt3sas/mpt3sas_base.h
index 4221a4d..e923c91 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -375,7 +375,6 @@ struct MPT3SAS_TARGET {
  * per device private data
  */
 #define MPT_DEVICE_FLAGS_INIT  0x01
-#define MPT_DEVICE_TLR_ON  0x02
 
 #define MFG_PAGE10_HIDE_SSDS_MASK  (0x0003)
 #define MFG_PAGE10_HIDE_ALL_DISKS  (0x00)
-- 
2.4.3

--
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 v2 01/11] mpt3sas: Fix for improper info displayed in var log, while blocking or unblocking the device.

2016-10-26 Thread Suganath Prabu S
Return value and Device_handle Arguments passed in correct order
 to match with its format string.

Signed-off-by: Chaitra P B 
Signed-off-by: Sathya Prakash 
Signed-off-by: Suganath Prabu S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 209a969..282ca40 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -2837,7 +2837,7 @@ _scsih_internal_device_block(struct scsi_device *sdev,
if (r == -EINVAL)
sdev_printk(KERN_WARNING, sdev,
"device_block failed with return(%d) for handle(0x%04x)\n",
-   sas_device_priv_data->sas_target->handle, r);
+   r, sas_device_priv_data->sas_target->handle);
 }
 
 /**
@@ -2867,20 +2867,20 @@ _scsih_internal_device_unblock(struct scsi_device *sdev,
sdev_printk(KERN_WARNING, sdev,
"device_unblock failed with return(%d) for handle(0x%04x) "
"performing a block followed by an unblock\n",
-   sas_device_priv_data->sas_target->handle, r);
+   r, sas_device_priv_data->sas_target->handle);
sas_device_priv_data->block = 1;
r = scsi_internal_device_block(sdev);
if (r)
sdev_printk(KERN_WARNING, sdev, "retried device_block "
"failed with return(%d) for handle(0x%04x)\n",
-   sas_device_priv_data->sas_target->handle, r);
+   r, sas_device_priv_data->sas_target->handle);
 
sas_device_priv_data->block = 0;
r = scsi_internal_device_unblock(sdev, SDEV_RUNNING);
if (r)
sdev_printk(KERN_WARNING, sdev, "retried device_unblock"
" failed with return(%d) for handle(0x%04x)\n",
-   sas_device_priv_data->sas_target->handle, r);
+   r, sas_device_priv_data->sas_target->handle);
}
 }
 
-- 
2.4.3

--
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 v2 11/11] mpt3sas: Bump driver version as "14.101.00.00"

2016-10-26 Thread Suganath Prabu S
Signed-off-by: Chaitra P B 
Signed-off-by: Sathya Prakash 
Signed-off-by: Suganath Prabu S 
---
 drivers/scsi/mpt3sas/mpt3sas_base.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
b/drivers/scsi/mpt3sas/mpt3sas_base.h
index 5d9ae15..8de0eda 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -73,9 +73,9 @@
 #define MPT3SAS_DRIVER_NAME"mpt3sas"
 #define MPT3SAS_AUTHOR "Avago Technologies "
 #define MPT3SAS_DESCRIPTION"LSI MPT Fusion SAS 3.0 Device Driver"
-#define MPT3SAS_DRIVER_VERSION "14.100.00.00"
+#define MPT3SAS_DRIVER_VERSION "14.101.00.00"
 #define MPT3SAS_MAJOR_VERSION  14
-#define MPT3SAS_MINOR_VERSION  100
+#define MPT3SAS_MINOR_VERSION  101
 #define MPT3SAS_BUILD_VERSION  0
 #define MPT3SAS_RELEASE_VERSION00
 
-- 
2.4.3

--
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 v2 10/11] mpt3sas: Fix for Endianness issue.

2016-10-26 Thread Suganath Prabu S
Use le16_to_cpu only for accessing two byte data provided by controller.

Signed-off-by: Chaitra P B 
Signed-off-by: Sathya Prakash 
Signed-off-by: Suganath Prabu S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 6d17f66..981be7b 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -5384,10 +5384,10 @@ _scsih_check_device(struct MPT3SAS_ADAPTER *ioc,
sas_device->handle, handle);
sas_target_priv_data->handle = handle;
sas_device->handle = handle;
-   if (sas_device_pg0.Flags &
+   if (le16_to_cpu(sas_device_pg0.Flags) &
 MPI2_SAS_DEVICE0_FLAGS_ENCL_LEVEL_VALID) {
sas_device->enclosure_level =
-   le16_to_cpu(sas_device_pg0.EnclosureLevel);
+   sas_device_pg0.EnclosureLevel;
memcpy(sas_device->connector_name,
sas_device_pg0.ConnectorName, 4);
sas_device->connector_name[4] = '\0';
@@ -5516,9 +5516,10 @@ _scsih_add_device(struct MPT3SAS_ADAPTER *ioc, u16 
handle, u8 phy_num,
sas_device->fast_path = (le16_to_cpu(sas_device_pg0.Flags) &
MPI25_SAS_DEVICE0_FLAGS_FAST_PATH_CAPABLE) ? 1 : 0;
 
-   if (sas_device_pg0.Flags & MPI2_SAS_DEVICE0_FLAGS_ENCL_LEVEL_VALID) {
+   if (le16_to_cpu(sas_device_pg0.Flags)
+   & MPI2_SAS_DEVICE0_FLAGS_ENCL_LEVEL_VALID) {
sas_device->enclosure_level =
-   le16_to_cpu(sas_device_pg0.EnclosureLevel);
+   sas_device_pg0.EnclosureLevel;
memcpy(sas_device->connector_name,
sas_device_pg0.ConnectorName, 4);
sas_device->connector_name[4] = '\0';
@@ -7056,7 +7057,7 @@ Mpi2SasDevicePage0_t *sas_device_pg0)
if (sas_device_pg0->Flags &
  MPI2_SAS_DEVICE0_FLAGS_ENCL_LEVEL_VALID) {
sas_device->enclosure_level =
-  le16_to_cpu(sas_device_pg0->EnclosureLevel);
+  sas_device_pg0->EnclosureLevel;
memcpy(_device->connector_name[0],
_device_pg0->ConnectorName[0], 4);
} else {
@@ -7118,6 +7119,7 @@ _scsih_search_responding_sas_devices(struct 
MPT3SAS_ADAPTER *ioc)
sas_device_pg0.SASAddress =
le64_to_cpu(sas_device_pg0.SASAddress);
sas_device_pg0.Slot = le16_to_cpu(sas_device_pg0.Slot);
+   sas_device_pg0.Flags = le16_to_cpu(sas_device_pg0.Flags);
_scsih_mark_responding_sas_device(ioc, _device_pg0);
}
 
-- 
2.4.3

--
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 v2 02/11] mpt3sas: Fix for incorrect numbers for MSIX vectors enabled when non RDPQ card is enumerated first.

2016-10-26 Thread Suganath Prabu S
No. of MSIX vectors supported = min (Total no. of CPU cores,
MSIX vectors supported by card)

when RDPQ is disabled "max_msix_vectors" module parameter which was
declared as global was set to '8' and hence if there are more than one card
in system among which if RDPQ disabled card is enumerated first then only 8
MSIX vectors was getting enabled for all the cards(including RDPQ enabled
card,which can support more than 8 MSIX vectors).

Used local variable instead of global variable ,if RDPQ is disabled this
local variable is set to '8' else it is set to "max_msix_vectors" (by
default this is set to -1, whose value can be set by user during driver
load time).So now regardless of whether RDPQ disabled card is enumerated
first or RDPQ enabled card is enumerated first , MSIX vectors enabled
depends on the cards capability.

Signed-off-by: Chaitra P B 
Signed-off-by: Sathya Prakash 
Signed-off-by: Suganath Prabu S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
b/drivers/scsi/mpt3sas/mpt3sas_base.c
index a1a5ceb..4ea81e1 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -1959,7 +1959,7 @@ _base_enable_msix(struct MPT3SAS_ADAPTER *ioc)
 {
struct msix_entry *entries, *a;
int r;
-   int i;
+   int i, local_max_msix_vectors;
u8 try_msix = 0;
 
if (msix_disable == -1 || msix_disable == 0)
@@ -1979,13 +1979,15 @@ _base_enable_msix(struct MPT3SAS_ADAPTER *ioc)
  ioc->cpu_count, max_msix_vectors);
 
if (!ioc->rdpq_array_enable && max_msix_vectors == -1)
-   max_msix_vectors = 8;
+   local_max_msix_vectors = 8;
+   else
+   local_max_msix_vectors = max_msix_vectors;
 
-   if (max_msix_vectors > 0) {
-   ioc->reply_queue_count = min_t(int, max_msix_vectors,
+   if (local_max_msix_vectors > 0) {
+   ioc->reply_queue_count = min_t(int, local_max_msix_vectors,
ioc->reply_queue_count);
ioc->msix_vector_count = ioc->reply_queue_count;
-   } else if (max_msix_vectors == 0)
+   } else if (local_max_msix_vectors == 0)
goto try_ioapic;
 
if (ioc->msix_vector_count < ioc->cpu_count)
-- 
2.4.3

--
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 v2 06/11] mpt3sas: Added Device ID's for SAS35 devices and updated MPI header.

2016-10-26 Thread Suganath Prabu S
Added Device ID's for SAS35 devices (Ventura, Crusader, Harpoon &
Tomcat) and updated mpi header file for the same. Also added
"is_gen35_ioc" to MPT3SAS_ADAPTER structure for identifying SAS35 adapters.

Signed-off-by: Chaitra P B 
Signed-off-by: Sathya Prakash 
Signed-off-by: Suganath Prabu S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h |  7 +++
 drivers/scsi/mpt3sas/mpt3sas_base.h  |  1 +
 drivers/scsi/mpt3sas/mpt3sas_ctl.c   |  5 -
 drivers/scsi/mpt3sas/mpt3sas_ctl.h   |  1 +
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 31 +++
 5 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h 
b/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h
index 95356a8..fa61baf 100644
--- a/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h
+++ b/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h
@@ -478,6 +478,13 @@ typedef struct _MPI2_CONFIG_REPLY {
 #define MPI26_MFGPAGE_DEVID_SAS3324_3   (0x00C2)
 #define MPI26_MFGPAGE_DEVID_SAS3324_4   (0x00C3)
 
+#define MPI26_MFGPAGE_DEVID_SAS3516 (0x00AA)
+#define MPI26_MFGPAGE_DEVID_SAS3516_1   (0x00AB)
+#define MPI26_MFGPAGE_DEVID_SAS3416 (0x00AC)
+#define MPI26_MFGPAGE_DEVID_SAS3508 (0x00AD)
+#define MPI26_MFGPAGE_DEVID_SAS3508_1   (0x00AE)
+#define MPI26_MFGPAGE_DEVID_SAS3408 (0x00AF)
+
 /*Manufacturing Page 0 */
 
 typedef struct _MPI2_CONFIG_PAGE_MAN_0 {
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
b/drivers/scsi/mpt3sas/mpt3sas_base.h
index 6f03a86..3d75c57 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -1191,6 +1191,7 @@ struct MPT3SAS_ADAPTER {
struct SL_WH_MPI_TRIGGERS_T diag_trigger_mpi;
void*device_remove_in_progress;
u16 device_remove_in_progress_sz;
+   u8  is_gen35_ioc;
 };
 
 typedef u8 (*MPT_CALLBACK)(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 
msix_index,
diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c 
b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
index de720c9..a287bfb 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
@@ -1096,7 +1096,10 @@ _ctl_getiocinfo(struct MPT3SAS_ADAPTER *ioc, void __user 
*arg)
break;
case MPI25_VERSION:
case MPI26_VERSION:
-   karg.adapter_type = MPT3_IOCTL_INTERFACE_SAS3;
+   if (ioc->is_gen35_ioc)
+   karg.adapter_type = MPT3_IOCTL_INTERFACE_SAS35;
+   else
+   karg.adapter_type = MPT3_IOCTL_INTERFACE_SAS3;
strcat(karg.driver_version, MPT3SAS_DRIVER_VERSION);
break;
}
diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.h 
b/drivers/scsi/mpt3sas/mpt3sas_ctl.h
index 8940835..f3e17a8 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.h
@@ -143,6 +143,7 @@ struct mpt3_ioctl_pci_info {
 #define MPT2_IOCTL_INTERFACE_SAS2  (0x04)
 #define MPT2_IOCTL_INTERFACE_SAS2_SSS6200  (0x05)
 #define MPT3_IOCTL_INTERFACE_SAS3  (0x06)
+#define MPT3_IOCTL_INTERFACE_SAS35 (0x07)
 #define MPT2_IOCTL_VERSION_LENGTH  (32)
 
 /**
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 9584d6b..521849d 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -8660,6 +8660,12 @@ _scsih_determine_hba_mpi_version(struct pci_dev *pdev)
case MPI26_MFGPAGE_DEVID_SAS3324_2:
case MPI26_MFGPAGE_DEVID_SAS3324_3:
case MPI26_MFGPAGE_DEVID_SAS3324_4:
+   case MPI26_MFGPAGE_DEVID_SAS3508:
+   case MPI26_MFGPAGE_DEVID_SAS3508_1:
+   case MPI26_MFGPAGE_DEVID_SAS3408:
+   case MPI26_MFGPAGE_DEVID_SAS3516:
+   case MPI26_MFGPAGE_DEVID_SAS3516_1:
+   case MPI26_MFGPAGE_DEVID_SAS3416:
return MPI26_VERSION;
}
return 0;
@@ -8728,6 +8734,18 @@ _scsih_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
ioc->hba_mpi_version_belonged = hba_mpi_version;
ioc->id = mpt3_ids++;
sprintf(ioc->driver_name, "%s", MPT3SAS_DRIVER_NAME);
+   switch (pdev->device) {
+   case MPI26_MFGPAGE_DEVID_SAS3508:
+   case MPI26_MFGPAGE_DEVID_SAS3508_1:
+   case MPI26_MFGPAGE_DEVID_SAS3408:
+   case MPI26_MFGPAGE_DEVID_SAS3516:
+   case MPI26_MFGPAGE_DEVID_SAS3516_1:
+   case MPI26_MFGPAGE_DEVID_SAS3416:
+   ioc->is_gen35_ioc = 1;
+   break;
+   default:
+   ioc->is_gen35_ioc = 0;
+   }
if ((ioc->hba_mpi_version_belonged == MPI25_VERSION &&
 

[PATCH v2 08/11] mpt3sas: set EEDP-escape-flags for SAS35 devices.

2016-10-26 Thread Suganath Prabu S
An UNMAP command on a PI formatted device will leave the Logical Block
Application Tag and Logical Block Reference Tag as all F's (for those LBAs
that are unmapped). To avoid IO errors if those LBAs are subsequently read
before they are written with valid tag fields, the MPI SCSI IO requests
need to set the EEDPFlags element EEDP Escape Mode field, Bits [7:6]
appropriately. A value of 2 should be set to disable all PI checks if the
Logical Block Application Tag is 0x for PI types 1 and 2.  A value
of 3 should be set to disable all PI checks if the Logical Block
Application Tag is 0x and the Logical Block Reference Tag is
0x for PI type 3.

Signed-off-by: Chaitra P B 
Signed-off-by: Sathya Prakash 
Signed-off-by: Suganath Prabu S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index a1c541d..c58f326 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -3989,6 +3989,9 @@ _scsih_setup_eedp(struct MPT3SAS_ADAPTER *ioc, struct 
scsi_cmnd *scmd,
 
mpi_request_3v->EEDPBlockSize =
cpu_to_le16(scmd->device->sector_size);
+
+   if (ioc->is_gen35_ioc)
+   eedp_flags |= MPI25_SCSIIO_EEDPFLAGS_APPTAG_DISABLE_MODE;
mpi_request->EEDPFlags = cpu_to_le16(eedp_flags);
 }
 
-- 
2.4.3

--
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 v2 07/11] mpt3sas: Increased/Additional MSIX support for SAS35 devices.

2016-10-26 Thread Suganath Prabu S
For SAS35 devices MSIX vectors are inceased to 128 from 96. To support this
Reply post host index register count is increased to 16. Also variable
msix96_vector is replaced with combined_reply_queue and variable
combined_reply_index_count is added to set different values for SAS3 and
SAS35 devices.

Signed-off-by: Chaitra P B 
Signed-off-by: Sathya Prakash 
Signed-off-by: Suganath Prabu S 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/mpt3sas/mpt3sas_base.c  | 14 +++---
 drivers/scsi/mpt3sas/mpt3sas_base.h  |  8 +---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 11 +--
 3 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 9ad7f7c..43cdc02 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -1078,7 +1078,7 @@ _base_interrupt(int irq, void *bus_id)
 * new reply host index value in ReplyPostIndex Field and msix_index
 * value in MSIxIndex field.
 */
-   if (ioc->msix96_vector)
+   if (ioc->combined_reply_queue)
writel(reply_q->reply_post_host_index | ((msix_index  & 7) <<
MPI2_RPHI_MSIX_INDEX_SHIFT),
ioc->replyPostRegisterIndex[msix_index/8]);
@@ -2052,7 +2052,7 @@ mpt3sas_base_unmap_resources(struct MPT3SAS_ADAPTER *ioc)
_base_free_irq(ioc);
_base_disable_msix(ioc);
 
-   if (ioc->msix96_vector) {
+   if (ioc->combined_reply_queue) {
kfree(ioc->replyPostRegisterIndex);
ioc->replyPostRegisterIndex = NULL;
}
@@ -2162,7 +2162,7 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc)
/* Use the Combined reply queue feature only for SAS3 C0 & higher
 * revision HBAs and also only when reply queue count is greater than 8
 */
-   if (ioc->msix96_vector && ioc->reply_queue_count > 8) {
+   if (ioc->combined_reply_queue && ioc->reply_queue_count > 8) {
/* Determine the Supplemental Reply Post Host Index Registers
 * Addresse. Supplemental Reply Post Host Index Registers
 * starts at offset MPI25_SUP_REPLY_POST_HOST_INDEX_OFFSET and
@@ -2170,7 +2170,7 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc)
 * MPT3_SUP_REPLY_POST_HOST_INDEX_REG_OFFSET from previous one.
 */
ioc->replyPostRegisterIndex = kcalloc(
-MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT,
+ioc->combined_reply_index_count,
 sizeof(resource_size_t *), GFP_KERNEL);
if (!ioc->replyPostRegisterIndex) {
dfailprintk(ioc, printk(MPT3SAS_FMT
@@ -2180,14 +2180,14 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc)
goto out_fail;
}
 
-   for (i = 0; i < MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT; i++) {
+   for (i = 0; i < ioc->combined_reply_index_count; i++) {
ioc->replyPostRegisterIndex[i] = (resource_size_t *)
 ((u8 *)>chip->Doorbell +
 MPI25_SUP_REPLY_POST_HOST_INDEX_OFFSET +
 (i * MPT3_SUP_REPLY_POST_HOST_INDEX_REG_OFFSET));
}
} else
-   ioc->msix96_vector = 0;
+   ioc->combined_reply_queue = 0;
 
if (ioc->is_warpdrive) {
ioc->reply_post_host_index[0] = (resource_size_t __iomem *)
@@ -5140,7 +5140,7 @@ _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc)
 
/* initialize reply post host index */
list_for_each_entry(reply_q, >reply_queue_list, list) {
-   if (ioc->msix96_vector)
+   if (ioc->combined_reply_queue)
writel((reply_q->msix_index & 7)<<
   MPI2_RPHI_MSIX_INDEX_SHIFT,
   ioc->replyPostRegisterIndex[reply_q->msix_index/8]);
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
b/drivers/scsi/mpt3sas/mpt3sas_base.h
index 3d75c57..acb4106 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -300,8 +300,9 @@
  * There are twelve Supplemental Reply Post Host Index Registers
  * and each register is at offset 0x10 bytes from the previous one.
  */
-#define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT 12
-#define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_OFFSET (0x10)
+#define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT_G312
+#define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT_G35   16
+#define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_OFFSET  (0x10)
 
 /* OEM Identifiers */
 #define MFG10_OEM_ID_INVALID   (0x)
@@ -1158,7 +1159,8 @@ struct MPT3SAS_ADAPTER {

[PATCH v2 00/11] mpt3sas driver Enhancements and

2016-10-26 Thread Suganath Prabu S
Here is the change list:
Posting 11 patches for mpt3sas driver enhancements and few fixes.
  * Added Device ID's for SAS35 devices and updated MPI Header.
  * Support "EEDP Escape flag" for SAS35 devices.
  * fixed improper printk statement.
  * Regardless of whether RDPQ disabled card is enumerated
first or RDPQ enabled card is enumerated first, MSIX vectors
depends on the cards capability.
  * device_remove_in_progress bit check has been added in IOCTL path. If
bit is set, then IOCTL will be failed printing failure message.
  * Started using the Atomic Request Descriptors for
SAS35 devices.
  * For SAS35 devices MSIX vectors are inceased to 128 from 96.
  * Fixing Endianness issue.
  * Updated driver version to 14.100.00.00 at the end of SAS3
changes and updated driver minor version to 14.101.00.00
after SAS35 changes.

Suganath Prabu S (11):
  mpt3sas: Fix for improper info displayed in var log, while blocking or
unblocking the device.
  mpt3sas: Fix for incorrect numbers for MSIX vectors enabled when non
RDPQ card is enumerated first.
  mpt3sas: Implement device_remove_in_progress check in  IOCTL path
  mpt3sas: Removing unused macro "MPT_DEVICE_TLR_ON"
  mpt3sas: Bump driver version as "14.100.00.00"
  mpt3sas: Added Device ID's for SAS35 devices and updated MPI header.
  mpt3sas: Increased/Additional MSIX support for SAS35 devices.
  mpt3sas: set EEDP-escape-flags for SAS35 devices.
  mpt3sas: Use the new MPI 2.6 32-bit Atomic Request  Descriptors
for SAS35 devices.
  mpt3sas: Fix for Endianness issue.
  mpt3sas: Bump driver version as "14.101.00.00"

 drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h |   7 ++
 drivers/scsi/mpt3sas/mpt3sas_base.c  | 186 ++-
 drivers/scsi/mpt3sas/mpt3sas_base.h  |  39 ---
 drivers/scsi/mpt3sas/mpt3sas_config.c|   2 +-
 drivers/scsi/mpt3sas/mpt3sas_ctl.c   |  69 +---
 drivers/scsi/mpt3sas/mpt3sas_ctl.h   |   1 +
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 113 +++
 drivers/scsi/mpt3sas/mpt3sas_transport.c |   8 +-
 8 files changed, 334 insertions(+), 91 deletions(-)

Thanks,
Suganath prabu S 
-- 
2.4.3

--
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 v2 03/11] mpt3sas: Implement device_remove_in_progress check in IOCTL path

2016-10-26 Thread Suganath Prabu S
When device missing event arrives, device_remove_in_progress bit will be
set and hence driver has to stop sending IOCTL commands.Now the check has
been added in IOCTL path to test device_remove_in_progress bit is set, if
so then IOCTL will be failed printing failure message.

Signed-off-by: Chaitra P B 
Signed-off-by: Sathya Prakash 
Signed-off-by: Suganath Prabu S 
---
 drivers/scsi/mpt3sas/mpt3sas_base.c  | 19 +++
 drivers/scsi/mpt3sas/mpt3sas_base.h  |  5 
 drivers/scsi/mpt3sas/mpt3sas_ctl.c   | 46 ++--
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 24 ++-
 4 files changed, 86 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 4ea81e1..9ad7f7c 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -5334,6 +5334,21 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
goto out_free_resources;
}
 
+   /* allocate memory for pending OS device add list */
+   ioc->pend_os_device_add_sz = (ioc->facts.MaxDevHandle / 8);
+   if (ioc->facts.MaxDevHandle % 8)
+   ioc->pend_os_device_add_sz++;
+   ioc->pend_os_device_add = kzalloc(ioc->pend_os_device_add_sz,
+   GFP_KERNEL);
+   if (!ioc->pend_os_device_add)
+   goto out_free_resources;
+
+   ioc->device_remove_in_progress_sz = ioc->pend_os_device_add_sz;
+   ioc->device_remove_in_progress =
+   kzalloc(ioc->device_remove_in_progress_sz, GFP_KERNEL);
+   if (!ioc->device_remove_in_progress)
+   goto out_free_resources;
+
ioc->fwfault_debug = mpt3sas_fwfault_debug;
 
/* base internal command bits */
@@ -5416,6 +5431,8 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
kfree(ioc->reply_post_host_index);
kfree(ioc->pd_handles);
kfree(ioc->blocking_handles);
+   kfree(ioc->device_remove_in_progress);
+   kfree(ioc->pend_os_device_add);
kfree(ioc->tm_cmds.reply);
kfree(ioc->transport_cmds.reply);
kfree(ioc->scsih_cmds.reply);
@@ -5457,6 +5474,8 @@ mpt3sas_base_detach(struct MPT3SAS_ADAPTER *ioc)
kfree(ioc->reply_post_host_index);
kfree(ioc->pd_handles);
kfree(ioc->blocking_handles);
+   kfree(ioc->device_remove_in_progress);
+   kfree(ioc->pend_os_device_add);
kfree(ioc->pfacts);
kfree(ioc->ctl_cmds.reply);
kfree(ioc->ctl_cmds.sense);
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
b/drivers/scsi/mpt3sas/mpt3sas_base.h
index 3e71bc1..4221a4d 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -1079,6 +1079,9 @@ struct MPT3SAS_ADAPTER {
void*pd_handles;
u16 pd_handles_sz;
 
+   void*pend_os_device_add;
+   u16 pend_os_device_add_sz;
+
/* config page */
u16 config_page_sz;
void*config_page;
@@ -1187,6 +1190,8 @@ struct MPT3SAS_ADAPTER {
struct SL_WH_EVENT_TRIGGERS_T diag_trigger_event;
struct SL_WH_SCSI_TRIGGERS_T diag_trigger_scsi;
struct SL_WH_MPI_TRIGGERS_T diag_trigger_mpi;
+   void*device_remove_in_progress;
+   u16 device_remove_in_progress_sz;
 };
 
 typedef u8 (*MPT_CALLBACK)(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 
msix_index,
diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c 
b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
index 26cdc12..de720c9 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
@@ -654,6 +654,7 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct 
mpt3_ioctl_command karg,
size_t data_in_sz = 0;
long ret;
u16 wait_state_count;
+   u16 device_handle = MPT3SAS_INVALID_DEVICE_HANDLE;
 
issue_reset = 0;
 
@@ -738,10 +739,13 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct 
mpt3_ioctl_command karg,
data_in_sz = karg.data_in_size;
 
if (mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST ||
-   mpi_request->Function == MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH) {
-   if (!le16_to_cpu(mpi_request->FunctionDependent1) ||
-   le16_to_cpu(mpi_request->FunctionDependent1) >
-   ioc->facts.MaxDevHandle) {
+   mpi_request->Function == MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH ||
+   mpi_request->Function == MPI2_FUNCTION_SCSI_TASK_MGMT ||
+   mpi_request->Function == MPI2_FUNCTION_SATA_PASSTHROUGH) {
+
+   device_handle = le16_to_cpu(mpi_request->FunctionDependent1);
+   if (!device_handle || (device_handle >
+   ioc->facts.MaxDevHandle)) {
ret = -EINVAL;

[PATCH v2 05/11] mpt3sas: Bump driver version as "14.100.00.00"

2016-10-26 Thread Suganath Prabu S
Signed-off-by: Chaitra P B 
Signed-off-by: Sathya Prakash 
Signed-off-by: Suganath Prabu S 
---
 drivers/scsi/mpt3sas/mpt3sas_base.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
b/drivers/scsi/mpt3sas/mpt3sas_base.h
index e923c91..6f03a86 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -73,8 +73,8 @@
 #define MPT3SAS_DRIVER_NAME"mpt3sas"
 #define MPT3SAS_AUTHOR "Avago Technologies "
 #define MPT3SAS_DESCRIPTION"LSI MPT Fusion SAS 3.0 Device Driver"
-#define MPT3SAS_DRIVER_VERSION "13.100.00.00"
-#define MPT3SAS_MAJOR_VERSION  13
+#define MPT3SAS_DRIVER_VERSION "14.100.00.00"
+#define MPT3SAS_MAJOR_VERSION  14
 #define MPT3SAS_MINOR_VERSION  100
 #define MPT3SAS_BUILD_VERSION  0
 #define MPT3SAS_RELEASE_VERSION00
-- 
2.4.3

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


[PATCH 2/2] scsi: ufs: Use the resource-managed function to add devfreq device

2016-10-26 Thread Chanwoo Choi
This patch uses the resource-managed to add the devfreq device.
This function will make it easy to handle the devfreq device.

- struct devfreq *devm_devfreq_add_device(struct device *dev,
  struct devfreq_dev_profile *profile,
  const char *governor_name,
  void *data);
Cc: Vinayak Holikatti 
Cc: James E.J. Bottomley 
Cc: Martin K. Petersen 
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Chanwoo Choi 
---
 drivers/scsi/ufs/ufshcd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index f08d41a2d70b..e639071fd3a1 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -6198,8 +6198,6 @@ void ufshcd_remove(struct ufs_hba *hba)
scsi_host_put(hba->host);
 
ufshcd_exit_clk_gating(hba);
-   if (ufshcd_is_clkscaling_enabled(hba))
-   devfreq_remove_device(hba->devfreq);
ufshcd_hba_exit(hba);
 }
 EXPORT_SYMBOL_GPL(ufshcd_remove);
@@ -6495,7 +6493,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem 
*mmio_base, unsigned int irq)
}
 
if (ufshcd_is_clkscaling_enabled(hba)) {
-   hba->devfreq = devfreq_add_device(dev, _devfreq_profile,
+   hba->devfreq = devm_devfreq_add_device(dev, 
_devfreq_profile,
   "simple_ondemand", NULL);
if (IS_ERR(hba->devfreq)) {
dev_err(hba->dev, "Unable to register with devfreq 
%ld\n",
-- 
1.9.1

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


[PATCH 2/2] scsi: ufs: Use the resource-managed function to add devfreq device

2016-10-26 Thread Chanwoo Choi
This patch uses the resource-managed to add the devfreq device.
This function will make it easy to handle the devfreq device.

- struct devfreq *devm_devfreq_add_device(struct device *dev,
  struct devfreq_dev_profile *profile,
  const char *governor_name,
  void *data);
Cc: Vinayak Holikatti 
Cc: James E.J. Bottomley 
Cc: Martin K. Petersen 
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Chanwoo Choi 
---
 drivers/scsi/ufs/ufshcd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index f08d41a2d70b..e639071fd3a1 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -6198,8 +6198,6 @@ void ufshcd_remove(struct ufs_hba *hba)
scsi_host_put(hba->host);
 
ufshcd_exit_clk_gating(hba);
-   if (ufshcd_is_clkscaling_enabled(hba))
-   devfreq_remove_device(hba->devfreq);
ufshcd_hba_exit(hba);
 }
 EXPORT_SYMBOL_GPL(ufshcd_remove);
@@ -6495,7 +6493,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem 
*mmio_base, unsigned int irq)
}
 
if (ufshcd_is_clkscaling_enabled(hba)) {
-   hba->devfreq = devfreq_add_device(dev, _devfreq_profile,
+   hba->devfreq = devm_devfreq_add_device(dev, 
_devfreq_profile,
   "simple_ondemand", NULL);
if (IS_ERR(hba->devfreq)) {
dev_err(hba->dev, "Unable to register with devfreq 
%ld\n",
-- 
1.9.1

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


Re: Kernel 4.8.4: INFO: task kworker/u16:8:289 blocked for more than 120 seconds.

2016-10-26 Thread Nicholas A. Bellinger
Hello TomK & Co,

Comments below.

On Tue, 2016-10-25 at 22:05 -0400, TomK wrote:
> On 10/25/2016 1:28 AM, TomK wrote:
> > On 10/24/2016 2:36 AM, Nicholas A. Bellinger wrote:
> >> Hi TomK,
> >>
> >> Thanks for reporting this bug.  Comments inline below.
> >>
> >> On Mon, 2016-10-24 at 00:45 -0400, TomK wrote:
> >>> On 10/24/2016 12:32 AM, TomK wrote:
>  On 10/23/2016 10:03 PM, TomK wrote:



>  Including the full log:
> 
>  http://microdevsys.com/linux-lio/messages-mailing-list
> 
> >>>
> >>
> >> Thanks for posting with qla2xxx verbose debug enabled on your setup.
> >>
> >>>
> >>> When tryint to shut down target using /etc/init.d/target stop, the
> >>> following is printed repeatedly:
> >>>
> >>> Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-e837:20:
> >>> ABTS_RECV_24XX: instance 0
> >>> Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-f811:20:
> >>> qla_target(0): task abort (s_id=1:5:0, tag=1177068, param=0)
> >>> Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-f812:20:
> >>> qla_target(0): task abort for non-existant session
> >>> Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-f80e:20:
> >>> Scheduling work (type 1, prm 880093365680) to find session for param
> >>> 88010f8c7680 (size 64, tgt 880111f06600)
> >>> Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-f800:20: Sess
> >>> work (tgt 880111f06600)
> >>> Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-e806:20: Sending
> >>> task mgmt ABTS response (ha=88010fae, atio=880093365694,
> >>> status=4
> >>> Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-e838:20:
> >>> ABTS_RESP_24XX: compl_status 31
> >>> Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-e807:20: Sending
> >>> retry TERM EXCH CTIO7 (ha=88010fae)
> >>> Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-e806:20: Sending
> >>> task mgmt ABTS response (ha=88010fae, atio=88010f8c76c0,
> >>> status=0
> >>> Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-e838:20:
> >>> ABTS_RESP_24XX: compl_status 0
> >>> Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-e872:20:
> >>> qlt_24xx_atio_pkt_all_vps: qla_target(0): type 6 ox_id 029c
> >>> Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-3861:20: New
> >>> command while device 880111f06600 is shutting down
> >>> Oct 24 00:39:48 mbpc-pc kernel: qla2xxx [:04:00.0]-e859:20:
> >>> qla_target: Unable to send command to target for req, ignoring.
> >>>
> >>>
> >>
> >> At your earliest convenience, please verify the patch using v4.8.y with
> >> the above ABORT_TASK + shutdown scenario.
> >>
> >> Also, it would be helpful to understand why this ESX FC host is
> >> generating ABORT_TASKs.
> >>
> >> Eg: Is ABORT_TASK generated due to FC target response packet loss..?
> >> Or due to target backend I/O latency, that ultimately triggers FC host
> >> side timeouts...?
> >>

Ok, so the specific hung task warnings reported earlier above are
ABORT_TASK due to the target-core backend md array holding onto
outstanding I/O long enough, for ESX host side SCSI timeouts to begin to
trigger.

> >>>
> >>> + when I disable the ports on the brocade switch that we're using then
> >>> try to stop target, the following is printed:
> >>>
> >>>
> >>>
> >>> Oct 24 00:41:31 mbpc-pc kernel: qla2xxx [:04:00.1]-680a:21: Loop
> >>> down - seconds remaining 231.
> >>> Oct 24 00:41:32 mbpc-pc kernel: qla2xxx [:04:00.0]-680a:20: Loop
> >>> down - seconds remaining 153.
> >>> Oct 24 00:41:32 mbpc-pc kernel: [ cut here ]
> >>> Oct 24 00:41:32 mbpc-pc kernel: WARNING: CPU: 2 PID: 8615 at
> >>> lib/list_debug.c:33 __list_add+0xbe/0xd0
> >>> Oct 24 00:41:32 mbpc-pc kernel: list_add corruption. prev->next should
> >>> be next (88009e83b330), but was 88011fc972a0.
> >>> (prev=880118ada4c0).
> >>> Oct 24 00:41:32 mbpc-pc kernel: Modules linked in: tcm_qla2xxx tcm_fc
> >>> tcm_loop target_core_file target_core_iblock target_core_pscsi
> >>> target_core_mod configfs ip6table_filter ip6_tables ebtable_nat ebtables
> >>> nf_conntrack_ipv4 nf_defrag_ipv4 xt_state nf_conntrack xt_CHECKSUM
> >>> iptable_mangle bridge nfsd lockd grace nfs_acl auth_rpcgss autofs4 it87
> >>> hwmon_vid bnx2fc cnic uio fcoe libfcoe libfc 8021q garp stp llc ppdev
> >>> parport_pc parport sunrpc cpufreq_ondemand bonding ipv6 crc_ccitt
> >>> ipt_REJECT nf_reject_ipv4 xt_multiport iptable_filter ip_tables fuse
> >>> vfat fat xfs vhost_net macvtap macvlan vhost tun uinput raid456
> >>> async_raid6_recov async_pq async_xor xor async_memcpy async_tx raid6_pq
> >>> libcrc32c joydev sg serio_raw e1000 kvm_amd kvm irqbypass r8169 mii
> >>> pcspkr k10temp snd_hda_codec_realtek snd_hda_codec_generic snd_hda_intel
> >>> snd_hda_codec snd_hda_core snd_hwdep snd_seq snd_seq_device snd_pcm
> >>> snd_timer snd soundcore i2c_piix4 i2c_core wmi acpi_cpufreq shpchp ext4
> >>> mbcache jbd2 qla2xxx scsi_transport_fc floppy firewire_ohci f
> >>> Oct 24 

Re: Crash in TCM-LIO

2016-10-26 Thread Nicholas A. Bellinger
Hello Anil & Co,

On Tue, 2016-10-25 at 05:33 +, Gurumurthy, Anil wrote:
> On Mon, 2016-10-24 at 06:36 +, Anil Gurumurthy wrote:



> > 
> > [71884.588748] BUG: unable to handle kernel NULL pointer dereference 
> > at 00e0
> > 
> > [71884.51] IP: [] kmem_cache_free+0x11a/0x200
> > 
> > [71884.588981] PGD 0
> > 
> > [71884.589017] Oops:  [#1] SMP
> > 
> > [71884.589041] [ cut here ]
> > 
> > [71884.589048] WARNING: CPU: 2 PID: 20783 at lib/list_debug.c:62
> > __list_del_entry+0x86/0xd0
> > 
> > [71884.589049] list_del corruption. next->prev should be 
> > 8806f8daeb68, but was 8806f8db79e8
> > 
> > [71884.589075] Modules linked in: target_core_pscsi tcm_qla2xxx(OE)
> > qla2xxx(OE) iscsi_target_mod target_core_file target_core_iblock 
> > target_core_mod netconsole ebtable_nat ebtables ipt_MASQUERADE
> > nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 nf_nat xt_CHECKSUM 
> > iptable_mangle bridge 8021q mrp garp stp llc ipt_REJECT nf_reject_ipv4
> > nf_conntrack_ipv4 nf_defrag_ipv4 iptable_filter ip_tables ip6t_REJECT
> > nf_reject_ipv6 nf_conntrack_ipv6 nf_defrag_ipv6 xt_state nf_conntrack 
> > ip6table_filter ip6_tables binfmt_misc vhost_net macvtap macvlan vhost 
> > tun uinput sg serio_raw iTCO_wdt iTCO_vendor_support ipmi_ssif ipmi_si 
> > ipmi_msghandler hpilo hpwdt bnx2 intel_powerclamp coretemp kvm_intel 
> > kvm irqbypass crct10dif_pclmul crc32_pclmul crc32c_intel 
> > ghash_clmulni_intel pcspkr acpi_power_meter lpc_ich mfd_core 
> > i7core_edac edac_core shpchp ext4(E) mbcache(E) jbd2(E) sd_mod(E)
> > sr_mod(E) cdrom(E) scsi_transport_fc(E) hpsa(E) scsi_transport_sas(E)
> > aesni_intel(E) ablk_helper(E) cryptd(E) lrw(E) gf128mul(E)
> > glue_helper(E) pata_acpi(E) ata_generic(E) ata_piix(E) libata(E)
> > radeon(E) ttm(E) drm_kms_helper(E) drm(E) fb_sys_fops(E) sysimgblt(E)
> > sysfillrect(E) syscopyarea(E) i2c_algo_bit(E) i2c_core(E) dm_mirror(E)
> > dm_region_hash(E) dm_log(E) dm_mod(E) [last unloaded: qla2xxx]
> > 
> > [71884.589091] CPU: 2 PID: 20783 Comm: kworker/2:0 Tainted: GW
> > IOE   4.7.0-rc1+ #2
> > 
> > [71884.589092] Hardware name: HP ProLiant DL380 G7, BIOS P67
> > 05/05/2011
> > 
> > [71884.589107] Workqueue: target_completion target_complete_ok_work 
> > [target_core_mod]
> > 
> > [71884.589109]   880408d1fae8 81352197
> > 81370ef6
> > 
> > [71884.589110]  880408d1fb48 880408d1fb48 
> > 880408d1fb38
> > 
> > [71884.589111]  8108a12d 07c3 003e0246
> > 0246
> > 
> > [71884.589112] Call Trace:
> > 
> > [71884.589115]  [] dump_stack+0x67/0x90
> > 
> > [71884.589117]  [] ? __list_del_entry+0x86/0xd0
> > 
> > [71884.589119]  [] __warn+0xfd/0x120
> > 
> > [71884.589120]  [] warn_slowpath_fmt+0x49/0x50
> > 
> > [71884.589122]  [] __list_del_entry+0x86/0xd0
> > 
> > [71884.589123]  [] list_del+0x11/0x40
> > 
> > [71884.589132]  [] target_remove_from_state_list
> > +0x6e/0x80 [target_core_mod]
> > 
> > [71884.589140]  [] transport_cmd_check_stop
> > +0xe4/0x120 [target_core_mod]
> > 
> > [71884.589151]  []
> > transport_cmd_check_stop_to_fabric+0x15/0x20 [target_core_mod]
> > 
> > [71884.589160]  [] target_complete_ok_work
> > +0x14e/0x280 [target_core_mod]
> > 
> > [71884.589162]  [] ? pwq_dec_nr_in_flight+0x50/0xa0
> > 
> > [71884.589164]  [] process_one_work+0x183/0x4d0
> > 
> > [71884.589166]  [] ? __schedule+0x1ff/0x5c0
> > 
> > [71884.589167]  [] ? schedule+0x40/0xb0
> > 
> > [71884.589169]  [] worker_thread+0x16d/0x530
> > 
> > [71884.589171]  [] ? __switch_to+0x1cd/0x5e0
> > 
> > [71884.589173]  [] ? __schedule+0x1ff/0x5c0
> > 
> > [71884.589175]  [] ? __wake_up_common+0x56/0x90
> > 
> > [71884.589177]  [] ? maybe_create_worker+0x120/0x120
> > 
> > [71884.589178]  [] ? schedule+0x40/0xb0
> > 
> > [71884.589179]  [] ? maybe_create_worker+0x120/0x120
> > 
> > [71884.589180]  [] kthread+0xcc/0xf0
> > 
> > [71884.589183]  [] ? do_syscall_64+0x78/0x1d0
> > 
> > [71884.589185]  [] ? schedule_tail+0x1e/0xc0
> > 
> > [71884.589188]  [] ret_from_fork+0x1f/0x40
> > 
> > [71884.589189]  [] ? kthread_freezable_should_stop
> > +0x70/0x70
> > 
> > [71884.589190] ---[ end trace 7f24d6c863b6e35b ]---
> > 
> > [71884.589204] [ cut here ]
> > 
> > [71884.589206] WARNING: CPU: 2 PID: 20783 at lib/list_debug.c:59
> > __list_del_entry+0xa5/0xd0
> > 
> >  
> 
> Was list corruption preceded by hung kernel task warnings..?
> 
> No. The only messages prior to them were similar to this:
> [ 3345.864359] ABORT_TASK: Sending TMR_TASK_DOES_NOT_EXIST for ref_tag: 
> 1219168 [ 3345.864378] qla2xxx [:0b:00.1]-e900:4: RESET-TMR 
> online/active/old-count/new-count = 1/0/0/1.
> [ 3345.864418] BUG: unable to handle kernel NULL pointer dereference at 
> 00e0 [ 3345.864549] IP: [] 
> kmem_cache_free+0x11a/0x200
> 

Thanks for confirming.  The ABORT_TASK TMR_TASK_DOES_NOT_EXIST
exceptions here do not depend on the