RE: [PATCH 0/5] blk-mq/scsi-mq: support global tags & introduce force_blk_mq

2018-02-13 Thread Kashyap Desai
> -Original Message-
> From: Ming Lei [mailto:ming@redhat.com]
> Sent: Tuesday, February 13, 2018 6:11 AM
> To: Kashyap Desai
> Cc: Hannes Reinecke; Jens Axboe; linux-bl...@vger.kernel.org; Christoph
> Hellwig; Mike Snitzer; linux-scsi@vger.kernel.org; Arun Easi; Omar
Sandoval;
> Martin K . Petersen; James Bottomley; Christoph Hellwig; Don Brace;
Peter
> Rivera; Paolo Bonzini; Laurence Oberman
> Subject: Re: [PATCH 0/5] blk-mq/scsi-mq: support global tags & introduce
> force_blk_mq
>
> Hi Kashyap,
>
> On Tue, Feb 13, 2018 at 12:05:14AM +0530, Kashyap Desai wrote:
> > > -Original Message-
> > > From: Ming Lei [mailto:ming@redhat.com]
> > > Sent: Sunday, February 11, 2018 11:01 AM
> > > To: Kashyap Desai
> > > Cc: Hannes Reinecke; Jens Axboe; linux-bl...@vger.kernel.org;
> > > Christoph Hellwig; Mike Snitzer; linux-scsi@vger.kernel.org; Arun
> > > Easi; Omar
> > Sandoval;
> > > Martin K . Petersen; James Bottomley; Christoph Hellwig; Don Brace;
> > Peter
> > > Rivera; Paolo Bonzini; Laurence Oberman
> > > Subject: Re: [PATCH 0/5] blk-mq/scsi-mq: support global tags &
> > > introduce force_blk_mq
> > >
> > > On Sat, Feb 10, 2018 at 09:00:57AM +0800, Ming Lei wrote:
> > > > Hi Kashyap,
> > > >
> > > > On Fri, Feb 09, 2018 at 02:12:16PM +0530, Kashyap Desai wrote:
> > > > > > -Original Message-
> > > > > > From: Ming Lei [mailto:ming@redhat.com]
> > > > > > Sent: Friday, February 9, 2018 11:01 AM
> > > > > > To: Kashyap Desai
> > > > > > Cc: Hannes Reinecke; Jens Axboe; linux-bl...@vger.kernel.org;
> > > > > > Christoph Hellwig; Mike Snitzer; linux-scsi@vger.kernel.org;
> > > > > > Arun Easi; Omar
> > > > > Sandoval;
> > > > > > Martin K . Petersen; James Bottomley; Christoph Hellwig; Don
> > > > > > Brace;
> > > > > Peter
> > > > > > Rivera; Paolo Bonzini; Laurence Oberman
> > > > > > Subject: Re: [PATCH 0/5] blk-mq/scsi-mq: support global tags &
> > > > > > introduce force_blk_mq
> > > > > >
> > > > > > On Fri, Feb 09, 2018 at 10:28:23AM +0530, Kashyap Desai wrote:
> > > > > > > > -Original Message-
> > > > > > > > From: Ming Lei [mailto:ming@redhat.com]
> > > > > > > > Sent: Thursday, February 8, 2018 10:23 PM
> > > > > > > > To: Hannes Reinecke
> > > > > > > > Cc: Kashyap Desai; Jens Axboe;
> > > > > > > > linux-bl...@vger.kernel.org; Christoph Hellwig; Mike
> > > > > > > > Snitzer; linux-scsi@vger.kernel.org; Arun Easi; Omar
> > > > > > > Sandoval;
> > > > > > > > Martin K . Petersen; James Bottomley; Christoph Hellwig;
> > > > > > > > Don Brace;
> > > > > > > Peter
> > > > > > > > Rivera; Paolo Bonzini; Laurence Oberman
> > > > > > > > Subject: Re: [PATCH 0/5] blk-mq/scsi-mq: support global
> > > > > > > > tags & introduce force_blk_mq
> > > > > > > >
> > > > > > > > On Thu, Feb 08, 2018 at 08:00:29AM +0100, Hannes Reinecke
> > wrote:
> > > > > > > > > On 02/07/2018 03:14 PM, Kashyap Desai wrote:
> > > > > > > > > >> -Original Message-
> > > > > > > > > >> From: Ming Lei [mailto:ming@redhat.com]
> > > > > > > > > >> Sent: Wednesday, February 7, 2018 5:53 PM
> > > > > > > > > >> To: Hannes Reinecke
> > > > > > > > > >> Cc: Kashyap Desai; Jens Axboe;
> > > > > > > > > >> linux-bl...@vger.kernel.org; Christoph Hellwig; Mike
> > > > > > > > > >> Snitzer; linux-scsi@vger.kernel.org; Arun Easi; Omar
> > > > > > > > > > Sandoval;
> > > > > > > > > >> Martin K . Petersen; James Bottomley; Christoph
> > > > > > > > > >> Hellwig; Don Brace;
> > > > > > > > > > Peter
> > > > > > > > > >> Rivera; Paolo Bonzini; Laurence Oberman
> > > > > > > > > >> Subject: Re: [PATCH 0/5] blk-mq/scsi-mq: support
> > > > > > > > > >> global tags & introduce force_blk_mq
> > > > > > > > > >>
> > > > > > > > > >> On Wed, Feb 07, 2018 at 07:50:21AM +0100, Hannes
> > > > > > > > > >> Reinecke
> > > > > wrote:
> > > > > > > > > >>> Hi all,
> > > > > > > > > >>>
> > > > > > > > > >>> [ .. ]
> > > > > > > > > >
> > > > > > > > > > Could you share us your patch for enabling
> > > > > > > > > > global_tags/MQ on
> > > > > > > > >  megaraid_sas
> > > > > > > > > > so that I can reproduce your test?
> > > > > > > > > >
> > > > > > > > > >> See below perf top data. "bt_iter" is consuming 4
> > > > > > > > > >> times more
> > > > > > > CPU.
> > > > > > > > > >
> > > > > > > > > > Could you share us what the IOPS/CPU utilization
> > > > > > > > > > effect is after
> > > > > > > > >  applying the
> > > > > > > > > > patch V2? And your test script?
> > > > > > > > >  Regarding CPU utilization, I need to test one more
> > time.
> > > > > > > > >  Currently system is in used.
> > > > > > > > > 
> > > > > > > > >  I run below fio test on total 24 SSDs expander
> > attached.
> > > > > > > > > 
> > > > > > > > >  numactl -N 1 fio jbod.fio --rw=randread
> > > > > > > > >  --iodepth=64 --bs=4k --ioengine=libaio
> > > > > > > > >  --rw=randread
> > > > > > > > > 
> > > > > > > > >  Performance dropped from 

Re: [PATCH 2/2] scsi_debug: reset injection flags for every_nth > 0

2018-02-13 Thread Martin K. Petersen

Martin,

> If every_nth > 0, the injection flags must be reset for commands
> that aren't supposed to fail (i.e. that aren't "nth"). Otherwise,
> commands will continue to fail, like in the every_nth < 0 case.

Applied to 4.17/scsi-queue.

Please rebase patch 1/2. Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] Reduce number of scsi_test_unit_ready() retries

2018-02-13 Thread Martin K. Petersen

Bart,

> Make scsi_test_unit_ready() send at most as many TURs as specified
> in the 'retries' argument instead of retries * (retries + 1) / 2.

Applied to 4.17/scsi-queue, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] Move the eh_deadline module parameter definition to the top of hosts.c

2018-02-13 Thread Martin K. Petersen

Bart,

> The eh_deadline definition occurs in the middle of the code for
> releasing a host. Avoid splitting the host release code by moving
> the definition of the eh_deadline parameter to the top of the
> hosts.c source file.

Applied to 4.17/scsi-queue. Thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scmd_eh_abort_handler(): Add a comment

2018-02-13 Thread Martin K. Petersen

Bart,

> After the patch that introduced this function was posted on the
> linux-scsi mailing list an explanation was posted why this patch
> is correct. Since that explanation contains important information,
> add a summary of it above the code that explanation applies to.
> See also http://www.spinics.net/lists/linux-scsi/msg106326.html.

Applied to 4.17/scsi-queue. Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 0/3] Use sgl_alloc_order() and sgl_free_order()

2018-02-13 Thread Martin K. Petersen

Bart,

> In kernel v4.16-rc1 the functions sgl_alloc_order() and
> sgl_free_order() were introduced in lib/scatterlist.c. This patch
> series introduces these functions in the ipr and pmcraid SCSI
> drivers. Please consider these patches for kernel v4.17.

Applied to 4.17/scsi-queue, thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] qla4xxx: skip error recovery in case of register disconnect.

2018-02-13 Thread Martin K. Petersen

Manish,

> A system crashes when continuously removing/re-adding the storage
> controller.

Applied to 4.16/scsi-fixes. Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] megaraid_sas: Do not use 32-bit atomic request descriptor for Ventura controllers

2018-02-13 Thread Martin K. Petersen

Shivasharan,

> Sending I/O through 32 bit descriptors to Ventura series of controller
> results in IO timeout on certain conditions.

Please address Tomas' and Hannes' comments and repost these two.

Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH v2] scsi_debug: implement IMMED bit

2018-02-13 Thread Martin K. Petersen

Doug,

> The Start Stop Unit (SSU) command takes in the order of a second to
> complete on some SAS SSDs and longer on hard disks. Synchronize Cache
> (SC) can also take some time. Both commands have an IMMED bit in their
> cdbs for those apps that don't want to wait. This patch introduces a
> long delay for those commands when the IMMED bit is clear.  Since SC
> is a media access command then when the fake_rw option is active, its
> cdb processing is skipped and it returns immediately. The SSU command
> is not altered by the setting of the fake_rw option. These actions are
> not changed by this patch.

Applied to 4.17/scsi-queue. Thank you!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] scsi: scsi_debug: Fix pointer stying issues

2018-02-13 Thread Martin K. Petersen

John,

> Pointer styling issues exposed by checkpatch.pl in scsi_debug.c:
>
>ERROR: "foo * bar" should be "foo *bar"
>
> Fixed 37 total errors reported.

Applied to 4.17/scsi-queue. Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [bug report] scsi: myrs: Add Mylex RAID controller (SCSI interface)

2018-02-13 Thread Martin K. Petersen

Hannes,

> The patch 8a8606895947: "scsi: myrs: Add Mylex RAID controller (SCSI
> interface)" from Jan 24, 2018, leads to the following static checker
> warning:

I dropped the two Mylex patches from 4.17/scsi-queue for now. Please fix
the issues reported and repost.

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: Fwd: All scsi_debug devices in the scsi_debug driver share the same RAM space

2018-02-13 Thread Martin K. Petersen

Lukas,

> I like the idea to have an option to separate the memory area for
> different LUNs, while keeping the current behavior as default.

As the name implies, scsi_debug is mostly a tool for debugging the SCSI
stack.

If you care about storing data, why not simply use target in loopback
mode?

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH] qla2xxx: Fix NULL pointer crash due to active timer for ABTS

2018-02-13 Thread Madhani, Himanshu
Hi John, 

> On Feb 13, 2018, at 2:54 AM, John Garry  wrote:
> 
> On 12/02/2018 18:28, Himanshu Madhani wrote:
>> This patch fixes NULL pointer crash due to active timer running
>> for abort IOCB.
>> 
>>> From crash dump analysis it was discoverd that get_next_timer_interrupt()
>> encountered a corrupted entry on the timer list.
>> 
>> #9 [95e1f6f0fd40] page_fault at 914fe8f8
>>[exception RIP: get_next_timer_interrupt+440]
>>RIP: 90ea3088  RSP: 95e1f6f0fdf0  RFLAGS: 00010013
>>RAX: 95e1f6451028  RBX: 000218e2389e5f40  RCX: 0001232ad600
>>RDX: 0001  RSI: 95e1f6f0fdf0  RDI: 01232ad6
>>RBP: 95e1f6f0fe40   R8: 95e1f6451188   R9: 0001
>>R10: 0016  R11: 0016  R12: 0001232ad5f6
>>R13: 95e1f645  R14: 95e1f6f0fdf8  R15: 95e1f6f0fe10
>>ORIG_RAX:   CS: 0010  SS: 0018
>> 
>> Looking at the assembly of get_next_timer_interrupt(), address came
>> from %r8 (95e1f6451188) which is pointing to list_head with single
>> entry at 95e5ff621178.
>> 
>> 0x90ea307a :  mov(%r8),%rdx
>> 0x90ea307d :  cmp%r8,%rdx
>> 0x90ea3080 :  je 
>> 0x90ea30a7 
>> 0x90ea3082 :  nopw   
>> 0x0(%rax,%rax,1)
>> 0x90ea3088 :  testb  
>> $0x1,0x18(%rdx)
>> 
>> crash> rd 95e1f6451188 10
>> 95e1f6451188:  95e5ff621178 95e5ff621178   x.b.x.b.
>> 95e1f6451198:  95e1f6451198 95e1f6451198   ..E...E.
>> 95e1f64511a8:  95e1f64511a8 95e1f64511a8   ..E...E.
>> 95e1f64511b8:  95e77cf509a0 95e77cf509a0   ...|...|
>> 95e1f64511c8:  95e1f64511c8 95e1f64511c8   ..E...E.
>> 
>> crash> rd 95e5ff621178 10
>> 95e5ff621178:  0001 95e15936aa00   ..6Y
>> 95e5ff621188:      
>> 95e5ff621198:  00a0 0010   
>> 95e5ff6211a8:  95e5ff621198 000c   ..b.
>> 95e5ff6211b8:  0f58 95e751f8d720   X... ..Q
>> 
>> 95e5ff621178 belongs to freed mempool object at 95e5ff621080.
>> 
>> CACHENAME OBJSIZE  ALLOCATED TOTAL  SLABS  
>> SSIZE
>> 95dc7fd74d00 mnt_cache384  19785 24948594
>> 16k
>>   SLAB  MEMORYNODE  TOTAL  ALLOCATED  FREE
>>   dc5dabfd8800  95e5ff62 1 42 2913
>>   FREE / [ALLOCATED]
>>95e5ff621080  (cpu 6 cache)
>> 
>> Examining the contents of that memory reveals a pointer to a constant
>> string in the driver, "abort\0", which is set by qla24xx_async_abort_cmd().
>> 
>> crash> rd c059277c 20
>> c059277c:  6e490074726f6261 0074707572726574   abort.Interrupt.
>> c059278c:  00676e696c6c6f50 6920726576697244   Polling.Driver i
>> c059279c:  646f6d207325206e 6974736554000a65   n %s mode..Testi
>> c05927ac:  636976656420676e 786c252074612065   ng device at %lx
>> c05927bc:  6b63656843000a2e 646f727020676e69   ...Checking prod
>> c05927cc:  6f20444920746375 0a2e706968632066   uct ID of chip..
>> c05927dc:  5120646e756f4600 204130303232414c   .Found QLA2200A
>> c05927ec:  43000a2e70696843 20676e696b636568   Chip...Checking
>> c05927fc:  65786f626c69616d 6c636e69000a2e73   mailboxes...incl
>> c059280c:  756e696c2f656475 616d2d616d642f78   ude/linux/dma-ma
>> 
>> crash> struct -ox srb_iocb
>> struct srb_iocb {
>>   union {
>>   struct {...} logio;
>>   struct {...} els_logo;
>>   struct {...} tmf;
>>   struct {...} fxiocb;
>>   struct {...} abt;
>>   struct ct_arg ctarg;
>>   struct {...} mbx;
>>   struct {...} nack;
>>[0x0 ] } u;
>>[0xb8] struct timer_list timer;
>>[0x108] void (*timeout)(void *);
>> }
>> SIZE: 0x110
>> 
>> crash> ! bc
>> ibase=16
>> obase=10
>> B8+40
>> F8
>> 
>> The object is a srb_t, and at offset 0xf8 within that structure
>> (i.e. 95e5ff621080 + f8 -> 95e5ff621178) is a struct timer_list.
>> 
>> Cc:  #4.4+
>> Signed-off-by: Himanshu Madhani 
>> ---
>> Hi Martin,
>> 
>> This patch addresses crash due to NULL pointer access because driver
>> left active timer running for abort IOCB.
>> 
>> Please apply this patch to 4.16/scsi-fixes at your earliest convenience.
>> 
>> Thanks,
>> Himanshu
>> ---
>> drivers/scsi/qla2xxx/qla_init.c | 1 +
>> 1 file changed, 1 insertion(+)
>> 
>> diff --git a/drivers/scsi/qla2xxx/qla_init.c 
>> 

[PATCH v3 03/13] lpfc: Add SLI-4 if_type=6 support to the code base

2018-02-13 Thread James Smart
New hardware supports a SLI-4 interface, but with a new if_type
variant of 6.

If_type=6 has a different PCI BAR map, separate EQ/CQ doorbells,
and some changes in doorbell formats.

Add the changes for the if_type into headers, adapter initialization
and control flows. Add new eq and cq handlers.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/lpfc/lpfc_bsg.c  |   4 +-
 drivers/scsi/lpfc/lpfc_hw4.h  |  54 ++-
 drivers/scsi/lpfc/lpfc_init.c | 120 +++---
 drivers/scsi/lpfc/lpfc_sli.c  | 120 --
 drivers/scsi/lpfc/lpfc_sli4.h |   3 ++
 5 files changed, 275 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c
index d89816222b23..8b33b652226b 100644
--- a/drivers/scsi/lpfc/lpfc_bsg.c
+++ b/drivers/scsi/lpfc/lpfc_bsg.c
@@ -3867,7 +3867,7 @@ lpfc_bsg_sli_cfg_read_cmd_ext(struct lpfc_hba *phba, 
struct bsg_job *job,
"ext_buf_cnt:%d\n", ext_buf_cnt);
} else {
/* sanity check on interface type for support */
-   if (bf_get(lpfc_sli_intf_if_type, >sli4_hba.sli_intf) !=
+   if (bf_get(lpfc_sli_intf_if_type, >sli4_hba.sli_intf) <
LPFC_SLI_INTF_IF_TYPE_2) {
rc = -ENODEV;
goto job_error;
@@ -4053,7 +4053,7 @@ lpfc_bsg_sli_cfg_write_cmd_ext(struct lpfc_hba *phba, 
struct bsg_job *job,
"ext_buf_cnt:%d\n", ext_buf_cnt);
} else {
/* sanity check on interface type for support */
-   if (bf_get(lpfc_sli_intf_if_type, >sli4_hba.sli_intf) !=
+   if (bf_get(lpfc_sli_intf_if_type, >sli4_hba.sli_intf) <
LPFC_SLI_INTF_IF_TYPE_2)
return -ENODEV;
/* nemb_tp == nemb_hbd */
diff --git a/drivers/scsi/lpfc/lpfc_hw4.h b/drivers/scsi/lpfc/lpfc_hw4.h
index 8685d26e6929..93fd9fd10a0f 100644
--- a/drivers/scsi/lpfc/lpfc_hw4.h
+++ b/drivers/scsi/lpfc/lpfc_hw4.h
@@ -84,6 +84,7 @@ struct lpfc_sli_intf {
 #define LPFC_SLI_INTF_IF_TYPE_00
 #define LPFC_SLI_INTF_IF_TYPE_11
 #define LPFC_SLI_INTF_IF_TYPE_22
+#define LPFC_SLI_INTF_IF_TYPE_66
 #define lpfc_sli_intf_sli_family_SHIFT 8
 #define lpfc_sli_intf_sli_family_MASK  0x000F
 #define lpfc_sli_intf_sli_family_WORD  word0
@@ -731,11 +732,13 @@ struct lpfc_register {
  * register sets depending on the UCNA Port's reported if_type
  * value.  For UCNA ports running SLI4 and if_type 0, they reside in
  * BAR4.  For UCNA ports running SLI4 and if_type 2, they reside in
- * BAR0.  The offsets are the same so the driver must account for
- * any base address difference.
+ * BAR0.  For FC ports running SLI4 and if_type 6, they reside in
+ * BAR2. The offsets and base address are different,  so the driver
+ * has to compute the register addresses accordingly
  */
 #define LPFC_ULP0_RQ_DOORBELL  0x00A0
 #define LPFC_ULP1_RQ_DOORBELL  0x00C0
+#define LPFC_IF6_RQ_DOORBELL   0x0080
 #define lpfc_rq_db_list_fm_num_posted_SHIFT24
 #define lpfc_rq_db_list_fm_num_posted_MASK 0x00FF
 #define lpfc_rq_db_list_fm_num_posted_WORD word0
@@ -770,6 +773,20 @@ struct lpfc_register {
 #define lpfc_wq_db_ring_fm_id_MASK  0x
 #define lpfc_wq_db_ring_fm_id_WORD  word0
 
+#define LPFC_IF6_WQ_DOORBELL   0x0040
+#define lpfc_if6_wq_db_list_fm_num_posted_SHIFT24
+#define lpfc_if6_wq_db_list_fm_num_posted_MASK 0x00FF
+#define lpfc_if6_wq_db_list_fm_num_posted_WORD word0
+#define lpfc_if6_wq_db_list_fm_dpp_SHIFT   23
+#define lpfc_if6_wq_db_list_fm_dpp_MASK0x0001
+#define lpfc_if6_wq_db_list_fm_dpp_WORDword0
+#define lpfc_if6_wq_db_list_fm_dpp_id_SHIFT16
+#define lpfc_if6_wq_db_list_fm_dpp_id_MASK 0x001F
+#define lpfc_if6_wq_db_list_fm_dpp_id_WORD word0
+#define lpfc_if6_wq_db_list_fm_id_SHIFT0
+#define lpfc_if6_wq_db_list_fm_id_MASK 0x
+#define lpfc_if6_wq_db_list_fm_id_WORD word0
+
 #define LPFC_EQCQ_DOORBELL 0x0120
 #define lpfc_eqcq_doorbell_se_SHIFT31
 #define lpfc_eqcq_doorbell_se_MASK 0x0001
@@ -805,6 +822,38 @@ struct lpfc_register {
 #define LPFC_CQID_HI_FIELD_SHIFT   10
 #define LPFC_EQID_HI_FIELD_SHIFT   9
 
+#define LPFC_IF6_CQ_DOORBELL   0x00C0
+#define lpfc_if6_cq_doorbell_se_SHIFT  31
+#define lpfc_if6_cq_doorbell_se_MASK   0x0001
+#define lpfc_if6_cq_doorbell_se_WORD   word0
+#define LPFC_IF6_CQ_SOLICIT_ENABLE_OFF 0
+#define LPFC_IF6_CQ_SOLICIT_ENABLE_ON  1
+#define lpfc_if6_cq_doorbell_arm_SHIFT   

[PATCH v3 04/13] lpfc: Add push-to-adapter support to sli4

2018-02-13 Thread James Smart
New if_type=6 adapters support an additional BAR that provides
apertures to allow direct WQE to adapter push support - termed
Direct Packet Push (DPP). WQ creation differs slightly to ask for
a WQ to be DPP-ized. When submitting a WQE to a DPP WQ, it is
submitted to the host memory for the WQ normally, but is also
written by the host cpu directly to a BAR aperture.  Write buffer
coalescing in hardware is (hopefully) turned on, enabling single
pci write operation support. The doorbell is thing rung to indicate
the WQE is available and was pushed to the aperture.

This patch:
- Updates the WQ Create commands for the DPP options
- Adds the bar mapping for if_type=6 DPP bar
- Adds the WQE pushing to the DDP aperture received from WQ create
- Adds a new module parameter to disable DPP operation if desired.
  Default is enabled.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 

---
v3:
  remove unnecessary parens
  use ioremap_wc() instead of set_memory_wc(). the wc property
is now set by default on the BAR. if direct push is disabled,
the BAR won't be used so it won't matter what is set on it.
Track cases where the ioremap_wc() may not succeed, leaving
bar pointer NULL. In this case, disable direct push.
  As some platforms will honor ioremap_wc() but not truly enable
wc, change default for direct push so enabled only on X86.
---
 drivers/scsi/lpfc/lpfc.h  |   3 +-
 drivers/scsi/lpfc/lpfc_attr.c |  14 +++
 drivers/scsi/lpfc/lpfc_hw4.h  |  31 ++
 drivers/scsi/lpfc/lpfc_init.c |  17 
 drivers/scsi/lpfc/lpfc_sli.c  | 218 ++
 drivers/scsi/lpfc/lpfc_sli4.h |  16 +++-
 6 files changed, 212 insertions(+), 87 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 9698b9635058..86ffb9756e65 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -840,7 +840,8 @@ struct lpfc_hba {
uint32_t cfg_enable_SmartSAN;
uint32_t cfg_enable_mds_diags;
uint32_t cfg_enable_fc4_type;
-   uint32_t cfg_enable_bbcr;   /*Enable BB Credit Recovery*/
+   uint32_t cfg_enable_bbcr;   /* Enable BB Credit Recovery */
+   uint32_t cfg_enable_dpp;/* Enable Direct Packet Push */
uint32_t cfg_xri_split;
 #define LPFC_ENABLE_FCP  1
 #define LPFC_ENABLE_NVME 2
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 7be4bdef4d42..e90d5066f66b 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -5186,6 +5186,18 @@ LPFC_ATTR_R(enable_mds_diags, 0, 0, 1, "Enable MDS 
Diagnostics");
  */
 LPFC_BBCR_ATTR_RW(enable_bbcr, 1, 0, 1, "Enable BBC Recovery");
 
+/*
+ * lpfc_enable_dpp: Enable DPP on G7
+ *   0  = DPP on G7 disabled
+ *   1  = DPP on G7 enabled (default)
+ * Value range is [0,1]. Default value is 1 on X86, 0 on other architectures.
+ */
+#ifdef CONFIG_X86
+LPFC_ATTR_RW(enable_dpp, 1, 0, 1, "Enable Direct Packet Push");
+#else
+LPFC_ATTR_RW(enable_dpp, 0, 0, 1, "Enable Direct Packet Push");
+#endif
+
 struct device_attribute *lpfc_hba_attrs[] = {
_attr_nvme_info,
_attr_bg_info,
@@ -5294,6 +5306,7 @@ struct device_attribute *lpfc_hba_attrs[] = {
_attr_lpfc_xlane_supported,
_attr_lpfc_enable_mds_diags,
_attr_lpfc_enable_bbcr,
+   _attr_lpfc_enable_dpp,
NULL,
 };
 
@@ -6306,6 +6319,7 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
lpfc_fcp_io_channel_init(phba, lpfc_fcp_io_channel);
lpfc_nvme_io_channel_init(phba, lpfc_nvme_io_channel);
lpfc_enable_bbcr_init(phba, lpfc_enable_bbcr);
+   lpfc_enable_dpp_init(phba, lpfc_enable_dpp);
 
if (phba->sli_rev != LPFC_SLI_REV4) {
/* NVME only supported on SLI4 */
diff --git a/drivers/scsi/lpfc/lpfc_hw4.h b/drivers/scsi/lpfc/lpfc_hw4.h
index 93fd9fd10a0f..60ccff6fa8b0 100644
--- a/drivers/scsi/lpfc/lpfc_hw4.h
+++ b/drivers/scsi/lpfc/lpfc_hw4.h
@@ -1372,6 +1372,15 @@ struct lpfc_mbx_wq_create {
 #define lpfc_mbx_wq_create_page_size_MASK  0x00FF
 #define lpfc_mbx_wq_create_page_size_WORD  word1
 #define LPFC_WQ_PAGE_SIZE_4096 0x1
+#define lpfc_mbx_wq_create_dpp_req_SHIFT   15
+#define lpfc_mbx_wq_create_dpp_req_MASK0x0001
+#define lpfc_mbx_wq_create_dpp_req_WORDword1
+#define lpfc_mbx_wq_create_doe_SHIFT   14
+#define lpfc_mbx_wq_create_doe_MASK0x0001
+#define lpfc_mbx_wq_create_doe_WORDword1
+#define lpfc_mbx_wq_create_toe_SHIFT   13
+#define lpfc_mbx_wq_create_toe_MASK0x0001
+#define lpfc_mbx_wq_create_toe_WORDword1
 #define lpfc_mbx_wq_create_wqe_size_SHIFT  8
 #define lpfc_mbx_wq_create_wqe_size_MASK   0x000F
 #define lpfc_mbx_wq_create_wqe_size_WORD   word1
@@ -1400,6 +1409,28 @@ struct lpfc_mbx_wq_create {
 #define lpfc_mbx_wq_create_db_format_MASK  0x
 #define 

[PATCH v3 09/13] lpfc: Add embedded data pointers for enhanced performance

2018-02-13 Thread James Smart
The current driver isn't taking advantage of a performance hint whereby
the initial data buffer descriptor can be placed in the WQE as well as
the SGL.

Add the logic to detect support for the feature and to use it when
supported.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 

---
v3:
  remove unneeded parens
  combined 6422 msg on 1 line
---
 drivers/scsi/lpfc/lpfc.h   |  2 ++
 drivers/scsi/lpfc/lpfc_hw4.h   |  3 +++
 drivers/scsi/lpfc/lpfc_init.c  | 20 
 drivers/scsi/lpfc/lpfc_nvme.c  | 18 ++
 drivers/scsi/lpfc/lpfc_nvmet.c | 24 
 drivers/scsi/lpfc/lpfc_scsi.c  |  8 ++--
 drivers/scsi/lpfc/lpfc_sli.c   | 25 +
 7 files changed, 94 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 7aad4a717f13..9136a59b1c5b 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -840,6 +840,8 @@ struct lpfc_hba {
 #define LPFC_ENABLE_FCP  1
 #define LPFC_ENABLE_NVME 2
 #define LPFC_ENABLE_BOTH 3
+   uint32_t nvme_embed_pbde;
+   uint32_t fcp_embed_pbde;
uint32_t io_channel_irqs;   /* number of irqs for io channels */
struct nvmet_fc_target_port *targetport;
lpfc_vpd_t vpd; /* vital product data */
diff --git a/drivers/scsi/lpfc/lpfc_hw4.h b/drivers/scsi/lpfc/lpfc_hw4.h
index be8227dfa086..ed5e870c58c3 100644
--- a/drivers/scsi/lpfc/lpfc_hw4.h
+++ b/drivers/scsi/lpfc/lpfc_hw4.h
@@ -4226,6 +4226,9 @@ struct wqe_common {
 #define wqe_irsp_SHIFT4
 #define wqe_irsp_MASK 0x0001
 #define wqe_irsp_WORD word11
+#define wqe_pbde_SHIFT5
+#define wqe_pbde_MASK 0x0001
+#define wqe_pbde_WORD word11
 #define wqe_sup_SHIFT 6
 #define wqe_sup_MASK  0x0001
 #define wqe_sup_WORD  word11
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index fc452ffa73bc..f8af3adee21a 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -10607,6 +10607,19 @@ lpfc_get_sli4_parameters(struct lpfc_hba *phba, 
LPFC_MBOXQ_t *mboxq)
phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP;
}
 
+   /* Only embed PBDE for if_type 6 */
+   if (bf_get(lpfc_sli_intf_if_type, >sli4_hba.sli_intf) ==
+   LPFC_SLI_INTF_IF_TYPE_6) {
+   phba->fcp_embed_pbde = 1;
+   phba->nvme_embed_pbde = 1;
+   }
+
+   /* PBDE support requires xib be set */
+   if (!bf_get(cfg_xib, mbx_sli4_parameters)) {
+   phba->fcp_embed_pbde = 0;
+   phba->nvme_embed_pbde = 0;
+   }
+
/*
 * To support Suppress Response feature we must satisfy 3 conditions.
 * lpfc_suppress_rsp module parameter must be set (default).
@@ -10638,6 +10651,13 @@ lpfc_get_sli4_parameters(struct lpfc_hba *phba, 
LPFC_MBOXQ_t *mboxq)
else
phba->fcp_embed_io = 0;
 
+   lpfc_printf_log(phba, KERN_INFO, LOG_INIT | LOG_NVME,
+   "6422 XIB %d: FCP %d %d NVME %d %d %d\n",
+   bf_get(cfg_xib, mbx_sli4_parameters),
+   phba->fcp_embed_pbde, phba->fcp_embed_io,
+   phba->nvme_support, phba->nvme_embed_pbde,
+   phba->cfg_suppress_rsp);
+
if ((bf_get(cfg_cqpsize, mbx_sli4_parameters) & LPFC_CQ_16K_PAGE_SZ) &&
(bf_get(cfg_wqpsize, mbx_sli4_parameters) & LPFC_WQ_16K_PAGE_SZ) &&
(sli4_params->wqsize & LPFC_WQ_SZ128_SUPPORT))
diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
index 3a103d0895a2..5a1a6e24a27f 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -1170,6 +1170,7 @@ lpfc_nvme_prep_io_dma(struct lpfc_vport *vport,
struct sli4_sge *sgl = lpfc_ncmd->nvme_sgl;
struct scatterlist *data_sg;
struct sli4_sge *first_data_sgl;
+   struct ulp_bde64 *bde;
dma_addr_t physaddr;
uint32_t num_bde = 0;
uint32_t dma_len;
@@ -1237,7 +1238,24 @@ lpfc_nvme_prep_io_dma(struct lpfc_vport *vport,
data_sg = sg_next(data_sg);
sgl++;
}
+   if (phba->nvme_embed_pbde) {
+   /* Use PBDE support for first SGL only, offset == 0 */
+   /* Words 13-15 */
+   bde = (struct ulp_bde64 *)
+   >words[13];
+   bde->addrLow = first_data_sgl->addr_lo;
+   bde->addrHigh = first_data_sgl->addr_hi;
+   bde->tus.f.bdeSize =
+   le32_to_cpu(first_data_sgl->sge_len);
+   bde->tus.f.bdeFlags = BUFF_TYPE_BDE_64;
+   bde->tus.w = cpu_to_le32(bde->tus.w);
+   bf_set(wqe_pbde, >generic.wqe_com, 1);

[PATCH v3 10/13] lpfc: Fix nvme embedded io length on new hardware

2018-02-13 Thread James Smart
Newer hardware more strictly enforces buffer lenghts, causing an
mis-set value to be identified. Older hardware won't catch it.
The difference is benign on old hardware.

Set the right embedded buffer length for nvme ios.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/lpfc/lpfc_nvme.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
index 5a1a6e24a27f..c75958daf799 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -655,7 +655,7 @@ lpfc_nvme_adj_fcp_sgls(struct lpfc_vport *vport,
 
/* Word 0-2 - NVME CMND IU (embedded payload) */
wqe->generic.bde.tus.f.bdeFlags = BUFF_TYPE_BDE_IMMED;
-   wqe->generic.bde.tus.f.bdeSize = 60;
+   wqe->generic.bde.tus.f.bdeSize = 56;
wqe->generic.bde.addrHigh = 0;
wqe->generic.bde.addrLow =  64;  /* Word 16 */
 
-- 
2.13.1



[PATCH v3 11/13] lpfc: Work around NVME cmd iu SGL type

2018-02-13 Thread James Smart
The hardware offload for NVME commands was created when the
FC-NVME standard was setting SGL Descriptor Type to SGL Data
Block Descriptor (0h) and SGL Descriptor Sub Type to Address (0h).

A late change in NVMe-over-Fabrics obsoleted these values, creating
a transport SGL descriptor type with new values to go into these
fields.

For initial hardware support, in order to be compliant to the spec,
use host-supplied cmd IU buffers instead of the adapter generated
values. Later hardware will correct this.

Add a module parameter to override this offload disablement if looking
for lowest latency. This is reasonable as nothing in FC-NVME uses
the SQE SGL values.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 

---
v3:
  msg 6422 combined on 1 line
---
 drivers/scsi/lpfc/lpfc.h  |  1 +
 drivers/scsi/lpfc/lpfc_attr.c | 14 
 drivers/scsi/lpfc/lpfc_hw4.h  |  1 +
 drivers/scsi/lpfc/lpfc_init.c |  4 ++--
 drivers/scsi/lpfc/lpfc_nvme.c | 51 ++-
 drivers/scsi/lpfc/lpfc_sli.c  | 15 +
 6 files changed, 69 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 9136a59b1c5b..6c0d351c0d0d 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -782,6 +782,7 @@ struct lpfc_hba {
uint32_t cfg_fcp_io_channel;
uint32_t cfg_suppress_rsp;
uint32_t cfg_nvme_oas;
+   uint32_t cfg_nvme_embed_cmd;
uint32_t cfg_nvme_io_channel;
uint32_t cfg_nvmet_mrq;
uint32_t cfg_enable_nvmet;
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index bbed20a39b25..5afa85ade6f8 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -5042,6 +5042,18 @@ LPFC_ATTR_RW(nvme_oas, 0, 0, 1,
 "Use OAS bit on NVME IOs");
 
 /*
+ * lpfc_nvme_embed_cmd: Use the oas bit when sending NVME/NVMET IOs
+ *
+ *  0  = Put NVME Command in SGL
+ *  1  = Embed NVME Command in WQE (unless G7)
+ *  2 =  Embed NVME Command in WQE (force)
+ *
+ * Value range is [0,2]. Default value is 1.
+ */
+LPFC_ATTR_RW(nvme_embed_cmd, 1, 0, 2,
+"Embed NVME Command in WQE");
+
+/*
  * lpfc_fcp_io_channel: Set the number of FCP IO channels the driver
  * will advertise it supports to the SCSI layer. This also will map to
  * the number of WQs the driver will create.
@@ -5286,6 +5298,7 @@ struct device_attribute *lpfc_hba_attrs[] = {
_attr_lpfc_task_mgmt_tmo,
_attr_lpfc_use_msi,
_attr_lpfc_nvme_oas,
+   _attr_lpfc_nvme_embed_cmd,
_attr_lpfc_auto_imax,
_attr_lpfc_fcp_imax,
_attr_lpfc_fcp_cpu_map,
@@ -6310,6 +6323,7 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
lpfc_enable_SmartSAN_init(phba, lpfc_enable_SmartSAN);
lpfc_use_msi_init(phba, lpfc_use_msi);
lpfc_nvme_oas_init(phba, lpfc_nvme_oas);
+   lpfc_nvme_embed_cmd_init(phba, lpfc_nvme_embed_cmd);
lpfc_auto_imax_init(phba, lpfc_auto_imax);
lpfc_fcp_imax_init(phba, lpfc_fcp_imax);
lpfc_fcp_cpu_map_init(phba, lpfc_fcp_cpu_map);
diff --git a/drivers/scsi/lpfc/lpfc_hw4.h b/drivers/scsi/lpfc/lpfc_hw4.h
index ed5e870c58c3..37c547b4bc78 100644
--- a/drivers/scsi/lpfc/lpfc_hw4.h
+++ b/drivers/scsi/lpfc/lpfc_hw4.h
@@ -2678,6 +2678,7 @@ struct lpfc_mbx_read_rev {
 #define lpfc_mbx_rd_rev_vpd_MASK   0x0001
 #define lpfc_mbx_rd_rev_vpd_WORD   word1
uint32_t first_hw_rev;
+#define LPFC_G7_ASIC_1 0xd
uint32_t second_hw_rev;
uint32_t word4_rsvd;
uint32_t third_hw_rev;
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index f8af3adee21a..476caeac201d 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -10652,11 +10652,11 @@ lpfc_get_sli4_parameters(struct lpfc_hba *phba, 
LPFC_MBOXQ_t *mboxq)
phba->fcp_embed_io = 0;
 
lpfc_printf_log(phba, KERN_INFO, LOG_INIT | LOG_NVME,
-   "6422 XIB %d: FCP %d %d NVME %d %d %d\n",
+   "6422 XIB %d: FCP %d %d NVME %d %d %d %d\n",
bf_get(cfg_xib, mbx_sli4_parameters),
phba->fcp_embed_pbde, phba->fcp_embed_io,
phba->nvme_support, phba->nvme_embed_pbde,
-   phba->cfg_suppress_rsp);
+   phba->cfg_nvme_embed_cmd, phba->cfg_suppress_rsp);
 
if ((bf_get(cfg_cqpsize, mbx_sli4_parameters) & LPFC_CQ_16K_PAGE_SZ) &&
(bf_get(cfg_wqpsize, mbx_sli4_parameters) & LPFC_WQ_16K_PAGE_SZ) &&
diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
index c75958daf799..6ea6cc372647 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -617,11 +617,21 @@ lpfc_nvme_adj_fcp_sgls(struct lpfc_vport *vport,
   struct lpfc_nvme_buf 

[PATCH v3 06/13] lpfc: Add 64G link speed support

2018-02-13 Thread James Smart
The G7 adapter supports 64G link speeds. Add support to the driver.

In addition, a small cleanup to replace the odd bitmap logic with
a switch case.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 

---
v2:
  address review comment of typo in define name. Define wasn't used
  anywhere yet.
v3:
  reformat printf_log 0469
---
 drivers/scsi/lpfc/lpfc.h | 14 +++--
 drivers/scsi/lpfc/lpfc_attr.c| 62 
 drivers/scsi/lpfc/lpfc_ct.c  |  5 
 drivers/scsi/lpfc/lpfc_els.c |  5 
 drivers/scsi/lpfc/lpfc_hbadisc.c |  1 +
 drivers/scsi/lpfc/lpfc_hw.h  | 12 
 drivers/scsi/lpfc/lpfc_hw4.h |  3 ++
 drivers/scsi/lpfc/lpfc_init.c| 17 +--
 drivers/scsi/lpfc/lpfc_mbox.c|  4 +++
 9 files changed, 93 insertions(+), 30 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 86ffb9756e65..7aad4a717f13 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -544,16 +544,10 @@ struct unsol_rcv_ct_ctx {
 #define LPFC_USER_LINK_SPEED_10G   10  /* 10 Gigabaud */
 #define LPFC_USER_LINK_SPEED_16G   16  /* 16 Gigabaud */
 #define LPFC_USER_LINK_SPEED_32G   32  /* 32 Gigabaud */
-#define LPFC_USER_LINK_SPEED_MAX   LPFC_USER_LINK_SPEED_32G
-#define LPFC_USER_LINK_SPEED_BITMAP  ((1ULL << LPFC_USER_LINK_SPEED_32G) | \
-(1 << LPFC_USER_LINK_SPEED_16G) | \
-(1 << LPFC_USER_LINK_SPEED_10G) | \
-(1 << LPFC_USER_LINK_SPEED_8G) | \
-(1 << LPFC_USER_LINK_SPEED_4G) | \
-(1 << LPFC_USER_LINK_SPEED_2G) | \
-(1 << LPFC_USER_LINK_SPEED_1G) | \
-(1 << LPFC_USER_LINK_SPEED_AUTO))
-#define LPFC_LINK_SPEED_STRING "0, 1, 2, 4, 8, 10, 16, 32"
+#define LPFC_USER_LINK_SPEED_64G   64  /* 64 Gigabaud */
+#define LPFC_USER_LINK_SPEED_MAX   LPFC_USER_LINK_SPEED_64G
+
+#define LPFC_LINK_SPEED_STRING "0, 1, 2, 4, 8, 10, 16, 32, 64"
 
 enum nemb_type {
nemb_mse = 1,
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index e90d5066f66b..bbed20a39b25 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -4115,23 +4115,32 @@ lpfc_link_speed_store(struct device *dev, struct 
device_attribute *attr,
((val == LPFC_USER_LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) ||
((val == LPFC_USER_LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)) ||
((val == LPFC_USER_LINK_SPEED_16G) && !(phba->lmt & LMT_16Gb)) ||
-   ((val == LPFC_USER_LINK_SPEED_32G) && !(phba->lmt & LMT_32Gb))) {
+   ((val == LPFC_USER_LINK_SPEED_32G) && !(phba->lmt & LMT_32Gb)) ||
+   ((val == LPFC_USER_LINK_SPEED_64G) && !(phba->lmt & LMT_64Gb))) {
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
"2879 lpfc_link_speed attribute cannot be set "
"to %d. Speed is not supported by this port.\n",
val);
return -EINVAL;
}
-   if (val == LPFC_USER_LINK_SPEED_16G &&
-phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
+   if (val >= LPFC_USER_LINK_SPEED_16G &&
+   phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
"3112 lpfc_link_speed attribute cannot be set "
"to %d. Speed is not supported in loop mode.\n",
val);
return -EINVAL;
}
-   if ((val >= 0) && (val <= LPFC_USER_LINK_SPEED_MAX) &&
-   (LPFC_USER_LINK_SPEED_BITMAP & (1 << val))) {
+
+   switch (val) {
+   case LPFC_USER_LINK_SPEED_AUTO:
+   case LPFC_USER_LINK_SPEED_1G:
+   case LPFC_USER_LINK_SPEED_2G:
+   case LPFC_USER_LINK_SPEED_4G:
+   case LPFC_USER_LINK_SPEED_8G:
+   case LPFC_USER_LINK_SPEED_16G:
+   case LPFC_USER_LINK_SPEED_32G:
+   case LPFC_USER_LINK_SPEED_64G:
prev_val = phba->cfg_link_speed;
phba->cfg_link_speed = val;
if (nolip)
@@ -4141,13 +4150,18 @@ lpfc_link_speed_store(struct device *dev, struct 
device_attribute *attr,
if (err) {
phba->cfg_link_speed = prev_val;
return -EINVAL;
-   } else
-   return strlen(buf);
+   }
+   return strlen(buf);
+   default:
+   break;
}
+
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
-   "0469 lpfc_link_speed attribute cannot be set to %d, "
-   "allowed values are ["LPFC_LINK_SPEED_STRING"]\n", val);
+   "0469 

[PATCH v3 08/13] lpfc: Enable fw download on if_type=6 devices

2018-02-13 Thread James Smart
Current code is very explicit in what it allows to be downloaded.
The driver checking prevented G7 firmware download. The driver
checking is unnecessary as the device will validate what it receives.

Revise the firmware download interface checking.
Added a little debug support in case there is still a failure.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/lpfc/lpfc_hw4.h  |  5 +
 drivers/scsi/lpfc/lpfc_init.c | 44 ++-
 drivers/scsi/lpfc/lpfc_sli.c  |  1 +
 3 files changed, 33 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_hw4.h b/drivers/scsi/lpfc/lpfc_hw4.h
index dba724e1f5ee..be8227dfa086 100644
--- a/drivers/scsi/lpfc/lpfc_hw4.h
+++ b/drivers/scsi/lpfc/lpfc_hw4.h
@@ -2241,6 +2241,7 @@ struct lpfc_mbx_redisc_fcf_tbl {
  * command.
  */
 #define ADD_STATUS_OPERATION_ALREADY_ACTIVE0x67
+#define ADD_STATUS_FW_NOT_SUPPORTED0xEB
 
 struct lpfc_mbx_sli4_config {
struct mbox_header header;
@@ -4603,10 +4604,6 @@ union lpfc_wqe128 {
struct gen_req64_wqe gen_req;
 };
 
-#define LPFC_GROUP_OJECT_MAGIC_G5  0xfeaa0001
-#define LPFC_GROUP_OJECT_MAGIC_G6  0xfeaa0003
-#define LPFC_FILE_TYPE_GROUP   0xf7
-#define LPFC_FILE_ID_GROUP 0xa2
 struct lpfc_grp_hdr {
uint32_t size;
uint32_t magic_number;
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index e7b0b83d4378..fc452ffa73bc 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -11296,6 +11296,27 @@ lpfc_sli4_get_iocb_cnt(struct lpfc_hba *phba)
 }
 
 
+static void
+lpfc_log_write_firmware_error(struct lpfc_hba *phba, uint32_t offset,
+   uint32_t magic_number, uint32_t ftype, uint32_t fid, uint32_t fsize,
+   const struct firmware *fw)
+{
+   if (offset == ADD_STATUS_FW_NOT_SUPPORTED)
+   lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+   "3030 This firmware version is not supported on "
+   "this HBA model. Device:%x Magic:%x Type:%x "
+   "ID:%x Size %d %zd\n",
+   phba->pcidev->device, magic_number, ftype, fid,
+   fsize, fw->size);
+   else
+   lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+   "3022 FW Download failed. Device:%x Magic:%x Type:%x "
+   "ID:%x Size %d %zd\n",
+   phba->pcidev->device, magic_number, ftype, fid,
+   fsize, fw->size);
+}
+
+
 /**
  * lpfc_write_firmware - attempt to write a firmware image to the port
  * @fw: pointer to firmware image returned from request_firmware.
@@ -11323,20 +11344,10 @@ lpfc_write_firmware(const struct firmware *fw, void 
*context)
 
magic_number = be32_to_cpu(image->magic_number);
ftype = bf_get_be32(lpfc_grp_hdr_file_type, image);
-   fid = bf_get_be32(lpfc_grp_hdr_id, image),
+   fid = bf_get_be32(lpfc_grp_hdr_id, image);
fsize = be32_to_cpu(image->size);
 
INIT_LIST_HEAD(_buffer_list);
-   if ((magic_number != LPFC_GROUP_OJECT_MAGIC_G5 &&
-magic_number != LPFC_GROUP_OJECT_MAGIC_G6) ||
-   ftype != LPFC_FILE_TYPE_GROUP || fsize != fw->size) {
-   lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
-   "3022 Invalid FW image found. "
-   "Magic:%x Type:%x ID:%x Size %d %zd\n",
-   magic_number, ftype, fid, fsize, fw->size);
-   rc = -EINVAL;
-   goto release_out;
-   }
lpfc_decode_firmware_rev(phba, fwrev, 1);
if (strncmp(fwrev, image->revision, strnlen(image->revision, 16))) {
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
@@ -11377,11 +11388,18 @@ lpfc_write_firmware(const struct firmware *fw, void 
*context)
}
rc = lpfc_wr_object(phba, _buffer_list,
(fw->size - offset), );
-   if (rc)
+   if (rc) {
+   lpfc_log_write_firmware_error(phba, offset,
+   magic_number, ftype, fid, fsize, fw);
goto release_out;
+   }
}
rc = offset;
-   }
+   } else
+   lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+   "3029 Skipped Firmware update, Current "
+   "Version:%s New Version:%s\n",
+   fwrev, image->revision);
 
 release_out:
list_for_each_entry_safe(dmabuf, next, _buffer_list, list) {
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 

[PATCH v3 12/13] lpfc: update driver version to 12.0.0.0

2018-02-13 Thread James Smart
Update the driver version to 12.0.0.0

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/lpfc/lpfc_version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h
index 4adbf07880a2..b1ae62a44aae 100644
--- a/drivers/scsi/lpfc/lpfc_version.h
+++ b/drivers/scsi/lpfc/lpfc_version.h
@@ -20,7 +20,7 @@
  * included with this package. *
  ***/
 
-#define LPFC_DRIVER_VERSION "11.4.0.7"
+#define LPFC_DRIVER_VERSION "12.0.0.0"
 #define LPFC_DRIVER_NAME   "lpfc"
 
 /* Used for SLI 2/3 */
-- 
2.13.1



[PATCH v3 07/13] lpfc: Add if_type=6 support for cycling valid bits

2018-02-13 Thread James Smart
Traditional SLI4 required the driver to clear Valid bits on
EQEs and CQEs after consuming them.

The new if_type=6 hardware will cycle the value for what is
valid on each queue itteration. The driver no longer has to
touch the valid bits. This also means all the cpu cache
dirtying and perhaps flush/refill's done by the hardware
in accessing the EQ/CQ elements is eliminated.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/lpfc/lpfc_hw4.h  | 18 --
 drivers/scsi/lpfc/lpfc_init.c | 11 +++
 drivers/scsi/lpfc/lpfc_sli.c  | 77 +++
 drivers/scsi/lpfc/lpfc_sli4.h |  3 ++
 4 files changed, 92 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_hw4.h b/drivers/scsi/lpfc/lpfc_hw4.h
index 0c33510fe75c..dba724e1f5ee 100644
--- a/drivers/scsi/lpfc/lpfc_hw4.h
+++ b/drivers/scsi/lpfc/lpfc_hw4.h
@@ -1040,6 +1040,9 @@ struct eq_context {
 #define lpfc_eq_context_valid_SHIFT29
 #define lpfc_eq_context_valid_MASK 0x0001
 #define lpfc_eq_context_valid_WORD word0
+#define lpfc_eq_context_autovalid_SHIFT 28
+#define lpfc_eq_context_autovalid_MASK  0x0001
+#define lpfc_eq_context_autovalid_WORD  word0
uint32_t word1;
 #define lpfc_eq_context_count_SHIFT26
 #define lpfc_eq_context_count_MASK 0x0003
@@ -1173,6 +1176,9 @@ struct cq_context {
 #define LPFC_CQ_CNT_5120x1
 #define LPFC_CQ_CNT_1024   0x2
 #define LPFC_CQ_CNT_WORD7  0x3
+#define lpfc_cq_context_autovalid_SHIFT 15
+#define lpfc_cq_context_autovalid_MASK  0x0001
+#define lpfc_cq_context_autovalid_WORD  word0
uint32_t word1;
 #define lpfc_cq_eq_id_SHIFT22  /* Version 0 Only */
 #define lpfc_cq_eq_id_MASK 0x00FF
@@ -1231,9 +1237,9 @@ struct lpfc_mbx_cq_create_set {
 #define lpfc_mbx_cq_create_set_cqe_size_SHIFT  25
 #define lpfc_mbx_cq_create_set_cqe_size_MASK   0x0003
 #define lpfc_mbx_cq_create_set_cqe_size_WORD   word1
-#define lpfc_mbx_cq_create_set_auto_SHIFT  15
-#define lpfc_mbx_cq_create_set_auto_MASK   0x001
-#define lpfc_mbx_cq_create_set_auto_WORD   word1
+#define lpfc_mbx_cq_create_set_autovalid_SHIFT 15
+#define lpfc_mbx_cq_create_set_autovalid_MASK  0x001
+#define lpfc_mbx_cq_create_set_autovalid_WORD  word1
 #define lpfc_mbx_cq_create_set_nodelay_SHIFT   14
 #define lpfc_mbx_cq_create_set_nodelay_MASK0x0001
 #define lpfc_mbx_cq_create_set_nodelay_WORDword1
@@ -3288,6 +3294,9 @@ struct lpfc_sli4_parameters {
 #define cfg_sli_hint_2_MASK0x001f
 #define cfg_sli_hint_2_WORDword1
uint32_t word2;
+#define cfg_eqav_SHIFT 31
+#define cfg_eqav_MASK  0x0001
+#define cfg_eqav_WORD  word2
uint32_t word3;
uint32_t word4;
 #define cfg_cqv_SHIFT  14
@@ -3296,6 +3305,9 @@ struct lpfc_sli4_parameters {
 #define cfg_cqpsize_SHIFT  16
 #define cfg_cqpsize_MASK   0x00ff
 #define cfg_cqpsize_WORD   word4
+#define cfg_cqav_SHIFT 31
+#define cfg_cqav_MASK  0x0001
+#define cfg_cqav_WORD  word4
uint32_t word5;
uint32_t word6;
 #define cfg_mqv_SHIFT  14
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 0666f91bbbe1..e7b0b83d4378 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -8063,6 +8063,7 @@ lpfc_alloc_nvme_wq_cq(struct lpfc_hba *phba, int wqidx)
wqidx);
return 1;
}
+   qdesc->qe_valid = 1;
phba->sli4_hba.nvme_cq[wqidx] = qdesc;
 
qdesc = lpfc_sli4_queue_alloc(phba, LPFC_EXPANDED_PAGE_SIZE,
@@ -8100,6 +8101,7 @@ lpfc_alloc_fcp_wq_cq(struct lpfc_hba *phba, int wqidx)
"0499 Failed allocate fast-path FCP CQ (%d)\n", wqidx);
return 1;
}
+   qdesc->qe_valid = 1;
phba->sli4_hba.fcp_cq[wqidx] = qdesc;
 
/* Create Fast Path FCP WQs */
@@ -8293,6 +8295,7 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba)
"0497 Failed allocate EQ (%d)\n", idx);
goto out_error;
}
+   qdesc->qe_valid = 1;
phba->sli4_hba.hba_eq[idx] = qdesc;
}
 
@@ -8318,6 +8321,7 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba)
"CQ Set (%d)\n", idx);
goto out_error;
}
+   qdesc->qe_valid = 1;
phba->sli4_hba.nvmet_cqset[idx] = qdesc;
}
}
@@ -8335,6 +8339,7 @@ 

[PATCH v3 13/13] lpfc: Change Copyright of 12.0.0.0 modified files to 2018

2018-02-13 Thread James Smart
Updated Copyright in files updated as part of 12.0.0.0

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
Reviewed-by: Johannes Thumshirn 

---
v3:
  patch title
---
 drivers/scsi/lpfc/lpfc_bsg.c | 2 +-
 drivers/scsi/lpfc/lpfc_ct.c  | 2 +-
 drivers/scsi/lpfc/lpfc_debugfs.c | 2 +-
 drivers/scsi/lpfc/lpfc_debugfs.h | 2 +-
 drivers/scsi/lpfc/lpfc_hw.h  | 2 +-
 drivers/scsi/lpfc/lpfc_ids.h | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c
index 8b33b652226b..0f174ca80f67 100644
--- a/drivers/scsi/lpfc/lpfc_bsg.c
+++ b/drivers/scsi/lpfc/lpfc_bsg.c
@@ -1,7 +1,7 @@
 /***
  * This file is part of the Emulex Linux Device Driver for *
  * Fibre Channel Host Bus Adapters.*
- * Copyright (C) 2017 Broadcom. All Rights Reserved. The term  *
+ * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term *
  * “Broadcom” refers to Broadcom Limited and/or its subsidiaries.  *
  * Copyright (C) 2009-2015 Emulex.  All rights reserved.   *
  * EMULEX and SLI are trademarks of Emulex.*
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 03a7e13a049d..ebe8ac1b88e7 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -1,7 +1,7 @@
 /***
  * This file is part of the Emulex Linux Device Driver for *
  * Fibre Channel Host Bus Adapters.*
- * Copyright (C) 2017 Broadcom. All Rights Reserved. The term  *
+ * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term *
  * “Broadcom” refers to Broadcom Limited and/or its subsidiaries.  *
  * Copyright (C) 2004-2016 Emulex.  All rights reserved.   *
  * EMULEX and SLI are trademarks of Emulex.*
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index 308303d501cf..fb0dc2aeed91 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -1,7 +1,7 @@
 /***
  * This file is part of the Emulex Linux Device Driver for *
  * Fibre Channel Host Bus Adapters.*
- * Copyright (C) 2017 Broadcom. All Rights Reserved. The term  *
+ * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term *
  * “Broadcom” refers to Broadcom Limited and/or its subsidiaries.  *
  * Copyright (C) 2007-2015 Emulex.  All rights reserved.   *
  * EMULEX and SLI are trademarks of Emulex.*
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.h b/drivers/scsi/lpfc/lpfc_debugfs.h
index 12fbf498a7ce..f32eaeb2225a 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.h
+++ b/drivers/scsi/lpfc/lpfc_debugfs.h
@@ -1,7 +1,7 @@
 /***
  * This file is part of the Emulex Linux Device Driver for *
  * Fibre Channel Host Bus Adapters.*
- * Copyright (C) 2017 Broadcom. All Rights Reserved. The term  *
+ * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term *
  * “Broadcom” refers to Broadcom Limited and/or its subsidiaries.  *
  * Copyright (C) 2007-2011 Emulex.  All rights reserved.   *
  * EMULEX and SLI are trademarks of Emulex.*
diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h
index cf83322cd4fe..08a3f1520159 100644
--- a/drivers/scsi/lpfc/lpfc_hw.h
+++ b/drivers/scsi/lpfc/lpfc_hw.h
@@ -1,7 +1,7 @@
 /***
  * This file is part of the Emulex Linux Device Driver for *
  * Fibre Channel Host Bus Adapters.*
- * Copyright (C) 2017 Broadcom. All Rights Reserved. The term  *
+ * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term *
  * “Broadcom” refers to Broadcom Limited and/or its subsidiaries.  *
  * Copyright (C) 2004-2016 Emulex.  All rights reserved.   *
  * EMULEX and SLI are trademarks of Emulex.*
diff --git a/drivers/scsi/lpfc/lpfc_ids.h b/drivers/scsi/lpfc/lpfc_ids.h
index 329c8d28869c..07ee34017d88 100644
--- a/drivers/scsi/lpfc/lpfc_ids.h
+++ b/drivers/scsi/lpfc/lpfc_ids.h
@@ -1,7 +1,7 @@
 /***
  * This file is part of the Emulex Linux Device Driver for *
  * Fibre Channel Host Bus Adapters.*
- * Copyright (C) 2017 Broadcom. All Rights Reserved. The term  *
+ * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term *
  * “Broadcom” refers to Broadcom Limited and/or its subsidiaries.  *
  * Copyright (C) 

[PATCH v3 01/13] lpfc: Rework lpfc to allow different sli4 cq and eq handlers

2018-02-13 Thread James Smart
Up until now, an SLI-4 device had no variance in the way it handled
its EQs and CQs. With newer hardware, there are now differences in
doorbells and some differences in how entries are valid.

Prepare the code for new hardware by creating a sli4-based callout
table that can be set based on if_type.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/lpfc/lpfc_init.c |  7 +
 drivers/scsi/lpfc/lpfc_sli.c  | 63 ++-
 drivers/scsi/lpfc/lpfc_sli4.h |  5 
 3 files changed, 44 insertions(+), 31 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 465d890220d5..e24dca2b3f2f 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -9540,6 +9540,13 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba)
}
}
 
+   /* Set up the EQ/CQ register handeling functions now */
+   if (if_type <= LPFC_SLI_INTF_IF_TYPE_2) {
+   phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_eq_clr_intr;
+   phba->sli4_hba.sli4_eq_release = lpfc_sli4_eq_release;
+   phba->sli4_hba.sli4_cq_release = lpfc_sli4_cq_release;
+   }
+
return 0;
 
 out_iounmap_all:
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index e97d080e9f65..f91caae6489a 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -299,7 +299,7 @@ lpfc_sli4_eq_get(struct lpfc_queue *q)
  * @q: The Event Queue to disable interrupts
  *
  **/
-static inline void
+inline void
 lpfc_sli4_eq_clr_intr(struct lpfc_queue *q)
 {
struct lpfc_register doorbell;
@@ -5302,41 +5302,42 @@ static void
 lpfc_sli4_arm_cqeq_intr(struct lpfc_hba *phba)
 {
int qidx;
+   struct lpfc_sli4_hba *sli4_hba = >sli4_hba;
 
-   lpfc_sli4_cq_release(phba->sli4_hba.mbx_cq, LPFC_QUEUE_REARM);
-   lpfc_sli4_cq_release(phba->sli4_hba.els_cq, LPFC_QUEUE_REARM);
-   if (phba->sli4_hba.nvmels_cq)
-   lpfc_sli4_cq_release(phba->sli4_hba.nvmels_cq,
+   sli4_hba->sli4_cq_release(sli4_hba->mbx_cq, LPFC_QUEUE_REARM);
+   sli4_hba->sli4_cq_release(sli4_hba->els_cq, LPFC_QUEUE_REARM);
+   if (sli4_hba->nvmels_cq)
+   sli4_hba->sli4_cq_release(sli4_hba->nvmels_cq,
LPFC_QUEUE_REARM);
 
-   if (phba->sli4_hba.fcp_cq)
+   if (sli4_hba->fcp_cq)
for (qidx = 0; qidx < phba->cfg_fcp_io_channel; qidx++)
-   lpfc_sli4_cq_release(phba->sli4_hba.fcp_cq[qidx],
+   sli4_hba->sli4_cq_release(sli4_hba->fcp_cq[qidx],
LPFC_QUEUE_REARM);
 
-   if (phba->sli4_hba.nvme_cq)
+   if (sli4_hba->nvme_cq)
for (qidx = 0; qidx < phba->cfg_nvme_io_channel; qidx++)
-   lpfc_sli4_cq_release(phba->sli4_hba.nvme_cq[qidx],
+   sli4_hba->sli4_cq_release(sli4_hba->nvme_cq[qidx],
LPFC_QUEUE_REARM);
 
if (phba->cfg_fof)
-   lpfc_sli4_cq_release(phba->sli4_hba.oas_cq, LPFC_QUEUE_REARM);
+   sli4_hba->sli4_cq_release(sli4_hba->oas_cq, LPFC_QUEUE_REARM);
 
-   if (phba->sli4_hba.hba_eq)
+   if (sli4_hba->hba_eq)
for (qidx = 0; qidx < phba->io_channel_irqs; qidx++)
-   lpfc_sli4_eq_release(phba->sli4_hba.hba_eq[qidx],
-   LPFC_QUEUE_REARM);
+   sli4_hba->sli4_eq_release(sli4_hba->hba_eq[qidx],
+   LPFC_QUEUE_REARM);
 
if (phba->nvmet_support) {
for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) {
-   lpfc_sli4_cq_release(
-   phba->sli4_hba.nvmet_cqset[qidx],
+   sli4_hba->sli4_cq_release(
+   sli4_hba->nvmet_cqset[qidx],
LPFC_QUEUE_REARM);
}
}
 
if (phba->cfg_fof)
-   lpfc_sli4_eq_release(phba->sli4_hba.fof_eq, LPFC_QUEUE_REARM);
+   sli4_hba->sli4_eq_release(sli4_hba->fof_eq, LPFC_QUEUE_REARM);
 }
 
 /**
@@ -7270,7 +7271,7 @@ lpfc_sli4_mbox_completions_pending(struct lpfc_hba *phba)
 bool
 lpfc_sli4_process_missed_mbox_completions(struct lpfc_hba *phba)
 {
-
+   struct lpfc_sli4_hba *sli4_hba = >sli4_hba;
uint32_t eqidx;
struct lpfc_queue *fpeq = NULL;
struct lpfc_eqe *eqe;
@@ -7281,11 +7282,11 @@ lpfc_sli4_process_missed_mbox_completions(struct 
lpfc_hba *phba)
 
/* Find the eq associated with the mcq */
 
-   if (phba->sli4_hba.hba_eq)
+   if (sli4_hba->hba_eq)
for (eqidx = 0; eqidx < phba->io_channel_irqs; eqidx++)
-   

[PATCH v3 02/13] lpfc: Rework sli4 doorbell infrastructure

2018-02-13 Thread James Smart
Up until now, all SLI-4 devices had the same doorbells at the same
bar locations. With newer hardware, there are now independent EQ and
CQ doorbells and the bar locations differ.

Prepare the code for new hardware by separating the eq/cq doorbell into
separate components. The components can be set based on if_type.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
Reviewed-by: Johannes Thumshirn 
---
 drivers/scsi/lpfc/lpfc_debugfs.c | 20 ++--
 drivers/scsi/lpfc/lpfc_debugfs.h | 11 ++-
 drivers/scsi/lpfc/lpfc_init.c|  9 ++---
 drivers/scsi/lpfc/lpfc_sli.c |  8 
 drivers/scsi/lpfc/lpfc_sli4.h|  3 ++-
 5 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index 17ea3bb04266..308303d501cf 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -3944,10 +3944,15 @@ lpfc_idiag_drbacc_read_reg(struct lpfc_hba *phba, char 
*pbuffer,
return 0;
 
switch (drbregid) {
-   case LPFC_DRB_EQCQ:
-   len += snprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
-   "EQCQ-DRB-REG: 0x%08x\n",
-   readl(phba->sli4_hba.EQCQDBregaddr));
+   case LPFC_DRB_EQ:
+   len += snprintf(pbuffer + len, LPFC_DRB_ACC_BUF_SIZE-len,
+   "EQ-DRB-REG: 0x%08x\n",
+   readl(phba->sli4_hba.EQDBregaddr));
+   break;
+   case LPFC_DRB_CQ:
+   len += snprintf(pbuffer + len, LPFC_DRB_ACC_BUF_SIZE - len,
+   "CQ-DRB-REG: 0x%08x\n",
+   readl(phba->sli4_hba.CQDBregaddr));
break;
case LPFC_DRB_MQ:
len += snprintf(pbuffer+len, LPFC_DRB_ACC_BUF_SIZE-len,
@@ -4086,8 +4091,11 @@ lpfc_idiag_drbacc_write(struct file *file, const char 
__user *buf,
idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_ST ||
idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_CL) {
switch (drb_reg_id) {
-   case LPFC_DRB_EQCQ:
-   drb_reg = phba->sli4_hba.EQCQDBregaddr;
+   case LPFC_DRB_EQ:
+   drb_reg = phba->sli4_hba.EQDBregaddr;
+   break;
+   case LPFC_DRB_CQ:
+   drb_reg = phba->sli4_hba.CQDBregaddr;
break;
case LPFC_DRB_MQ:
drb_reg = phba->sli4_hba.MQDBregaddr;
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.h b/drivers/scsi/lpfc/lpfc_debugfs.h
index c4edd87bfc65..12fbf498a7ce 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.h
+++ b/drivers/scsi/lpfc/lpfc_debugfs.h
@@ -126,12 +126,13 @@
 #define LPFC_DRB_ACC_WR_CMD_ARG 2
 #define LPFC_DRB_ACC_BUF_SIZE 256
 
-#define LPFC_DRB_EQCQ 1
-#define LPFC_DRB_MQ   2
-#define LPFC_DRB_WQ   3
-#define LPFC_DRB_RQ   4
+#define LPFC_DRB_EQ   1
+#define LPFC_DRB_CQ   2
+#define LPFC_DRB_MQ   3
+#define LPFC_DRB_WQ   4
+#define LPFC_DRB_RQ   5
 
-#define LPFC_DRB_MAX  4
+#define LPFC_DRB_MAX  5
 
 #define IDIAG_DRBACC_REGID_INDX 0
 #define IDIAG_DRBACC_VALUE_INDX 1
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index e24dca2b3f2f..b2cf8eb99008 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -7430,8 +7430,9 @@ lpfc_sli4_bar0_register_memmap(struct lpfc_hba *phba, 
uint32_t if_type)
phba->sli4_hba.WQDBregaddr =
phba->sli4_hba.conf_regs_memmap_p +
LPFC_ULP0_WQ_DOORBELL;
-   phba->sli4_hba.EQCQDBregaddr =
+   phba->sli4_hba.CQDBregaddr =
phba->sli4_hba.conf_regs_memmap_p + LPFC_EQCQ_DOORBELL;
+   phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr;
phba->sli4_hba.MQDBregaddr =
phba->sli4_hba.conf_regs_memmap_p + LPFC_MQ_DOORBELL;
phba->sli4_hba.BMBXregaddr =
@@ -7488,8 +7489,10 @@ lpfc_sli4_bar2_register_memmap(struct lpfc_hba *phba, 
uint32_t vf)
phba->sli4_hba.WQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p +
vf * LPFC_VFR_PAGE_SIZE +
LPFC_ULP0_WQ_DOORBELL);
-   phba->sli4_hba.EQCQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p +
-   vf * LPFC_VFR_PAGE_SIZE + LPFC_EQCQ_DOORBELL);
+   phba->sli4_hba.CQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p +
+   vf * LPFC_VFR_PAGE_SIZE +
+   LPFC_EQCQ_DOORBELL);
+   phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr;
phba->sli4_hba.MQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p +
vf * LPFC_VFR_PAGE_SIZE 

[PATCH v3 05/13] lpfc: Add PCI Ids for if_type=6 hardware

2018-02-13 Thread James Smart
Add PCI ids for the new G7 adapter

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 

---
v3:
  Add default adapter id string for G7 adapter
---
 drivers/scsi/lpfc/lpfc_hw.h   | 1 +
 drivers/scsi/lpfc/lpfc_ids.h  | 2 ++
 drivers/scsi/lpfc/lpfc_init.c | 3 +++
 3 files changed, 6 insertions(+)

diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h
index bdc1f184f67a..d07d2fcbea34 100644
--- a/drivers/scsi/lpfc/lpfc_hw.h
+++ b/drivers/scsi/lpfc/lpfc_hw.h
@@ -1580,6 +1580,7 @@ struct lpfc_fdmi_reg_portattr {
 #define PCI_DEVICE_ID_LANCER_FCOE   0xe260
 #define PCI_DEVICE_ID_LANCER_FCOE_VF 0xe268
 #define PCI_DEVICE_ID_LANCER_G6_FC  0xe300
+#define PCI_DEVICE_ID_LANCER_G7_FC  0xf400
 #define PCI_DEVICE_ID_SAT_SMB   0xf011
 #define PCI_DEVICE_ID_SAT_MID   0xf015
 #define PCI_DEVICE_ID_RFLY  0xf095
diff --git a/drivers/scsi/lpfc/lpfc_ids.h b/drivers/scsi/lpfc/lpfc_ids.h
index 0ba3733eb36d..329c8d28869c 100644
--- a/drivers/scsi/lpfc/lpfc_ids.h
+++ b/drivers/scsi/lpfc/lpfc_ids.h
@@ -116,6 +116,8 @@ const struct pci_device_id lpfc_id_table[] = {
PCI_ANY_ID, PCI_ANY_ID, },
{PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LANCER_G6_FC,
PCI_ANY_ID, PCI_ANY_ID, },
+   {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LANCER_G7_FC,
+   PCI_ANY_ID, PCI_ANY_ID, },
{PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SKYHAWK,
PCI_ANY_ID, PCI_ANY_ID, },
{PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SKYHAWK_VF,
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 6db631ace750..4ae32a764f4b 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -2473,6 +2473,9 @@ lpfc_get_hba_model_desc(struct lpfc_hba *phba, uint8_t 
*mdp, uint8_t *descp)
case PCI_DEVICE_ID_LANCER_G6_FC:
m = (typeof(m)){"LPe32000", "PCIe", "Fibre Channel Adapter"};
break;
+   case PCI_DEVICE_ID_LANCER_G7_FC:
+   m = (typeof(m)){"LPe36000", "PCIe", "Fibre Channel Adapter"};
+   break;
case PCI_DEVICE_ID_SKYHAWK:
case PCI_DEVICE_ID_SKYHAWK_VF:
oneConnect = 1;
-- 
2.13.1



[PATCH v3 00/13] lpfc new hardware patches for 12.0.0.0

2018-02-13 Thread James Smart
This patch set adds support for Broadcom's new G7 product that
supports G4G FC.

The patches were cut against the Martin's 4.17/scsi-queue tree.

v2:
 Address comments:
   patch 1, 2, 4, 7: patch description typos
   patch 6: typo on 256GBit speed define

v3:
 Add review tags
 Address comments:
   patch 4: parens, replace set_memory_wc by ioremap_wc
   patch 6: reformat strings
   patch 9: parens
   patch 13: patch title
 patch 5: add missing snippet for default id string
 patch 9, 11: log print condensed to line


James Smart (13):
  lpfc: Rework lpfc to allow different sli4 cq and eq handlers
  lpfc: Rework sli4 doorbell infrastructure
  lpfc: Add SLI-4 if_type=6 support to the code base
  lpfc: Add push-to-adapter support to sli4
  lpfc: Add PCI Ids for if_type=6 hardware
  lpfc: Add 64G link speed support
  lpfc: Add if_type=6 support for cycling valid bits
  lpfc: Enable fw download on if_type=6 devices
  lpfc: Add embedded data pointers for enhanced performance
  lpfc: Fix nvme embedded io length on new hardware
  lpfc: Work around NVME cmd iu SGL type
  lpfc: update driver version to 12.0.0.0
  lpfc: Change Copyright of 12.0.0.0 modified files to 2018

 drivers/scsi/lpfc/lpfc.h |  20 +-
 drivers/scsi/lpfc/lpfc_attr.c|  90 +--
 drivers/scsi/lpfc/lpfc_bsg.c |   6 +-
 drivers/scsi/lpfc/lpfc_ct.c  |   7 +-
 drivers/scsi/lpfc/lpfc_debugfs.c |  22 +-
 drivers/scsi/lpfc/lpfc_debugfs.h |  13 +-
 drivers/scsi/lpfc/lpfc_els.c |   5 +
 drivers/scsi/lpfc/lpfc_hbadisc.c |   1 +
 drivers/scsi/lpfc/lpfc_hw.h  |  15 +-
 drivers/scsi/lpfc/lpfc_hw4.h | 115 -
 drivers/scsi/lpfc/lpfc_ids.h |   4 +-
 drivers/scsi/lpfc/lpfc_init.c| 246 ---
 drivers/scsi/lpfc/lpfc_mbox.c|   4 +
 drivers/scsi/lpfc/lpfc_nvme.c|  69 --
 drivers/scsi/lpfc/lpfc_nvmet.c   |  24 ++
 drivers/scsi/lpfc/lpfc_scsi.c|   8 +-
 drivers/scsi/lpfc/lpfc_sli.c | 519 +--
 drivers/scsi/lpfc/lpfc_sli4.h|  30 ++-
 drivers/scsi/lpfc/lpfc_version.h |   2 +-
 19 files changed, 950 insertions(+), 250 deletions(-)

-- 
2.13.1



Re: [PATCH] qla2xxx: Fix NULL pointer crash due to active timer for ABTS

2018-02-13 Thread Madhani, Himanshu
Hi Johannes, 

> On Feb 13, 2018, at 2:38 AM, Johannes Thumshirn  wrote:
> 
> Thanks Himanshu,
> Reviewed-by: Johannes Thumshirn 
> 
> Do you happen to know which commit it actually fixes?
> 

Thanks for asking (I did not add fixes commit ID because it was pre 4.x kernel) 

Here’s commit id 4440e46d5db7b445a961a8849b2a31fa7fd1 which is fixed by 
this patch.

> -- 
> Johannes Thumshirn  Storage
> jthu
> msh...@suse.de+49 911 74053 689
> SUSE
> LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
> GF: Felix Imendörffer, Jane
> Smithard, Graham Norton
> HRB 21284 (AG Nürnberg)
> Key fingerprint = EC38
> 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

Thanks,
- Himanshu



Re: [PATCH] libsas: Fix kernel-doc headers

2018-02-13 Thread Bart Van Assche

On 02/13/18 02:17, John Garry wrote:

On 12/02/2018 18:45, Bart Van Assche wrote:

[ ... ]
-/**
+/*
  * sas_init_disc -- initialize the discovery struct in the port
  * @port: pointer to struct port


I wonder why you get no complaint that @disc argument is not mentioned, 


Hello John,

Since I was not sure how to document the 'disc' argument I changed /** 
into /* to make the kernel-doc tool skip the sas_init_disc() function. 
Any suggestion for how to document the 'disc' argument would be welcome.




-/**
+/*
  * sas_configure_parent -- configure routing table of parent
- * parent: parent expander
- * child: child expander
- * sas_addr: SAS port identifier of device directly attached to child
+ * @parent: parent expander
+ * @child: child expander
+ * @sas_addr: SAS port identifier of device directly attached to child


and no mention of @include here


Also for the 'include' argument, a suggestion of how to document it 
would be welcome.



 /**
  * sas_revalidate_domain -- revalidate the domain


This function name seems incorrect. [ ... ]  And I would write "port domain 
device"


Thanks, will fix.


-/**
+/*


If the build does not complain about this for W=1, then should we 
include it? I ask, as I see many other instances of "/**". I don't mind 
cleaning them up in a separate patch.


The kernel-doc tool only analyzes function headers that start with 
"/**". Any changes of "/**" into "/*" mean that I did not know how to 
document the arguments about which the kernel-doc tool complained that 
documentation was missing.


Thanks,

Bart.


Re: [PATCH v2 04/13] lpfc: Add push-to-adapter support to sli4

2018-02-13 Thread James Smart

On 2/12/2018 9:59 PM, Michael Ellerman wrote:

Johannes Thumshirn  writes:


On Wed, Feb 07, 2018 at 10:51:57AM +0100, Johannes Thumshirn wrote:

+   /* Enable combined writes for DPP aperture */
+   pg_addr = (unsigned long)(wq->dpp_regaddr) & PAGE_MASK;
+#ifdef CONFIG_X86
+   rc = set_memory_wc(pg_addr, 1);
+   if (rc) {
+   lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+   "3272 Cannot setup Combined "
+   "Write on WQ[%d] - disable 
DPP\n",
+   wq->queue_id);
+   phba->cfg_enable_dpp = 0;
+   }
+#else
+   phba->cfg_enable_dpp = 0;
+#endif
+   } else
+   wq->db_regaddr = phba->sli4_hba.WQDBregaddr;


I don't really like the set_memory_wc() call here. Neither do I like the ifdef
CONFIG_X86 special casing.

If you really need write combining, can't you at least use ioremap_wc()?


Coming back to this again (after talking to our ARM/POWER folks internally).
Is this really x86 specific here? I know there are servers with other 
architectures
using lpfcs out there.

I _think_ write combining should be possible on other architectures (that have
PCIe and aren't dead) as well.

The ioremap_wc() I suggested is probably wrong.

So can you please revisit this? I CCed Mark and Michael, maybe they can help
here.


I'm not much of an I/O guy, but I do know that on powerpc we don't
implement set_memory_wc(). So if you're using that then you do need the
ifdef.

I couldn't easily find the rest of this thread, so I'm not sure if
ioremap_wc() is an option. We do implement that and on modern CPUs at
least it will give you something that's not just a plain uncached
mapping.


I went back and looked at things.  It does appear that we should be 
using ioremap_wc().  There's a pci routine that wrappers it, but as 
we're already are using the other routines in the wrapper, it's not very 
interesting.   Ioremap_wc seems to be supported pretty much anywhere, 
with platforms managing what it resolves to. Granted, some platforms 
may not do write combining but will relax the caching aspects (as 
Michael indicates).


The interesting thing is - when wc is truly on, we see a substantial 
difference. But in cases where wc isn't on and we perform the individual 
writes plus the flush before the doorbell write to synchronize things, 
it turns out it takes longer than if we don't use the feature. So, in 
cases where we don't have real wc, I'm going to turn it off. Based on 
what we've tested so far (includes ppc p8), we'll be leaving it enabled 
on X86 only.


-- james



[PATCH] ufs: Fix kernel-doc errors and warnings

2018-02-13 Thread Bart Van Assche
Avoid that the kernel-doc tool complains about mismatches between
kernel-doc headers and function definitions. Avoid that errors like
the following are reported when building the UFS driver with W=1:

drivers/scsi/ufs/tc-dwc-g210-pci.c:60: error: Cannot parse struct or union!
drivers/scsi/ufs/tc-dwc-g210-pltfrm.c:26: warning: cannot understand function 
prototype: 'struct ufs_hba_variant_ops tc_dwc_g210_20bit_pltfm_hba_vops = '

Signed-off-by: Bart Van Assche 
Cc: Vivek Gautam 
---
 drivers/scsi/ufs/tc-dwc-g210-pci.c|  4 +-
 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c |  2 +-
 drivers/scsi/ufs/ufshcd-pci.c |  7 ++-
 drivers/scsi/ufs/ufshcd.c | 94 +--
 4 files changed, 53 insertions(+), 54 deletions(-)

diff --git a/drivers/scsi/ufs/tc-dwc-g210-pci.c 
b/drivers/scsi/ufs/tc-dwc-g210-pci.c
index 325d5e14fc0d..2f41722a8c28 100644
--- a/drivers/scsi/ufs/tc-dwc-g210-pci.c
+++ b/drivers/scsi/ufs/tc-dwc-g210-pci.c
@@ -51,7 +51,7 @@ static int tc_dwc_g210_pci_runtime_idle(struct device *dev)
return ufshcd_runtime_idle(dev_get_drvdata(dev));
 }
 
-/**
+/*
  * struct ufs_hba_dwc_vops - UFS DWC specific variant operations
  */
 static struct ufs_hba_variant_ops tc_dwc_g210_pci_hba_vops = {
@@ -71,7 +71,7 @@ static void tc_dwc_g210_pci_shutdown(struct pci_dev *pdev)
 /**
  * tc_dwc_g210_pci_remove - de-allocate PCI/SCSI host and host memory space
  * data structure memory
- * @pdev - pointer to PCI handle
+ * @pdev: pointer to PCI handle
  */
 static void tc_dwc_g210_pci_remove(struct pci_dev *pdev)
 {
diff --git a/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c 
b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
index 2d3f5270f875..6dfe5a9206e9 100644
--- a/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
+++ b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
@@ -20,7 +20,7 @@
 #include "ufshcd-dwc.h"
 #include "tc-dwc-g210.h"
 
-/**
+/*
  * UFS DWC specific variant operations
  */
 static struct ufs_hba_variant_ops tc_dwc_g210_20bit_pltfm_hba_vops = {
diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
index 925b0ec7ec54..ffe6f82182ba 100644
--- a/drivers/scsi/ufs/ufshcd-pci.c
+++ b/drivers/scsi/ufs/ufshcd-pci.c
@@ -75,8 +75,7 @@ static struct ufs_hba_variant_ops ufs_intel_cnl_hba_vops = {
 #ifdef CONFIG_PM_SLEEP
 /**
  * ufshcd_pci_suspend - suspend power management function
- * @pdev: pointer to PCI device handle
- * @state: power state
+ * @dev: pointer to PCI device handle
  *
  * Returns 0 if successful
  * Returns non-zero otherwise
@@ -88,7 +87,7 @@ static int ufshcd_pci_suspend(struct device *dev)
 
 /**
  * ufshcd_pci_resume - resume power management function
- * @pdev: pointer to PCI device handle
+ * @dev: pointer to PCI device handle
  *
  * Returns 0 if successful
  * Returns non-zero otherwise
@@ -126,7 +125,7 @@ static void ufshcd_pci_shutdown(struct pci_dev *pdev)
 /**
  * ufshcd_pci_remove - de-allocate PCI/SCSI host and host memory space
  * data structure memory
- * @pdev - pointer to PCI handle
+ * @pdev: pointer to PCI handle
  */
 static void ufshcd_pci_remove(struct pci_dev *pdev)
 {
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index c7da2c185990..15d0f44563f8 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -87,6 +87,8 @@
 /* Interrupt aggregation default timeout, unit: 40us */
 #define INT_AGGR_DEF_TO0x02
 
+#define ASCII_STD true
+
 #define ufshcd_toggle_vreg(_dev, _vreg, _on)   \
({  \
int _ret;   \
@@ -523,7 +525,7 @@ int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, 
u32 mask,
 
 /**
  * ufshcd_get_intr_mask - Get the interrupt bit mask
- * @hba - Pointer to adapter instance
+ * @hba: Pointer to adapter instance
  *
  * Returns interrupt bit mask per version
  */
@@ -550,7 +552,7 @@ static inline u32 ufshcd_get_intr_mask(struct ufs_hba *hba)
 
 /**
  * ufshcd_get_ufs_version - Get the UFS version supported by the HBA
- * @hba - Pointer to adapter instance
+ * @hba: Pointer to adapter instance
  *
  * Returns UFSHCI version supported by the controller
  */
@@ -577,7 +579,7 @@ static inline bool ufshcd_is_device_present(struct ufs_hba 
*hba)
 
 /**
  * ufshcd_get_tr_ocs - Get the UTRD Overall Command Status
- * @lrb: pointer to local command reference block
+ * @lrbp: pointer to local command reference block
  *
  * This function is used to get the OCS field from UTRD
  * Returns the OCS field in the UTRD
@@ -1759,7 +1761,7 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned 
int task_tag)
 
 /**
  * ufshcd_copy_sense_data - Copy sense data in case of check condition
- * @lrb - pointer to local reference block
+ * @lrbp: pointer to local reference block
  */
 static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp)
 {
@@ -1781,7 +1783,7 @@ static 

Re: [PATCH] megaraid_sas: Do not use 32-bit atomic request descriptor for Ventura controllers

2018-02-13 Thread Tomas Henzl
On 02/12/2018 06:39 AM, Shivasharan S wrote:
> Problem Statement:
> Sending I/O through 32 bit descriptors to Ventura series of controller
> results in IO timeout on certain conditions.
>  
> This error only occurs on systems with high I/O activity on
> Ventura series controllers.
>   
> Changes in this patch will prevent driver from using 32 bit descriptor
> and use 64 bit Descriptors.
>
> Cc: 
> Signed-off-by: Kashyap Desai 
> Signed-off-by: Shivasharan S 
> ---
>  drivers/scsi/megaraid/megaraid_sas_fusion.c | 37 
> ++---
>  1 file changed, 12 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
> b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> index 073ced07e662..09f2bdb14b0a 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> @@ -226,26 +226,21 @@ static void
>  megasas_fire_cmd_fusion(struct megasas_instance *instance,
>   union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc)
>  {
> - if (instance->adapter_type == VENTURA_SERIES)
> - writel(le32_to_cpu(req_desc->u.low),
> - >reg_set->inbound_single_queue_port);
> - else {
>  #if defined(writeq) && defined(CONFIG_64BIT)
> - u64 req_data = (((u64)le32_to_cpu(req_desc->u.high) << 32) |
> - le32_to_cpu(req_desc->u.low));
> + u64 req_data = (((u64)le32_to_cpu(req_desc->u.high) << 32) |
> + le32_to_cpu(req_desc->u.low));
>  
> - writeq(req_data, >reg_set->inbound_low_queue_port);
> + writeq(req_data, >reg_set->inbound_low_queue_port);
>  #else
> - unsigned long flags;
> - spin_lock_irqsave(>hba_lock, flags);
> - writel(le32_to_cpu(req_desc->u.low),
> - >reg_set->inbound_low_queue_port);
> - writel(le32_to_cpu(req_desc->u.high),
> - >reg_set->inbound_high_queue_port);
> - mmiowb();
> - spin_unlock_irqrestore(>hba_lock, flags);
> + unsigned long flags;
> + spin_lock_irqsave(>hba_lock, flags);
> + writel(le32_to_cpu(req_desc->u.low),
> + >reg_set->inbound_low_queue_port);
> + writel(le32_to_cpu(req_desc->u.high),
> + >reg_set->inbound_high_queue_port);
> + mmiowb();
> + spin_unlock_irqrestore(>hba_lock, flags);
>  #endif
> - }
>  }
>  
>  /**
> @@ -982,7 +977,6 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
>   const char *sys_info;
>   MFI_CAPABILITIES *drv_ops;
>   u32 scratch_pad_2;
> - unsigned long flags;
>   ktime_t time;
>   bool cur_fw_64bit_dma_capable;
>  
> @@ -1121,14 +1115,7 @@ megasas_ioc_init_fusion(struct megasas_instance 
> *instance)
>   break;
>   }
>  
> - /* For Ventura also IOC INIT required 64 bit Descriptor write. */
> - spin_lock_irqsave(>hba_lock, flags);
> - writel(le32_to_cpu(req_desc.u.low),
> ->reg_set->inbound_low_queue_port);
> - writel(le32_to_cpu(req_desc.u.high),
> ->reg_set->inbound_high_queue_port);
> - mmiowb();
> - spin_unlock_irqrestore(>hba_lock, flags);
> + megasas_fire_cmd_fusion(instance, _desc);
>  
>   wait_and_poll(instance, cmd, MFI_POLL_TIMEOUT_SECS);
>  

Reviewed-by: Tomas Henzl 

Please also remove the text
 * Ventura supports 32 bit Descriptor.
 * Prior to Ventura (12G) MR controller supports 64 bit Descriptor.
from the function description (not urgent may happen later)

Thanks,
Tomas




Re: UFS writing request failure handling

2018-02-13 Thread Bean Huo (beanhuo)
Hi Bart
Thanks for your answer.
I looked at SCSI core source codes these days, UFS also follows SCSI core error 
handling.
There is already re-issue behavior, and assign 5 retries for each UFS request 
if there is error.

>
>On 02/12/18 04:21, Bean Huo (beanhuo) wrote
>> I am looking at UFS error handling, but I didn't notice re-issues
>> requests with UTP error to the host controller. According UFS host
>> spec, "host software either completes the request that had the error
>> and requests still outstanding with error to higher level software, or
>> re-issues these requests to the host controller". For the latest Linux
>> UFS driver, it belongs to former one? If I am wrong, please correct
>> me.
>
>Hello Bean,
>
>I'm afraid that reissuing a failed write forever could cause an infinite loop 
>that
>makes e.g. user space processes unkillable or that could cause an orderly
>system shutdown to hang. I'm not sure that we want such behavior.
>
>If you want to learn more about how the SCSI core handles failed writes,
>please have a look at scsi_decide_disposition(). A possible approach to
>modify the error handling behavior is to stack a dm driver on top of the SCSI
>core that implements the desired behavior.
>
>Bart.


[bug report] scsi: myrs: Add Mylex RAID controller (SCSI interface)

2018-02-13 Thread Dan Carpenter
Hello Hannes Reinecke,

The patch 8a8606895947: "scsi: myrs: Add Mylex RAID controller (SCSI
interface)" from Jan 24, 2018, leads to the following static checker
warning:

drivers/scsi/myrs.c:479 myrs_get_event()
warn: right shifting more than type allows 16 vs 16

drivers/scsi/myrs.c
   461  static unsigned char
   462  myrs_get_event(myrs_hba *cs, unsigned short event_num,
 

   463 myrs_event *event_buf)
   464  {
   465  struct pci_dev *pdev = cs->pdev;
   466  dma_addr_t event_addr;
   467  myrs_cmdblk *cmd_blk = >mcmd_blk;
   468  myrs_cmd_mbox *mbox = _blk->mbox;
   469  myrs_sgl *sgl;
   470  unsigned char status;
   471  
   472  event_addr = dma_map_single(>dev, event_buf,
   473  sizeof(myrs_event), 
DMA_FROM_DEVICE);
   474  if (dma_mapping_error(>dev, event_addr))
   475  return DAC960_V2_AbnormalCompletion;
   476  
   477  mbox->GetEvent.opcode = DAC960_V2_IOCTL;
   478  mbox->GetEvent.dma_size = sizeof(myrs_event);
   479  mbox->GetEvent.evnum_upper = event_num >> 16;
 ^^^

This is always going to be zero.

   480  mbox->GetEvent.ctlr_num = 0;
   481  mbox->GetEvent.ioctl_opcode = DAC960_V2_GetEvent;
   482  mbox->GetEvent.evnum_lower = event_num & 0x;
   483  sgl = >GetEvent.dma_addr;
   484  sgl->sge[0].sge_addr = event_addr;
   485  sgl->sge[0].sge_count = mbox->GetEvent.dma_size;
   486  myrs_exec_cmd(cs, cmd_blk);
   487  status = cmd_blk->status;
   488  dma_unmap_single(>dev, event_addr,
   489   sizeof(myrs_event), DMA_FROM_DEVICE);
   490  
   491  return status;
   492  }

This warning is probably a false positive which you can ignore but what
made me question it was looking at the caller:

drivers/scsi/myrs.c
    static void myrs_monitor(struct work_struct *work)
  2223  {
  2224  myrs_hba *cs = container_of(work, myrs_hba, monitor_work.work);
  2225  struct Scsi_Host *shost = cs->host;
  2226  myrs_ctlr_info *info = cs->ctlr_info;
  2227  unsigned int epoch = cs->fwstat_buf->epoch;
  2228  unsigned long interval = MYRS_PRIMARY_MONITOR_INTERVAL;
  2229  unsigned char status;
  2230  
  2231  dev_dbg(>shost_gendev, "monitor tick\n");
  2232  
  2233  status = myrs_get_fwstatus(cs);
  2234  
  2235  if (cs->needs_update) {
  2236  cs->needs_update = false;
  2237  mutex_lock(>cinfo_mutex);
  2238  status = myrs_get_ctlr_info(cs);
  2239  mutex_unlock(>cinfo_mutex);
  2240  }
  2241  if (cs->fwstat_buf->next_evseq - cs->next_evseq > 0) {
  2242  status = myrs_get_event(cs, cs->next_evseq,
^^
This is an int.

  2243  cs->event_buf);
  2244  if (status == DAC960_V2_NormalCompletion) {
  2245  myrs_log_event(cs, cs->event_buf);
  2246  cs->next_evseq++;

And I guess this is where we set cs->next_evseq.

  2247  interval = 1;
  2248  }
  2249  }

regards,
dan carpenter


Re: [PATCH] scsi: ata: don't reset three times if device is offline for SAS host

2018-02-13 Thread Tejun Heo
Hello,

On Tue, Feb 13, 2018 at 09:44:53AM +0800, chenxiang (M) wrote:
> For those drivers using libsas,  i think they have the same issue.
> It takes about 1 minute to
> recover but actually device is gone, so this recover is useless for
> this scenario (when enter EH,
> all normal IOs are blocked actually, so it will cause normal IOs are
> blocked one more minute which
> user doesn't want to).

Right, it'd block other devices sharing the port.  Doesn't sas map
each ata device to its own port tho?

> Actually in sas_ata_hard_reset, there are two situations returned
> -ENODEV which represent device is gone:
> - LLDD directly returns -ENODEV through lldd_I_T_nexus_reset;
> - It sends SMP DISCOVER to check local phy in smp_ata_check_ready,
> and find it is gone;

So, if there are real consequences, we can definitely add a way to
short-circuit the recovery logic but let's do that by adding proper
signaling rathr than testing for driver type.

Thanks.

-- 
tejun


Re: [PATCH] qla4xxx: skip error recovery in case of register disconnect.

2018-02-13 Thread Tomas Henzl
On 02/12/2018 07:48 AM, Manish Rangankar wrote:
> A system crashes when continuously removing/re-adding
> the storage controller.
>
> Signed-off-by: Manish Rangankar 

Reviewed-by: Tomas Henzl 



Re: [PATCH] qla2xxx: Fix NULL pointer crash due to active timer for ABTS

2018-02-13 Thread John Garry

On 12/02/2018 18:28, Himanshu Madhani wrote:

This patch fixes NULL pointer crash due to active timer running
for abort IOCB.


From crash dump analysis it was discoverd that get_next_timer_interrupt()

encountered a corrupted entry on the timer list.

 #9 [95e1f6f0fd40] page_fault at 914fe8f8
[exception RIP: get_next_timer_interrupt+440]
RIP: 90ea3088  RSP: 95e1f6f0fdf0  RFLAGS: 00010013
RAX: 95e1f6451028  RBX: 000218e2389e5f40  RCX: 0001232ad600
RDX: 0001  RSI: 95e1f6f0fdf0  RDI: 01232ad6
RBP: 95e1f6f0fe40   R8: 95e1f6451188   R9: 0001
R10: 0016  R11: 0016  R12: 0001232ad5f6
R13: 95e1f645  R14: 95e1f6f0fdf8  R15: 95e1f6f0fe10
ORIG_RAX:   CS: 0010  SS: 0018

 Looking at the assembly of get_next_timer_interrupt(), address came
 from %r8 (95e1f6451188) which is pointing to list_head with single
 entry at 95e5ff621178.

 0x90ea307a :  mov(%r8),%rdx
 0x90ea307d :  cmp%r8,%rdx
 0x90ea3080 :  je 0x90ea30a7 

 0x90ea3082 :  nopw   0x0(%rax,%rax,1)
 0x90ea3088 :  testb  $0x1,0x18(%rdx)

 crash> rd 95e1f6451188 10
 95e1f6451188:  95e5ff621178 95e5ff621178   x.b.x.b.
 95e1f6451198:  95e1f6451198 95e1f6451198   ..E...E.
 95e1f64511a8:  95e1f64511a8 95e1f64511a8   ..E...E.
 95e1f64511b8:  95e77cf509a0 95e77cf509a0   ...|...|
 95e1f64511c8:  95e1f64511c8 95e1f64511c8   ..E...E.

 crash> rd 95e5ff621178 10
 95e5ff621178:  0001 95e15936aa00   ..6Y
 95e5ff621188:      
 95e5ff621198:  00a0 0010   
 95e5ff6211a8:  95e5ff621198 000c   ..b.
 95e5ff6211b8:  0f58 95e751f8d720   X... ..Q

 95e5ff621178 belongs to freed mempool object at 95e5ff621080.

 CACHENAME OBJSIZE  ALLOCATED TOTAL  SLABS  
SSIZE
 95dc7fd74d00 mnt_cache384  19785 24948594
16k
   SLAB  MEMORYNODE  TOTAL  ALLOCATED  FREE
   dc5dabfd8800  95e5ff62 1 42 2913
   FREE / [ALLOCATED]
95e5ff621080  (cpu 6 cache)

 Examining the contents of that memory reveals a pointer to a constant
 string in the driver, "abort\0", which is set by qla24xx_async_abort_cmd().

 crash> rd c059277c 20
 c059277c:  6e490074726f6261 0074707572726574   abort.Interrupt.
 c059278c:  00676e696c6c6f50 6920726576697244   Polling.Driver i
 c059279c:  646f6d207325206e 6974736554000a65   n %s mode..Testi
 c05927ac:  636976656420676e 786c252074612065   ng device at %lx
 c05927bc:  6b63656843000a2e 646f727020676e69   ...Checking prod
 c05927cc:  6f20444920746375 0a2e706968632066   uct ID of chip..
 c05927dc:  5120646e756f4600 204130303232414c   .Found QLA2200A
 c05927ec:  43000a2e70696843 20676e696b636568   Chip...Checking
 c05927fc:  65786f626c69616d 6c636e69000a2e73   mailboxes...incl
 c059280c:  756e696c2f656475 616d2d616d642f78   ude/linux/dma-ma

 crash> struct -ox srb_iocb
 struct srb_iocb {
   union {
   struct {...} logio;
   struct {...} els_logo;
   struct {...} tmf;
   struct {...} fxiocb;
   struct {...} abt;
   struct ct_arg ctarg;
   struct {...} mbx;
   struct {...} nack;
[0x0 ] } u;
[0xb8] struct timer_list timer;
[0x108] void (*timeout)(void *);
 }
 SIZE: 0x110

 crash> ! bc
 ibase=16
 obase=10
 B8+40
 F8

 The object is a srb_t, and at offset 0xf8 within that structure
 (i.e. 95e5ff621080 + f8 -> 95e5ff621178) is a struct timer_list.

Cc:  #4.4+
Signed-off-by: Himanshu Madhani 
---
Hi Martin,

This patch addresses crash due to NULL pointer access because driver
left active timer running for abort IOCB.

Please apply this patch to 4.16/scsi-fixes at your earliest convenience.

Thanks,
Himanshu
---
 drivers/scsi/qla2xxx/qla_init.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 2dea1129d396..04870621e712 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1527,6 +1527,7 @@ qla24xx_abort_sp_done(void *ptr, int res)
srb_t *sp = ptr;
struct srb_iocb *abt = >u.iocb_cmd;

+   del_timer(>u.iocb_cmd.timer);


Hi,

I am not familiar with this 

Re: [PATCH] qla2xxx: Fix NULL pointer crash due to active timer for ABTS

2018-02-13 Thread Johannes Thumshirn
Thanks Himanshu,
Reviewed-by: Johannes Thumshirn 

Do you happen to know which commit it actually fixes?

-- 
Johannes Thumshirn                                          Storage
jthu
msh...@suse.de                                +49 911 74053 689
SUSE
LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane
Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38
9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


[PATCH v8 3/5] arm64: dts: add ufs dts node

2018-02-13 Thread Li Wei
arm64: dts: add ufs node for Hisilicon.

Signed-off-by: Li Wei 
---
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi 
b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
index ab0b95ba5ae5..d0dfa97fdad1 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
@@ -904,6 +904,25 @@
reset-gpios = < 1 0 >;
};
 
+   /* UFS */
+   ufs: ufs@ff3b {
+   compatible = "hisilicon,hi3660-ufs", "jedec,ufs-1.1";
+   /* 0: HCI standard */
+   /* 1: UFS SYS CTRL */
+   reg = <0x0 0xff3b 0x0 0x1000>,
+   <0x0 0xff3b1000 0x0 0x1000>;
+   interrupt-parent = <>;
+   interrupts = ;
+   clocks = <_ctrl HI3660_CLK_GATE_UFSIO_REF>,
+   <_ctrl HI3660_CLK_GATE_UFSPHY_CFG>;
+   clock-names = "ref_clk", "phy_clk";
+   /* offset: 0x84; bit: 12 */
+   /* offset: 0x84; bit: 7  */
+   resets = <_rst 0x84 12>,
+   <_rst 0x84 7>;
+   reset-names = "rst", "assert";
+   };
+
/* SD */
dwmmc1: dwmmc1@ff37f000 {
#address-cells = <1>;
-- 
2.15.0



[PATCH v8 2/5] dt-bindings: scsi: ufs: add document for hisi-ufs

2018-02-13 Thread Li Wei
add ufs node document for Hisilicon.

Signed-off-by: Li Wei 
---
 Documentation/devicetree/bindings/ufs/ufs-hisi.txt | 37 ++
 1 file changed, 37 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ufs/ufs-hisi.txt

diff --git a/Documentation/devicetree/bindings/ufs/ufs-hisi.txt 
b/Documentation/devicetree/bindings/ufs/ufs-hisi.txt
new file mode 100644
index ..0d21b57496cf
--- /dev/null
+++ b/Documentation/devicetree/bindings/ufs/ufs-hisi.txt
@@ -0,0 +1,37 @@
+* Hisilicon Universal Flash Storage (UFS) Host Controller
+
+UFS nodes are defined to describe on-chip UFS hardware macro.
+Each UFS Host Controller should have its own node.
+
+Required properties:
+- compatible: compatible list, contains one of the following -
+   "hisilicon,hi3660-ufs", "jedec,ufs-1.1" 
for hisi ufs
+   host controller present on Hi36xx 
chipset.
+- reg   : should contain UFS register address space & UFS SYS CTRL 
register address,
+- interrupt-parent  : interrupt device
+- interrupts: interrupt number
+- clocks   : List of phandle and clock specifier pairs
+- clock-names   : List of clock input name strings sorted in the same
+   order as the clocks property. 
"ref_clk", "phy_clk" is optional
+- resets: reset node register, one reset the clk and the other 
reset the controller
+- reset-names   : describe reset node register
+
+Example:
+
+   ufs: ufs@ff3b {
+   compatible = "hisilicon,hi3660-ufs", "jedec,ufs-1.1";
+   /* 0: HCI standard */
+   /* 1: UFS SYS CTRL */
+   reg = <0x0 0xff3b 0x0 0x1000>,
+   <0x0 0xff3b1000 0x0 0x1000>;
+   interrupt-parent = <>;
+   interrupts = ;
+   clocks = <_ctrl HI3660_CLK_GATE_UFSIO_REF>,
+   <_ctrl HI3660_CLK_GATE_UFSPHY_CFG>;
+   clock-names = "ref_clk", "phy_clk";
+   /* offset: 0x84; bit: 12 */
+   /* offset: 0x84; bit: 7  */
+   resets = <_rst 0x84 12>,
+   <_rst 0x84 7>;
+   reset-names = "rst", "assert";
+   };
-- 
2.15.0



[PATCH v8 4/5] arm64: defconfig: enable configs for Hisilicon ufs

2018-02-13 Thread Li Wei
This enable configs for Hisilicon Hi UFS driver.

Signed-off-by: Li Wei 
Signed-off-by: Zhangfei Gao 
Signed-off-by: Guodong Xu 
---
 arch/arm64/configs/defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 6356c6da34ea..fa6f921eed86 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -174,6 +174,9 @@ CONFIG_BLK_DEV_SD=y
 CONFIG_SCSI_SAS_ATA=y
 CONFIG_SCSI_HISI_SAS=y
 CONFIG_SCSI_HISI_SAS_PCI=y
+CONFIG_SCSI_UFSHCD=y
+CONFIG_SCSI_UFSHCD_PLATFORM=y
+CONFIG_SCSI_UFS_HISI=y
 CONFIG_ATA=y
 CONFIG_SATA_AHCI=y
 CONFIG_SATA_AHCI_PLATFORM=y
-- 
2.15.0



Re: [PATCH] libsas: Fix kernel-doc headers

2018-02-13 Thread John Garry

On 12/02/2018 18:45, Bart Van Assche wrote:

Avoid that building with W=1 causes the kernel-doc tool to complain
about the libsas kernel-doc headers.



Hi Bart,

A few comments, below:


Signed-off-by: Bart Van Assche 
---
 drivers/scsi/libsas/sas_discover.c |  6 +++---
 drivers/scsi/libsas/sas_expander.c | 20 ++--
 drivers/scsi/libsas/sas_init.c |  2 +-
 drivers/scsi/libsas/sas_port.c |  1 +
 4 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/libsas/sas_discover.c 
b/drivers/scsi/libsas/sas_discover.c
index e4fd078e4175..8a184c7f5f56 100644
--- a/drivers/scsi/libsas/sas_discover.c
+++ b/drivers/scsi/libsas/sas_discover.c
@@ -279,7 +279,7 @@ static void sas_resume_devices(struct work_struct *work)

 /**
  * sas_discover_end_dev -- discover an end device (SSP, etc)
- * @end: pointer to domain device of interest
+ * @dev: pointer to domain device of interest
  *
  * See comment in sas_discover_sata().
  */
@@ -429,7 +429,7 @@ void sas_device_set_phy(struct domain_device *dev, struct 
sas_port *port)

 /**
  * sas_discover_domain -- discover the domain
- * @port: port to the domain of interest
+ * @work: work structure embedded in port to the domain of interest
  *
  * NOTE: this process _must_ quit (return) as soon as any connection
  * errors are encountered.  Connection recovery is done elsewhere.
@@ -571,7 +571,7 @@ int sas_discover_event(struct asd_sas_port *port, enum 
discover_event ev)
return 0;
 }

-/**
+/*
  * sas_init_disc -- initialize the discovery struct in the port
  * @port: pointer to struct port


I wonder why you get no complaint that @disc argument is not mentioned, 
here's the code:

/**
 * sas_init_disc -- initialize the discovery struct in the port
 * @port: pointer to struct port
 *
 * Called when the ports are being initialized.
 */
void sas_init_disc(struct sas_discovery *disc, struct asd_sas_port *port)
{


  *
diff --git a/drivers/scsi/libsas/sas_expander.c 
b/drivers/scsi/libsas/sas_expander.c
index 6a4f8198b78e..6e7a128619f4 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -1171,8 +1171,8 @@ static int sas_check_level_subtractive_boundary(struct 
domain_device *dev)
 }
 /**
  * sas_ex_discover_devices -- discover devices attached to this expander
- * dev: pointer to the expander domain device
- * single: if you want to do a single phy, else set to -1;
+ * @dev: pointer to the expander domain device
+ * @single: if you want to do a single phy, else set to -1;
  *
  * Configure this expander for use with its devices and register the
  * devices of this expander.
@@ -1527,11 +1527,11 @@ static int sas_configure_phy(struct domain_device *dev, 
int phy_id,
return res;
 }

-/**
+/*
  * sas_configure_parent -- configure routing table of parent
- * parent: parent expander
- * child: child expander
- * sas_addr: SAS port identifier of device directly attached to child
+ * @parent: parent expander
+ * @child: child expander
+ * @sas_addr: SAS port identifier of device directly attached to child


and no mention of @include here


  */
 static int sas_configure_parent(struct domain_device *parent,
struct domain_device *child,
@@ -1571,8 +1571,8 @@ static int sas_configure_parent(struct domain_device 
*parent,

 /**
  * sas_configure_routing -- configure routing
- * dev: expander device
- * sas_addr: port identifier of device directly attached to the expander device
+ * @dev: expander device
+ * @sas_addr: port identifier of device directly attached to the expander 
device
  */
 static int sas_configure_routing(struct domain_device *dev, u8 *sas_addr)
 {
@@ -1590,7 +1590,7 @@ static int sas_disable_routing(struct domain_device *dev, 
 u8 *sas_addr)

 /**
  * sas_discover_expander -- expander discovery
- * @ex: pointer to expander domain device
+ * @dev: pointer to expander domain device
  *
  * See comment in sas_discover_sata().
  */
@@ -2112,7 +2112,7 @@ static int sas_rediscover(struct domain_device *dev, 
const int phy_id)

 /**
  * sas_revalidate_domain -- revalidate the domain


This function name seems incorrect. Here is the code as I see it on 
linux-next:

/**
 * sas_revalidate_domain -- revalidate the domain
 * @port: port to the domain of interest
 *
 * NOTE: this process _must_ quit (return) as soon as any connection
 * errors are encountered.  Connection recovery is done elsewhere.
 * Discover process only interrogates devices in order to discover the
 * domain.
 */
int sas_ex_revalidate_domain(struct domain_device *port_dev)
{

And I would write "port domain device"


- * @port: port to the domain of interest
+ * @port_dev: port to the domain of interest
  *
  * NOTE: this process _must_ quit (return) as soon as any connection
  * errors are encountered.  Connection recovery is done elsewhere.
diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c
index c81a63b5dc71..ede0af78144f 100644
--- 

[PATCH v8 0/5] scsi: ufs: add ufs driver code for Hisilicon Hi3660 SoC

2018-02-13 Thread Li Wei
This patchset adds driver support for UFS for Hi3660 SoC. It is verified on 
HiKey960 board.

Li Wei (5):
  scsi: ufs: add Hisilicon ufs driver code
  dt-bindings: scsi: ufs: add document for hisi-ufs
  arm64: dts: add ufs dts node
  arm64: defconfig: enable configs for Hisilicon ufs
  arm64: defconfig: enable f2fs and squashfs

 Documentation/devicetree/bindings/ufs/ufs-hisi.txt |  37 ++
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi  |  19 +
 arch/arm64/configs/defconfig   |  11 +
 drivers/scsi/ufs/Kconfig   |   9 +
 drivers/scsi/ufs/Makefile  |   1 +
 drivers/scsi/ufs/ufs-hisi.c| 623 +
 drivers/scsi/ufs/ufs-hisi.h| 116 
 7 files changed, 816 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ufs/ufs-hisi.txt
 create mode 100644 drivers/scsi/ufs/ufs-hisi.c
 create mode 100644 drivers/scsi/ufs/ufs-hisi.h

-- 
Major changes in v7:
 - solve review comments from Philippe Ombredanne.
   *use the new SPDX license ids instead of the GNU General Public License.

Major changes in v8:
 - solve review comments from zhangfei.
   *Add Version history.
 - solve review comments from Rob Herring.
   *remove freq-table-hz.
 -  solve review comments from Riku Voipio.
   *Add MODULE_DEVICE_TABLE for ufs driver.
2.15.0



[PATCH v8 5/5] arm64: defconfig: enable f2fs and squashfs

2018-02-13 Thread Li Wei
Partitions in HiKey960 are formatted as f2fs and squashfs.
f2fs is for userdata; squashfs is for system. Both partitions are required
by Android.

Signed-off-by: Li Wei 
Signed-off-by: Zhangfei Gao 
Signed-off-by: Guodong Xu 
---
 arch/arm64/configs/defconfig | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index fa6f921eed86..7be4ee2ac680 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -572,6 +572,7 @@ CONFIG_ACPI_APEI_GHES=y
 CONFIG_ACPI_APEI_PCIEAER=y
 CONFIG_EXT2_FS=y
 CONFIG_EXT3_FS=y
+CONFIG_F2FS_FS=y
 CONFIG_EXT4_FS_POSIX_ACL=y
 CONFIG_BTRFS_FS=m
 CONFIG_BTRFS_FS_POSIX_ACL=y
@@ -587,6 +588,13 @@ CONFIG_HUGETLBFS=y
 CONFIG_CONFIGFS_FS=y
 CONFIG_EFIVAR_FS=y
 CONFIG_SQUASHFS=y
+CONFIG_SQUASHFS_FILE_DIRECT=y
+CONFIG_SQUASHFS_DECOMP_MULTI_PERCPU=y
+CONFIG_SQUASHFS_XATTR=y
+CONFIG_SQUASHFS_LZ4=y
+CONFIG_SQUASHFS_LZO=y
+CONFIG_SQUASHFS_XZ=y
+CONFIG_SQUASHFS_4K_DEVBLK_SIZE=y
 CONFIG_NFS_FS=y
 CONFIG_NFS_V4=y
 CONFIG_NFS_V4_1=y
-- 
2.15.0



[PATCH v8 1/5] scsi: ufs: add Hisilicon ufs driver code

2018-02-13 Thread Li Wei
add Hisilicon ufs driver code.

Signed-off-by: Li Wei 
Signed-off-by: Geng Jianfeng 
Signed-off-by: Zang Leigang 
Signed-off-by: Yu Jianfeng 
---
 drivers/scsi/ufs/Kconfig|   9 +
 drivers/scsi/ufs/Makefile   |   1 +
 drivers/scsi/ufs/ufs-hisi.c | 623 
 drivers/scsi/ufs/ufs-hisi.h | 116 +
 4 files changed, 749 insertions(+)
 create mode 100644 drivers/scsi/ufs/ufs-hisi.c
 create mode 100644 drivers/scsi/ufs/ufs-hisi.h

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index e27b4d4e6ae2..e09fe6ab3572 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -100,3 +100,12 @@ config SCSI_UFS_QCOM
 
  Select this if you have UFS controller on QCOM chipset.
  If unsure, say N.
+
+config SCSI_UFS_HISI
+   tristate "Hisilicon specific hooks to UFS controller platform driver"
+   depends on (ARCH_HISI || COMPILE_TEST) && SCSI_UFSHCD_PLATFORM
+   ---help---
+ This selects the Hisilicon specific additions to UFSHCD platform 
driver.
+
+ Select this if you have UFS controller on Hisilicon chipset.
+ If unsure, say N.
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index 9310c6c83041..e1ebf1031437 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
 obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
+obj-$(CONFIG_SCSI_UFS_HISI) += ufs-hisi.o
diff --git a/drivers/scsi/ufs/ufs-hisi.c b/drivers/scsi/ufs/ufs-hisi.c
new file mode 100644
index ..c1eaf862a44c
--- /dev/null
+++ b/drivers/scsi/ufs/ufs-hisi.c
@@ -0,0 +1,623 @@
+/*
+ * HiSilicon Hi UFS Driver
+ *
+ * Copyright (c) 2016-2017 Linaro Ltd.
+ * Copyright (c) 2016-2017 HiSilicon Technologies Co., Ltd.
+ *
+ * Released under the GPLv2 only.
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ufshcd.h"
+#include "ufshcd-pltfrm.h"
+#include "unipro.h"
+#include "ufs-hisi.h"
+#include "ufshci.h"
+
+static int ufs_hisi_check_hibern8(struct ufs_hba *hba)
+{
+   int err = 0;
+   u32 tx_fsm_val_0 = 0;
+   u32 tx_fsm_val_1 = 0;
+   unsigned long timeout = jiffies + msecs_to_jiffies(HBRN8_POLL_TOUT_MS);
+
+   do {
+   err = ufshcd_dme_get(hba, UIC_ARG_MIB_SEL(MPHY_TX_FSM_STATE, 0),
+ _fsm_val_0);
+   err |= ufshcd_dme_get(hba,
+   UIC_ARG_MIB_SEL(MPHY_TX_FSM_STATE, 1), _fsm_val_1);
+   if (err || (tx_fsm_val_0 == TX_FSM_HIBERN8 &&
+   tx_fsm_val_1 == TX_FSM_HIBERN8))
+   break;
+
+   /* sleep for max. 200us */
+   usleep_range(100, 200);
+   } while (time_before(jiffies, timeout));
+
+   /*
+* we might have scheduled out for long during polling so
+* check the state again.
+*/
+   if (time_after(jiffies, timeout)) {
+   err = ufshcd_dme_get(hba, UIC_ARG_MIB_SEL(MPHY_TX_FSM_STATE, 0),
+_fsm_val_0);
+   err |= ufshcd_dme_get(hba,
+UIC_ARG_MIB_SEL(MPHY_TX_FSM_STATE, 1), _fsm_val_1);
+   }
+
+   if (err) {
+   dev_err(hba->dev, "%s: unable to get TX_FSM_STATE, err %d\n",
+   __func__, err);
+   } else if (tx_fsm_val_0 != TX_FSM_HIBERN8 ||
+tx_fsm_val_1 != TX_FSM_HIBERN8) {
+   err = -1;
+   dev_err(hba->dev, "%s: invalid TX_FSM_STATE, lane0 = %d, lane1 
= %d\n",
+   __func__, tx_fsm_val_0, tx_fsm_val_1);
+   }
+
+   return err;
+}
+
+static void ufs_hi3660_clk_init(struct ufs_hba *hba)
+{
+   struct ufs_hisi_host *host = ufshcd_get_variant(hba);
+
+   ufs_sys_ctrl_clr_bits(host, BIT_SYSCTRL_REF_CLOCK_EN, PHY_CLK_CTRL);
+   if (ufs_sys_ctrl_readl(host, PHY_CLK_CTRL) & BIT_SYSCTRL_REF_CLOCK_EN)
+   mdelay(1);
+   /* use abb clk */
+   ufs_sys_ctrl_clr_bits(host, BIT_UFS_REFCLK_SRC_SEl, UFS_SYSCTRL);
+   ufs_sys_ctrl_clr_bits(host, BIT_UFS_REFCLK_ISO_EN, PHY_ISO_EN);
+   /* open mphy ref clk */
+   ufs_sys_ctrl_set_bits(host, BIT_SYSCTRL_REF_CLOCK_EN, PHY_CLK_CTRL);
+}
+
+static void ufs_hi3660_soc_init(struct ufs_hba *hba)
+{
+   struct ufs_hisi_host *host = ufshcd_get_variant(hba);
+   u32 reg;
+
+   if (!IS_ERR(host->rst))
+   reset_control_assert(host->rst);
+
+   /* HC_PSW powerup */
+   ufs_sys_ctrl_set_bits(host, BIT_UFS_PSW_MTCMOS_EN, PSW_POWER_CTRL);
+   udelay(10);
+   /* notify PWR ready */
+   ufs_sys_ctrl_set_bits(host, BIT_SYSCTRL_PWR_READY, HC_LP_CTRL);
+   

Re: [PATCH] megaraid_sas: Do not use 32-bit atomic request descriptor for Ventura controllers

2018-02-13 Thread Hannes Reinecke
On 02/12/2018 06:39 AM, Shivasharan S wrote:
> Problem Statement:
> Sending I/O through 32 bit descriptors to Ventura series of controller
> results in IO timeout on certain conditions.
>  
> This error only occurs on systems with high I/O activity on
> Ventura series controllers.
>   
> Changes in this patch will prevent driver from using 32 bit descriptor
> and use 64 bit Descriptors.
> 
> Cc: 
> Signed-off-by: Kashyap Desai 
> Signed-off-by: Shivasharan S 
> ---
>  drivers/scsi/megaraid/megaraid_sas_fusion.c | 37 
> ++---
>  1 file changed, 12 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
> b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> index 073ced07e662..09f2bdb14b0a 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> @@ -226,26 +226,21 @@ static void
>  megasas_fire_cmd_fusion(struct megasas_instance *instance,
>   union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc)
>  {
> - if (instance->adapter_type == VENTURA_SERIES)
> - writel(le32_to_cpu(req_desc->u.low),
> - >reg_set->inbound_single_queue_port);
> - else {
>  #if defined(writeq) && defined(CONFIG_64BIT)
> - u64 req_data = (((u64)le32_to_cpu(req_desc->u.high) << 32) |
> - le32_to_cpu(req_desc->u.low));
> + u64 req_data = (((u64)le32_to_cpu(req_desc->u.high) << 32) |
> + le32_to_cpu(req_desc->u.low));
>  
> - writeq(req_data, >reg_set->inbound_low_queue_port);
> + writeq(req_data, >reg_set->inbound_low_queue_port);
>  #else
> - unsigned long flags;
> - spin_lock_irqsave(>hba_lock, flags);
> - writel(le32_to_cpu(req_desc->u.low),
> - >reg_set->inbound_low_queue_port);
> - writel(le32_to_cpu(req_desc->u.high),
> - >reg_set->inbound_high_queue_port);
> - mmiowb();
> - spin_unlock_irqrestore(>hba_lock, flags);
> + unsigned long flags;
> + spin_lock_irqsave(>hba_lock, flags);
> + writel(le32_to_cpu(req_desc->u.low),
> + >reg_set->inbound_low_queue_port);
> + writel(le32_to_cpu(req_desc->u.high),
> + >reg_set->inbound_high_queue_port);
> + mmiowb();
> + spin_unlock_irqrestore(>hba_lock, flags);
>  #endif
> - }
>  }
>  
>  /**
> @@ -982,7 +977,6 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
>   const char *sys_info;
>   MFI_CAPABILITIES *drv_ops;
>   u32 scratch_pad_2;
> - unsigned long flags;
>   ktime_t time;
>   bool cur_fw_64bit_dma_capable;
>  
> @@ -1121,14 +1115,7 @@ megasas_ioc_init_fusion(struct megasas_instance 
> *instance)
>   break;
>   }
>  
> - /* For Ventura also IOC INIT required 64 bit Descriptor write. */
> - spin_lock_irqsave(>hba_lock, flags);
> - writel(le32_to_cpu(req_desc.u.low),
> ->reg_set->inbound_low_queue_port);
> - writel(le32_to_cpu(req_desc.u.high),
> ->reg_set->inbound_high_queue_port);
> - mmiowb();
> - spin_unlock_irqrestore(>hba_lock, flags);
> + megasas_fire_cmd_fusion(instance, _desc);
>  
>   wait_and_poll(instance, cmd, MFI_POLL_TIMEOUT_SECS);
>  
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH] mpt3sas: Do not use 32-bit atomic request descriptor for Ventura controllers

2018-02-13 Thread Hannes Reinecke
On 02/12/2018 06:47 AM, Shivasharan S wrote:
> From: Suganath Prabu S 
> 
> Problem Statement:
> Sending I/O through 32 bit descriptors to Ventura series of controller
> results in IO timeout on certain conditions.
>  
> This error only occurs on systems with high I/O activity on
> Ventura series controllers.
>   
> Changes in this patch will prevent driver from using 32 bit descriptor
> and use 64 bit Descriptors.
> 
> Cc: 
> Signed-off-by: Suganath Prabu S 
> Signed-off-by: Shivasharan S 
> ---
>  drivers/scsi/mpt3sas/mpt3sas_base.c | 121 
> 
>  drivers/scsi/mpt3sas/mpt3sas_base.h |   1 -
>  2 files changed, 122 deletions(-)
> 
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
> b/drivers/scsi/mpt3sas/mpt3sas_base.c
> index 13d6e4e..6051469 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
> @@ -3108,116 +3108,6 @@ _base_put_smid_default(struct MPT3SAS_ADAPTER *ioc, 
> u16 smid)
>  }
>  
>  /**
> -* _base_put_smid_scsi_io_atomic - send SCSI_IO request to firmware using
> -*   Atomic Request Descriptor
> -* @ioc: per adapter object
> -* @smid: system request message index
> -* @handle: device handle, unused in this function, for function type match
> -*
> -* Return nothing.
> -*/
> -static void
> -_base_put_smid_scsi_io_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid,
> - u16 handle)
> -{
> - Mpi26AtomicRequestDescriptor_t descriptor;
> - u32 *request = (u32 *)
> -
> - descriptor.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO;
> - descriptor.MSIxIndex = _base_get_msix_index(ioc);
> - descriptor.SMID = cpu_to_le16(smid);
> -
> - writel(cpu_to_le32(*request), >chip->AtomicRequestDescriptorPost);
> -}
> -
> -/**
> - * _base_put_smid_fast_path_atomic - send fast path request to firmware
> - * using Atomic Request Descriptor
> - * @ioc: per adapter object
> - * @smid: system request message index
> - * @handle: device handle, unused in this function, for function type match
> - * Return nothing
> - */
> -static void
> -_base_put_smid_fast_path_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid,
> - u16 handle)
> -{
> - Mpi26AtomicRequestDescriptor_t descriptor;
> - u32 *request = (u32 *)
> -
> - descriptor.RequestFlags = MPI25_REQ_DESCRIPT_FLAGS_FAST_PATH_SCSI_IO;
> - descriptor.MSIxIndex = _base_get_msix_index(ioc);
> - descriptor.SMID = cpu_to_le16(smid);
> -
> - writel(cpu_to_le32(*request), >chip->AtomicRequestDescriptorPost);
> -}
> -
> -/**
> - * _base_put_smid_hi_priority_atomic - send Task Management request to
> - * firmware using Atomic Request Descriptor
> - * @ioc: per adapter object
> - * @smid: system request message index
> - * @msix_task: msix_task will be same as msix of IO incase of task abort 
> else 0
> - *
> - * Return nothing.
> - */
> -static void
> -_base_put_smid_hi_priority_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid,
> - u16 msix_task)
> -{
> - Mpi26AtomicRequestDescriptor_t descriptor;
> - u32 *request = (u32 *)
> -
> - descriptor.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
> - descriptor.MSIxIndex = msix_task;
> - descriptor.SMID = cpu_to_le16(smid);
> -
> - writel(cpu_to_le32(*request), >chip->AtomicRequestDescriptorPost);
> -}
> -
> -/**
> - * _base_put_smid_nvme_encap_atomic - send NVMe encapsulated request to
> - *   firmware using Atomic Request Descriptor
> - * @ioc: per adapter object
> - * @smid: system request message index
> - *
> - * Return nothing.
> - */
> -static void
> -_base_put_smid_nvme_encap_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid)
> -{
> - Mpi26AtomicRequestDescriptor_t descriptor;
> - u32 *request = (u32 *)
> -
> - descriptor.RequestFlags = MPI26_REQ_DESCRIPT_FLAGS_PCIE_ENCAPSULATED;
> - descriptor.MSIxIndex = _base_get_msix_index(ioc);
> - descriptor.SMID = cpu_to_le16(smid);
> -
> - writel(cpu_to_le32(*request), >chip->AtomicRequestDescriptorPost);
> -}
> -
> -/**
> - * _base_put_smid_default - Default, primarily used for config pages
> - * use Atomic Request Descriptor
> - * @ioc: per adapter object
> - * @smid: system request message index
> - *
> - * Return nothing.
> - */
> -static void
> -_base_put_smid_default_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid)
> -{
> - Mpi26AtomicRequestDescriptor_t descriptor;
> - u32 *request = (u32 *)
> -
> - descriptor.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
> - descriptor.MSIxIndex = _base_get_msix_index(ioc);
> - descriptor.SMID = cpu_to_le16(smid);
> -
> - writel(cpu_to_le32(*request), >chip->AtomicRequestDescriptorPost);
> -}
> -
> -/**
>   * _base_display_OEMs_branding - Display branding string
>   * @ioc: per adapter object
>   *
> @@ -5071,8 +4961,6 @@ _base_get_ioc_facts(struct MPT3SAS_ADAPTER *ioc)
>   if ((facts->IOCCapabilities &
>

Re: rescan-scsi-bus causes arcmsr death

2018-02-13 Thread Hannes Reinecke
On 02/09/2018 08:58 PM, Alex Richman wrote:
> Hi,
> 
> We're seeing an odd rare interaction between rescan-scsi-bus and arcmsr,
> which manifests as these log messages, then a hang/panic:
> Feb  9 18:51:19 Space kernel: [ 2624.283565] arcmsr: abort
> scsi_cmnd(0x8807d06cc900), cmnd[0x8a,0x 0,0x 0,0x 0,0x 0,0x 1,0x
> 8,0xc0,0x2b,0xe8,0x 0,0x 0], scsi_id = 0x 0, scsi_lun = 0x 0.
> Feb  9 18:51:19 Space kernel: [ 2624.283604] arcmsr0: to abort
> command(0x8807d06cc900), ccb = 0x881058b11180
> Feb  9 18:51:21 Space kernel: [ 2625.924838] arcmsr0: abort ccb =
> 0x881058b11180 not done yet, do not force aborting command!
> --- Snip many more ---
> 
> On the (seemingly less common) occasion that it panics rather than
> hangs, it looks like this:
> Feb  9 11:55:05 Space kernel: [58801.943419] arcmsr9: abort
> scsi_cmnd(0x881027968900), cmnd[0x 0,0x 0,0x 0,0x 0,0x 0,0x 0,0x
> 0,0x 0,0x 0,0x 0,0x 0,0x 0], scsi_id = 0x 0, scsi_lun = 0x 0.
> Feb  9 11:55:05 Space kernel: [58801.943427] arcmsr9: to abort
> command(0x881027968900), ccb = 0x88085864a580
> Feb  9 11:55:05 Space kernel: [58801.943429] arcmsr9: scsi id = 0 lun =
> 0 ccb = '0x88085864a580' polling a done ccb, abort successfully
> Feb  9 11:55:05 Space kernel: [58801.943460] BUG: scheduling while
> atomic: ksoftirqd/19/85/0x0100
> Feb  9 11:55:05 Space kernel: [58801.943463] Modules linked in: xfs
> libcrc32c mlx4_ib ib_sa ib_mad ib_core ib_addr mlx4_en mlx4_core
> myri10ge bonding target_core_mod configfs ip6table_filter ip6_tables
> iptable_filter ip_tables ebtable_nat ebtables x_tables dm_crypt
> ipmi_ssif x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel kvm
> crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel aes_x86_64
> lrw gf128mul glue_helper ablk_helper cryptd sb_edac microcode edac_core
> lpc_ich ioatdma tpm_tis ipmi_si ipmi_msghandler 8250_fintek mac_hid nfsd
> auth_rpcgss pcspkr nfs_acl nfs lockd grace sunrpc fscache ext2 mlx5_core
> raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor
> async_tx xor raid6_pq raid1 raid0 multipath linear vxlan ip6_udp_tunnel
> udp_tunnel bcache hid_generic igb isci usbhid i2c_algo_bit libsas ahci
> dca hid libahci ptp scsi_transport_sas pps_core arcmsr(OE) [last
> unloaded: mlx4_core]
> Feb  9 11:55:05 Space kernel: [58801.943511] CPU: 19 PID: 85 Comm:
> ksoftirqd/19 Tainted: G   OE  3.19.0-21-spacev3 #160915
> Feb  9 11:55:05 Space kernel: [58801.943512] Hardware name: GBLabs
> Space+/X9DRH-7TF/7F/iTF/iF, BIOS 3.2  06/04/2015
> Feb  9 11:55:05 Space kernel: [58801.943514]  88105bd13a08
> 88105bd13948 af6e521c 
> Feb  9 11:55:05 Space kernel: [58801.943516]  88107fcf29c0
> 88105bd13958 af6dfa07 88105bd139c8
> Feb  9 11:55:05 Space kernel: [58801.943517]  af6e84fc
> 88105bcb41a0 000129c0 88105bd13fd8
> Feb  9 11:55:05 Space kernel: [58801.943519] Call Trace:
> Feb  9 11:55:05 Space kernel: [58801.943528]  []
> dump_stack+0x45/0x57
> Feb  9 11:55:05 Space kernel: [58801.943533]  []
> __schedule_bug+0x4b/0x59
> Feb  9 11:55:05 Space kernel: [58801.943535]  []
> __schedule+0x75c/0x780
> Feb  9 11:55:05 Space kernel: [58801.943537]  []
> schedule+0x29/0x70
> Feb  9 11:55:05 Space kernel: [58801.943540]  []
> schedule_timeout+0x10b/0x210
> Feb  9 11:55:05 Space kernel: [58801.943544]  [] ?
> internal_add_timer+0x80/0x80
> Feb  9 11:55:05 Space kernel: [58801.943546]  []
> msleep+0x37/0x50
> Feb  9 11:55:05 Space kernel: [58801.943552]  []
> arcmsr_queue_command+0x82/0xf40 [arcmsr]
> Feb  9 11:55:05 Space kernel: [58801.943553]  [] ?
> __slab_free+0x101/0x2c1
> Feb  9 11:55:05 Space kernel: [58801.943555]  [] ?
> __slab_free+0x101/0x2c1
> Feb  9 11:55:05 Space kernel: [58801.943561]  []
> scsi_dispatch_cmd+0xaf/0x310
> Feb  9 11:55:05 Space kernel: [58801.943563]  []
> scsi_request_fn+0x4f0/0x7e0
> Feb  9 11:55:05 Space kernel: [58801.943566]  []
> __blk_run_queue+0x37/0x50
> Feb  9 11:55:05 Space kernel: [58801.943568]  []
> blk_run_queue+0x26/0x40
> Feb  9 11:55:05 Space kernel: [58801.943570]  []
> scsi_run_queue+0x230/0x2d0
> Feb  9 11:55:05 Space kernel: [58801.943572]  [] ?
> scsi_put_command+0x7d/0xd0
> Feb  9 11:55:05 Space kernel: [58801.943575]  []
> scsi_end_request+0x142/0x1e0
> Feb  9 11:55:05 Space kernel: [58801.943576]  []
> scsi_io_completion+0x109/0x6b0
> Feb  9 11:55:05 Space kernel: [58801.943578]  []
> scsi_finish_command+0xcf/0x130
> Feb  9 11:55:05 Space kernel: [58801.943580]  []
> scsi_softirq_done+0x137/0x160
> Feb  9 11:55:05 Space kernel: [58801.943583]  []
> blk_done_softirq+0x83/0xa0
> Feb  9 11:55:05 Space kernel: [58801.943587]  []
> __do_softirq+0xe4/0x270
> Feb  9 11:55:05 Space kernel: [58801.943588]  []
> run_ksoftirqd+0x29/0x40
> Feb  9 11:55:05 Space kernel: [58801.943593]  []
> smpboot_thread_fn+0x143/0x1b0
> Feb  9 11:55:05 Space kernel: [58801.943596]  [] ?
> SyS_setgroups+0x180/0x180
> Feb  9 11:55:05 Space kernel: [58801.943598]  

Re: [PATCH] Reduce number of scsi_test_unit_ready() retries

2018-02-13 Thread Hannes Reinecke
On 02/12/2018 07:57 PM, Bart Van Assche wrote:
> Make scsi_test_unit_ready() send at most as many TURs as specified
> in the 'retries' argument instead of retries * (retries + 1) / 2.
> 
> Signed-off-by: Bart Van Assche 
> ---
>  drivers/scsi/scsi_lib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index b03cb2d5b733..9c793090dbf1 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -2607,7 +2607,7 @@ scsi_test_unit_ready(struct scsi_device *sdev, int 
> timeout, int retries,
>   /* try to eat the UNIT_ATTENTION if there are enough retries */
>   do {
>   result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, sshdr,
> -   timeout, retries, NULL);
> +   timeout, 1, NULL);
>   if (sdev->removable && scsi_sense_valid(sshdr) &&
>   sshdr->sense_key == UNIT_ATTENTION)
>   sdev->changed = 1;
> 
At one point we _really_ need to clean up BLOCK_PC command handling.
This 'some parts are handled by the core, some parts need to be
evaluated by the caller' magic is driving my nuts :-(
Anyway.

Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH] Move the eh_deadline module parameter definition to the top of hosts.c

2018-02-13 Thread Johannes Thumshirn
Thanks Bart,
Reviewed-by: Johannes Thumshirn 

-- 
Johannes Thumshirn                                          Storage
jthu
msh...@suse.de                                +49 911 74053 689
SUSE
LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane
Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38
9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850