History log of /drivers/scsi/mpt2sas/mpt2sas_base.c
Revision Date Author Comments
a66dd970c7808f0a3453bbc38b39553f6eafd994 12-Sep-2014 Sreekanth Reddy <sreekanth.reddy@avagotech.com> mpt2sas: Get IOC_FACTS information using handshake protocol only after HBA card gets into READY or Operational state.

Driver initialization fails if driver tries to send IOC facts request message when the IOC is in reset or in a fault state.

This patch will make sure that
1.Driver to send IOC facts request message only if HBA is in operational or ready state.
2.If IOC is in fault state, a diagnostic reset would be issued.
3.If IOC is in reset state then driver will wait for 10 seconds to exit out of reset state.
If the HBA continues to be in reset state, then the HBA wouldn't be claimed by the driver.

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>
5fb1bf8aaa832e1e9ca3198de7bbecb8eff7db9c 12-Sep-2014 Sreekanth Reddy <sreekanth.reddy@avagotech.com> mpt2sas: Added Reply Descriptor Post Queue (RDPQ) Array support

Up to now, Driver allocates a single contiguous block of memory
pool for all reply queues and passes down a single address in the
ReplyDescriptorPostQueueAddress field of the IOC Init Request
Message to the firmware.

When firmware receives this address, it will program each of the
Reply Descriptor Post Queue registers, as each reply queue has its
own register. Thus the firmware, starting from a base address it
determines the starting address of the subsequent reply queues
through some simple arithmetic calculations.

The size of this contiguous block of memory pool is directly proportional
to number of MSI-X vectors and the HBA queue depth. For example higher
MSIX vectors requires larger contiguous block of memory pool.

But some of the OS kernels are unable to allocate this larger
contiguous block of memory pool.

So, the proposal is to allocate memory independently for each
Reply Queue and pass down all of the addresses to the firmware.
Then the firmware will just take each address and program the value
into the correct register.

When HBAs with older firmware(i.e. without RDPQ capability) is used
with this new driver then the max_msix_vectors value would be set
to 8 by default.

Change_set in v1:

1. Declared _base_get_ioc_facts() function at the beginning of the mpt2sas_base.c
file instead of moving all these functions before mpt2sas_base_map_resources() function
a. _base_wait_for_doorbell_int()
b. _base_wait_for_doorbell_ack()
c. _base_wait_for_doorbell_not_used()
d. _base_handshake_req_reply_wait()
e. _base_get_ioc_facts()

2. Initially set the consistent DMA mask to 32 bit and then change it to 64 bit mask
after allocating RDPQ pools by calling the function _base_change_consistent_dma_mask.
This is to ensure that all the upper 32 bits of RDPQ entries's base address to be same.

3. Reduced the redundancy between the RDPQ and non-RDPQ support in these following functions
a. _base_release_memory_pools()
b. _base_allocate_memory_pools()
c. _base_send_ioc_init()
d. _base_make_ioc_operational()

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>
e9edbe310dbb745067f7c5761ba91005fb9d60af 12-Sep-2014 Sreekanth Reddy <sreekanth.reddy@avagotech.com> mpt2sas: Copyright in driver sources is updated for year the 2014

Copyright in driver sources is updated for year the 2014.

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>
4e1f20ae4f92706518d6c18b13da8c2bc28339c7 12-Sep-2014 Sreekanth Reddy <sreekanth.reddy@avagotech.com> mpt2sas: Added driver module parameter max_msix_vectors

Added driver module parameter max_msix_vectors. Using this
module parameter the maximum number of MSI-X vectors could be set.

The number of MSI-X vectors used would be the minimum of MSI-X vectors
supported by the HBA, the number of CPU cores and the value set to
max_msix_vectors module parameters.

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>
52674c65f9751f607a4ed9d75227a0d8e4f54189 18-Aug-2014 Alexander Gordeev <agordeev@redhat.com> mpt2sas: Use pci_enable_msix_exact() instead of pci_enable_msix()

As result of deprecation of MSI-X/MSI enablement functions
pci_enable_msix() and pci_enable_msi_block() all drivers
using these two interfaces need to be updated to use the
new pci_enable_msi_range() or pci_enable_msi_exact()
and pci_enable_msix_range() or pci_enable_msix_exact()
interfaces.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Cc: Nagalakshmi Nandigama <Nagalakshmi.Nandigama@lsi.com>
Cc: Sreekanth Reddy <Sreekanth.Reddy@lsi.com>
Cc: support@lsi.com
Cc: DL-MPTFusionLinux@lsi.com
Cc: linux-scsi@vger.kernel.org
Cc: linux-pci@vger.kernel.org
Signed-off-by: Christoph Hellwig <hch@lst.de>
02b7708134037f85656d15992912226134b10250 13-Jul-2014 Reddy, Sreekanth <Sreekanth.Reddy@avagotech.com> mpt2sas: delay scsi_add_host call to work with scsi-mq

In _scsih_probe, delay the call to scsi_add_host until the host has been
fully set up.

Otherwise, the default .can_queue value of 1 causes scsi-mq to set the block
layer request queue size to its minimum size, resulting in awful performance.

In _scsih_probe error handling, call mpt3sas_base_detach rather than
scsi_remove_host to properly clean up in reverse order.

In _scsih_remove, call scsi_remove_host earlier to clean up in reverse order.

Signed-off-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nagalakshmi Nandigama <Nagalakshmi.Nandigama@avagotech.com>
Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
cbbb7b31ad842e17b690254a546ddcedc79a4f05 04-Jan-2014 Martin K. Petersen <martin.petersen@oracle.com> mpt2sas: Rework the MSI-X grouping code

On systems with a non power-of-two CPU count the existing MSI-X grouping
code failed to distribute interrupts correctly. Rework the code to
handle arbitrary processor counts.

Also remove the hardcoded upper limit on the number of processors so we
can boot on large systems.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Acked-by: Sreekanth Reddy <Sreekanth.reddy@avagotech.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
42de597eabc2ba837203788170cc57814a9df7a7 25-Jun-2014 Joe Lawrence <joe.lawrence@stratus.com> mpt2sas: annotate ioc->reply_post_host_index as __iomem

The MPT2SAS_ADAPTER reply_post_host_index[] holds calculated addresses
in memory mapped register space. Add an "__iomem" annotation to silence
the following sparse warnings:

drivers/scsi/mpt2sas/mpt2sas_base.c:1006:43:
warning: incorrect type in argument 2 (different address spaces)
expected void volatile [noderef] <asn:2>*addr
got unsigned long long [usertype] *<noident>

drivers/scsi/mpt2sas/mpt2sas_base.c:4299:22:
warning: cast removes address space of expression
drivers/scsi/mpt2sas/mpt2sas_base.c:4303:27:
warning: cast removes address space of expression

Signed-off-by: Joe Lawrence <joe.lawrence@stratus.com>
Acked-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
049b3e81d79b1957c0be231d66a98b5715b347e4 27-Mar-2014 Matthew Wilcox <matthew.r.wilcox@intel.com> mpt2sas: Add free smids to the head, not tail of list

Reusing a smid quickly means it's still cache-hot. This yields a small
but noticable performance improvement in a well-known database benchmark.
This improvement is already present in the mpt3sas driver.

Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Reviewed-by: Nicholas Bellinger <nab@linux-iscsi.org>
Reviewed-by: Praveen Krishnamoorthy <Praveen.krishnamoorthy@lsi.com>
Acked-by: Sreekanth Reddy <Sreekanth.reddy@lsi.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
64cdb4181d87900c6560f8c72d02c7ccf75c9070 10-Jan-2014 Rafael J. Wysocki <rafael.j.wysocki@intel.com> MPT / PCI: Use pci_stop_and_remove_bus_device_locked()

Race conditions are theoretically possible between the MPT PCI device
removal and the generic PCI bus rescan and device removal that can be
triggered via sysfs.

To avoid those race conditions make the MPT PCI code use
pci_stop_and_remove_bus_device_locked().

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
d648d5a9a803eb94d6a13beee3e9d40e8f09a9ed 25-Jul-2013 Sreekanth Reddy <Sreekanth.Reddy@lsi.com> [SCSI] mpt2sas: The copyright in driver sources is updated for the year 2013

The copyright in driver sources is updated for the year 2013.

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
6409a7d000020ffdd61082af8bb24291d2cdc1a6 25-Jul-2013 Sreekanth Reddy <Sreekanth.Reddy@lsi.com> [SCSI] mpt2sas: Null pointer deference possibility in mpt2sas_ctl_event_callback function

Added a check to identify if mpi_reply is NULL in mpt2sas_ctl_event_callback()
and return without proceeding if it is the case.

Also modified the following functions to return void instead of 0 or 1
as returning those values from events perspective doesn't make sense.
* _base_async_event()
* mpt2sas_ctl_event_callback()
* mpt2sas_scsih_event_callback()

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
3b3e6f8df3b03642d6705d1db84842c24415b21f 08-Aug-2013 Joe Lawrence <joe.lawrence@stratus.com> [SCSI] mpt2sas: fix cleanup on controller resource mapping failure

If mpt2sas_base_map_resources takes an early error path then its
counterpart, mpt2sas_base_free_resources needs to be careful about
cleaning up:

1 - _base_mask_interrupts and _base_make_ioc_ready require memory
mapped I/O registers, make sure that this is true.

2 - _base_free_irq iterates over the adapter's reply_queue_list, so
move this list head initialization out of _base_enable_msix to
_scsih_probe so this will always be safe.

3 - check that the controller PCI device and its BARs have been
enabled before disabling them.

Signed-off-by: Joe Lawrence <joe.lawrence@stratus.com>
Acked-by: Sreekanth Reddy <Sreekanth.Reddy@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
148124d9310f3870fb016bd2637057841d5b7705 01-Feb-2013 Sreekanth Reddy <Sreekanth.Reddy@lsi.com> [SCSI] mpt2sas: Calulate the Reply post queue depth calculation as per the MPI spec

[jejb: checkpatch fixes]
Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
ca6832e91b5d851fca4ea8579915cd2b6c958117 01-Feb-2013 Sreekanth Reddy <Sreekanth.Reddy@lsi.com> [SCSI] mpt2sas: Update the timing requirements for issuing a Hard Reset

Updated the mpt2sas driver code that issues hard reset to comply with the
timing requirements mentioned in MPI specifications rev V.

[jejb: checpatch fixes]
Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
b0df96a0068daee4f9c2189c29b9053eb6e46b17 26-Feb-2013 Reddy, Sreekanth <Sreekanth.Reddy@lsi.com> [SCSI] mpt2sas: Fix for issue Missing delay not getting set during system bootup

Missing delay is not getting set properly. The reason is that it is not
defined in the same file from where it is being invoked. The fix is to move
the missing delay module parameter from mpt2sas_base.c to mpt2sas_scsh.c.

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@lsi.com>
Cc: stable@vger.kernel.org
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
7887ea7f942770c2146dbcdfa2a85aa8de93df31 01-Feb-2013 Sreekanth Reddy <Sreekanth.Reddy@lsi.com> [SCSI] mpt2sas: Add support for OEM specific controller

Defined SSDID & HW vendor brand strings. Added entries for SSDID within the
function that prints the brand string.

Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
b4730fb6e54a634a145c9c71c5cf856f00beb5cd 18-Dec-2012 Sreekanth Reddy <Sreekanth.Reddy@lsi.com> [SCSI] mpt2sas: fix for driver fails EEH, recovery from injected pci bus error

This patch stops the driver to invoke kthread (which remove the dead ioc)
for some time while EEH recovery has started.

[thenzl: add a 'non_operational_loop' reset.]
Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@lsi.com>
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
10cce6d8b5af0b32bc4254ae4a28423a74c0921c 22-Aug-2012 sreekanth.reddy@lsi.com <sreekanth.reddy@lsi.com> [SCSI] mpt2sas: Fix for issue - Unable to boot from the drive connected to HBA

This patch checks whether HBA is SAS2008 B0 controller.
if it is a SAS2008 B0 controller then it use IO-APIC interrupt instead of MSIX,
as SAS2008 B0 controller doesn't support MSIX interrupts.

[jejb: fix whitespace problems]
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@lsi.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
e17eee45102bfd28f357efa119c4ecaf7a17c155 17-Jul-2012 sreekanth.reddy@lsi.com <sreekanth.reddy@lsi.com> [SCSI] mpt2sas: To include more Intel Branding

Updating the customer branding string for "SSD 910 Series" controller

Signed-off-by: Sreekanth Reddy <sreekanth.reddy@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
433d71766c293a5c7ce1b411dae3fede9b549797 17-Jul-2012 sreekanth.reddy@lsi.com <sreekanth.reddy@lsi.com> [SCSI] mpt2sas: 2012 source code copyright

The Copyright String in all the drivers sources were changed to 2012

Signed-off-by: Sreekanth Reddy <sreekanth.reddy@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
338b131a3269881c7431234855c93c219b0979b6 17-Jul-2012 sreekanth.reddy@lsi.com <sreekanth.reddy@lsi.com> [SCSI] mpt2sas: Fix for Driver oops, when loading driver with max_queue_depth command line option to a very small value

If the specified max_queue_depth setting is less than the
expected number of internal commands, then driver will calculate
the queue depth size to a negitive number. This negitive number
is actually a very large number because variable is unsigned
16bit integer. So, the driver will ask for a very large amount of
memory for message frames and resulting into oops as memory
allocation routines will not able to handle such a large request.

So, in order to limit this kind of oops, The driver need to set
the max_queue_depth to a scsi mid layer's can_queue value. Then
the overall message frames required for IO is minimum of either
(max_queue_depth plus internal commands) or the IOC global
credits.

Signed-off-by: Sreekanth Reddy <sreekanth.reddy@lsi.com>
Cc: <stable@kernel.org>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
a2c658505bf5c75516ee0a79287223e86a2474af 17-Apr-2012 nagalakshmi.nandigama@lsi.com <nagalakshmi.nandigama@lsi.com> [SCSI] mpt2sas: Fix unsafe using smp_processor_id() in preemptible

When CONFIG_DEBUG_PREEMPT is enabled, bug is observed in the smp_processor_id().
This is because smp_processor_id() is not called in preempt safe condition.

To fix this issue, use raw_smp_processor_id instead of smp_processor_id.

Signed-off-by: Nagalakshmi Nandigama <nagalakshmi.nandigama@lsi.com>
CC: stable@vger.kernel.org
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
e42fafc25fa86c61824e8d4c5e7582316415d24f 19-Mar-2012 nagalakshmi.nandigama@lsi.com <nagalakshmi.nandigama@lsi.com> [SCSI] mpt2sas: Fix for panic happening because of improper memory allocation

The ioc->pfacts member in the IOC structure is getting set to zero
following a call to _base_get_ioc_facts due to the memset in that routine.
So if the ioc->pfacts was read after a host reset, there would be a NULL
pointer dereference. The routine _base_get_ioc_facts is called from context
of host reset. The problem in _base_get_ioc_facts is the size of
Mpi2IOCFactsReply is 64, whereas the sizeof "struct mpt2sas_facts" is 60,
so there is a four byte overflow resulting from the memset.

Also, there is memset in _base_get_port_facts using the incorrect structure,
it should be "struct mpt2sas_port_facts" instead of Mpi2PortFactsReply.

Signed-off-by: Nagalakshmi Nandigama <nagalakshmi.nandigama@lsi.com>
CC: stable@vger.kernel.org
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
d838c36cb7d9642b9b42dd18c511ba28c592b694 19-Mar-2012 nagalakshmi.nandigama@lsi.com <nagalakshmi.nandigama@lsi.com> [SCSI] mpt2sas: Fix linux driver sparse errors

Fix several endian issues found by runing sparse.

Signed-off-by: Nagalakshmi Nandigama <nagalakshmi.nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
298c794def0631763ec861e641a448c7decf73bb 19-Mar-2012 nagalakshmi.nandigama@lsi.com <nagalakshmi.nandigama@lsi.com> [SCSI] mpt2sas: Fix security scan issues reported by source code analysis tool

Modified the source code as per the findings reported by the source
code analysis tool. Source code for the following functionalities
has been touched. None of the driver functionalities has changed.

- SMP Passthrough IOCTL
- Debug messages for MPT Replies (i.e. bit 9 of Logging Level)
- Task Management using sysfs
- Device removal, i.e. when a target device (including any PD within a volume)
is removed, and Volume Deletion.
- Trace Buffer

Signed-off-by: Nagalakshmi Nandigama <nagalakshmi.nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
09da0b32d078a3b94aa6d948d053b84755712a2b 19-Mar-2012 nagalakshmi.nandigama@lsi.com <nagalakshmi.nandigama@lsi.com> [SCSI] mpt2sas: Improvement were made to better protect the sas_device, raid_device, and expander_device lists

There were possible race conditions surrounding reading an object
from the link list while from another context in the driver was
removing it. The nature of this enhancement is to rearrange locking
so the link lists are better protected.

Change set:
(1) numerous routines were rearranged so spin locks are held through
the entire time a link list object is being read from or written to.
(2) added new routines for object deletion from link list. Thus ensuring
lock was held during the deletion of the link list object, then and memory
for object freed outside the lock. The memory was freed outside the lock
so driver had access to device object info which was required for
notifying the scsi mid layer that a device was getting deleted.
(3) added the ioc->blocking_handles parameter. This is a bitmask used
to identify which devices need blocking when there is device loss. This was
introduced so that lock can be held for the entire time traversing the link
list objects, and the bitmask was set to indicate which device handles need
blocking. Oustide the lock the ioc->blocking_handles bitmask is traversed,
with the respective device handle the scsi mid layer is called for moving
devices into blocking state.

Signed-off-by: Nagalakshmi Nandigama <nagalakshmi.nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
7d7311c44567cd2001ca318e4de64b753d9d35f8 14-Mar-2012 Sergei Shtylyov <sshtylyov@ru.mvista.com> [SCSI] atp870u, mpt2sas, qla4xxx use pci_dev->revision

commit 44c10138fd4bbc4b6d6bff0873c24902f2a9da65 (PCI: Change all
drivers to use pci_device->revision) converted all drivers to use
pci_dev->revision. Convert these three drivers which got missed.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
714be35885093305b7491cc3eea959bb3e1be6f2 13-Mar-2012 Sathisha Nanjappa <sathisha.nanjappa@hp.com> [SCSI] mpt2sas: remove extraneous sas_log_info messages

This fix ensures that the IOP_LOGINFO_CODE_TASK_TERMINATED
messages do not clutter the sas_log_info messages.

Bugzilla 42142 - mpt2sas: Number specified in wrong base
https://bugzilla.kernel.org/show_bug.cgi?id=42142

Signed-off-by: Sathisha Nanjappa <sathisha.nanjappa@hp.com>
Acked-by: "Nandigama, Nagalakshmi" <Nagalakshmi.Nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
210647af897af8ef2d00828aa2a6b1b42206aae6 25-Feb-2012 Yinghai Lu <yinghai@kernel.org> PCI: Rename pci_remove_bus_device to pci_stop_and_remove_bus_device

The old pci_remove_bus_device actually did stop and remove.

Make the name reflect that to reduce confusion.

This patch is done by sed scripts and changes back some incorrect
__pci_remove_bus_device changes.

Suggested-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
c834b1c4ec8ccc9c2d814bd78264b509708fe6dd 13-Feb-2012 Tomas Henzl <thenzl@redhat.com> [SCSI] mpt2sas: add missing allocation check

The __get_free_pages can fail, so the return value should be checked.
Spotted thanks to Stanislaw.

Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Acked-by: "Nandigama, Nagalakshmi" <Nagalakshmi.Nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
7fbd764881a5f9dc81a378293b7a74227fcc04ed 25-Aug-2011 Alexey Khoroshilov <khoroshilov@ispras.ru> [SCSI] mpt2sas: Fix mismatch in mpt2sas_base_hard_reset_handler() mutex lock-unlock

If ioc->pci_error_recovery is set, goto out in mpt2sas_base_hard_reset_handler()
leads to unlock unheld ioc->reset_in_progress_mutex.

The patch fixes the issue by jumping afer mutex_unlock() call.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Acked-by: "Nandigama, Nagalakshmi" <Nagalakshmi.Nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2cb6fc8c014b9b00c4487a79b8f6ed0da4121f45 13-Dec-2011 nagalakshmi.nandigama@lsi.com <nagalakshmi.nandigama@lsi.com> [SCSI] mpt2sas: Removed redundant calling of _scsih_probe_devices() from _scsih_probe

Removed redundant calling of _scsih_probe_devices() from _scsih_probe as
it is getting called from _scsih_scan_finished.

Also moved the function scsi_scan_host(shost) to get called after the
volumes on warp drive are reported to the OS. Otherwise by the time
the (ioc->hide_drives) flags is set, the volumes on warp drive
are reported to the OS already.

Also modified the initialization of reply queues only in case of driver load
time in the function _base_make_ioc_operational().

Signed-off-by: Nagalakshmi Nandigama <nagalakshmi.nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
ef8c98543c3ad75240599d4032f7e56b793740a9 30-Nov-2011 Roland Dreier <roland@purestorage.com> [SCSI] mpt2sas: Remove unused duplicate diag_buffer_enable param

Commit 921cd8024b90 ("[SCSI] mpt2sas: New feature - Fast Load
Support") moved handling of the diag_buffer_enable module parameter
from mpt2sas_base.c to mpt2sas_scsih.c, but it left an old copy of the
parameter in mpt2sas_base.c. Remove the unused stub.

Signed-off-by: Roland Dreier <roland@purestorage.com>
Acked-by: "Nandigama, Nagalakshmi" <Nagalakshmi.Nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2f73b9a896634dd0ce68b5af9ae5f475e24ce51e 01-Dec-2011 Roland Dreier <roland@purestorage.com> [SCSI] mpt2sas: Fix possible integer truncation of cpu_count

When computing reply_queue_count (the number of MSI-X vectors to use),
the driver does

ioc->reply_queue_count = min_t(u8, ioc->cpu_count,
ioc->msix_vector_count);

However, on a big machine, ioc->cpu_count could be outside the range
that fits in a u8; eg a system with 256 CPUs will end up
reply_queue_count set to 0.

Fix this by calculating the minimum as ints and then letting the
assignment to reply_queue_count handle integer demotion.

Signed-off-by: Roland Dreier <roland@purestorage.com>
Acked-by: "Nandigama, Nagalakshmi" <Nagalakshmi.Nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
c24a1710d18d706ee2bbd87390868242f1a6d8d5 01-Dec-2011 Roland Dreier <roland@purestorage.com> [SCSI] mpt2sas: Fix leak on mpt2sas_base_attach() error path

Commit 911ae9434f83 ("[SCSI] mpt2sas: Added NUNA IO support in driver
which uses multi-reply queue support of the HBA") added new
allocations to the beginning of mpt2sas_base_attach(), which means
directly returning an error on failure of mpt2sas_base_map_resources()
will leak those allocations.

Fix this by doing "goto out_free_resources" in this place too, as the
rest of the function does.

Signed-off-by: Roland Dreier <roland@purestorage.com>
Acked-by: "Nandigama, Nagalakshmi" <Nagalakshmi.Nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
aff132d95ffe14eca96cab90597cdd010b457af7 01-Dec-2011 nagalakshmi.nandigama@lsi.com <nagalakshmi.nandigama@lsi.com> [SCSI] mpt2sas : Fix for memory allocation error for large host credits

The amount of memory required for tracking chain buffers is rather
large, and when the host credit count is big, memory allocation
failure occurs inside __get_free_pages.

The fix is to limit the number of chains to 100,000. In addition,
the number of host credits is limited to 30,000 IOs. However this
limitation can be overridden this using the command line option
max_queue_depth. The algorithm for calculating the
reply_post_queue_depth is changed so that it is equal to
(reply_free_queue_depth + 16), previously it was (reply_free_queue_depth * 2).

Signed-off-by: Nagalakshmi Nandigama <nagalakshmi.nandigama@lsi.com>
Cc: stable@kernel.org
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
8bad3055e902a16b7cf47777fc3e78a965d0b57a 01-Dec-2011 nagalakshmi.nandigama@lsi.com <nagalakshmi.nandigama@lsi.com> [SCSI] mpt2sas: Added support for customer specific branding

Signed-off-by: Nagalakshmi Nandigama <nagalakshmi.nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
f01690d31d905d46aaf2df8021a33231a71cd744 01-Dec-2011 nagalakshmi.nandigama@lsi.com <nagalakshmi.nandigama@lsi.com> [SCSI] mpt2sas: Rearrange the the code so that the completion queues are initialized prior to sending the request to controller firmware

Signed-off-by: Nagalakshmi Nandigama <nagalakshmi.nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
70e73f9945f80a5ad469d4d21b32209218aa51ac 01-Dec-2011 nagalakshmi.nandigama@lsi.com <nagalakshmi.nandigama@lsi.com> [SCSI] mpt2sas: Adding support for customer specific branding

Signed-off-by: Nagalakshmi Nandigama <nagalakshmi.nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
845a0e40afb77bebdbda353b44ebf48784aa51f4 01-Dec-2011 nagalakshmi.nandigama@lsi.com <nagalakshmi.nandigama@lsi.com> [SCSI] mpt2sas: Better handling DEAD IOC (PCI-E LInk down) error condition

Detection of Dead IOC has been done in fault_reset_work thread.

If IOC Doorbell is 0xFFFFFFFF, it will be detected as non-operation/DEAD IOC.
When a DEAD IOC is detected, the code is modified to remove that IOC and
all its attached devices from OS.
The PCI layer API pci_remove_bus_device() is called to remove the dead IOC.

Signed-off-by: Nagalakshmi Nandigama <nagalakshmi.nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
921cd8024b908f8f49f772c8d3a02381b4db2ed2 19-Oct-2011 nagalakshmi.nandigama@lsi.com <nagalakshmi.nandigama@lsi.com> [SCSI] mpt2sas: New feature - Fast Load Support

New feature Fast Load Support.

(1)Asynchronous SCSI scanning: This will allow the drivers to scan
for devices in parallel while other device drivers are loading at
the same time. This will improve the amount of time it takes for the
OS to load.

(2) Reporting Devices while port enable is active: This feature will
allow devices to be reported to OS immediately while port enable is
active. The previous implementation waits for port enable to complete,
and then report devices. This feature is only enabled on IT firmware
configurations when there are no boot device configured in BIOS Configuration
Utility, else the driver will wait till port enable completes reporting
devices. For IR firmware, this feature is turned off. This feature is to
address large SAS topologies (>100 drives) when the boot OS is using onboard
SATA device, in other words, the boot devices is not
connected to our controller.

(3) Scanning for devices after diagnostic reset completes: A new routine
_scsih_scan_start is added. This will scan the expander pages, IR pages,
and sas device pages, then reporting new devices to SCSI Mid layer. It
seems the driver is not supporting adding devices while diagnostic reset
is active. Apparently this is due to the sanity checks on
ioc->shost_recovery flag throughout the context of kernel work thread FIFO,
and the mpt2sas_fw_work.

Signed-off-by: Nagalakshmi Nandigama <nagalakshmi.nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
911ae9434f83e7355d343f6c2be3ef5b00ea7aed 08-Sep-2011 nagalakshmi.nandigama@lsi.com <nagalakshmi.nandigama@lsi.com> [SCSI] mpt2sas: Added NUNA IO support in driver which uses multi-reply queue support of the HBA

Support added for controllers capable of multi reply queues.

The following are the modifications to the driver to support NUMA.

1) Create the new structure adapter_reply_queue to contain the reply queue
info for every msix vector. This object will contain a
reply_post_host_index, reply_post_free for each instance, msix_index, among
other parameters. We will track all the reply queues on a link list called
ioc->reply_queue_list. Each reply queue is aligned with each IRQ, and is
passed to the interrupt via the bus_id parameter.

(2) The driver will figure out the msix_vector_count from the PCIe MSIX
capabilities register instead of the IOC Facts->MaxMSIxVectors. This is
because the firmware is not filling in this field until the driver has
already registered MSIX support.

(3) If the ioc_facts reports that the controller is MSIX compatible in the
capabilities, then the driver will request for multiple irqs. This count
is calculated based on the minimum between the online cpus available and
the ioc->msix_vector_count. This count is reported to firmware in the
ioc_init request.

(4) New routines were added _base_free_irq and _base_request_irq, so
registering and freeing msix vectors were done thru simple function API.

(5) The new routine _base_assign_reply_queues was added to align the msix
indexes across cpus. This will initialize the array called
ioc->cpu_msix_table. This array is looked up on every MPI request so the
MSIxIndex is set appropriately.

(6) A new shost sysfs attribute was added to report the reply_queue_count.

(7) User needs to set the affinity cpu mask, so the interrupts occur on the
same cpu that sent the original request.

Signed-off-by: Nagalakshmi Nandigama <nagalakshmi.nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
101ae14edc14efb0fe6ed8a77ed370cca670ffc8 01-Aug-2011 Jesper Juhl <jj@chaosbits.net> Remove unneeded version.h includes from drivers/scsi/

It was pointed out by 'make versioncheck' that some includes of
linux/version.h are not needed in drivers/scsi/.
This patch removes them.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
ab3e5f60d1fc8fe725d02510ff820ff207a8dbef 14-Jun-2011 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Adding support for customer specific branding

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
c97951ec46d4b076c2236b77db34eeed6dddb8eb 14-Jun-2011 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Fixed Big Indian Issues on 32 bit PPC

This patch addresses many endian issues solved by runing sparse with the
option __CHECK_ENDIAN__ turned on.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
0bdccdb0a090ad8dc5f851cad5e843244c410ee8 06-Apr-2011 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas : WarpDrive New product SSS6200 support added

This patch has Support for the new solid state device product SSS6200
from LSI and relavent features w.r.t SSS6200.

The major feature added in this driver is supporting Direct-I/O to the
SSS6200 storage.There are some additional changes done to avoid exposing
the RAID member disks to the OS and hiding/exposing drives based on the
OEM Specific Flag in Manufacturing Page10 (this is required to handle
specific changes in the SSS6200 firmware).

Each and every changes are listed below.
1. Hiding IR related messages.
For SSS6200, the driver is modified not to print IR related events.
Even if the debugging is enabled the IR related messages will not be displayed.
In some places if there is a need to display a message related to IR the
string "IR" is replaced with string "DD" and the string "volume" is replaced
with "direct drive". But the function names are not changed hence there are
some places where the reference to volume can be seen if debug level is set.

2. Removed RAID transport support
In Linux the user can retrieve RAID volume information from the sysfs directory.
This support is removed for SSS6200.

3. Direct I/O support.
The driver tries to enable direct I/O when a volume is reported to the driver
by the firmware through IRCC events and the driver does this just before
reporting to the OS, hence all the OS issued I/O can go through direct path
if they can, The first validation is to see whether the manufacturing page10
flag is set to expose all drives always. If that is set, the driver will not
enable direct I/O and displays the message "DDIO" is disabled globally as
drives are exposed. The driver checks whether there is more than one volume
in the controller, if so the direct I/O will be disabled globally for all
volumes in the controller and the message displayed will be "DDIO is disabled
globally as number of drives > 1.
If retrieving number of PD is failed the driver will not enable direct I/O
and displays the message Failure in computing number of drives DDIO disabled.
If memory allocation for RAIDVolumePage0 is failed, the driver will not enable
direct I/O and displays the message Memory allocation failure for
RVPG0 DDIO disabled. If retrieving RAIDVolumePage0 is failed the driver will
not enable direct I/O and displays the message Failure in retrieving
RVPG0 DDIO disabled

If the number of PD in a volume is greater than 8, then the direct I/O will
be disabled.
If any of individual drives handle retrieval is failed then the DD-IO will
be disabled.
If the volume is not RAID0 or if the block size is not 512 then the DD-IO will
be disabled.
If the volume size is greater than 2TB then the DD-IO will be disabled.
If the driver is not able to find a valid stripe exponent using the configured
stripe size then the DD-IO will be disabled

When the DD-IO is enabled the driver will check every I/O request issued to
the storage and checks whether the request is either
READ6/WRITE6/READ10/WRITE10, if it is and if the complete I/O transfer
is within a stripe size then the I/O is redirected to
the drive directly instead of the volume.

On completion of every I/O, if the completion is failure means if the reply
is address reply with a reply frame associated with it, then the type of I/O
will be checked, if the I/O is direct then the I/O will be retried to
the volume once.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Reviewed-by: Eric Moore <eric.moore@lsi.com>
Reviewed-by: Sathya Prakash <sathya.prakash@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
25985edcedea6396277003854657b5f3cb31a628 31-Mar-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Fix common misspellings

Fixes generated by 'codespell' and manually reviewed.

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
0a2385cea9a715e11df10fce1f1442d933008a40 15-Mar-2011 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas : Added customer specific display support

Added Vendor specific branding message support.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
d5bd3491c8c30b98f642cab4361ff1a43955ccd4 04-Jan-2011 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Basic Code Cleanup in mpt2sas_base

Basic Code Cleanup:
(1) _base_get_cb_idx and mpt2sas_base_free_smid were reorganized in
similar fashion so the order of obtaining the cbx and smid are
scsiio,
hi_priority, and internal.
(2) The hi_priority and internal request queue struct was made
smaller
by removing the scmd and chain_tracker, thus saving memory
allocation.
(3) For scsiio request, a new structure was created having the same
elements from the former request tracker struct.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
fb396bec76187aae1a0eaf5b7f21327b8cb34fec 04-Jan-2011 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Add support for Customer specific branding messages

Add support for Customer specific branding messages when device driver loads,
based on specific customer subsystem vendor and device Ids

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
4224489f45b503f0a1f1cf310f76dc108f45689a 04-Jan-2011 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Kernel Panic during Large Topology discovery

There was a configuration page timing out during the initial port
enable at driver load time. The port enable would fail, and this would
result in the driver unloading itself, meanwhile the driver was accessing
freed memory in another context resulting in the panic. The fix is to
prevent access to freed memory once the driver had issued the diag reset
which woke up the sleeping port enable process. The routine
_base_reset_handler was reorganized so the last sleeping process woken up was
the port_enable.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Cc: stable@kernel.org
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
11e1b961ab067ee3acaf723531da4d3f23e1d6f7 04-Jan-2011 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Correct resizing calculation for max_queue_depth

The ioc->hba_queue_depth is not properly resized when the controller
firmware reports that it supports more outstanding IO than what can be fit
inside the reply descriptor pool depth. This is reproduced by setting the
controller global credits larger than 30,000. The bug results in an
incorrect sizing of the queues. The fix is to resize the queue_size by
dividing queue_diff by two.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Cc: stable@kernel.org
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
90d2a672250b9d6e5c700f2d2c07c19d6fad064a 13-Nov-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Remove code for TASK_SET_FULL from driver.

remove support for MPI2_EVENT_TASK_SET_FULL
This event is obsoleted, so this processing of this event
needs to be removed from the driver. The controller firmware is going
to handle TASK_SET_FULL, the driver doesn't need to do anything.
Even though we are removing the EVENT handling, the behavour has not
changed between driver versions becuase fimrware will still be handling
queue throttling, and retrying of commands when the target device queues
are full.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
35f805b52c94f8e6cb22907ef32517132a15cb96 13-Nov-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Create a pool of chain buffer instead of dedicated per IOs

Create a pool of chain buffers, instead of dedicated per IO:
This enahancment is to address memory allocation failure when asking
for more than 2300 IOs per host. There is just not enough contiquious
DMA physical memory to make one single allocation to hold both message
frames and chain buffers when asking for more than 2300 request. In order
to address this problem we will have to allocate memory for each chain
buffer in a seperate individual memory allocation, placing each chain
element of 128 bytes onto a pool of available chains, which can be
shared amoung all request.
Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
6cb8ef573fd4c2bd72248f492fe336133660148d 13-Nov-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Added loadtime para for IOMissingDelay and DMD

Ability to override/set the ReportDeviceMissingDelay and
IODeviceMissingDelay from driver: Add new command line option missing_delay,
this is an array, where the first element is the device missing delay,
and the second element is io missing delay. The driver will program
sas iounit page 1 with the new setting when the driver loads. This is
programmed to the current and persistent configuration page so this takes
immediately, as will be sticky across host reboots.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
dd3741d30300f9cf1adc046773a4bb87252d96ac 13-Nov-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Added sanity check for cb_idx and smid access.

Sometime it is seen that controller
firmware returns an invalid system message id (smid).

the oops is occurring becuase mpt_callbacks pointer is referenced to
either null or invalid virtual address. this is due to cb_idx set
incorrectly from routine _base_get_cb_idx. the cb_idx was set incorrectly
becuase there is no check to make sure smid is less than maxiumum
anticapted smid. to fix this issue, we add a check in
_base_get_cb_idx to make sure smid is not greater than
ioc->hba_queue_depth. in addition, a similar check was added to make
sure the reply address was less than the largest anticapated address.

Newer firmware has sovled this issue, however it good to have this sanity
check.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
7968f1944c9d6c83683e87fd2ede977ccfd29285 05-Aug-2010 Julia Lawall <julia@diku.dk> [SCSI] drivers/scsi: Adjust confusing if indentation

Outdent the code following the if.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r disable braces4@
position p1,p2;
statement S1,S2;
@@

(
if (...) { ... }
|
if (...) S1@p1 S2@p2
)

@script:python@
p1 << r.p1;
p2 << r.p2;
@@

if (p1[0].column == p2[0].column):
cocci.print_main("branch",p1)
cocci.print_secs("after",p2)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Nick Cheng <nick.cheng@areca.com.tw>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
3cb5469a2ab4b87a7c63dd218fdc1625bc73eccc 08-Jul-2010 Eric Moore <eric.moore@lsi.com> [SCSI] mpt2sas: driver fails to recover from injected PCIe bus errors

fixes surrounding PCIe enhanced error handling:

(1) We need to reject all request generated internaly inside the driver as well
as request arriving from the scsi mid layer when PCIe EEH is active. The fix is
to add a per adapter flag called pci_error_recovery which is checked thru out
the driver when request are generated.

(2) We don't need to call the pci_driver->remove directly from the PCIe
callbacks becuase its already called from the PCIe EEH code. In its place we are
shutting down the watchdog timer, and flushing back all pending IO.

(3) We need to save and restore the pci state across PCIe EEH handling.

Signed-off-by: Eric Moore <eric.moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
769578ff811e43ccddd96b15640fa7c9df65c374 17-Jun-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Copy sense buffer instead of working on direct memory location

(1) driver was not setting the sense data size prior to sending SCSI_IO,
resulting in the 0x31190000 loginfo
(2) The driver needs to copy the sense data to local buffer prior
to releasing the request message frame. If not, the sense buffer gets
overwritten by the next SCSI_IO request.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
3e2e833a547cbd0cb3fbe85a5f6ee71a93931fde 17-Jun-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Added -ENOMEM return type when allocation fails

In the driver mpt2sas_base_attach subroutine, we need to add
support to return the proper error code when there are memory allocation
failures, e.g. returning -ENOMEM.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
f3eedd698ebafd0fe8a292672604a2db61c2c00a 17-Jun-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Redesign Raid devices event handling using pd_handles per HBA

Actual problem :
Driver may receiving the top level expander
removal event prior to all the individual PD removal events, hence the
driver is breaking down all the PDs in advanced to the actaul PD UNHIDE
event. Driver sends multiple
Target Resets to the same volume handle for each individual PD removal.

FIX DESCRIPTION:
To fix this issue, the entire PD device handshake protocal has to be
moved to interrupt context so the breakdown occurs immediately after the
actual UNHIDE event arrives. The driver will only issue one Target Reset to
the volume handle, occurring after the FAILED or MISSING volume status
event arrives from interrupt context. For the PD UNHIDE event, the driver
will issue target resets to the PD handles, followed by OP_REMOVE. The
driver will set the "deteleted" flag during interrupt context. A "pd_handle"
bitmask was introduced so the driver has a list of known pds during entire
life of the PD; this replaces the "hidden_raid_component" flag handle in
the sas_device object. Each bit in the bitmask represents a device handle.
The bit in the bitmask would be toggled ON/OFF when the HIDE/UNHIDE
events arrive; also this pd_handle bitmask would bould be refreshed
across host resets.

Here we kept older behavior of sending target reset to volume when there is
a single drive pull, wait for the reply, then send target resets
to the PDs. We kept this behavior so the driver will
behave the same for older versions of firmware.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
eabb08ad2d3b0257cd2c9aed4f106fb39d14604a 17-Jun-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: print level KERN_DEBUG is replaced by KERN_INFO

Converting print level from MPT2SAS_DEBUG_FMT to MPT2SAS_INFO_FMT.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
570c67ac443dab5c46e5744e950f0539724cb65d 17-Jun-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Added sysfs support for trace buffer

Added support so the diag ring buffer can be pulled via sysfs
Added three new shost attributes: host_trace_buffer,
host_trace_buffer_enable, and host_trace_buffer_size. The
host_trace_buffer_enable attribute is used to either post or release
the trace buffers. The host_trace_buffer_size attribute contains
the size of the trace buffer. The host_trace_buffer atttribute contains
a maximum 4KB window of the buffer. In order to read the entire host buffer,
you will need to write the offset to host_trace_buffer prior to reading
it. release the host buffer, then write the entire host buffer contents to
a file.
In addition to this enhancement, we moved the automatic posting of host buffers
at driver load time to be called prior to port_enable, instead of after.
That way discovery is available in the host buffer.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
d32a8c15e1116e87f0105356eca1afb99842ab49 17-Jun-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Added sysfs counter for ioc reset

Added a new sysfs shost attribute called ioc_reset_count. This will
keep count of host resets (both diagnostic and message unit).

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
dd5fd3323abcb799d4d81f3c4b3e2a5fcbfce7bf 17-Jun-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: staged device discovery. disable_discovery module parameter is added.

Added command line option called disable_discovery. When enabled
on the command line, the driver will not send a port_enable when loaded
for the first time. If port_enable is not called, then there is
no discovery of devices, as well as the sas topology. Then later if one
desires to invoke discovery, then they will need to issue a diagnostic reset.
A diagnostic reset can be issued various ways. One of the way is throught
sysfs.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
d274213a1ae59e8abde8d43e1e3a478fe9f28794 17-Jun-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Hold Controller reset when another reset is in progress

Driver should not allow multiple host reset when already host reset is in
progress. It is possible that host reset was sent by scsi mid layer while there was already an host reset active,
either issued via IOCTL interface or internaly, like a config page timeout.
Since there was a host reset active, the driver would return a FAILED response
to the scsi mid layer. The solution is make sure pending host resets will
wait for the active host reset to complete before returning control
back up the call stack.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
4be929be34f9bdeffa40d815d32d7d60d2c7f03b 24-May-2010 Alexey Dobriyan <adobriyan@gmail.com> kernel-wide: replace USHORT_MAX, SHORT_MAX and SHORT_MIN with USHRT_MAX, SHRT_MAX and SHRT_MIN

- C99 knows about USHRT_MAX/SHRT_MAX/SHRT_MIN, not
USHORT_MAX/SHORT_MAX/SHORT_MIN.

- Make SHRT_MIN of type s16, not int, for consistency.

[akpm@linux-foundation.org: fix drivers/dma/timb_dma.c]
[akpm@linux-foundation.org: fix security/keys/keyring.c]
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Acked-by: WANG Cong <xiyou.wangcong@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
66a679365780a8d775b1ed03e2576007f7100121 05-Apr-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Check for NULL pointer before free_pages is added.

Added check before free_pages just to make sure ioc->scsi_lookup is not NULL.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
ef7c80c1f18f2c5eea2dabd214f12e0c93ac29cf 05-Apr-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Added support for PCIe Advanced Error Recovery.

Added support in the driver to support EEH and
PCIe Advanced Error Recovery. This involves adding new
pci_error_handler interface for recovering the controller from PCI Bus
errors, such as SERR and PERR. Some tools are available for simulating
PCI errors in order to validate this interface:
http://www.kernel.org/pub/linux/utils/pci/aer-inject

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
31b7f2e25d4b30d9b8701a6820c8e521cf409c29 17-Mar-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Copyright 2010.

Copyright changes for year 2010.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
f6aee7b9aee96ef18354f0f86e65ec635ee5039f 17-Mar-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: return -ENOMEM if memory allocation failed.

Added proper return type values in case memory allocation failed.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
e94f67472106e5a0e97c79090211c551e69e889b 17-Mar-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Fix for little endian

1. Fixes for little endian issues.
2. Now Debug info for Discovery event is more readable.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
6558bbb1457d2f33e233f9ed7bcf17fe96b93878 17-Mar-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Early return from function if shost is in recovery.

Aded checks for shost_recovery flag for early return from function.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
89009fbb7d2df37536c8dc932fdead4189783f92 17-Mar-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Use of get_free_pages for huge memorary allocation.

use the get_free_pages API for larger contigious physical memory chunk.
Also, the ioc->chain_depth need to be changed from
a 16bit to 32bit variable because the number of chains will exceed 64k
when the queue depth is large.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
7921b35c5fcf300ebd860e3e7894c692c9547838 17-Mar-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Corrected time stamp

incorrect timestamp on 32 bit platforms: The upper 32 bit of
the timestamp was getting truncated when converting seconds to
milliseconds, which was due to the variable being long. To fix the problem,
the variable needs to be u64. Also the microseconds conversion to
milliseconds was incorrect; it should be divide by 1000 instead of divide by
8.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
fc193172e63af2c749e198816a1ee694dd6395e6 13-Mar-2010 Richard A Lary <rlary@linux.vnet.ibm.com> [SCSI] mpt2sas: use correct pci_resource_flag for comparison

This patch replaces incorrect base address space flag with correct IO
resource flag. Also, performs check of memory resource to validate
resource before using.

Signed-off-by: Richard A Lary <rlary@linux.vnet.ibm.com>
Acked-by: "Desai, Kashyap" <Kashyap.Desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
f1c35e6aea579d5bdb6dc02dfa99c67c7c3b3f67 09-Mar-2010 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: RESCAN Barrier work is added in case of HBA reset.

Add the cancel_pending_work flag from the fw_event_work structure, and then to
set the flag during host reset, check the flag later from work threads
context and if cancel_pending_work_flag is set ingore those events.

Now Rescan after host reset is changed.
Added special task MPT2SAS_RESCAN_AFTER_HOST_RESET. This task will be queued
at the time of HBA reset. this task is treated as barrier. All work after
MPT2SAS_RESCAN_AFTER_HOST_RESET will be treated as new work and will be
server by callback handle. If host_recovery is going on while running RESCAN
task, it will wait for shos_recovery_done completion which will be called
from HBA reset DONE context.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Reviewed-by: Eric Moore <eric.moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
e75b9b6d9d81e35aed5ef2692285c4948e173c5c 16-Dec-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Set ioc->fwfault_debug to the cmd line option mpt2sas_fwfault_debug.

(1) change the formentioned string from logging_level to fwfault_debug
(2) set ioc->fwfault_debug to the command line option mpt2sas_fwfault_debug
setting at driver load time.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Reviewed-by: Eric Moore <eric.moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
6846e75cdfa76c6609ac0381a6739c9f4af8fd3b 16-Dec-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: User resource_size_t instead of unsigned long

Use resource_size_t to define the type resource for the system interface
register set.
The existing implementation was using "unsigned long" which would be 32 bit
in 32 bit OS. If 32 bit OS is using 64 bit physical
address space for the system interface register set, we need to shift to
using resource_size_t which takes care of physical address space.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Reviewed-by: Eric Moore <eric.moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
d685c262083dcd5fd98b7499b22a377a3225229c 17-Nov-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: add missing initialization of scsih_cmds

Internal command scsih_cmds init is included in mpt2sas_base_attach.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
463217bfecbf5d17a30133a55553d94aa9fc255e 05-Oct-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas : PPC (power pc) endian bug fix's

(1) EEDP(End to End data protection) was not working. This was due to not
setting EEDP BlockSize and Flags to little endian format in the message
frame.
(2) Some expander sysfs attributes were not getting set properly. The sas
format was not getting set due to endian issues with sas_format field in the
struct rep_manu_reply. Since sas_format was not set properly, the
component_vendor_id, component_revision_id, and component_id were not set.
(3) In _transport_smp_handler: we don't need to convert the smid from little
endian to cpu prior to calling mpt2sas_base_free_smid, because its allready
in cpu format. (4) Some loginfos and ioc status were not xonverted from
little endian to cpu.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: Eric Moore <Eric.moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
ec9472c74c3074541ea8389517f406b5c7ad0632 23-Sep-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: mpt2sas_base_get_sense_buffer_dma should be returning little endian

cpu_to_le64 when calculating the physical dma address. This will properly
handle endianess on big endian systems. The return value of this function
was changed from dma_addr_t to __le64. Remove the typecasting of u32 when
setting the SenseBufferLowAddress, since its already in __le32 format.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: Eric Moore <Eric.moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
96b681c6ad3f2f5013c0ffc558969ee6ac8c450b 23-Sep-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Retrieve the ioc facts prior to putting the controller into READY state

The driver needs to retrieve the ioc facts prior to putting the controller
into READY state. The current design is calling ioc facts after putting the
controller into READY state, which means the driver is sending a diag reset
instead of message unit reset becuase the capability information is not yet
available.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: Eric Moore <Eric.moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
a8ebd76c49fa45d93a736ae0b0f192b554cc8c3f 23-Sep-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Added support to set the TimeStamp when sending ioc_init

Added support to set the TimeStamp when sending ioc_init.
Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: Eric Moore <Eric.moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
1b01fe3aa58b114b2dc296676023451c6434561e 23-Sep-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Add Extended Type for Diagnostic Buffer support

Added tests for registry entries of EXBuffSize, EXImmed, and EXType to
support the new Extended diag buffer type. Modified code where necessary to
handle the new ExtendedType field in the F/W diagnostic Post and Release
messages.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: Eric Moore <Eric.moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
32e0eb569df09a8cb790cf370ee498721d88e5c6 23-Sep-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Added command line option diag_buffer_enable.

Added command line option diag_buffer_enable. When the command line option is
set, the driver will automatically post diag buffers at driver load time.
The command line option diag_buffer_enable is bitwise, so it's possible to
enable both and/or snapshot + trace buffers. For trace, the driver will
allocate 1MB buffer, whereas for snapshot its 2MB. The purpose for this is
so the enduser doesn't have to manually use an application to setup diag
buffers for debugging firmware related issues.

Here is some examples
trace:
# insmod mpt2sas.ko diag_buffer_enable=1

snapshot:
# insmod mpt2sas.ko diag_buffer_enable=2

both trace and snapshot:
# insmod mpt2sas.ko diag_buffer_enable=3

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: Eric Moore <Eric.moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
cef7a12cd1e0647ce2b566a76bbf4cd132b9118d 23-Sep-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Fixed some of the comment

Fixed some of the comments sections for some of the function so "@ioc:
pointer to scsi command object" was changed to "@ioc: per adapter object"

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: Eric Moore <Eric.moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
fa7f31673583a6e0876f8bb420735cdd8a3ffa57 23-Sep-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Support for stopping driver when Firmware encounters

Added command line option and shost sysfs attribute called
mpt2sas_fwfault_debug. When enduser writes a "1" to this parameter, this
will enable support in the driver for debugging firmware timeout related
issues. This handling was added in three areas (a) scsi error handling
callback called task_abort, (b) IOCTL interface, and (c) other timeouts that
result in diag resets, such as manufacturing config pages. When this
support is enabled, the driver will provide dump_stack to console, halt
controller firmware, and panic driver. The end user probably would want to
setup serial console redirection so the dump stack can be seen.

Here are the three methods for enable this support:

(a) # insmod mpt2sas.ko mpt2sas_fwfault_debug=1
(b) # echo 1 > /sys/module/mpt2sas/parameters/mpt2sas_fwfault_debug
(c) # echo 1 > /sys/class/scsi_host/host#/fwfault_debug (where # is
the host number)

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: Eric Moore <Eric.moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
29786e19cda2117e12303df67546839591d2afa7 14-Sep-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Timeout occurred within the HANDSHAKE logic while waiting on firmware to ACK.

Following a diag_reset, a request to send an ioc_init is timing out. The
timeout occurred within the HANDSHAKE logic while waiting on firmware to
acknowledge that the driver had wrote to the doorbell register. This was
root caused to a logic timeout in the firmware code. The proposed solution
is for the driver to call the udelay instead of msleep API in function where
its looping reading the interrupt status. In addition to this change, there
were two additional cases where we deleted the clearing interrupt status
outside handshake context.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
bcfb6e6ea46d84bfb541069545e5b0d7f6cc3233 14-Sep-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Call init_completion on a per request basis.

Now driver call init_completion on a per request basis. At some
point the wait_for_completion_timeout is not waiting for the timeout,
instead returning immediately, thus going into diag reset. This fix will
address all request using the wait_for_completion_timeout API. The previous
implimentation was only calling init_completion at driver
load time.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
77e63ed44305e89c0564f8292f9cd5764d4fddfb 14-Sep-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Target Reset will be issued from Interrupt context.

(1) Added three new functions to handle sending target resest and OP_REMOVE
from interrupt time, they are _scsih_tm_tr_send, _scsih_tm_tr_complete, and
_scsih_sas_control_complete. This code will create a link list of pending
target resets if there is no more available request in the hipriority
request queue. The list is stored in ioc->delayed_tr_list.

(2) All callback handler return type is changed from void to u8.
Now _base_interrupt will check for return type of callback handlers to
take decision of message frame is already freed or not.
In genral,
Return 1 meaning mf should be freed from _base_interrupt
0 means the mf is freed from function.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
595bb0bd62edb28a965993d90e0fa1285560ce53 14-Sep-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Added SCSIIO, Internal and high priority memory pools to support multiple TM

1) create a pool of high priority message frames in the region of memory
between message frames and chains. The modifications are in
_base_allocate_memory_pools. Also create a seperate pool of memory for
internal commands located near the same region of memory. The pool of high
priority message frames is restriced by the facts->HighPriorityCredit.

2) Create additional API for accessing request message frames. New function
mpt2sas_base_get_smid_hpr is for highpriority request. New function
mpt2sas_base_get_smid_scsiio for SCSI_IO, passing in the scsi command
pointer. The mpt2sas_base_get_smid function is for requesting internal
commands.

3) Added new function _base_get_cb_idx to obtain the callback
index from one of the three pools of request message frames.

4) Removed wrapper functions _scsih_scsi_lookup_set and
_scsih_scsi_lookup_getclear. These were removed because this handling was
moved into mpt2sas_base_get_smid_scsiio and mpt2sas_base_free_smid.

5) The function mpt2sas_base_free_smid is modified so the request message
frames are put back on one of the three pools of request message frames.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
19d3ebe3d5c4d56c8309a64561d99e7920a35fbb 14-Sep-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Copyright change to 2009.

Update the copyright year to 2009 through out the code.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
7b936b02293b2891d899233d3f4bb45295e8c1f9 25-Sep-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Update driver to MPI2 REV K headers.

Drivers header are updated to the MPI2 REV K headers.
Renamed VF_ID to msix_index in all call back handlers.
VF_ID is removed from all request descriptor.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
5b768581ea722172f059ad5a5eebea9008961af0 20-Aug-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: cleanup interrupt routine and config_request optimization

Cleaned up base_interrupt routine to be more effiecent.

Deleted about a third of the config page API by moving redundant code from all
the calling functions to _config_request.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Reviewed-by: Eric Moore <Eric.moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
ed79f1280d1bc54f168abcffc8c3e0bf8ffb1873 20-Aug-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Raid 10 Volume is showing as Raid 1E in dmesg

This patch modifies the slave_configure callback so the messages that get sent
to system log for RAID1E volumes contain the string "RAID10" instead of
"RAID1E". These messages contain information regarding what kind of scsi device
is being added. Certain OEMS can enable displaying the RAID10 string instead of
RAID1E via manufacturing page 10. The driver will read this config page at
driver load time, then determine from the GenericFlags0 bits whether display
the RAID10 or RAID1E string, also even drive count is taken into consideration.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Reviewed-by: Eric Moore <Eric.moore@lsi.com>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
155dd4c763694222c125e65438d823f58ea653bc 20-Aug-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Prevent sending command to FW while Host Reset

This patch renames the flag for indicating host reset from
ioc_reset_in_progress to shost_recovery. It also removes the spin locks
surrounding the setting of this flag, which are unnecessary. Sanity checks on
the shost_recovery flag were added thru out the code so as to prevent sending
firmware commands during host reset. Also, the setting of the shost state to
SHOST_RECOVERY was removed to prevent deadlocks, this is actually better
handled by the shost_recovery flag.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Reviewed-by: Eric Moore <Eric.moore@lsi.com>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
cd4e12e8ad246ec5bc23ab04d0da0e6985025620 20-Aug-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas : Rescan topology from Interrupt context instead of work thread

Following host reset its possible that the controller firmware could
assign new handles for devices, as well as adding or deleting devices. There is
code in the driver that will rescan the topology folowing host reset; updating
device handles, and remove devices that are no longer responding. This patch
will improve the responsivness by moving this rescaning from the delayed hotplug
worker thread to immediately following the host reset.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Reviewed-by: Eric Moore <Eric.moore@lsi.com>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
fcfe6392d18283df3c561b5ef59c330d485ff8ca 07-Aug-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: fix oops because drv data points to NULL on resume from hibernate

Fix another ocurring when the system resumes. This oops was due to driver
setting the pci drvdata to NULL on the prior hibernation. Becuase it was
set to NULL, upon resmume we assume the pci drvdata is non-zero, and we oops.
To fix the ooops, we don't set pci drvdata to NULL at hibernation time.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
e4750c989f732555fca86dd73d488c79972362db 07-Aug-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: fix crash due to Watchdog is active while OS in standby mode

Fix oops ocurring at hibernation time. This oops was due to the firmware fault
watchdog timer still running after we freed resources. To fix the issue we need
to terminate the watchdog timer at hibernation time.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
be9e8cd75ce8d94ae4aab721fdcc337fa78a9090 07-Aug-2009 Kashyap, Desai <kashyap.desai@lsi.com> [SCSI] mpt2sas: Excessive log info causes sas iounit page time out

Inhibit 0x3117 loginfos - during cable pull, there are too many printks going
to the syslog, this is have impact on how fast the interrupt routine can handle
keeping up with command completions; this was the root cause to the config
pages timeouts.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
f0f9cc1fb8a21f3ff90900505fc82a43d29d0975 21-Apr-2009 Eric Moore <eric.moore@lsi.com> [SCSI] mpt2sas : Identify Dell series-7 adapters at driver load time

The Dell branding along with the VID, DID, SSVID, SSDID following the LSI
branding that contains the card firmware/chip/bios versions. If the SSDID
is not known but it is a Dell HBA, the driver will print the SSDID instead
of the Dell branding string. Nothing will be printed for non Dell HBAs

Signed-off-by: Eric Moore <eric.moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
03ea1115506c53b46cec2177deb189d186bb80dd 21-Apr-2009 Eric Moore <eric.moore@lsi.com> [SCSI] mpt2sas : the sanity check in base_interrupt needs to be on dword boundary

The poison sanity check on the reply_post_free register needs to be by 32bit,
not 64bit. The poison check is there because its possible that the driver read
the 1st 32bit before the 2nd 32bit has been written to by firmware. In other
words, this handles race between driver reading the 64 bit register, and it
being dma'd across pci memory from controller firmware as two 32bit pci writes.

Signed-off-by: Eric Moore <eric.moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
e930438c42e744ef1f8bfdbb338253c9f384df42 13-Apr-2009 Yang Hongyang <yanghy@cn.fujitsu.com> Replace all DMA_nBIT_MASK macro with DMA_BIT_MASK(n)

This is the second go through of the old DMA_nBIT_MASK macro,and there're not
so many of them left,so I put them into one patch.I hope this is the last round.
After this the definition of the old DMA_nBIT_MASK macro could be removed.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Tony Lindgren <tony@atomide.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Greg KH <greg@kroah.com>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
635374e7eb110e80d9918b8611198edd56a32975 09-Mar-2009 Eric Moore <eric.moore@lsi.com> [SCSI] mpt2sas v00.100.11.15

* This is new scsi lld device driver from LSI supporting the SAS 2.0
standard. I have split patchs by filename.

* Here is list of new 6gb host controllers:

LSI SAS2004
LSI SAS2008
LSI SAS2108
LSI SAS2116

* Here are the changes in the 4th posting of this patch set:

(1) fix compile errors when SCSI_MPT2SAS_LOGGING is not enabled
(2) add mpt2sas to the SCSI Mid Layer Makefile
(3) append mpt2sas_ to the naming of all non-static functions
(4) fix oops for SMP_PASSTHRU
(5) doorbell algorithm imported changes from windows driver

* Here are the changes in the 3rd posting of this patch set:

(1) add readl following writel from the function that disables interrupts
(2) replace 0xFFFFFFFFFFFFFFFFULL with ~0ULL
(3) when calling pci_enable_msix, only pass one msix entry (instead of 15).
(4) remove the "current HW implementation uses..... " comment in the sources
(5) merged bug fix for SIGIO/POLLIN notifcation; reported by the storlib team.

* Here are the changes in the 2nd posting of this patch set:

(1) use little endian types in the mpi headers
(2) merged in bug fix's from inhouse drivers.

Signed-off-by: Eric Moore <eric.moore@lsi.com>
Tested-by: peter Bogdanovic <pbog@us.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>