]> www.infradead.org Git - users/jedix/linux-maple.git/log
users/jedix/linux-maple.git
9 years agoixgbevf: use ether_addr_copy instead of memcpy
Emil Tantilov [Mon, 12 Oct 2015 17:55:51 +0000 (10:55 -0700)]
ixgbevf: use ether_addr_copy instead of memcpy

Orabug: 23177316

replace some instances of memcpy for setting up the mac address with
ether_addr_copy()

Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
Tested-by: Darin Miller <darin.j.miller@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
(cherry picked from commit 91a76baadec1f30e8441c3d52c2559468a4da693)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
9 years agoixgbe: Remove CS4227 diagnostic code
Mark Rustad [Fri, 2 Oct 2015 16:23:53 +0000 (09:23 -0700)]
ixgbe: Remove CS4227 diagnostic code

Orabug: 23177316

Testing has now shown that the diagnostic code used with the CS4227
is no longer needed, so remove it.

Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Tested-by: Darin Miller <darin.j.miller@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
(cherry picked from commit d206563ad8f6fb41943366cf22f1aabc19d2b1a7)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
9 years agoixgbe/ixgbevf: use napi_schedule_irqoff()
Alexander Duyck [Tue, 29 Sep 2015 22:19:43 +0000 (15:19 -0700)]
ixgbe/ixgbevf: use napi_schedule_irqoff()

Orabug: 23177316

The ixgbe_intr and ixgbe/ixgbevf_msix_clean_rings functions run from hard
interrupt context or with interrupts already disabled in netpoll.

They can use napi_schedule_irqoff() instead of napi_schedule()

Signed-off-by: Alexander Duyck <aduyck@mirantis.com>
Tested-by: Darin Miller <darin.j.miller@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
(cherry picked from commit ef2662b2a820aaca4c147b91659bf57c06688ede)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
9 years agoixgbevf: Limit lowest interrupt rate for adaptive interrupt moderation to 12K
Alexander Duyck [Tue, 29 Sep 2015 20:11:15 +0000 (13:11 -0700)]
ixgbevf: Limit lowest interrupt rate for adaptive interrupt moderation to 12K

Orabug: 23177316

This patch is the ixgbevf version of commit 8ac34f10a5ea4 "ixgbe: Limit
lowest interrupt rate for adaptive interrupt moderation to 12K"

The same logic applies here as well as the same results since a netperf
test will starve for memory in the time from one Tx interrupt to the next.
As a result the ixgbevf driver underperformed when compared to vhost_net.

Signed-off-by: Alexander Duyck <aduyck@mirantis.com>
Tested-by: Darin Miller <darin.j.miller@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
(cherry picked from commit 8a9ca1104da0de6dd8551237e7d0e50eeeea4e80)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
9 years agoixgbe: Add KR mode support for CS4227 chip
Mark Rustad [Mon, 28 Sep 2015 21:37:47 +0000 (14:37 -0700)]
ixgbe: Add KR mode support for CS4227 chip

Orabug: 23177316

KR auto-neg mode is what we will be using going forward. The SW
interface for this mode is different that what was used for iXFI.

Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
(cherry picked from commit d91e3a7d624590220e31ccb80a6fb5247cbfa64a)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
9 years agoixgbe: Fix handling of NAPI budget when multiple queues are enabled per vector
Alexander Duyck [Tue, 22 Sep 2015 21:35:41 +0000 (14:35 -0700)]
ixgbe: Fix handling of NAPI budget when multiple queues are enabled per vector

Orabug: 23177316

This patch corrects an issue in which the polling routine would increase
the budget for Rx to at least 1 per queue if multiple queues were present.
This would result in Rx packets being processed when the budget was 0 which
is meant to indicate that no Rx can be handled.

Signed-off-by: Alexander Duyck <aduyck@mirantis.com>
Tested-by: Darin Miller <darin.j.miller@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
(cherry picked from commit 5d6002b7b822c7423e75d4651e6790bfb5642b1b)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
9 years agoixgbe: fix multiple kernel-doc errors
Jean Sacren [Sat, 19 Sep 2015 11:08:44 +0000 (05:08 -0600)]
ixgbe: fix multiple kernel-doc errors

Orabug: 23177316

The commit dfaf891dd3e1 ("ixgbe: Refactor the RSS configuration code")
introduced a few kernel-doc errors:

1) The function name is missing;
2) The format is wrong;
3) The short description is redundant.

Fix all the above for the correct execution of the kernel doc.

Signed-off-by: Jean Sacren <sakiwit@gmail.com>
Tested-by: Darin Miller <darin.j.miller@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
(cherry picked from commit a897a2adb602fe3d9223aa59393be07341d3a124)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
9 years agoixgbe: Delete redundant include file
Mark Rustad [Fri, 18 Sep 2015 17:08:00 +0000 (10:08 -0700)]
ixgbe: Delete redundant include file

Orabug: 23177316

Delete a redundant include of net/vxlan.h.

Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Tested-by: Darin Miller <darin.j.miller@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
(cherry picked from commit cc1f88ba16fa5cc4769cf25dca9fafeb1546be50)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
9 years agoixgbe: drop null test before destroy functions
Julia Lawall [Sun, 13 Sep 2015 12:15:13 +0000 (14:15 +0200)]
ixgbe: drop null test before destroy functions

Orabug: 23177316

Remove unneeded NULL test.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@ expression x; @@
-if (x != NULL)
  \(kmem_cache_destroy\|mempool_destroy\|dma_pool_destroy\)(x);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Tested-by: Darin Miller <darin.j.miller@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
(cherry picked from commit edab421a57fbdb7f7b83fb494a48c47bc719a7f0)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
9 years agoixgbe: Reset interface after enabling SR-IOV
Alexander Duyck [Tue, 20 Oct 2015 20:28:17 +0000 (13:28 -0700)]
ixgbe: Reset interface after enabling SR-IOV

Orabug: 23177316

Enabling SR-IOV and then bringing the interface up was resulting in the PF
MAC addresses getting into a bad state.  Specifically the MAC address was
enabled for both VF 0 and the PF.  This resulted in some odd behaviors such
as VF 0 receiving a copy of the PFs traffic, which in turn enables the
ability for VF 0 to spoof the PF.

A workaround for this issue appears to be to bring up the interface first
and then enable SR-IOV as this way the reset is then triggered in the
existing code.

In order to correct this I have added a change to ixgbe_setup_tc where if
the interface is down we still will at least call ixgbe_reset so that the
MAC addresses for the device are reset to the correct pools.

Steps to reproduce issue:
modprobe ixgbe
echo 7 > /sys/bus/pci/devices/0000\:01\:00.1/sriov_numvfs
ifconfig enp1s0f1 up
ethregs -s 1:00.1 | grep MPSAR | grep -v 00000000

Result:
MPSAR[0]               00000081
MPSAR[254]             00000001

Expected Result, behavior after patch:
MPSAR[0]               00000080
MPSAR[254]             00000080

Signed-off-by: Alexander Duyck <aduyck@mirantis.com>
Tested-by: Darin Miller <darin.j.miller@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
(cherry picked from commit bf4d67d94c842edf57e3cac2c4dff58a9ce7ac41)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
9 years agoixgbe, ixgbevf: Add new mbox API xcast mode
Hiroshi Shimamoto [Fri, 28 Aug 2015 06:59:03 +0000 (06:59 +0000)]
ixgbe, ixgbevf: Add new mbox API xcast mode

Orabug: 23177316

The limitation of the number of multicast address for VF is not enough
for the large scale server with SR-IOV feature. IPv6 requires the multicast
MAC address for each IP address to handle the Neighbor Solicitation
message. We couldn't assign over 30 IPv6 addresses to a single VF.

This patch introduces the new mailbox API, IXGBE_VF_UPDATE_XCAST_MODE,
to update multicast mode of VF. This adds 3 modes;
  - NONE     only L2 exact match addresses or Flow Director enabled
  - MULTI    BAM and ROMPE set
  - ALLMULTI BAM, ROMPE and MPE set

If a guest VF user wants over 30 MAC multicast addresses, set IFF_ALLMULTI
to request PF to update xcast mode to enable VF multicast promiscuous mode.

On the other hand, enabling VF multicast promiscuous mode may affect
security and performance in the network of the NIC. Only trusted VF can
enable multicast promiscuous mode. The behavior of untrusted VF is the
same as previous version.

Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Tested-by: Krishneil Singh <Krishneil.k.singh@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
(cherry picked from commit 8443c1a4b192089e62642d847ebac3e4d15134c3)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
Conflicts:
drivers/net/ethernet/intel/ixgbe/ixgbe.h
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c

9 years agoixgbe: Check for setup_internal_link method
Mark Rustad [Wed, 9 Sep 2015 20:37:33 +0000 (13:37 -0700)]
ixgbe: Check for setup_internal_link method

Orabug: 23177316

Only call the internal_setup_link method when it is provided. This
check is required for newer version parts.

Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Tested-by: Darin Miller <darin.j.miller@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
(cherry picked from commit a85ce532f28efabda030d9065a0c2023a2003f36)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
9 years agoixgbe: Fix CS4227-related semaphore error on reset failure
Mark Rustad [Wed, 26 Aug 2015 21:10:22 +0000 (14:10 -0700)]
ixgbe: Fix CS4227-related semaphore error on reset failure

Orabug: 23177316

If the reset never completes, it is necessary to retake the
semaphore before returning, because the caller will release
the semaphore.

Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Tested-by: Darin Miller <darin.j.miller@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
(cherry picked from commit 8bf7a7b879985321c63e3ae46fee4e7f0d654ab1)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
9 years agoixgbe: disable LRO by default
Emil Tantilov [Tue, 25 Aug 2015 01:08:31 +0000 (18:08 -0700)]
ixgbe: disable LRO by default

Orabug: 23177316

This patch disables LRO by default in favor of GRO.

LRO is incompatible with forwarding and is disabled when forwarding
is turned on which makes the default offloads of the driver
inconsistent. LRO can still be enabled via ethtool.

Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
Tested-by: Darin Miller <darin.j.miller@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
(cherry picked from commit 72bfd32d2f84d26aa132dd74a8eef14d039d326f)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
9 years agoixgbe: add flow control ethertype to the anti-spoofing filter
Emil Tantilov [Thu, 20 Aug 2015 22:31:20 +0000 (15:31 -0700)]
ixgbe: add flow control ethertype to the anti-spoofing filter

Orabug: 23177316

This patch makes sure that flow control packets initiated by the VF are
dropped and reported as spoofed.

Flow control packets can be used to limit the throughput or as DOS
attack when generated from a VF. Flow control is not supported per VF
hence any pause frames generated from a VF are considered malicious.

Also cleaned up indentation and some redundant comments.

Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
Tested-by: Krishneil Singh <krishneil.k.singh@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
(cherry picked from commit f079fa005aae08ee0e1bc32699874ff4f02e11c1)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
9 years agoi40e: queue-specific settings for interrupt moderation
Kan Liang [Fri, 19 Feb 2016 14:24:04 +0000 (09:24 -0500)]
i40e: queue-specific settings for interrupt moderation

Orabug: 23176970

For i40e driver, each vector has its own ITR register. However, there
are no concept of queue-specific settings in the driver proper. Only
global variable is used to store ITR values. That will cause problems
especially when resetting the vector. The specific ITR values could be
lost.
This patch move rx_itr_setting and tx_itr_setting to i40e_ring to store
specific ITR register for each queue.
i40e_get_coalesce and i40e_set_coalesce are also modified accordingly to
support queue-specific settings. To make it compatible with old ethtool,
if user doesn't specify the queue number, i40e_get_coalesce will return
queue 0's value. While i40e_set_coalesce will apply value to all queues.

Signed-off-by: Kan Liang <kan.liang@intel.com>
Acked-by: Shannon Nelson <shannon.nelson@intel.com>
Acked-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit a75e8005d506f374554b17383c39aa82db0ea860)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
9 years agoNVMe: IO ending fixes on surprise removal
Keith Busch [Fri, 11 Dec 2015 20:14:28 +0000 (13:14 -0700)]
NVMe: IO ending fixes on surprise removal

This patch fixes a lost request discovered during IO + hot removal.

The driver's pci removal deletes gendisks prior to shutting down the
controller to allow dirty data to sync. Dirty data can not be synced on
a surprise removal, though, and would potentially block indefinitely.

The driver previously had marked the queue as dying in this scenario
to prevent new requests from attempting, however it will still block
for requests that already entered the queue. This patch fixes this by
quiescing IO first, then aborting the requeued requests before deleting
disks.

Reported-by: Sujith Pandel <sujith_pandel@dell.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Tested-by: Sujith Pandel <sujith_pandel@dell.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit b5875222de2fb91339db79a753677ba4f68120d0)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
Conflicts:
drivers/nvme/host/pci.c

9 years agonvme: temporary fix for Apple controller reset
Stephan Günther [Tue, 1 Dec 2015 20:23:22 +0000 (13:23 -0700)]
nvme: temporary fix for Apple controller reset

Recent patches added basic support for the Apple NVMe controller but
still cause resets and data corruption on that particular controller
when a specific pattern of read/flush commands occurs. Limiting the
queue depth to 2 works around that issue.

This patch enforces that limit only for the Apple controller and is
considered a temporary fix until we find the root source of that
problem.

Signed-off-by: Stephan Günther <guenther@tum.de>
Signed-off-by: Maurice Leclaire <leclaire@in.tum.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 1f390c1fde3a96974784be53cb3a645da3e4849c)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agonvme: add missing unmaps in nvme_queue_rq
Christoph Hellwig [Fri, 16 Oct 2015 05:58:31 +0000 (07:58 +0200)]
nvme: add missing unmaps in nvme_queue_rq

When we fail various metadata related operations in nvme_queue_rq we
need to unmap the data SGL.

Cc: stable@vger.kernel.org
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>
(cherry picked from commit bf508e910b02a6107a5aa054e03c6fc8a65dae1e)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe: default to 4k device page size
Nishanth Aravamudan [Tue, 24 Nov 2015 16:55:05 +0000 (09:55 -0700)]
NVMe: default to 4k device page size

We received a bug report recently when DDW (64-bit direct DMA on Power)
is not enabled for NVMe devices. In that case, we fall back to 32-bit
DMA via the IOMMU, which is always done via 4K TCEs (Translation Control
Entries).

The NVMe device driver, though, assumes that the DMA alignment for the
PRP entries will match the device's page size, and that the DMA aligment
matches the kernel's page aligment. On Power, the the IOMMU page size,
as mentioned above, can be 4K, while the device can have a page size of
8K, while the kernel has a page size of 64K. This eventually trips the
BUG_ON in nvme_setup_prps(), as we have a 'dma_len' that is a multiple
of 4K but not 8K (e.g., 0xF000).

In this particular case of page sizes, we clearly want to use the
IOMMU's page size in the driver. And generally, the NVMe driver in this
function should be using the IOMMU's page size for the default device
page size, rather than the kernel's page size. There is not currently an
API to obtain the IOMMU's page size across all architectures and in the
interest of a stop-gap fix to this functional issue, default the NVMe
device page size to 4K, with the intent of adding such an API and
implementation across all architectures in the next merge window.

With the functionally equivalent v3 of this patch, our hardware test
exerciser survives when using 32-bit DMA; without the patch, the kernel
will BUG within a few minutes.

Signed-off-by: Nishanth Aravamudan <nacc at linux.vnet.ibm.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit c5c9f25b98a568451d665afe4aeefe17bf9f2995)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe: reap completion entries when deleting queue
Keith Busch [Fri, 20 Nov 2015 15:38:13 +0000 (08:38 -0700)]
NVMe: reap completion entries when deleting queue

Make sure that there are no unprocesssed entries on a completion
queue before deleting it, and check for validity of the CQ
door bell before writing completions to it.

This fixes problems with doing a sysfs reset of the device while
it's handling IO.

Tested-by: Jon Derrick <jonathan.derrick@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 604e8c8da8854351496215d269c3fa93859e3fee)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe: Fix possible arithmetic overflow for max segments
Keith Busch [Wed, 18 Nov 2015 23:33:08 +0000 (16:33 -0700)]
NVMe: Fix possible arithmetic overflow for max segments

Reported-by: Paul Grabinar <paul.grabinar@ranbarg.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 6824c5ef5e8900e61ce8ed40885cacc1c9301c14)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe: add support for Apple NVMe controller
Stephan Günther [Tue, 3 Nov 2015 23:49:45 +0000 (00:49 +0100)]
NVMe: add support for Apple NVMe controller

Add PCI ID of Apple's NVMe controller.

Signed-off-by: Stephan Guenther <guenther@tum.de>
Signed-off-by: Maurice Leclaire <leclaire@in.tum.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit c74dc7801d515d01847fd5cf2b472489fa5717b1)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe: use split lo_hi_{read,write}q
Stephan Günther [Sun, 8 Nov 2015 01:07:02 +0000 (18:07 -0700)]
NVMe: use split lo_hi_{read,write}q

Some controllers may require ordered split transfers even on 64bit
machines, e.g. Apple's NVMe controller as found in the MacBook8,1 and
MacBookAir7,1 (256/512GB models).

This patch enforces ordered split transfers on 64bit platforms, which
works around that issue for all controllers. As pointed out by Christoph
[1] there should be no performance impact due to that modification.

[1] http://lists.infradead.org/pipermail/linux-nvme/2015-November/002965.html

Signed-off-by: Stephan Guenther <guenther@tum.de>
Signed-off-by: Maurice Leclaire <leclaire@in.tum.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Updated by me to explicitly use lo_hi_read/writeq instead of playing
define tricks.

Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit a310acd7a7ea53533886c11bb7edd11ffd61a036)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe: Increase the max transfer size when mdts is 0
Sathyavathi M [Thu, 5 Nov 2015 19:52:28 +0000 (12:52 -0700)]
NVMe: Increase the max transfer size when mdts is 0

This patch address the issue when IO with 128KB from FIO is split into
two parts, 124KB and 4KB, due to max transfer size(127KB). This degrades
the device performance.

Signed-off-by: Sathyavathi M <sathya.m@samsung.com>
Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit b12363d0a5da00c422641f3d926fffb713192ea3)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
Conflicts:
drivers/nvme/host/pci.c

9 years agonvme: fix 32-bit build warning
Arnd Bergmann [Tue, 6 Oct 2015 20:29:48 +0000 (22:29 +0200)]
nvme: fix 32-bit build warning

Compiling the nvme driver on 32-bit warns about a cast from a __u64
variable to a pointer:

drivers/block/nvme-core.c: In function 'nvme_submit_io':
drivers/block/nvme-core.c:1847:4: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
    (void __user *)io.addr, length, NULL, 0);

The cast here is intentional and safe, so we can shut up the
gcc warning by adding an intermediate cast to 'uintptr_t'.

I had previously submitted a patch to fix this problem in the
nvme driver, but it was accepted on the same day that two new
warnings got added.

For clarification, I also change the third instance of this cast
to use uintptr_t instead of unsigned long now.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: d29ec8241c10e ("nvme: submit internal commands through the block layer")
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 3d42e67fe5ebc1e5c3aae9b1037e38ec99a362cc)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
Conflicts:
drivers/nvme/host/pci.c

9 years agoNVMe: Add explicit block config dependency
Keith Busch [Mon, 12 Oct 2015 17:37:38 +0000 (11:37 -0600)]
NVMe: Add explicit block config dependency

The nvme driver was moved from drivers/block, losing our implicit
dependency on CONFIG_BLOCK. This makes it an explicit driver dependency.

Reported-by: Jim Davis <jim.epost@gmail.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 11feb18f4edb1423ed6091908c45de7ade30d5b7)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agonvme: move to a new drivers/nvme/host directory
Jay Sternberg [Fri, 9 Oct 2015 16:17:06 +0000 (18:17 +0200)]
nvme: move to a new drivers/nvme/host directory

This patch moves the NVMe driver from drivers/block/ to its own new
drivers/nvme/host/ directory.  This is in preparation of splitting the
current monolithic driver up and add support for the upcoming NVMe
over Fabrics standard.  The drivers/nvme/host/ is chose to leave space
for a NVMe target implementation in addition to this host side driver.

Signed-off-by: Jay Sternberg <jay.e.sternberg@intel.com>
[hch: rebased, renamed core.c to pci.c, slight tweaks]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 57dacad5f2288e3de91f99b29f07b4a2793446d2)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoblock: export blkdev_reread_part() and __blkdev_reread_part()
Jarod Wilson [Wed, 6 May 2015 04:26:22 +0000 (12:26 +0800)]
block: export blkdev_reread_part() and __blkdev_reread_part()

This patch exports blkdev_reread_part() for block drivers, also
introduce __blkdev_reread_part().

For some drivers, such as loop, reread of partitions can be run
from the release path, and bd_mutex may already be held prior to
calling ioctl_by_bdev(bdev, BLKRRPART, 0), so introduce
__blkdev_reread_part for use in such cases.

CC: Christoph Hellwig <hch@lst.de>
CC: Jens Axboe <axboe@kernel.dk>
CC: Tejun Heo <tj@kernel.org>
CC: Alexander Viro <viro@zeniv.linux.org.uk>
CC: Markus Pargmann <mpa@pengutronix.de>
CC: Stefan Weinhuber <wein@de.ibm.com>
CC: Stefan Haberland <stefan.haberland@de.ibm.com>
CC: Sebastian Ott <sebott@linux.vnet.ibm.com>
CC: Fabian Frederick <fabf@skynet.be>
CC: Ming Lei <ming.lei@canonical.com>
CC: David Herrmann <dh.herrmann@gmail.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Peter Zijlstra <peterz@infradead.org>
CC: nbd-general@lists.sourceforge.net
CC: linux-s390@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit be32417796c2b8a83fe4cbece83bea96ab9e378f)

Needed by Nvme driver update

Orabug: 22620486

Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNvme: fix build error
Jason Luo [Wed, 3 Feb 2016 04:38:16 +0000 (12:38 +0800)]
Nvme: fix build error

error: implicit declaration of function 'nvme_identify'
which is introduced by b4145035630715ee821528f209f098

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNvme: fix several build errors
Jason Luo [Wed, 3 Feb 2016 03:15:05 +0000 (11:15 +0800)]
Nvme: fix several build errors

struct nvme_queue' has no member named 'hctx which introduced
by a55c4be4f9afc516368d3a45360f735887cf72fe.

'REQ_TYPE_DRV_PRIV' undeclared (first use in this function)
while it's redefined as REQ_TYPE_SPECIAL in uek4.

Orabug: 22620486

Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agonvme: properly handle partially initialized queues in nvme_create_io_queues
Christoph Hellwig [Fri, 2 Oct 2015 16:51:31 +0000 (18:51 +0200)]
nvme: properly handle partially initialized queues in nvme_create_io_queues

This avoids having to clean up later in a seemingly unrelated place.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 2659e57b906562bb020fb093b0c1b670b9700314)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agonvme: merge nvme_dev_start, nvme_dev_resume and nvme_async_probe
Christoph Hellwig [Sat, 3 Oct 2015 07:49:23 +0000 (09:49 +0200)]
nvme: merge nvme_dev_start, nvme_dev_resume and nvme_async_probe

And give the resulting function a sensible name.  This keeps all the
error handling in a single place and will allow for further improvements
to it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 3cf519b5a8d4d067e3de19736283c9414402d3a2)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agonvme: factor reset code into a common helper
Christoph Hellwig [Fri, 2 Oct 2015 16:49:23 +0000 (18:49 +0200)]
nvme: factor reset code into a common helper

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 90667892c5a78b47080359883a569a260e9e87ed)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agonvme: delete dev from dev_list in nvme_reset
Christoph Hellwig [Fri, 2 Oct 2015 16:48:36 +0000 (18:48 +0200)]
nvme: delete dev from dev_list in nvme_reset

Device resets need to delete the device from the device list before
kicking of the reset an re-probe, otherwise we get the device added
to the list twice.  nvme_reset is the only side missing this deletion
at the moment, and this patch adds it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 201cf1ecdfe5ea2774cbb21d4214c98ec8b418de)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe: Namespace removal simplifications
Keith Busch [Fri, 2 Oct 2015 16:37:28 +0000 (10:37 -0600)]
NVMe: Namespace removal simplifications

This liberates namespace removal from the device, allowing gendisk
references to be closed independent of the nvme controller reference
count.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 5105aa555c1c681ae281ea0d6108efd0a5d8a5e8)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agonvme: merge nvme_dev_reset into nvme_reset_failed_dev
Christoph Hellwig [Fri, 2 Oct 2015 15:41:18 +0000 (17:41 +0200)]
nvme: merge nvme_dev_reset into nvme_reset_failed_dev

And give the resulting function a more descriptive name.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 77b50d9e15e113fdb871218aa0f2e3bed12ee731)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agonvme.h: add missing nvme_id_ctrl endianess annotations
Christoph Hellwig [Fri, 2 Oct 2015 13:27:16 +0000 (15:27 +0200)]
nvme.h: add missing nvme_id_ctrl endianess annotations

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 08c69640cfcbdcc7aaed31c05bbfaf03bb60611c)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agonvme: move hardware structures out of the uapi version of nvme.h
Christoph Hellwig [Fri, 2 Oct 2015 13:25:49 +0000 (15:25 +0200)]
nvme: move hardware structures out of the uapi version of nvme.h

Currently all NVMe command and completion structures are exposed to userspace
through the uapi version of nvme.h.  They are not an ABI between the kernel
and userspace, and will change in C-incompatible way for future versions of
the spec.  Move them to the kernel version of the file and rename the uapi
header to nvme_ioctl.h so that userspace can easily detect the presence of
the new clean header.  Nvme-cli already carries a local copy of the header,
so it won't be affected by this move.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 9d99a8dda154f38307d43d9c9aa504bd3703d596)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agonvme: add a local nvme.h header
Christoph Hellwig [Sat, 3 Oct 2015 13:46:41 +0000 (15:46 +0200)]
nvme: add a local nvme.h header

Add a new drivers/block/nvme.h which contains all the driver internal
interface.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit f11bb3e244c4b14e2d0a3b9d7e41895752997170)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe: Simplify device resume on io queue failure
Keith Busch [Fri, 2 Oct 2015 16:37:29 +0000 (10:37 -0600)]
NVMe: Simplify device resume on io queue failure

Releasing IO queues and disks was done in a work queue outside the
controller resume context to delete namespaces if the controller failed
after a resume from suspend. This is unnecessary since we can resume
a device asynchronously.

This patch makes resume use probe_work so it can directly remove
namespaces if the device is manageable but not IO capable. Since the
deleting disks was the only reason we had the convoluted "reset_workfn",
this patch removes that unnecessary indirection.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 0a7385ad69f0f210c5cfbfd334b42423a6e05e5a)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe: Reference count open namespaces
Keith Busch [Thu, 1 Oct 2015 23:14:10 +0000 (17:14 -0600)]
NVMe: Reference count open namespaces

Dynamic namespace attachment means the namespace may be removed at any
time, so the namespace reference count can not be tied to the device
reference count. This fixes a NULL dereference if an opened namespace
is detached from a controller.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 188c3568f814fea965947ed24739987ba9c5a87e)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe: Using PRACT bit to generate and verify PI by controller
Alok Pandey [Wed, 26 Aug 2015 14:56:14 +0000 (08:56 -0600)]
NVMe: Using PRACT bit to generate and verify PI by controller

This patch enables the PRCHK and reftag support when PRACT bit is set, and
block layer integrity is disabled.

Signed-off-by: Alok Pandey <pandey.alok@samsung.com>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit e19b127f5b76ec03b9c52b64f117dc75bb39eda1)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe: removed unused nn var from nvme_dev_add
Matias Bjørling [Tue, 18 Aug 2015 16:13:41 +0000 (10:13 -0600)]
NVMe: removed unused nn var from nvme_dev_add

The logic in nvme_dev_add to enumerate namespaces was moved to
nvme_dev_scan. When moved, the nn variable is no longer used. This patch
removes it.

Fixes: a5768aai ("NVMe: Automatic namespace rescan")
Signed-off-by: Matias Bjørling <m@bjorling.me>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit b2b1ec9b55ed0840956db15f823c4a73383c08be)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe: Set queue max segments
Keith Busch [Wed, 12 Aug 2015 22:17:54 +0000 (16:17 -0600)]
NVMe: Set queue max segments

This sets the queue's max segment size to match the device's
capabilities. The default of 128 is usable until a device's transfer
capability exceeds 512k, assuming a device page size of 4k. Many nvme
devices exceed that transfer limit, so this lets the block layer know what
kind of commands it to allow to form rather than unnecessarily split them.

One additional segment is added to account for a transfer that may start
in the middle of a page.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit e824410ffcf4b245296b56c6fdf7b9797fce8c3e)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe: Add nvme subsystem reset IOCTL
Jon Derrick [Mon, 10 Aug 2015 21:20:41 +0000 (15:20 -0600)]
NVMe: Add nvme subsystem reset IOCTL

Controllers can perform optional subsystem resets as introduced in NVMe
1.1. This patch adds an IOCTL to trigger the subsystem reset by writing
"NVMe" to the NSSR register.

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 81f03fedcce7ee7e83c37237ecaa2f68aad236fd)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe: Add nvme subsystem reset support
Keith Busch [Mon, 10 Aug 2015 21:20:40 +0000 (15:20 -0600)]
NVMe: Add nvme subsystem reset support

Controllers part of an NVMe subsystem may be reset by any other controller
in the subsystem. If the device is capable of subsystem resets, this
patch adds detection for such events and performs appropriate controller
initialization upon subsystem reset detection.

The register bit is a RW1C type, so the driver needs to write a 1 to the
status bit to clear the subsystem reset occured bit during initialization.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit dfbac8c7ac5f58448b2216fe42ff52aaf175421d)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe:Remove unreachable code in nvme_abort_req
Sunad Bhandary [Fri, 31 Jul 2015 13:26:58 +0000 (18:56 +0530)]
NVMe:Remove unreachable code in nvme_abort_req

Removing unreachable code from nvme_abort_req as nvme_submit_cmd has no
failure status to return.

Signed-off-by: Sunad Bhandary <sunad.s@samsung.com>
Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit e3f879bf1ea3e03f433d292b0114807785f0754b)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agonvme: Fixes u64 division which breaks i386 builds
Jon Derrick [Tue, 21 Jul 2015 21:08:13 +0000 (15:08 -0600)]
nvme: Fixes u64 division which breaks i386 builds

Uses div_u64 for u64 division and round_down, a bitwise operation,
instead of rounddown, which uses a modulus.

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit c45f5c9943ce0b16b299b543c2aae12408039027)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe: Use CMB for the IO SQes if available
Jon Derrick [Mon, 20 Jul 2015 16:14:09 +0000 (10:14 -0600)]
NVMe: Use CMB for the IO SQes if available

Some controllers have a controller-side memory buffer available for use
for submissions, completions, lists, or data.

If a CMB is available, the entire CMB will be ioremapped and it will
attempt to map the IO SQes onto the CMB. The queues will be shrunk as
needed. The CMB will not be used if the queue depth is shrunk below some
threshold where it may have reduced performance over a larger queue
in system memory.

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 8ffaadf7429270914b8f146ec13cf305e01df20d)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe: Unify SQ entry writing and doorbell ringing
Jon Derrick [Mon, 20 Jul 2015 16:14:08 +0000 (10:14 -0600)]
NVMe: Unify SQ entry writing and doorbell ringing

This patch changes sq_cmd writers to instead create their command on
the stack. __nvme_submit_cmd copies the sq entry to the queue and writes
the doorbell.

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 498c43949c7b8f57e0afb8195019cf5a7ba72de0)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe: Reread partitions on metadata formats
Keith Busch [Tue, 14 Jul 2015 17:57:48 +0000 (11:57 -0600)]
NVMe: Reread partitions on metadata formats

This patch has the driver automatically reread partitions if a namespace
has a separate metadata format. Previously revalidating a disk was
sufficient to get the correct capacity set on such formatted drives,
but partitions that may exist would not have been surfaced.

Reported-by: Paul Grabinar <paul.grabinar@ranbarg.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Cc: Matthew Wilcox <willy@linux.intel.com>
Tested-by: Paul Grabinar <paul.grabinar@ranbarg.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 7bee607472aa2e5a36dfe143e5a625be06125f53)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe: Fix irq freeing when queue_request_irq fails
Jon Derrick [Tue, 30 Jun 2015 17:22:52 +0000 (11:22 -0600)]
NVMe: Fix irq freeing when queue_request_irq fails

Fixes an issue when queue_reuest_irq fails in nvme_setup_io_queues. This
patch initializes all vectors to -1 and resets the vector to -1 in the
case of a failure in queue_request_irq. This avoids the free_irq in
nvme_suspend_queue if the queue did not get an irq.

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 758dd7fdffd60507624edce34fff122a63163b3f)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoNVMe: Memory barrier before queue_count is incremented
Jon Derrick [Wed, 27 May 2015 18:26:23 +0000 (12:26 -0600)]
NVMe: Memory barrier before queue_count is incremented

Protects against reordering and/or preempting which would allow the
kthread to access the queue descriptor before it is set up

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 36a7e993eedb2c3f11de3b686b351f75e1edbbb5)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agodrivers/block/nvme-core.c: fix build with gcc-4.4.4
Andrew Morton [Sat, 27 Jun 2015 18:20:34 +0000 (12:20 -0600)]
drivers/block/nvme-core.c: fix build with gcc-4.4.4

gcc-4.4.4 (and possibly other versions) fail the compile when initializers
are used with anonymous unions.  Work around this.

drivers/block/nvme-core.c: In function 'nvme_identify_ctrl':
drivers/block/nvme-core.c:1163: error: unknown field 'identify' specified in initializer
drivers/block/nvme-core.c:1163: warning: missing braces around initializer
drivers/block/nvme-core.c:1163: warning: (near initialization for 'c.<anonymous>')
drivers/block/nvme-core.c:1164: error: unknown field 'identify' specified in initializer
drivers/block/nvme-core.c:1164: warning: excess elements in struct initializer
drivers/block/nvme-core.c:1164: warning: (near initialization for 'c')
...

This patch has no effect on text size with gcc-4.8.2.

Fixes: d29ec8241c10eac ("nvme: submit internal commands through the block layer")
Cc: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@fb.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit e44ac588cd61c960226d61c379e2873a95544a51)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agoblock: nvme-scsi: Catch kcalloc failure
Axel Lin [Sat, 20 Jun 2015 08:29:14 +0000 (16:29 +0800)]
block: nvme-scsi: Catch kcalloc failure

res variable was initialized to -ENOMEM, but it's override by
nvme_trans_copy_from_user(). So current code returns 0 if kcalloc fails.
Fix it to return proper error code.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 51ef72bda70841fddd595142ed0e7e0fc571c500)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agonvme: submit internal commands through the block layer
Christoph Hellwig [Fri, 22 May 2015 09:12:46 +0000 (11:12 +0200)]
nvme: submit internal commands through the block layer

Use block layer queues with an internal cmd_type to submit internally
generated NVMe commands.  This both simplifies the code a lot and allow
for a better structure.  For example now the LighNVM code can construct
commands without knowing the details of the underlying I/O descriptors.
Or a future NVMe over network target could inject commands, as well as
could the SCSI translation and ioctl code be reused for such a beast.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit d29ec8241c10eacf59c23b3828a88dbae06e7e3f)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
Conflicts:
drivers/block/nvme-core.c

9 years agonvme: fail SCSI read/write command with unsupported protection bit
Christoph Hellwig [Fri, 22 May 2015 09:12:45 +0000 (11:12 +0200)]
nvme: fail SCSI read/write command with unsupported protection bit

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 772ce43559e076730ddff5907fabcb3485545e38)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agonvme: report the DPOFUA in MODE_SENSE
Christoph Hellwig [Fri, 22 May 2015 09:12:44 +0000 (11:12 +0200)]
nvme: report the DPOFUA in MODE_SENSE

NVMe device always support the FUA bit, and the SCSI translations
accepts the DPO bit, which doesn't have much of a meaning for us.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 908517684807f3b3d93893da78c7906f5ff2c49b)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agonvme: simplify and cleanup the READ/WRITE SCSI CDB parsing code
Christoph Hellwig [Fri, 22 May 2015 09:12:43 +0000 (11:12 +0200)]
nvme: simplify and cleanup the READ/WRITE SCSI CDB parsing code

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit cbbb7a2ec6001a0c15297c85184c9cc7fae5f11e)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agonvme: first round at deobsfucating the SCSI translation code
Christoph Hellwig [Fri, 22 May 2015 09:12:42 +0000 (11:12 +0200)]
nvme: first round at deobsfucating the SCSI translation code

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 3726897efde1d7a43b6f966ab81b0c143a176556)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agonvme: fix scsi translation error handling
Christoph Hellwig [Fri, 22 May 2015 09:12:41 +0000 (11:12 +0200)]
nvme: fix scsi translation error handling

Erorr handling for the scsi translation was completely broken, as there
were two different positive error number spaces overlapping.  Fix this
up by removing one of them, and centralizing the generation of the other
positive values in a single place.  Also fix up a few places that didn't
handle the NVMe error codes properly.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit e61b0a86cac83c3bf501705c8d52a0a29cecf091)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agonvme: split nvme_trans_send_fw_cmd
Christoph Hellwig [Fri, 22 May 2015 09:12:40 +0000 (11:12 +0200)]
nvme: split nvme_trans_send_fw_cmd

This function handles two totally different opcodes, so split it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit b90c48d0c11efe373a42a60e66e2ac2a503c287b)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
9 years agonvme: store a struct device pointer in struct nvme_dev
Christoph Hellwig [Fri, 22 May 2015 09:12:39 +0000 (11:12 +0200)]
nvme: store a struct device pointer in struct nvme_dev

Most users want the generic device, so store that in struct nvme_dev
instead of the pci_dev.  This also happens to be a nice step towards
making some code reusable for non-PCI transports.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit e75ec752d725b7b612c0b2db1bca50a9e53c0879)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
Conflicts:
drivers/block/nvme-core.c

9 years agonvme: consolidate synchronous command submission helpers
Christoph Hellwig [Fri, 22 May 2015 09:12:38 +0000 (11:12 +0200)]
nvme: consolidate synchronous command submission helpers

Note that we keep the unused timeout argument, but allow callers to
pass 0 instead of a timeout if they want the default.  This will allow
adding a timeout to the pass through path later on.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit f705f837c58ebe1ea69dfffff4dcc234e2fbc8dd)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
Conflicts:
drivers/block/nvme-core.c

9 years agohpsa: correct check for disk and zbc devices
Petros Koutoupis [Fri, 6 May 2016 19:18:37 +0000 (12:18 -0700)]
hpsa: correct check for disk and zbc devices

The check added always skips over every device and the
ioaccel parameters are never set.

Reviewed-by: Justin Lindley <Justin.Lindley@microsemi.com>
Acked-by: Don Brace <don.brace@microsemi.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: update driver version
Don Brace [Fri, 6 May 2016 19:18:17 +0000 (12:18 -0700)]
hpsa: update driver version

Reviewed-by: Gerry Morong <gerry.morong@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: correct handling of HBA device removal
Don Brace [Fri, 6 May 2016 19:17:57 +0000 (12:17 -0700)]
hpsa: correct handling of HBA device removal

Need to report HBA device removal faster than the
event handler polling interval.

Stop I/O to the removed disk and wait for all
I/O operations to flush before removing the device.

Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: correct ioaccel2 error procecssing.
Don Brace [Fri, 6 May 2016 19:17:36 +0000 (12:17 -0700)]
hpsa: correct ioaccel2 error procecssing.

set offload_to_be_enabled to 0 when an ioaccel2 error is processed.

Before, an ioaccel completion error would turn of ioaccel but a rescan
would turn it back on again.

Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: correct ioaccel state change operation
Don Brace [Fri, 6 May 2016 19:17:16 +0000 (12:17 -0700)]
hpsa: correct ioaccel state change operation

offload_to_be_enabled also needs to be set to 0 during a state
change.

Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: add timeouts for driver initiated commands
Don Brace [Fri, 6 May 2016 19:16:56 +0000 (12:16 -0700)]
hpsa: add timeouts for driver initiated commands

faulty drives can cause the driver to hang during a
scan operation.

Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: add sas_address to sysfs device attibute
Joseph T Handzik [Fri, 6 May 2016 19:16:35 +0000 (12:16 -0700)]
hpsa: add sas_address to sysfs device attibute

There have been companies requesting a sysfs entry
to obtain the sas address of device.

Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: correct initialization order issue
Don Brace [Fri, 6 May 2016 19:16:15 +0000 (12:16 -0700)]
hpsa: correct initialization order issue

The driver was calling scsi_scan_host before enabling interrupts.

This has gone unnoticed except for customers running in intx mode.
Calling scsi_scan_host before interrupts are enabled causes
"irq XX: nobody cared" messages and the driver to hang.

This patch enables interrupts before the call to scsi_scan_host.

Reported-by: Piotr Karbowski <piotr.karbowski@gmail.com>
Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: update copyright information
Don Brace [Fri, 6 May 2016 19:15:55 +0000 (12:15 -0700)]
hpsa: update copyright information

Reviewed-by: Justin Lindley <justin.lindley@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: add support for tagged queuing
Don Brace [Thu, 12 May 2016 18:13:07 +0000 (14:13 -0400)]
hpsa: add support for tagged queuing

Signed-off-by: Don Brace <don.brace@pmcs.com>
Orabug: 23064595
Signed-off-by: Manjunath <manjunath.govindashetty@oracle.com>
9 years agohpsa: check for a null phys_disk pointer in ioaccel2
Don Brace [Fri, 6 May 2016 19:15:14 +0000 (12:15 -0700)]
hpsa: check for a null phys_disk pointer in ioaccel2

 path

An oops can occur when submitting ioaccel2 commands when the phys_disk
pointer is NULL in hpsa_scsi_ioaccel_raid_map.  Happens when there are
configuration changes during I/O operations.

If the phys_disk pointer is NULL, send the command down the RAID path.

Reviewed-by: Mahesh Rajashekhara <mahesh.rajashekhara@microsemi.com>
Reviewed-by: Justin Lindley <justin.lindley@microsemi.com>
Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: correct abort tmf for hba devices
Don Brace [Fri, 6 May 2016 19:14:54 +0000 (12:14 -0700)]
hpsa: correct abort tmf for hba devices

Aborts were not being sent down to HBA devices

Reviewed-by: Mahesh Rajashekhara <mahesh.rajashekhara@microsemi.com>
Reviewed-by: Justin Lindley <justin.lindley@microsemi.com>
Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: correct lun data caching bitmap definition
Don Brace [Fri, 6 May 2016 19:14:34 +0000 (12:14 -0700)]
hpsa: correct lun data caching bitmap definition

The bitmap was changed after this definition was added to the
driver. Correcting the bitmap definition.

Reviewed-by: Mahesh Rajashekhara <mahesh.rajashekhara@microsemi.com>
Reviewed-by: Justin Lindley <justin.lindley@microsemi.com>
Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: add SMR drive support
Don Brace [Fri, 6 May 2016 19:14:14 +0000 (12:14 -0700)]
hpsa: add SMR drive support

Reviewed-by: Mahesh Rajashekhara <mahesh.rajashekhara@microsemi.com>
Reviewed-by: Justin Lindley <justin.lindley@microsemi.com>
Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: do not get enclosure info for external devices
Don Brace [Fri, 6 May 2016 19:13:53 +0000 (12:13 -0700)]
hpsa: do not get enclosure info for external devices

Stop annoying "Error, could not get enclosure information"
messages.

Reviewed-by: Mahesh Rajashekhara <mahesh.rajashekhara@microsemi.com>
Reviewed-by: Justin Lindley <justin.lindley@microsemi.com>
Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: Add box and bay information for enclosure
Don Brace [Fri, 6 May 2016 19:13:33 +0000 (12:13 -0700)]
hpsa: Add box and bay information for enclosure

 devices

Adding a new method to display enclosure device information.

Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: Change SAS transport devices to bus 0.
Don Brace [Fri, 6 May 2016 19:13:13 +0000 (12:13 -0700)]
hpsa: Change SAS transport devices to bus 0.

SAS transport places devices on bus 0 but driver was setting the bus to
3.

Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: fix path_info_show
Don Brace [Fri, 6 May 2016 19:12:53 +0000 (12:12 -0700)]
hpsa: fix path_info_show

Left off some changes from Rasmus Villemoes where he changed snprintf to
scnprintf.

Suggested-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: logical vs bitwise AND typo
Dan Carpenter [Fri, 6 May 2016 19:12:32 +0000 (12:12 -0700)]
hpsa: logical vs bitwise AND typo

HPSA_DIAG_OPTS_DISABLE_RLD_CACHING is a mask and bitwise AND was
intended here instead of logical &&.  This bug is essentially harmless,
it means that sometimes we don't print a warning message which we wanted
to print.

Fixes: c2adae44e916 ('hpsa: disable report lun data caching')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Acked-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agoscsi: use host wide tags by default
Christoph Hellwig [Fri, 6 May 2016 19:12:12 +0000 (12:12 -0700)]
scsi: use host wide tags by default

This patch changes the !blk-mq path to the same defaults as the blk-mq
I/O path by always enabling block tagging, and always using host wide
tags.  We've had blk-mq available for a few releases so bugs with
this mode should have been ironed out, and this ensures we get better
coverage of over tagging setup over different configs.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Jens Axboe <axboe@kernel.dk>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: James Bottomley <JBottomley@Odin.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: bump the driver version
Don Brace [Fri, 6 May 2016 19:11:52 +0000 (12:11 -0700)]
hpsa: bump the driver version

Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Gerry Morong <gerry.morong.pmcs.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: add in sas transport class
Kevin Barnett [Fri, 6 May 2016 19:11:32 +0000 (12:11 -0700)]
hpsa: add in sas transport class

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: fix multiple issues in path_info_show
Rasmus Villemoes [Fri, 6 May 2016 19:11:09 +0000 (12:11 -0700)]
hpsa: fix multiple issues in path_info_show

path_info_show() seems to be broken in multiple ways.

First, there's

  817 return snprintf(buf, output_len+1, "%s%s%s%s%s%s%s%s",
  818       path[0], path[1], path[2], path[3],
  819       path[4], path[5], path[6], path[7]);

so hopefully output_len contains the combined length of the eight
strings. Otherwise, snprintf will stop copying to the output
buffer, but still end up reporting that combined length - which
in turn would result in user-space getting a bunch of useless nul
bytes (thankfully the upper sysfs layer seems to clear the output
buffer before passing it to the various ->show routines). But we have

  767      output_len = snprintf(path[i],
  768                       PATH_STRING_LEN, "[%d:%d:%d:%d] %20.20s ",
  769                       h->scsi_host->host_no,
  770                       hdev->bus, hdev->target, hdev->lun,
  771                       scsi_device_type(hdev->devtype));

so output_len at best contains the length of the last string printed.

Inside the loop, we then otherwise add to output_len. By magic,
we still have PATH_STRING_LEN available every time... This
wouldn't really be a problem if the bean-counting has been done
properly and each line actually does fit in 50 bytes, and maybe
it does, but I don't immediately see why. Suppose we end up
taking this branch:

  802                  output_len += snprintf(path[i] + output_len,
  803                          PATH_STRING_LEN,
  804                          "BOX: %hhu BAY: %hhu %s\n",
  805                          box, bay, active);

An optimistic estimate says this uses strlen("BOX: 1 BAY: 2
Active\n") which is 21. Now add the 20 bytes guaranteed by the
%20.20s and then some for the rest of that format string, and
we're easily over 50 bytes. I don't think we can get over 100
bytes even being pessimistic, so this just means we'll scribble
into the next path[i+1] and maybe get that overwritten later,
leading to some garbled output (in fact, since we'd overwrite the
previous string's 0-terminator, we could end up with one very
long string and then print various suffixes of that, leading to
much more than 400 bytes of output). Except of course when we're
filling path[7], where overrunning it means writing random stuff
to the kernel stack, which is usually a lot of fun.

We can fix all of that and get rid of the 400 byte stack buffer by
simply writing directly to the given output buffer, which the upper
layer guarantees is at least PAGE_SIZE. s[c]nprintf doesn't care where
it is writing to, so this doesn't make the spin lock hold time any
longer. Using scnprintf ensures that output_len always represents the
number of bytes actually written to the buffer, so we'll report the
proper amount to the upper layer.

Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: enhance device messages
Don Brace [Fri, 6 May 2016 19:10:47 +0000 (12:10 -0700)]
hpsa: enhance device messages

Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: disable report lun data caching
Scott Teel [Fri, 6 May 2016 19:10:20 +0000 (12:10 -0700)]
hpsa: disable report lun data caching

When external target arrays are present, disable the firmware's
normal behavior of returning a cached copy of the report lun data,
and force it to collect new data each time we request a report luns.

This is necessary for external arrays, since there may be no
reliable signal from the external array to the smart array when
lun configuration changes, and thus when driver requests
report luns, it may be stale data.

Use diag options to turn off RPL data caching.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: add discovery polling for PT RAID devices.
Scott Teel [Fri, 6 May 2016 19:09:59 +0000 (12:09 -0700)]
hpsa: add discovery polling for PT RAID devices.

There are problems with getting configuration change notification
in pass-through RAID environments.  So, activate flag
h->discovery_polling when one of these devices is detected in
update_scsi_devices.

After discovery_polling is set, execute a report luns from
rescan_controller_worker (every 30 seconds).

If the data from report_luns is different than last
time (binary compare), execute a full rescan via update_scsi_devices.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: eliminate fake lun0 enclosures
Scott Teel [Fri, 6 May 2016 19:09:39 +0000 (12:09 -0700)]
hpsa: eliminate fake lun0 enclosures

We don't need to create fake enclosure devices at Lun0
in external target array configurations anymore.
This was done to support Pre-SCSI rev 5 controllers
that didn't suppoprt report luns commands, so the
SCSI layer had to scan targets. If there was no
LUN at LUN 0, then the target scan would stop, and
move to the next target.  Lun0 enclosure device
was added to prevent sparsely-numbered LUNs from
being missed.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: generalize external arrays
Scott Teel [Fri, 6 May 2016 19:09:19 +0000 (12:09 -0700)]
hpsa: generalize external arrays

External array LUNs must use target and lun numbers assigned by the
external array. So the driver must treat these differently from
local LUNs when assigning lun/target.

LUN's 'model' field has been used to detect Lun types that need
special treatment, but the desire is to eliminate the need to reference
specific array models, and support any external array.

Pass-through RAID (PTRAID) luns are not luns of the local controller,
so they are not reported in LUN count of command 'ID controller'.
However, they ARE reported in "Report logical Luns" command.
Local luns are listed first, then PTRAID LUNs.

The number of luns from "Report LUNs" in excess of those reported by
'ID controller' are therefore the PTRAID LUNS.

We can now remove function is_ext_target, and the 'white list'
array of supported model names.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: move scsi_add_device and scsi_remove_device
Kevin Barnett [Fri, 6 May 2016 19:08:59 +0000 (12:08 -0700)]
hpsa: move scsi_add_device and scsi_remove_device

 calls to new function

preparation for adding the sas transport class

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: refactor hpsa_figure_bus_target_lun
Kevin Barnett [Fri, 6 May 2016 19:08:38 +0000 (12:08 -0700)]
hpsa: refactor hpsa_figure_bus_target_lun

setup for sas transport. Need to set the
bus and target accordingly.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: enhance hpsa_get_device_id
Don Brace [Fri, 6 May 2016 19:08:18 +0000 (12:08 -0700)]
hpsa: enhance hpsa_get_device_id

use an index into vpd data for SAS/SATA drives

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: add function is_logical_device
Kevin Barnett [Fri, 6 May 2016 19:07:58 +0000 (12:07 -0700)]
hpsa: add function is_logical_device

simplify checking for logical/physical devices

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: simplify update scsi devices
Kevin Barnett [Fri, 6 May 2016 19:07:38 +0000 (12:07 -0700)]
hpsa: simplify update scsi devices

remove repeated calculation that checks for physical
or logical devices.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: simplify check for device exposure
Kevin Barnett [Fri, 6 May 2016 19:07:17 +0000 (12:07 -0700)]
hpsa: simplify check for device exposure

remove macros and cleanup device exposure checking

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>
9 years agohpsa: correct ioaccel2 sg chain len
Don Brace [Fri, 6 May 2016 19:06:57 +0000 (12:06 -0700)]
hpsa: correct ioaccel2 sg chain len

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Reviewed-by: Kevin Barnett <kevin.barnett@pmcs.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 23064595
Signed-off-by: Manjunath Govindashetty <manjunath.govindashetty@oracle.com>