]> git.karo-electronics.de Git - karo-tx-linux.git/log
karo-tx-linux.git
8 years agocxlflash: Unmap problem state area before detaching master context
Uma Krishnan [Fri, 4 Mar 2016 21:55:15 +0000 (15:55 -0600)]
cxlflash: Unmap problem state area before detaching master context

When operating in the PowerVM environment, the cxlflash module can
receive an error from the hypervisor indicating that there are
existing mappings in the page table for the process MMIO space.

This issue exists because term_afu() currently invokes term_mc()
before stop_afu(), allowing for the master context to be detached
first and the problem state area to be unmapped second.

To resolve this issue, stop_afu() should be called before term_mc().

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agocxlflash: Simplify PCI registration
Manoj N. Kumar [Fri, 4 Mar 2016 21:55:14 +0000 (15:55 -0600)]
cxlflash: Simplify PCI registration

The calls to pci_request_regions(), pci_resource_start(),
pci_set_dma_mask(), pci_set_master() and pci_save_state() are all
unnecessary for the IBM CXL flash adapter since data buffers
are not required to be mapped to the device's memory.

The use of services such as pci_set_dma_mask() are problematic on
hypervisor managed systems as the IBM CXL flash adapter is operating
under a virtual PCI Host Bridge (virtual PHB) which does not support
these services.

cxlflash 0001:00:00.0: init_pci: Failed to set PCI DMA mask rc=-5

The resolution is to simplify init_pci(), to a point where it does the
bare minimum (pci_enable_device). Similarly, remove the call the
pci_release_regions() from cxlflash_remove().

Signed-off-by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>
Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agobe2iscsi: Remove unnecessary synchronize_irq() before free_irq()
Lars-Peter Clausen [Fri, 4 Mar 2016 10:15:06 +0000 (11:15 +0100)]
be2iscsi: Remove unnecessary synchronize_irq() before free_irq()

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

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

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_sysfs: call 'device_add' after attaching device handler
Hannes Reinecke [Thu, 3 Mar 2016 06:54:12 +0000 (07:54 +0100)]
scsi_sysfs: call 'device_add' after attaching device handler

'device_add' will be evaluating the 'is_visible' callback when creating
the sysfs attributes. As by this time the device handler has not been
attached the 'access_state' attribute will never be visible.

This patch moves the code around so that the device handler is present
by the time 'is_visible' is evaluated to correctly display the
'access_state' attribute.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Bart van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_emc: update 'access_state' field
Hannes Reinecke [Thu, 3 Mar 2016 06:54:11 +0000 (07:54 +0100)]
scsi_dh_emc: update 'access_state' field

Update the 'access_state' field of the SCSI device whenever the path
state changes.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_rdac: update 'access_state' field
Hannes Reinecke [Thu, 3 Mar 2016 06:54:10 +0000 (07:54 +0100)]
scsi_dh_rdac: update 'access_state' field

Track attached SCSI devices and update the 'access_state' whenever the
path state of the device changes.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_alua: update 'access_state' field
Hannes Reinecke [Thu, 3 Mar 2016 06:54:09 +0000 (07:54 +0100)]
scsi_dh_alua: update 'access_state' field

Track attached SCSI devices and update the 'access_state' field whenever
an ALUA state change has been detected.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Ewan Milne <emilne@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_alua: use common definitions for ALUA state
Hannes Reinecke [Thu, 3 Mar 2016 06:54:08 +0000 (07:54 +0100)]
scsi_dh_alua: use common definitions for ALUA state

scsi_proto.h now contains definitions for the ALUA state, so we don't
have to carry them in the device handler.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Bart van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: Add 'access_state' and 'preferred_path' attribute
Hannes Reinecke [Thu, 3 Mar 2016 06:54:07 +0000 (07:54 +0100)]
scsi: Add 'access_state' and 'preferred_path' attribute

Add an 'access_state' field to struct scsi_device and display them in
sysfs as 'access_state' and 'preferred_path' attribute.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Bart van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_sysfs: add 'is_bin_visible' callback
Hannes Reinecke [Thu, 3 Mar 2016 06:41:24 +0000 (07:41 +0100)]
scsi_sysfs: add 'is_bin_visible' callback

Add 'is_bin_visible' callback to blank out unsupported vpd pages.

Reviewed-by: Shane Seymour <shane.seymour@hpe.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: mvumi: use __maybe_unused to hide pm functions
Arnd Bergmann [Wed, 2 Mar 2016 15:59:00 +0000 (16:59 +0100)]
scsi: mvumi: use __maybe_unused to hide pm functions

The mvumi scsi hides the references to its suspend/resume functions in
an #ifdef but does not hide the implementation the same way:

drivers/scsi/mvumi.c:2632:12: error: 'mvumi_suspend' defined but not used [-Werror=unused-function]
drivers/scsi/mvumi.c:2651:12: error: 'mvumi_resume' defined but not used [-Werror=unused-function]

This adds __maybe_unused annotations so the compiler knows it can
silently drop them instead of warning, while avoiding the addition of
another #ifdef.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: storvsc: Fix a build issue reported by kbuild test robot
K. Y. Srinivasan [Sat, 27 Feb 2016 01:48:58 +0000 (17:48 -0800)]
scsi: storvsc: Fix a build issue reported by kbuild test robot

tree:   https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fgit.kernel.org%2fpub%2fscm%2flinux%2fkernel%2fgit%2ftorvalds%2flinux.git&data=01%7c01%7ckys%40microsoft.com%7ce2e0622715844b79ad7108d32796ec3c%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=ubr4GbBaNS%2ftOz%2buJBk0CL9N0UNG9x2TidLgy6Yovg4%3d master
head:   03c21cb775a313f1ff19be59c5d02df3e3526471
commit: dac582417bc449b1f7f572d3f1dd9d23eec15cc9 storvsc: Properly support Fibre Channel devices
date:   3 weeks ago
config: x86_64-randconfig-s3-01281016 (attached as .config)
reproduce:
        git checkout dac582417bc449b1f7f572d3f1dd9d23eec15cc9
        # save the attached .config to linux build tree
        make ARCH=x86_64

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `storvsc_remove':
>> storvsc_drv.c:(.text+0x213af7): undefined reference to `fc_remove_host'
   drivers/built-in.o: In function `storvsc_drv_init':
>> storvsc_drv.c:(.init.text+0xcbcc): undefined reference to `fc_attach_transport'
>> storvsc_drv.c:(.init.text+0xcc06): undefined reference to `fc_release_transport'
   drivers/built-in.o: In function `storvsc_drv_exit':
>> storvsc_drv.c:(.exit.text+0x123c): undefined reference to `fc_release_transport'

With this commit, the storvsc driver depends on FC atttributes. Make this
dependency explicit.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agosnic: correctly check for array overrun on overly long version number
Colin Ian King [Thu, 25 Feb 2016 22:58:25 +0000 (22:58 +0000)]
snic: correctly check for array overrun on overly long version number

The snic version number is expected to be 4 decimals in the form like a
netmask string with each number stored in an element in array v.
However, there is an off-by-one check on the number of elements in v
allowing one to pass a 5 decimal version number causing v[4] to be
referenced, causing a buffer overrun.  Fix the off-by-one error by
comparing to i > 3 rather than 4.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Shane Seymour <shane.seymour@hpe.com>
Reviewed-by: Ewan Milne <emilne@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoqlogicpti: Return correct error code
Amitoj Kaur Chawla [Wed, 17 Feb 2016 13:32:54 +0000 (19:02 +0530)]
qlogicpti: Return correct error code

The return value of of_ioremap on failure should be -ENODEV and not
-1.

Found using Coccinelle. A simplified version of the semantic patch
used is:

//<smpl>
@@
expression *e;
@@

e = of_ioremap(...);
if (e == NULL) {
...
return
- -1
+ -ENODEV
;
}
//</smpl>

The single call site only checks that the return value is less than 0,
hence no change is required at the call site.

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Reviewed-by: Shane Seymour <shane.seymour@hpe.com>
Reviewed-by: Hannes Reinicke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoncr5380: Call scsi_eh_prep_cmnd() and scsi_eh_restore_cmnd() as and when appropriate
Finn Thain [Mon, 22 Feb 2016 23:07:09 +0000 (10:07 +1100)]
ncr5380: Call scsi_eh_prep_cmnd() and scsi_eh_restore_cmnd() as and when appropriate

This bug causes the wrong command to have its sense pointer overwritten,
which sometimes leads to a NULL pointer deref. Fix this by checking which
command is being requeued before restoring the scsi_eh_save data.

It turns out that some targets will disconnect a REQUEST SENSE command.
The autosense algorithm doesn't anticipate this. Hence multiple commands
can end up undergoing autosense simultaneously, and they will all try to
use the same scsi_eh_save struct, which won't work. Defer autosense when
the scsi_eh_save storage is in use by another command.

Fixes: f27db8eb98a1 ("ncr5380: Fix autosense bugs")
Reported-and-tested-by: Michael Schmitz <schmitzmic@gmail.com>
Cc: <stable@vger.kernel.org> # 4.5
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoncr5380: Fix NCR5380_select() EH checks and result handling
Finn Thain [Mon, 22 Feb 2016 23:07:08 +0000 (10:07 +1100)]
ncr5380: Fix NCR5380_select() EH checks and result handling

Add missing checks for EH abort during arbitration and selection.
Rework the handling of NCR5380_select() result to improve clarity.

Fixes: 707d62b37fbb ("ncr5380: Fix EH during arbitration and selection")
Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Cc: <stable@vger.kernel.org> # 4.5
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoncr5380: Forget aborted commands
Finn Thain [Mon, 22 Feb 2016 23:07:07 +0000 (10:07 +1100)]
ncr5380: Forget aborted commands

The list structures and related logic used in the NCR5380 driver mean that
a command cannot be queued twice (i.e. can't appear on more than one queue
and can't appear on the same queue more than once).

The abort handler must forget the command so that the mid-layer can re-use
it. E.g. the ML may send it back to the LLD via via scsi_eh_get_sense().

Fix this and also fix two error paths, so that commands get forgotten iff
completed.

Fixes: 8b00c3d5d40d ("ncr5380: Implement new eh_abort_handler")
Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Cc: <stable@vger.kernel.org> # 4.5
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoncr5380: Dont re-enter NCR5380_select()
Finn Thain [Mon, 22 Feb 2016 23:07:06 +0000 (10:07 +1100)]
ncr5380: Dont re-enter NCR5380_select()

Calling NCR5380_select() from the abort handler causes various problems.
Firstly, it means potentially re-entering NCR5380_select(). Secondly, it
means that the lock is released, which permits the EH handlers to be
re-entered. The combination results in crashes. Don't do it.

Fixes: 8b00c3d5d40d ("ncr5380: Implement new eh_abort_handler")
Reported-and-tested-by: Michael Schmitz <schmitzmic@gmail.com>
Cc: <stable@vger.kernel.org> # 4.5
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoncr5380: Dont release lock for PIO transfer
Finn Thain [Mon, 22 Feb 2016 23:07:05 +0000 (10:07 +1100)]
ncr5380: Dont release lock for PIO transfer

The calls to NCR5380_transfer_pio() for DATA IN and DATA OUT phases will
modify cmd->SCp.this_residual, cmd->SCp.ptr and cmd->SCp.buffer. That
works as long as EH does not intervene, which became possible in
atari_NCR5380.c when I changed the locking to bring it closer to
NCR5380.c.

If error recovery aborts the command, the scsi_cmnd in question and its
buffer will be returned to the mid-layer. So the transfer has to cease,
but it can't be stopped by the initiator because the target controls the
bus phase.

The problem does not arise if the lock is not released. That was fine for
atari_scsi, because it implements DMA. For the other drivers, we have to
release the lock and re-enable interrupts for long PIO data transfers.

The solution is to split the transfer into small chunks. In between chunks
the main loop releases the lock and re-enables interrupts. Thus interrupts
can be serviced and eh_bus_reset_handler can intervene if need be.

This fixes an oops in NCR5380_transfer_pio() that can happen when the EH
abort handler is invoked during DATA IN or DATA OUT phase.

Fixes: 11d2f63b9cf5 ("ncr5380: Change instance->host_lock to hostdata->lock")
Reported-and-tested-by: Michael Schmitz <schmitzmic@gmail.com>
Cc: <stable@vger.kernel.org> # 4.5
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoncr5380: Correctly clear command pointers and lists after bus reset
Finn Thain [Mon, 22 Feb 2016 23:07:04 +0000 (10:07 +1100)]
ncr5380: Correctly clear command pointers and lists after bus reset

Commands subject to exception handling are to be returned to the scsi
mid-layer. Make sure that the various command pointers and command lists
in the low-level driver are correctly cleansed of affected commands.

This fixes some bugs that I accidentally introduced in v4.5-rc1 including
the removal of INIT_LIST_HEAD for the 'autosense' and 'disconnected'
command lists, and the possible NULL pointer dereference in
NCR5380_bus_reset() that was reported by Dan Carpenter.

hostdata->sensing may also point to an affected command so this pointer
also has to be cleared. The abort handler calls complete_cmd() to take
care of this; let's have the bus reset handler do the same.

The issue queue may also contain an affected command. If so, remove it.
This also follows the abort handler logic.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 62717f537e1b ("ncr5380: Implement new eh_bus_reset_handler")
Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Cc: <stable@vger.kernel.org> # 4.5
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agobe2iscsi:Add missing error check in beiscsi_eeh_resume
Nicholas Krause [Sat, 27 Feb 2016 17:43:25 +0000 (12:43 -0500)]
be2iscsi:Add missing error check in beiscsi_eeh_resume

This adds the missing error check and path for if the call to the
function hwi_init_controller fails as this error path was clearly missed
when writing beiscsi_eeh_resume and thus we must add it now in order to
be able to handle this nonrecoverable failing function call gracefully
in beiscsi_eeh_resume.

Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
Reviewed-by: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agofcoe: fix reset of fip selection time.
Usha Ketineni [Mon, 29 Feb 2016 11:36:52 +0000 (03:36 -0800)]
fcoe: fix reset of fip selection time.

Do not reset fip selection time for every advertisement
in fcoe_ctlr_recv_adv() but set it only once for the first
validated FCF. Otherwise FCF selection won't happen when the
advertisements consistently arrive with sub FCOE_CTLR_START_DELAY
periodicity.

Tested-by: Narendra K <narendra_k@dell.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Acked-by: Vasu Dev <vasu.dev@intel.com>
Signed-off-by: Usha Ketineni <usha.k.ketineni@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agohisi_sas: update driver version to 1.3
John Garry [Thu, 25 Feb 2016 09:42:15 +0000 (17:42 +0800)]
hisi_sas: update driver version to 1.3

Signed-off-by: John Garry <john.garry@huawei.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agohisi_sas: add hisi_sas_slave_configure()
John Garry [Thu, 25 Feb 2016 09:42:14 +0000 (17:42 +0800)]
hisi_sas: add hisi_sas_slave_configure()

In high-datarate aging tests, it is found that the
SCSI framework can periodically issue lu resets as
some commands timeout.
Response TASK SET FULL and SAS_QUEUE_FULL may be
returned many times for the same command, causing the
timeouts.
The SAS_QUEUE_FULL errors come from
TRANS_TX_CREDIT_TIMEOUT_ERR, TRANS_TX_CLOSE_NORMAL_ERR,
and TRANS_TX_ERR_FRAME_TXED errors. They do not mean
that the queue is full in the host, but rather it is
equivalent to meaning the queue is full for the sdev.
To overcome this, the queue depth for the sdev is
reduced to 64 (from 256, set in sas_slave_configure()).
Normally error code SAS_QUEUE_FULL will result in the
sdev queue depth falling, but it falls too slowly during
high-datarate tests and commands timeout before it
has fallen to an adequete level from original value.

Signed-off-by: John Garry <john.garry@huawei.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agohisi_sas: use slot abort in v2 hw
John Garry [Thu, 25 Feb 2016 09:42:13 +0000 (17:42 +0800)]
hisi_sas: use slot abort in v2 hw

When TRANS_TX_ERR_FRAME_TXED error occurs in
a slot, the command should be re-attempted.
This error is equivalent to meaning that the queue
is full in the sdev (and not the host).
A superflous debug statement is also removed in the
slot complete handler.

Signed-off-by: John Garry <john.garry@huawei.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agohisi_sas: use slot abort in v1 hw
John Garry [Thu, 25 Feb 2016 09:42:12 +0000 (17:42 +0800)]
hisi_sas: use slot abort in v1 hw

When TRANS_TX_CREDIT_TIMEOUT_ERR or
TRANS_TX_CLOSE_NORMAL_ERR error occur in
a slot, the command should be re-attempted.
This error is equivalent to meaning that the queue
is full in the sdev (and not the host).

Signed-off-by: John Garry <john.garry@huawei.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agohisi_sas: add hisi_sas_slot_abort()
John Garry [Thu, 25 Feb 2016 09:42:11 +0000 (17:42 +0800)]
hisi_sas: add hisi_sas_slot_abort()

Add a function to abort a slot (task) in the target
device and then cleanup and complete the task.
The function is called from work queue context as
it cannot be called from the context where it is
triggered (interrupt).
Flag hisi_sas_slot.abort is added as the flag used
in the slot error handler to indicate whether the
slot needs to be aborted in the sdev prior to
cleanup and finish.

Signed-off-by: John Garry <john.garry@huawei.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agohisi_sas: change tmf func complete check
John Garry [Thu, 25 Feb 2016 09:42:10 +0000 (17:42 +0800)]
hisi_sas: change tmf func complete check

In hisi_sas_exec_internal_tmf_task(), the check for
SAM_STAT_GOOD is replaced with
TMF_RESP_FUNC_COMPLETE, which is a genuine tmf
response code.
SAM_STAT_GOOD and TMF_RESP_FUNC_COMPLETE have the
same value, so this is why it worked before.

Signed-off-by: John Garry <john.garry@huawei.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agogdth: replace struct timeval with ktime_get_real_seconds()
Alison Schofield [Thu, 18 Feb 2016 05:29:34 +0000 (21:29 -0800)]
gdth: replace struct timeval with ktime_get_real_seconds()

struct timeval will overflow on 32-bit systems in y2038 and is being
removed from the kernel. Replace the use of struct timeval and
do_gettimeofday() with ktime_get_real_seconds() which provides a 64-bit
seconds value and is y2038 safe.

gdth driver requires changes in two areas:

1) gdth_store_event() loads two u32 timestamp fields for ioctl GDTIOCTL_EVENT

   These timestamp fields are part of struct gdth_evt_str used for passing
   event data to userspace. At the first instance of an event we do
   (first_stamp=last_stamp="current time"). If that same event repeats,
   we do (last_stamp="current time") AND increment same_count to indicate
   how many times the event has repeated since first_stamp.

   This patch replaces the use of timeval and do_gettimeofday() with
   ktime_get_real_seconds() cast to u32 to extend the timestamp fields
   to y2106.

   Beyond y2106, the userspace tools (ie. RAID controller monitors) can
   work around the time rollover and this driver would still not need to
   change.

   Alternative: The alternative approach is to introduce a new ioctl in gdth
   with the u32 time fields defined as u64.  This would require userspace
   changes now, but not in y2106.

2)  gdth_show_info() calculates elapsed time using u32 first_stamp

    It is adding events with timestamps to a seq_file.  Timestamps are
    calculated as the "current time" minus the first_stamp.

    This patch replaces the use of timeval and do_gettimeofday() with
    ktime_get_real_seconds() cast to u32 to calculate the timestamp.

    This elapsed time calculation is safe even when the time wraps (beyond
    y2106) due to how unsigned subtraction works. A comment has been added
    to the code to indicate this safety.

    Alternative: This piece itself doesn't warrant an alternative, but
    if we do introduce a new structure & ioctl with u64 timestamps, this
    would change accordingly.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoosd: remove deadcode
Sudip Mukherjee [Wed, 24 Feb 2016 11:21:28 +0000 (16:51 +0530)]
osd: remove deadcode

The variable is_ver1 is always true and so OSD_CAP_LEN can never be
used.

Reported by Coverity.

Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Acked-by: Boaz harrosh <ooo@elecrozaur.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoimm: check parport_claim
Sudip Mukherjee [Wed, 24 Feb 2016 10:57:11 +0000 (16:27 +0530)]
imm: check parport_claim

parport_claim() can fail and we should be checking if we were able to
claim the port.

Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agostex: Add S3/S4 support
Charles [Mon, 22 Feb 2016 12:07:09 +0000 (20:07 +0800)]
stex: Add S3/S4 support

Add S3/S4 support, add .suspend and .resume function in pci_driver.  In
.suspend handler, driver send S3/S4 signal to the device.

Signed-off-by: Charles Chiou <charles.chiou@tw.promise.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agostex: Add hotplug support
Charles [Mon, 22 Feb 2016 12:04:25 +0000 (20:04 +0800)]
stex: Add hotplug support

1. Add hotplug support. Pegasus support surprise removal. To this end, I
   use return_abnormal_state function to return DID_NO_CONNECT for all
   commands which sent to driver.

2. Remove stex_hba_stop in stex_remove because we cannot send command to
   device after hotplug.

3. Add new device status: MU_STATE_STOP, MU_STATE_NOCONNECT,
   MU_STATE_STOP. MU_STATE_STOP is currently not referenced.
   MU_STATE_NOCONNECT represent that device is plugged out from the
   host.

4. Use return_abnormal_function() to substitute part of code in
   stex_do_reset.

Signed-off-by: Charles Chiou <charles.chiou@tw.promise.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agostex: Support to Pegasus series.
Charles [Mon, 22 Feb 2016 12:02:02 +0000 (20:02 +0800)]
stex: Support to Pegasus series.

Pegasus is a high performace hardware RAID solution designed to unleash
the raw power of Thunderbolt technology.

1. Add code to distinct SuperTrack and Pegasus series by sub device ID.
   It should support backward compatibility.

2. Change the driver version.

Signed-off-by: Charles Chiou <charles.chiou@tw.promise.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agohpsa: update MAINTAINERS with new e-mail
Don Brace [Tue, 23 Feb 2016 21:21:44 +0000 (15:21 -0600)]
hpsa: update MAINTAINERS with new e-mail

Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Reviewed-by: Justin Lindley <justin.lindley@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>
8 years agohpsa: update copyright information
Don Brace [Tue, 23 Feb 2016 21:16:46 +0000 (15:16 -0600)]
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>
8 years agohpsa: remove function definition for sanitize_inquiry_string
Don Brace [Tue, 23 Feb 2016 21:16:40 +0000 (15:16 -0600)]
hpsa: remove function definition for sanitize_inquiry_string

This patch depends on patch
 - commit ac10a3e4ed64
   ("Export function scsi_scan.c:sanitize_inquiry_string")

Suggested-by: Hannes Reinecke <hare@suse.de>
Suggested-by: Matthew R. Ochs mrochs@linux.vnet.ibm.com
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>
8 years agohpsa: check for a null phys_disk pointer in ioaccel2 path
Don Brace [Tue, 23 Feb 2016 21:16:34 +0000 (15:16 -0600)]
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>
8 years agohpsa: correct abort tmf for hba devices
Don Brace [Tue, 23 Feb 2016 21:16:28 +0000 (15:16 -0600)]
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>
8 years agohpsa: correct lun data caching bitmap definition
Don Brace [Tue, 23 Feb 2016 21:16:22 +0000 (15:16 -0600)]
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>
8 years agohpsa: add SMR drive support
Don Brace [Tue, 23 Feb 2016 21:16:15 +0000 (15:16 -0600)]
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>
8 years agohpsa: do not get enclosure info for external devices
Don Brace [Tue, 23 Feb 2016 21:16:09 +0000 (15:16 -0600)]
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>
8 years agoscsi_dh_alua: Update version to 2.0
Hannes Reinecke [Fri, 19 Feb 2016 08:17:20 +0000 (09:17 +0100)]
scsi_dh_alua: Update version to 2.0

[mkp: Fixed merge due to patches 20-22 of series being postponed]

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh: add 'rescan' callback
Hannes Reinecke [Fri, 19 Feb 2016 08:17:16 +0000 (09:17 +0100)]
scsi_dh: add 'rescan' callback

If a device needs to be rescanned the device_handler might need
to be rechecked, too.
So add a 'rescan' callback to the device handler and call it
upon scsi_rescan_device(). The rescan callback will be invoked
from the Unit Attention handling of ASC/ASCQ 3F 03
(INQUIRY DATA HAS CHANGED).

Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_alua: Send TEST UNIT READY to poll for transitioning
Hannes Reinecke [Fri, 19 Feb 2016 08:17:15 +0000 (09:17 +0100)]
scsi_dh_alua: Send TEST UNIT READY to poll for transitioning

Sending a 'REPORT TARGET PORT GROUP' command is a costly operation,
as the array has to gather information about all ports.
So instead of using RTPG to poll for a status update when a port
is in transitioning we should be sending a TEST UNIT READY, and
wait for the sense code to report success.

Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Ewan Milne <emilne@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_alua: update all port states
Hannes Reinecke [Fri, 19 Feb 2016 08:17:14 +0000 (09:17 +0100)]
scsi_dh_alua: update all port states

When we read in the target port group state we should be
updating all affected port groups, otherwise we risk
running out of sync.

Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_alua: Recheck state on unit attention
Hannes Reinecke [Fri, 19 Feb 2016 08:17:13 +0000 (09:17 +0100)]
scsi_dh_alua: Recheck state on unit attention

When we receive a unit attention code of 'ALUA state changed'
we should recheck the state, as it might be due to an implicit
ALUA state transition. This allows us to return NEEDS_RETRY
instead of ADD_TO_MLQUEUE, allowing to terminate the retries
after a certain time.
At the same time a workqueue item might already be queued, which
should be started immediately to avoid any delays.

Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_alua: Add new blacklist flag 'BLIST_SYNC_ALUA'
Hannes Reinecke [Fri, 19 Feb 2016 08:17:12 +0000 (09:17 +0100)]
scsi_dh_alua: Add new blacklist flag 'BLIST_SYNC_ALUA'

Add a new blacklist flag BLIST_SYNC_ALUA to instruct the
alua device handler to use synchronous command submission
for ALUA commands.

Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_alua: Allow workqueue to run synchronously
Hannes Reinecke [Fri, 19 Feb 2016 08:17:11 +0000 (09:17 +0100)]
scsi_dh_alua: Allow workqueue to run synchronously

Some arrays may only capable of handling one STPG at a time,
so this patch adds a singlethreaded workqueue for STPGs to be
submitted synchronously.

Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_alua: Use workqueue for RTPG
Hannes Reinecke [Fri, 19 Feb 2016 08:17:10 +0000 (09:17 +0100)]
scsi_dh_alua: Use workqueue for RTPG

The current ALUA device_handler has two drawbacks:
- We're sending a 'SET TARGET PORT GROUP' command to every LUN,
  disregarding the fact that several LUNs might be in a port group
  and will be automatically switched whenever _any_ LUN within
  that port group receives the command.
- Whenever a LUN is in 'transitioning' mode we cannot block I/O
  to that LUN, instead the controller has to abort the command.
  This leads to increased traffic across the wire and heavy load
  on the controller during switchover.

With this patch the RTPG handling is moved to a per-portgroup
workqueue. This reduces the number of 'REPORT TARGET PORT GROUP'
and 'SET TARGET PORT GROUPS' sent to the controller as we're sending
them now per port group, and not per device as previously.
It also allows us to block I/O to any LUN / port group found to be
in 'transitioning' ALUA mode, as the workqueue item will be requeued
until the controller moves out of transitioning.

Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_alua: remove 'rel_port' from alua_dh_data structure
Hannes Reinecke [Fri, 19 Feb 2016 08:17:09 +0000 (09:17 +0100)]
scsi_dh_alua: remove 'rel_port' from alua_dh_data structure

The 'relative port' field is not used, and might get stale when
the port group changes. So remove the field altogether.

Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_alua: move optimize_stpg evaluation
Hannes Reinecke [Fri, 19 Feb 2016 08:17:08 +0000 (09:17 +0100)]
scsi_dh_alua: move optimize_stpg evaluation

When the optimize_stpg module option is set we should just set it
once during port_group allocation. Doing so allows us to override
it later with device specific settings.

Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agorevert commit a8e5a2d593cb ("[SCSI] scsi_dh_alua: ALUA handler attach should succeed...
Hannes Reinecke [Fri, 19 Feb 2016 08:17:07 +0000 (09:17 +0100)]
revert commit a8e5a2d593cb ("[SCSI] scsi_dh_alua: ALUA handler attach should succeed while TPG is transitioning")

This reverts commit a8e5a2d593cbfccf530c3382c2c328d2edaa7b66

Obsoleted by the next patch.

Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Ewan Milne <emilne@redhat.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_alua: simplify alua_initialize()
Hannes Reinecke [Fri, 19 Feb 2016 08:17:06 +0000 (09:17 +0100)]
scsi_dh_alua: simplify alua_initialize()

Rework alua_check_vpd() to use scsi_vpd_get_tpg()
and move the port group selection into the function, too.
With that we can simplify alua_initialize() to just
call alua_check_tpgs() and alua_check_vpd();

Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_alua: use unique device id
Hannes Reinecke [Fri, 19 Feb 2016 08:17:05 +0000 (09:17 +0100)]
scsi_dh_alua: use unique device id

Use scsi_vpd_lun_id() to assign a unique device identification
to the alua port group structure.

Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_alua: Use separate alua_port_group structure
Hannes Reinecke [Fri, 19 Feb 2016 08:17:04 +0000 (09:17 +0100)]
scsi_dh_alua: Use separate alua_port_group structure

The port group needs to be a separate structure as several
LUNs might belong to the same group.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Ewan Milne <emilne@redhat.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_alua: allocate RTPG buffer separately
Hannes Reinecke [Fri, 19 Feb 2016 08:17:03 +0000 (09:17 +0100)]
scsi_dh_alua: allocate RTPG buffer separately

The RTPG buffer will only evaluated within alua_rtpg(),
so we can allocate it locally there and avoid having to
put it into the global structure.

Reviewed-by: Ewan Milne <emilne@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_alua: switch to scsi_execute_req_flags()
Hannes Reinecke [Fri, 19 Feb 2016 08:17:02 +0000 (09:17 +0100)]
scsi_dh_alua: switch to scsi_execute_req_flags()

All commands are issued synchronously, so no need to open-code
scsi_execute_req_flags() anymore. And we can get rid of the
static sense code structure element. scsi_execute_req_flags()
will be setting REQ_QUIET and REQ_PREEMPT, but that is
perfectly fine as we're evaluating and logging any errors
ourselves and we really need to send the command even if
the device is quiesced.

Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Ewan Milne <emilne@redhat.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_alua: call alua_rtpg() if stpg fails
Hannes Reinecke [Fri, 19 Feb 2016 08:17:01 +0000 (09:17 +0100)]
scsi_dh_alua: call alua_rtpg() if stpg fails

If the call to SET TARGET PORT GROUPS fails we have no idea what
state the array is left in, so we need to issue a call to
REPORT TARGET PORT GROUPS in these cases.

Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_alua: Make stpg synchronous
Hannes Reinecke [Fri, 19 Feb 2016 08:17:00 +0000 (09:17 +0100)]
scsi_dh_alua: Make stpg synchronous

The 'activate_complete' function needs to be executed after
stpg has finished, so we can as well execute stpg synchronously
and call the function directly.

Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_alua: separate out alua_stpg()
Hannes Reinecke [Fri, 19 Feb 2016 08:16:59 +0000 (09:16 +0100)]
scsi_dh_alua: separate out alua_stpg()

Separate out SET TARGET PORT GROUP functionality into a separate
function alua_stpg().

Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh_alua: Pass buffer as function argument
Hannes Reinecke [Fri, 19 Feb 2016 08:16:58 +0000 (09:16 +0100)]
scsi_dh_alua: Pass buffer as function argument

Pass in the buffer as a function argument for submit_rtpg().

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agomptbase: fixup error handling paths in mpt_attach()
Ewan D. Milne [Tue, 23 Feb 2016 14:00:12 +0000 (09:00 -0500)]
mptbase: fixup error handling paths in mpt_attach()

mpt_attach() was not checking for the failure to create fw_event_q.
Also, iounmap() was not being called in all error cases after ioremap()
had been called by mpt_mapresources().

Signed-off-by: Ewan D. Milne <emilne@redhat.com>
Reported-by: Insu Yun <wuninsu@gmail.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agodpt_i2o: fix build warning
Sudip Mukherjee [Thu, 18 Feb 2016 08:29:13 +0000 (13:59 +0530)]
dpt_i2o: fix build warning

We were getting build warning about:
drivers/scsi/dpt_i2o.c:183:29: warning: 'dptids' defined but not used

dptids[] is only used in the MODULE_DEVICE_TABLE so when MODULE is not
defined then dptids[] becomes unused.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoSCSI: Updating maintainers list for MPT FUSION DRIVERS.
Suganath prabu Subramani [Thu, 18 Feb 2016 08:39:46 +0000 (14:09 +0530)]
SCSI: Updating maintainers list for MPT FUSION DRIVERS.

Updating maintainers list for MPT FUSION DRIVERS, broadcom support link
and email id.

Signed-off-by: Suganath prabu Subramani <suganath-prabu.subramani@avagotech.com>
Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agompt3sas: Free memory pools before retrying to allocate with different value.
Suganath prabu Subramani [Thu, 18 Feb 2016 08:39:45 +0000 (14:09 +0530)]
mpt3sas: Free memory pools before retrying to allocate with different value.

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

Signed-off-by: Suganath prabu Subramani <suganath-prabu.subramani@avagotech.com>
Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agolpfc: fix missing zero termination in debugfs
Alan [Mon, 15 Feb 2016 19:11:56 +0000 (19:11 +0000)]
lpfc: fix missing zero termination in debugfs

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

Signed-off-by: Alan Cox <alan@linux.intel.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoesas2r: Fix array overrun
Alan [Mon, 15 Feb 2016 19:01:29 +0000 (19:01 +0000)]
esas2r: Fix array overrun

Check the array size *before* dereferencing it with a user provided
offset.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoaic7xxx: Fix queue depth handling
Alan [Mon, 15 Feb 2016 18:53:15 +0000 (18:53 +0000)]
aic7xxx: Fix queue depth handling

We were setting the queue depth correctly, then setting it back to
two. If you hit this as a bisection point then please send me an email
as it would imply we've been hiding other bugs with this one.

Cc: <stable@vger.kernel.org>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Reviewed-by: Hannes Reinicke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoibmvfc: byteswap scsi_id, wwpn, and node_name prior to logging
Tyrel Datwyler [Thu, 11 Feb 2016 22:24:35 +0000 (16:24 -0600)]
ibmvfc: byteswap scsi_id, wwpn, and node_name prior to logging

When logging async events the scsi_id, wwpn, and node_name values are
used directly from the CRQ struct which are of type __be64. This can be
confusing to someone looking through the log on a LE system.  Instead
byteswap these values to host endian prior to logging.

Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoibmvscsi: use H_CLOSED instead of magic number
Tyrel Datwyler [Thu, 11 Feb 2016 01:32:28 +0000 (19:32 -0600)]
ibmvscsi: use H_CLOSED instead of magic number

In a couple places the magic value of 2 is used to check the return code
of hypercalls. This translates to H_CLOSED.

Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoibmvscsi: Add endian conversions to sysfs attribute show functions
Tyrel Datwyler [Thu, 11 Feb 2016 01:32:27 +0000 (19:32 -0600)]
ibmvscsi: Add endian conversions to sysfs attribute show functions

The values returned by the show functions for the host os_type,
mad_version, and partition_number attributes get their values directly
from the madapter_info struct whose associated fields are __be32
typed. Added endian conversion to ensure these values are sane on LE
platforms.

Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoibmvscsi: Remove unsupported host config MAD
Tyrel Datwyler [Thu, 11 Feb 2016 01:32:26 +0000 (19:32 -0600)]
ibmvscsi: Remove unsupported host config MAD

A VIOSRP_HOST_CONFIG_TYPE management datagram (MAD) has existed in the
code for some time. From what information I've gathered from Brian King
this was likely implemented on the host side in a SLES 9 based VIOS,
which is no longer supported anywhere. Further, it is not defined in
PAPR or supported by any AIX based VIOS.

Treating as bit rot and removing the associated host config code.  The
config attribute and its show function are left as not to break
userspace. The behavior remains the same returning nothing.

Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoibmvscsi: Use of_root to access OF device tree root node
Tyrel Datwyler [Thu, 11 Feb 2016 01:32:25 +0000 (19:32 -0600)]
ibmvscsi: Use of_root to access OF device tree root node

The root node of the OF device tree is exported as of_root. No need to
look up the root by path name. Instead just get a reference directly via
of_root.

Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoibmvscsi: Replace magic values in set_adpater_info() with defines
Tyrel Datwyler [Thu, 11 Feb 2016 01:32:24 +0000 (19:32 -0600)]
ibmvscsi: Replace magic values in set_adpater_info() with defines

Add defines for mad version and mad os_type, and replace the magic
numbers in set_adapter_info() accordingly.

Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Manoj Kumar <manoj@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoibmvscsi: Add and use enums for valid CRQ header values
Tyrel Datwyler [Thu, 11 Feb 2016 01:32:23 +0000 (19:32 -0600)]
ibmvscsi: Add and use enums for valid CRQ header values

The PAPR defines four valid header values for the first byte of a CRQ
message. Namely, an unused/empty message (0x00), a valid
command/response entry (0x80), a valid initialization entry (0xC0), and
a valid transport event (0xFF). Further, initialization responses have
two formats namely initialize (0x01) and initialize complete
(0x02). Define these values as enums and use them in the code in
place of their magic number equivalents.

Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Reported-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Manoj Kumar <manoj@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoibmvscsi: Correct values for several viosrp_crq_format enums
Tyrel Datwyler [Thu, 11 Feb 2016 01:32:22 +0000 (19:32 -0600)]
ibmvscsi: Correct values for several viosrp_crq_format enums

The enum values for VIOSRP_LINUX_FORMAT and VIOSRP_INLINE_FORMAT are off
by one. They are currently defined as 0x06 and 0x07 respetively.  These
values are defined in PAPR correctly as 0x05 and 0x06. This
inconsistency has gone unnoticed as neither enum is currently used.  The
possible future support of PING messages between the VIOS and client
adapter relies on VIOSRP_INLINE_FORMAT crq messages.  Corrected these
enum values to match PAPR definitions.

Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Manoj Kumar <manoj@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agompt3sas: Remove cpumask_clear for zalloc_cpumask_var and don't free free_cpu_mask_var...
Suganath prabu Subramani [Thu, 11 Feb 2016 09:32:55 +0000 (15:02 +0530)]
mpt3sas: Remove cpumask_clear for zalloc_cpumask_var and don't free free_cpu_mask_var before reply_q

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

Signed-off-by: Suganath prabu Subramani <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agolpfc: Add lockdep assertions
Johannes Thumshirn [Wed, 20 Jan 2016 15:22:22 +0000 (16:22 +0100)]
lpfc: Add lockdep assertions

Several functions in lpfc have comments stating that the function must
be called with the hbalock (or hostlock, or ringlock) held. Add
lockdep_assert_held() annotations to these functions, so one can
actually verify the locks are held.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Acked-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agobfa: deinline __bfa_trc() and __bfa_trc32()
Denys Vlasenko [Thu, 4 Feb 2016 20:40:48 +0000 (21:40 +0100)]
bfa: deinline __bfa_trc() and __bfa_trc32()

__bfa_trc() compiles to 115 bytes of machine code.
With this .config: http://busybox.net/~vda/kernel_config
there are 1494 calls of __bfa_trc().

__bfa_trc32() is very similar, so it is uninlined too.
However, it appears to be unused, therefore this patch
ifdefs it out.

Change in code size is about 130,000 bytes:

    text     data      bss       dec     hex filename
85975426 22294712 20627456 128897594 7aed23a vmlinux.before
85842882 22294584 20627456 128764922 7accbfa vmlinux

[mkp: Removed unused __bfa_trc32()]

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Acked-by: Anil Gurumurthy <anil.gurumurthy@qlogic.com>
CC: Fabian Frederick <fabf@skynet.be>
CC: Anil Gurumurthy <anil.gurumurthy@qlogic.com>
CC: Christoph Hellwig <hch@lst.de>
CC: Guenter Roeck <linux@roeck-us.net>
CC: Ben Hutchings <ben@decadent.org.uk>
CC: James Bottomley <JBottomley@Parallels.com>
CC: linux-kernel@vger.kernel.org
CC: linux-scsi@vger.kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: ppa: use new parport device model
Sudip Mukherjee [Thu, 11 Feb 2016 05:12:49 +0000 (10:42 +0530)]
scsi: ppa: use new parport device model

Modify ppa driver to use the new parallel port device model.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: sim710: fix build warning
Sudip Mukherjee [Thu, 11 Feb 2016 04:59:03 +0000 (10:29 +0530)]
scsi: sim710: fix build warning

We are getting build warning about:
 "Section mismatch in reference from the variable sim710_eisa_driver to
 the function .init.text:sim710_eisa_probe()
 The variable sim710_eisa_driver references the function __init
 sim710_eisa_probe()"

sim710_eisa_probe() was having __init but that was being referenced from
sim710_eisa_driver.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agobe2iscsi: Fix memory leak in beiscsi_alloc_mem()
Maurizio Lombardi [Thu, 1 Oct 2015 08:56:25 +0000 (10:56 +0200)]
be2iscsi: Fix memory leak in beiscsi_alloc_mem()

In case of error, the memory allocated for phwi_ctrlr was not freed.

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: ufs: fix typo in comment
Tomas Winkler [Tue, 9 Feb 2016 08:25:41 +0000 (10:25 +0200)]
scsi: ufs: fix typo in comment

[mkp: Only one typo remained]

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoufs: fix typo: MAZ to MAX
Tomas Winkler [Tue, 9 Feb 2016 08:25:40 +0000 (10:25 +0200)]
ufs: fix typo: MAZ to MAX

QUERY_DESC_GEOMETRY_MAZ_SIZE
QUERY_DESC_GEOMETRY_MAX_SIZE

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: ufs: add wrapper for retrying sending query attribute
Yaniv Gardi [Mon, 1 Feb 2016 13:02:50 +0000 (15:02 +0200)]
scsi: ufs: add wrapper for retrying sending query attribute

Sometimes queries from the device might return a failure so it is
recommended to retry sending the query, before giving up.  This change
adds a wrapper to retry sending a query attribute, in cases where we
need to wait longer, before we continue, or before reporting a failure.

Reviewed-by: Gilad Broner <gbroner@codeaurora.org>
Reviewed-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: ufs: commit descriptors before setting the doorbell
Yaniv Gardi [Mon, 1 Feb 2016 13:02:49 +0000 (15:02 +0200)]
scsi: ufs: commit descriptors before setting the doorbell

Add a write memory barrier to make sure descriptors prepared are
actually written to memory before ringing the doorbell. We have also
added the write memory barrier after ringing the doorbell register so
that controller sees the new request immediately.

Reviewed-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: ufs: add missing memory barriers
Yaniv Gardi [Mon, 1 Feb 2016 13:02:48 +0000 (15:02 +0200)]
scsi: ufs: add missing memory barriers

Performing several writes to UFS host controller registers has no
guarantee of ordering, so we must make sure register writes to setup
request list base address etc. are performed before the run/stop
register is enabled.  In addition, when setting up a task request, we
must make sure the updating of descriptors takes places before ringing
the doorbell, similarly to setting up a transfer request.

Reviewed-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: ufs: reduce the interrupts for power mode change requests
Yaniv Gardi [Mon, 1 Feb 2016 13:02:47 +0000 (15:02 +0200)]
scsi: ufs: reduce the interrupts for power mode change requests

DME commands such as Hibern8 enter/exit and gear switch generate 2
completion interrupts, one for confirmation that command is received by
local UniPro and 2nd one is the final confirmation after communication
with remote UniPro. Currently both of these completions are registered
as interrupt events which is not quite necessary and instead we can just
wait for the interrupt of 2nd completion, this should reduce the number
of interrupts and could reduce the unnecessary CPU wakeups to handle
extra interrupts.

Reviewed-by: Gilad Broner <gbroner@codeaurora.org>
Reviewed-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: ufs: retry failed query flag requests
Yaniv Gardi [Mon, 1 Feb 2016 13:02:46 +0000 (15:02 +0200)]
scsi: ufs: retry failed query flag requests

UFS flag query requests may fail sometimes due to timeouts etc.  Add a
wrapper function to retry up to 10 times in case of such failure,
similar to retries being made for attribute queries.

Reviewed-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: ufs: fix error recovery after the hibern8 exit failure
Yaniv Gardi [Mon, 1 Feb 2016 13:02:45 +0000 (15:02 +0200)]
scsi: ufs: fix error recovery after the hibern8 exit failure

Hibern8 exit can be called from 3 different contexts:
    - ufshcd_hibern8_exit_work
    - ufshcd_ungate_work
    - runtime/system resume

If hibern8 exit fails for some reason then we try to bring the link to
active state by link startup but this recovery mechanism results into
deadlock or errors from first 2 context listed above. This change fixes
the recovery by adding proper error handling mechanism.

Reviewed-by: Gilad Broner <gbroner@codeaurora.org>
Reviewed-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: ufs: add retries for hibern8 enter
Yaniv Gardi [Mon, 1 Feb 2016 13:02:44 +0000 (15:02 +0200)]
scsi: ufs: add retries for hibern8 enter

If hibern8 enter command fails then UFS link state may be unknown which
may result into timeout of all the commands issued after failure.

This change does 2 things (for pre-defined number of retry counts) after
hibern8 enter failure:

1. Recovers the UFS link to active state

2. If link is recovered to active state, tries to put the UFS link in
   hibern8 enter again until retry count expires.

Reviewed-by: Gilad Broner <gbroner@codeaurora.org>
Reviewed-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: ufs: add retries to dme_peer get and set attribute
Yaniv Gardi [Mon, 1 Feb 2016 13:02:43 +0000 (15:02 +0200)]
scsi: ufs: add retries to dme_peer get and set attribute

The dme_peer get/set attribute commands are prone to errors, therefore
we add three retries for the UIC command sending.  Error code returned
from ufshcd_send_uic_cmd() is checked, and unless it was successful or
the retries have finished, another command will be sent.

Reviewed-by: Gilad Broner <gbroner@codeaurora.org>
Reviewed-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: ufs: avoid exception event handler racing with PM callbacks
Yaniv Gardi [Mon, 1 Feb 2016 13:02:42 +0000 (15:02 +0200)]
scsi: ufs: avoid exception event handler racing with PM callbacks

If device raises the exception event in the response to the commands
sent during the runtime/system PM callbacks, exception event handler
might run in parallel with PM callbacks and may see unclocked register
accesses. This change fixes this issue by not scheduling the exception
event handler while PM callbacks are running.

Reviewed-by: Gilad Broner <gbroner@codeaurora.org>
Reviewed-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: ufs: increase fDeviceInit query response timeout
Yaniv Gardi [Mon, 1 Feb 2016 13:02:41 +0000 (15:02 +0200)]
scsi: ufs: increase fDeviceInit query response timeout

fDeviceInit query response time for some devices is too long that
default query request timeout of 100ms may not be enough. Experiments
show that fDeviceInit response sometimes takes 500ms so to be on safer
side this change sets the timeout to 600ms. Without this change, we
might unnecessarily have to retry fDeviceInit query requests multiple
times and each query request timeout prints one error message.

Reviewed-by: Gilad Broner <gbroner@codeaurora.org>
Reviewed-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: ufs: clear outstanding_request bit in case query timeout
Yaniv Gardi [Mon, 1 Feb 2016 13:02:40 +0000 (15:02 +0200)]
scsi: ufs: clear outstanding_request bit in case query timeout

When sending a query to the device returns with a timeout error, we
clear the corresponding bit in the DOORBELL register but we don't clear
the outstanding_request field as we should.  This patch fixes this bug.

Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
Reviewed-by: Gilad Broner <gbroner@codeaurora.org>
Reviewed-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: ufs: verify command tag validity
Yaniv Gardi [Mon, 1 Feb 2016 13:02:39 +0000 (15:02 +0200)]
scsi: ufs: verify command tag validity

A race condition appear to exist between request completion when
scsi_done() is called to end the request and set the tag back to -1 (at
blk_queue_end_tag() scsi_end_request), and scsi layer error handling
which aborts the command and reuses it to request sense data. Sending
the request sense is done with tag which was set to -1 and so it is
invalid.  Assert command tag passed from scsi layer is valid.

Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
Reviewed-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: ufs: clear fields UTRD, UPIU req and rsp before new transfers
Yaniv Gardi [Mon, 1 Feb 2016 13:02:38 +0000 (15:02 +0200)]
scsi: ufs: clear fields UTRD, UPIU req and rsp before new transfers

Some of the data structures (like response UPIU) and/or its elements
(unused fields) should be cleared before sending out the respective
command to UFS device.

This change clears the UPIU response data structure for query commands
and NOP command before sending out the command. We also initialize the
PRDT table length to zero which should take care of commands which
doesn't have any data associated with it. We are also clearing the
unused fields in request UPIU for NOP command.

Reviewed-by: Gilad Broner <gbroner@codeaurora.org>
Reviewed-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Tested-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi: ufs: clear UTRD, UPIU req and rsp before new transfers
Yaniv Gardi [Mon, 1 Feb 2016 13:02:37 +0000 (15:02 +0200)]
scsi: ufs: clear UTRD, UPIU req and rsp before new transfers

Clear the UFS data structures before sending new request.

The SCSI command is sent to the device within the UFS UPIU request.
As part of the transfer UPIU preparation, the SCSI command is copied
to the UPIU structure according to the SCSI command size.
As different SCSI commands differ in size from each other, we need
to clear the whole SCSI command field to prevent sending uninitialized
data to the device.

The UPIU response doesn't always include the sense data and can differ
in size.
Hence, the UPIU response should also be cleared before the transfer.

Reviewed-by: Gilad Broner <gbroner@codeaurora.org>
Reviewed-by: Dolev Raviv <draviv@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoscsi_dh: force modular build if SCSI is a module
Arnd Bergmann [Wed, 27 Jan 2016 15:57:23 +0000 (16:57 +0100)]
scsi_dh: force modular build if SCSI is a module

When the scsi_dh core was moved into the scsi core module,
CONFIG_SCSI_DH became a 'bool' option, and now anything depending on it
can be built-in even when CONFIG_SCSI=m. This of course cannot link
successfully:

drivers/scsi/built-in.o: In function `rdac_init':
scsi_dh_alua.c:(.init.text+0x14): undefined reference to `scsi_register_device_handler'
scsi_dh_alua.c:(.init.text+0x64): undefined reference to `scsi_unregister_device_handler'
drivers/scsi/built-in.o: In function `alua_init':
scsi_dh_alua.c:(.init.text+0xb0): undefined reference to `scsi_register_device_handler'

As a workaround, this adds an extra dependency on CONFIG_SCSI, so
Kconfig can figure out whether built-in is allowed or not.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 086b91d052eb ("scsi_dh: integrate into the core SCSI code")
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>