]> www.infradead.org Git - users/jedix/linux-maple.git/log
users/jedix/linux-maple.git
8 years agonvme: fix max_segments integer truncation
Ashok Vairavan [Thu, 27 Oct 2016 19:31:52 +0000 (12:31 -0700)]
nvme: fix max_segments integer truncation

The block layer uses an unsigned short for max_segments.  The way we
calculate the value for NVMe tends to generate very large 32-bit values,
which after integer truncation may lead to a zero value instead of
the desired outcome.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reported-by: Jeff Lien <Jeff.Lien@hgst.com>
Tested-by: Jeff Lien <Jeff.Lien@hgst.com>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Orabug: 24928835
Cherry picked commit: 45686b6198bd824f083ff5293f191d78db9d708a
Conflicts:
UEK4 QU2 nvme module doesn't have core.c file. All the functions
resides in pci.c. Hence, this patch is manually ported to the respective
function in pci.c
drivers/nvme/host/core.c

Signed-off-by: Ashok Vairavan <ashok.vairavan@oracle.com>
8 years agodrivers/nvme: provide a module parameter for setting number of I/O queues
Shan Hai [Wed, 12 Oct 2016 14:24:57 +0000 (22:24 +0800)]
drivers/nvme: provide a module parameter for setting number of I/O queues

Orabug: 24914952

The current NVME driver allocates I/O queue per-cpu and alloctes IRQ
per-queue for the devices, a large number of IRQs will be allotted to
the I/O queues on a large NUMA/SMP system with multiple NVME devices
installed because of this design.

It would cause failure of CPU hotplug operations on the above mentioned
system, the problem is that the CPU cores could not be hotplugged after
certain number of them are offlined because the remaining online CPU cores
have not enough IRQ vectors to accept the large number of migrated IRQs.

This patch fixes it by providing a way to reduce the NVME queue IRQs to
an acceptable number.

Signed-off-by: Shan Hai <shan.hai@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agonvme: Remove RCU namespace protection
Ashok Vairavan [Mon, 10 Oct 2016 20:31:35 +0000 (13:31 -0700)]
nvme: Remove RCU namespace protection

We can't sleep with RCU read lock held, but we need to do potentially
blocking stuff to namespace queues when iterating the list. This patch
removes the RCU locking and holds a mutex instead.

To prevent deadlocks, this patch removes holding the mutex during
namespace scanning and removal. The unlocked namespace scanning is made
safe by holding a reference to the namespace being scanned.

List iteration that does IO has to be unlocked to allow error recovery.
The caller must ensure the list can not be manipulated during such an
event, so this patch adds a comment explaining this requirement to the
only function that iterates an unlocked list. All callers currently
meet this requirement, so no further changes required.

List iterations that do not do IO can safely use the lock since it couldn't
block recovery from missing forced IO completions.

Reported-by: Ming Lin <mlin at kernel.org>
[fixes 0bf77e9 nvme: switch to RCU freeing the namespace]
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 32f0c4afb4363e31dad49202f1554ba591d649f2)

Orabug: 24583236
Signed-off-by: Ashok Vairavan <ashok.vairavan@oracle.com>
8 years agonvme: synchronize access to ctrl->namespaces
Ashok Vairavan [Mon, 10 Oct 2016 19:15:14 +0000 (12:15 -0700)]
nvme: synchronize access to ctrl->namespaces

Currently traversal and modification of ctrl->namespaces happens completely
unsynchronized, which can be fixed by the addition of a simple mutex.

Note: nvme_dev_ioctl will be handled in the next patch.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 69d3b8ac15a5eb938e6a01909f6cc8ae4b5d3a17)

Orabug: 24583236
Signed-off-by: Ashok Vairavan <ashok.vairavan@oracle.com>
8 years agoNVMe: Implement namespace list scanning
Ashok Vairavan [Mon, 10 Oct 2016 19:13:01 +0000 (12:13 -0700)]
NVMe: Implement namespace list scanning

The NVMe 1.1 specification provides an identify mode to return a
list of active namespaces. This is more efficient to discover which
namespace identifiers are active on a controller, providing potentially
significant improvement in scan time for controllers with sparesly
populated namespaces.

Signed-off-by: Keith Busch <keith.busch@intel.com>
[hch: add quirk for the broken Qemu Identify implementation.  To be relaxed
 later]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 540c801c65eb58e05e0ca38b6fd644a83d7e2b33)

Orabug: 24583236
Signed-off-by: Ashok Vairavan <ashok.vairavan@oracle.com>
8 years agoRevert "scsi: fix soft lockup in scsi_remove_target() on module removal"
Johannes Thumshirn [Tue, 5 Apr 2016 09:50:45 +0000 (11:50 +0200)]
Revert "scsi: fix soft lockup in scsi_remove_target() on module removal"

Now that we've done a more comprehensive fix with the intermediate
target state we can remove the previous hack introduced with commit
90a88d6ef88e ("scsi: fix soft lockup in scsi_remove_target() on module
removal").

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Cc: stable@vger.kernel.org
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 305c2e71b3d733ec065cb716c76af7d554bd5571)

Orabug: 24844559
Signed-off-by: ashok.vairavan <ashok.vairavan@oracle.com>
8 years agoscsi: Add intermediate STARGET_REMOVE state to scsi_target_state
ashok.vairavan [Sat, 8 Oct 2016 01:47:01 +0000 (21:47 -0400)]
scsi: Add intermediate STARGET_REMOVE state to scsi_target_state

Add intermediate STARGET_REMOVE state to scsi_target_state to avoid
running into the BUG_ON() in scsi_target_reap(). The STARGET_REMOVE
state is only valid in the path from scsi_remove_target() to
scsi_target_destroy() indicating this target is going to be removed.

This re-fixes the problem introduced in commits bc3f02a795d3 ("[SCSI]
scsi_remove_target: fix softlockup regression on hot remove") and
40998193560d ("scsi: restart list search after unlock in
scsi_remove_target") in a more comprehensive way.

[mkp: Included James' fix for scsi_target_destroy()]

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Fixes: 40998193560dab6c3ce8d25f4fa58a23e252ef38
Cc: stable@vger.kernel.org
Reported-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Tested-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: James Bottomley <jejb@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 24844559
Mainline commit: f05795d3d771f30a7bdc3a138bf714b06d42aa95
Conflicts:
    The following changes are done to fix kabi breakage.

        #ifndef __GENKSYMS__
        STARGET_REMOVE,
        #endif

8 years agoscsi: fix soft lockup in scsi_remove_target() on module removal
James Bottomley [Wed, 10 Feb 2016 16:03:26 +0000 (08:03 -0800)]
scsi: fix soft lockup in scsi_remove_target() on module removal

This softlockup is currently happening:

[  444.088002] NMI watchdog: BUG: soft lockup - CPU#1 stuck for 22s! [kworker/1:1:29]
[  444.088002] Modules linked in: lpfc(-) qla2x00tgt(O) qla2xxx_scst(O) scst_vdisk(O) scsi_transport_fc libcrc32c scst(O) dlm configfs nfsd lockd grace nfs_acl auth_rpcgss sunrpc ed
d snd_pcm_oss snd_mixer_oss snd_seq snd_seq_device dm_mod iTCO_wdt snd_hda_codec_realtek snd_hda_codec_generic gpio_ich iTCO_vendor_support ppdev snd_hda_intel snd_hda_codec snd_hda
_core snd_hwdep tg3 snd_pcm snd_timer libphy lpc_ich parport_pc ptp acpi_cpufreq snd pps_core fjes parport i2c_i801 ehci_pci tpm_tis tpm sr_mod cdrom soundcore floppy hwmon sg 8250_
fintek pcspkr i915 drm_kms_helper uhci_hcd ehci_hcd drm fb_sys_fops sysimgblt sysfillrect syscopyarea i2c_algo_bit usbcore button video usb_common fan ata_generic ata_piix libata th
ermal
[  444.088002] CPU: 1 PID: 29 Comm: kworker/1:1 Tainted: G           O    4.4.0-rc5-2.g1e923a3-default #1
[  444.088002] Hardware name: FUJITSU SIEMENS ESPRIMO E           /D2164-A1, BIOS 5.00 R1.10.2164.A1               05/08/2006
[  444.088002] Workqueue: fc_wq_4 fc_rport_final_delete [scsi_transport_fc]
[  444.088002] task: f6266ec0 ti: f6268000 task.ti: f6268000
[  444.088002] EIP: 0060:[<c07e7044>] EFLAGS: 00000286 CPU: 1
[  444.088002] EIP is at _raw_spin_unlock_irqrestore+0x14/0x20
[  444.088002] EAX: 00000286 EBX: f20d3800 ECX: 00000002 EDX: 00000286
[  444.088002] ESI: f50ba800 EDI: f2146848 EBP: f6269ec8 ESP: f6269ec8
[  444.088002]  DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
[  444.088002] CR0: 8005003b CR2: 08f96600 CR3: 363ae000 CR4: 000006d0
[  444.088002] Stack:
[  444.088002]  f6269eec c066b0f7 00000286 f2146848 f50ba808 f50ba800 f50ba800 f2146a90
[  444.088002]  f2146848 f6269f08 f8f0a4ed f3141000 f2146800 f2146a90 f619fa00 00000040
[  444.088002]  f6269f40 c026cb25 00000001 166c6392 00000061 f6757140 f6136340 00000004
[  444.088002] Call Trace:
[  444.088002]  [<c066b0f7>] scsi_remove_target+0x167/0x1c0
[  444.088002]  [<f8f0a4ed>] fc_rport_final_delete+0x9d/0x1e0 [scsi_transport_fc]
[  444.088002]  [<c026cb25>] process_one_work+0x155/0x3e0
[  444.088002]  [<c026cde7>] worker_thread+0x37/0x490
[  444.088002]  [<c027214b>] kthread+0x9b/0xb0
[  444.088002]  [<c07e72c1>] ret_from_kernel_thread+0x21/0x40

What appears to be happening is that something has pinned the target
so it can't go into STARGET_DEL via final release and the loop in
scsi_remove_target spins endlessly until that happens.

The fix for this soft lockup is to not keep looping over a device that
we've called remove on but which hasn't gone into DEL state.  This
patch will retain a simplistic memory of the last target and not keep
looping over it.

Reported-by: Sebastian Herbszt <herbszt@gmx.de>
Tested-by: Sebastian Herbszt <herbszt@gmx.de>
Fixes: 40998193560dab6c3ce8d25f4fa58a23e252ef38
Cc: stable@vger.kernel.org
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
(cherry picked from commit 90a88d6ef88edcfc4f644dddc7eef4ea41bccf8b)

Orabug: 24844559
Signed-off-by: ashok.vairavan <ashok.vairavan@oracle.com>
8 years agoscsi: restart list search after unlock in scsi_remove_target
Christoph Hellwig [Mon, 19 Oct 2015 14:35:46 +0000 (16:35 +0200)]
scsi: restart list search after unlock in scsi_remove_target

When dropping a lock while iterating a list we must restart the search
as other threads could have manipulated the list under us.  Without this
we can get stuck in an endless loop.  This bug was introduced by

commit bc3f02a795d3b4faa99d37390174be2a75d091bd
Author: Dan Williams <djbw@fb.com>
Date:   Tue Aug 28 22:12:10 2012 -0700

    [SCSI] scsi_remove_target: fix softlockup regression on hot remove

Which was itself trying to fix a reported soft lockup issue

http://thread.gmane.org/gmane.linux.kernel/1348679

However, we believe even with this revert of the original patch, the soft
lockup problem has been fixed by

commit f2495e228fce9f9cec84367547813cbb0d6db15a
Author: James Bottomley <JBottomley@Parallels.com>
Date:   Tue Jan 21 07:01:41 2014 -0800

    [SCSI] dual scan thread bug fix

Thanks go to Dan Williams <dan.j.williams@intel.com> for tracking all this
prior history down.

Reported-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Fixes: bc3f02a795d3b4faa99d37390174be2a75d091bd
Cc: stable@vger.kernel.org
Signed-off-by: James Bottomley <JBottomley@Odin.com>
(cherry picked from commit 40998193560dab6c3ce8d25f4fa58a23e252ef38)

Orabug: 24844559
Signed-off-by: ashok.vairavan <ashok.vairavan@oracle.com>
8 years agoHID: hiddev: validate num_values for HIDIOCGUSAGES, HIDIOCSUSAGES commands
Scott Bauer [Thu, 23 Jun 2016 14:59:47 +0000 (08:59 -0600)]
HID: hiddev: validate num_values for HIDIOCGUSAGES, HIDIOCSUSAGES commands

Orabug: 24798688
CVE: CVE-2016-5829

This patch validates the num_values parameter from userland during the
HIDIOCGUSAGES and HIDIOCSUSAGES commands. Previously, if the report id was set
to HID_REPORT_ID_UNKNOWN, we would fail to validate the num_values parameter
leading to a heap overflow.

Cc: stable@vger.kernel.org
Signed-off-by: Scott Bauer <sbauer@plzdonthack.me>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
(cherry picked from commit 93a2001bdfd5376c3dc2158653034c20392d15c5)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
8 years agomegaraid_sas: Don't issue kill adapter for MFI controllers in case of PD list DCMD...
Sumit Saxena [Thu, 10 Mar 2016 10:14:37 +0000 (02:14 -0800)]
megaraid_sas: Don't issue kill adapter for MFI controllers in case of PD list DCMD failure

There are few MFI adapters which do not support MR_DCMD_PD_LIST_QUERY so
if MFI adapters fail this DCMD, it should not be considered as FATAL and
driver should not issue kill adapter and set per controller's instance
variable- pd_list_not_supported so that same variable can be used inside
functions- slave_alloc and slave_configure to allow firmware scan.

Killing adapter because of DCMD failure when this DCMD is not supported
causes driver's probe getting failed. This issue got introduced by
commit 6d40afbc7d13 ("megaraid_sas: MFI IO timeout handling").

Killing adapter in case of this DCMD failure should be limited to Fusion
adapters only. Per controller's instance variable allow_fw_scan is
removed as pd_list_not_supported better reflect the purpose.

Fixes: 6d40afbc7d13359b30a5cd783e3db6ebefa5f40a
Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Hannes Reinicke <hare@suse.de>
Reviewed-by: Ewan Milne <emilne@redhat.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 3084558658c2f9a48d7c460d57aeb30964c06b7e)

Orabug: 24759460
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>
8 years agomptsas: add TUR with retries to ensure LUNs complete initialization
Dan Duval [Fri, 2 Sep 2016 16:56:30 +0000 (12:56 -0400)]
mptsas: add TUR with retries to ensure LUNs complete initialization

Orabug: 24745062

Earlier versions of the mptsas driver included a mechanism for
executing, and if necessary retrying, SCSI TEST UNIT READY commands
to ensure that devices complete their initialization during device
discovery.  This functionality, present in UEK2, was never sent
upstream, and was lost when UEK4 was initiated.

We have been seeing flash devices returning errors, or simply
disappearing, during alter cell validate configuration operations
on Exadata systems.  Giving the flash disks time to initialize
after (re-) discovery appears to resolve this issue.

This commit simply restores the missing functionality.

Signed-off-by: Dan Duval <dan.duval@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agonvme: refactor nvme_queue_rq
Christoph Hellwig [Fri, 16 Oct 2015 05:58:38 +0000 (07:58 +0200)]
nvme: refactor nvme_queue_rq

This "backports" the structure I've used for the fabrics driver.  It
mostly started out as a cleanup so that I could actually understand
the code, but I think it also qualifies as a micro-optimization due
to the reduced time we hold q_lock and disable interrupts.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Orabug: 24691685
mainline commit ba1ca37ea4e320c108c356eb8c91ac652afc57dd
Conflicts:
    Adding GFP_ATOMIC to nvme_setup_prps and replacing
REQ_TYPE_DRV_PRIV with REQ_TYPE_SPECIAL

Signed-off-by: Ashok Vairavan <ashok.vairavan@oracle.com>
8 years agoRevert "ixgbe: make a workaround to tx hang issue under dom"
Brian Maly [Wed, 31 Aug 2016 21:50:48 +0000 (17:50 -0400)]
Revert "ixgbe: make a workaround to tx hang issue under dom"

Orabug: 24574722

This reverts commit 885bb302d5bb06d7f26427133a3b8afb2115a53a.

Need to revert this commit as it causes a tx hang on dom0 for OVM

Signed-off-by: Brian Maly <brian.maly@oracle.com>
8 years agonvme: don't overwrite req->cmd_flags on sync cmd
Ashok Vairavan [Fri, 26 Aug 2016 17:22:26 +0000 (10:22 -0700)]
nvme: don't overwrite req->cmd_flags on sync cmd

In __nvme_submit_sync_cmd, the request direction is overwritten when
the REQ_FAILFAST_DRIVER flag is set.

Signed-off-by: Matias Bjørling <m@bjorling.me>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Fixes: 75619bfa904d0 ("NVMe: End sync requests immediately on failure")
Signed-off-by: Jens Axboe <axboe@fb.com>
  Orabug: 24561038
  Mainline Commit: e112af0dc9f55099b948e55077504a44b4162c79

Signed-off-by: Ashok Vairavan <ashok.vairavan@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoNVMe: End sync requests immediately on failure
Ashok Vairavan [Fri, 26 Aug 2016 17:18:19 +0000 (10:18 -0700)]
NVMe: End sync requests immediately on failure

Do not retry failed sync commands so the original status may be seen
without issuing unnecessary retries.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
  Orabug: 24561038
  Mainline Commit: 75619bfa904d0f2840b4274eb92ce47b2e1c472e

Signed-off-by: Ashok Vairavan <ashok.vairavan@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoNVMe: Fix obtaining command result
Keith Busch [Fri, 22 May 2015 18:28:31 +0000 (12:28 -0600)]
NVMe: Fix obtaining command result

Replaces req->sense_len usage, which is not owned by the LLD, to
req->special to contain the command result for driver created commands,
and sets the result unconditionally on completion.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@fb.com>
Fixes: d29ec8241c10 ("nvme: submit internal commands through the block layer")
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit a0a931d6a2c1fbc5d5966ebf0e7a043748692c22 and
added missing pieces from d29ec8241c10eacf59c23b3828a88dbae06e7e3f
backport)
Orabug: 24532912
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoqede: Bump up driver version to 8.10.1.20
Manish Chopra [Thu, 30 Jun 2016 06:35:22 +0000 (02:35 -0400)]
qede: Bump up driver version to 8.10.1.20

Signed-off-by: Manish Chopra <manish.chopra@qlogic.com>
Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqede: Add get/set rx copy break tunable support
Manish Chopra [Thu, 30 Jun 2016 06:35:21 +0000 (02:35 -0400)]
qede: Add get/set rx copy break tunable support

Signed-off-by: Manish <manish.chopra@qlogic.com>
Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqede: Utilize xmit_more
Manish Chopra [Thu, 30 Jun 2016 06:35:20 +0000 (02:35 -0400)]
qede: Utilize xmit_more

This patch uses xmit_more optimization to reduce
number of TX doorbells write per packet.

Signed-off-by: Manish <manish.chopra@qlogic.com>
Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqede: qede_poll refactoring
Manish Chopra [Thu, 30 Jun 2016 06:35:19 +0000 (02:35 -0400)]
qede: qede_poll refactoring

This patch cleanups qede_poll() routine a bit
and allows qede_poll() to do single iteration to handle
TX completion [As under heavy TX load qede_poll() might
run for indefinite time in the while(1) loop for TX
completion processing and cause CPU stuck].

Signed-off-by: Manish <manish.chopra@qlogic.com>
Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqede: Add support for handling IP fragmented packets.
Manish Chopra [Thu, 30 Jun 2016 06:35:18 +0000 (02:35 -0400)]
qede: Add support for handling IP fragmented packets.

When handling IP fragmented packets with csum in their
transport header, the csum isn't changed as part of the
fragmentation. As a result, the packet containing the
transport headers would have the correct csum of the original
packet, but one that mismatches the actual packet that
passes on the wire. As a result, on receive path HW would
give an indication that the packet has incorrect csum,
which would cause qede to discard the incoming packet.

Since HW also delivers a notification of IP fragments,
change driver behavior to pass such incoming packets
to stack and let it make the decision whether it needs
to be dropped.

Signed-off-by: Manish <manish.chopra@qlogic.com>
Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqede: Fix the static checker warnings.
Sudarsana Reddy Kalluru [Tue, 28 Jun 2016 06:10:59 +0000 (02:10 -0400)]
qede: Fix the static checker warnings.

Static checker warnings:
drivers/net/ethernet/qlogic/qede/qede_ethtool.c:435 qede_get_coalesce()
warn: passing casted pointer '&coal->rx_coalesce_usecs' to
'edev->ops->common->get_coalesce()' 32 vs 16.

The u32 pointer is being typecasted to u16 which may fail for big-endian
platforms.

Fixes: d552fa84cb35 ("qede: Add support for coalescing config read/update.")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sudarsana Reddy Kalluru <sudarsana.kalluru@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqed: Fix static checker warnings.
Sudarsana Reddy Kalluru [Tue, 28 Jun 2016 06:10:58 +0000 (02:10 -0400)]
qed: Fix static checker warnings.

Static checker warnings:
drivers/net/ethernet/qlogic/qed/qed_int.c:2450 qed_init_cau_sb_entry()
warn: always true condition '(cdev->rx_coalesce_usecs <= 255) =>
(0-255 <= 255)'
drivers/net/ethernet/qlogic/qed/qed_int.c:2511 qed_int_cau_conf_sb()
warn: always true condition '(p_hwfn->cdev->rx_coalesce_usecs <= 255)
=> (0-255 <= 255)'
..

The data types for rx/tx_coalesce_usecs should be u16.

Fixes: commit 722003ac40c2 ("qed: Add support for coalescing config read/update.")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sudarsana Reddy Kalluru <sudarsana.kalluru@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqede: Add support for coalescing config read/update.
Sudarsana Reddy Kalluru [Tue, 21 Jun 2016 13:36:22 +0000 (09:36 -0400)]
qede: Add support for coalescing config read/update.

Signed-off-by: Sudarsana Reddy Kalluru <sudarsana.kalluru@qlogic.com>
Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqed: Add support for coalescing config read/update.
Sudarsana Reddy Kalluru [Tue, 21 Jun 2016 13:36:21 +0000 (09:36 -0400)]
qed: Add support for coalescing config read/update.

This patch adds support for configuring the device tx/rx coalescing
timeout values in the order of micro seconds. It also adds APIs for
upper layer drivers for reading/updating the coalescing values.

Signed-off-by: Sudarsana Reddy Kalluru <sudarsana.kalluru@qlogic.com>
Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqede: Add dcbnl support.
Sudarsana Reddy Kalluru [Wed, 8 Jun 2016 10:22:12 +0000 (06:22 -0400)]
qede: Add dcbnl support.

This patch adds the interfaces for ieee/cee dcbnl callbacks and registers
them with the kernel.

Signed-off-by: Sudarsana Reddy Kalluru <sudarsana.kalluru@qlogic.com>
Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqed: Add dcbnl support.
Sudarsana Reddy Kalluru [Wed, 8 Jun 2016 10:22:11 +0000 (06:22 -0400)]
qed: Add dcbnl support.

This patch adds the implementation for both cee/ieee dcbnl callbacks by
using the qed query/config APIs.

Signed-off-by: Sudarsana Reddy Kalluru <sudarsana.kalluru@qlogic.com>
Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqed: Add support for query/config dcbx.
Sudarsana Reddy Kalluru [Wed, 8 Jun 2016 10:22:10 +0000 (06:22 -0400)]
qed: Add support for query/config dcbx.

Query API reads the dcbx data from the device shared memory and return it
to the caller. The config API configures the user provided dcbx values on
the device, and initiates the dcbx negotiation with the peer.

Signed-off-by: Sudarsana Reddy Kalluru <sudarsana.kalluru@qlogic.com>
Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqed: potential overflow in qed_cxt_src_t2_alloc()
Dan Carpenter [Tue, 7 Jun 2016 12:04:16 +0000 (15:04 +0300)]
qed: potential overflow in qed_cxt_src_t2_alloc()

In the current code "ent_per_page" could be more than "conn_num" making
"conn_num" negative after the subtraction.  In the next iteration
through the loop then the negative is treated as a very high positive
meaning we don't put a limit on "ent_num".  It could lead to memory
corruption.

Fixes: dbb799c39717 ('qed: Initialize hardware for new protocols')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqed: PF to reply to unknown messages
Yuval Mintz [Sun, 5 Jun 2016 10:11:16 +0000 (13:11 +0300)]
qed: PF to reply to unknown messages

If a future VF would send the PF an unknown message, the PF today would
not send a reply. This would have 2 bad effects:
  a. VF would have to timeout on the request.
  b. If VF were to send an additional message to PF, firmware would mark
     it as malicious.

Instead, if there's some valid reply-address on the message - let the PF
answer and tell the VF it doesn't know the message.

Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqed: PF enforce MAC limitation of VFs
Yuval Mintz [Sun, 5 Jun 2016 10:11:15 +0000 (13:11 +0300)]
qed: PF enforce MAC limitation of VFs

The only limitation relating to MACs the PF enforce today on its VFs
is in case it has a forced-unicast MAC address for them, in which case
they can't configure other unicast addresses.
Specifically, the PF isn't enforcing the number of MAC addresse a VF can
configure regardless of the nubmer of such filters agreed upon by PF and
VF during the acquisition process.

PF's shadow-config is now extended to also contain information about its
VFs' unicast addresses configuration, allowing such enforcement.

Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqed: Move doorbell calculation from VF to PF
Yuval Mintz [Sun, 5 Jun 2016 10:11:14 +0000 (13:11 +0300)]
qed: Move doorbell calculation from VF to PF

Today, the VF is aware of its queues context-ids, and calculates the
doorbell address when opening its queues on its own.
The configuration of doorbells in HW can sometime in the future be changed
by the PF [hw has several configurable features that might affect doorbell
addresses, e.g., dpm support], this would break compatibility with older
VFs as their calculated doorbell addresses would be incorrect for such a
configuration.

In order to avoid such a backward compatibility failure, let the PF make
the calculation of the doorbell offset based on the context-id, and pass
that to the VF.

Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqed: Make PF more robust against malicious VF
Yuval Mintz [Sun, 5 Jun 2016 10:11:13 +0000 (13:11 +0300)]
qed: Make PF more robust against malicious VF

There are several requests the VF can make toward the PF which the driver
would pass to firmware without checking the validity first - specifically,
opening queues and updating vports. Such configurations might cause the
firmware to assert.

This adds validation of the legality of said configurations on the PF side
before passing it onward via ramrod to firmware.

Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqed: PF-VF resource negotiation
Yuval Mintz [Sun, 5 Jun 2016 10:11:12 +0000 (13:11 +0300)]
qed: PF-VF resource negotiation

One of the goals of the vf's first message to the PF [acquire]
is to learn about the number of resources available to it [macs, vlans,
etc.]. This is done via negotiation - the VF requires a set of resources,
which the PF either approves or disaproves and sends a smaller set of
resources as alternative. In this later case, the VF is then expected to
either abort the probe or re-send the acquire message with less
required resources.

While this infrastructure exists since the initial submision of qed
SRIOV support, it's in fact completely inoperational - PF isn't really
looking into the resources the VF has asked for and is never going to
reply to the VF that it lacks resources.

This patch addresses this flow, fixing it and allowing the PF and VF
to actually agree on a set of resources.

Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqed: Relax VF firmware requirements
Yuval Mintz [Sun, 5 Jun 2016 10:11:11 +0000 (13:11 +0300)]
qed: Relax VF firmware requirements

Current driver require an exact match between VF and PF storm firmware;
Any difference would fail the VF acquire message, causing the VF probe
to be aborted.

While there's still dependencies between the two, the recent FW submission
has relaxed the match requirement - instead of an exact match, there's now
a 'fastpath' HSI major/minor scheme, where VFs and PFs that match in their
major number can co-exist even if their minor is different.

In order to accomadate this change some changes in the vf-start init flow
had to be made, as the VF start ramrod now has to be sent only after PF
learns which fastpath HSI its VF is requiring.

Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqed: Fix next-ptr chains for BE / 32-bit
Yuval Mintz [Sat, 4 Jun 2016 05:20:16 +0000 (08:20 +0300)]
qed: Fix next-ptr chains for BE / 32-bit

Commit a91eb52abb50 ("qed: Revisit chain implementation") contains an
incorrect implementation for BE platforms, as device's regpairs containing
addresses are LE and they're not converted correctly when read back.
In addition, it raises a compilation warning for 32-bit platforms where
dma_addr_t is a 32-bit variable.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqed: Initialize hardware for new protocols
Yuval Mintz [Fri, 3 Jun 2016 11:35:35 +0000 (14:35 +0300)]
qed: Initialize hardware for new protocols

RoCE and iSCSI would require some added/changed hw configuration in order
to properly run; The biggest single change being the requirement of
allocating and mapping host memory for several HW blocks that aren't being
used by qede [SRC, QM, TM, etc.].

In addition, whereas qede is only using context memory for HW blocks, the
new protocol would also require task memories to be added.

Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqed: Add iscsi/rdma personalities
Yuval Mintz [Fri, 3 Jun 2016 11:35:34 +0000 (14:35 +0300)]
qed: Add iscsi/rdma personalities

This patch adds in the ecore 2 new personalities in addition to
QED_PCI_ETH - QED_PCI_ISCSI and QED_PCI_ETH_ROCE.

Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqed: Add common HSI for new protocols
Yuval Mintz [Fri, 3 Jun 2016 11:35:33 +0000 (14:35 +0300)]
qed: Add common HSI for new protocols

This adds the qed portion of the RoCE & iSCSI firmware HSI,
as well as adding several new common HSI files which would be required
by both qed and qed* protocols.

Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqed: Revisit chain implementation
Yuval Mintz [Fri, 3 Jun 2016 11:35:32 +0000 (14:35 +0300)]
qed: Revisit chain implementation

RoCE driver is going to need a 32-bit chain [current chain implementation
for qed* currently supports only 16-bit producer/consumer chains].

This patch adds said support, as well as doing other slight tweaks and
modifications to qed's chain API.

Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqed: Utilize FW 8.10.3.0
Yuval Mintz [Thu, 2 Jun 2016 07:23:29 +0000 (10:23 +0300)]
qed: Utilize FW 8.10.3.0

The New QED firmware contains several fixes, including:
  - Wrong classification of packets in 4-port devices.
  - Anti-spoof interoperability with encapsulated packets.
  - Tx-switching of encapsulated packets.
It also slightly improves Tx performance of the device.

In addition, this firmware contains the necessary logic for
supporting iscsi & rdma, for which we plan on pushing protocol
drivers in the imminent future.

Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24361996
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agolpfc: fix oops in lpfc_sli4_scmd_to_wqidx_distr() from lpfc_send_taskmgmt()
Mauricio Faria de Oliveira [Tue, 7 Jun 2016 23:13:08 +0000 (20:13 -0300)]
lpfc: fix oops in lpfc_sli4_scmd_to_wqidx_distr() from lpfc_send_taskmgmt()

The lpfc_sli4_scmd_to_wqidx_distr() function expects the scsi_cmnd
'lpfc_cmd->pCmd' not to be null, and point to the midlayer command.

That's not true in the .eh_(device|target|bus)_reset_handler path,
because lpfc_send_taskmgmt() sends commands not from the midlayer, so
does not set 'lpfc_cmd->pCmd'.

That is true in the .queuecommand path because lpfc_queuecommand()
stores the scsi_cmnd from midlayer in lpfc_cmd->pCmd; and lpfc_cmd is
stored by lpfc_scsi_prep_cmnd() in piocbq->context1 -- which is passed
to lpfc_sli4_scmd_to_wqidx_distr() as lpfc_cmd parameter.

This problem can be hit on SCSI EH, and immediately with sg_reset.
These 2 test-cases demonstrate the problem/fix with next-20160601.

Test-case 1) sg_reset

    # strace sg_reset --device /dev/sdm
    <...>
    open("/dev/sdm", O_RDWR|O_NONBLOCK)     = 3
    ioctl(3, SG_SCSI_RESET, 0x3fffde6d0994 <unfinished ...>
    +++ killed by SIGSEGV +++
    Segmentation fault

    # dmesg
    Unable to handle kernel paging request for data at address 0x00000000
    Faulting instruction address: 0xd00000001c88442c
    Oops: Kernel access of bad area, sig: 11 [#1]
    <...>
    CPU: 104 PID: 16333 Comm: sg_reset Tainted: G        W       4.7.0-rc1-next-20160601-00004-g95b89dc #6
    <...>
    NIP [d00000001c88442c] lpfc_sli4_scmd_to_wqidx_distr+0xc/0xd0 [lpfc]
    LR [d00000001c826fe8] lpfc_sli_calc_ring.part.27+0x98/0xd0 [lpfc]
    Call Trace:
    [c000003c9ec876f0] [c000003c9ec87770] 0xc000003c9ec87770 (unreliable)
    [c000003c9ec87720] [d00000001c82e004] lpfc_sli_issue_iocb+0xd4/0x260 [lpfc]
    [c000003c9ec87780] [d00000001c831a3c] lpfc_sli_issue_iocb_wait+0x15c/0x5b0 [lpfc]
    [c000003c9ec87880] [d00000001c87f27c] lpfc_send_taskmgmt+0x24c/0x650 [lpfc]
    [c000003c9ec87950] [d00000001c87fd7c] lpfc_device_reset_handler+0x10c/0x200 [lpfc]
    [c000003c9ec87a10] [c000000000610694] scsi_try_bus_device_reset+0x44/0xc0
    [c000003c9ec87a40] [c0000000006113e8] scsi_ioctl_reset+0x198/0x2c0
    [c000003c9ec87bf0] [c00000000060fe5c] scsi_ioctl+0x13c/0x4b0
    [c000003c9ec87c80] [c0000000006629b0] sd_ioctl+0xf0/0x120
    [c000003c9ec87cd0] [c00000000046e4f8] blkdev_ioctl+0x248/0xb70
    [c000003c9ec87d30] [c0000000002a1f60] block_ioctl+0x70/0x90
    [c000003c9ec87d50] [c00000000026d334] do_vfs_ioctl+0xc4/0x890
    [c000003c9ec87de0] [c00000000026db60] SyS_ioctl+0x60/0xc0
    [c000003c9ec87e30] [c000000000009120] system_call+0x38/0x108
    Instruction dump:
    <...>

    With fix:

    # strace sg_reset --device /dev/sdm
    <...>
    open("/dev/sdm", O_RDWR|O_NONBLOCK)     = 3
    ioctl(3, SG_SCSI_RESET, 0x3fffe103c554) = 0
    close(3)                                = 0
    exit_group(0)                           = ?
    +++ exited with 0 +++

    # dmesg
    [  424.658649] lpfc 0006:01:00.4: 4:(0):0713 SCSI layer issued Device Reset (1, 0) return x2002

Test-case 2) SCSI EH

    Using this debug patch to wire an SCSI EH trigger, for lpfc_scsi_cmd_iocb_cmpl():
    -       cmd->scsi_done(cmd);
    +       if ((phba->pport ? phba->pport->cfg_log_verbose : phba->cfg_log_verbose) == 0x32100000)
    +               printk(KERN_ALERT "lpfc: skip scsi_done()\n");
    +       else
    +               cmd->scsi_done(cmd);

    # echo 0x32100000 > /sys/class/scsi_host/host11/lpfc_log_verbose

    # dd if=/dev/sdm of=/dev/null iflag=direct &
    <...>

    After a while:

    # dmesg
    lpfc 0006:01:00.4: 4:(0):3053 lpfc_log_verbose changed from 0 (x0) to 839909376 (x32100000)
    lpfc: skip scsi_done()
    <...>
    Unable to handle kernel paging request for data at address 0x00000000
    Faulting instruction address: 0xd0000000199e448c
    Oops: Kernel access of bad area, sig: 11 [#1]
    <...>
    CPU: 96 PID: 28556 Comm: scsi_eh_11 Tainted: G        W       4.7.0-rc1-next-20160601-00004-g95b89dc #6
    <...>
    NIP [d0000000199e448c] lpfc_sli4_scmd_to_wqidx_distr+0xc/0xd0 [lpfc]
    LR [d000000019986fe8] lpfc_sli_calc_ring.part.27+0x98/0xd0 [lpfc]
    Call Trace:
    [c000000ff0d0b890] [c000000ff0d0b900] 0xc000000ff0d0b900 (unreliable)
    [c000000ff0d0b8c0] [d00000001998e004] lpfc_sli_issue_iocb+0xd4/0x260 [lpfc]
    [c000000ff0d0b920] [d000000019991a3c] lpfc_sli_issue_iocb_wait+0x15c/0x5b0 [lpfc]
    [c000000ff0d0ba20] [d0000000199df27c] lpfc_send_taskmgmt+0x24c/0x650 [lpfc]
    [c000000ff0d0baf0] [d0000000199dfd7c] lpfc_device_reset_handler+0x10c/0x200 [lpfc]
    [c000000ff0d0bbb0] [c000000000610694] scsi_try_bus_device_reset+0x44/0xc0
    [c000000ff0d0bbe0] [c0000000006126cc] scsi_eh_ready_devs+0x49c/0x9c0
    [c000000ff0d0bcb0] [c000000000614160] scsi_error_handler+0x580/0x680
    [c000000ff0d0bd80] [c0000000000ae848] kthread+0x108/0x130
    [c000000ff0d0be30] [c0000000000094a8] ret_from_kernel_thread+0x5c/0xb4
    Instruction dump:
    <...>

    With fix:

    # dmesg
    lpfc 0006:01:00.4: 4:(0):3053 lpfc_log_verbose changed from 0 (x0) to 839909376 (x32100000)
    lpfc: skip scsi_done()
    <...>
    lpfc 0006:01:00.4: 4:(0):0713 SCSI layer issued Device Reset (0, 0) return x2002
    <...>
    lpfc 0006:01:00.4: 4:(0):0723 SCSI layer issued Target Reset (1, 0) return x2002
    <...>
    lpfc 0006:01:00.4: 4:(0):0714 SCSI layer issued Bus Reset Data: x2002
    <...>
    lpfc 0006:01:00.4: 4:(0):3172 SCSI layer issued Host Reset Data:
    <...>

Orabug: 24434040
Mainline commit: 05a05872c8d4b4357c9d913e6d73ae64882bddf5

Fixes: 8b0dff14164d ("lpfc: Add support for using block multi-queue")
Cc: <stable@vger.kernel.org> # v4.2+
Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Acked-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Ashok Vairavan <ashok.vairavan@oracle.com>
8 years agoblock: Initialize max_dev_sectors to 0
Keith Busch [Wed, 10 Feb 2016 23:52:47 +0000 (16:52 -0700)]
block: Initialize max_dev_sectors to 0

Orabug: 23615929

(commit 5f009d3f8e6685fe8c6215082c1696a08b411220 of upstream)
The new queue limit is not used by the majority of block drivers, and
should be initialized to 0 for the driver's requested settings to be used.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Joe Jin <joe.jin@oracle.com>
8 years agosd: Fix rw_max for devices that report an optimal xfer size
Martin K. Petersen [Fri, 13 May 2016 02:17:34 +0000 (22:17 -0400)]
sd: Fix rw_max for devices that report an optimal xfer size

Orabug: 23615929

(commit 6b7e9cde49691e04314342b7dce90c67ad567fcc of upstream)
For historic reasons, io_opt is in bytes and max_sectors in block layer
sectors. This interface inconsistency is error prone and should be
fixed. But for 4.4--4.7 let's make the unit difference explicit via a
wrapper function.

Fixes: d0eb20a863ba ("sd: Optimal I/O size is in bytes, not sectors")
Cc: stable@vger.kernel.org # 4.4+
Reported-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Tested-by: Andrew Patterson <andrew.patterson@hpe.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Joe Jin <joe.jin@oracle.com>
8 years agosd: Fix excessive capacity printing on devices with blocks bigger than 512 bytes
Martin K. Petersen [Tue, 29 Mar 2016 01:18:56 +0000 (21:18 -0400)]
sd: Fix excessive capacity printing on devices with blocks bigger than 512 bytes

Orabug: 23615929

(commit f08bb1e0dbdd0297258d0b8cd4dbfcc057e57b2a of upstream)
During revalidate we check whether device capacity has changed before we
decide whether to output disk information or not.

The check for old capacity failed to take into account that we scaled
sdkp->capacity based on the reported logical block size. And therefore
the capacity test would always fail for devices with sectors bigger than
512 bytes and we would print several copies of the same discovery
information.

Avoid scaling sdkp->capacity and instead adjust the value on the fly
when setting the block device capacity and generating fake C/H/S
geometry.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Cc: <stable@vger.kernel.org>
Reported-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Hannes Reinicke <hare@suse.de>
Reviewed-by: Ewan Milne <emilne@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Joe Jin <joe.jin@oracle.com>
8 years agosd: Optimal I/O size is in bytes, not sectors
Martin K. Petersen [Wed, 20 Jan 2016 16:01:23 +0000 (11:01 -0500)]
sd: Optimal I/O size is in bytes, not sectors

Orabug: 23615929

(commit d0eb20a863ba7dc1d3f4b841639671f134560be2 of upstream)
Commit ca369d51b3e1 ("block/sd: Fix device-imposed transfer length
limits") accidentally switched optimal I/O size reporting from bytes to
block layer sectors.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
Fixes: ca369d51b3e1649be4a72addd6d6a168cfb3f537
Cc: stable@vger.kernel.org # 4.4+
Reviewed-by: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Joe Jin <joe.jin@oracle.com>
8 years agosd: Reject optimal transfer length smaller than page size
Martin K. Petersen [Wed, 16 Dec 2015 22:53:52 +0000 (17:53 -0500)]
sd: Reject optimal transfer length smaller than page size

Orabug: 23615929

(commit 9c1d9c207bb800498347a2716da298043ee280c5 of upstream)
Eryu Guan reported that loading scsi_debug would fail. This turned out
to be caused by scsi_debug reporting an optimal I/O size of 32KB which
is smaller than the 64KB page size on the PowerPC system in question.

Add a check to ensure that we only use the device-reported OPTIMAL
TRANSFER LENGTH if it is bigger than or equal to the page cache size.

Reported-by: Eryu Guan <guaneryu@gmail.com>
Reported-by: Ming Lei <tom.leiming@gmail.com>
Reviewed-by: Douglas Gilbert <dgilbert@interlog.com>
Reviewed-by: Ewan Milne <emilne@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Joe Jin <joe.jin@oracle.com>
8 years agoblock/sd: Fix device-imposed transfer length limits
Joe Jin [Mon, 6 Jun 2016 05:22:30 +0000 (13:22 +0800)]
block/sd: Fix device-imposed transfer length limits

Orabug: 23615929

(commit ca369d51b3e1649be4a72addd6d6a168cfb3f537 of upstream)
Commit 4f258a46346c ("sd: Fix maximum I/O size for BLOCK_PC requests")
had the unfortunate side-effect of removing an implicit clamp to
BLK_DEF_MAX_SECTORS for REQ_TYPE_FS requests in the block layer
code. This caused problems for some SMR drives.

Debugging this issue revealed a few problems with the existing
infrastructure since the block layer didn't know how to deal with
device-imposed limits, only limits set by the I/O controller.

 - Introduce a new queue limit, max_dev_sectors, which is used by the
   ULD to signal the maximum sectors for a REQ_TYPE_FS request.

 - Ensure that max_dev_sectors is correctly stacked and taken into
   account when overriding max_sectors through sysfs.

 - Rework sd_read_block_limits() so it saves the max_xfer and opt_xfer
   values for later processing.

 - In sd_revalidate() set the queue's max_dev_sectors based on the
   MAXIMUM TRANSFER LENGTH value in the Block Limits VPD. If this value
   is not reported, fall back to a cap based on the CDB TRANSFER LENGTH
   field size.

 - In sd_revalidate(), use OPTIMAL TRANSFER LENGTH from the Block Limits
   VPD--if reported and sane--to signal the preferred device transfer
   size for FS requests. Otherwise use BLK_DEF_MAX_SECTORS.

 - blk_limits_max_hw_sectors() is no longer used and can be removed.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=93581
Reviewed-by: Christoph Hellwig <hch@lst.de>
Tested-by: sweeneygj@gmx.com
Tested-by: Arzeets <anatol.pomozov@gmail.com>
Tested-by: David Eisner <david.eisner@oriel.oxon.org>
Tested-by: Mario Kicherer <dev@kicherer.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Joe Jin <joe.jin@oracle.com>
Conflicts:
  drivers/scsi/sd.h
  include/linux/blkdev.h
    Adding opt_xfer_blocks and max_dev_sectors breaks kABI.
    They will be added using by UEK_KABI_USE2() in a fix-up commit.
Signed-off-by: Chuck Anderson <chuck.anderson@oracle.com>
8 years agobfa: Fix for crash when bfa_itnim is NULL
Sudarsana Reddy Kalluru [Wed, 6 Jul 2016 10:51:29 +0000 (06:51 -0400)]
bfa: Fix for crash when bfa_itnim is NULL

Orabug: 23950878

Fix a very corner case when the port gets disconnected and the BFA and
FCS layers clean up references to the IT nexus.  During this window if a
task management command is issued by the SCSI-ML and ends up referencing
a NULL itnim, it could lead to a crash.

Signed-off-by: Anil Gurumurthy <anil.gurumurthy@qlogic.com>
Tested-by: Sudarasana Kalluru <sudarsana.kalluru@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agobfa:Update driver version to 3.2.25.0
Anil Gurumurthy [Thu, 26 Nov 2015 07:17:05 +0000 (12:47 +0530)]
bfa:Update driver version to 3.2.25.0

Orabug: 23950878

Signed-off-by: Sudarsana Kalluru <sudarsana.kalluru@qlogic.com>
Signed-off-by: Anil Gurumurthy <anil.gurumurthy@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agobfa:File header and user visible string changes
Anil Gurumurthy [Thu, 26 Nov 2015 07:14:35 +0000 (12:44 +0530)]
bfa:File header and user visible string changes

Orabug: 23950878

Signed-off-by: Sudarsana Kalluru <sudarsana.kalluru@qlogic.com>
Signed-off-by: Anil Gurumurthy <anil.gurumurthy@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agobfa:Updating copyright messages
Anil Gurumurthy [Thu, 26 Nov 2015 07:09:00 +0000 (12:39 +0530)]
bfa:Updating copyright messages

Orabug: 23950878

Signed-off-by: Sudarsana Kalluru <sudarsana.kalluru@qlogic.com>
Signed-off-by: Anil Gurumurthy <anil.gurumurthy@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agobfa: Fix incorrect de-reference of pointer
Anil Gurumurthy [Thu, 13 Aug 2015 10:14:24 +0000 (03:14 -0700)]
bfa: Fix incorrect de-reference of pointer

Orabug: 23950878

Signed-off-by: Anil Gurumurthy <anil.gurumurthy@qlogic.com>
Tested-by: Sudarsana Kalluru <sudarsana.kalluru@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agobfa: Fix indentation
Anil Gurumurthy [Thu, 13 Aug 2015 10:12:47 +0000 (03:12 -0700)]
bfa: Fix indentation

Orabug: 23950878

Signed-off-by: Anil Gurumurthy <anil.gurumurthy@qlogic.com>
Tested-by : Sudarasana Kalluru <sudarsana.kalluru@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agolpfc updates to 11.1.0.4 for uek4-r2
rkennedy [Mon, 20 Jun 2016 18:05:12 +0000 (11:05 -0700)]
lpfc updates to 11.1.0.4 for uek4-r2

Orabug: 23762058

Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agolpfc: Update modified file copyrights
James Smart [Thu, 31 Mar 2016 21:12:34 +0000 (14:12 -0700)]
lpfc: Update modified file copyrights

Signed-off-by: Dick Kennedy <dick.kennedy@avagotech.com>
Signed-off-by: James Smart <james.smart@avagotech.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23762058
(cherry picked from commit 506115777af017bfc0968ee1c6aed024cdb6e43b)
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agolpfc: Fix interaction between fdmi_on and enable_SmartSAN
James Smart [Thu, 31 Mar 2016 21:12:33 +0000 (14:12 -0700)]
lpfc: Fix interaction between fdmi_on and enable_SmartSAN

Signed-off-by: Dick Kennedy <dick.kennedy@avagotech.com>
Signed-off-by: James Smart <james.smart@avagotech.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23762058
(cherry picked from commit 8663cbbe3ba0d8142faec48bbab0dc3482e3007d)
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agolpfc: Add support for SmartSAN 2.0
James Smart [Thu, 31 Mar 2016 21:12:32 +0000 (14:12 -0700)]
lpfc: Add support for SmartSAN 2.0

Revise versions to reflect SmartSAN 2.0 support

RDP updated to support additional descriptors:
  Credit descriptor
  Optical Element Data descriptors for Temperature, Voltage,
        Bias current, TX power and TX power.
  Optical Product Data descriptor.

Signed-off-by: Dick Kennedy <dick.kennedy@avagotech.com>
Signed-off-by: James Smart <james.smart@avagotech.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23762058
(cherry picked from commit 56204984761d80b973a0a534c42566ad78303766)
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agolpfc: Fix Device discovery failures during switch reboot test.
James Smart [Thu, 31 Mar 2016 21:12:31 +0000 (14:12 -0700)]
lpfc: Fix Device discovery failures during switch reboot test.

When the switch is rebooted, the lpfc driver fails to log
into the fabric, and Unexpected timeout message is seen.

Fix: Do not issue RegVFI if the FLOGI was internally aborted.

Signed-off-by: Dick Kennedy <dick.kennedy@avagotech.com>
Signed-off-by: James Smart <james.smart@avagotech.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23762058
(cherry picked from commit 342b59caa66240b670285d519fdfe2c44289b516)
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agolpfc: Utilize embedded CDB logic to minimize IO latency
James Smart [Thu, 31 Mar 2016 21:12:30 +0000 (14:12 -0700)]
lpfc: Utilize embedded CDB logic to minimize IO latency

Pass cmd iu payloads inline to adapter job structure rather than as
separate dma buffers.

Signed-off-by: Dick Kennedy <dick.kennedy@avagotech.com>
Signed-off-by: James Smart <james.smart@avagotech.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23762058
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agolpfc: Fix crash when unregistering default rpi.
James Smart [Thu, 31 Mar 2016 21:12:29 +0000 (14:12 -0700)]
lpfc: Fix crash when unregistering default rpi.

The default rpi completion handler does back to back puts to force the
removal of the ndlp. This ends up calling lpfc_unreg_rpi after the
reference count is at 0.

Fix:  Check the reference count of the ndlp before getting the ref to
make sure we are not getting a reference on a removed object.

Signed-off-by: Dick Kennedy <dick.kennedy@avagotech.com>
Signed-off-by: James Smart <james.smart@avagotech.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23762058
(cherry picked from commit a6517db9006eb618dfde54f4bf6a9a8bc21e16e7)
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agolpfc: Fix DMA faults observed upon plugging loopback connector
James Smart [Thu, 31 Mar 2016 21:12:28 +0000 (14:12 -0700)]
lpfc: Fix DMA faults observed upon plugging loopback connector

Driver didn't program the REG_VFI mailbox correctly, giving the adapter
bad addresses.

Signed-off-by: Dick Kennedy <dick.kennedy@avagotech.com>
Signed-off-by: James Smart <james.smart@avagotech.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23762058
(cherry picked from commit ae09c765109293b600ba9169aa3d632e1ac1a843)
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agolpfc: Correct LOGO handling during login
James Smart [Thu, 31 Mar 2016 21:12:27 +0000 (14:12 -0700)]
lpfc: Correct LOGO handling during login

After a link bounce, when a remote port issues a LOGO while a REGLOGIN
is pending on that port, the driver does not clean up the ndlp
structure. May result in stack traces in the console log.

Fix: Clear the NLP_REG_LOGIN_SEND flag on the ndlp in the routine

Signed-off-by: Dick Kennedy <dick.kennedy@avagotech.com>
Signed-off-by: James Smart <james.smart@avagotech.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23762058
(cherry picked from commit de96e9c5b82801ea17558c271730fdc2aa5e7e77)
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agolpfc: fix misleading indentation
Arnd Bergmann [Mon, 14 Mar 2016 14:29:44 +0000 (15:29 +0100)]
lpfc: fix misleading indentation

gcc-6 complains about the indentation of the lpfc_destroy_vport_work_array()
call in lpfc_online(), which clearly doesn't look right:

drivers/scsi/lpfc/lpfc_init.c: In function 'lpfc_online':
drivers/scsi/lpfc/lpfc_init.c:2880:3: warning: statement is indented as if it were guarded by... [-Wmisleading-indentation]
   lpfc_destroy_vport_work_array(phba, vports);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/lpfc/lpfc_init.c:2863:2: note: ...this 'if' clause, but it is not
  if (vports != NULL)
  ^~

Looking at the patch that introduced this code, it's clear that the
behavior is correct and the indentation is wrong.

This fixes the indentation and adds curly braces around the previous
if() block for clarity, as that is most likely what caused the code
to be misindented in the first place.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 549e55cd2a1b ("[SCSI] lpfc 8.2.2 : Fix locking around HBA's port_list")
Reviewed-by: Sebastian Herbszt <herbszt@gmx.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23762058
(cherry picked from commit aeb6641f8ebdd61939f462a8255b316f9bfab707)
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agolpfc: fix missing zero termination in debugfs
Alan [Mon, 15 Feb 2016 19:11:56 +0000 (19:11 +0000)]
lpfc: fix missing zero termination in debugfs

If you feed 32 bytes in then the kstrtoull() doesn't receive a terminated
string so will run off the end.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23762058
(cherry picked from commit 0872774d8a319676dea7416e0cf85bec63eea0d0)
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agolpfc: Remove redundant code block in lpfc_scsi_cmd_iocb_cmpl
Johannes Thumshirn [Wed, 20 Jan 2016 15:08:40 +0000 (16:08 +0100)]
lpfc: Remove redundant code block in lpfc_scsi_cmd_iocb_cmpl

This removes a redundant code block that will either be executed if the
ENABLE_FCP_RING_POLLING flag is set in phba->cfg_poll or not. The code
is just duplicated in both cases, hence we unify it again.

This probably is a left over from some sort of refactoring.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Reviewed-by: Sebastian Herbszt <herbszt@gmx.de>
Acked-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23762058
(cherry picked from commit 19db2307365231e798bb99324ed553bcada57913)
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
8 years agoqla2xxx: Update driver version to 8.07.00.38.40.0-k.
Sawan Chandak [Thu, 7 Jul 2016 10:16:44 +0000 (15:46 +0530)]
qla2xxx: Update driver version to 8.07.00.38.40.0-k.

Orabug: 23755773

Signed-off-by: Sawan Chandak <sawan.chandak@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agoqla2xxx: Fix BBCR offset
Sawan Chandak [Thu, 30 Jun 2016 04:34:02 +0000 (21:34 -0700)]
qla2xxx: Fix BBCR offset

Orabug: 23755773

Fixes: 969a619 ("qla2xxx: Add support for buffer to buffer credit value for ISP27XX.")
Signed-off-by: Sawan Chandak <sawan.chandak@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agoqla2xxx: Disable the adapter and skip error recovery in case of register disconnect.
Sawan Chandak [Fri, 3 Jun 2016 05:57:54 +0000 (11:27 +0530)]
qla2xxx: Disable the adapter and skip error recovery in case of register disconnect.

Orabug: 23755773

If there is error recovery going on due to command timeout and
there is register disconnect, then disable the adapter.

Signed-off-by: Sawan Chandak <sawan.chandak@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agoqla2xxx: Separate ISP type bits out from device type.
Joe Carnuccio [Fri, 3 Jun 2016 05:55:57 +0000 (11:25 +0530)]
qla2xxx: Separate ISP type bits out from device type.

Orabug: 23755773

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agoqla2xxx: Correction to function qla26xx_dport_diagnostics().
Joe Carnuccio [Thu, 7 Jul 2016 10:08:03 +0000 (15:38 +0530)]
qla2xxx: Correction to function qla26xx_dport_diagnostics().

Orabug: 23755773

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agoqla2xxx: Add support to handle Loop Init error Asynchronus event.
Joe Carnuccio [Thu, 7 Jul 2016 10:09:34 +0000 (15:39 +0530)]
qla2xxx: Add support to handle Loop Init error Asynchronus event.

Orabug: 23755773

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agoqla2xxx: Let DPORT be enabled purely by nvram.
Joe Carnuccio [Thu, 7 Jul 2016 08:20:20 +0000 (13:50 +0530)]
qla2xxx: Let DPORT be enabled purely by nvram.

Orabug: 23755773

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agoqla2xxx: Add bsg interface to support statistics counter reset.
Sawan Chandak [Thu, 7 Jul 2016 08:50:37 +0000 (14:20 +0530)]
qla2xxx: Add bsg interface to support statistics counter reset.

Orabug: 23755773

Signed-off-by: Sawan Chandak <sawan.chandak@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agoqla2xxx: Add bsg interface to support D_Port Diagnostics.
Joe Carnuccio [Thu, 7 Jul 2016 07:57:30 +0000 (13:27 +0530)]
qla2xxx: Add bsg interface to support D_Port Diagnostics.

Orabug: 23755773

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agoqla2xxx: Check for device state before unloading the driver.
Sawan Chandak [Thu, 7 Jul 2016 07:01:32 +0000 (12:31 +0530)]
qla2xxx: Check for device state before unloading the driver.

Orabug: 23755773

During hot swap of PCI device, there can be PCI error on device,
during normal driver unload. The race between normal driver unload and
driver unload due to PCI error, can lead to system crash.Fix is to check
if there is unload going on and allow that function to unload the driver.

Signed-off-by: Sawan Chandak <sawan.chandak@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agoqla2xxx: Properly reset firmware statistics.
Joe Carnuccio [Fri, 1 Apr 2016 19:35:55 +0000 (12:35 -0700)]
qla2xxx: Properly reset firmware statistics.

Orabug: 23755773

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agoqla2xxx: Properly initialize IO statistics.
Joe Carnuccio [Thu, 10 Mar 2016 00:44:03 +0000 (16:44 -0800)]
qla2xxx: Properly initialize IO statistics.

Orabug: 23755773

Properly initialize IO statistics to avoid initial 0xFFFFFFF (-1) values.

Cleanup/simplify usage of pointer to statistics structure.

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agoqla2xxx: Make debug buffer log easier to view.
Joe Carnuccio [Thu, 7 Jul 2016 06:31:34 +0000 (12:01 +0530)]
qla2xxx: Make debug buffer log easier to view.

Orabug: 23755773

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agoqla2xxx: Add module parameter alternate/short names.
Joe Carnuccio [Thu, 28 Jan 2016 22:52:03 +0000 (14:52 -0800)]
qla2xxx: Add module parameter alternate/short names.

Orabug: 23755773

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agoqla2xxx: Set FLOGI retry in additional firmware options for P2P (N2N) mode.
Giridhar Malavali [Thu, 7 Jul 2016 06:15:53 +0000 (11:45 +0530)]
qla2xxx: Set FLOGI retry in additional firmware options for P2P (N2N) mode.

Orabug: 23755773

When VP decoupling enabled, there could be a window where, FLOGI from
initiators can be dropped before VP0 is enabled, causing link level recovery.
Retry FLOGI to avoid link level recovery.

Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agoqla2xxx: Shutdown board on thermal shutdown aen.
Joe Carnuccio [Thu, 7 Jul 2016 06:03:08 +0000 (11:33 +0530)]
qla2xxx: Shutdown board on thermal shutdown aen.

Orabug: 23755773

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agoqla2xxx: Add ram area DDR for fwdump template entry T262.
Joe Carnuccio [Mon, 1 Feb 2016 18:42:04 +0000 (10:42 -0800)]
qla2xxx: Add ram area DDR for fwdump template entry T262.

Orabug: 23755773

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agoqla2xxx: Remove sysfs node fw_dump_template.
Joe Carnuccio [Mon, 22 Feb 2016 08:52:17 +0000 (14:22 +0530)]
qla2xxx: Remove sysfs node fw_dump_template.

Orabug: 23755773

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: Ethan Zhao <ethan.zhao@oracle.com>
8 years agompt3sas: Used "synchronize_irq()"API to synchronize timed-out IO & TMs
Chaitra P B [Fri, 6 May 2016 08:59:31 +0000 (14:29 +0530)]
mpt3sas: Used "synchronize_irq()"API to synchronize timed-out IO & TMs

Replaced mpt3sas_base_flush_reply_queues() with
mpt3sas_base_sync_reply_irqs(),as mpt3sas_base_flush_reply_queues()
skips over reply queues that are currently busy (i.e. being handled by
interrupt processing in another core). If a reply queue is busy, then
call to synchronize_irq()in mpt3sas_base_sync_reply_irqs()make sures the
other core has finished flushing the queue and completed any calls to
the mid-layer scsi_done() routine.

Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 22529571
(cherry picked from commit 5f0dfb7a9bcc8139958f59ecb9bbd7e738ae702d)
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agompt3sas: Set maximum transfer length per IO to 4MB for VDs
Chaitra P B [Fri, 6 May 2016 08:59:30 +0000 (14:29 +0530)]
mpt3sas: Set maximum transfer length per IO to 4MB for VDs

Set maximum transfer length per IO on RAID volumes to 4MB by setting
VD's queue's max_sector to 8192.

Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 22529571
(cherry picked from commit 6c197093847e8cdec844df39a373bfe1f9a1ac8a)
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agompt3sas: Updating mpt3sas driver version to 13.100.00.00
Chaitra P B [Fri, 6 May 2016 08:59:29 +0000 (14:29 +0530)]
mpt3sas: Updating mpt3sas driver version to 13.100.00.00

Bump mpt3sas driver version from 12.100.00.00 to 13.100.00.00

Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 22529571
(cherry picked from commit b2500d76a0dbaa8993cd6b43941d23d31a312831)
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agompt3sas: Fix initial Reference tag field for 4K PI drives.
Chaitra P B [Fri, 6 May 2016 08:59:28 +0000 (14:29 +0530)]
mpt3sas: Fix initial Reference tag field for 4K PI drives.

Modified driver code to use scsi_prot_ref_tag() API instead of
scsi_get_lba(), while initializing reference tag field in the CDB.

Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 22529571
(cherry picked from commit 648512ccd7d42ccf761f515b7c0cb456a48c477a)
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agompt3sas: Handle active cable exception event
Chaitra P B [Fri, 6 May 2016 08:59:27 +0000 (14:29 +0530)]
mpt3sas: Handle active cable exception event

In-order to handle this 'MPI2_EVENT_ACTIVE_CABLE_EXCEPTION' event,
driver need to follow below steps,
1. Unmask the 'MPI2_EVENT_ACTIVE_CABLE_EXCEPTION' event,
so that FW can notify this event to host driver.
2. After receiving this event, add this event to AEN event queue,
for notifying this event to applications.
3. Then Print below message in kernel logs if the event data's reason
code is zero,
"Currently an active cable with ReceptacleID <ID_Value> cannot be powered
and devices connected to this active cable will not be seen. This active
cable requires <PowerValue_in_mW> of power"

This event is only for Intruder/Cutlass HBAs.

Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 22529571
(cherry picked from commit a470a51cd6481373cdf2b5934b1b9f7853688de9)
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agompt3sas: Update MPI header to 2.00.42
Chaitra P B [Fri, 6 May 2016 08:59:26 +0000 (14:29 +0530)]
mpt3sas: Update MPI header to 2.00.42

Updated MPI version and MPI header files.

ChangeList:
* Added SATADeviceWaitTime to SAS IO Unit Page 4
* Added EEDPObservedValue added to SCSI IO Reply message
* Added MPI2_EVENT_ACTIVE_CABLE_EXCEPTION and
  MPI26_EVENT_DATA_ACTIVE_CABLE_EXCEPT

Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 22529571
(cherry picked from commit 4fe6bc97efebdc5083aa749850928fad1740a60d)
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agompt3sas - remove unused fw_event_work elements
Joe Lawrence [Mon, 18 Apr 2016 14:50:12 +0000 (10:50 -0400)]
mpt3sas - remove unused fw_event_work elements

Firmware events are queued up using the fw_event_work's struct work, not
its delayed_work member.  The initial driver for SAS2 controllers had
handled firmware reset using the rescan barrier and was later redesigned
through "mpt2sas: [Resend] Host Reset code cleanup".  The delayed_work
variables are now unused and may provoke CONFIG_DEBUG_OBJECTS_TIMERS
"assert_init not available" false warnings in
_scsih_fw_event_cleanup_queue.

Cleanup fw_event_work's unused entries, update its kerneldoc, and
update _scsih_fw_event_cleanup_queue accordingly.

Fixes: 146b16c8071f (mpt3sas: Refcount fw_events and fix unsafe list usage)
Signed-off-by: Joe Lawrence <joe.lawrence@stratus.com>
Acked-by: Chaitra P B <chaitra.basappa@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 22529571
(cherry picked from commit b8ac0cc78b56e798851f1435bc673761d3fb877e)
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agompt3sas: Remove usage of 'struct timeval'
Tina Ruchandani [Wed, 13 Apr 2016 07:01:40 +0000 (00:01 -0700)]
mpt3sas: Remove usage of 'struct timeval'

'struct timeval' will have its tv_sec value overflow on 32-bit systems
in year 2038 and beyond. This patch replaces the use of struct timeval
for computing mpi_request.TimeStamp, and instead uses ktime_t which
provides 64-bit seconds value. The timestamp computed remains
unaffected (milliseconds since Unix epoch).

Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Acked-by: Sathya Prakash <sathya.prakash@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 22529571
(cherry picked from commit 23409bd4a8b051e28d0106c7a83f362617452098)
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agompt3sas: Don't overreach ioc->reply_post[] during initialization
Calvin Owens [Fri, 18 Mar 2016 19:45:42 +0000 (12:45 -0700)]
mpt3sas: Don't overreach ioc->reply_post[] during initialization

In _base_make_ioc_operational(), we walk ioc->reply_queue_list and pull
a pointer out of successive elements of ioc->reply_post[] for each entry
in that list if RDPQ is enabled.

Since the code pulls the pointer for the next iteration at the bottom of
the loop, it triggers the a KASAN dump on the final iteration:

    BUG: KASAN: slab-out-of-bounds in _base_make_ioc_operational+0x47b7/0x47e0 [mpt3sas] at addr ffff880754816ab0
    Read of size 8 by task modprobe/305
    <snip>
    Call Trace:
     [<ffffffff81dfc591>] dump_stack+0x4d/0x6c
     [<ffffffff814c9689>] print_trailer+0xf9/0x150
     [<ffffffff814ceda4>] object_err+0x34/0x40
     [<ffffffff814d1231>] kasan_report_error+0x221/0x530
     [<ffffffff814d1673>] __asan_report_load8_noabort+0x43/0x50
     [<ffffffffa0043637>] _base_make_ioc_operational+0x47b7/0x47e0 [mpt3sas]
     [<ffffffffa0049a51>] mpt3sas_base_attach+0x1991/0x2120 [mpt3sas]
     [<ffffffffa0053c93>] _scsih_probe+0xeb3/0x16b0 [mpt3sas]
     [<ffffffff81ebd047>] local_pci_probe+0xc7/0x170
     [<ffffffff81ebf2cf>] pci_device_probe+0x20f/0x290
     [<ffffffff820d50cd>] really_probe+0x17d/0x600
     [<ffffffff820d56a3>] __driver_attach+0x153/0x190
     [<ffffffff820cffac>] bus_for_each_dev+0x11c/0x1a0
     [<ffffffff820d421d>] driver_attach+0x3d/0x50
     [<ffffffff820d378a>] bus_add_driver+0x44a/0x5f0
     [<ffffffff820d666c>] driver_register+0x18c/0x3b0
     [<ffffffff81ebcb76>] __pci_register_driver+0x156/0x200
     [<ffffffffa00c8135>] _mpt3sas_init+0x135/0x1000 [mpt3sas]
     [<ffffffff81000423>] do_one_initcall+0x113/0x2b0
     [<ffffffff813caa5a>] do_init_module+0x1d0/0x4d8
     [<ffffffff81273909>] load_module+0x6729/0x8dc0
     [<ffffffff81276123>] SYSC_init_module+0x183/0x1a0
     [<ffffffff8127625e>] SyS_init_module+0xe/0x10
     [<ffffffff828fe7d7>] entry_SYSCALL_64_fastpath+0x12/0x6a

Fix this by pulling the value at the beginning of the loop.

Signed-off-by: Calvin Owens <calvinowens@fb.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Jens Axboe <axboe@fb.com>
Acked-by: Chaitra Basappa <chaitra.basappa@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 22529571
(cherry picked from commit 5ec8a1753bc29efa7e4b1391d691c9c719b30257)
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agompt3sas: Remove unnecessary synchronize_irq() before free_irq()
Lars-Peter Clausen [Fri, 4 Mar 2016 10:15:07 +0000 (11:15 +0100)]
mpt3sas: Remove unnecessary synchronize_irq() before free_irq()

Calling synchronize_irq() right before free_irq() is quite useless. On
one hand the IRQ can easily fire again before free_irq() is entered, on
the other hand free_irq() itself calls synchronize_irq() internally (in
a race condition free way), before any state associated with the IRQ is
freed.

Patch was generated using the following semantic patch:
// <smpl>
@@
expression irq;
@@
-synchronize_irq(irq);
 free_irq(irq, ...);
// </smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 22529571
(cherry picked from commit 7f8b8f3fba55b345f9b6e3f55906bef6e29e354b)
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agompt3sas: Free memory pools before retrying to allocate with different value.
Suganath prabu Subramani [Thu, 18 Feb 2016 08:39:45 +0000 (14:09 +0530)]
mpt3sas: Free memory pools before retrying to allocate with different value.

Deallocate resources before reallocating of the same in retry_allocation
path of _base_allocate_memory_pools()

Signed-off-by: Suganath prabu Subramani <suganath-prabu.subramani@avagotech.com>
Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 22529571
(cherry picked from commit 8ff045c92708a595b7e39d68bdc0bd7edc08a073)
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agompt3sas: Remove cpumask_clear for zalloc_cpumask_var and don't free free_cpu_mask_var...
Suganath prabu Subramani [Thu, 11 Feb 2016 09:32:55 +0000 (15:02 +0530)]
mpt3sas: Remove cpumask_clear for zalloc_cpumask_var and don't free free_cpu_mask_var before reply_q

Removed cpumask_clear as it is not required for zalloc_cpumask_var and
free free_cpumask_var before freeing reply_q.

Signed-off-by: Suganath prabu Subramani <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 22529571
(cherry picked from commit da3cec2515f0094796679876ba17ba359331dbf6)
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agompt3sas: Updating mpt3sas driver version to 12.100.00.00
Suganath prabu Subramani [Thu, 28 Jan 2016 06:37:07 +0000 (12:07 +0530)]
mpt3sas: Updating mpt3sas driver version to 12.100.00.00

Bump mpt3sas driver version from 09.102.00.00 to 12.100.00.00

Signed-off-by: Suganath prabu Subramani <suganath-prabu.subramani@avagotech.com>
Signed-off-by: Chaitra P B <chaitra.basappa@avagotech.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 22529571
(cherry picked from commit d867b655eadf01fd5231ad9f41010c4d3b002a16)
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agompt3sas: Fix for Asynchronous completion of timedout IO and task abort of timedout IO.
Suganath prabu Subramani [Thu, 28 Jan 2016 06:37:06 +0000 (12:07 +0530)]
mpt3sas: Fix for Asynchronous completion of timedout IO and task abort of timedout IO.

Track msix of each IO and use the same msix for issuing abort to timed
out IO. With this driver will process IO's reply first followed by TM.

Signed-off-by: Suganath prabu Subramani <suganath-prabu.subramani@avagotech.com>
Signed-off-by: Chaitra P B <chaitra.basappa@avagotech.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 22529571
(cherry picked from commit 03d1fb3a65783979f23bd58b5a0387e6992d9e26)
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agompt3sas: Updated MPI Header to 2.00.42
Suganath prabu Subramani [Thu, 28 Jan 2016 06:37:05 +0000 (12:07 +0530)]
mpt3sas: Updated MPI Header to 2.00.42

Updated MPI version and MPI header files.

Signed-off-by: Suganath prabu Subramani <suganath-prabu.subramani@avagotech.com>
Signed-off-by: Chaitra P B <chaitra.basappa@avagotech.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 22529571
(cherry picked from commit 5c739b6157bd090942e5847ddd12bfb99cd4240d)
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>