firefly-linux-kernel-4.4.55.git
9 years agohpsa: add in P840ar controller model name
Don Brace [Fri, 23 Jan 2015 22:45:12 +0000 (16:45 -0600)]
hpsa: add in P840ar controller model name

Add in P840ar model name for gen9

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: add in gen9 controller model names
Don Brace [Fri, 23 Jan 2015 22:45:07 +0000 (16:45 -0600)]
hpsa: add in gen9 controller model names

Add in gen9 controller model names

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: detect and report failures changing controller transport modes
Robert Elliott [Fri, 23 Jan 2015 22:45:01 +0000 (16:45 -0600)]
hpsa: detect and report failures changing controller transport modes

Detect failues when attempting to change controller to use simple
or performant transport modes (mode change ack) rather than just
proceeding ahead after timeouts.

Return values are added to:
hpsa_put_ctlr_into_performant_mode
hpsa_wait_for_mode_change_ack
and all their callers check/propagate the result.

More consistency in printing errors and whether
dev_err is used.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: shorten the wait for the CISS doorbell mode change ack
Robert Elliott [Fri, 23 Jan 2015 22:44:56 +0000 (16:44 -0600)]
hpsa: shorten the wait for the CISS doorbell mode change ack

Shorten the wait for the CISS configuration table doorbell mode
change acknowledgment from 300-600 s to 20 s, which is the value
specified in the CISS specification that should be honored by
all controllers.

Wait using interruptible msleep() rather than uninterruptible
usleep_range(), which triggers rt_sched timeout errors if the
wait is long.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: refactor duplicated scan completion code into a new routine
Webb Scales [Fri, 23 Jan 2015 22:44:50 +0000 (16:44 -0600)]
hpsa: refactor duplicated scan completion code into a new routine

Hoist the conditional out of do_not_scan_if_controller_locked_up() and
place it in the caller (this improves the code structure, making it
more consistent with other uses and enabling tail-call optimization);
rename the function to hpsa_scan_complete(), and use it at the end of
hpsa_scan_start() as well.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Webb Scales <webbnh@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: move SG descriptor set-up out of hpsa_scatter_gather()
Webb Scales [Fri, 23 Jan 2015 22:44:45 +0000 (16:44 -0600)]
hpsa: move SG descriptor set-up out of hpsa_scatter_gather()

Move the code which sets up the SG descriptor out of hpsa_scatter_gather()
and into a subroutine where it can be reused (in the next patch).  The Ext
field is now assigned unconditionally: this makes the refactor much simpler,
but more importantly it removes a conditional operation from inside the
loop.  The case for which the conditional formerly tested is now executed
(unconditionally) after the loop is exited.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Webb Scales <webbnh@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: do not use function pointers in fast path command submission
Stephen Cameron [Fri, 23 Jan 2015 22:44:40 +0000 (16:44 -0600)]
hpsa: do not use function pointers in fast path command submission

Performance tweak, avoid unnecessary function calls.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: print CDBs instead of kernel virtual addresses for uncommon errors
Stephen Cameron [Fri, 23 Jan 2015 22:44:35 +0000 (16:44 -0600)]
hpsa: print CDBs instead of kernel virtual addresses for uncommon errors

Printing the address of the command pointer is of little value, change
to print the CDB.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: do not use a void pointer for scsi_cmd field of struct CommandList
Stephen Cameron [Fri, 23 Jan 2015 22:44:30 +0000 (16:44 -0600)]
hpsa: do not use a void pointer for scsi_cmd field of struct CommandList

There's no reason for it to be a void *, it should be a struct scsi_cmnd *

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: return failed from device reset/abort handlers
Don Brace [Fri, 23 Jan 2015 22:44:24 +0000 (16:44 -0600)]
hpsa: return failed from device reset/abort handlers

Returning failed from the device reset handler will get the device
kicked offline, which is fine if the controller is locked up anyhow.

Cannot abort a command from a failed controller.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Justin Lindley <justin.lindley@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: check for ctlr lockup after command allocation in main io path
Stephen Cameron [Fri, 23 Jan 2015 22:44:19 +0000 (16:44 -0600)]
hpsa: check for ctlr lockup after command allocation in main io path

Command allocation is the thing that takes the longest in the main i/o
path, so check for controller lockup immediately after this to prevent
submitting commands to locked up controller as much as possible.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: guard against overflowing raid map array
Stephen Cameron [Fri, 23 Jan 2015 22:44:14 +0000 (16:44 -0600)]
hpsa: guard against overflowing raid map array

In the code that translates logical drive LBAs to physical
drive LBAs if we overflow the raid map disk data array we
will get the wrong answers.  We do not expect that to happen,
but best to be on the safe side and guard against it anyway.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: do not ack controller events on controllers that do not support it
Stephen Cameron [Fri, 23 Jan 2015 22:44:07 +0000 (16:44 -0600)]
hpsa: do not ack controller events on controllers that do not support it

Acking controller events on controllers that do not support
it can cause such controllers to lock up.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Joe Handzik <joseph.t.handzik@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: remove incorrect BUG_ONs checking for raid offload enable
Stephen Cameron [Fri, 23 Jan 2015 22:44:01 +0000 (16:44 -0600)]
hpsa: remove incorrect BUG_ONs checking for raid offload enable

In set_encrypt_ioaccel2() and in hpsa_scsi_ioaccel_raid_map
there were BUG_ONs that looked like this:

BUG_ON(!(dev->offload_config && dev->offload_enabled));

But, In hpsa_ack_ctlr_events() we have this,

/* Stop sending new RAID offload reqs via the IO accelerator */
scsi_block_requests(h->scsi_host);
for (i = 0; i < h->ndevices; i++)
h->dev[i]->offload_enabled = 0;
hpsa_drain_accel_commands(h);

So, we set offload_enabled = 0 for all drives, then do this
drain_accel_commands, so that means accel commands could still
be in flight, ie. perhaps having just been submitted into
hpsa_scsi_ioaccel_raid_map concurrent with ->offload_enabled
having just been set to zero.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: do not check for msi(x) in interrupt_pending
Stephen Cameron [Fri, 23 Jan 2015 22:43:56 +0000 (16:43 -0600)]
hpsa: do not check for msi(x) in interrupt_pending

No need to check whether interrupt pending for MSI(X) and
conversely, no need to check whether MSI(X) interrupts are
being used when checking if interrupts are pending.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: slightly optimize SA5_performant_completed
Don Brace [Fri, 23 Jan 2015 22:43:51 +0000 (16:43 -0600)]
hpsa: slightly optimize SA5_performant_completed

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: count passthru cmds with atomics, not a spin locked int
Don Brace [Fri, 23 Jan 2015 22:43:46 +0000 (16:43 -0600)]
hpsa: count passthru cmds with atomics, not a spin locked int

Performance enhancement. Remove spin_locks from the driver.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: optimize cmd_alloc function by remembering last allocation
Robert Elliott [Fri, 23 Jan 2015 22:43:41 +0000 (16:43 -0600)]
hpsa: optimize cmd_alloc function by remembering last allocation

Empirically, this improves performance slightly (~2% max IOPS) by
allowing cmd_alloc to remember where it left off searching for
free commands between calls instead of always starting its search
at command 0.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: fix race between abort handler and main i/o path
Webb Scales [Fri, 23 Jan 2015 22:43:35 +0000 (16:43 -0600)]
hpsa: fix race between abort handler and main i/o path

This means changing the allocator to reference count commands.
The reference count is now the authoritative indicator of whether a
command is allocated or not.  The h->cmd_pool_bits bitmap is now
only a heuristic hint to speed up the allocation process, it is no
longer the authoritative record of allocated commands.

Since we changed the command allocator to use reference counting
as the authoritative indicator of whether a command is allocated,
fail_all_outstanding_cmds needs to use the reference count not
h->cmd_pool_bits for this purpose.

Fix hpsa_drain_accel_commands to use the reference count as the
authoritative indicator of whether a command is allocated instead of
the h->cmd_pool_bits bitmap.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: honor queue depth of physical devices
Don Brace [Fri, 23 Jan 2015 22:43:30 +0000 (16:43 -0600)]
hpsa: honor queue depth of physical devices

When using the ioaccel submission methods, requests destined for RAID volumes
are sometimes diverted to physical devices.  The OS has no or limited
knowledge of these physical devices, so it is up to the driver to avoid
pushing the device too hard.  It is better to honor the physical device queue
limit rather than making the device spew zillions of TASK SET FULL responses.

This is so that hpsa based devices support /sys/block/sdNN/device/queue_type
of simple, which lets the SCSI midlayer automatically adjust the queue_depth
based on TASK SET FULL and GOOD status.

Adjust the queue depth for a new device after it is created based on the
maximum queue depths of the physical devices that constitute the
device. This drops the maximum queue depth from .can_queue of 1024 to
something like 174 for single-drive RAID-0, 348 for two-drive RAID-1, etc.
It also adjusts for the ratio of data to parity drives.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Webb Scales <webbnh@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: use workqueue to resubmit failed ioaccel commands
Don Brace [Fri, 23 Jan 2015 22:43:25 +0000 (16:43 -0600)]
hpsa: use workqueue to resubmit failed ioaccel commands

Instead of kicking the commands all the way back to the mid
layer, use a work queue.  This enables having a mechanism for
the driver to be able to resubmit the commands down the "normal"
raid path without turning off the ioaccel feature entirely
whenever an error is encountered on the ioaccel path, and
prevent excessive rescanning of devices.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: factor out hpsa_ciss_submit function
Stephen Cameron [Fri, 23 Jan 2015 22:43:20 +0000 (16:43 -0600)]
hpsa: factor out hpsa_ciss_submit function

Factor out the bottom part of the queuecommand function
which is the part that builds commands for submitting down
the "normal' RAID stack path of a Smart Array.

Need to factor this out to improve how commands that
were initially sent down one of the "ioaccellerated"
paths but which have some sort of error condition are
retried down the "normal" path.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: do not request device rescan on every ioaccel path error
Stephen Cameron [Fri, 23 Jan 2015 22:43:14 +0000 (16:43 -0600)]
hpsa: do not request device rescan on every ioaccel path error

The original reasoning behind doing this was faulty.  An error
of some sort would be encountered, accelerated i/o would be
disabled for that logical drive, the command would be kicked
back out to the SCSI midlayer for a retry, and since i/o accelerator
mode was disabled, it would get retried down the RAID path.
However, something needs to turn ioaccellerator mode back on,
and this rescan request was what did that.  However, it was racy,
and extremely bad for performance to rescan all devices, so,
don't do that.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: do not queue commands internally in driver
Don Brace [Fri, 23 Jan 2015 22:43:09 +0000 (16:43 -0600)]
hpsa: do not queue commands internally in driver

By not doing maintaining a list of queued commands, we can eliminate some spin
locking in the main i/o path and gain significant improvement in IOPS.  Remove
the queuing code and the code that calls it; remove now-unused interrupt code;
remove DIRECT_LOOKUP_BIT.

Now that the passthru commands share the same command pool as
the main i/o path, and the total size of the pool is less than
or equal to the number of commands that will fit in the hardware
fifo, there is no need to check to see if we are exceeding the
hardware fifo's depth.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: get rid of cmd_special_alloc and cmd_special_free
Stephen Cameron [Fri, 23 Jan 2015 22:43:04 +0000 (16:43 -0600)]
hpsa: get rid of cmd_special_alloc and cmd_special_free

We have commands reserved for internal use.

This is laying the groundwork for removing the internal
queue of commands from the driver so that the locks that
protect that queue may be removed.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: reserve some commands for use by driver
Stephen Cameron [Fri, 23 Jan 2015 22:42:59 +0000 (16:42 -0600)]
hpsa: reserve some commands for use by driver

We need to reserve some commands for device rescans,
aborts, and the pass through ioctls, etc. so we cannot
give them all to the scsi mid layer.

This is in preparation for removing cmd_special_alloc and
cmd_special_free so that we can stop queuing commands internally
in the driver so that we can remove the locks thta protect the
queue that we will no longer have.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: avoid unneccesary calls to resource freeing functions
Robert Elliott [Fri, 23 Jan 2015 22:42:54 +0000 (16:42 -0600)]
hpsa: avoid unneccesary calls to resource freeing functions

If hpsa_allocate_cmd_pool failed, we were calling two functions unnecessarily:

  hpsa_free_sg_chain_blocks(h);
  hpsa_free_cmd_pool(h);

This didn't cause any problem, as those functions can tolerate being called
when what they free hasn't been allocated (relevant pointers would be NULL)
but it is potentially confusing.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: fix memory leak in hpsa_alloc_cmd_pool
Robert Elliott [Fri, 23 Jan 2015 22:42:48 +0000 (16:42 -0600)]
hpsa: fix memory leak in hpsa_alloc_cmd_pool

Partial allocation failure wasn't handled correctly

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: report allocation failures while allocating SG chain blocks
Robert Elliott [Fri, 23 Jan 2015 22:42:42 +0000 (16:42 -0600)]
hpsa: report allocation failures while allocating SG chain blocks

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: pass error from pci_set_consistent_dma_mask from hpsa_message
Robert Elliott [Fri, 23 Jan 2015 22:42:37 +0000 (16:42 -0600)]
hpsa: pass error from pci_set_consistent_dma_mask from hpsa_message

Return the actual error code instead of a generic error code.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: rename hpsa_request_irq to hpsa_request_irqs
Robert Elliott [Fri, 23 Jan 2015 22:42:32 +0000 (16:42 -0600)]
hpsa: rename hpsa_request_irq to hpsa_request_irqs

Make the function name more descriptive. We use more than
one interrupt.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: report failure to ioremap config table
Robert Elliott [Fri, 23 Jan 2015 22:42:27 +0000 (16:42 -0600)]
hpsa: report failure to ioremap config table

Enhance error reporting.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: trivial message and comment clean ups
Stephen Cameron [Fri, 23 Jan 2015 22:42:22 +0000 (16:42 -0600)]
hpsa: trivial message and comment clean ups

Cleanup comments to be more specific. Make messages more
informational.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: refactor hpsa_find_board_params() to encapsulate legacy test
Webb Scales [Fri, 23 Jan 2015 22:42:17 +0000 (16:42 -0600)]
hpsa: refactor hpsa_find_board_params() to encapsulate legacy test

Encapsulate the conditional predicate which tests for legacy controllers
in a separate function and rework the code comments.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Webb Scales <webbnh@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: downgrade the Waiting for no-op print to dev_info
Robert Elliott [Fri, 23 Jan 2015 22:42:11 +0000 (16:42 -0600)]
hpsa: downgrade the Waiting for no-op print to dev_info

There is nothing worrisome about the "Waiting for controller to
respond to no-op" print, so use dev_info rather than dev_warn.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: propagate return value from board ID lookup
Robert Elliott [Fri, 23 Jan 2015 22:42:06 +0000 (16:42 -0600)]
hpsa: propagate return value from board ID lookup

If the board ID lookup function fails, return the return
code rather than return -ENODEV.

The only board ID failure reason right now is -ENODEV,
so this just provides more informative prints in kdump
and adapts to future changes.

Tested with error injection while booting with
reset_devices
on the kernel command line:
[   62.804324]  injecting error in inj_hpsa_lookup_board_id: 1 11
[   62.804423] hpsa 0000:04:00.0: Board ID not found

(the pci probe layer does not print an additional
message if -ENODEV is the reason)

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: propagate hard_reset failures in reset_devices mode
Robert Elliott [Fri, 23 Jan 2015 22:42:01 +0000 (16:42 -0600)]
hpsa: propagate hard_reset failures in reset_devices mode

Return the real reason for kdump_hard_reset failure rather
than change them all to -ENODEV.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: remove 0x from queue depth print which is in decimal
Robert Elliott [Fri, 23 Jan 2015 22:41:56 +0000 (16:41 -0600)]
hpsa: remove 0x from queue depth print which is in decimal

The queue depth printed at startup is in decimal, so
shouldn't have a 0x prefix.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: notice all request_irq errors
Robert Elliott [Fri, 23 Jan 2015 22:41:51 +0000 (16:41 -0600)]
hpsa: notice all request_irq errors

In MSI and MSI-X mode, where hpsa asks for more than one interrupt,
hpsa_request_irqs forgets if the first request_irq call failed
if later ones succeed.

It needs to exit the loop on any failure rather than continue,
freeing all irqs that were requested until that point.

Also, it needs to clear out the q numbers up to MAX_REPLY_QUEUES.
The same is true for the general hpsa_free_irqs function.

Tested with error injection of -ENOSYS on the 4th call:
[    9.277691]  injecting error in inj_request_irq: 1 4
[    9.277780] hpsa 0000:02:00.0: failed to get irq 35 for hpsa1
[   10.711623] scsi host1: Error handler scsi_eh_1 exiting
[   10.739170] hpsa: probe of 0000:02:00.0 failed with error -38

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: Fix -Wunused-but-set-variable warning
Fabian Frederick [Fri, 23 Jan 2015 22:41:46 +0000 (16:41 -0600)]
hpsa: Fix -Wunused-but-set-variable warning

Remove unused variable in hpsa_free_cmd_pool.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Fabian Frederick <fabf@skynet.be>
Acked-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: rename free_irqs to hpsa_free_irqs
Robert Elliott [Fri, 23 Jan 2015 22:41:40 +0000 (16:41 -0600)]
hpsa: rename free_irqs to hpsa_free_irqs

Change the function names to have hpsa prefix.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: adjust RAID-1, RAID-1ADM, and RAID-6 names
Robert Elliott [Fri, 23 Jan 2015 22:41:35 +0000 (16:41 -0600)]
hpsa: adjust RAID-1, RAID-1ADM, and RAID-6 names

HP now uses RAID-6 rather than RAID-ADG (Advanced Data Guarding)
as the marketing name for our implementation of RAID-6.

The driver considers RAID-1 and RAID-1+0 to be the same level, and
considers RAID-1ADM and RAID-1+0ADM to be the same level.  Parenthesis
can be used to reflect the optional +0 portion of both those RAID levels.

Rename: RAID-ADG to RAID-6
RAID-1(1+0) to RAID-1(+0)
RAID-1(ADM) to RAID-1(+0)ADM

Also, add another const after the pointer type as suggested
by checkpatch.pl so the array is:
static const char * const raid_label[]

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: correct change_queue_depth
Don Brace [Fri, 23 Jan 2015 22:41:30 +0000 (16:41 -0600)]
hpsa: correct change_queue_depth

We change drive queue depths to match drive reported queue depths.
The name of the SML function was changed from scsi_adjust_queue_depth
changed to scsi_change_queue_depth.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: change how SA controllers are reset
Don Brace [Fri, 23 Jan 2015 22:41:25 +0000 (16:41 -0600)]
hpsa: change how SA controllers are reset

Change how SA controllers are reset by changing PCI power levels.
The hpsa driver was finding the PCI_PM_CTRL_STATE_MASK offset
then reading/writing a bitmask to change the power state. There
are kernel functions that do the same operations. Better to use
the kernel functions.

Signed-off-by: Don Brace <don.brace@pmcs.com>
Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Webb Scales <webbnh@hp.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: turn off interrupts when kdump starts
Tomas Henzl [Fri, 23 Jan 2015 22:41:20 +0000 (16:41 -0600)]
hpsa: turn off interrupts when kdump starts

Sometimes when the card is restarted it may cause -
"irq 16: nobody cared (try booting with the "irqpoll" option)"
that is likely caused so, that the card, after the hard reset
finishes, pulls on the irq. Disabling the ints before or after
the hpsa_kdump_hard_reset_controller fixes it.

At this point we can't know in which state the card is,
so using SA5_INTR_OFF + SA5_REPLY_INTR_MASK_OFFSET defines directly,
instead of the function the drivers provides, seems to be apropriate.

Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: fix memory leak in kdump hard reset
Tomas Henzl [Fri, 23 Jan 2015 22:41:14 +0000 (16:41 -0600)]
hpsa: fix memory leak in kdump hard reset

There is a potential memory leak in hpsa_kdump_hard_reset_controller.

Reviewed-by: Don Brace <don.brace@pmcs.com>
Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Don Brace <don.brace@pmcs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agohpsa: correct endian sparse warnings
Don Brace [Fri, 23 Jan 2015 22:41:09 +0000 (16:41 -0600)]
hpsa: correct endian sparse warnings

Correct endiness issues reported by sparse. SA controllers are
little endian. This patch ensures endiness correctness.

Signed-off-by: Don Brace <don.brace@pmcs.com>
Reviewed-by: Scott Teel <scott.teel@pmcs.com>
Reviewed-by: Webb Scales <webbnh@hp.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agoufs-qcom: add support for Qualcomm Technologies Inc platforms
Yaniv Gardi [Thu, 15 Jan 2015 14:32:37 +0000 (16:32 +0200)]
ufs-qcom: add support for Qualcomm Technologies Inc platforms

This change adds support for Qualcomm Technologies Inc platforms that
use UFS driver. for example, it adds :
- PM specific operations during hibern8, suspend, resume, clock setup
- qcom-ufs generic phy driver initialization, calibration,
  power-on/off sequence, etc.
- UFS Controller specific configuration
- Rate, Gear, Mode negotiation between device and controller

Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Reviewed-by: Dov Levenglick <dovl@codeaurora.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agophy: qcom-ufs: add support for 14nm phy
Yaniv Gardi [Thu, 15 Jan 2015 14:32:38 +0000 (16:32 +0200)]
phy: qcom-ufs: add support for 14nm phy

This change adds a support for a 14nm qcom-ufs phy that is
required in platforms that use ufs-qcom controller.

Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Reviewed-by: Dov Levenglick <dovl@codeaurora.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agophy: qcom-ufs: add support for 20nm phy
Yaniv Gardi [Thu, 15 Jan 2015 14:32:36 +0000 (16:32 +0200)]
phy: qcom-ufs: add support for 20nm phy

This change adds a support for a 20nm qcom-ufs phy that is required in
platforms that use ufs-qcom controller.

Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Reviewed-by: Dov Levenglick <dovl@codeaurora.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agophy: qcom-ufs: add support for QUALCOMM Technologies UFS PHY drivers
Yaniv Gardi [Thu, 15 Jan 2015 14:32:35 +0000 (16:32 +0200)]
phy: qcom-ufs: add support for QUALCOMM Technologies UFS PHY drivers

This change adds a generic and common API support for ufs phy QUALCOMM
Technologies. This support provides common code and also points
to specific phy callbacks to differentiate between different behaviors
of frequent use-cases (like power on, power off, phy calibration etc).

Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Reviewed-by: Dov Levenglick <dovl@codeaurora.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agosr: reduce debug noise in sr_do_ioctl
Christoph Hellwig [Sun, 18 Jan 2015 15:11:31 +0000 (16:11 +0100)]
sr: reduce debug noise in sr_do_ioctl

The midlayer scsi logging already logs the command and sense code
if the logging level is high enough, no need to duplicate that
in the sr driver.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: James Bottomley <JBottomley@Parallels.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
9 years agoch: remove debug noise in ch_do_scsi
Christoph Hellwig [Sun, 18 Jan 2015 15:11:30 +0000 (16:11 +0100)]
ch: remove debug noise in ch_do_scsi

The midlayer logging already prints the cdb details if the logging
level is high enough, no need to duplicate this in the ch driver.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: James Bottomley <JBottomley@Parallels.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
9 years agoscsi: always use format argumets for dev_printk
Christoph Hellwig [Sun, 18 Jan 2015 15:11:28 +0000 (16:11 +0100)]
scsi: always use format argumets for dev_printk

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: James Bottomley <JBottomley@Parallels.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
9 years agoscsi: annotate sdev_prefix_printk and scmd_printk as printf-like
Christoph Hellwig [Sun, 18 Jan 2015 15:11:29 +0000 (16:11 +0100)]
scsi: annotate sdev_prefix_printk and scmd_printk as printf-like

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: James Bottomley <JBottomley@Parallels.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
9 years agolibata: fixup oops in ata_eh_link_report()
Hannes Reinecke [Mon, 19 Jan 2015 15:55:38 +0000 (16:55 +0100)]
libata: fixup oops in ata_eh_link_report()

We should only try to evaluate the cdb if this is an ATAPI
device, for any other device the 'cdb' field and the cdb_len
has no meaning.

Fixes: cbba5b0ee4c6c2fc8b78a21d0900099d480cf2e9
Reported-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Tejun Heo <tj@kernel.org>
Tested-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agompt2sas: Bump driver version to 20.100.00.00
Sreekanth Reddy [Mon, 12 Jan 2015 06:09:04 +0000 (11:39 +0530)]
mpt2sas: Bump driver version to 20.100.00.00

Bump mpt2sas driver version to 20.100.00.00.

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agompt2sas, mpt3sas: set cpu affinity for each MSIX vectors
Sreekanth Reddy [Mon, 12 Jan 2015 06:09:03 +0000 (11:39 +0530)]
mpt2sas, mpt3sas: set cpu affinity for each MSIX vectors

Added a support to set cpu affinity mask for each MSIX vector enabled
by the HBA. So that, running the irqbalancer will balance interrupts among
the cpus.

Change_set:
1. Added affinity_hint varable of type cpumask_var_t in adapter_reply_queue
   structure. And allocated a memory for this varable by calling
   alloc_cpumask_var.
2. Call the API irq_set_affinity_hint for each MSIx vector to affiniate it
   with calculated cpus at driver inilization time.
3. While freeing the MSIX vector, call this same API to release the cpu
   affinity mask for each MSIx vector by providing the NULL value in
   cpumask argument.
4. then call the free_cpumask_var API to free the memory allocated in step 2.

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agompt2sas, mpt3sas: Update attribution language to Avago
Sreekanth Reddy [Mon, 12 Jan 2015 06:09:02 +0000 (11:39 +0530)]
mpt2sas, mpt3sas: Update attribution language to Avago

Copyright, Trademark & Confidentiality legal statements throughout the
source code changed from LSI to Avago.

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agompt2sas: map log_info value 0x0x32010081 to DID_RESET
Sreekanth Reddy [Mon, 12 Jan 2015 06:09:01 +0000 (11:39 +0530)]
mpt2sas: map log_info value 0x0x32010081 to DID_RESET

For any SCSI command, if the driver receives IOC status =
SCSI_IOC_TERMINATED and log info = 0x32010081 then that command will be
completed with DID_RESET host status.

The definition of this log info value is "Virtual IO has failed and has
to be retried".

Firmware will provide this log info value with IOC Status
"SCSI_IOC_TERMINATED", whenever a drive (with is a part of a volume)
is pulled and pushed back within some minimal delay.  With this log info
value, firmware informs the driver to retry the failed IO command
infinite times, so to provide some time for the firmware to discover
the reinserted drive successfully instated of just retrying failed
command for five times( doesn't giving enough time for firmware to
complete the drive discovery) and failing the IO permanently even
though drive came back successfully.

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agompt2sas, mpt3sas: fix upper bound for the module parameter max_sgl_entries
Sreekanth Reddy [Mon, 12 Jan 2015 06:09:00 +0000 (11:39 +0530)]
mpt2sas, mpt3sas: fix upper bound for the module parameter max_sgl_entries

Change Set:

1. Extended the upper boundary restriction for the module parameter
   max_sgl_entries. Earlier, the max_sgl_entries was capped at the
   SCSI_MAX_SG_SEGMENTS kernel definition. With this change, the user
   would be able to set the max_sgl_entries to any value which is
   greater than SCSI_MAX_SG_SEGMENTS and less than the minimum of
   SCSI_MAX_SG_CHAIN_SEGMENTS & hardware limit (Calculated using
   IOCFacts's MaxChainDepth).

2. Added a print for the message log whenever the user sets the
   max_sgl_entries to a value greater than SCSI_MAX_SG_SEGMENTS to
   warn about the kernel definition overriding.

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agompt2sas: MPI2 Rev BB (2.00.20) specification and 2.00.35 header files
Sreekanth Reddy [Mon, 12 Jan 2015 06:08:59 +0000 (11:38 +0530)]
mpt2sas: MPI2 Rev BB (2.00.20) specification and 2.00.35 header files

Change List in this MPI2 specification,

1. Added SSUTimeout field to MPI2_CONFIG_PAGE_BIOS_1,
   and more defines for the BiosOptions field.

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agompt2sas: Bump driver version to 19.100.00.00
Sreekanth Reddy [Mon, 12 Jan 2015 06:08:58 +0000 (11:38 +0530)]
mpt2sas: Bump driver version to 19.100.00.00

Bump driver version to 19.100.00.00.

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agompt2sas, mpt3sas: Fail the host reset initiated due to discovery related I/O timeouts...
Sreekanth Reddy [Mon, 12 Jan 2015 06:08:57 +0000 (11:38 +0530)]
mpt2sas, mpt3sas: Fail the host reset initiated due to discovery related I/O timeouts at driver load time

When a flaky disk is there in a topology then during driver load,
discovery related I/O times out; which results in SCSI error recovery
initiating host reset and then the controller won't see any disk.

In this patch, The driver would return FAILED status to the host reset
initiated due to discovery related I/O timeout if ioc->is_driver_loading
is set. This flag would be set until we exit out of scsih_scan_finished().
i.e.
During device discovery if one of the disk is flaky
(which responds to some discovery commands and doesn't respond to some)
the driver wouldn't perform host reset for discovery related I/O timeout.
Instead it would return Failure for the host reset resulting in the
flaky disk getting removed by the SCSI Mid layer,
so other disks would be added correctly.

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agompt2sas, mpt3sas: log exceeded temperature thresholds
Sreekanth Reddy [Mon, 12 Jan 2015 06:08:56 +0000 (11:38 +0530)]
mpt2sas, mpt3sas: log exceeded temperature thresholds

This patch will log a message when driver receives "Temperature Threshold
exceeded" event from any temperature sensor.

The message will look similar to like:
mpt3sas0: Temperature Threshold flags a b c d exceeded for Sensor: x !!!
mpt3sas0: Current Temp In Celsius: y

where a b c d are threshold flags 0 1 2 3

Change_set:
1. Get the number of sensor count of this IOC by reading IO Unit page 8 at
   driver initialization time.
2. Also unmask the Temperature Threshold Event at driver initialization
   time
3. Whenever a MPI2_EVENT_TEMP_THRESHOLD event is received from the
   firmware, then print the sensor number, the maximum threshold number it
   has exceed and the current temperature of this sensor.

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agompt2sas: MPI2 Rev AA (2.00.19) specifications
Sreekanth Reddy [Mon, 12 Jan 2015 06:08:55 +0000 (11:38 +0530)]
mpt2sas: MPI2 Rev AA (2.00.19) specifications

Below is the changeset from the MPI specification and 2.00.34 header
files:

1) Defined additional bits in the BiosOptions field of BIOS Page 1 to
   allow for finer control of X86 BIOS and UEFI BSD.
2) For the Clean Tool, reserved bit 26 of the Flags field for product
   specific use.

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agomegaraid_sas: driver version update
Sumit.Saxena@avagotech.com [Mon, 5 Jan 2015 14:36:28 +0000 (20:06 +0530)]
megaraid_sas: driver version update

Update megaraid_sas driver version.

Signed-off-by: Sumit Saxena <sumit.saxena@avagotech.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agomegaraid_sas: remove redundant memset call
Sumit.Saxena@avagotech.com [Mon, 5 Jan 2015 14:36:28 +0000 (20:06 +0530)]
megaraid_sas: remove redundant memset call

struct fusion_context *fusion is already memset to '0', so remove a
redundant call to memmset "fusion->load_balance_info" to '0'.

Signed-off-by: Chaitra Basappa <chaitra.basappa@avagotech.com>
Signed-off-by: Sumit Saxena <sumit.saxena@avagotech.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agomegaraid_sas: reserve commands for IOCTLs and internal DCMDs
Sumit.Saxena@avagotech.com [Mon, 5 Jan 2015 14:36:23 +0000 (20:06 +0530)]
megaraid_sas: reserve commands for IOCTLs and internal DCMDs

1) For fusion adapters, limit reserved frames for non SCSI commands to 8
   (3 for parallel IOCTLs + 5 for driver's internal DCMDs).
   Earlier reserved commands for non SCSI IO frames was set to 32, so with
   this implementation, increased per controller "can_queue".
   Behavior of MFI controllers will remain unchanged.

2) Optimize the code related to per controller's 'can_queue' setting.

Signed-off-by: Sumit Saxena <sumit.saxena@avagotech.com>
Signed-off-by: Chaitra Basappa <chaitra.basappa@avagotech.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agomegaraid_sas: complete outstanding IOCTLs before killing adapter
Sumit.Saxena@avagotech.com [Mon, 5 Jan 2015 14:36:18 +0000 (20:06 +0530)]
megaraid_sas: complete outstanding IOCTLs before killing adapter

Driver calls megasas_complete_cmd() to call wake_up() for each MFI frame
that was issued through the ioctl() interface prior to the kill adapter.
This ensures userspace ioctl() system calls issued just before a kill
adapter don't get stuck in wait state and IOCTLs are returned to
the application.

Cc: <stable@vger.kernel.org>
Signed-off-by: Sumit Saxena <sumit.saxena@avagotech.com>
Signed-off-by: Chaitra Basappa <chaitra.basappa@avagotech.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agomegaraid_sas: disable interrupt_mask before enabling hardware interrupts
Sumit.Saxena@avagotech.com [Mon, 5 Jan 2015 14:36:13 +0000 (20:06 +0530)]
megaraid_sas: disable interrupt_mask before enabling hardware interrupts

Update driver "mask_interrupts" before enable/disable hardware interrupt
in order to avoid missing interrupts because of "mask_interrupts" still
set to 1 and hardware interrupts are enabled.

Cc: <stable@vger.kernel.org>
Signed-off-by: Sumit Saxena <sumit.saxena@avagotech.com>
Signed-off-by: Chaitra Basappa <chaitra.basappa@avagotech.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agomegaraid_sas: fix the problem of non-existing VD exposed to host
Sumit.Saxena@avagotech.com [Mon, 5 Jan 2015 14:36:08 +0000 (20:06 +0530)]
megaraid_sas: fix the problem of non-existing VD exposed to host

This patch will address the issue of SCSI device created at OS level for
non existing VD. ldTgtIdtoLd[] array has size 256 for Extended VD firmware
and 128 for legacy firmware. Accessing indices beyond array size (OS will
send TUR, INQUIRY.. commands upto device index 255), may return valid LD
value and that particular SCSI command will be SUCCESS and creating SCSI
device for non existing target(VD).

For legacy firmware (64 VD firmware), invalidates LD (by setting LD value
to 0xff) in LdTgtIdtoLd[] array for device index beyond 127, so that
invalid LD(0xff) value should be returned beyond device index beyond 127.

Cc: <stable@vger.kernel.org>
Signed-off-by: Kashyap Desai <kashyap.desai@avagotech.com>
Signed-off-by: Sumit Saxena <sumit.saxena@avagotech.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agomegaraid_sas: add support for secure JBOD
Sumit.Saxena@avagotech.com [Mon, 5 Jan 2015 14:36:03 +0000 (20:06 +0530)]
megaraid_sas: add support for secure JBOD

This patch adds support for Secure Encrypting Drives (SED) in JBOD mode:

1) If the firmware supports SED JBOD, all non read/write commands to JBODs
   will be sent via firmware path, and read/write commands to JBODs will
   be sent via fastpath.
2) If the firmware does not support SED JBOD, driver will fall back to the
   old design, i.e. send all JBOD I/O via fastpath.

Signed-off-by: Sumit Saxena <sumit.saxena@avagotech.com>
Signed-off-by: Chaitra Basappa <chaitra.basappa@avagotech.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agomegaraid_sas: endianness related bug fixes and code optimization
Sumit.Saxena@avagotech.com [Mon, 5 Jan 2015 14:35:58 +0000 (20:05 +0530)]
megaraid_sas: endianness related bug fixes and code optimization

This patch addresses below issues:

1) Few endianness bug fixes.
2) Break the iteration after (MAX_LOGICAL_DRIVES_EXT - 1)),
   instead of MAX_LOGICAL_DRIVES_EXT.
3) Optimization in MFI INIT frame before firing.
4) MFI IO frame should be 256bytes aligned.  Code is optimized to reduce
   the size of frame for fusion adapters and make the MFI frame size
   calculation a bit transparent and readable.

Cc: <stable@vger.kernel.org>
Signed-off-by: Kashyap Desai <kashyap.desai@avagotech.com>
Signed-off-by: Sumit Saxena <sumit.saxena@avagotech.com>
Signed-off-by: Chaitra Basappa <chaitra.basappa@avagotech.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agoscsi: do not display kernel pointer in message logs
Hannes Reinecke [Thu, 8 Jan 2015 06:43:50 +0000 (07:43 +0100)]
scsi: do not display kernel pointer in message logs

It is not good practice to display the kernel pointer in any message logs,
and it doesn't display any additional information. And as we know have
block-layer assigned tags we can use them to differentiate the messages.
So remove any pointer references from the displayed messages.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agoscsi: Do not display buffer pointers in scsi_log_send()
Hannes Reinecke [Thu, 8 Jan 2015 06:43:49 +0000 (07:43 +0100)]
scsi: Do not display buffer pointers in scsi_log_send()

scsi_log_send() would display buffer pointer for higher logging levels.
This is not only of questionable value but also exposes kernel pointer to
userspace, which is discouraged in some setups. So drop this message
altogether.

Tested-by: Robert Elliott <elliott@hp.com>
Reviewed-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agoscsi: Conditionally compile in constants.c
Hannes Reinecke [Thu, 8 Jan 2015 06:43:48 +0000 (07:43 +0100)]
scsi: Conditionally compile in constants.c

Instead of having constants.c littered with ifdef statements we should
be moving dummy functions into the header and condintionally compile in
constants.c if selected. And update the Kconfig description to reflect
the actual size difference.

Suggested-by: Christoph Hellwig <hch@infradead.org>
Tested-by: Robert Elliott <elliott@hp.com>
Reviewed-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agoscsi: use per-cpu buffer for formatting scsi_print_result()
Hannes Reinecke [Thu, 8 Jan 2015 06:43:47 +0000 (07:43 +0100)]
scsi: use per-cpu buffer for formatting scsi_print_result()

Convert scsi_print_result() to use the per-cpu buffer for decoding the
command result and disposition.

Tested-by: Robert Elliott <elliott@hp.com>
Reviewed-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agoscsi: use per-cpu buffer for formatting sense
Hannes Reinecke [Thu, 8 Jan 2015 06:43:46 +0000 (07:43 +0100)]
scsi: use per-cpu buffer for formatting sense

Convert sense buffer logging to use the per-cpu buffer to avoid line
breakup.

Tested-by: Robert Elliott <elliott@hp.com>
Reviewed-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agolibata: use __scsi_format_command()
Hannes Reinecke [Thu, 8 Jan 2015 06:43:45 +0000 (07:43 +0100)]
libata: use __scsi_format_command()

libata already uses an internal buffer, so we should be using
__scsi_format_command() here.

Tested-by: Robert Elliott <elliott@hp.com>
Reviewed-by: Robert Elliott <elliott@hp.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agoscsi: use external buffer for command logging
Hannes Reinecke [Thu, 8 Jan 2015 06:43:44 +0000 (07:43 +0100)]
scsi: use external buffer for command logging

Use an external buffer for __scsi_print_command() and move command
logging over to use the per-cpu logging buffer.  With that we can
guarantee the command always will always be formatted in one line.
So we can even print out a variable length command correctly across
several lines. Finally rename __scsi_print_command() to
__scsi_format_comment() to better reflect the functionality.

Tested-by: Robert Elliott <elliott@hp.com>
Reviewed-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agoscsi: log request tag for scmd_printk()
Hannes Reinecke [Thu, 8 Jan 2015 06:43:43 +0000 (07:43 +0100)]
scsi: log request tag for scmd_printk()

The request tag provides a concise identification of a SCSI
command, so we should be printing that out for scmd_printk().

Suggested-by: Christoph Hellwig <hch@lst.de>
Tested-by: Robert Elliott <elliott@hp.com>
Reviewed-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agoscsi: Implement per-cpu logging buffer
Hannes Reinecke [Thu, 8 Jan 2015 06:43:42 +0000 (07:43 +0100)]
scsi: Implement per-cpu logging buffer

Implement a per-cpu buffer for formatting messages to avoid line breaks
up under high load.  This patch implements scmd_printk() and
sdev_prefix_printk() using the per-cpu buffer and makes sdev_printk() a
wrapper for sdev_prefix_printk().

Tested-by: Robert Elliott <elliott@hp.com>
Reviewed-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agostorvsc: force SPC-3 compliance on win8 and win8 r2 hosts
K. Y. Srinivasan [Tue, 16 Dec 2014 21:21:45 +0000 (13:21 -0800)]
storvsc: force SPC-3 compliance on win8 and win8 r2 hosts

On win8 and win8 r2 hosts force SPC-3 compliance for MSFT virtual disks.
Ubuntu has been carrying a similar patch outside the tree for a while now.
Starting with win10, the host will support SPC-3 compliance. Based on all
the testing that has been done on win8 and win8 r2 hosts, we are comfortable
claiming SPC-3 compliance on these hosts as well. This will enable TRIM
support on these hosts.

Suggested by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: Long Li <longli@microsoft.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agostorvsc: fix a bug in storvsc limits
K. Y. Srinivasan [Tue, 16 Dec 2014 21:21:44 +0000 (13:21 -0800)]
storvsc: fix a bug in storvsc limits

Commit 4cd83ecdac20d30725b4f96e5d7814a1e290bc7e changed the limits to
reflect the values on the host. It turns out that WS2008R2 cannot
correctly handle these new limits. Fix this bug by setting the limits
based on the host.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: Long Li <longli@microsoft.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agostorvsc: force discovery of LUNs that may have been removed.
K. Y. Srinivasan [Tue, 16 Dec 2014 21:21:43 +0000 (13:21 -0800)]
storvsc: force discovery of LUNs that may have been removed.

The host asks the guest to scan when a LUN is removed or added.
The only way a guest can identify the removed LUN is when an I/O is
attempted on a removed LUN - the SRB status code indicates that the LUN
is invalid. We currently handle this SRB status and remove the device.

Rather than waiting for an I/O to remove the device, force the discovery of
LUNs that may have been removed prior to discovering LUNs that may have
been added.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: Long Li <longli@microsoft.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agostorvsc: in responce to a scan event, scan the host
K. Y. Srinivasan [Tue, 16 Dec 2014 21:21:42 +0000 (13:21 -0800)]
storvsc: in responce to a scan event, scan the host

The virtual HBA that storvsc implements can support multiple channels and
targets. So, scan the host when the host notifies that a scan is needed.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: Long Li <longli@microsoft.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agostorvsc: use cmd_size to allocate per-command data
Christoph Hellwig [Tue, 30 Dec 2014 04:05:09 +0000 (20:05 -0800)]
storvsc: use cmd_size to allocate per-command data

STORVSC uses its own momory pool to manage device request data.  However,
the SCSI layer already has a mechanisim for allocating additional memory
for each command issued to device driver. This patch removes the memory
pool in STORVSC and makes it use SCSI layer to allocate memory for device
request data.

Reviewed-by: Long Li <longli@microsoft.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agolpfc: correct device removal deadlock after link bounce
James Smart [Tue, 30 Dec 2014 17:08:58 +0000 (12:08 -0500)]
lpfc: correct device removal deadlock after link bounce

This patch, applicable to 8G/4G/2G adapters, adds a call that
resumes transmit operations after a link bounce. Without it, targets
that tried to suspend exchanges after a link bounce (such as tape devices
using sequence level error recovery) would never resume io operation,
causing scan failures, and eventually deadlocks if a device removal
request is made.

Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: Dick Kennedy <dick.kennedy@emulex.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agoesp_scsi: remove check for ESP_MAX_TAGS
Hannes Reinecke [Fri, 2 Jan 2015 14:18:13 +0000 (15:18 +0100)]
esp_scsi: remove check for ESP_MAX_TAGS

'num_tags' is an unsigned char, so the check for 'ESP_MAX_TAGS'
(which is set to 256) is pointless.

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agompt3sas: issue_reset is uninitialized
Dan Carpenter [Thu, 4 Dec 2014 10:57:05 +0000 (13:57 +0300)]
mpt3sas: issue_reset is uninitialized

The "issue_reset" can be used uninitialized.  It should be set to false
at the start.

Also I cleaned up the types a little by using bool.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agompt2sas: issue_reset is uninitialized
Dan Carpenter [Thu, 4 Dec 2014 10:56:10 +0000 (13:56 +0300)]
mpt2sas: issue_reset is uninitialized

The "issue_reset" variable can be used uninitialized.  It should be set
to false at the start.

Also I cleaned up the types by using bool.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years ago3w-9xxx.c: Cleaning up missing null-terminate in conjunction with strncpy
Rickard Strandqvist [Sun, 27 Jul 2014 15:11:18 +0000 (17:11 +0200)]
3w-9xxx.c: Cleaning up missing null-terminate in conjunction with strncpy

Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
And use the sizeof on the to string rather than strlen on the from string.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Acked-by: Adam Radford <aradford@gmail.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agoscsi_debug: Implement WRITE BUFFER command
Ewan D. Milne [Thu, 4 Dec 2014 16:49:28 +0000 (11:49 -0500)]
scsi_debug: Implement WRITE BUFFER command

Accept the WRITE BUFFER command and do nothing other than
set the appropriate "microcode has been changed" UA on the LU.

>From an earlier patch by Doug Gilbert.

Signed-off-by: Ewan D. Milne <emilne@redhat.com>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
Tested-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agoscsi_debug: Add REPORTED LUNS DATA HAS CHANGED Unit Attention
Ewan D. Milne [Thu, 4 Dec 2014 16:49:27 +0000 (11:49 -0500)]
scsi_debug: Add REPORTED LUNS DATA HAS CHANGED Unit Attention

Generate a REPORTED LUNS DATA HAS CHANGED Unit Attention if
sysfs "max_luns" is used to change the number of scsi_debug LUNs.
This is only done if scsi_debug_scsi_level is SPC-3 or above.
Additionally, implement SPC-4 behavior which only generates
this Unit Attention on the first LUN on the target to receive
a command after the change.  This condition is cleared when
a REPORT LUNS command is received.

Signed-off-by: Ewan D. Milne <emilne@redhat.com>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
Tested-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agoses: Add power_status to SES device slot
Song Liu [Tue, 30 Dec 2014 22:46:18 +0000 (14:46 -0800)]
ses: Add power_status to SES device slot

Add power_status to SES device slot, so we can power on/off the
HDDs behind the enclosure.

Check firmware status in ses_set_* before sending control pages to
firmware.

Signed-off-by: Song Liu <songliubraving@fb.com>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Jens Axboe <axboe@fb.com>
Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agoses: add reliable slot attribute
Dan Williams [Tue, 30 Dec 2014 22:46:17 +0000 (14:46 -0800)]
ses: add reliable slot attribute

The name provided by firmware is in a vendor specific format, publish
the slot number to have a reliable mechanism for identifying slots
across firmware implementations.  If the enclosure does not provide a
slot number fallback to the component number which is guaranteed unique,
and usually mirrors the slot number.

Cleaned up the unused ses_component.desc in the process.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
Reviewed-by: Jens Axboe <axboe@fb.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agoses: add enclosure logical id
Dan Williams [Tue, 30 Dec 2014 22:46:16 +0000 (14:46 -0800)]
ses: add enclosure logical id

Export the NAA logical id for the enclosure.  This is optionally
available from the sas_transport_class, but it is really a property of
the enclosure.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
Reviewed-by: Jens Axboe <axboe@fb.com>
Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agoses: generate KOBJ_CHANGE on enclosure attach
Dan Williams [Tue, 30 Dec 2014 22:46:15 +0000 (14:46 -0800)]
ses: generate KOBJ_CHANGE on enclosure attach

In support of a /dev/disk/by-slot populated with data from the enclosure
and ses modules udev needs notification when the new interface
files/links are available.  Otherwise, any udev rules specified for the
disk cannot assume that the enclosure topology has settled.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
Reviewed-by: Jens Axboe <axboe@fb.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
9 years agoses: close potential registration race
Dan Williams [Tue, 30 Dec 2014 22:46:14 +0000 (14:46 -0800)]
ses: close potential registration race

The slot and address fields have a small window of instability when
userspace can read them before initialization. Separate
enclosure_component
allocation from registration.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
Reviewed-by: Jens Axboe <axboe@fb.com>
Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>