]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/log
mirror_ubuntu-bionic-kernel.git
6 years agoMerge branch 'fixes' into misc
James Bottomley [Thu, 7 Sep 2017 19:12:43 +0000 (12:12 -0700)]
Merge branch 'fixes' into misc

6 years agoscsi: scsi-mq: Always unprepare before requeuing a request
Bart Van Assche [Wed, 30 Aug 2017 23:58:42 +0000 (16:58 -0700)]
scsi: scsi-mq: Always unprepare before requeuing a request

One of the two scsi-mq functions that requeue a request unprepares a
request before requeueing (scsi_io_completion()) but the other function
not (__scsi_queue_insert()). Make sure that a request is unprepared
before requeuing it.

Fixes: commit d285203cf647 ("scsi: add support for a blk-mq based I/O path.")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Damien Le Moal <damien.lemoal@wdc.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: Show .retries and .jiffies_at_alloc in debugfs
Bart Van Assche [Wed, 30 Aug 2017 23:58:41 +0000 (16:58 -0700)]
scsi: Show .retries and .jiffies_at_alloc in debugfs

Make these two member variables available in debugfs such that their
value can be verified by kernel developers. An example of the new
output:

ffff8804a513d480 {.op=READ, .cmd_flags=META|PRIO, .rq_flags=MQ_INFLIGHT|DONTPREP|IO_STAT|STATS, .atomic_flags=STARTED, .tag=17, .internal_tag=-1, .cmd=Read(10) 28 00 08 81 32 38 00 00 08 00, .retries=0, allocated 0.010 s ago}

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: Improve requeuing behavior
Bart Van Assche [Wed, 30 Aug 2017 23:58:40 +0000 (16:58 -0700)]
scsi: Improve requeuing behavior

Requests are unprepared and reprepared when being requeued.  Avoid that
requeuing resets .jiffies_at_alloc and .retries by initializing these
two member variables from inside scsi_initialize_rq() and by preserving
both member variables when preparing a request. This patch affects the
requeuing behavior of both the legacy scsi and the scsi-mq code paths.

Reported-by: Brian King <brking@linux.vnet.ibm.com>
References: https://lkml.org/lkml/2017/8/18/923 ("Re: [BUG][bisected 270065e] linux-next fails to boot on powerpc")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Brian King <brking@linux.vnet.ibm.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: Call scsi_initialize_rq() for filesystem requests
Bart Van Assche [Wed, 30 Aug 2017 23:58:39 +0000 (16:58 -0700)]
scsi: Call scsi_initialize_rq() for filesystem requests

If a pass-through request is submitted then blk_get_request()
initializes that request by calling scsi_initialize_rq(). Also call this
function for filesystem requests. Introduce CMD_INITIALIZED to keep
track of whether or not a request has already been initialized.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Brian King <brking@linux.vnet.ibm.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: qla2xxx: Reset the logo flag, after target re-login.
Quinn Tran [Wed, 30 Aug 2017 17:16:50 +0000 (10:16 -0700)]
scsi: qla2xxx: Reset the logo flag, after target re-login.

After relogin is sucessful, "send_els_logo" flag needs to be
reinitialized. This will allow next re-login to happen successfully.

In target mode, this flag was not reset correctly, causing IO's failure
during reset recovery and port ON/OFF test cases from initiator.

Signed-off-by: Quinn Tran <quinn.tran@cavium.com>
Signed-off-by: Sawan Chandak <sawan.chandak@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: qla2xxx: Fix slow mem alloc behind lock
Quinn Tran [Wed, 30 Aug 2017 17:16:49 +0000 (10:16 -0700)]
scsi: qla2xxx: Fix slow mem alloc behind lock

Call Trace:
 [<ffffffff81341687>] dump_stack+0x6b/0xa4
 [<ffffffff810c3e30>] ? print_irqtrace_events+0xd0/0xe0
 [<ffffffff8109e3c3>] ___might_sleep+0x183/0x240
 [<ffffffff8109e4d2>] __might_sleep+0x52/0x90
 [<ffffffff811fe17b>] kmem_cache_alloc_trace+0x5b/0x300
 [<ffffffff810c666b>] ? __lock_acquired+0x30b/0x420
 [<ffffffffa0733c28>] qla2x00_alloc_fcport+0x38/0x2a0 [qla2xxx]
 [<ffffffffa07217f4>] ? qla2x00_do_work+0x34/0x2b0 [qla2xxx]
 [<ffffffff816cc82b>] ? _raw_spin_lock_irqsave+0x7b/0x90
 [<ffffffffa072169a>] ? qla24xx_create_new_sess+0x3a/0x160 [qla2xxx]
 [<ffffffffa0721723>] qla24xx_create_new_sess+0xc3/0x160 [qla2xxx]
 [<ffffffff810c91ed>] ? trace_hardirqs_on+0xd/0x10
 [<ffffffffa07218f8>] qla2x00_do_work+0x138/0x2b0 [qla2xxx]

Signed-off-by: Quinn Tran <quinn.tran@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: qla2xxx: Clear fc4f_nvme flag
Darren Trap [Wed, 30 Aug 2017 17:16:48 +0000 (10:16 -0700)]
scsi: qla2xxx: Clear fc4f_nvme flag

Signed-off-by: Darren Trap <darren.trap@cavium.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: qla2xxx: add missing includes for qla_isr
Johannes Thumshirn [Wed, 30 Aug 2017 13:12:31 +0000 (15:12 +0200)]
scsi: qla2xxx: add missing includes for qla_isr

Since commit 7401bc18d1ee ("scsi: qla2xxx: Add FC-NVMe command
handling") we make use of 'struct nvmefc_fcp_req' in
qla24xx_nvme_iocb_entry() without including linux/nvme-fc-driver.h where
it is defined.

Add linux/nvme-fc-driver.h (and scsi/fc/fc_fs.h as nvme-fc-driver.h
needs the definition of 'struct fc_ba_rjt' from scsi/fc/fc_fs.h) to the
header files included by qla_isr.c.

Fixes: 7401bc18d1ee ("scsi: qla2xxx: Add FC-NVMe command handling")
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Acked-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: qla2xxx: Fix an integer overflow in sysfs code
Dan Carpenter [Wed, 30 Aug 2017 13:30:35 +0000 (16:30 +0300)]
scsi: qla2xxx: Fix an integer overflow in sysfs code

The value of "size" comes from the user.  When we add "start + size" it
could lead to an integer overflow bug.

It means we vmalloc() a lot more memory than we had intended.  I believe
that on 64 bit systems vmalloc() can succeed even if we ask it to
allocate huge 4GB buffers.  So we would get memory corruption and likely
a crash when we call ha->isp_ops->write_optrom() and ->read_optrom().

Only root can trigger this bug.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=194061
Cc: <stable@vger.kernel.org>
Fixes: b7cc176c9eb3 ("[SCSI] qla2xxx: Allow region-based flash-part accesses.")
Reported-by: shqking <shqking@gmail.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: aacraid: report -ENOMEM to upper layer from aac_convert_sgraw2()
Nikola Pajkovsky [Tue, 29 Aug 2017 11:59:04 +0000 (13:59 +0200)]
scsi: aacraid: report -ENOMEM to upper layer from aac_convert_sgraw2()

aac_convert_sgraw2() kmalloc memory and return -1 on error, which should
be -ENOMEM. However, nobody is checking return value, so with this
change, -ENOMEM is propagated to upper layer.

Signed-off-by: Nikola Pajkovsky <npajkovsky@suse.cz>
Reviewed-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: aacraid: get rid of one level of indentation
Nikola Pajkovsky [Tue, 29 Aug 2017 11:59:03 +0000 (13:59 +0200)]
scsi: aacraid: get rid of one level of indentation

  unsigned long byte_count = 0;
  nseg = scsi_dma_map(scsicmd);
  if (nseg < 0)
     return nseg;
  if (nseg) {
     ...
  }
  return byte_count;

is equal to

  unsigned long byte_count = 0;
  nseg = scsi_dma_map(scsicmd);
  if (nseg <= 0)
     return nseg;
  ...
  return byte_count;

No other code has changed.

[mkp: fix checkpatch complaints]

Signed-off-by: Nikola Pajkovsky <npajkovsky@suse.cz>
Reviewed-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: aacraid: fix indentation errors
Nikola Pajkovsky [Tue, 29 Aug 2017 11:59:02 +0000 (13:59 +0200)]
scsi: aacraid: fix indentation errors

fix stupid indent error, no rocket science here.

Signed-off-by: Nikola Pajkovsky <npajkovsky@suse.cz>
Reviewed-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: storvsc: fix memory leak on ring buffer busy
Long Li [Tue, 29 Aug 2017 00:43:59 +0000 (17:43 -0700)]
scsi: storvsc: fix memory leak on ring buffer busy

When storvsc is sending I/O to Hyper-v, it may allocate a bigger buffer
descriptor for large data payload that can't fit into a pre-allocated
buffer descriptor. This bigger buffer is freed on return path.

If I/O request to Hyper-v fails due to ring buffer busy, the storvsc
allocated buffer descriptor should also be freed.

[mkp: applied by hand]

Fixes: be0cf6ca301c ("scsi: storvsc: Set the tablesize based on the information given by the host")
Cc: <stable@vger.kernel.org>
Signed-off-by: Long Li <longli@microsoft.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: scsi_transport_sas: switch to bsg-lib for SMP passthrough
Christoph Hellwig [Fri, 25 Aug 2017 15:37:41 +0000 (17:37 +0200)]
scsi: scsi_transport_sas: switch to bsg-lib for SMP passthrough

Simplify the SMP passthrough code by switching it to the generic bsg-lib
helpers that abstract away the details of the request code, and gets
drivers out of seeing struct scsi_request.

For the libsas host SMP code there is a small behavior difference in
that we now always clear the residual len for successful commands,
similar to the three other SMP handler implementations.  Given that
there is no partial command handling in the host SMP handler this should
not matter in practice.

[mkp: typos and checkpatch fixes]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: smartpqi: remove the smp_handler stub
Christoph Hellwig [Fri, 25 Aug 2017 15:37:40 +0000 (17:37 +0200)]
scsi: smartpqi: remove the smp_handler stub

The SAS transport class will do the right thing and not register the BSG
node if now smp_handler method is present.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: hpsa: remove the smp_handler stub
Christoph Hellwig [Fri, 25 Aug 2017 15:37:39 +0000 (17:37 +0200)]
scsi: hpsa: remove the smp_handler stub

The SAS transport class will do the right thing and not register the BSG
node if now smp_handler method is present.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Acked-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: bsg-lib: pass the release callback through bsg_setup_queue
Christoph Hellwig [Fri, 25 Aug 2017 15:37:38 +0000 (17:37 +0200)]
scsi: bsg-lib: pass the release callback through bsg_setup_queue

The SAS code will need it.  Also mark the name argument const to match
bsg_register_queue.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: Rework handling of scsi_device.vpd_pg8[03]
Bart Van Assche [Tue, 29 Aug 2017 15:50:13 +0000 (08:50 -0700)]
scsi: Rework handling of scsi_device.vpd_pg8[03]

Introduce struct scsi_vpd for the VPD page length, data and the RCU head
that will be used to free the VPD data. Use kfree_rcu() instead of
kfree() to free VPD data. Move the VPD buffer pointer check inside the
RCU read lock in the sysfs code. Only annotate pointers that are shared
across threads with __rcu. Use rcu_dereference() when dereferencing an
RCU pointer. This patch suppresses about twenty sparse complaints about
the vpd_pg8[03] pointers. This patch also fixes a race condition, namely
that updating of the VPD pointers and length variables in struct
scsi_device was not atomic with reference to the code reading these
variables. See also "Does the update code tolerate concurrent accesses?"
in Documentation/RCU/checklist.txt.

Fixes: commit 09e2b0b14690 ("scsi: rescan VPD attributes")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Acked-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Shane Seymour <shane.seymour@hpe.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Shane Seymour <shane.seymour@hpe.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: Rework the code for caching Vital Product Data (VPD)
Bart Van Assche [Tue, 29 Aug 2017 15:50:12 +0000 (08:50 -0700)]
scsi: Rework the code for caching Vital Product Data (VPD)

Introduce the scsi_get_vpd_buf() and scsi_update_vpd_page()
functions. The only functional change in this patch is that if updating
page 0x80 fails that it is attempted to update page 0x83.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Acked-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Shane Seymour <shane.seymour@hpe.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Shane M Seymour <shane.seymour@hpe.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: rcu: Introduce rcu_swap_protected()
Bart Van Assche [Tue, 29 Aug 2017 15:50:11 +0000 (08:50 -0700)]
scsi: rcu: Introduce rcu_swap_protected()

A common pattern in RCU code is to assign a new value to an RCU pointer
after having read and stored the old value. Introduce a macro for this
pattern.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Shane M Seymour <shane.seymour@hpe.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: aacraid: Fix command send race condition
Brian King [Tue, 29 Aug 2017 15:00:29 +0000 (10:00 -0500)]
scsi: aacraid: Fix command send race condition

This fixes a potential race condition observed on Power systems.

Several places throughout the aacraid driver call aac_fib_send or
similar to send a command to the aacraid adapter, then check the return
code to determine if the command was actually sent to the adapter, then
update the phase field in the scsi command scratch pad area to track
that the firmware now owns this command.  However, there is nothing that
ensures that by the time the aac_fib_send function returns and we go to
write to the scsi command, that the command hasn't already completed and
the scsi command has been freed.  This was causing random crashes in the
TCP stack which was tracked down to be caused by memory that had been a
struct request + scsi_cmnd being now used for an skbuff. Memory
poisoning was enabled in the kernel to debug this which showed that the
last owner of the memory that had been freed was aacraid and that it was
a struct request.  The memory that was corrupted was the exact data
pattern of AAC_OWNER_FIRMWARE and it was at the same offset that aacraid
writes, which is scsicmd->SCp.phase. The patch below resolves this
issue.

Cc: <stable@vger.kernel.org>
Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Tested-by: Wen Xiong <wenxiong@linux.vnet.ibm.com>
Reviewed-by: Dave Carroll <david.carroll@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: qlogicpti: fixup qlogicpti_reset() definition
Hannes Reinecke [Mon, 28 Aug 2017 08:14:26 +0000 (10:14 +0200)]
scsi: qlogicpti: fixup qlogicpti_reset() definition

A merge error crept in when formatting commit af167bc ("scsi: qlogicpti:
move bus reset to host reset")

Fixes: af167bc ("scsi: qlogicpti: move bus reset to host reset")
Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: qedi: off by one in qedi_get_cmd_from_tid()
Dan Carpenter [Fri, 25 Aug 2017 10:36:57 +0000 (13:36 +0300)]
scsi: qedi: off by one in qedi_get_cmd_from_tid()

The > here should be >= or we end up reading one element beyond the end
of the qedi->itt_map[] array.  The qedi->itt_map[] array is allocated in
qedi_alloc_itt().

Fixes: ace7f46ba5fd ("scsi: qedi: Add QLogic FastLinQ offload iSCSI driver framework.")
Cc: <stable@vger.kernel.org> # v4.10+
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Manish Rangankar <Manish.Rangankar@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: avoid false-positive gcc-8 warning
Arnd Bergmann [Thu, 24 Aug 2017 23:10:00 +0000 (01:10 +0200)]
scsi: lpfc: avoid false-positive gcc-8 warning

This is an interesting regression with gcc-8, showing a harmless warning
for correct code:

In file included from include/linux/kernel.h:13:0,
                 ...
                 from drivers/scsi/lpfc/lpfc_debugfs.c:23:
include/linux/printk.h:301:2: error: 'eq' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
  ^~~~~~
In file included from drivers/scsi/lpfc/lpfc_debugfs.c:58:0:
drivers/scsi/lpfc/lpfc_debugfs.h:451:31: note: 'eq' was declared here

I managed to reduce the warning into a small test case for gcc-8 that I
reported in the gcc bugzilla[1].

As a workaround, this changes the logic to move the two assignments of
'eq' out of the conditions and instead make the index conditional.  This
works for all configurations I tried and avoids adding a bogus
initialization.

Acked-by: James Smart <james.smart@broadcom.com>
Link: [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81958
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: avoid an unused function warning
Arnd Bergmann [Thu, 24 Aug 2017 23:09:59 +0000 (01:09 +0200)]
scsi: lpfc: avoid an unused function warning

The only reference to lpfc_nvmet_replenish_context() is inside of an
disabled:

drivers/scsi/lpfc/lpfc_nvmet.c:1457:1: error: 'lpfc_nvmet_replenish_context' defined but not used [-Werror=unused-function]

This replaces the preprocessor conditional with a C condition, so the
compiler can see that the function is intentionally unused.

Fixes: 9a38e4f1c82f ("scsi: lpfc: Fix MRQ > 1 context list handling")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: cxlflash: Fix vlun resize failure in the shrink path
Uma Krishnan [Fri, 25 Aug 2017 22:18:12 +0000 (17:18 -0500)]
scsi: cxlflash: Fix vlun resize failure in the shrink path

The ioctl DK_CAPI_VLUN_RESIZE can fail if the allocated vlun size is
reduced from almost maximum capacity and then increased again.

The shrink_lxt() routine is currently using the SISL_ASTATUS_MASK to
mask the higher 48 bits of the lxt entry. This is unnecessary and
incorrect as it uses a mask designed for the asynchronous interrupt
status register.  When the 4 port support was added to cxlflash, the
SISL_ASTATUS_MASK was updated to reflect the status bits for all 4
ports. This change indirectly affected the shrink_lxt() code path.

To extract the base, simply shift the bits without masking.

Fixes: 565180723294 ("scsi: cxlflash: SISlite updates to support 4 ports")
Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: cxlflash: Avoid double mutex unlock
Matthew R. Ochs [Fri, 25 Aug 2017 22:18:03 +0000 (17:18 -0500)]
scsi: cxlflash: Avoid double mutex unlock

The AFU recovery routine uses an interruptible mutex to control the flow
of in-flight recoveries. Upon receiving an interruptible signal the code
branches to a common exit path which wrongly assumes the mutex is
held. Add a local variable to track when the mutex should be unlocked.

Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: cxlflash: Remove unnecessary existence check
Matthew R. Ochs [Fri, 25 Aug 2017 22:17:53 +0000 (17:17 -0500)]
scsi: cxlflash: Remove unnecessary existence check

The AFU termination sequence has been refactored over time such that the
main tear down routine, term_afu(), can no longer can be invoked with a
NULL AFU pointer. Remove the unnecessary existence check from
term_afu().

Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: ibmvfc: ibmvscsi: ibmvscsi_tgt: constify vio_device_id
Arvind Yadav [Thu, 17 Aug 2017 13:45:05 +0000 (19:15 +0530)]
scsi: ibmvfc: ibmvscsi: ibmvscsi_tgt: constify vio_device_id

vio_device_id are not supposed to change at runtime. All functions
working with vio_device_id provided by <asm/vio.h> work with const
vio_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: Fix the kerneldoc for scsi_initialize_rq()
Jonathan Corbet [Thu, 24 Aug 2017 22:11:09 +0000 (16:11 -0600)]
scsi: Fix the kerneldoc for scsi_initialize_rq()

The kerneldoc comment for scsi_initialize_rq() neglected to document the
"rq" parameter, leading to this docs build warning:

  ./drivers/scsi/scsi_lib.c:1116: warning: No description found for parameter 'rq'

Document the parameter and make the build slightly quieter.

[mkp: used wording suggested by Bart]

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: ses: Fix racy cleanup of /sys in remove_dev()
Calvin Owens [Thu, 24 Aug 2017 13:13:52 +0000 (15:13 +0200)]
scsi: ses: Fix racy cleanup of /sys in remove_dev()

Currently we free the resources backing the enclosure device before we
call device_unregister(). This is racy: during rmmod of low-level SCSI
drivers that hook into enclosure, we end up with a small window of time
during which writing to /sys can OOPS. Example trace with mpt3sas:

  general protection fault: 0000 [#1] SMP KASAN
  Modules linked in: mpt3sas(-) <...>
  RIP: [<ffffffffa0388a98>] ses_get_page2_descriptor.isra.6+0x38/0x220 [ses]
  Call Trace:
   [<ffffffffa0389d14>] ses_set_fault+0xf4/0x400 [ses]
   [<ffffffffa0361069>] set_component_fault+0xa9/0xf0 [enclosure]
   [<ffffffff8205bffc>] dev_attr_store+0x3c/0x70
   [<ffffffff81677df5>] sysfs_kf_write+0x115/0x180
   [<ffffffff81675725>] kernfs_fop_write+0x275/0x3a0
   [<ffffffff8151f810>] __vfs_write+0xe0/0x3e0
   [<ffffffff8152281f>] vfs_write+0x13f/0x4a0
   [<ffffffff81526731>] SyS_write+0x111/0x230
   [<ffffffff828b401b>] entry_SYSCALL_64_fastpath+0x13/0x94

Fortunately the solution is extremely simple: call device_unregister()
before we free the resources, and the race no longer exists. The driver
core holds a reference over ->remove_dev(), so AFAICT this is safe.

Signed-off-by: Calvin Owens <calvinowens@fb.com>
Acked-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: mptsas: Fixup device hotplug for VMWare ESXi
Hannes Reinecke [Thu, 24 Aug 2017 12:52:43 +0000 (14:52 +0200)]
scsi: mptsas: Fixup device hotplug for VMWare ESXi

VMWare ESXi emulates an mptsas HBA, but exposes all drives as
direct-attached SAS drives.  This it not how the driver originally
envisioned things; SAS drives were supposed to be connected via an
expander, and only SATA drives would be direct attached.  As such, any
hotplug event for direct-attach SAS drives was silently ignored, and the
guest failed to detect new drives from within a VMWare ESXi environment.

[mkp: typos]

Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1030850
Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: make device_type const
Bhumika Goyal [Sat, 19 Aug 2017 08:22:24 +0000 (13:52 +0530)]
scsi: make device_type const

Make these const as they are only stored in the type field of a device
structure, which is const.
Done using Coccinelle.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: sd: remove duplicated setting of gd->minors
weiping zhang [Fri, 18 Aug 2017 06:49:30 +0000 (14:49 +0800)]
scsi: sd: remove duplicated setting of gd->minors

gd->minors has been set when call alloc_disk() in sd_probe.

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: eata: remove 'arg_done' from eata2x_eh_host_reset()
Hannes Reinecke [Fri, 25 Aug 2017 11:57:21 +0000 (13:57 +0200)]
scsi: eata: remove 'arg_done' from eata2x_eh_host_reset()

Just displaying some different information; drop it.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: visorhba: sanitze private device data allocation
Hannes Reinecke [Fri, 25 Aug 2017 11:57:20 +0000 (13:57 +0200)]
scsi: visorhba: sanitze private device data allocation

There's no need to keep the private data for a device in a separate
list; better to store it in ->hostdata and do away with the additional
list.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: David Kershner <david.kershner@unisys.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: megaraid_mbox: drop duplicate bus reset and device reset function
Hannes Reinecke [Fri, 25 Aug 2017 11:57:19 +0000 (13:57 +0200)]
scsi: megaraid_mbox: drop duplicate bus reset and device reset function

megaraid_mbox only has one reset function, and that is a host reset.  So
drop the duplicate bus reset and device reset functions.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: bnx2fc: remove obsolete bnx2fc_eh_host_reset() definition
Hannes Reinecke [Fri, 25 Aug 2017 11:57:18 +0000 (13:57 +0200)]
scsi: bnx2fc: remove obsolete bnx2fc_eh_host_reset() definition

Never used anywhere.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: 53c700: move bus reset to host reset
Hannes Reinecke [Fri, 25 Aug 2017 11:57:17 +0000 (13:57 +0200)]
scsi: 53c700: move bus reset to host reset

bus reset always returns SUCCESS, meaning host reset was never
tested. At the same time the only difference to the HBA is a missing
call to NCR_700_chip_reset().  So add the missing call to bus reset,
drop host reset, and move bus reset to host reset.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: aha152x: drop host reset
Hannes Reinecke [Fri, 25 Aug 2017 11:57:16 +0000 (13:57 +0200)]
scsi: aha152x: drop host reset

The driver has both a bus and a host reset, where the host reset does a
bus reset followed by an attempt to reset the chip registers to a
default state.  However, as the bus reset always returned SUCCESS the
host reset was never called, so the functionality of the register reset
function was never validated.  Additionally, tha AIC-6260 chip has a
hard reset line, which actually should be preferred for a host
reset. But I haven't found a way how this can be triggered via software,
so take the safe approach and drop the host reset.

[mkp: typo]

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: nsp32: drop bus reset
Hannes Reinecke [Fri, 25 Aug 2017 11:57:15 +0000 (13:57 +0200)]
scsi: nsp32: drop bus reset

bus reset is a host reset without nsp32hw_init(), and will always return
SUCCESS, thus disabling the use of host reset.  So drop bus reset in
favour of host reset.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: qedf: drop bus reset handler
Hannes Reinecke [Fri, 25 Aug 2017 11:57:14 +0000 (13:57 +0200)]
scsi: qedf: drop bus reset handler

qedf has a host reset handler, but as the bus reset handler is a stub
always returning SUCCESS the host reset is never invoked.  So drop the
bus reset handler.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Tested-by: Chad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: ppa: drop duplicate bus_reset handler
Hannes Reinecke [Fri, 25 Aug 2017 11:57:13 +0000 (13:57 +0200)]
scsi: ppa: drop duplicate bus_reset handler

bus_reset and host_reset are the same functions, so drop bus_reset.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: imm: drop duplicate bus_reset handler
Hannes Reinecke [Fri, 25 Aug 2017 11:57:12 +0000 (13:57 +0200)]
scsi: imm: drop duplicate bus_reset handler

host_reset and bus_reset is the same function, so drop bus reset.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: qlogicfas: move bus_reset to host_reset
Hannes Reinecke [Fri, 25 Aug 2017 11:57:11 +0000 (13:57 +0200)]
scsi: qlogicfas: move bus_reset to host_reset

The bus reset handler is really a host reset.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: NCR5380: Move bus reset to host reset
Hannes Reinecke [Fri, 25 Aug 2017 11:57:10 +0000 (13:57 +0200)]
scsi: NCR5380: Move bus reset to host reset

The bus reset handler really is a host reset, so move it to
eh_bus_reset_handler.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Acked-by: Finn Thain <fthain@telegraphics.com.au>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: acornscsi: move bus reset to host reset
Hannes Reinecke [Fri, 25 Aug 2017 11:57:09 +0000 (13:57 +0200)]
scsi: acornscsi: move bus reset to host reset

The bus reset function is really a host reset, so move it to
eh_host_reset_handler.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: qlogicpti: move bus reset to host reset
Hannes Reinecke [Fri, 25 Aug 2017 11:57:08 +0000 (13:57 +0200)]
scsi: qlogicpti: move bus reset to host reset

The bus reset function really is a host reset, so move it to
eh_host_reset_handler().

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: rtsx: drop bus reset function
Hannes Reinecke [Fri, 25 Aug 2017 11:57:07 +0000 (13:57 +0200)]
scsi: rtsx: drop bus reset function

Function is a stub, so can as well be dropped.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: drop bus reset for wd33c93-compatible boards
Hannes Reinecke [Fri, 25 Aug 2017 11:57:06 +0000 (13:57 +0200)]
scsi: drop bus reset for wd33c93-compatible boards

The bus reset function is just a wrapper calling host reset under the
host lock. So move taking of the host lock into the host reset function
and drop bus reset.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: fdomain: move bus reset to host reset
Hannes Reinecke [Fri, 25 Aug 2017 11:57:05 +0000 (13:57 +0200)]
scsi: fdomain: move bus reset to host reset

The bus reset function really is a host reset, so move it to
eh_host_reset_handler().

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: hptiop: Simplify reset handling
Hannes Reinecke [Fri, 25 Aug 2017 11:57:04 +0000 (13:57 +0200)]
scsi: hptiop: Simplify reset handling

The Highpoint driver only has one reset function, and that is a host
reset. So stop pretending we're doing anything else.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: bfa: move bus reset to target reset
Hannes Reinecke [Fri, 25 Aug 2017 11:57:03 +0000 (13:57 +0200)]
scsi: bfa: move bus reset to target reset

The bus reset handler is just calling target reset on all targets, which
is exactly what SCSI EH will be doing anyway.  So move the bus reset
function to target reset and drop the loop.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: libsas: move bus_reset_handler() to target_reset_handler()
Hannes Reinecke [Fri, 25 Aug 2017 11:57:02 +0000 (13:57 +0200)]
scsi: libsas: move bus_reset_handler() to target_reset_handler()

The bus reset handler is calling I_T Nexus reset, which logically is a
target reset as it need to specify both the initiator and the target.
So move it to target reset.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: uas: move eh_bus_reset_handler to eh_device_reset_handler
Hannes Reinecke [Fri, 25 Aug 2017 11:57:01 +0000 (13:57 +0200)]
scsi: uas: move eh_bus_reset_handler to eh_device_reset_handler

The bus_reset handler is really a device reset, so move it to
eh_device_reset_handler().

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: fnic: do not call host reset from command abort
Hannes Reinecke [Fri, 25 Aug 2017 11:57:00 +0000 (13:57 +0200)]
scsi: fnic: do not call host reset from command abort

Command abort already returns FAILED, which will then be escalated to a
host reset. So no need to call host_reset directly.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: fc_fcp: do not call fc_block_scsi_eh() from host reset
Hannes Reinecke [Fri, 25 Aug 2017 11:56:59 +0000 (13:56 +0200)]
scsi: fc_fcp: do not call fc_block_scsi_eh() from host reset

When calling host reset we're resetting all ports anyway, so there is no
point in waiting for the ports to become unblocked.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: ibmvfc: Do not call fc_block_scsi_eh() on host reset
Hannes Reinecke [Fri, 25 Aug 2017 11:56:58 +0000 (13:56 +0200)]
scsi: ibmvfc: Do not call fc_block_scsi_eh() on host reset

When we're resetting the host any remote port states will be reset
anyway, so it's pointless to wait for dev_loss_tmo during host reset.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: mptfc: Do not call fc_block_scsi_eh() on host reset
Hannes Reinecke [Fri, 25 Aug 2017 11:56:57 +0000 (13:56 +0200)]
scsi: mptfc: Do not call fc_block_scsi_eh() on host reset

When we're resetting the host any remote port states will be reset
anyway, so it's pointless to wait for dev_loss_tmo during host reset.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: fix comment in scsi_device_set_state()
Hannes Reinecke [Fri, 25 Aug 2017 11:56:56 +0000 (13:56 +0200)]
scsi: fix comment in scsi_device_set_state()

The function returns '0' if successful; with the original comment
the function doesn't have a way to indicate success ...

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Bart van Assche <bvanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: iscsi_tcp: Remove a set-but-not-used variable
Bart Van Assche [Fri, 25 Aug 2017 20:46:43 +0000 (13:46 -0700)]
scsi: iscsi_tcp: Remove a set-but-not-used variable

This patch avoids that gcc reports the following warning when
building with W=1:

drivers/scsi/iscsi_tcp.c:166:24: warning: variable ?session? set but not used [-Wunused-but-set-variable]

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: Lee Duncan <lduncan@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: scsi_debug: Remove a set-but-not-used variable
Bart Van Assche [Fri, 25 Aug 2017 20:46:42 +0000 (13:46 -0700)]
scsi: scsi_debug: Remove a set-but-not-used variable

This patch avoids that gcc reports the following warning when
building with W=1:

drivers/scsi/scsi_debug.c:2264:15: warning: variable ?pcontrol? set but not used [-Wunused-but-set-variable]

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: scsi_transport_srp: Suppress a W=1 compiler warning
Bart Van Assche [Fri, 25 Aug 2017 20:46:41 +0000 (13:46 -0700)]
scsi: scsi_transport_srp: Suppress a W=1 compiler warning

Avoid that the following compiler warning is reported when building
with W=1:

drivers/scsi/scsi_transport_srp.c:92:19: warning: comparison is always false due to limited range of data type [-Wtype-limits]

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: scsi_transport_sas: Check kzalloc() return value
Bart Van Assche [Fri, 25 Aug 2017 20:46:40 +0000 (13:46 -0700)]
scsi: scsi_transport_sas: Check kzalloc() return value

Check whether memory allocation succeeded before dereferencing
the pointer to the allocated memory.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: libsas: Annotate fall-through in a switch statement
Bart Van Assche [Fri, 25 Aug 2017 20:46:39 +0000 (13:46 -0700)]
scsi: libsas: Annotate fall-through in a switch statement

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: libsas: Remove a set-but-not-used variable
Bart Van Assche [Fri, 25 Aug 2017 20:46:38 +0000 (13:46 -0700)]
scsi: libsas: Remove a set-but-not-used variable

This was detected by building with W=1.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: libiscsi: Fix indentation
Bart Van Assche [Fri, 25 Aug 2017 20:46:37 +0000 (13:46 -0700)]
scsi: libiscsi: Fix indentation

This patch avoids that smatch reports the following:

drivers/scsi/libiscsi.c:1081: iscsi_handle_reject() warn: inconsistent indenting

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: sg: Fix type of last blk_trace_setup() argument
Bart Van Assche [Fri, 25 Aug 2017 20:46:36 +0000 (13:46 -0700)]
scsi: sg: Fix type of last blk_trace_setup() argument

Avoid that sparse reports the following:

drivers/scsi/sg.c:1114:41: warning: incorrect type in argument 5 (different address spaces)
drivers/scsi/sg.c:1114:41:    expected char [noderef] <asn:1>*arg
drivers/scsi/sg.c:1114:41:    got char *<noident>

This patch does not change any functionality.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: sd: Remove a useless comparison
Bart Van Assche [Fri, 25 Aug 2017 20:46:35 +0000 (13:46 -0700)]
scsi: sd: Remove a useless comparison

This patch avoids that gcc reports the following warning when
building with W=1:

drivers/scsi/sd.c:315:10: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
  if (val >= 0 && val <= T10_PI_TYPE3_PROTECTION)

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: sd: Fix indentation
Bart Van Assche [Fri, 25 Aug 2017 20:46:34 +0000 (13:46 -0700)]
scsi: sd: Fix indentation

This patch avoids that smatch reports the following:

drivers/scsi/sd.c:3540: sd_suspend_common() warn: inconsistent indenting

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: sd: sr: Convert two assignments into warning statements
Bart Van Assche [Fri, 25 Aug 2017 20:46:33 +0000 (13:46 -0700)]
scsi: sd: sr: Convert two assignments into warning statements

Before scsi_prep_fn() calls the ULP .init_command() callback
function it stores the SCSI command pointer in request.special.
This means that the SCpnt = rq->special assignments in the sd
and sr drivers assign a pointer to itself. Hence convert these
two assignment statements into warning statements.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: Use blk_mq_rq_to_pdu() to convert a request to a SCSI command pointer
Bart Van Assche [Fri, 25 Aug 2017 20:46:32 +0000 (13:46 -0700)]
scsi: Use blk_mq_rq_to_pdu() to convert a request to a SCSI command pointer

Since commit e9c787e65c0c ("scsi: allocate scsi_cmnd structures as
part of struct request") struct request and struct scsi_cmnd are
adjacent. This means that there is now an alternative to reading
req->special to convert a pointer to a prepared request into a
SCSI command pointer, namely by using blk_mq_rq_to_pdu(). Make
this change where appropriate. Although this patch does not
change any functionality, it slightly improves performance and
slightly improves readability.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: Document which queue type a function is intended for
Bart Van Assche [Fri, 25 Aug 2017 20:46:31 +0000 (13:46 -0700)]
scsi: Document which queue type a function is intended for

Rename several functions to make it easy to see which queue type a
function is intended for.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: Convert a strncmp() call into a strcmp() call
Bart Van Assche [Fri, 25 Aug 2017 20:46:30 +0000 (13:46 -0700)]
scsi: Convert a strncmp() call into a strcmp() call

This patch avoids that smatch reports the following warning:

drivers/scsi/scsi_sysfs.c:117: check_set() error: strncmp() '"-"' too small (2 vs 20)

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: Suppress gcc 7 fall-through warnings reported with W=1
Bart Van Assche [Fri, 25 Aug 2017 20:46:29 +0000 (13:46 -0700)]
scsi: Suppress gcc 7 fall-through warnings reported with W=1

The conclusion of a recent discussion about the new warnings
reported by gcc 7 is that the new warnings reported when building
with W=1 should be suppressed. However, gcc 7 still warns about
fall-through in switch statements when building with W=1. Suppress
these warnings by annotating the SCSI core properly.

See also Linus Torvalds, Lots of new warnings with gcc-7.1.1, 11
July 2017 (https://www.mail-archive.com/linux-media@vger.kernel.org/msg115428.html).

References: commit bd664f6b3e37 ("disable new gcc-7.1.1 warnings for now")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: Avoid sign extension of scsi_device.type
Bart Van Assche [Fri, 25 Aug 2017 20:46:28 +0000 (13:46 -0700)]
scsi: Avoid sign extension of scsi_device.type

This patch avoids that smatch reports the following:

drivers/scsi/scsi_sysfs.c:506 scsi_bus_uevent() warn: argument 3 to %02x specifier has type 'char'
drivers/scsi/scsi_sysfs.c:872 sdev_show_modalias() warn: argument 4 to %02x specifier has type 'char'

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: Remove an obsolete function declaration
Bart Van Assche [Fri, 25 Aug 2017 20:46:27 +0000 (13:46 -0700)]
scsi: Remove an obsolete function declaration

Commit e9c787e65c0c ("scsi: allocate scsi_cmnd structures as part of
struct request") removed the scsi_get_command() function. Hence also
remove the declaration of that function.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: ufs: reqs and tasks were put in the wrong order
Zang Leigang [Thu, 24 Aug 2017 02:57:15 +0000 (10:57 +0800)]
scsi: ufs: reqs and tasks were put in the wrong order

Signed-off-by: Zang Leigang <zangleigang@hisilicon.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: lpfc version bump 11.4.0.3
Dick Kennedy [Wed, 23 Aug 2017 23:55:49 +0000 (16:55 -0700)]
scsi: lpfc: lpfc version bump 11.4.0.3

Update driver version to 11.4.0.3

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: fix "integer constant too large" error on 32bit archs
Maurizio Lombardi [Wed, 23 Aug 2017 23:55:48 +0000 (16:55 -0700)]
scsi: lpfc: fix "integer constant too large" error on 32bit archs

cc1: warnings being treated as errors
drivers/scsi/lpfc/lpfc_init.c: In function 'lpfc_get_wwpn':
drivers/scsi/lpfc/lpfc_init.c:3253: error: integer constant is too large for 'long' type

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: Add Buffer to Buffer credit recovery support
James Smart [Wed, 23 Aug 2017 23:55:47 +0000 (16:55 -0700)]
scsi: lpfc: Add Buffer to Buffer credit recovery support

Add Buffer to buffer credit recovery support to the driver.  This is a
negotiated feature with the peer that allows for both sides to detect
dropped RRDY's and FC Frames and recover credit.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: remove console log clutter
James Smart [Wed, 23 Aug 2017 23:55:46 +0000 (16:55 -0700)]
scsi: lpfc: remove console log clutter

Change hw queue binding messages to info - not error.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: Fix bad sgl reposting after 2nd adapter reset
Dick Kennedy [Wed, 23 Aug 2017 23:55:45 +0000 (16:55 -0700)]
scsi: lpfc: Fix bad sgl reposting after 2nd adapter reset

Port issue was fixed, the hbacmd reset would take more than 8 minutes to
complete.

There were conflicting NVME SGL posting/reposting responsibilities
between lpfc_online()/lpfc_sli4_hba_setup() and
lpfc_nvme_create_localport().  The lpfc_online() causes a REPOST on
existing NVME SGLs which is not released during the fc port reset.
However, lpfc_nvme_create_localport() wants to allocate new NVME buffers
and post them. Both cancelled out each other which had a side effect of
hosing the mailbox handling that was used to remove the sgl lists -
causing multiple 60s mbx timeouts.

Fix by preserving all SGL lists over the fc port reset.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: Fix nvme target failure after 2nd adapter reset
Dick Kennedy [Wed, 23 Aug 2017 23:55:44 +0000 (16:55 -0700)]
scsi: lpfc: Fix nvme target failure after 2nd adapter reset

The nonrecovery occurred because the lpfc nvme initiator function did
not reestablish its localport creation with the nvme host transport in
lpfc_oneline.  Because of that, an NVME rport binding could not take
place.

Corrected by recreating the localport in the adapter reset recovery
routine.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: Fix relative offset error on large nvmet target ios
Dick Kennedy [Wed, 23 Aug 2017 23:55:43 +0000 (16:55 -0700)]
scsi: lpfc: Fix relative offset error on large nvmet target ios

If the nvmet_fc transport breaks an io into multiple sequences, the
driver will improperly set the relative offset on the 2nd through N
sequences.

Correct by properly formatting the hw cmd so the relative offset is
picked up from the hw cmd.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: Fix MRQ > 1 context list handling
Dick Kennedy [Wed, 23 Aug 2017 23:55:42 +0000 (16:55 -0700)]
scsi: lpfc: Fix MRQ > 1 context list handling

Various oops including cpu LOCKUPs were seen.

For asynchronously received ius where the driver must assign exchange
resources, the resources were on a single get (free) list and put list
(finished, waiting to be put on get list). As all cpus are sharing the
lists, an interrupt for a receive frame may have to wait for all the
other cpus to place their done work onto the put list before it can
acquire the lock to pull from the list.

Fix by breaking the resource lists into per-cpu lists or at least more
than 1 list with cpu's sharing the lists). A cpu would allocate from the
free list for its own cpu, and put its done work on the its own put list
- avoiding the contention. As cpu load may vary, when empty, a cpu may
grab from another cpu, thereby changing resource distribution.  But
searching for a resource only occurs on 1 or a few cpus until a single
resource can be allocated. if the condition reoccurs, it starts looking
at a different cpu.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: Limit amount of work processed in IRQ
Dick Kennedy [Wed, 23 Aug 2017 23:55:41 +0000 (16:55 -0700)]
scsi: lpfc: Limit amount of work processed in IRQ

Various oops being seen on being in the ISR too long and cpu lockups,
when under heavy load.

The amount of work being posted off of completion queues kept the ISR
running almost all the time

Correct the issue by limiting the amount of work per iteration.

[mkp: typo]

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: Correct issues with FAWWN and FDISCs
Dick Kennedy [Wed, 23 Aug 2017 23:55:40 +0000 (16:55 -0700)]
scsi: lpfc: Correct issues with FAWWN and FDISCs

When using fabric-assigned WWNs, the switch doesn't like copy of the
FLOGI payload, which includes valid VVL bits, to be used as the FDISC
payload.

Rather than wait for corrected switch firmware, ensure the VVL bits are
marked invalid on FDISCs.

[mkp: typo]

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: Fix NVME PRLI handling during RSCN
Dick Kennedy [Wed, 23 Aug 2017 23:55:39 +0000 (16:55 -0700)]
scsi: lpfc: Fix NVME PRLI handling during RSCN

A race condition was found whereby the initiator would receive the RSCN
for a new NVME device before it had a chance to register its FC4 support
with the fabric. Thus, when queried by the initiator, it would see that
the target supported FC-NVME.

Corrected by making the assumption that the target always supports
FC-NVME thus a PRLI is sent. It's ok for the target to reject it.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: Fix crash in lpfc nvmet when fc port is reset
Dick Kennedy [Wed, 23 Aug 2017 23:55:38 +0000 (16:55 -0700)]
scsi: lpfc: Fix crash in lpfc nvmet when fc port is reset

In adapter reset tests, an oops was seen with a NULL pointer in
lpfc_free_rq_buffer+0x20/0x60

The driver is failing to properly repost the nvmet sgl list when
recovering from the reset. Thus the driver eventually trys to walk an
errant buffer list.

Corrected the sgl buffer recovery as well as strengthening the
initialization of the bufferlist.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: Fix duplicate NVME rport entries and namespaces.
Dick Kennedy [Wed, 23 Aug 2017 23:55:37 +0000 (16:55 -0700)]
scsi: lpfc: Fix duplicate NVME rport entries and namespaces.

After lip, the driver sometimes would have two rports for the same
device, allowing the namespaces to be duplicated by nvme.

In lpfc_plogi_confirm_nport() the driver was not swapping the nrport
maintained by the ndlp's undergoing address swapping. This allowed the
2nd rport to sneak in as it was considered a separate device.

This patch adds the fixes to Swap the nrport in each ndlp and take care
of the reference counts on the ndlps similar to FCP rports.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: Fix handling of FCP and NVME FC4 types in Pt2Pt topology
Dick Kennedy [Wed, 23 Aug 2017 23:55:36 +0000 (16:55 -0700)]
scsi: lpfc: Fix handling of FCP and NVME FC4 types in Pt2Pt topology

After link bounce in a NVME Pt2Pt config, the driver managed to map the
same nport twice, resulting in multiple device nodes for the same
namespace.

In Pt2Pt, the driver must send PRLI's for both (scsi) FCP and NVME
rather than using fabric aids. The driver was inconsistent on handling
various PRLI completions, especially rejects, which had reject codes
cross the different protocol PRLI completions.

Fixed to perform the following: if nvmet mode (fc port can only be a
nvme target) - rejects all unsolicitly FCP PRLI's. Never issues a FCP
PRLI.

The multiple protocol PRLI's are sent simultaneously. However, driver
will now only state transition after both PRLI's are complete. New flags
were added to aid tracking the responses from the different PRLI's.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: Correct return error codes to align with nvme_fc transport
Dick Kennedy [Wed, 23 Aug 2017 23:55:35 +0000 (16:55 -0700)]
scsi: lpfc: Correct return error codes to align with nvme_fc transport

Modify driver return error codes to align with host nvme transport.

Driver isn't returning Exxx error codes to properly reflect out of
resource or connectivity conditions (-EBUSY), yet there were hard error
conditions returning -EBUSY.

Ensure the following situations return the proper return code:

 - Temporary failures or temporary resource availability: -EBUSY

 - Connectivity issues: -ENODEV

All others are treated as hard errors and return an -Exxx value that
indicates the type of error.

Also, lpfc_sli4_issue_wqe() was modified to not translate error from
-Exxx to WQE state.  This allows lpfc_nvme_fcp_io_submit() routine to
just return whatever -E value was returned from other routines.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: convert info messages to standard messages
Dick Kennedy [Wed, 23 Aug 2017 23:55:34 +0000 (16:55 -0700)]
scsi: lpfc: convert info messages to standard messages

Transitioned some informational discovery messages to now always be
displayed when log_verbose is set.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: Fix oops when NVME Target is discovered in a nonNVME environment
Dick Kennedy [Wed, 23 Aug 2017 23:55:33 +0000 (16:55 -0700)]
scsi: lpfc: Fix oops when NVME Target is discovered in a nonNVME environment

lpfc oops when it discovers a NVME target but is configured for SCSI
only operation. Oops is in lpfc_nvme_register_port+0x33/0x300.

The localport is not valid so it should not have been referenced.

Added validity check for localport

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: Fix rediscovery on switch blade pull
Dick Kennedy [Wed, 23 Aug 2017 23:55:32 +0000 (16:55 -0700)]
scsi: lpfc: Fix rediscovery on switch blade pull

When the switch blade is pulled out then plugged back in, the driver
does not issue a PLOGI to the target

When the switch blade is pulled out, it does not reset the link. The
driver ends up issuing a LOGO to the target, and finally sees devloss.
Since the driver believes that a LOGO is outstanding, it does not issue
a PLOGI to the target upon link up

Correct by placing the ndlp in UNUSED state When devloss happens in
LOGO_ISSUE state.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: Fix loop mode target discovery
Dick Kennedy [Wed, 23 Aug 2017 23:55:31 +0000 (16:55 -0700)]
scsi: lpfc: Fix loop mode target discovery

The driver does not discover targets when in loop mode.

The NLP type is correctly getting set when a fabric connection is
detected but, not for loop. The unknown NLP type means that the driver
does not issue a PRLI when in loop topology. Thus target discovery
fails.

Fix by checking the topology during discovery.  If it is loop, set the
NLP FC4 type to FCP.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: lpfc: Fix plogi collision that causes illegal state transition
Dick Kennedy [Wed, 23 Aug 2017 23:55:30 +0000 (16:55 -0700)]
scsi: lpfc: Fix plogi collision that causes illegal state transition

Message "0271 Illegal State Transition: node" seen in logs, all luns are
unuseable for that target.

A window exists in the rcv_plogi path where if the state is plogi issue
but the driver has not issued a plogi, then two reglogins will be sent
for the same RPI. The first one to complete will advance the state to
prli issue the second one will be detected as an illegal state, and
leave the node in an unusable state.

Correct the completion routine for the PLOGI ACC that detects the state
change when the driver starts discovery on the node again and drop the
REGLOGIN mailbox command.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 years agoscsi: qla2xxx: Update driver version to 10.00.00.01-k
himanshu.madhani@cavium.com [Wed, 23 Aug 2017 22:05:25 +0000 (15:05 -0700)]
scsi: qla2xxx: Update driver version to 10.00.00.01-k

Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>