[PATCH] scsi: libiscsi: Fix an error handling path in 'iscsi_session_setup()'

2017-09-13 Thread Christophe JAILLET
All error handling paths in this function go through
'iscsi_host_dec_session_cnt()' except this one.
Fix it and properly decrement the number of active sessions in such a case.

Signed-off-by: Christophe JAILLET 
---
 drivers/scsi/libiscsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index bd4605a34f54..5d195375ba75 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -2779,7 +2779,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit, 
struct Scsi_Host *shost,
   "must be a power of 2.\n", total_cmds);
total_cmds = rounddown_pow_of_two(total_cmds);
if (total_cmds < ISCSI_TOTAL_CMDS_MIN)
-   return NULL;
+   goto dec_session_count;
printk(KERN_INFO "iscsi: Rounding can_queue to %d.\n",
   total_cmds);
}
-- 
2.11.0



Re: [PATCH 01/10] arch:powerpc: return -ENOMEM on failed allocation

2017-09-13 Thread Allen
> I think the changelog for this series of conversions
> should show that you've validated the change by
> inspecting the return call chain at each modified line.
>
> Also, it seems you've cc'd the same mailing lists for
> all of the patches modified by this series.
>
> It would be better to individually address each patch
> in the series only cc'ing the appropriate maintainers
> and mailing lists.
>
> A cover letter would be good too.

 Point noted. Thanks.

- Allen


Re: [PATCH V4 08/10] block: allow to allocate req with RQF_PREEMPT when queue is preempt frozen

2017-09-13 Thread Ming Lei
On Wed, Sep 13, 2017 at 07:07:53PM +, Bart Van Assche wrote:
> On Thu, 2017-09-14 at 01:48 +0800, Ming Lei wrote:
> > No, that patch only changes blk_insert_cloned_request() which is used
> > by dm-rq(mpath) only, nothing to do with the reported issue during
> > suspend and sending SCSI Domain validation.
> 
> There may be other ways to fix the SCSI domain validation code.

Again the issue isn't in domain validation, it is in quiesce,
so we need to fix quiesce, instead of working around transport_spi.

Also What is the other way? Why not this patchset?

> 
> Regarding the hang during resume: I have not been able to reproduce that
> hang with Jens' latest for-next branch. If that hang would turn out not to
> be reproducible with v4.13-rc1, why to change the behavior of the block
> layer with regard to PREEMPT requests?

Previously you object this patchset because you mention there
is race, now you want to change to another reason?

So I suppose there isn't the race you worried about.

PREEMPT is special enough but used widely, not like NVMe,
traditional SCSI doesn't has a specific queue for
administration purpose only, then RFQ_PREEMPT need to
be dispatched to the same queue even normal I/O is not
allowed at that time.

Because it is a common/generic issue with quiesce, we have to
avoid I/O hang with quiesce. This way is a generic enough for
cover all this kind of issue. And no side effect on normal I/O
of block layer.

Can you make sure that the following two points can't happen
wrt. I/O hang during suspend/resume?

- no normal I/O is triggered during suspend

- all I/O requests in queue will be drained out before
entering suspend

-- 
Ming


Re: [Patch v2 2/2] libiscsi: Remove iscsi_destroy_session

2017-09-13 Thread Lee Duncan
On 07/13/2017 09:11 AM, Khazhismel Kumykov wrote:
> iscsi_session_teardown was the only user of this function. Function
> currently is just short for iscsi_remove_session + iscsi_free_session.
> 
> Signed-off-by: Khazhismel Kumykov 

Why is this needed? I dislike changes that don't fix anything.

> ---
>  drivers/scsi/scsi_transport_iscsi.c | 16 
>  include/scsi/scsi_transport_iscsi.h |  1 -
>  2 files changed, 17 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_transport_iscsi.c 
> b/drivers/scsi/scsi_transport_iscsi.c
> index a424eaeafeb0..924ac408d8a9 100644
> --- a/drivers/scsi/scsi_transport_iscsi.c
> +++ b/drivers/scsi/scsi_transport_iscsi.c
> @@ -2210,22 +2210,6 @@ void iscsi_free_session(struct iscsi_cls_session 
> *session)
>  }
>  EXPORT_SYMBOL_GPL(iscsi_free_session);
>  
> -/**
> - * iscsi_destroy_session - destroy iscsi session
> - * @session: iscsi_session
> - *
> - * Can be called by a LLD or iscsi_transport. There must not be
> - * any running connections.
> - */
> -int iscsi_destroy_session(struct iscsi_cls_session *session)
> -{
> - iscsi_remove_session(session);
> - ISCSI_DBG_TRANS_SESSION(session, "Completing session destruction\n");
> - iscsi_free_session(session);
> - return 0;
> -}
> -EXPORT_SYMBOL_GPL(iscsi_destroy_session);
> -
>  /**
>   * iscsi_create_conn - create iscsi class connection
>   * @session: iscsi cls session
> diff --git a/include/scsi/scsi_transport_iscsi.h 
> b/include/scsi/scsi_transport_iscsi.h
> index 6183d20a01fb..b266d2a3bcb1 100644
> --- a/include/scsi/scsi_transport_iscsi.h
> +++ b/include/scsi/scsi_transport_iscsi.h
> @@ -434,7 +434,6 @@ extern struct iscsi_cls_session 
> *iscsi_create_session(struct Scsi_Host *shost,
>   unsigned int target_id);
>  extern void iscsi_remove_session(struct iscsi_cls_session *session);
>  extern void iscsi_free_session(struct iscsi_cls_session *session);
> -extern int iscsi_destroy_session(struct iscsi_cls_session *session);
>  extern struct iscsi_cls_conn *iscsi_create_conn(struct iscsi_cls_session 
> *sess,
>   int dd_size, uint32_t cid);
>  extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn);
> 

-- 
Lee Duncan
SUSE Labs


Re: [PATCH V2 00/12] scsi-mq support for ZBC disks

2017-09-13 Thread Damien Le Moal
Christoph,

On 9/14/17 05:17, Christoph Hellwig wrote:
> On Tue, Sep 12, 2017 at 05:38:05PM +0900, Damien Le Moal wrote:
>> struct blk_zoned {
>>  unsigned int nr_zones;
>>  unsigned long *seq_zones;
>> };
>>
>> struct request_queue {
>>  ...
>> #ifdef CONFIG_BLK_DEV_ZONED
>>  struct blk_zoned zoned;
>> #endif
>>  ...
> 
> Do we even need a new structure for it?  I'd just hang it off
> the gendisk directly.

Using a structure just seemed cleaner to me. But it is indeed not really
necessary. As for attaching this info to the gendisk, that would indeed
be equivalent. Having the struct on hand in the request queue just makes
it easier to write small helpers in blkdev.h to access the info. Hence
this choice. Should I change it ?

I have a V3 under test using the blk_zoned struct in the request queue
under test. I will post shortly.

> Except for that the idea looks fine to me.

Thanks !

-- 
Damien Le Moal,
Western Digital


Re: [PATCH V2 00/12] scsi-mq support for ZBC disks

2017-09-13 Thread Christoph Hellwig
On Tue, Sep 12, 2017 at 05:38:05PM +0900, Damien Le Moal wrote:
> struct blk_zoned {
>   unsigned int nr_zones;
>   unsigned long *seq_zones;
> };
> 
> struct request_queue {
>   ...
> #ifdef CONFIG_BLK_DEV_ZONED
>   struct blk_zoned zoned;
> #endif
>   ...

Do we even need a new structure for it?  I'd just hang it off
the gendisk directly.

Except for that the idea looks fine to me.


Re: [PATCH V4 08/10] block: allow to allocate req with RQF_PREEMPT when queue is preempt frozen

2017-09-13 Thread Bart Van Assche
On Thu, 2017-09-14 at 01:48 +0800, Ming Lei wrote:
> No, that patch only changes blk_insert_cloned_request() which is used
> by dm-rq(mpath) only, nothing to do with the reported issue during
> suspend and sending SCSI Domain validation.

There may be other ways to fix the SCSI domain validation code.

Regarding the hang during resume: I have not been able to reproduce that
hang with Jens' latest for-next branch. If that hang would turn out not to
be reproducible with v4.13-rc1, why to change the behavior of the block
layer with regard to PREEMPT requests?

Bart.

Re: [PATCH V4 08/10] block: allow to allocate req with RQF_PREEMPT when queue is preempt frozen

2017-09-13 Thread Ming Lei
On Wed, Sep 13, 2017 at 05:28:24PM +, Bart Van Assche wrote:
> On Thu, 2017-09-14 at 00:48 +0800, Ming Lei wrote:
> > Could you please let me know if your concern about race between
> > preempt freeze and blk_cleanup_queue() is addressed in my last
> > reply?
> 
> Shouldn't we wait until v4.13-rc1 has been released before spending more
> energy on this? Certain patches that have been sent to Linus, e.g. commit

The discussion should have been done any time, right?

I believe I replied all your comments, if you don't agree any one of
my follow-up, please point it out.

> 157f377beb71 ("block: directly insert blk-mq request from
> blk_insert_cloned_request()"), may affect the test results. I have not

No, that patch only changes blk_insert_cloned_request() which is used
by dm-rq(mpath) only, nothing to do with the reported issue during
suspend and sending SCSI Domain validation.


-- 
Ming


Re: [PATCH] scsi: Remove unnecessary condition in sd_read_block_limits()

2017-09-13 Thread Bart Van Assche
On Wed, 2017-09-13 at 16:29 +0200, Lukas Czerner wrote:
> After series of changes around WRITE_SAME and UNMAP setup we ended up
> with leftover unnecessary condition. Remove it.

A similar patch was sitting in my tree and waiting to be posted. But since you
posted this first:

Reviewed-by: Bart Van Assche 



Re: [PATCH V4 08/10] block: allow to allocate req with RQF_PREEMPT when queue is preempt frozen

2017-09-13 Thread Bart Van Assche
On Thu, 2017-09-14 at 00:48 +0800, Ming Lei wrote:
> Could you please let me know if your concern about race between
> preempt freeze and blk_cleanup_queue() is addressed in my last
> reply?

Shouldn't we wait until v4.13-rc1 has been released before spending more
energy on this? Certain patches that have been sent to Linus, e.g. commit
157f377beb71 ("block: directly insert blk-mq request from
blk_insert_cloned_request()"), may affect the test results. I have not
been able to reproduce the hang during resume with Jens' latest for-next
branch.

Bart.

Re: [PATCH V4 08/10] block: allow to allocate req with RQF_PREEMPT when queue is preempt frozen

2017-09-13 Thread Ming Lei
On Tue, Sep 12, 2017 at 11:40:57AM +0800, Ming Lei wrote:
> On Mon, Sep 11, 2017 at 04:03:55PM +, Bart Van Assche wrote:
> > On Mon, 2017-09-11 at 19:10 +0800, Ming Lei wrote:
> > > @@ -787,6 +787,35 @@ int blk_queue_enter(struct request_queue *q, 
> > > unsigned flags)
> > >   if (percpu_ref_tryget_live(>q_usage_counter))
> > >   return 0;
> > >  
> > > + /*
> > > +  * If queue is preempt frozen and caller need to allocate
> > > +  * request for RQF_PREEMPT, we grab the .q_usage_counter
> > > +  * unconditionally and return successfully.
> > > +  *
> > > +  * There isn't race with queue cleanup because:
> > > +  *
> > > +  * 1) it is guaranteed that preempt freeze can't be
> > > +  * started after queue is set as dying
> > > +  *
> > > +  * 2) normal freeze runs exclusively with preempt
> > > +  * freeze, so even after queue is set as dying
> > > +  * afterwards, blk_queue_cleanup() won't move on
> > > +  * until preempt freeze is done
> > > +  *
> > > +  * 3) blk_queue_dying() needn't to be checked here
> > > +  *  - for legacy path, it will be checked in
> > > +  *  __get_request()
> > 
> > For the legacy block layer core, what do you think will happen if the
> > "dying" state is set by another thread after __get_request() has passed the
> > blk_queue_dying() check?
> 
> Without this patchset, block core still need to handle the above
> situation, so your question isn't related with this patchset.
> 
> Also q->queue_lock is required in both setting dying and checking
> dying in__get_request(). But the lock can be released in
> __get_request(), so it is possible to allocate one request after
> queue is set as dying, and the request can be dispatched to a
> dying queue too for legacy.
> 
> > 
> > > +  *  - blk-mq depends on driver to handle dying well
> > > +  *  because it is normal for queue to be set as dying
> > > +  *  just between blk_queue_enter() and allocating new
> > > +  *  request.
> > 
> > The above comment is not correct. The block layer core handles the "dying"
> > state. Block drivers other than dm-mpath should not have to query this state
> > directly.
> 
> If blk-mq doesn't query dying state, how does it know queue is dying
> and handle the state? Also blk-mq isn't different with legacy wrt.
> depending on driver to handle dying.
> 
> > 
> > > +  */
> > > + if ((flags & BLK_REQ_PREEMPT) &&
> > > + blk_queue_is_preempt_frozen(q)) {
> > > + blk_queue_enter_live(q);
> > > + return 0;
> > > + }
> > > +
> > 
> > Sorry but to me it looks like the above code introduces a race condition
> > between blk_queue_cleanup() and blk_get_request() for at least blk-mq.
> > Consider e.g. the following scenario:
> > * A first thread preempt-freezes a request queue.
> > * A second thread calls blk_get_request() with BLK_REQ_PREEMPT set. That
> >   results in a call of blk_queue_is_preempt_frozen().
> > * A context switch occurs to the first thread.
> > * The first thread preempt-unfreezes the same request queue and calls
> >   blk_queue_cleanup(). That last function changes the request queue state
> >   into DYING and waits until all pending requests have finished.
> > * The second thread continues and calls blk_queue_enter_live(), allocates
> >   a request and submits it.
> 
> OK, looks a race I don't think of, but it can be fixed easily by calling
> blk_queue_enter_live() with holding q->freeze_lock, and it won't
> cause performance issue too since it is in slow path.
> 
> For example, we can introduce the following code in blk_queue_enter():
> 
>   if ((flags & BLK_REQ_PREEMPT) &&
>   blk_queue_enter_preempt_freeze(q))
>   return 0;
> 
> static inline bool blk_queue_enter_preempt_freeze(struct request_queue *q)
> {
>   bool preempt_frozen;
> 
>   spin_lock(>freeze_lock);
>   preempt_frozen = q->preempt_freezing && !q->preempt_unfreezing;
>   if (preempt_froze)
>   blk_queue_enter_live(q);
>   spin_unlock(>freeze_lock);
> 
>   return preempt_frozen;
> }
> 
> > 
> > In other words, a request gets submitted against a dying queue. This must
> > not happen. See also my explanation of queue shutdown from a few days ago
> 
> That is not correct, think about why queue dead is checked in
> __blk_run_queue_uncond() instead of queue dying. We still need to
> submit requests to driver when queue is dying, and driver knows
> how to handle that.
> 
> > (https://marc.info/?l=linux-block=150449845831789).
> 
> > from (https://marc.info/?l=linux-block=150449845831789).
> >> Do you understand how request queue cleanup works? The algorithm used for
> >> request queue cleanup is as follows:
> >> * Set the DYING flag. This flag 

Re: [PATCH 06/10] drivers:ethernet: return -ENOMEM on allocation failure.

2017-09-13 Thread David Miller
From: Allen Pais 
Date: Wed, 13 Sep 2017 13:02:15 +0530

> Signed-off-by: Allen Pais 

This is quite pointless as the caller doesn't do anything with
the value, it just tests whether a negative value is returned
or not.


Re: [PATCH] scsi: fix the issue that iscsi_if_rx doesn't parse nlmsg properly

2017-09-13 Thread Chris Leech

Acked-by: Chris Leech 

On Sun, Aug 27, 2017 at 08:25:26PM +0800, Xin Long wrote:
> ChunYu found a kernel crash by syzkaller:
> 
> [  651.617875] kasan: CONFIG_KASAN_INLINE enabled
> [  651.618217] kasan: GPF could be caused by NULL-ptr deref or user memory 
> access
> [  651.618731] general protection fault:  [#1] SMP KASAN
> [  651.621543] CPU: 1 PID: 9539 Comm: scsi Not tainted 4.11.0.cov #32
> [  651.621938] Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
> [  651.622309] task: 88011778 task.stack: 8800a3188000
> [  651.622762] RIP: 0010:skb_release_data+0x26c/0x590
> [...]
> [  651.627260] Call Trace:
> [  651.629156]  skb_release_all+0x4f/0x60
> [  651.629450]  consume_skb+0x1a5/0x600
> [  651.630705]  netlink_unicast+0x505/0x720
> [  651.632345]  netlink_sendmsg+0xab2/0xe70
> [  651.633704]  sock_sendmsg+0xcf/0x110
> [  651.633942]  ___sys_sendmsg+0x833/0x980
> [  651.637117]  __sys_sendmsg+0xf3/0x240
> [  651.638820]  SyS_sendmsg+0x32/0x50
> [  651.639048]  entry_SYSCALL_64_fastpath+0x1f/0xc2
> 
> It's caused by skb_shared_info at the end of sk_buff was overwritten by
> ISCSI_KEVENT_IF_ERROR when parsing nlmsg info from skb in iscsi_if_rx.
> 
> During the loop if skb->len == nlh->nlmsg_len and both are sizeof(*nlh),
> ev = nlmsg_data(nlh) will acutally get skb_shinfo(SKB) instead and set a
> new value to skb_shinfo(SKB)->nr_frags by ev->type.
> 
> This patch is to fix it by checking nlh->nlmsg_len properly there to
> avoid over accessing sk_buff.
> 
> Reported-by: ChunYu Wang 
> Signed-off-by: Xin Long 
> ---
>  drivers/scsi/scsi_transport_iscsi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/scsi_transport_iscsi.c 
> b/drivers/scsi/scsi_transport_iscsi.c
> index e4b3d8f..bb4ed7b 100644
> --- a/drivers/scsi/scsi_transport_iscsi.c
> +++ b/drivers/scsi/scsi_transport_iscsi.c
> @@ -3697,7 +3697,7 @@ iscsi_if_rx(struct sk_buff *skb)
>   uint32_t group;
>  
>   nlh = nlmsg_hdr(skb);
> - if (nlh->nlmsg_len < sizeof(*nlh) ||
> + if (nlh->nlmsg_len < sizeof(*nlh) + sizeof(*ev) ||
>   skb->len < nlh->nlmsg_len) {
>   break;
>   }
> -- 
> 2.1.0
> 


Re: [PATCH 10/10] fs:btrfs: return -ENOMEM on allocation failure.

2017-09-13 Thread David Sterba
On Wed, Sep 13, 2017 at 01:02:19PM +0530, Allen Pais wrote:
> Signed-off-by: Allen Pais 
> ---
>  fs/btrfs/check-integrity.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
> index 7d5a9b5..efa4c23 100644
> --- a/fs/btrfs/check-integrity.c
> +++ b/fs/btrfs/check-integrity.c
> @@ -2913,7 +2913,7 @@ int btrfsic_mount(struct btrfs_fs_info *fs_info,
>   state = kvzalloc(sizeof(*state), GFP_KERNEL);
>   if (!state) {
>   pr_info("btrfs check-integrity: allocation failed!\n");
> - return -1;
> + return -ENOMEM;

Makes sense, also please fix the -1 a few lines below that also result
from failed memory allocation, indirectly from btrfsic_dev_state_alloc().

>   }
>  
>   if (!btrfsic_is_initialized) {
> -- 
> 2.7.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/10] arch:powerpc: return -ENOMEM on failed allocation

2017-09-13 Thread Joe Perches
On Wed, 2017-09-13 at 13:02 +0530, Allen Pais wrote:
> Signed-off-by: Allen Pais 

I think the changelog for this series of conversions
should show that you've validated the change by
inspecting the return call chain at each modified line.

Also, it seems you've cc'd the same mailing lists for
all of the patches modified by this series.

It would be better to individually address each patch
in the series only cc'ing the appropriate maintainers
and mailing lists.

A cover letter would be good too.

> ---
>  arch/powerpc/platforms/cell/spider-pci.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/cell/spider-pci.c 
> b/arch/powerpc/platforms/cell/spider-pci.c
> index d1e61e2..82aa3f7 100644
> --- a/arch/powerpc/platforms/cell/spider-pci.c
> +++ b/arch/powerpc/platforms/cell/spider-pci.c
> @@ -106,7 +106,7 @@ static int __init spiderpci_pci_setup_chip(struct 
> pci_controller *phb,
>   dummy_page_va = kmalloc(PAGE_SIZE, GFP_KERNEL);
>   if (!dummy_page_va) {
>   pr_err("SPIDERPCI-IOWA:Alloc dummy_page_va failed.\n");
> - return -1;
> + return -ENOMEM;
>   }
>  
>   dummy_page_da = dma_map_single(phb->parent, dummy_page_va,
> @@ -137,7 +137,7 @@ int __init spiderpci_iowa_init(struct iowa_bus *bus, void 
> *data)
>   if (!priv) {
>   pr_err("SPIDERPCI-IOWA:"
>  "Can't allocate struct spiderpci_iowa_private");
> - return -1;
> + return -ENOMEM;
>   }
>  
>   if (of_address_to_resource(np, 0, )) {


[PATCH] scsi: Remove unnecessary condition in sd_read_block_limits()

2017-09-13 Thread Lukas Czerner
After series of changes around WRITE_SAME and UNMAP setup we ended up
with leftover unnecessary condition. Remove it.

Signed-off-by: Lukas Czerner 
---
 drivers/scsi/sd.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 11c1738..fb9f8b5 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2915,8 +2915,6 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)
sd_config_discard(sdkp, SD_LBP_WS16);
else if (sdkp->lbpws10)
sd_config_discard(sdkp, SD_LBP_WS10);
-   else if (sdkp->lbpu && sdkp->max_unmap_blocks)
-   sd_config_discard(sdkp, SD_LBP_UNMAP);
else
sd_config_discard(sdkp, SD_LBP_DISABLE);
}
-- 
2.7.5



[GIT PULL] final round of SCSI updates for the 4.13+ merge window

2017-09-13 Thread James Bottomley
A tiny update: one patch corrects a Kconfig problem with the shift of
the SAS SMP code to BSG and the other removes a vestige of user space
target mode.

The patch is available here:

git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git scsi-misc

The short changelog is:

Arnd Bergmann (1):
  scsi: scsi_transport_sas: select BLK_DEV_BSGLIB

Bart Van Assche (1):
  scsi: Remove Scsi_Host.uspace_req_q

And the diffstat:

 drivers/scsi/Kconfig | 2 +-
 drivers/scsi/hosts.c | 8 
 include/scsi/scsi_host.h | 6 --
 3 files changed, 1 insertion(+), 15 deletions(-)

With full diff below.

James

---

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index f4538d7a3016..c470a05c7f47 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -272,7 +272,7 @@ config SCSI_ISCSI_ATTRS
 config SCSI_SAS_ATTRS
tristate "SAS Transport Attributes"
depends on SCSI
-   select BLK_DEV_BSG
+   select BLK_DEV_BSGLIB
help
  If you wish to export transport-specific information about
  each attached SAS device to sysfs, say Y.
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 831a1c8b9f89..fe3a0da3ec97 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -315,8 +315,6 @@ static void scsi_host_dev_release(struct device *dev)
 {
struct Scsi_Host *shost = dev_to_shost(dev);
struct device *parent = dev->parent;
-   struct request_queue *q;
-   void *queuedata;
 
scsi_proc_hostdir_rm(shost->hostt);
 
@@ -326,12 +324,6 @@ static void scsi_host_dev_release(struct device *dev)
kthread_stop(shost->ehandler);
if (shost->work_q)
destroy_workqueue(shost->work_q);
-   q = shost->uspace_req_q;
-   if (q) {
-   queuedata = q->queuedata;
-   blk_cleanup_queue(q);
-   kfree(queuedata);
-   }
 
if (shost->shost_state == SHOST_CREATED) {
/*
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index afb04811b7b9..0a804b1a4726 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -691,12 +691,6 @@ struct Scsi_Host {
unsigned int prot_capabilities;
unsigned char prot_guard_type;
 
-   /*
-* q used for scsi_tgt msgs, async events or any other requests that
-* need to be processed in userspace
-*/
-   struct request_queue *uspace_req_q;
-
/* legacy crap */
unsigned long base;
unsigned long io_port;



RE: system hung up when offlining CPUs

2017-09-13 Thread Thomas Gleixner
On Wed, 13 Sep 2017, Kashyap Desai wrote:
> > On 09/12/2017 08:15 PM, YASUAKI ISHIMATSU wrote:
> > > + linux-scsi and maintainers of megasas

> > >> In my server, IRQ#66-89 are sent to CPU#24-29. And if I offline
> > >> CPU#24-29, I/O does not work, showing the following messages.



> > This indeed looks like a problem.
> > We're going to great lengths to submit and complete I/O on the same CPU,
> > so
> > if the CPU is offlined while I/O is in flight we won't be getting a
> > completion for
> > this particular I/O.
> > However, the megasas driver should be able to cope with this situation;
> > after
> > all, the firmware maintains completions queues, so it would be dead easy
> > to
> > look at _other_ completions queues, too, if a timeout occurs.
> In case of IO timeout, megaraid_sas driver is checking other queues as well.
> That is why IO was completed in this case and further IOs were resumed.
> 
> Driver complete commands as below code executed from
> megasas_wait_for_outstanding_fusion().
> for (MSIxIndex = 0 ; MSIxIndex < count; MSIxIndex++)
> complete_cmd_fusion(instance, MSIxIndex);
> 
> Because of above code executed in driver, we see only one print as below in
> this logs.
> megaraid_sas :02:00.0: [ 0]waiting for 2 commands to complete for scsi0
> 
> As per below link CPU hotplug will take care- "All interrupts targeted to
> this CPU are migrated to a new CPU"
> https://www.kernel.org/doc/html/v4.11/core-api/cpu_hotplug.html
> 
> BTW - We are also able reproduce this issue locally.  Reason for IO timeout
> is -" IO is completed, but corresponding interrupt did not arrived on Online
> CPU. Either missed due to CPU is in transient state of being OFFLINED. I am
> not sure which component should take care this."
> 
> Question - "what happens once __cpu_disable is called and some of the queued
> interrupt has affinity to that particular CPU ?"
> I assume ideally those pending/queued Interrupt should be migrated to
> remaining online CPUs. It should not be unhandled if we want to avoid such
> IO timeout.

Can you please provide the following information, before and after
offlining the last CPU in the affinity set:

# cat /proc/irq/$IRQNUM/smp_affinity_list
# cat /proc/irq/$IRQNUM/effective_affinity
# cat /sys/kernel/debug/irq/irqs/$IRQNUM

The last one requires: CONFIG_GENERIC_IRQ_DEBUGFS=y

Thanks,

tglx


Re: [PATCH V2 5/9] pm80xx : cleanup in pm8001_abort_task function.

2017-09-13 Thread Jinpu Wang
On Wed, Feb 18, 2015 at 12:36 AM, Viswas G  wrote:
> Signed-off-by: Deepak Ukey 
> Signed-off-by: Viswas G 
> ---
>  drivers/scsi/pm8001/pm8001_sas.c | 49 
> +++-
>  1 file changed, 13 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/scsi/pm8001/pm8001_sas.c 
> b/drivers/scsi/pm8001/pm8001_sas.c
> index ce584c31d36e..e80b0542a67f 100644
> --- a/drivers/scsi/pm8001/pm8001_sas.c
> +++ b/drivers/scsi/pm8001/pm8001_sas.c
> @@ -1159,40 +1159,35 @@ int pm8001_query_task(struct sas_task *task)
>  int pm8001_abort_task(struct sas_task *task)
>  {
> unsigned long flags;
> -   u32 tag = 0xdeadbeef;
> +   u32 tag;
> u32 device_id;
> struct domain_device *dev ;
> -   struct pm8001_hba_info *pm8001_ha = NULL;
> +   struct pm8001_hba_info *pm8001_ha;
> struct pm8001_ccb_info *ccb;
> struct scsi_lun lun;
> struct pm8001_device *pm8001_dev;
> struct pm8001_tmf_task tmf_task;
> int rc = TMF_RESP_FUNC_FAILED;
> if (unlikely(!task || !task->lldd_task || !task->dev))
> -   return rc;
> +   return TMF_RESP_FUNC_FAILED;
> +   dev = task->dev;
> +   pm8001_dev = dev->lldd_dev;
> +   pm8001_ha = pm8001_find_ha_by_dev(dev);
> +   device_id = pm8001_dev->device_id;
> +   rc = pm8001_find_tag(task, );
> +   if (rc == 0) {
> +   pm8001_printk("no tag for task:%p\n", task);
> +   return TMF_RESP_FUNC_FAILED;
> +   }
> spin_lock_irqsave(>task_state_lock, flags);
> if (task->task_state_flags & SAS_TASK_STATE_DONE) {
> spin_unlock_irqrestore(>task_state_lock, flags);
> -   rc = TMF_RESP_FUNC_COMPLETE;
> -   goto out;
> +   return TMF_RESP_FUNC_COMPLETE;
> }
> spin_unlock_irqrestore(>task_state_lock, flags);
> if (task->task_proto & SAS_PROTOCOL_SSP) {
> struct scsi_cmnd *cmnd = task->uldd_task;
> -   dev = task->dev;
> -   ccb = task->lldd_task;
> -   pm8001_dev = dev->lldd_dev;
> -   pm8001_ha = pm8001_find_ha_by_dev(dev);
> int_to_scsilun(cmnd->device->lun, );
> -   rc = pm8001_find_tag(task, );
> -   if (rc == 0) {
> -   printk(KERN_INFO "No such tag in %s\n", __func__);
> -   rc = TMF_RESP_FUNC_FAILED;
> -   return rc;
> -   }
> -   device_id = pm8001_dev->device_id;
> -   PM8001_EH_DBG(pm8001_ha,
> -   pm8001_printk("abort io to deviceid= %d\n", 
> device_id));
> tmf_task.tmf = TMF_ABORT_TASK;
> tmf_task.tag_of_task_to_be_managed = tag;
> rc = pm8001_issue_ssp_tmf(dev, lun.scsi_lun, _task);
> @@ -1200,28 +1195,10 @@ int pm8001_abort_task(struct sas_task *task)
> pm8001_dev->sas_device, 0, tag);
> } else if (task->task_proto & SAS_PROTOCOL_SATA ||
> task->task_proto & SAS_PROTOCOL_STP) {
> -   dev = task->dev;
> -   pm8001_dev = dev->lldd_dev;
> -   pm8001_ha = pm8001_find_ha_by_dev(dev);
> -   rc = pm8001_find_tag(task, );
> -   if (rc == 0) {
> -   printk(KERN_INFO "No such tag in %s\n", __func__);
> -   rc = TMF_RESP_FUNC_FAILED;
> -   return rc;
> -   }
> rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev,
> pm8001_dev->sas_device, 0, tag);
> } else if (task->task_proto & SAS_PROTOCOL_SMP) {
> /* SMP */
> -   dev = task->dev;
> -   pm8001_dev = dev->lldd_dev;
> -   pm8001_ha = pm8001_find_ha_by_dev(dev);
> -   rc = pm8001_find_tag(task, );
> -   if (rc == 0) {
> -   printk(KERN_INFO "No such tag in %s\n", __func__);
> -   rc = TMF_RESP_FUNC_FAILED;
> -   return rc;
> -   }
> rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev,
> pm8001_dev->sas_device, 0, tag);
>
> --
> 2.12.3
>

Thanks,
Acked-by: Jack Wang 

-- 
Jack Wang
Linux Kernel Developer

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin

Tel:   +49 30 577 008  042
Fax:  +49 30 577 008 299
Email:jinpu.w...@profitbricks.com
URL:  https://www.profitbricks.de

Sitz der Gesellschaft: Berlin
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B
Geschäftsführer: Achim Weiss


Re: [PATCH 05/10] drivers:net: return -ENOMEM on allocation failure.

2017-09-13 Thread Allen
> propagates the -1. That is only called by bond_open() with:
>
> if (bond_alb_initialize(bond, (BOND_MODE(bond) == BOND_MODE_ALB)))
> return -ENOMEM;
>
> So you might want to also modify this code, to return the return
> value, rather than use the hard coded ENOMEM.
>

 I'll modify the above and send it out a separate patch.

Thank you.


Re: [PATCH 06/10] drivers:ethernet: return -ENOMEM on allocation failure.

2017-09-13 Thread Allen
>
> static int cas_alloc_rxds(struct cas *cp)
> {
> int i;
>
> for (i = 0; i < N_RX_DESC_RINGS; i++) {
> if (cas_alloc_rx_desc(cp, i) < 0) {
> cas_free_rxds(cp);
> return -1;
> }
> }
> return 0;
> }
>
> Again, your change is correct, but in the end the value is not used.
> And if you fix it at the cas_alloc_rxds level, you also need a fix at
> the next level up:
>
> err = -ENOMEM;
> if (cas_tx_tiny_alloc(cp) < 0)
> goto err_unlock;
>
> /* alloc rx descriptors */
> if (cas_alloc_rxds(cp) < 0)
> goto err_tx_tiny;
>
> again, the return value is discarded.

 I agree. I could send out v2 with fixes at both level.

- Allen


Re: [PATCH 06/10] drivers:ethernet: return -ENOMEM on allocation failure.

2017-09-13 Thread Andrew Lunn
On Wed, Sep 13, 2017 at 01:02:15PM +0530, Allen Pais wrote:
> Signed-off-by: Allen Pais 
> ---
>  drivers/net/ethernet/sun/cassini.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/sun/cassini.c 
> b/drivers/net/ethernet/sun/cassini.c
> index 382993c..fc0ea3a 100644
> --- a/drivers/net/ethernet/sun/cassini.c
> +++ b/drivers/net/ethernet/sun/cassini.c
> @@ -3984,7 +3984,7 @@ static inline int cas_alloc_rx_desc(struct cas *cp, int 
> ring)
>   size = RX_DESC_RINGN_SIZE(ring);
>   for (i = 0; i < size; i++) {
>   if ((page[i] = cas_page_alloc(cp, GFP_KERNEL)) == NULL)
> - return -1;
> + return -ENOMEM;
>   }
>   return 0;
>  }

static int cas_alloc_rxds(struct cas *cp)
{
int i;

for (i = 0; i < N_RX_DESC_RINGS; i++) {
if (cas_alloc_rx_desc(cp, i) < 0) {
cas_free_rxds(cp);
return -1;
}
}
return 0;
}

Again, your change is correct, but in the end the value is not used.
And if you fix it at the cas_alloc_rxds level, you also need a fix at
the next level up:

err = -ENOMEM;
if (cas_tx_tiny_alloc(cp) < 0)
goto err_unlock;

/* alloc rx descriptors */
if (cas_alloc_rxds(cp) < 0)
goto err_tx_tiny;

again, the return value is discarded.

   Andrew


Re: [PATCH 05/10] drivers:net: return -ENOMEM on allocation failure.

2017-09-13 Thread Andrew Lunn
On Wed, Sep 13, 2017 at 01:02:14PM +0530, Allen Pais wrote:
> Signed-off-by: Allen Pais 

Hi Allen

Although correct, if you look higher up the call chain, this appears
to be not so useful.

rlb_initialize() is only called by bond_alb_initialize(), and it
propagates the -1. That is only called by bond_open() with:

if (bond_alb_initialize(bond, (BOND_MODE(bond) == BOND_MODE_ALB)))
return -ENOMEM;

So you might want to also modify this code, to return the return
value, rather than use the hard coded ENOMEM.

Since you code is OK as far as it goes:

Reviewed-by: Andrew Lunn 

Andrew


RE: system hung up when offlining CPUs

2017-09-13 Thread Kashyap Desai
>
> On 09/12/2017 08:15 PM, YASUAKI ISHIMATSU wrote:
> > + linux-scsi and maintainers of megasas
> >
> > When offlining CPU, I/O stops. Do you have any ideas?
> >
> > On 09/07/2017 04:23 PM, YASUAKI ISHIMATSU wrote:
> >> Hi Mark and Christoph,
> >>
> >> Sorry for the late reply. I appreciated that you fixed the issue on kvm
> environment.
> >> But the issue still occurs on physical server.
> >>
> >> Here ares irq information that I summarized megasas irqs from
> >> /proc/interrupts and /proc/irq/*/smp_affinity_list on my server:
> >>
> >> ---
> >> IRQ affinity_list IRQ_TYPE
> >>  420-5IR-PCI-MSI 1048576-edge megasas
> >>  430-5IR-PCI-MSI 1048577-edge megasas
> >>  440-5IR-PCI-MSI 1048578-edge megasas
> >>  450-5IR-PCI-MSI 1048579-edge megasas
> >>  460-5IR-PCI-MSI 1048580-edge megasas
> >>  470-5IR-PCI-MSI 1048581-edge megasas
> >>  480-5IR-PCI-MSI 1048582-edge megasas
> >>  490-5IR-PCI-MSI 1048583-edge megasas
> >>  500-5IR-PCI-MSI 1048584-edge megasas
> >>  510-5IR-PCI-MSI 1048585-edge megasas
> >>  520-5IR-PCI-MSI 1048586-edge megasas
> >>  530-5IR-PCI-MSI 1048587-edge megasas
> >>  540-5IR-PCI-MSI 1048588-edge megasas
> >>  550-5IR-PCI-MSI 1048589-edge megasas
> >>  560-5IR-PCI-MSI 1048590-edge megasas
> >>  570-5IR-PCI-MSI 1048591-edge megasas
> >>  580-5IR-PCI-MSI 1048592-edge megasas
> >>  590-5IR-PCI-MSI 1048593-edge megasas
> >>  600-5IR-PCI-MSI 1048594-edge megasas
> >>  610-5IR-PCI-MSI 1048595-edge megasas
> >>  620-5IR-PCI-MSI 1048596-edge megasas
> >>  630-5IR-PCI-MSI 1048597-edge megasas
> >>  640-5IR-PCI-MSI 1048598-edge megasas
> >>  650-5IR-PCI-MSI 1048599-edge megasas
> >>  66  24-29IR-PCI-MSI 1048600-edge megasas
> >>  67  24-29IR-PCI-MSI 1048601-edge megasas
> >>  68  24-29IR-PCI-MSI 1048602-edge megasas
> >>  69  24-29IR-PCI-MSI 1048603-edge megasas
> >>  70  24-29IR-PCI-MSI 1048604-edge megasas
> >>  71  24-29IR-PCI-MSI 1048605-edge megasas
> >>  72  24-29IR-PCI-MSI 1048606-edge megasas
> >>  73  24-29IR-PCI-MSI 1048607-edge megasas
> >>  74  24-29IR-PCI-MSI 1048608-edge megasas
> >>  75  24-29IR-PCI-MSI 1048609-edge megasas
> >>  76  24-29IR-PCI-MSI 1048610-edge megasas
> >>  77  24-29IR-PCI-MSI 1048611-edge megasas
> >>  78  24-29IR-PCI-MSI 1048612-edge megasas
> >>  79  24-29IR-PCI-MSI 1048613-edge megasas
> >>  80  24-29IR-PCI-MSI 1048614-edge megasas
> >>  81  24-29IR-PCI-MSI 1048615-edge megasas
> >>  82  24-29IR-PCI-MSI 1048616-edge megasas
> >>  83  24-29IR-PCI-MSI 1048617-edge megasas
> >>  84  24-29IR-PCI-MSI 1048618-edge megasas
> >>  85  24-29IR-PCI-MSI 1048619-edge megasas
> >>  86  24-29IR-PCI-MSI 1048620-edge megasas
> >>  87  24-29IR-PCI-MSI 1048621-edge megasas
> >>  88  24-29IR-PCI-MSI 1048622-edge megasas
> >>  89  24-29IR-PCI-MSI 1048623-edge megasas
> >> ---
> >>
> >> In my server, IRQ#66-89 are sent to CPU#24-29. And if I offline
> >> CPU#24-29, I/O does not work, showing the following messages.
> >>
> >> ---
> >> [...] sd 0:2:0:0: [sda] tag#1 task abort called for
> >> scmd(8820574d7560) [...] sd 0:2:0:0: [sda] tag#1 CDB: Read(10) 28
> >> 00 0d e8 cf 78 00 00 08 00 [...] sd 0:2:0:0: task abort: FAILED
> >> scmd(8820574d7560) [...] sd 0:2:0:0: [sda] tag#0 task abort
> >> called for scmd(882057426560) [...] sd 0:2:0:0: [sda] tag#0 CDB:
> >> Write(10) 2a 00 0d 58 37 00 00 00 08 00 [...] sd 0:2:0:0: task abort:
> >> FAILED scmd(882057426560) [...] sd 0:2:0:0: target reset called
> >> for scmd(8820574d7560) [...] sd 0:2:0:0: [sda] tag#1 megasas:
> >> target
> reset FAILED!!
> >> [...] sd 0:2:0:0: [sda] tag#0 Controller reset is requested due to IO
> >> timeout
> >> [...] SCSI command pointer: (882057426560)   SCSI host state: 5
> >> SCSI
> >> [...] IO request frame:
> >> [...]
> >> 
> >> [...]
> >> [...] megaraid_sas :02:00.0: [ 0]waiting for 2 commands to
> >> complete for scsi0 [...] INFO: task auditd:1200 blocked for more than
> >> 120
> seconds.
> >> [...]   Not tainted 4.13.0+ #15
> >> [...] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this
> message.
> >> [...] auditd  D0  1200  1 0x
> >> [...] Call Trace:
> >> [...]  __schedule+0x28d/0x890
> >> [...]  schedule+0x36/0x80
> >> [...]  io_schedule+0x16/0x40
> >> [...]  wait_on_page_bit_common+0x109/0x1c0
> >> [...]  ? page_cache_tree_insert+0xf0/0xf0 [...]
> >> __filemap_fdatawait_range+0x127/0x190
> >> [...]  ? __filemap_fdatawrite_range+0xd1/0x100
> >> [...]  file_write_and_wait_range+0x60/0xb0
> >> [...]  xfs_file_fsync+0x67/0x1d0 [xfs] [...]
> >> 

Re: system hung up when offlining CPUs

2017-09-13 Thread Hannes Reinecke
On 09/12/2017 08:15 PM, YASUAKI ISHIMATSU wrote:
> + linux-scsi and maintainers of megasas
> 
> When offlining CPU, I/O stops. Do you have any ideas?
> 
> On 09/07/2017 04:23 PM, YASUAKI ISHIMATSU wrote:
>> Hi Mark and Christoph,
>>
>> Sorry for the late reply. I appreciated that you fixed the issue on kvm 
>> environment.
>> But the issue still occurs on physical server.
>>
>> Here ares irq information that I summarized megasas irqs from 
>> /proc/interrupts
>> and /proc/irq/*/smp_affinity_list on my server:
>>
>> ---
>> IRQ affinity_list IRQ_TYPE
>>  420-5IR-PCI-MSI 1048576-edge megasas
>>  430-5IR-PCI-MSI 1048577-edge megasas
>>  440-5IR-PCI-MSI 1048578-edge megasas
>>  450-5IR-PCI-MSI 1048579-edge megasas
>>  460-5IR-PCI-MSI 1048580-edge megasas
>>  470-5IR-PCI-MSI 1048581-edge megasas
>>  480-5IR-PCI-MSI 1048582-edge megasas
>>  490-5IR-PCI-MSI 1048583-edge megasas
>>  500-5IR-PCI-MSI 1048584-edge megasas
>>  510-5IR-PCI-MSI 1048585-edge megasas
>>  520-5IR-PCI-MSI 1048586-edge megasas
>>  530-5IR-PCI-MSI 1048587-edge megasas
>>  540-5IR-PCI-MSI 1048588-edge megasas
>>  550-5IR-PCI-MSI 1048589-edge megasas
>>  560-5IR-PCI-MSI 1048590-edge megasas
>>  570-5IR-PCI-MSI 1048591-edge megasas
>>  580-5IR-PCI-MSI 1048592-edge megasas
>>  590-5IR-PCI-MSI 1048593-edge megasas
>>  600-5IR-PCI-MSI 1048594-edge megasas
>>  610-5IR-PCI-MSI 1048595-edge megasas
>>  620-5IR-PCI-MSI 1048596-edge megasas
>>  630-5IR-PCI-MSI 1048597-edge megasas
>>  640-5IR-PCI-MSI 1048598-edge megasas
>>  650-5IR-PCI-MSI 1048599-edge megasas
>>  66  24-29IR-PCI-MSI 1048600-edge megasas
>>  67  24-29IR-PCI-MSI 1048601-edge megasas
>>  68  24-29IR-PCI-MSI 1048602-edge megasas
>>  69  24-29IR-PCI-MSI 1048603-edge megasas
>>  70  24-29IR-PCI-MSI 1048604-edge megasas
>>  71  24-29IR-PCI-MSI 1048605-edge megasas
>>  72  24-29IR-PCI-MSI 1048606-edge megasas
>>  73  24-29IR-PCI-MSI 1048607-edge megasas
>>  74  24-29IR-PCI-MSI 1048608-edge megasas
>>  75  24-29IR-PCI-MSI 1048609-edge megasas
>>  76  24-29IR-PCI-MSI 1048610-edge megasas
>>  77  24-29IR-PCI-MSI 1048611-edge megasas
>>  78  24-29IR-PCI-MSI 1048612-edge megasas
>>  79  24-29IR-PCI-MSI 1048613-edge megasas
>>  80  24-29IR-PCI-MSI 1048614-edge megasas
>>  81  24-29IR-PCI-MSI 1048615-edge megasas
>>  82  24-29IR-PCI-MSI 1048616-edge megasas
>>  83  24-29IR-PCI-MSI 1048617-edge megasas
>>  84  24-29IR-PCI-MSI 1048618-edge megasas
>>  85  24-29IR-PCI-MSI 1048619-edge megasas
>>  86  24-29IR-PCI-MSI 1048620-edge megasas
>>  87  24-29IR-PCI-MSI 1048621-edge megasas
>>  88  24-29IR-PCI-MSI 1048622-edge megasas
>>  89  24-29IR-PCI-MSI 1048623-edge megasas
>> ---
>>
>> In my server, IRQ#66-89 are sent to CPU#24-29. And if I offline CPU#24-29,
>> I/O does not work, showing the following messages.
>>
>> ---
>> [...] sd 0:2:0:0: [sda] tag#1 task abort called for scmd(8820574d7560)
>> [...] sd 0:2:0:0: [sda] tag#1 CDB: Read(10) 28 00 0d e8 cf 78 00 00 08 00
>> [...] sd 0:2:0:0: task abort: FAILED scmd(8820574d7560)
>> [...] sd 0:2:0:0: [sda] tag#0 task abort called for scmd(882057426560)
>> [...] sd 0:2:0:0: [sda] tag#0 CDB: Write(10) 2a 00 0d 58 37 00 00 00 08 00
>> [...] sd 0:2:0:0: task abort: FAILED scmd(882057426560)
>> [...] sd 0:2:0:0: target reset called for scmd(8820574d7560)
>> [...] sd 0:2:0:0: [sda] tag#1 megasas: target reset FAILED!!
>> [...] sd 0:2:0:0: [sda] tag#0 Controller reset is requested due to IO timeout
>> [...] SCSI command pointer: (882057426560)   SCSI host state: 5  SCSI
>> [...] IO request frame:
>> [...]
>> 
>> [...]
>> [...] megaraid_sas :02:00.0: [ 0]waiting for 2 commands to complete for 
>> scsi0
>> [...] INFO: task auditd:1200 blocked for more than 120 seconds.
>> [...]   Not tainted 4.13.0+ #15
>> [...] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this 
>> message.
>> [...] auditd  D0  1200  1 0x
>> [...] Call Trace:
>> [...]  __schedule+0x28d/0x890
>> [...]  schedule+0x36/0x80
>> [...]  io_schedule+0x16/0x40
>> [...]  wait_on_page_bit_common+0x109/0x1c0
>> [...]  ? page_cache_tree_insert+0xf0/0xf0
>> [...]  __filemap_fdatawait_range+0x127/0x190
>> [...]  ? __filemap_fdatawrite_range+0xd1/0x100
>> [...]  file_write_and_wait_range+0x60/0xb0
>> [...]  xfs_file_fsync+0x67/0x1d0 [xfs]
>> [...]  vfs_fsync_range+0x3d/0xb0
>> [...]  do_fsync+0x3d/0x70
>> [...]  SyS_fsync+0x10/0x20
>> [...]  entry_SYSCALL_64_fastpath+0x1a/0xa5
>> [...] RIP: 0033:0x7f0bd9633d2d
>> [...] RSP: 002b:7f0bd751ed30 EFLAGS: 0293 ORIG_RAX: 

Re: [PATCH V2 8/9] pm80xx : panic on ncq error cleaning up the read log.

2017-09-13 Thread Jinpu Wang
On Wed, Feb 18, 2015 at 12:36 AM, Viswas G  wrote:
> when there's an error in 'ncq mode' the host has to read the ncq
> error log (10h) to clear the error state. however, the ccb that
> is setup for doing this doesn't setup the ccb so that the
> previous state is cleared. if the ccb was previously used for an IO
> n_elems is set and pm8001_ccb_task_free() treats this as the signal
> to go free a scatter-gather list (that's already been free-ed).
>
> Signed-off-by: Deepak Ukey 
> Signed-off-by: Viswas G 
> ---
>  drivers/scsi/pm8001/pm80xx_hwi.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c 
> b/drivers/scsi/pm8001/pm80xx_hwi.c
> index 92d2045dea68..f2c0839afbe3 100644
> --- a/drivers/scsi/pm8001/pm80xx_hwi.c
> +++ b/drivers/scsi/pm8001/pm80xx_hwi.c
> @@ -1489,6 +1489,7 @@ static void pm80xx_send_read_log(struct pm8001_hba_info 
> *pm8001_ha,
> ccb->device = pm8001_ha_dev;
> ccb->ccb_tag = ccb_tag;
> ccb->task = task;
> +   ccb->n_elem = 0;
> pm8001_ha_dev->id |= NCQ_READ_LOG_FLAG;
> pm8001_ha_dev->id |= NCQ_2ND_RLE_FLAG;
>
> --
> 2.12.3
>

Thanks,
Acked-by: Jack Wang 

-- 
Jack Wang
Linux Kernel Developer

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin

Tel:   +49 30 577 008  042
Fax:  +49 30 577 008 299
Email:jinpu.w...@profitbricks.com
URL:  https://www.profitbricks.de

Sitz der Gesellschaft: Berlin
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B
Geschäftsführer: Achim Weiss


Re: [PATCH V2 7/9] pm80xx : corrected SATA abort handling sequence.

2017-09-13 Thread Jinpu Wang
On Wed, Feb 18, 2015 at 12:36 AM, Viswas G  wrote:
> Modified SATA abort handling with following steps:
> 1) Set device state as recovery.
> 2) Send phy reset.
> 3) Wait for reset completion.
> 4) After successful reset, abort all IO's to the device.
> 5) After aborting all IO's to device, set device state as operational.
>
> Signed-off-by: Deepak Ukey 
> Signed-off-by: Viswas G 
> ---
>  drivers/scsi/pm8001/pm8001_hwi.c |  8 -
>  drivers/scsi/pm8001/pm8001_sas.c | 71 
> ++--
>  drivers/scsi/pm8001/pm8001_sas.h |  8 +
>  drivers/scsi/pm8001/pm80xx_hwi.c | 36 
>  4 files changed, 113 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/scsi/pm8001/pm8001_hwi.c 
> b/drivers/scsi/pm8001/pm8001_hwi.c
> index bc4a6f649ec9..db88a8e7ee0e 100644
> --- a/drivers/scsi/pm8001/pm8001_hwi.c
> +++ b/drivers/scsi/pm8001/pm8001_hwi.c
> @@ -3209,10 +3209,16 @@ int pm8001_mpi_local_phy_ctl(struct pm8001_hba_info 
> *pm8001_ha, void *piomb)
> PM8001_MSG_DBG(pm8001_ha,
> pm8001_printk("%x phy execute %x phy op failed!\n",
> phy_id, phy_op));
> -   } else
> +   } else {
> PM8001_MSG_DBG(pm8001_ha,
> pm8001_printk("%x phy execute %x phy op success!\n",
> phy_id, phy_op));
> +   pm8001_ha->phy[phy_id].reset_success = true;
> +   }
> +   if (pm8001_ha->phy[phy_id].enable_completion) {
> +   complete(pm8001_ha->phy[phy_id].enable_completion);
> +   pm8001_ha->phy[phy_id].enable_completion = NULL;
> +   }
> pm8001_tag_free(pm8001_ha, tag);
> return 0;
>  }
> diff --git a/drivers/scsi/pm8001/pm8001_sas.c 
> b/drivers/scsi/pm8001/pm8001_sas.c
> index e80b0542a67f..60d5bec5c45e 100644
> --- a/drivers/scsi/pm8001/pm8001_sas.c
> +++ b/drivers/scsi/pm8001/pm8001_sas.c
> @@ -1167,13 +1167,16 @@ int pm8001_abort_task(struct sas_task *task)
> struct scsi_lun lun;
> struct pm8001_device *pm8001_dev;
> struct pm8001_tmf_task tmf_task;
> -   int rc = TMF_RESP_FUNC_FAILED;
> +   int rc = TMF_RESP_FUNC_FAILED, ret;
> +   u32 phy_id;
> +   struct sas_task_slow slow_task;
> if (unlikely(!task || !task->lldd_task || !task->dev))
> return TMF_RESP_FUNC_FAILED;
> dev = task->dev;
> pm8001_dev = dev->lldd_dev;
> pm8001_ha = pm8001_find_ha_by_dev(dev);
> device_id = pm8001_dev->device_id;
> +   phy_id = pm8001_dev->attached_phy;
> rc = pm8001_find_tag(task, );
> if (rc == 0) {
> pm8001_printk("no tag for task:%p\n", task);
> @@ -1184,6 +1187,11 @@ int pm8001_abort_task(struct sas_task *task)
> spin_unlock_irqrestore(>task_state_lock, flags);
> return TMF_RESP_FUNC_COMPLETE;
> }
> +   task->task_state_flags |= SAS_TASK_STATE_ABORTED;
> +   if (task->slow_task == NULL) {
> +   init_completion(_task.completion);
> +   task->slow_task = _task;
> +   }
> spin_unlock_irqrestore(>task_state_lock, flags);
> if (task->task_proto & SAS_PROTOCOL_SSP) {
> struct scsi_cmnd *cmnd = task->uldd_task;
> @@ -1195,8 +1203,61 @@ int pm8001_abort_task(struct sas_task *task)
> pm8001_dev->sas_device, 0, tag);
> } else if (task->task_proto & SAS_PROTOCOL_SATA ||
> task->task_proto & SAS_PROTOCOL_STP) {
> -   rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev,
> -   pm8001_dev->sas_device, 0, tag);
> +   if (pm8001_ha->chip_id == chip_8006) {
> +   DECLARE_COMPLETION_ONSTACK(completion_reset);
> +   DECLARE_COMPLETION_ONSTACK(completion);
> +   struct pm8001_phy *phy = pm8001_ha->phy + phy_id;
> +   /* 1. Set Device state as Recovery*/
> +   pm8001_dev->setds_completion = 
> +   PM8001_CHIP_DISP->set_dev_state_req(pm8001_ha,
> +   pm8001_dev, 0x03);
> +   wait_for_completion();
> +   /* 2. Send Phy Control Hard Reset */
> +   reinit_completion();
> +   phy->reset_success = false;
> +   phy->enable_completion = 
> +   phy->reset_completion = _reset;
> +   ret = PM8001_CHIP_DISP->phy_ctl_req(pm8001_ha, phy_id,
> +   PHY_HARD_RESET);
> +   if (ret)
> +   goto out;
> +   PM8001_MSG_DBG(pm8001_ha,
> +   pm8001_printk("Waiting for local phy ctl\n"));
> +   wait_for_completion();
> +   

Re: [PATCH V2 6/9] pm80xx : modified port reset timer value for PM8006 card

2017-09-13 Thread Jinpu Wang
On Wed, Feb 18, 2015 at 12:36 AM, Viswas G  wrote:
> Added port reset timer value as 2000ms for PM8006 sata controller.
>
> Signed-off-by: Deepak Ukey 
> Signed-off-by: Viswas G 
> ---
>  drivers/scsi/pm8001/pm80xx_hwi.c | 6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c 
> b/drivers/scsi/pm8001/pm80xx_hwi.c
> index baab8a19c78e..8f1f5dc77d71 100644
> --- a/drivers/scsi/pm8001/pm80xx_hwi.c
> +++ b/drivers/scsi/pm8001/pm80xx_hwi.c
> @@ -597,6 +597,12 @@ static void update_main_config_table(struct 
> pm8001_hba_info *pm8001_ha)
> pm8001_ha->main_cfg_tbl.pm80xx_tbl.port_recovery_timer &= 0x;
> pm8001_ha->main_cfg_tbl.pm80xx_tbl.port_recovery_timer |=
> PORT_RECOVERY_TIMEOUT;
> +   if (pm8001_ha->chip_id == chip_8006) {
> +   pm8001_ha->main_cfg_tbl.pm80xx_tbl.port_recovery_timer &=
> +   0x;
> +   pm8001_ha->main_cfg_tbl.pm80xx_tbl.port_recovery_timer |=
> +   0x14;
> +   }
> pm8001_mw32(address, MAIN_PORT_RECOVERY_TIMER,
> 
> pm8001_ha->main_cfg_tbl.pm80xx_tbl.port_recovery_timer);
>  }
> --
> 2.12.3
>

Thanks,
Acked-by: Jack Wang 

-- 
Jack Wang
Linux Kernel Developer

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin

Tel:   +49 30 577 008  042
Fax:  +49 30 577 008 299
Email:jinpu.w...@profitbricks.com
URL:  https://www.profitbricks.de

Sitz der Gesellschaft: Berlin
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B
Geschäftsführer: Achim Weiss


Re: [PATCH V2 4/9] pm80xx : tag allocation for phy control request.

2017-09-13 Thread Jinpu Wang
On Wed, Feb 18, 2015 at 12:36 AM, Viswas G  wrote:
> tag is taken from the tag pool instead of using the hardcoded
> tag value(1).
>
> Signed-off-by: Deepak Ukey 
> Signed-off-by: Viswas G 
> ---
>  drivers/scsi/pm8001/pm8001_hwi.c |  3 +++
>  drivers/scsi/pm8001/pm80xx_hwi.c | 10 +++---
>  2 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/scsi/pm8001/pm8001_hwi.c 
> b/drivers/scsi/pm8001/pm8001_hwi.c
> index 10546faac58c..bc4a6f649ec9 100644
> --- a/drivers/scsi/pm8001/pm8001_hwi.c
> +++ b/drivers/scsi/pm8001/pm8001_hwi.c
> @@ -3198,11 +3198,13 @@ pm8001_mpi_get_nvmd_resp(struct pm8001_hba_info 
> *pm8001_ha, void *piomb)
>
>  int pm8001_mpi_local_phy_ctl(struct pm8001_hba_info *pm8001_ha, void *piomb)
>  {
> +   u32 tag;
> struct local_phy_ctl_resp *pPayload =
> (struct local_phy_ctl_resp *)(piomb + 4);
> u32 status = le32_to_cpu(pPayload->status);
> u32 phy_id = le32_to_cpu(pPayload->phyop_phyid) & ID_BITS;
> u32 phy_op = le32_to_cpu(pPayload->phyop_phyid) & OP_BITS;
> +   tag = le32_to_cpu(pPayload->tag);
> if (status != 0) {
> PM8001_MSG_DBG(pm8001_ha,
> pm8001_printk("%x phy execute %x phy op failed!\n",
> @@ -3211,6 +3213,7 @@ int pm8001_mpi_local_phy_ctl(struct pm8001_hba_info 
> *pm8001_ha, void *piomb)
> PM8001_MSG_DBG(pm8001_ha,
> pm8001_printk("%x phy execute %x phy op success!\n",
> phy_id, phy_op));
> +   pm8001_tag_free(pm8001_ha, tag);
> return 0;
>  }
>
> diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c 
> b/drivers/scsi/pm8001/pm80xx_hwi.c
> index 2b26445d1b97..baab8a19c78e 100644
> --- a/drivers/scsi/pm8001/pm80xx_hwi.c
> +++ b/drivers/scsi/pm8001/pm80xx_hwi.c
> @@ -4500,17 +4500,21 @@ static int pm80xx_chip_reg_dev_req(struct 
> pm8001_hba_info *pm8001_ha,
>  static int pm80xx_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha,
> u32 phyId, u32 phy_op)
>  {
> +   u32 tag;
> +   int rc;
> struct local_phy_ctl_req payload;
> struct inbound_queue_table *circularQ;
> int ret;
> u32 opc = OPC_INB_LOCAL_PHY_CONTROL;
> memset(, 0, sizeof(payload));
> +   rc = pm8001_tag_alloc(pm8001_ha, );
> +   if (rc)
> +   return rc;
> circularQ = _ha->inbnd_q_tbl[0];
> -   payload.tag = cpu_to_le32(1);
> +   payload.tag = cpu_to_le32(tag);
> payload.phyop_phyid =
> cpu_to_le32(((phy_op & 0xFF) << 8) | (phyId & 0xFF));
> -   ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, , 0);
> -   return ret;
> +   return pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, , 0);
>  }
>
>  static u32 pm80xx_chip_is_our_interupt(struct pm8001_hba_info *pm8001_ha)
> --
> 2.12.3
>

Thanks,
Acked-by: Jack Wang 

-- 
Jack Wang
Linux Kernel Developer

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin

Tel:   +49 30 577 008  042
Fax:  +49 30 577 008 299
Email:jinpu.w...@profitbricks.com
URL:  https://www.profitbricks.de

Sitz der Gesellschaft: Berlin
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B
Geschäftsführer: Achim Weiss


Re: [PATCH V2 1/9] pm80xx : redefine sas_identify_frame structure

2017-09-13 Thread Jinpu Wang
On Wed, Feb 18, 2015 at 12:36 AM, Viswas G  wrote:
> sas_identify structure defined by pm80xx doesn't have CRC field.
> So added a new sas_identify structure without CRC.
>
> v2:
> - Since the structure changes is applicable for only pm80xx,
>   sas_identify_frame_local structure moved to pm80xx_hwi.h.
>
> Signed-off-by: Raj Dinesh 
> Signed-off-by: Viswas G 
> ---
>  drivers/scsi/pm8001/pm80xx_hwi.h | 98 
> +++-
>  1 file changed, 97 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/pm8001/pm80xx_hwi.h 
> b/drivers/scsi/pm8001/pm80xx_hwi.h
> index 7a443bad6163..82b8cf581da9 100644
> --- a/drivers/scsi/pm8001/pm80xx_hwi.h
> +++ b/drivers/scsi/pm8001/pm80xx_hwi.h
> @@ -229,6 +229,102 @@
>  #define IT_NEXUS_TIMEOUT   0x7D0
>  #define PORT_RECOVERY_TIMEOUT  ((IT_NEXUS_TIMEOUT/100) + 30)
>
> +#ifdef __LITTLE_ENDIAN_BITFIELD
> +struct sas_identify_frame_local {
> +   /* Byte 0 */
> +   u8  frame_type:4;
> +   u8  dev_type:3;
> +   u8  _un0:1;
> +
> +   /* Byte 1 */
> +   u8  _un1;
> +
> +   /* Byte 2 */
> +   union {
> +   struct {
> +   u8  _un20:1;
> +   u8  smp_iport:1;
> +   u8  stp_iport:1;
> +   u8  ssp_iport:1;
> +   u8  _un247:4;
> +   };
> +   u8 initiator_bits;
> +   };
> +
> +   /* Byte 3 */
> +   union {
> +   struct {
> +   u8  _un30:1;
> +   u8 smp_tport:1;
> +   u8 stp_tport:1;
> +   u8 ssp_tport:1;
> +   u8 _un347:4;
> +   };
> +   u8 target_bits;
> +   };
> +
> +   /* Byte 4 - 11 */
> +   u8 _un4_11[8];
> +
> +   /* Byte 12 - 19 */
> +   u8 sas_addr[SAS_ADDR_SIZE];
> +
> +   /* Byte 20 */
> +   u8 phy_id;
> +
> +   u8 _un21_27[7];
> +
> +} __packed;
> +
> +#elif defined(__BIG_ENDIAN_BITFIELD)
> +struct sas_identify_frame_local {
> +   /* Byte 0 */
> +   u8  _un0:1;
> +   u8  dev_type:3;
> +   u8  frame_type:4;
> +
> +   /* Byte 1 */
> +   u8  _un1;
> +
> +   /* Byte 2 */
> +   union {
> +   struct {
> +   u8  _un247:4;
> +   u8  ssp_iport:1;
> +   u8  stp_iport:1;
> +   u8  smp_iport:1;
> +   u8  _un20:1;
> +   };
> +   u8 initiator_bits;
> +   };
> +
> +   /* Byte 3 */
> +   union {
> +   struct {
> +   u8 _un347:4;
> +   u8 ssp_tport:1;
> +   u8 stp_tport:1;
> +   u8 smp_tport:1;
> +   u8 _un30:1;
> +   };
> +   u8 target_bits;
> +   };
> +
> +   /* Byte 4 - 11 */
> +   u8 _un4_11[8];
> +
> +   /* Byte 12 - 19 */
> +   u8 sas_addr[SAS_ADDR_SIZE];
> +
> +   /* Byte 20 */
> +   u8 phy_id;
> +
> +   u8 _un21_27[7];
> +} __packed;
> +#else
> +#error "Bitfield order not defined!"
> +#endif
> +
>  struct mpi_msg_hdr {
> __le32  header; /* Bits [11:0] - Message operation code */
> /* Bits [15:12] - Message Category */
> @@ -248,7 +344,7 @@ struct mpi_msg_hdr {
>  struct phy_start_req {
> __le32  tag;
> __le32  ase_sh_lm_slr_phyid;
> -   struct sas_identify_frame sas_identify; /* 28 Bytes */
> +   struct sas_identify_frame_local sas_identify; /* 28 Bytes */
> __le32 spasti;
> u32 reserved[21];
>  } __attribute__((packed, aligned(4)));
> --
> 2.12.3
>
Thanks,
Acked-by: Jack Wang 

-- 
Jack Wang
Linux Kernel Developer

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin

Tel:   +49 30 577 008  042
Fax:  +49 30 577 008 299
Email:jinpu.w...@profitbricks.com
URL:  https://www.profitbricks.de

Sitz der Gesellschaft: Berlin
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B
Geschäftsführer: Achim Weiss


[PATCH V2 4/9] pm80xx : tag allocation for phy control request.

2017-09-13 Thread Viswas G
tag is taken from the tag pool instead of using the hardcoded
tag value(1).

Signed-off-by: Deepak Ukey 
Signed-off-by: Viswas G 
---
 drivers/scsi/pm8001/pm8001_hwi.c |  3 +++
 drivers/scsi/pm8001/pm80xx_hwi.c | 10 +++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index 10546faac58c..bc4a6f649ec9 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -3198,11 +3198,13 @@ pm8001_mpi_get_nvmd_resp(struct pm8001_hba_info 
*pm8001_ha, void *piomb)
 
 int pm8001_mpi_local_phy_ctl(struct pm8001_hba_info *pm8001_ha, void *piomb)
 {
+   u32 tag;
struct local_phy_ctl_resp *pPayload =
(struct local_phy_ctl_resp *)(piomb + 4);
u32 status = le32_to_cpu(pPayload->status);
u32 phy_id = le32_to_cpu(pPayload->phyop_phyid) & ID_BITS;
u32 phy_op = le32_to_cpu(pPayload->phyop_phyid) & OP_BITS;
+   tag = le32_to_cpu(pPayload->tag);
if (status != 0) {
PM8001_MSG_DBG(pm8001_ha,
pm8001_printk("%x phy execute %x phy op failed!\n",
@@ -3211,6 +3213,7 @@ int pm8001_mpi_local_phy_ctl(struct pm8001_hba_info 
*pm8001_ha, void *piomb)
PM8001_MSG_DBG(pm8001_ha,
pm8001_printk("%x phy execute %x phy op success!\n",
phy_id, phy_op));
+   pm8001_tag_free(pm8001_ha, tag);
return 0;
 }
 
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
index 2b26445d1b97..baab8a19c78e 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.c
+++ b/drivers/scsi/pm8001/pm80xx_hwi.c
@@ -4500,17 +4500,21 @@ static int pm80xx_chip_reg_dev_req(struct 
pm8001_hba_info *pm8001_ha,
 static int pm80xx_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha,
u32 phyId, u32 phy_op)
 {
+   u32 tag;
+   int rc;
struct local_phy_ctl_req payload;
struct inbound_queue_table *circularQ;
int ret;
u32 opc = OPC_INB_LOCAL_PHY_CONTROL;
memset(, 0, sizeof(payload));
+   rc = pm8001_tag_alloc(pm8001_ha, );
+   if (rc)
+   return rc;
circularQ = _ha->inbnd_q_tbl[0];
-   payload.tag = cpu_to_le32(1);
+   payload.tag = cpu_to_le32(tag);
payload.phyop_phyid =
cpu_to_le32(((phy_op & 0xFF) << 8) | (phyId & 0xFF));
-   ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, , 0);
-   return ret;
+   return pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, , 0);
 }
 
 static u32 pm80xx_chip_is_our_interupt(struct pm8001_hba_info *pm8001_ha)
-- 
2.12.3



[PATCH V2 1/9] pm80xx : redefine sas_identify_frame structure

2017-09-13 Thread Viswas G
sas_identify structure defined by pm80xx doesn't have CRC field.
So added a new sas_identify structure without CRC.

v2:
- Since the structure changes is applicable for only pm80xx,
  sas_identify_frame_local structure moved to pm80xx_hwi.h.

Signed-off-by: Raj Dinesh 
Signed-off-by: Viswas G 
---
 drivers/scsi/pm8001/pm80xx_hwi.h | 98 +++-
 1 file changed, 97 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/pm8001/pm80xx_hwi.h b/drivers/scsi/pm8001/pm80xx_hwi.h
index 7a443bad6163..82b8cf581da9 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.h
+++ b/drivers/scsi/pm8001/pm80xx_hwi.h
@@ -229,6 +229,102 @@
 #define IT_NEXUS_TIMEOUT   0x7D0
 #define PORT_RECOVERY_TIMEOUT  ((IT_NEXUS_TIMEOUT/100) + 30)
 
+#ifdef __LITTLE_ENDIAN_BITFIELD
+struct sas_identify_frame_local {
+   /* Byte 0 */
+   u8  frame_type:4;
+   u8  dev_type:3;
+   u8  _un0:1;
+
+   /* Byte 1 */
+   u8  _un1;
+
+   /* Byte 2 */
+   union {
+   struct {
+   u8  _un20:1;
+   u8  smp_iport:1;
+   u8  stp_iport:1;
+   u8  ssp_iport:1;
+   u8  _un247:4;
+   };
+   u8 initiator_bits;
+   };
+
+   /* Byte 3 */
+   union {
+   struct {
+   u8  _un30:1;
+   u8 smp_tport:1;
+   u8 stp_tport:1;
+   u8 ssp_tport:1;
+   u8 _un347:4;
+   };
+   u8 target_bits;
+   };
+
+   /* Byte 4 - 11 */
+   u8 _un4_11[8];
+
+   /* Byte 12 - 19 */
+   u8 sas_addr[SAS_ADDR_SIZE];
+
+   /* Byte 20 */
+   u8 phy_id;
+
+   u8 _un21_27[7];
+
+} __packed;
+
+#elif defined(__BIG_ENDIAN_BITFIELD)
+struct sas_identify_frame_local {
+   /* Byte 0 */
+   u8  _un0:1;
+   u8  dev_type:3;
+   u8  frame_type:4;
+
+   /* Byte 1 */
+   u8  _un1;
+
+   /* Byte 2 */
+   union {
+   struct {
+   u8  _un247:4;
+   u8  ssp_iport:1;
+   u8  stp_iport:1;
+   u8  smp_iport:1;
+   u8  _un20:1;
+   };
+   u8 initiator_bits;
+   };
+
+   /* Byte 3 */
+   union {
+   struct {
+   u8 _un347:4;
+   u8 ssp_tport:1;
+   u8 stp_tport:1;
+   u8 smp_tport:1;
+   u8 _un30:1;
+   };
+   u8 target_bits;
+   };
+
+   /* Byte 4 - 11 */
+   u8 _un4_11[8];
+
+   /* Byte 12 - 19 */
+   u8 sas_addr[SAS_ADDR_SIZE];
+
+   /* Byte 20 */
+   u8 phy_id;
+
+   u8 _un21_27[7];
+} __packed;
+#else
+#error "Bitfield order not defined!"
+#endif
+
 struct mpi_msg_hdr {
__le32  header; /* Bits [11:0] - Message operation code */
/* Bits [15:12] - Message Category */
@@ -248,7 +344,7 @@ struct mpi_msg_hdr {
 struct phy_start_req {
__le32  tag;
__le32  ase_sh_lm_slr_phyid;
-   struct sas_identify_frame sas_identify; /* 28 Bytes */
+   struct sas_identify_frame_local sas_identify; /* 28 Bytes */
__le32 spasti;
u32 reserved[21];
 } __attribute__((packed, aligned(4)));
-- 
2.12.3



[PATCH V2 3/9] pm80xx : Different SAS addresses for phys.

2017-09-13 Thread Viswas G
Different SAS addresses are assigned for each set of phys.

Signed-off-by: Viswas G 
Acked-by: Jack Wang 
---
 drivers/scsi/pm8001/pm8001_init.c | 13 +
 drivers/scsi/pm8001/pm80xx_hwi.c  |  3 +--
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/pm8001/pm8001_init.c 
b/drivers/scsi/pm8001/pm8001_init.c
index 034b2f7d1135..d282f1562615 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -132,7 +132,7 @@ static void pm8001_phy_init(struct pm8001_hba_info 
*pm8001_ha, int phy_id)
sas_phy->oob_mode = OOB_NOT_CONNECTED;
sas_phy->linkrate = SAS_LINK_RATE_UNKNOWN;
sas_phy->id = phy_id;
-   sas_phy->sas_addr = _ha->sas_addr[0];
+   sas_phy->sas_addr = (u8 *)>dev_sas_addr;
sas_phy->frame_rcvd = >frame_rcvd[0];
sas_phy->ha = (struct sas_ha_struct *)pm8001_ha->shost->hostdata;
sas_phy->lldd_phy = phy;
@@ -593,10 +593,12 @@ static void  pm8001_post_sas_ha_init(struct Scsi_Host 
*shost,
for (i = 0; i < chip_info->n_phy; i++) {
sha->sas_phy[i] = _ha->phy[i].sas_phy;
sha->sas_port[i] = _ha->port[i].sas_port;
+   sha->sas_phy[i]->sas_addr =
+   (u8 *)_ha->phy[i].dev_sas_addr;
}
sha->sas_ha_name = DRV_NAME;
sha->dev = pm8001_ha->dev;
-
+   sha->strict_wide_ports = 1;
sha->lldd_module = THIS_MODULE;
sha->sas_addr = _ha->sas_addr[0];
sha->num_phys = chip_info->n_phy;
@@ -613,6 +615,7 @@ static void  pm8001_post_sas_ha_init(struct Scsi_Host 
*shost,
 static void pm8001_init_sas_add(struct pm8001_hba_info *pm8001_ha)
 {
u8 i, j;
+   u8 sas_add[8];
 #ifdef PM8001_READ_VPD
/* For new SPC controllers WWN is stored in flash vpd
*  For SPC/SPCve controllers WWN is stored in EEPROM
@@ -674,10 +677,12 @@ static void pm8001_init_sas_add(struct pm8001_hba_info 
*pm8001_ha)
pm8001_ha->sas_addr[j] =
payload.func_specific[0x804 + i];
}
-
+   memcpy(sas_add, pm8001_ha->sas_addr, SAS_ADDR_SIZE);
for (i = 0; i < pm8001_ha->chip->n_phy; i++) {
+   if (i && ((i % 4) == 0))
+   sas_add[7] = sas_add[7] + 4;
memcpy(_ha->phy[i].dev_sas_addr,
-   pm8001_ha->sas_addr, SAS_ADDR_SIZE);
+   sas_add, SAS_ADDR_SIZE);
PM8001_INIT_DBG(pm8001_ha,
pm8001_printk("phy %d sas_addr = %016llx\n", i,
pm8001_ha->phy[i].dev_sas_addr));
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
index 8fb5ddf08cc4..2b26445d1b97 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.c
+++ b/drivers/scsi/pm8001/pm80xx_hwi.c
@@ -3041,7 +3041,6 @@ hw_event_phy_down(struct pm8001_hba_info *pm8001_ha, void 
*piomb)
port->port_state = portstate;
phy->identify.device_type = 0;
phy->phy_attached = 0;
-   memset(>dev_sas_addr, 0, SAS_ADDR_SIZE);
switch (portstate) {
case PORT_VALID:
break;
@@ -4394,7 +4393,7 @@ pm80xx_chip_phy_start_req(struct pm8001_hba_info 
*pm8001_ha, u8 phy_id)
payload.sas_identify.dev_type = SAS_END_DEVICE;
payload.sas_identify.initiator_bits = SAS_PROTOCOL_ALL;
memcpy(payload.sas_identify.sas_addr,
-   pm8001_ha->sas_addr, SAS_ADDR_SIZE);
+ _ha->phy[phy_id].dev_sas_addr, SAS_ADDR_SIZE);
payload.sas_identify.phy_id = phy_id;
ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opcode, , 0);
return ret;
-- 
2.12.3



[PATCH V2 6/9] pm80xx : modified port reset timer value for PM8006 card

2017-09-13 Thread Viswas G
Added port reset timer value as 2000ms for PM8006 sata controller.

Signed-off-by: Deepak Ukey 
Signed-off-by: Viswas G 
---
 drivers/scsi/pm8001/pm80xx_hwi.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
index baab8a19c78e..8f1f5dc77d71 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.c
+++ b/drivers/scsi/pm8001/pm80xx_hwi.c
@@ -597,6 +597,12 @@ static void update_main_config_table(struct 
pm8001_hba_info *pm8001_ha)
pm8001_ha->main_cfg_tbl.pm80xx_tbl.port_recovery_timer &= 0x;
pm8001_ha->main_cfg_tbl.pm80xx_tbl.port_recovery_timer |=
PORT_RECOVERY_TIMEOUT;
+   if (pm8001_ha->chip_id == chip_8006) {
+   pm8001_ha->main_cfg_tbl.pm80xx_tbl.port_recovery_timer &=
+   0x;
+   pm8001_ha->main_cfg_tbl.pm80xx_tbl.port_recovery_timer |=
+   0x14;
+   }
pm8001_mw32(address, MAIN_PORT_RECOVERY_TIMER,
pm8001_ha->main_cfg_tbl.pm80xx_tbl.port_recovery_timer);
 }
-- 
2.12.3



[PATCH V2 9/9] pm80xx : corrected linkrate value.

2017-09-13 Thread Viswas G
Corrected the value defined for LINKRATE_60 (6 Gig).

Signed-off-by: Raj Dinesh 
Signed-off-by: Viswas G 
Acked-by: Jack Wang 
---
 drivers/scsi/pm8001/pm80xx_hwi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/pm8001/pm80xx_hwi.h b/drivers/scsi/pm8001/pm80xx_hwi.h
index e36c5176f9a9..889e69ce3689 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.h
+++ b/drivers/scsi/pm8001/pm80xx_hwi.h
@@ -167,7 +167,7 @@
 #define LINKMODE_AUTO  (0x03 << 12)
 #define LINKRATE_15(0x01 << 8)
 #define LINKRATE_30(0x02 << 8)
-#define LINKRATE_60(0x06 << 8)
+#define LINKRATE_60(0x04 << 8)
 #define LINKRATE_120   (0x08 << 8)
 
 /* phy_profile */
-- 
2.12.3



[PATCH V2 2/9] pm80xx : ILA and inactive firmware version through sysfs

2017-09-13 Thread Viswas G
Added support to read ILA version and inactive firmware version
from MPI configuration table and export through sysfs.

Signed-off-by: Deepak Ukey 
Signed-off-by: Viswas G 

Acked-by: Jack Wang 
---
 drivers/scsi/pm8001/pm8001_ctl.c | 54 
 drivers/scsi/pm8001/pm8001_sas.h |  2 ++
 drivers/scsi/pm8001/pm80xx_hwi.c |  5 
 drivers/scsi/pm8001/pm80xx_hwi.h |  2 ++
 4 files changed, 63 insertions(+)

diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c
index be8269c8d127..596f3ff965f5 100644
--- a/drivers/scsi/pm8001/pm8001_ctl.c
+++ b/drivers/scsi/pm8001/pm8001_ctl.c
@@ -98,6 +98,58 @@ static ssize_t pm8001_ctl_fw_version_show(struct device 
*cdev,
}
 }
 static DEVICE_ATTR(fw_version, S_IRUGO, pm8001_ctl_fw_version_show, NULL);
+
+/**
+ * pm8001_ctl_ila_version_show - ila version
+ * @cdev: pointer to embedded class device
+ * @buf: the buffer returned
+ *
+ * A sysfs 'read-only' shost attribute.
+ */
+static ssize_t pm8001_ctl_ila_version_show(struct device *cdev,
+   struct device_attribute *attr, char *buf)
+{
+   struct Scsi_Host *shost = class_to_shost(cdev);
+   struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
+   struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
+
+   if (pm8001_ha->chip_id != chip_8001) {
+   return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x\n",
+   (u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.ila_version >> 24),
+   (u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.ila_version >> 16),
+   (u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.ila_version >> 8),
+   (u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.ila_version));
+   }
+   return 0;
+}
+static DEVICE_ATTR(ila_version, 0444, pm8001_ctl_ila_version_show, NULL);
+
+/**
+ * pm8001_ctl_inactive_fw_version_show - Inacative firmware version number
+ * @cdev: pointer to embedded class device
+ * @buf: the buffer returned
+ *
+ * A sysfs 'read-only' shost attribute.
+ */
+static ssize_t pm8001_ctl_inactive_fw_version_show(struct device *cdev,
+   struct device_attribute *attr, char *buf)
+{
+   struct Scsi_Host *shost = class_to_shost(cdev);
+   struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
+   struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
+
+   if (pm8001_ha->chip_id != chip_8001) {
+   return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x\n",
+   (u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.inc_fw_version >> 24),
+   (u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.inc_fw_version >> 16),
+   (u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.inc_fw_version >> 8),
+   (u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.inc_fw_version));
+   }
+   return 0;
+}
+static
+DEVICE_ATTR(inc_fw_ver, 0444, pm8001_ctl_inactive_fw_version_show, NULL);
+
 /**
  * pm8001_ctl_max_out_io_show - max outstanding io supported
  * @cdev: pointer to embedded class device
@@ -748,6 +800,8 @@ struct device_attribute *pm8001_host_attrs[] = {
_attr_bios_version,
_attr_ib_log,
_attr_ob_log,
+   _attr_ila_version,
+   _attr_inc_fw_ver,
NULL,
 };
 
diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h
index e81a8fa7ef1a..c75de413e062 100644
--- a/drivers/scsi/pm8001/pm8001_sas.h
+++ b/drivers/scsi/pm8001/pm8001_sas.h
@@ -404,6 +404,8 @@ union main_cfg_table {
u32 port_recovery_timer;
u32 interrupt_reassertion_delay;
u32 fatal_n_non_fatal_dump; /* 0x28 */
+   u32 ila_version;
+   u32 inc_fw_version;
} pm80xx_tbl;
 };
 
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
index eb4fee61df72..8fb5ddf08cc4 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.c
+++ b/drivers/scsi/pm8001/pm80xx_hwi.c
@@ -312,6 +312,11 @@ static void read_main_config_table(struct pm8001_hba_info 
*pm8001_ha)
/* read port recover and reset timeout */
pm8001_ha->main_cfg_tbl.pm80xx_tbl.port_recovery_timer =
pm8001_mr32(address, MAIN_PORT_RECOVERY_TIMER);
+   /* read ILA and inactive firmware version */
+   pm8001_ha->main_cfg_tbl.pm80xx_tbl.ila_version =
+   pm8001_mr32(address, MAIN_MPI_ILA_RELEASE_TYPE);
+   pm8001_ha->main_cfg_tbl.pm80xx_tbl.inc_fw_version =
+   pm8001_mr32(address, MAIN_MPI_INACTIVE_FW_VERSION);
 }
 
 /**
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.h b/drivers/scsi/pm8001/pm80xx_hwi.h
index 82b8cf581da9..e36c5176f9a9 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.h
+++ b/drivers/scsi/pm8001/pm80xx_hwi.h
@@ -1445,6 +1445,8 @@ typedef struct SASProtocolTimerConfig 
SASProtocolTimerConfig_t;
 #define MAIN_SAS_PHY_ATTR_TABLE_OFFSET 0x90 /* DWORD 0x24 */
 #define MAIN_PORT_RECOVERY_TIMER   0x94 

[PATCH V2 8/9] pm80xx : panic on ncq error cleaning up the read log.

2017-09-13 Thread Viswas G
when there's an error in 'ncq mode' the host has to read the ncq
error log (10h) to clear the error state. however, the ccb that
is setup for doing this doesn't setup the ccb so that the
previous state is cleared. if the ccb was previously used for an IO
n_elems is set and pm8001_ccb_task_free() treats this as the signal
to go free a scatter-gather list (that's already been free-ed).

Signed-off-by: Deepak Ukey 
Signed-off-by: Viswas G 
---
 drivers/scsi/pm8001/pm80xx_hwi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
index 92d2045dea68..f2c0839afbe3 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.c
+++ b/drivers/scsi/pm8001/pm80xx_hwi.c
@@ -1489,6 +1489,7 @@ static void pm80xx_send_read_log(struct pm8001_hba_info 
*pm8001_ha,
ccb->device = pm8001_ha_dev;
ccb->ccb_tag = ccb_tag;
ccb->task = task;
+   ccb->n_elem = 0;
pm8001_ha_dev->id |= NCQ_READ_LOG_FLAG;
pm8001_ha_dev->id |= NCQ_2ND_RLE_FLAG;
 
-- 
2.12.3



[PATCH V2 0/9] pm80xx updates

2017-09-13 Thread Viswas G
This patch set include some bug fixes and enhancement for pm80xx driver.

Changes from V1:

- sas_identify_frame_local structure moved to pm80xx_hwi.h
- sata abort handling patch split to four patches.
- tag allocation for phy control request.
- cleanup in pm8001_abort_task function.
- modified port reset timer value for PM8006 card
- corrected SATA abort handling sequence.

Viswas G (9):
  pm80xx : redefine sas_identify_frame structure
  pm80xx : ILA and inactive firmware version through sysfs
  pm80xx : Different SAS addresses for phys.
  pm80xx : tag allocation for phy control request.
  pm80xx : cleanup in pm8001_abort_task function.
  pm80xx : modified port reset timer value for PM8006 card
  pm80xx : corrected SATA abort handling sequence.
  pm80xx : panic on ncq error cleaning up the read log.
  pm80xx : corrected linkrate value.

 drivers/scsi/pm8001/pm8001_ctl.c  |  54 +
 drivers/scsi/pm8001/pm8001_hwi.c  |  11 +++-
 drivers/scsi/pm8001/pm8001_init.c |  13 +++--
 drivers/scsi/pm8001/pm8001_sas.c  | 118 ++
 drivers/scsi/pm8001/pm8001_sas.h  |  10 
 drivers/scsi/pm8001/pm80xx_hwi.c  |  61 
 drivers/scsi/pm8001/pm80xx_hwi.h  | 102 +++-
 7 files changed, 313 insertions(+), 56 deletions(-)

-- 
2.12.3



[PATCH V2 7/9] pm80xx : corrected SATA abort handling sequence.

2017-09-13 Thread Viswas G
Modified SATA abort handling with following steps:
1) Set device state as recovery.
2) Send phy reset.
3) Wait for reset completion.
4) After successful reset, abort all IO's to the device.
5) After aborting all IO's to device, set device state as operational.

Signed-off-by: Deepak Ukey 
Signed-off-by: Viswas G 
---
 drivers/scsi/pm8001/pm8001_hwi.c |  8 -
 drivers/scsi/pm8001/pm8001_sas.c | 71 ++--
 drivers/scsi/pm8001/pm8001_sas.h |  8 +
 drivers/scsi/pm8001/pm80xx_hwi.c | 36 
 4 files changed, 113 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index bc4a6f649ec9..db88a8e7ee0e 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -3209,10 +3209,16 @@ int pm8001_mpi_local_phy_ctl(struct pm8001_hba_info 
*pm8001_ha, void *piomb)
PM8001_MSG_DBG(pm8001_ha,
pm8001_printk("%x phy execute %x phy op failed!\n",
phy_id, phy_op));
-   } else
+   } else {
PM8001_MSG_DBG(pm8001_ha,
pm8001_printk("%x phy execute %x phy op success!\n",
phy_id, phy_op));
+   pm8001_ha->phy[phy_id].reset_success = true;
+   }
+   if (pm8001_ha->phy[phy_id].enable_completion) {
+   complete(pm8001_ha->phy[phy_id].enable_completion);
+   pm8001_ha->phy[phy_id].enable_completion = NULL;
+   }
pm8001_tag_free(pm8001_ha, tag);
return 0;
 }
diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index e80b0542a67f..60d5bec5c45e 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -1167,13 +1167,16 @@ int pm8001_abort_task(struct sas_task *task)
struct scsi_lun lun;
struct pm8001_device *pm8001_dev;
struct pm8001_tmf_task tmf_task;
-   int rc = TMF_RESP_FUNC_FAILED;
+   int rc = TMF_RESP_FUNC_FAILED, ret;
+   u32 phy_id;
+   struct sas_task_slow slow_task;
if (unlikely(!task || !task->lldd_task || !task->dev))
return TMF_RESP_FUNC_FAILED;
dev = task->dev;
pm8001_dev = dev->lldd_dev;
pm8001_ha = pm8001_find_ha_by_dev(dev);
device_id = pm8001_dev->device_id;
+   phy_id = pm8001_dev->attached_phy;
rc = pm8001_find_tag(task, );
if (rc == 0) {
pm8001_printk("no tag for task:%p\n", task);
@@ -1184,6 +1187,11 @@ int pm8001_abort_task(struct sas_task *task)
spin_unlock_irqrestore(>task_state_lock, flags);
return TMF_RESP_FUNC_COMPLETE;
}
+   task->task_state_flags |= SAS_TASK_STATE_ABORTED;
+   if (task->slow_task == NULL) {
+   init_completion(_task.completion);
+   task->slow_task = _task;
+   }
spin_unlock_irqrestore(>task_state_lock, flags);
if (task->task_proto & SAS_PROTOCOL_SSP) {
struct scsi_cmnd *cmnd = task->uldd_task;
@@ -1195,8 +1203,61 @@ int pm8001_abort_task(struct sas_task *task)
pm8001_dev->sas_device, 0, tag);
} else if (task->task_proto & SAS_PROTOCOL_SATA ||
task->task_proto & SAS_PROTOCOL_STP) {
-   rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev,
-   pm8001_dev->sas_device, 0, tag);
+   if (pm8001_ha->chip_id == chip_8006) {
+   DECLARE_COMPLETION_ONSTACK(completion_reset);
+   DECLARE_COMPLETION_ONSTACK(completion);
+   struct pm8001_phy *phy = pm8001_ha->phy + phy_id;
+   /* 1. Set Device state as Recovery*/
+   pm8001_dev->setds_completion = 
+   PM8001_CHIP_DISP->set_dev_state_req(pm8001_ha,
+   pm8001_dev, 0x03);
+   wait_for_completion();
+   /* 2. Send Phy Control Hard Reset */
+   reinit_completion();
+   phy->reset_success = false;
+   phy->enable_completion = 
+   phy->reset_completion = _reset;
+   ret = PM8001_CHIP_DISP->phy_ctl_req(pm8001_ha, phy_id,
+   PHY_HARD_RESET);
+   if (ret)
+   goto out;
+   PM8001_MSG_DBG(pm8001_ha,
+   pm8001_printk("Waiting for local phy ctl\n"));
+   wait_for_completion();
+   if (!phy->reset_success)
+   goto out;
+   /* 3. Wait for Port Reset complete / Port reset TMO*/
+   PM8001_MSG_DBG(pm8001_ha,
+   pm8001_printk("Waiting for Port 

[PATCH V2 5/9] pm80xx : cleanup in pm8001_abort_task function.

2017-09-13 Thread Viswas G
Signed-off-by: Deepak Ukey 
Signed-off-by: Viswas G 
---
 drivers/scsi/pm8001/pm8001_sas.c | 49 +++-
 1 file changed, 13 insertions(+), 36 deletions(-)

diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index ce584c31d36e..e80b0542a67f 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -1159,40 +1159,35 @@ int pm8001_query_task(struct sas_task *task)
 int pm8001_abort_task(struct sas_task *task)
 {
unsigned long flags;
-   u32 tag = 0xdeadbeef;
+   u32 tag;
u32 device_id;
struct domain_device *dev ;
-   struct pm8001_hba_info *pm8001_ha = NULL;
+   struct pm8001_hba_info *pm8001_ha;
struct pm8001_ccb_info *ccb;
struct scsi_lun lun;
struct pm8001_device *pm8001_dev;
struct pm8001_tmf_task tmf_task;
int rc = TMF_RESP_FUNC_FAILED;
if (unlikely(!task || !task->lldd_task || !task->dev))
-   return rc;
+   return TMF_RESP_FUNC_FAILED;
+   dev = task->dev;
+   pm8001_dev = dev->lldd_dev;
+   pm8001_ha = pm8001_find_ha_by_dev(dev);
+   device_id = pm8001_dev->device_id;
+   rc = pm8001_find_tag(task, );
+   if (rc == 0) {
+   pm8001_printk("no tag for task:%p\n", task);
+   return TMF_RESP_FUNC_FAILED;
+   }
spin_lock_irqsave(>task_state_lock, flags);
if (task->task_state_flags & SAS_TASK_STATE_DONE) {
spin_unlock_irqrestore(>task_state_lock, flags);
-   rc = TMF_RESP_FUNC_COMPLETE;
-   goto out;
+   return TMF_RESP_FUNC_COMPLETE;
}
spin_unlock_irqrestore(>task_state_lock, flags);
if (task->task_proto & SAS_PROTOCOL_SSP) {
struct scsi_cmnd *cmnd = task->uldd_task;
-   dev = task->dev;
-   ccb = task->lldd_task;
-   pm8001_dev = dev->lldd_dev;
-   pm8001_ha = pm8001_find_ha_by_dev(dev);
int_to_scsilun(cmnd->device->lun, );
-   rc = pm8001_find_tag(task, );
-   if (rc == 0) {
-   printk(KERN_INFO "No such tag in %s\n", __func__);
-   rc = TMF_RESP_FUNC_FAILED;
-   return rc;
-   }
-   device_id = pm8001_dev->device_id;
-   PM8001_EH_DBG(pm8001_ha,
-   pm8001_printk("abort io to deviceid= %d\n", device_id));
tmf_task.tmf = TMF_ABORT_TASK;
tmf_task.tag_of_task_to_be_managed = tag;
rc = pm8001_issue_ssp_tmf(dev, lun.scsi_lun, _task);
@@ -1200,28 +1195,10 @@ int pm8001_abort_task(struct sas_task *task)
pm8001_dev->sas_device, 0, tag);
} else if (task->task_proto & SAS_PROTOCOL_SATA ||
task->task_proto & SAS_PROTOCOL_STP) {
-   dev = task->dev;
-   pm8001_dev = dev->lldd_dev;
-   pm8001_ha = pm8001_find_ha_by_dev(dev);
-   rc = pm8001_find_tag(task, );
-   if (rc == 0) {
-   printk(KERN_INFO "No such tag in %s\n", __func__);
-   rc = TMF_RESP_FUNC_FAILED;
-   return rc;
-   }
rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev,
pm8001_dev->sas_device, 0, tag);
} else if (task->task_proto & SAS_PROTOCOL_SMP) {
/* SMP */
-   dev = task->dev;
-   pm8001_dev = dev->lldd_dev;
-   pm8001_ha = pm8001_find_ha_by_dev(dev);
-   rc = pm8001_find_tag(task, );
-   if (rc == 0) {
-   printk(KERN_INFO "No such tag in %s\n", __func__);
-   rc = TMF_RESP_FUNC_FAILED;
-   return rc;
-   }
rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev,
pm8001_dev->sas_device, 0, tag);
 
-- 
2.12.3



[PATCH V3 3/3] scsi: Align queue to ARCH_DMA_MINALIGN in non-coherent DMA mode

2017-09-13 Thread Huacai Chen
In non-coherent DMA mode, kernel uses cache flushing operations to
maintain I/O coherency, so scsi's block queue should be aligned to
ARCH_DMA_MINALIGN.

Cc: sta...@vger.kernel.org
Signed-off-by: Huacai Chen 
---
 drivers/scsi/scsi_lib.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 9cf6a80..79433ad 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2132,11 +2132,14 @@ void __scsi_init_queue(struct Scsi_Host *shost, struct 
request_queue *q)
q->limits.cluster = 0;
 
/*
-* set a reasonable default alignment on word boundaries: the
-* host and device may alter it using
+* set a reasonable default alignment on word/cacheline boundaries:
+* the host and device may alter it using
 * blk_queue_update_dma_alignment() later.
 */
-   blk_queue_dma_alignment(q, 0x03);
+   if (plat_device_is_coherent(dev))
+   blk_queue_dma_alignment(q, 0x04 - 1);
+   else
+   blk_queue_dma_alignment(q, dma_get_cache_alignment() - 1);
 }
 EXPORT_SYMBOL_GPL(__scsi_init_queue);
 
-- 
2.7.0





[bug report] [SCSI] lpfc: NPIV: add NPIV support on top of SLI-3

2017-09-13 Thread Dan Carpenter
[ Really old patch... :/ - dan ]

Hello James Smart,

The patch 92d7f7b0cde3: "[SCSI] lpfc: NPIV: add NPIV support on top
of SLI-3" from Jun 17, 2007, leads to the following static checker
warning:

drivers/scsi/lpfc/lpfc_els.c:6148 lpfc_els_rcv_rscn()
error: buffer underflow 'vport->fc_rscn_id_list'

drivers/scsi/lpfc/lpfc_els.c
  6128  /* Indicate we are walking fc_rscn_id_list on this vport */
  6129  vport->fc_rscn_flush = 1;
  6130  spin_unlock_irq(shost->host_lock);
  6131  /* Get the array count after successfully have the token */
  6132  rscn_cnt = vport->fc_rscn_id_cnt;

We set rscn_cnt here.  rscn_cnt is an int.  Smatch thinks
vport->fc_rscn_id_cnt can be higher than INT_MAX which is not actually
possible but hopefully explains the warning message.  More analysis
below.

  6133  /* If we are already processing an RSCN, save the received
  6134   * RSCN payload buffer, cmdiocb->context2 to process later.
  6135   */
  6136  if (vport->fc_flag & (FC_RSCN_MODE | FC_NDISC_ACTIVE)) {
  6137  lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
  6138  "RCV RSCN defer:  did:x%x/ste:x%x flg:x%x",
  6139  ndlp->nlp_DID, vport->port_state, 
ndlp->nlp_flag);
  6140  
  6141  spin_lock_irq(shost->host_lock);
  6142  vport->fc_flag |= FC_RSCN_DEFERRED;
  6143  if ((rscn_cnt < FC_MAX_HOLD_RSCN) &&
^
On this path we check if it's invalid.

  6144  !(vport->fc_flag & FC_RSCN_DISCOVERY)) {
  6145  vport->fc_flag |= FC_RSCN_MODE;
  6146  spin_unlock_irq(shost->host_lock);
  6147  if (rscn_cnt) {
  6148  cmd = 
vport->fc_rscn_id_list[rscn_cnt-1]->virt;
  6149  length = be32_to_cpu(*cmd & 
~ELS_CMD_MASK);
  6150  }
  6151  if ((rscn_cnt) &&
  6152  (payload_len + length <= LPFC_BPL_SIZE)) {
  6153  *cmd &= ELS_CMD_MASK;
  6154  *cmd |= cpu_to_be32(payload_len + 
length);
  6155  memcpy(((uint8_t *)cmd) + length, lp,
  6156 payload_len);
  6157  } else {
  6158  vport->fc_rscn_id_list[rscn_cnt] = pcmd;
  6159  vport->fc_rscn_id_cnt++;
^^^
It gets incremented here

  6160  /* If we zero, cmdiocb->context2, the 
calling
  6161   * routine will not try to free it.
  6162   */
  6163  cmdiocb->context2 = NULL;
  6164  }
  6165  /* Deferred RSCN */
  6166  lpfc_printf_vlog(vport, KERN_INFO, 
LOG_DISCOVERY,
  6167   "0235 Deferred RSCN "
  6168   "Data: x%x x%x x%x\n",
  6169   vport->fc_rscn_id_cnt, 
vport->fc_flag,
  6170   vport->port_state);
  6171  } else {
  6172  vport->fc_flag |= FC_RSCN_DISCOVERY;
  6173  spin_unlock_irq(shost->host_lock);
  6174  /* ReDiscovery RSCN */
  6175  lpfc_printf_vlog(vport, KERN_INFO, 
LOG_DISCOVERY,
  6176   "0234 ReDiscovery RSCN "
  6177   "Data: x%x x%x x%x\n",
  6178   vport->fc_rscn_id_cnt, 
vport->fc_flag,
  6179   vport->port_state);
  6180  }
  6181  /* Indicate we are done walking fc_rscn_id_list on this 
vport */
  6182  vport->fc_rscn_flush = 0;
  6183  /* Send back ACC */
  6184  lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, 
NULL);
  6185  /* send RECOVERY event for ALL nodes that match RSCN 
payload */
  6186  lpfc_rscn_recovery_check(vport);
  6187  spin_lock_irq(shost->host_lock);
  6188  vport->fc_flag &= ~FC_RSCN_DEFERRED;
  6189  spin_unlock_irq(shost->host_lock);
  6190  return 0;
  6191  }
  6192  lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
  6193  "RCV RSCN:did:x%x/ste:x%x flg:x%x",
  6194  

[PATCH] scsi: aacraid: error: testing array offset 'bus' after use

2017-09-13 Thread Nikola Pajkovsky
Fix possible indexing array of bound for >hba_map[bus][cid],
where bus and cid boundary check happens later.

Fixes: 0d643ff3c353 ("scsi: aacraid: use aac_tmf_callback for reset fib")
Signed-off-by: Nikola Pajkovsky 
---
 drivers/scsi/aacraid/linit.c | 20 
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 87cc4a93e637..62beb2596466 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -906,12 +906,14 @@ static int aac_eh_dev_reset(struct scsi_cmnd *cmd)
 
bus = aac_logical_to_phys(scmd_channel(cmd));
cid = scmd_id(cmd);
-   info = >hba_map[bus][cid];
-   if (bus >= AAC_MAX_BUSES || cid >= AAC_MAX_TARGETS ||
-   info->devtype != AAC_DEVTYPE_NATIVE_RAW)
+
+   if (bus >= AAC_MAX_BUSES || cid >= AAC_MAX_TARGETS)
return FAILED;
 
-   if (info->reset_state > 0)
+   info = >hba_map[bus][cid];
+
+   if (info->devtype != AAC_DEVTYPE_NATIVE_RAW &&
+   info->reset_state > 0)
return FAILED;
 
pr_err("%s: Host adapter reset request. SCSI hang ?\n",
@@ -962,12 +964,14 @@ static int aac_eh_target_reset(struct scsi_cmnd *cmd)
 
bus = aac_logical_to_phys(scmd_channel(cmd));
cid = scmd_id(cmd);
-   info = >hba_map[bus][cid];
-   if (bus >= AAC_MAX_BUSES || cid >= AAC_MAX_TARGETS ||
-   info->devtype != AAC_DEVTYPE_NATIVE_RAW)
+
+   if (bus >= AAC_MAX_BUSES || cid >= AAC_MAX_TARGETS)
return FAILED;
 
-   if (info->reset_state > 0)
+   info = >hba_map[bus][cid];
+
+   if (info->devtype != AAC_DEVTYPE_NATIVE_RAW &&
+   info->reset_state > 0)
return FAILED;
 
pr_err("%s: Host adapter reset request. SCSI hang ?\n",
-- 
2.13.5



[PATCH 03/10] driver:gpu: return -ENOMEM on allocation failure.

2017-09-13 Thread Allen Pais
Signed-off-by: Allen Pais 
---
 drivers/gpu/drm/gma500/mid_bios.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/gma500/mid_bios.c 
b/drivers/gpu/drm/gma500/mid_bios.c
index d75ecb3..1fa1633 100644
--- a/drivers/gpu/drm/gma500/mid_bios.c
+++ b/drivers/gpu/drm/gma500/mid_bios.c
@@ -237,7 +237,7 @@ static int mid_get_vbt_data_r10(struct drm_psb_private 
*dev_priv, u32 addr)
 
gct = kmalloc(sizeof(*gct) * vbt.panel_count, GFP_KERNEL);
if (!gct)
-   return -1;
+   return -ENOMEM;
 
gct_virtual = ioremap(addr + sizeof(vbt),
sizeof(*gct) * vbt.panel_count);
-- 
2.7.4



[PATCH 02/10] drivers:crypto: return -ENOMEM on allocation failure.

2017-09-13 Thread Allen Pais
Signed-off-by: Allen Pais 
---
 drivers/crypto/omap-aes-gcm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/omap-aes-gcm.c b/drivers/crypto/omap-aes-gcm.c
index 7d4f8a4..2542224 100644
--- a/drivers/crypto/omap-aes-gcm.c
+++ b/drivers/crypto/omap-aes-gcm.c
@@ -186,7 +186,7 @@ static int do_encrypt_iv(struct aead_request *req, u32 
*tag, u32 *iv)
sk_req = skcipher_request_alloc(ctx->ctr, GFP_KERNEL);
if (!sk_req) {
pr_err("skcipher: Failed to allocate request\n");
-   return -1;
+   return -ENOMEM;
}
 
init_completion();
-- 
2.7.4



[PATCH 05/10] drivers:net: return -ENOMEM on allocation failure.

2017-09-13 Thread Allen Pais
Signed-off-by: Allen Pais 
---
 drivers/net/bonding/bond_alb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index c02cc81..89df377 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -864,7 +864,7 @@ static int rlb_initialize(struct bonding *bond)
 
new_hashtbl = kmalloc(size, GFP_KERNEL);
if (!new_hashtbl)
-   return -1;
+   return -ENOMEM;
 
spin_lock_bh(>mode_lock);
 
-- 
2.7.4



[PATCH 06/10] drivers:ethernet: return -ENOMEM on allocation failure.

2017-09-13 Thread Allen Pais
Signed-off-by: Allen Pais 
---
 drivers/net/ethernet/sun/cassini.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/sun/cassini.c 
b/drivers/net/ethernet/sun/cassini.c
index 382993c..fc0ea3a 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -3984,7 +3984,7 @@ static inline int cas_alloc_rx_desc(struct cas *cp, int 
ring)
size = RX_DESC_RINGN_SIZE(ring);
for (i = 0; i < size; i++) {
if ((page[i] = cas_page_alloc(cp, GFP_KERNEL)) == NULL)
-   return -1;
+   return -ENOMEM;
}
return 0;
 }
-- 
2.7.4



[PATCH 04/10] drivers:mpt: return -ENOMEM on allocation failure.

2017-09-13 Thread Allen Pais
Signed-off-by: Allen Pais 
---
 drivers/message/fusion/mptbase.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 84eab28..7920b2b 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -4328,15 +4328,15 @@ initChainBuffers(MPT_ADAPTER *ioc)
if (ioc->ReqToChain == NULL) {
sz = ioc->req_depth * sizeof(int);
mem = kmalloc(sz, GFP_ATOMIC);
-   if (mem == NULL)
-   return -1;
+   if (!mem)
+   return -ENOMEM;
 
ioc->ReqToChain = (int *) mem;
dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ReqToChain alloc  @ 
%p, sz=%d bytes\n",
ioc->name, mem, sz));
mem = kmalloc(sz, GFP_ATOMIC);
-   if (mem == NULL)
-   return -1;
+   if (!mem)
+   return -ENOMEM;
 
ioc->RequestNB = (int *) mem;
dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "RequestNB alloc  @ 
%p, sz=%d bytes\n",
@@ -4402,8 +4402,8 @@ initChainBuffers(MPT_ADAPTER *ioc)
sz = num_chain * sizeof(int);
if (ioc->ChainToChain == NULL) {
mem = kmalloc(sz, GFP_ATOMIC);
-   if (mem == NULL)
-   return -1;
+   if (!mem)
+   return -ENOMEM;
 
ioc->ChainToChain = (int *) mem;
dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ChainToChain alloc @ 
%p, sz=%d bytes\n",
-- 
2.7.4



[PATCH 08/10] driver:cxgbit: return -NOMEM on allocation failure.

2017-09-13 Thread Allen Pais
Signed-off-by: Allen Pais 
---
 drivers/target/iscsi/cxgbit/cxgbit_target.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/target/iscsi/cxgbit/cxgbit_target.c 
b/drivers/target/iscsi/cxgbit/cxgbit_target.c
index 514986b..47127d6 100644
--- a/drivers/target/iscsi/cxgbit/cxgbit_target.c
+++ b/drivers/target/iscsi/cxgbit/cxgbit_target.c
@@ -399,7 +399,7 @@ cxgbit_map_skb(struct iscsi_cmd *cmd, struct sk_buff *skb, 
u32 data_offset,
if (padding) {
page = alloc_page(GFP_KERNEL | __GFP_ZERO);
if (!page)
-   return -1;
+   return -ENOMEM;
skb_fill_page_desc(skb, i, page, 0, padding);
skb->data_len += padding;
skb->len += padding;
-- 
2.7.4



[PATCH 07/10] driver:megaraid: return -ENOMEM on allocation failure.

2017-09-13 Thread Allen Pais
Signed-off-by: Allen Pais 
---
 drivers/scsi/megaraid/megaraid_mbox.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_mbox.c 
b/drivers/scsi/megaraid/megaraid_mbox.c
index ec3c438..b09a0a6 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -724,8 +724,8 @@ megaraid_init_mbox(adapter_t *adapter)
 * controllers
 */
raid_dev = kzalloc(sizeof(mraid_device_t), GFP_KERNEL);
-   if (raid_dev == NULL) return -1;
-
+   if (!raid_dev)
+   return -ENOMEM;
 
/*
 * Attach the adapter soft state to raid device soft state
-- 
2.7.4



[PATCH 10/10] fs:btrfs: return -ENOMEM on allocation failure.

2017-09-13 Thread Allen Pais
Signed-off-by: Allen Pais 
---
 fs/btrfs/check-integrity.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 7d5a9b5..efa4c23 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -2913,7 +2913,7 @@ int btrfsic_mount(struct btrfs_fs_info *fs_info,
state = kvzalloc(sizeof(*state), GFP_KERNEL);
if (!state) {
pr_info("btrfs check-integrity: allocation failed!\n");
-   return -1;
+   return -ENOMEM;
}
 
if (!btrfsic_is_initialized) {
-- 
2.7.4



[PATCH 09/10] driver:video: return -ENOMEM on allocation failure.

2017-09-13 Thread Allen Pais
Signed-off-by: Allen Pais 
---
 drivers/video/fbdev/matrox/matroxfb_base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/matrox/matroxfb_base.c 
b/drivers/video/fbdev/matrox/matroxfb_base.c
index f6a0b9a..5cd238d 100644
--- a/drivers/video/fbdev/matrox/matroxfb_base.c
+++ b/drivers/video/fbdev/matrox/matroxfb_base.c
@@ -2058,7 +2058,7 @@ static int matroxfb_probe(struct pci_dev* pdev, const 
struct pci_device_id* dumm
 
minfo = kzalloc(sizeof(*minfo), GFP_KERNEL);
if (!minfo)
-   return -1;
+   return -ENOMEM;
 
minfo->pcidev = pdev;
minfo->dead = 0;
-- 
2.7.4



[PATCH 01/10] arch:powerpc: return -ENOMEM on failed allocation

2017-09-13 Thread Allen Pais
Signed-off-by: Allen Pais 
---
 arch/powerpc/platforms/cell/spider-pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/cell/spider-pci.c 
b/arch/powerpc/platforms/cell/spider-pci.c
index d1e61e2..82aa3f7 100644
--- a/arch/powerpc/platforms/cell/spider-pci.c
+++ b/arch/powerpc/platforms/cell/spider-pci.c
@@ -106,7 +106,7 @@ static int __init spiderpci_pci_setup_chip(struct 
pci_controller *phb,
dummy_page_va = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (!dummy_page_va) {
pr_err("SPIDERPCI-IOWA:Alloc dummy_page_va failed.\n");
-   return -1;
+   return -ENOMEM;
}
 
dummy_page_da = dma_map_single(phb->parent, dummy_page_va,
@@ -137,7 +137,7 @@ int __init spiderpci_iowa_init(struct iowa_bus *bus, void 
*data)
if (!priv) {
pr_err("SPIDERPCI-IOWA:"
   "Can't allocate struct spiderpci_iowa_private");
-   return -1;
+   return -ENOMEM;
}
 
if (of_address_to_resource(np, 0, )) {
-- 
2.7.4



Re: [PATCH v4 00/14] mpt3sas driver NVMe support:

2017-09-13 Thread Suganath Prabu Subramani
Hi Martin,

Is there any update on the submitted mpt3sas patches.

Thanks,
Suganath Prabu S

On Fri, Sep 1, 2017 at 2:09 PM, Suganath Prabu Subramani
 wrote:
> Hi Martin,
>
> On Fri, Sep 1, 2017 at 8:52 AM, Martin K. Petersen
>  wrote:
>>
>> Hi Suganath,
>>
>>> Let me explain - NVME device fast path is possible in two ways.  IEEE
>>> SGL and PRP SGL. Due to h/w constraint we choose IEEE SGL only for
>>> smaller IO size.  Both above is true h/w Fast Path and no firmware
>>> involvement.
>>
>>> Agree with you. We are planning to see if we can keep only simple Fast
>>> Path using only PRP.
>>
>> That would be great, thank you!
>>
>>> Currently there is no performance issue for UNMAP translation in FW.
>>
>> Good!
>>
 And yet patch 4 circumvents that statement by adding support for
 encapsulated commands to bypass the FW translation...
>>>
>>> This path is not due to performance reason. User wants to interact
>>> with NVME drive in native NVME command for management.
>>
>> Patch 4 states:
>>
>> "This encapsulated NVMe command is used by applications to send direct
>> NVMe commands to NVMe drives or for handling unmap where the translation
>> at controller/firmware level is having performance issues."
>>
>> --
>
> The statement in description of patch 4 is added by mistake, We ll
> correct the description and re sending that.
>
>> Martin K. Petersen  Oracle Linux Engineering
>
> Thanks,
> Suganath Prabu S