History log of /linux-master/drivers/scsi/aacraid/commsup.c
Revision Date Author Comments
# c5becf57 07-Dec-2023 Martin K. Petersen <martin.petersen@oracle.com>

Revert "scsi: aacraid: Reply queue mapping to CPUs based on IRQ affinity"

This reverts commit 9dc704dcc09eae7d21b5da0615eb2ed79278f63e.

Several reports have been made indicating that this commit caused
hangs. Numerous attempts at root causing and fixing the issue have
been unsuccessful so let's revert for now.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=217599
Cc: <stable@vger.kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 79519528 22-Aug-2023 Bart Van Assche <bvanassche@acm.org>

scsi: core: Improve type safety of scsi_rescan_device()

Most callers of scsi_rescan_device() have the scsi_device pointer readily
available. Pass a struct scsi_device pointer to scsi_rescan_device()
instead of a struct device pointer. This change prevents that a pointer to
another struct device would be passed accidentally to scsi_rescan_device().

Remove the scsi_rescan_device() declaration from the scsi_priv.h header
file since it duplicates the declaration in <scsi/scsi_host.h>.

Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Cc: Mike Christie <michael.christie@oracle.com>
Cc: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20230822153043.4046244-1-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 9dc704dc 19-May-2023 Sagar Biradar <sagar.biradar@microchip.com>

scsi: aacraid: Reply queue mapping to CPUs based on IRQ affinity

Fix the I/O hang that arises because of the MSIx vector not having a mapped
online CPU upon receiving completion.

SCSI cmds take the blk_mq route, which is setup during init. Reserved cmds
fetch the vector_no from mq_map after init is complete. Before init, they
have to use 0 - as per the norm.

Reviewed-by: Gilbert Wu <gilbert.wu@microchip.com>
Signed-off-by: Sagar Biradar <Sagar.Biradar@microchip.com>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Link: https://lore.kernel.org/r/20230519230834.27436-1-sagar.biradar@microchip.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 8779b4bd 09-Aug-2021 Bart Van Assche <bvanassche@acm.org>

scsi: aacraid: Use scsi_cmd_to_rq() instead of scsi_cmnd.request

Prepare for removal of the request pointer by using scsi_cmd_to_rq()
instead. This patch does not change any functionality.

Link: https://lore.kernel.org/r/20210809230355.8186-14-bvanassche@acm.org
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 53616df2 03-Mar-2021 Lee Jones <lee.jones@linaro.org>

scsi: aacraid: Repair formatting issue in aac_handle_sa_aif()'s header

Fixes the following W=1 kernel build warning(s):

drivers/scsi/aacraid/commsup.c:334: warning: expecting prototype for fib_deallocate(). Prototype was for fib_dealloc() instead
drivers/scsi/aacraid/commsup.c:1961: warning: expecting prototype for aac_handle_sa_aif Handle a message from the firmware(). Prototype was for aac_handle_sa_aif() instead

Link: https://lore.kernel.org/r/20210303144631.3175331-17-lee.jones@linaro.org
Cc: Adaptec OEM Raid Solutions <aacraid@microsemi.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: "PMC-Sierra, Inc" <aacraid@pmc-sierra.com>
Cc: linux-scsi@vger.kernel.org
Cc: linux-media@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: linaro-mm-sig@lists.linaro.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# da38e891 19-Nov-2020 Gustavo A. R. Silva <gustavoars@kernel.org>

scsi: aacraid: Fix fall-through warnings for Clang

In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by
explicitly adding a break statement instead of letting the code fall
through to the next case.

Link: https://github.com/KSPP/linux/issues/115
Link: https://lore.kernel.org/r/e4e25e57964a69f7173f868ff93df9d6d08f360f.1605896060.git.gustavoars@kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 66ab2fa3 26-Sep-2020 Tomas Henzl <thenzl@redhat.com>

scsi: aacraid: Add a missing iounmap call

Add a missing resource cleanup in _aac_reset_adapter.

Link: https://lore.kernel.org/r/20200926150015.6187-1-thenzl@redhat.com
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# e555cd5f 29-Jul-2020 Suraj Upadhyay <usuraj35@gmail.com>

scsi: aacraid: Remove pci-dma-compat wrapper API

The legacy API wrappers in include/linux/pci-dma-compat.h should go away as
they create unnecessary midlayering for include/linux/dma-mapping.h API.
Instead use dma-mapping.h API directly.

The patch has been generated with the coccinelle script below.
Compile-tested.

@@@@
- PCI_DMA_BIDIRECTIONAL
+ DMA_BIDIRECTIONAL

@@@@
- PCI_DMA_TODEVICE
+ DMA_TO_DEVICE

@@@@
- PCI_DMA_FROMDEVICE
+ DMA_FROM_DEVICE

@@@@
- PCI_DMA_NONE
+ DMA_NONE

@@ expression E1, E2, E3; @@
- pci_alloc_consistent(E1, E2, E3)
+ dma_alloc_coherent(&E1->dev, E2, E3, GFP_)

@@ expression E1, E2, E3; @@
- pci_zalloc_consistent(E1, E2, E3)
+ dma_alloc_coherent(&E1->dev, E2, E3, GFP_)

@@ expression E1, E2, E3, E4; @@
- pci_free_consistent(E1, E2, E3, E4)
+ dma_free_coherent(&E1->dev, E2, E3, E4)

@@ expression E1, E2, E3, E4; @@
- pci_map_single(E1, E2, E3, E4)
+ dma_map_single(&E1->dev, E2, E3, E4)

@@ expression E1, E2, E3, E4; @@
- pci_unmap_single(E1, E2, E3, E4)
+ dma_unmap_single(&E1->dev, E2, E3, E4)

@@ expression E1, E2, E3, E4, E5; @@
- pci_map_page(E1, E2, E3, E4, E5)
+ dma_map_page(&E1->dev, E2, E3, E4, E5)

@@ expression E1, E2, E3, E4; @@
- pci_unmap_page(E1, E2, E3, E4)
+ dma_unmap_page(&E1->dev, E2, E3, E4)

@@ expression E1, E2, E3, E4; @@
- pci_map_sg(E1, E2, E3, E4)
+ dma_map_sg(&E1->dev, E2, E3, E4)

@@ expression E1, E2, E3, E4; @@
- pci_unmap_sg(E1, E2, E3, E4)
+ dma_unmap_sg(&E1->dev, E2, E3, E4)

@@ expression E1, E2, E3, E4; @@
- pci_dma_sync_single_for_cpu(E1, E2, E3, E4)
+ dma_sync_single_for_cpu(&E1->dev, E2, E3, E4)

@@ expression E1, E2, E3, E4; @@
- pci_dma_sync_single_for_device(E1, E2, E3, E4)
+ dma_sync_single_for_device(&E1->dev, E2, E3, E4)

@@ expression E1, E2, E3, E4; @@
- pci_dma_sync_sg_for_cpu(E1, E2, E3, E4)
+ dma_sync_sg_for_cpu(&E1->dev, E2, E3, E4)

@@ expression E1, E2, E3, E4; @@
- pci_dma_sync_sg_for_device(E1, E2, E3, E4)
+ dma_sync_sg_for_device(&E1->dev, E2, E3, E4)

@@ expression E1, E2; @@
- pci_dma_mapping_error(E1, E2)
+ dma_mapping_error(&E1->dev, E2)

@@ expression E1, E2; @@
- pci_set_consistent_dma_mask(E1, E2)
+ dma_set_coherent_mask(&E1->dev, E2)

@@ expression E1, E2; @@
- pci_set_dma_mask(E1, E2)
+ dma_set_mask(&E1->dev, E2)

Link: https://lore.kernel.org/r/f8d4778440d55ba26c04eef0f7d63fb211a39443.1596045683.git.usuraj35@gmail.com
Signed-off-by: Suraj Upadhyay <usuraj35@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# df561f66 23-Aug-2020 Gustavo A. R. Silva <gustavoars@kernel.org>

treewide: Use fallthrough pseudo-keyword

Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>


# f1134f0e 13-Jul-2020 Lee Jones <lee.jones@linaro.org>

scsi: aacraid: Fix a bunch of function header issues

Some parameters not documented. Others misspelled.

Also, functions must follow directly after the header that documents them.

Fixes the following W=1 kernel build warning(s):

drivers/scsi/aacraid/commsup.c:223: warning: Function parameter or member 'scmd' not described in 'aac_fib_alloc_tag'
drivers/scsi/aacraid/commsup.c:421: warning: Function parameter or member 'qid' not described in 'aac_queue_get'
drivers/scsi/aacraid/commsup.c:421: warning: Function parameter or member 'hw_fib' not described in 'aac_queue_get'
drivers/scsi/aacraid/commsup.c:421: warning: Excess function parameter 'priority' description in 'aac_queue_get'
drivers/scsi/aacraid/commsup.c:421: warning: Excess function parameter 'fib' description in 'aac_queue_get'
drivers/scsi/aacraid/commsup.c:943: warning: Function parameter or member 'fibptr' not described in 'aac_fib_complete'
drivers/scsi/aacraid/commsup.c:943: warning: Excess function parameter 'fib' description in 'aac_fib_complete'
drivers/scsi/aacraid/commsup.c:1061: warning: Excess function parameter 'dev' description in 'AIF_SNIFF_TIMEOUT'
drivers/scsi/aacraid/commsup.c:1061: warning: Excess function parameter 'fibptr' description in 'AIF_SNIFF_TIMEOUT'
drivers/scsi/aacraid/commsup.c:2428: warning: Function parameter or member 'data' not described in 'aac_command_thread'
drivers/scsi/aacraid/commsup.c:2428: warning: Excess function parameter 'dev' description in 'aac_command_thread'

Link: https://lore.kernel.org/r/20200713080001.128044-8-lee.jones@linaro.org
Cc: Adaptec OEM Raid Solutions <aacraid@microsemi.com>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: "PMC-Sierra, Inc" <aacraid@pmc-sierra.com>
Cc: linux-media@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: linaro-mm-sig@lists.linaro.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 297083f6 30-Apr-2020 Zou Wei <zou_wei@huawei.com>

scsi: aacraid: Make some symbols static

Fix the following sparse warnings:

drivers/scsi/aacraid/linit.c:867:6: warning:
symbol 'aac_tmf_callback' was not declared. Should it be static?
drivers/scsi/aacraid/linit.c:1081:5: warning:
symbol 'aac_eh_host_reset' was not declared. Should it be static?
drivers/scsi/aacraid/commsup.c:2354:5: warning:
symbol 'aac_send_safw_hostttime' was not declared. Should it be static?
drivers/scsi/aacraid/commsup.c:2383:5: warning:
symbol 'aac_send_hosttime' was not declared. Should it be static?

Link: https://lore.kernel.org/r/1588240932-69020-1-git-send-email-zou_wei@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zou Wei <zou_wei@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 4e6c78d1 31-Mar-2020 Hannes Reinecke <hare@suse.de>

scsi: aacraid: do not overwrite retval in aac_reset_adapter()

'retval' got assigned a value twice, causing the original value to be lost.

Link: https://lore.kernel.org/r/20200331084111.95039-1-hare@suse.de
Fixes: 3d3ca53b1639 ("scsi: aacraid: use scsi_host_(block,unblock) to block I/O")
Reported-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# bef18d30 12-Feb-2020 Sagar Biradar <Sagar.Biradar@microchip.com>

scsi: aacraid: Disabling TM path and only processing IOP reset

Fixes the occasional adapter panic when sg_reset is issued with -d, -t, -b
and -H flags. Removal of command type HBA_IU_TYPE_SCSI_TM_REQ in
aac_hba_send since iu_type, request_id and fib_flags are not populated.
Device and target reset handlers are made to send TMF commands only when
reset_state is 0.

Link: https://lore.kernel.org/r/1581553771-25796-1-git-send-email-Sagar.Biradar@microchip.com
Reviewed-by: Sagar Biradar <Sagar.Biradar@microchip.com>
Signed-off-by: Sagar Biradar <Sagar.Biradar@microchip.com>
Signed-off-by: Balsundar P <balsundar.p@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 3d3ca53b 28-Feb-2020 Hannes Reinecke <hare@suse.de>

scsi: aacraid: use scsi_host_(block,unblock) to block I/O

Use scsi_host_block() and scsi_host_unblock() instead of
scsi_block_requests()/scsi_unblock_requests() to block and unblock I/O.
This has the advantage that the block layer will stop sending I/O to the
adapter instead of having the SCSI midlayer requeueing I/O internally.

Link: https://lore.kernel.org/r/20200228075318.91255-10-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Balsundar P < Balsundar.P@microchip.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 5646e13a 28-Feb-2020 Hannes Reinecke <hare@suse.de>

scsi: aacraid: move scsi_(block,unblock)_requests out of _aac_reset_adapter()

_aac_reset_adapter() only has one caller, and that one already calls
scsi_block_requests(). Move the calls out of _aac_reset_adapter() to avoid
calling scsi_block_requests() twice.

Link: https://lore.kernel.org/r/20200228075318.91255-8-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Balsundar P < Balsundar.P@microchip.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# a1855f61 28-Feb-2020 Hannes Reinecke <hare@suse.de>

scsi: aacraid: use scsi_host_complete_all_commands() to terminate outstanding commands

Use scsi_host_complete_all_commands() to terminate all outstanding commands
and change the command result for terminated commands to the more common
'DID_RESET' instead of 'QUEUE_FULL'.

Link: https://lore.kernel.org/r/20200228075318.91255-6-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Acked-by: Balsundar P <balsundar.p@microchip.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 26c54d0e 15-Oct-2019 Balsundar P <balsundar.p@microsemi.com>

scsi: aacraid: send AIF request post IOP RESET

After IOP reset completion, AIF request command is not issued to the
controller. Driver schedules a worker thread to issue a AIF request command
after IOP reset completion.

[mkp: fix zeroday warning]

Link: https://lore.kernel.org/r/1571120524-6037-7-git-send-email-balsundar.p@microsemi.com
Acked-by: Balsundar P < Balsundar.P@microchip.com>
Signed-off-by: Balsundar P <balsundar.p@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# f2244c1b 15-Oct-2019 Balsundar P <balsundar.p@microsemi.com>

scsi: aacraid: fixed IO reporting error

The problem is the driver detects FastResponse bit set and saves it to
Fib's flags to not check IO response status, but it never clears it for
next IO. Hence the next IO will pick up FastResponse bit to not check
the IO response status and fail to report any type IO error to kernel

Link: https://lore.kernel.org/r/1571120524-6037-3-git-send-email-balsundar.p@microsemi.com
Signed-off-by: Balsundar P <balsundar.p@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# c82ee6d3 19-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 18

Based on 1 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 or at your option any
later version this program is distributed in the hope that it will
be useful but without any warranty without even the implied warranty
of merchantability or fitness for a particular purpose see the gnu
general public license for more details you should have received a
copy of the gnu general public license along with this program see
the file copying if not write to the free software foundation 675
mass ave cambridge ma 02139 usa

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 52 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Jilayne Lovejoy <opensource@jilayne.com>
Reviewed-by: Steve Winslow <swinslow@gmail.com>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190519154042.342335923@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b6554cfe 22-Mar-2019 Dave Carroll <david.carroll@microsemi.com>

scsi: aacraid: Insure we don't access PCIe space during AER/EEH

There are a few windows during AER/EEH when we can access PCIe I/O mapped
registers. This will harden the access to insure we do not allow PCIe
access during errors

Signed-off-by: Dave Carroll <david.carroll@microsemi.com>
Reviewed-by: Sagar Biradar <sagar.biradar@microchip.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 5e420fe6 15-Feb-2019 Gustavo A. R. Silva <gustavo@embeddedor.com>

scsi: aacraid: Fix missing break in switch statement

Add missing break statement and fix identation issue.

This bug was found thanks to the ongoing efforts to enable
-Wimplicit-fallthrough.

Fixes: 9cb62fa24e0d ("aacraid: Log firmware AIF messages")
Cc: stable@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# e13949ae 02-Feb-2019 Colin Ian King <colin.king@canonical.com>

scsi: aacraid: clean up some indentation and formatting issues

There are several issues with badly indented statements. Fix these
and clean up the formatting.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Mahesh Rajashekhara <mahesh.rajashekhara@microchip.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# bc127d93 10-Dec-2018 Arnd Bergmann <arnd@arndb.de>

scsi: aacraid: change event_wait to a completion

The event_wait semaphore has completion semantics, so we can
change it over to the completion interface for clarity without
changing the behavior.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Dave Carroll <david.carroll@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# dc71eccc 10-Dec-2018 Arnd Bergmann <arnd@arndb.de>

scsi: aacraid: change wait_sem to a completion

The wait_sem member is used like a completion, so we should
use the respective API. The behavior is unchanged.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Dave Carroll <david.carroll@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 05a98744 16-Aug-2018 Colin Ian King <colin.king@canonical.com>

scsi: aacraid: remove unused variables dev and cpu

Variables dev and cpu are not being used and are redundant and hence can
be removed.

Cleans up clang warnings:
warning: variable 'dev' set but not used [-Wunused-but-set-variable]
warning: variable 'cpu' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# d98e000c 06-Aug-2018 Dongliang Mu <mudongliangabcd@gmail.com>

scsi: aacraid: Spelling fix in comment

requesed -> requested

Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 7d3af7d9 25-Apr-2018 Dave Carroll <david.carroll@microsemi.com>

scsi: aacraid: Correct hba_send to include iu_type

commit b60710ec7d7a ("scsi: aacraid: enable sending of TMFs from
aac_hba_send()") allows aac_hba_send() to send scsi commands, and TMF
requests, but the existing code only updates the iu_type for scsi
commands. For TMF requests we are sending an unknown iu_type to
firmware, which causes a fault.

Include iu_type prior to determining the validity of the command

Reported-by: Noah Misner <nmisner@us.ibm.com>
Fixes: b60710ec7d7ab ("aacraid: enable sending of TMFs from aac_hba_send()")
Fixes: 423400e64d377 ("aacraid: Include HBA direct interface")
Tested-by: Noah Misner <nmisner@us.ibm.com>
cc: stable@vger.kernel.org
Signed-off-by: Dave Carroll <david.carroll@microsemi.com>
Reviewed-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 1c6b41fb 03-Apr-2018 Dave Carroll <david.carroll@microsemi.com>

scsi: aacraid: Insure command thread is not recursively stopped

If a recursive IOP_RESET is invoked, usually due to the eh_thread
handling errors after the first reset, be sure we flag that the command
thread has been stopped to avoid an Oops of the form;

[ 336.620256] CPU: 28 PID: 1193 Comm: scsi_eh_0 Kdump: loaded Not tainted 4.14.0-49.el7a.ppc64le #1
[ 336.620297] task: c000003fd630b800 task.stack: c000003fd61a4000
[ 336.620326] NIP: c000000000176794 LR: c00000000013038c CTR: c00000000024bc10
[ 336.620361] REGS: c000003fd61a7720 TRAP: 0300 Not tainted (4.14.0-49.el7a.ppc64le)
[ 336.620395] MSR: 9000000000009033 <SF,HV,EE,ME,IR,DR,RI,LE> CR: 22084022 XER: 20040000
[ 336.620435] CFAR: c000000000130388 DAR: 0000000000000000 DSISR: 40000000 SOFTE: 1
[ 336.620435] GPR00: c00000000013038c c000003fd61a79a0 c0000000014c7e00 0000000000000000
[ 336.620435] GPR04: 000000000000000c 000000000000000c 9000000000009033 0000000000000477
[ 336.620435] GPR08: 0000000000000477 0000000000000000 0000000000000000 c008000010f7d940
[ 336.620435] GPR12: c00000000024bc10 c000000007a33400 c0000000001708a8 c000003fe3b881d8
[ 336.620435] GPR16: c000003fe3b88060 c000003fd61a7d10 fffffffffffff000 000000000000001e
[ 336.620435] GPR20: 0000000000000001 c000000000ebf1a0 0000000000000001 c000003fe3b88000
[ 336.620435] GPR24: 0000000000000003 0000000000000002 c000003fe3b88840 c000003fe3b887e8
[ 336.620435] GPR28: c000003fe3b88000 c000003fc8181788 0000000000000000 c000003fc8181700
[ 336.620750] NIP [c000000000176794] exit_creds+0x34/0x160
[ 336.620775] LR [c00000000013038c] __put_task_struct+0x8c/0x1f0
[ 336.620804] Call Trace:
[ 336.620817] [c000003fd61a79a0] [c000003fe3b88000] 0xc000003fe3b88000 (unreliable)
[ 336.620853] [c000003fd61a79d0] [c00000000013038c] __put_task_struct+0x8c/0x1f0
[ 336.620889] [c000003fd61a7a00] [c000000000171418] kthread_stop+0x1e8/0x1f0
[ 336.620922] [c000003fd61a7a40] [c008000010f7448c] aac_reset_adapter+0x14c/0x8d0 [aacraid]
[ 336.620959] [c000003fd61a7b00] [c008000010f60174] aac_eh_host_reset+0x84/0x100 [aacraid]
[ 336.621010] [c000003fd61a7b30] [c000000000864f24] scsi_try_host_reset+0x74/0x180
[ 336.621046] [c000003fd61a7bb0] [c000000000867ac0] scsi_eh_ready_devs+0xc00/0x14d0
[ 336.625165] [c000003fd61a7ca0] [c0000000008699e0] scsi_error_handler+0x550/0x730
[ 336.632101] [c000003fd61a7dc0] [c000000000170a08] kthread+0x168/0x1b0
[ 336.639031] [c000003fd61a7e30] [c00000000000b528] ret_from_kernel_thread+0x5c/0xb4
[ 336.645971] Instruction dump:
[ 336.648743] 384216a0 7c0802a6 fbe1fff8 f8010010 f821ffd1 7c7f1b78 60000000 60000000
[ 336.657056] 39400000 e87f0838 f95f0838 7c0004ac <7d401828> 314affff 7d40192d 40c2fff4
[ 336.663997] -[ end trace 4640cf8d4945ad95 ]-

So flag when the thread is stopped by setting the thread pointer to NULL.

Signed-off-by: Dave Carroll <david.carroll@microsemi.com>
Reviewed-by: Raghava Aditya Renukunta <raghavaaditya.renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 75be67cd 26-Dec-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Remove unused rescan variable

Remove unused rescan variable.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# fe523759 26-Dec-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Skip schedule rescan in case of kdump

There is a chance of the driver to be stuck in kdump if drives start
acting up in kdump discovery process and the kernel decides to send eh
resets, which would prompt rescan to be scheduled.

Do not perform a rescan in kdump context, since we do not expect a hotplug
event during kdump and all the devices are going to go away anyway.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 8a30e50b 26-Dec-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Fix hang while scanning in eh recovery

Add back the ability to scan for hotplug changes while eh was in progress.

Schedule a rescan for a later time in the eh recovery code and wait for
eh to complete in the rescan worker.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# a1367e4a 26-Dec-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Reschedule host scan in case of failure

If the driver fails to retrieve information from the fw (could happen when
the fw is not fully in its senses), the driver does nothing and change is
not processed correctly by the driver

Schedule host rescan in case of failure. This is only for SAFW, since
the information retrieval failure will happen on SAFW devices.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 8ebaa67f 26-Dec-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Use hotplug handling function in place of scsi_scan_host

Driver uses scsi_scan_host to add new devices in the driver init path,
which adds all the fw exposed devices. The drivers resorts to queue
command checks to block out commands to _hidden_ devices.

Use the hotplug handler code to add new devices during driver init and
other areas, this is only for safw. For ARC scsi_scan_host will still
apply.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 3395614e 26-Dec-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Block concurrent hotplug event handling

Currently driver will attempt to process hotplug events concurrently based
on the FW interrupt.

Protect safw update function with a scan mutex.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 6f44a22b 26-Dec-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Merge adapter setup with resolve luns

The device hotplug events are processed only after retrieving the updated
lun information from the fw. Does not make sense to keep them separate.

Merge both the hotplug handling and safw adapter setup code into single
function.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 3031c656 26-Dec-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Refactor resolve luns code and scsi functions

Resolve luns checks the if a sdev is already present in the os to figure
out if it needs to be removed. Internally the driver exposes HBA on bus
2 even though its bus 1 in the fw. Its mildly confusing.

Refactor out the sdev lookup into its function to check if sdev has been
added to the kernel or not. Add helper functions to add, remove and put
devices based on their fw bus and target number.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 2290678f 26-Dec-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Added macros to help loop through known buses and targets

Added macros to loop through the MAX SUPPORTED Buses and Targets. This
will make the code a bit easier to read.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# f2d2caba 26-Dec-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Process hba and container hot plug events in single function

The hotplug handler code is duplicated for hba handling and container
handling.

Merged function to handle hba and container hot plug events into the
resolve luns functions. Added a bunch of helper functions to check the
validity of a given target and to check if bus, target is container
device.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 1d1fec53 26-Dec-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Merge func to get container information

Merge aac_get_containers to setup target function, so that information
about all the present devices can be retrieved in one shot.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# fc0fdd9a 26-Dec-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Add target setup helper function

Add helper function to setup targets devices and create the base for the
upcoming patches

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# b5a475e9 26-Dec-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Refactor and rename to make mirror existing changes

Rename variables and functions to make bmic identify, report phy luns
to make them consistent across code internal existing code bases

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 5480aa18 26-Dec-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Change phy luns function to use common bmic function

Edit function that retrieves phy lun information to use common
bmic function

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 216ced02 26-Dec-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Move code to wait for IO completion to shutdown func

Ideally driver needs to wait for IO to be submitted or responded to before
shutdown.

Move code to wait for IO completion into shutdown path

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 95900629 26-Dec-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Do not remove offlined devices

As part of the recovery process, the drivers removes offline devices (
done by the kernel) and then tries to add them back in the rescan code.
Removing the device is like taking a sledgehammer to a nail.

Set the device as running if it is marked offline.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# c5313ae8 26-Dec-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Fix hang in kdump

Driver attempts to perform a device scan and device add after coming out
of reset. At times when the kdump kernel loads and it tries to perform
eh recovery, the device scan hangs since its commands are blocked because
of the eh recovery. This should have shown up in normal eh recovery path
(Should have been obvious)

Remove the code that performs scanning.I can live without the rescanning
support in the stable kernels but a hanging kdump/eh recovery needs to be
fixed.

Fixes: a2d0321dd532901e (scsi: aacraid: Reload offlined drives after controller reset)
Cc: <stable@vger.kernel.org>
Reported-by: Douglas Miller <dougmill@linux.vnet.ibm.com>
Tested-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
Fixes: a2d0321dd532901e (scsi: aacraid: Reload offlined drives after controller reset)
Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# d1853975 28-Nov-2017 Arnd Bergmann <arnd@arndb.de>

scsi: aacraid: address UBSAN warning regression

As reported by Meelis Roos, my previous patch causes an incorrect
calculation of the timeout, through an undefined signed integer
overflow:

[ 12.228155] UBSAN: Undefined behaviour in drivers/scsi/aacraid/commsup.c:2514:49
[ 12.228229] signed integer overflow:
[ 12.228283] 964297611 * 250 cannot be represented in type 'long int'

The problem is that doing a multiplication with HZ first and then
dividing by USEC_PER_SEC worked correctly for 32-bit microseconds,
but not for 32-bit nanoseconds, which would require up to 41 bits.

This reworks the calculation to first convert the nanoseconds into
jiffies, which should give us the same result as before and not overflow.

Unfortunately I did not understand the exact intention of the algorithm,
in particular the part where we add half a second, so it's possible that
there is still a preexisting problem in this function. I added a comment
that this would be handled more nicely using usleep_range(), which
generally works better for waking up at a particular time than the
current schedule_timeout() based implementation. I did not feel
comfortable trying to implement that without being sure what the
intent is here though.

Fixes: 820f18865912 ("scsi: aacraid: use timespec64 instead of timeval")
Tested-by: Meelis Roos <mroos@linux.ee>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# e4717292 17-Nov-2017 Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>

scsi: aacraid: Prevent crash in case of free interrupt during scsi EH path

As part of the scsi EH path, aacraid performs a reinitialization of the
adapter, which encompass freeing resources and IRQs, NULLifying lots of
pointers, and then initialize it all over again. We've identified a
problem during the free IRQ portion of this path if CONFIG_DEBUG_SHIRQ
is enabled on kernel config file.

Happens that, in case this flag was set, right after free_irq()
effectively clears the interrupt, it checks if it was requested as
IRQF_SHARED. In positive case, it performs another call to the IRQ
handler on driver. Problem is: since aacraid currently free some
resources *before* freeing the IRQ, once free_irq() path calls the
handler again (due to CONFIG_DEBUG_SHIRQ), aacraid crashes due to NULL
pointer dereference with the following trace:

aac_src_intr_message+0xf8/0x740 [aacraid]
__free_irq+0x33c/0x4a0
free_irq+0x78/0xb0
aac_free_irq+0x13c/0x150 [aacraid]
aac_reset_adapter+0x2e8/0x970 [aacraid]
aac_eh_reset+0x3a8/0x5d0 [aacraid]
scsi_try_host_reset+0x74/0x180
scsi_eh_ready_devs+0xc70/0x1510
scsi_error_handler+0x624/0xa20

This patch prevents the crash by changing the order of the
deinitialization in this path of aacraid: first we clear the IRQ, then
we free other resources. No functional change intended.

Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
Reviewed-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# bd257b2f 17-Nov-2017 Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>

scsi: aacraid: Check for PCI state of device in a generic way

Commit 16ae9dd35d37 ("scsi: aacraid: Fix for excessive prints on EEH")
introduced checks about the state of device before any PCI operations in
the driver. Basically, this prevents it to perform PCI accesses when
device is in the process of recover from a PCI error. In PowerPC, such
mechanism is called EEH, and the aforementioned commit introduced checks
that are based on EEH-specific primitives for that.

The potential problems with this approach are three: first, these checks
are "locked" to powerpc only - another archs could have error recovery
methods too, like AER in Intel. Also, the powerpc primitives perform
expensive FW accesses to validate the precise PCI state of a device.
Finally, code becomes more complicated and needs ifdef validation based
on arch config being set.

So, this patch makes use of generic PCI state checks, which are
lightweight and non-dependent of arch configs - also, it makes the code
cleaner.

Fixes: 16ae9dd35d37 ("scsi: aacraid: Fix for excessive prints on EEH")
Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
Reviewed-by: Dave Carroll <david.carroll@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 820f1886 07-Nov-2017 Arnd Bergmann <arnd@arndb.de>

scsi: aacraid: use timespec64 instead of timeval

aacraid passes the current time to the firmware in one of two ways,
either as year/month/day/... or as 32-bit unsigned seconds.

The first one is broken on 32-bit architectures as it cannot go past
year 2038. Using timespec64 here makes it behave properly on both 32-bit
and 64-bit architectures, and avoids relying on signed integer overflow
to pass times into the second interface.

The interface used in aac_send_hosttime() however is still problematic
in year 2106 when 32-bit seconds overflow. Hopefully we don't have to
worry about aacraid by that time.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Dave Carroll <david.carroll@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# c323eab7 30-Jun-2017 Hannes Reinecke <hare@suse.de>

scsi: aacraid: add fib flag to mark scsi command callback

To correctly identify which fib has a scsi command callback this
patch implements a flag FIB_CONTEXT_FLAG_SCSI_CMD.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# b60710ec 30-Jun-2017 Hannes Reinecke <hare@suse.de>

scsi: aacraid: enable sending of TMFs from aac_hba_send()

aac_hba_send() will return FAILED for any non-SCSI command requests,
failing any TMFs. This patch updates the check to allow TMFs.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 395e5df7 10-May-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Remove reference to Series-9

Remove reference to Series-9 HBA and created arc ctrl check function.

Signed-off-by: Prasad B Munirathnam <prasad.munirathnam@microsemi.com>
Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: David Carroll <david.carroll@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 8c41b9b7 10-May-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Make sure ioctl returns on controller reset

Made sure that ioctl commands return in case of a controller reset.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: Dave Carroll <david.carroll@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 9473ddb2 10-May-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Use correct function to get ctrl health

The command thread checks the ctrl health periodically before sending
updates to the controller. The function that it uses is aac_check_health
which does more than get the health status.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: David Carroll <david.carroll@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# fed82007 10-May-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Remove reset support from check_health

Check health does not need to reset the ctrl but just return the
controller health status.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: David Carroll <david.carroll@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 8105d39d 10-May-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Fix DMAR issues with iommu=pt

The driver changed the DMA consistent map after consistent memory was
allocated, this invalidated the IOMMU identity mapping. The fix was to
make sure that we set the DMA consistent mask setting once depending on
the controller card.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: Dave Carroll <david.carroll@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# f481973d 05-Apr-2017 Mahesh Rajashekhara <mahesh.rajashekhara@microsemi.com>

scsi: aacraid: pci_alloc_consistent() failures on ARM64

There were pci_alloc_consistent() failures on ARM64 platform. Use
dma_alloc_coherent() with GFP_KERNEL flag DMA memory allocations.

Signed-off-by: Mahesh Rajashekhara <mahesh.rajashekhara@microsemi.com>
[hch: tweaked indentation, removed memsets]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Dave Carroll <david.carroll@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 911e572e 06-Apr-2017 Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>

scsi: aacraid: fix PCI error recovery path

During a PCI error recovery, if aac_check_health() is not aware that a
PCI error happened and we have an offline PCI channel, it might trigger
some errors (like NULL pointer dereference) and inhibit the error
recovery process to complete.

This patch makes the health check procedure aware of PCI channel issues,
and in case of error recovery process, the function
aac_adapter_check_health() returns -1 and let the recovery process to
complete successfully. This patch was tested on upstream kernel
v4.11-rc5 in PowerPC ppc64le architecture with adapter 9005:028d
(VID:DID) - the error recovery procedure was able to recover fine.

Fixes: 5c63f7f710bd ("aacraid: Added EEH support")
Cc: stable@vger.kernel.org # v4.6+
Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
Reviewed-by: Dave Carroll <david.carroll@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# e498520e 14-Mar-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Fix potential null access

Currently, command threads fails to return ioctls commands for older
controller versions, since it returns when all the fibs have been
allocated. Another issue is even all the fibs have not been allocated,
the correct allocated fibs is not updated nor freed.

Fixes: 113156bcea9ef1e6 (scsi: aacraid: Reworked aac_command_thread)
Reported-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: Dave Carroll <david.carroll@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# fbdab3e7 24-Feb-2017 Colin Ian King <colin.king@canonical.com>

scsi: aacraid: remove redundant zero check on ret

The check for ret being zero is redundant as a few statements earlier we
break out of the while loop if ret is non-zero. Thus we can remove the
zero check and also the dead-code non-zero case too.

Detected by CoverityScan, CID#1411632 ("Logically Dead Code")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Dave Carroll <david.carroll@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# a56e5740 22-Feb-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Fixed expander hotplug for SMART family

Current driver Hotplug processing code skips over Enclosure channel,
therefore any addition/removal of expander enclosure is not processed.
Additionally device addition code relies on older device type, which
prevents the hotplug of adapter expanders.

Fixed by removing code that skips over Enclosure channels and using the
latest device type for addition or removal or enclosure expanders.

Fixes: 6223a39fe6fbbeef (scsi: aacraid: Added support for hotplug)
Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: Dave Carroll <david.carroll@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# d844752e 16-Feb-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Fix a potential spinlock double unlock bug

The driver does not unlock the reply queue spin lock after handling SMART
adapter events. Instead it might attempt to unlock an already unlocked
spin lock.

Fixed by making sure the driver locks the spin lock before freeing it.

Thank you dan for finding this issue out.

Fixes: 6223a39fe6fbbeef (scsi: aacraid: Added support for hotplug)
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: David Carroll <David.Carroll@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# a2d0321d 16-Feb-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Reload offlined drives after controller reset

During the IOP reset stress testing, it was found that the drives can be
marked offline when the adapter controller crashes and IO's are running
in parallel. When the controller does come back from the reset, the drive
that is marked offline is not exposed.

Fixed by removing and adding drives that are marked offline. In addition
invoke a scsi host bus rescan to capture any additional configuration
changes.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: David Carroll <David.Carroll@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 849ac6a5 16-Feb-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Skip wellness sync on controller failure

aac_command_thread checks on the health of controller periodically,
using aac_check_health. If the status is an error state KERNEL_PANIC or
anything else. The driver will attempt to restart the adapter, but the
response is not checked in aac_command_thread. This allows the periodic
sync to go thru and lead the driver to a hung state.

Fixed by terminating the periodic loop(intended per original design),
if the controller is not restored to a healthy state.

Cc: stable@vger.kernel.org
Fixes: 3d77d8404478353358 (scsi: aacraid: Added support for periodic wellness sync)
Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: David Carroll <David.Carroll@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 1bff5abc 16-Feb-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Fix memory leak in fib init path

aac_fib_map_free frees misaligned fib dma memory, additionally it does not
free up the whole memory.

Fixed by changing the code to free up the correct and full memory
allocation.

Cc: stable@vger.kernel.org
Fixes: e8b12f0fb835223 ([SCSI] aacraid: Add new code for PMC-Sierra's SRC based controller family)
Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: David Carroll <David.Carroll@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# a0c6143e 16-Feb-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Prevent E3 lockup when deleting units

Arrconf management utility at times sends fibs with AdapterProcessed set
in its fibs. This causes the controller to panic and lockup.

Fixed by failing the commands that have AdapterProcessed set in its flag.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: David Carroll <David.Carroll@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 16ae9dd3 16-Feb-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Fix for excessive prints on EEH

This issue showed up on a kdump debug(single CPU on powerkvm), when EEH
errors rendered the adapter unusable. The driver correctly detected the
issue and attempted to restart the controller, in doing so the driver
attempted to read the status registers of the controller. This triggered
additional eeh errors which continued for a good 6 minutes.

Fixed by returning without waiting when EEH error is reported.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: David Carroll <David.Carroll@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 1c68856e 16-Feb-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Fix camel case

Replaced camel case with snake case for init supported options.

Suggested-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: David Carroll <David.Carroll@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# f4babba0 02-Feb-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Update copyrights

Added new copyright messages

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Dave Carroll <David.Carroll@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 31364329 02-Feb-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Added new IWBR reset

Added a new IWBR soft reset type, reworked the IOP reset interface for
a bit.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Dave Carroll <David.Carroll@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 423400e6 02-Feb-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Include HBA direct interface

Added support to send direct pasthru srb commands from management utilty
to the controller.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Dave Carroll <David.Carroll@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 6223a39f 02-Feb-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Added support for hotplug

Added support for drive hotplug add and removal

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Dave Carroll <David.Carroll@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 3d77d840 02-Feb-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Added support for periodic wellness sync

This patch adds a new functions that periodically sync the time of host
to the adapter. In addition also informs the adapter that the driver is
alive and kicking. Only applicable to the HBA1000 and SMARTIOC2000.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Dave Carroll <David.Carroll@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 113156bc 02-Feb-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Reworked aac_command_thread

Reworked aac_command_thread into aac_process_events

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Signed-off-by: Dave Carroll <David.Carroll@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 3ffd6c5a 02-Feb-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: Added support for response path

This patch enables the driver to actually process the I/O, or srb replies
from adapter. In addition to any HBA1000 or SmartIOC2000 adapter events.

Signed-off-by: Raghava Aditya Renukunta <raghavaaditya.renukunta@microsemi.com>
Signed-off-by: Dave Carroll <David.Carroll@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# d1ef4da8 02-Feb-2017 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

scsi: aacraid: added support for init_struct_8

This patch lays the groundwork for supporting the new HBA-1000 controller
family.A new INIT structure INIT_STRUCT_8 has been added which allows for a
variable size for MSI-x vectors among other things, and is used for both
Series-8, HBA-1000 and SmartIOC-2000.

Signed-off-by: Raghava Aditya Renukunta <raghavaaditya.renukunta@microsemi.com>
Signed-off-by: Dave Carroll <David.Carroll@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 0910d8bb 08-Nov-2016 Hannes Reinecke <hare@suse.de>

scsi: aacraid: switch to pci_alloc_irq_vectors

Use pci_alloc_irq_vectors and drop the hand-crafted interrupt affinity
routines.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Cc: Adaptec OEM Raid Solutions <aacraid@microsemi.com>
Reviewed-by: Raghava Aditya Renukunta <raghavaaditya.renukunta@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 9cb62fa2 26-Apr-2016 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

aacraid: Log firmware AIF messages

Firmware AIF messages about cache loss and data recovery are being missed
by the driver since currently they are not captured but rather let go.
This patch to capture those messages and log them for the user.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# fc4bf75e 26-Apr-2016 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

aacraid: Fix for aac_command_thread hang

Typically under error conditions, it is possible for aac_command_thread()
to miss the wakeup from kthread_stop() and go back to sleep, causing it
to hang aac_shutdown.

In the observed scenario, the adapter is not functioning correctly and so
aac_fib_send() never completes (or time-outs depending on how it was
called). Shortly after aac_command_thread() starts it performs
aac_fib_send(SendHostTime) which hangs. When aac_probe_one
/aac_get_adapter_info send time outs, kthread_stop is called which breaks
the command thread out of it's hang.

The code will still go back to sleep in schedule_timeout() without
checking kthread_should_stop() so it causes aac_probe_one to hang until
the schedule_timeout() which is 30 minutes.

Fixed by: Adding another kthread_should_stop() before schedule_timeout()
Cc: stable@vger.kernel.org
Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 07beca2b 26-Apr-2016 Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>

aacraid: Relinquish CPU during timeout wait

aac_fib_send has a special function case for initial commands during
driver initialization using wait < 0(pseudo sync mode). In this case,
the command does not sleep but rather spins checking for timeout.This
loop is calls cpu_relax() in an attempt to allow other processes/threads
to use the CPU, but this function does not relinquish the CPU and so the
command will hog the processor. This was observed in a KDUMP
"crashkernel" and that prevented the "command thread" (which is
responsible for completing the command from being timed out) from
starting because it could not get the CPU.

Fixed by replacing "cpu_relax()" call with "schedule()"
Cc: stable@vger.kernel.org
Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# f88fa79a 03-Feb-2016 Raghava Aditya Renukunta <raghavaaditya.renukunta@pmcs.com>

aacraid: Fix memory leak in aac_fib_map_free

aac_fib_map_free() calls pci_free_consistent() without checking that
dev->hw_fib_va is not NULL and dev->max_fib_size is not zero.If they are
indeed NULL/0, this will result in a hang as pci_free_consistent() will
attempt to invalidate cache for the entire 64-bit address space
(which would take a very long time).

Fixed by adding a check to make sure that dev->hw_fib_va and
dev->max_fib_size are not NULL and 0 respectively.

Fixes: 9ad5204d6 - "[SCSI]aacraid: incorrect dma mapping mask during blinked recover or user initiated reset"
Cc: stable@vger.kernel.org

Signed-off-by: Raghava Aditya Renukunta <raghavaaditya.renukunta@pmcs.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>


# 3f4ce057 03-Feb-2016 Raghava Aditya Renukunta <raghavaaditya.renukunta@pmcs.com>

aacraid: Fix RRQ overload

The driver utilizes an array of atomic variables to keep track of IO
submissions to each vector. To submit an IO multiple threads iterate
through the array to find a vector which has empty slots to send an
IO. The reading and updating of the variable is not atomic, causing race
conditions when a thread uses a full vector to submit an IO.

Fixed by mapping each FIB to a vector, the submission path then uses
said vector to submit IO thereby removing the possibly of a race
condition.The vector assignment is started from 1 since vector 0 is
reserved for the use of AIF management FIBS.If the number of MSIx
vectors is 1 (MSI or INTx mode) then all the fibs are allocated to
vector 0.

Fixes: 495c0217 "aacraid: MSI-x support"
Cc: stable@vger.kernel.org # v4.1

Signed-off-by: Raghava Aditya Renukunta <raghavaaditya.renukunta@pmcs.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>


# 6bf3b630 03-Feb-2016 Raghava Aditya Renukunta <raghavaaditya.renukunta@pmcs.com>

aacraid: SCSI blk tag support

The method to allocate and free FIB's in the present code utilizes
spinlocks. Multiple IO's have to wait on the spinlock to acquire or free
fibs creating a performance bottleneck.

An alternative solution would be to use block layer tags to keep track
of the fibs allocated and freed. To this end aac_fib_alloc_tag was
created to utilize the blk layer tags to plug into the Fib pool.These
functions are used exclusively in the IO path. 8 fibs are reserved for
the use of AIF management software and utilize the previous spinlock
based implementations.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@pmcs.com>
Reviewed-by: Shane Seymour <shane.seymour@hpe.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>


# 8b1462e0 28-Aug-2015 Mahesh Rajashekhara <Mahesh.Rajashekhara@pmcs.com>

aacraid: Reset irq affinity hints

Reset irq affinity hints before releasing IRQ.
Removed duplicate code of IRQ acquire/release.

Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Reviewed-by: Murthy Bhat <Murthy.Bhat@pmcs.com>
Reviewed-by: Karthikeya Sunkesula <Karthikeya.Sunkesula@pmcs.com>
Signed-off-by: Mahesh Rajashekhara <Mahesh.Rajashekhara@pmcs.com>
Signed-off-by: James Bottomley <JBottomley@Odin.com>


# dab04b01 26-Mar-2015 Mahesh Rajashekhara <Mahesh.Rajashekhara@pmcs.com>

aacraid: AIF raw device remove support

Signed-off-by: Mahesh Rajashekhara <Mahesh.Rajashekhara@pmcs.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Murthy Bhat <Murthy.Bhat@pmcs.com>
Signed-off-by: James Bottomley <JBottomley@Odin.com>


# ef616233 26-Mar-2015 Mahesh Rajashekhara <Mahesh.Rajashekhara@pmcs.com>

aacraid: performance improvement changes

Signed-off-by: Mahesh Rajashekhara <Mahesh.Rajashekhara@pmcs.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Murthy Bhat <Murthy.Bhat@pmcs.com>
Signed-off-by: James Bottomley <JBottomley@Odin.com>


# 495c0217 26-Mar-2015 Mahesh Rajashekhara <Mahesh.Rajashekhara@pmcs.com>

aacraid: MSI-x support

Signed-off-by: Mahesh Rajashekhara <Mahesh.Rajashekhara@pmcs.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Murthy Bhat <Murthy.Bhat@pmcs.com>
Signed-off-by: James Bottomley <JBottomley@Odin.com>


# 46154a02 26-Mar-2015 Mahesh Rajashekhara <Mahesh.Rajashekhara@pmcs.com>

aacraid: AIF support for SES device add/remove

Signed-off-by: Mahesh Rajashekhara <Mahesh.Rajashekhara@pmcs.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Murthy Bhat <Murthy.Bhat@pmcs.com>
Signed-off-by: James Bottomley <JBottomley@Odin.com>


# f170168b 03-Jul-2013 Kees Cook <keescook@chromium.org>

drivers: avoid parsing names as kthread_run() format strings

Calling kthread_run with a single name parameter causes it to be handled
as a format string. Many callers are passing potentially dynamic string
content, so use "%s" in those cases to avoid any potential accidents.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 85d22bbf 14-Jul-2012 Mahesh Rajashekhara <Mahesh_Rajashekhara@pmc-sierra.com>

[SCSI] aacraid: Series 7 Async. (performance) mode support

- Series 7 Async. (performance) mode support added
- New scatter/gather list format for Series 7
- Driver converts s/g list to a firmware suitable list for best performance on
Series 7, this can be disabled with driver parameter "aac_convert_sgl" for
testing purposes
- New container read/write command structure for Series 7
- Fast response support for the SCSI pass-through path added
- Async. status response buffer changes

Signed-off-by: Mahesh Rajashekhara <Mahesh_Rajashekhara@pmc-sierra.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# 30002f1c 11-Jun-2012 Ben Collins <bcollins@ubuntu.com>

[SCSI] aacraid: Relax the tight timeout loop on fib commands

The loop that waited for syncronous fib commands was causing a CPU stall
when a timeout actually occured.

1) Switch to using a more accurate timeout mechanism.
2) Do not pace the loop with udelay(). Use cpu_relax() to allow for
scheduling to occur.

Signed-off-by: Ben Collins <bcollins@ubuntu.com>
Acked-by: Achim Leubner <Achim_Leubner@pmc-sierra.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# 11604612 08-Feb-2012 Mahesh Rajashekhara <Mahesh_Rajashekhara@pmc-sierra.com>

[SCSI] aacraid: Added Sync.mode to support series 7/8/9 controllers

Added Sync. mode to support Series 7/8/9 controller families: This is a
compatibility mode for all these controller families. The Async. (Performance)
mode can be changed in the future. First Async. mode version added for Series
7; Controller parameter aac_sync_mode added

Signed-off-by: Mahesh Rajashekhara <aacraid@pmc-sierra.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# d0efab26 02-Sep-2011 Vasily Averin <vvs@parallels.com>

[SCSI] aacraid: reset should disable MSI interrupt

scsi reset on hardware with enabled MSI interrupts generates WARNING message

[11027.798722] aacraid: Host adapter abort request (0,0,0,0)
[11027.798814] aacraid: Host adapter reset request. SCSI hang ?
[11087.762237] aacraid: SCSI bus appears hung
[11135.082543] ------------[ cut here ]------------
[11135.082646] WARNING: at drivers/pci/msi.c:658 pci_enable_msi_block+0x251/0x290()

Signed-off-by: Vasily Averin <vvs@sw.ru>
Acked-by: Mark Salyzyn <mark_salyzyn@us.xyratex.com>
Cc: stable@kernel.org
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# 25985edc 30-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>


# e8b12f0f 17-Mar-2011 Mahesh Rajashekhara <Mahesh_Rajashekhara@pmc-sierra.com>

[SCSI] aacraid: Add new code for PMC-Sierra's SRC based controller family

Added new hardware device 0x28b interface for PMC-Sierra's SRC based
controller family.

- new src.c file for 0x28b specific functions
- new XPORT header required
- sync. command interface: doorbell bits shifted (SRC_ODR_SHIFT, SRC_IDR_SHIFT)
- async. Interface: different inbound queue handling, no outbound I2O
queue available, using doorbell ("PmDoorBellResponseSent") and
response buffer on the host ("host_rrq") for status
- changed AIF (adapter initiated FIBs) interface: "DoorBellAifPending"
bit to inform about pending AIF, "AifRequest" command to read AIF,
"NoMoreAifDataAvailable" to mark the end of the AIFs

Signed-off-by: Mahesh Rajashekhara <aacraid@pmc-sierra.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# b595076a 01-Nov-2010 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

tree-wide: fix comment/printk typos

"gadget", "through", "command", "maintain", "maintain", "controller", "address",
"between", "initiali[zs]e", "instead", "function", "select", "already",
"equal", "access", "management", "hierarchy", "registration", "interest",
"relative", "memory", "offset", "already",

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 6de76cfc 07-Sep-2010 Thomas Gleixner <tglx@linutronix.de>

[SCSI] aacraid: semaphore cleanup

Get rid of init_MUTEX[_LOCKED]() and use sema_init() instead.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: aacraid@adaptec.com
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 9cccde93 10-May-2010 Rajashekhara, Mahesh <Mahesh_Rajashekhara@adaptec.com>

[SCSI] aacraid: add an ifdef'd device delete case instead of taking the device offline

Problem description:
--------------------

The problem reported by one of the customer was when a logical array
is deleted(from the SDK, from the GUI, from arcconf) then the
corresponding physical device (/dev/sdb, for example) is not removed
from the Linux namespace. So you end up with a "dead" device
entry. And some of the linux tools go slightly wonky.

Solution:
---------

Based on the notification from FW, the driver calls
"scsi_remove_device" for the DELETED drive. This call not only informs
the scsi device status to the SCSI mid layer and also it will remove
corresponding scsi device entries from the Linux sysfs.

Signed-off-by: Mahesh Rajashekhara <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 5ca05594 10-May-2010 Rajashekhara, Mahesh <Mahesh_Rajashekhara@adaptec.com>

[SCSI] aacraid: respond automatically to volumes added by config tool

Problem description:
--------------------

When the JBOD is created from the OS using Adaptec Storage Manager
utility device is not available under FDISK until a system restart is
done.

Solution:
---------

AIF handling: If there is a JBOD drive added to the system, identify
the old one with scsi_device_lookup() and remove it to enable a fresh
scsi_add_device(); else the new JBOD is not available until reboot.

Signed-off-by: Mahesh Rajashekhara <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# cacb6dc3 21-Dec-2009 Penchala Narasimha Reddy Chilakala, ERS-HCLTech <narasimhareddyc@hcl.in>

[SCSI] aacraid: fix File System going into read-only mode

These particular problems were reported by Cisco and SAP and customers
as well. Cisco reported on RHEL4 U6 and SAP reported on SLES9 SP4 and
SLES10 SP2. We added these fixes on RHEL4 U6 and gave a private build
to IBM and Cisco. Cisco and IBM tested it for more than 15 days and
they reported that they did not see the issue so far. Before the fix,
Cisco used to see the issue within 5 days. We generated a patch for
SLES9 SP4 and SLES10 SP2 and submitted to Novell. Novell applied the
patch and gave a test build to SAP. SAP tested and reported that the
build is working properly.

We also tested in our lab using the tools "dishogsync", which is IO
stress tool and the tool was provided by Cisco.

Issue1: File System going into read-only mode

Root cause: The driver tends to not free the memory (FIB) when the
management request exits prematurely. The accumulation of such
un-freed memory causes the driver to fail to allocate anymore memory
(FIB) and hence return 0x70000 value to the upper layer, which puts
the file system into read only mode.

Fix details: The fix makes sure to free the memory (FIB) even if the
request exits prematurely hence ensuring the driver wouldn't run out
of memory (FIBs).


Issue2: False Raid Alert occurs

When the Physical Drives and Logical drives are reported as deleted or
added, even though there is no change done on the system

Root cause: Driver IOCTLs is signaled with EINTR while waiting on
response from the lower layers. Returning "EINTR" will never initiate
internal retry.

Fix details: The issue was fixed by replacing "EINTR" with
"ERESTARTSYS" for mid-layer retries.

Signed-off-by: Penchala Narasimha Reddy <ServeRAIDDriver@hcl.in>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 929a22a5 06-Apr-2009 Yang Hongyang <yanghy@cn.fujitsu.com>

dma-mapping: replace all DMA_31BIT_MASK macro with DMA_BIT_MASK(31)

Replace all DMA_31BIT_MASK macro with DMA_BIT_MASK(31)

Signed-off-by: Yang Hongyang<yanghy@cn.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 284901a9 06-Apr-2009 Yang Hongyang <yanghy@cn.fujitsu.com>

dma-mapping: replace all DMA_32BIT_MASK macro with DMA_BIT_MASK(32)

Replace all DMA_32BIT_MASK macro with DMA_BIT_MASK(32)

Signed-off-by: Yang Hongyang<yanghy@cn.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# fa195afe 27-Oct-2008 Alan Cox <alan@lxorguk.ukuu.org.uk>

[SCSI] Clean up my email address and use a single standard address for everything

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# a4576b5d 30-Apr-2008 Mark Salyzyn <Mark_Salyzyn@adaptec.com>

[SCSI] aacraid: Fix jbod operations scan issues

As JBOD devices (really just Simple Single Drive Volumes exported to
the SCSI channel) are managed, they fail to update correctly when the
driver triggers a SCSI scan. In addition, the ability to change
multiple arrays or JBODs at the same time was resulting in dropped
scans, set up a mechanism to issue a list of single target scans on a
single configuration change notification from the Firmware.

Performed some additional sundry cosmetic code style cleanups.

Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 0462590e 23-Apr-2008 Mark Salyzyn <Mark_Salyzyn@adaptec.com>

[SCSI] aacraid: Fix down_interruptible() to check the return value correctly

On Apr 21, 2008, at 8:42 PM, Yinghai Lu wrote:
> bisected to:
>
> commit e6990c6448ca9359b6d4ad027c0a6efbf4379e64
> Author: Mark Salyzyn <Mark_Salyzyn@adaptec.com>
> Date: Mon Apr 14 14:20:16 2008 -0400
>
> [SCSI] aacraid: Fix down_interruptible() to check the return value

The return value for down_interruptible was incorrectly checked!
updated patch enclosed.

Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 6188e10d 18-Apr-2008 Matthew Wilcox <willy@infradead.org>

Convert asm/semaphore.h users to linux/semaphore.h

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>


# e6990c64 14-Apr-2008 Mark Salyzyn <Mark_Salyzyn@adaptec.com>

[SCSI] aacraid: Fix down_interruptible() to check the return value

Instead of ignoring the return value in aac_fib_send() return 2 to
indicate to the layers above that fib transmission was aborted due to
timeout.

Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 36b8dd1b 28-Mar-2008 Marcin Slusarz <marcin.slusarz@gmail.com>

[SCSI] aacraid, ips: leX_add_cpu conversion

replace all:
little_endian_variable = cpu_to_leX(leX_to_cpu(little_endian_variable) +
expression_in_cpu_byteorder);
with:
leX_add_cpu(&little_endian_variable, expression_in_cpu_byteorder);
generated with semantic patch

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Acked-by: "Salyzyn, Mark" <Mark_Salyzyn@adaptec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 2f7ecc55 08-Feb-2008 Salyzyn, Mark <Mark_Salyzyn@adaptec.com>

[SCSI] aacraid: ignore adapter reset check polarity

The Adapter's Ignore Reset flag and insmod parameter boolean polarity
is incorrect in the driver.

Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# cb1042f2 17-Jan-2008 Salyzyn, Mark <Mark_Salyzyn@adaptec.com>

[SCSI] aacraid: add Voodoo Lite class of cards.

The cards being added are supported in a limited sense already through
family matching, but we needed to add some functionality to the driver
to expose selectively the physical drives. These Physical drives are
specifically marked to not be part of any array and thus are declared
JBODs (Just a Bunch Of Drives) for generic SCSI access.

We report that this is the second patch in a set of two, but merely
depends on the stand-alone functionality of the first patch which adds
in that case the ability to report a driver feature flag via sysfs. We
leverage that functionality by reporting that this driver now supports
this new JBOD feature for the controller so that the array management
applications may react accordingly and guide the user as they manage
the controller.

Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 8ce3eca4 16-Jan-2008 Salyzyn, Mark <Mark_Salyzyn@adaptec.com>

[SCSI] aacraid: remove pigs in space

I was amazed at how much embedded space was present in the aacraid
driver source files. Just selected five files from the set to clean up
for now and the attached patch swelled to 73K in size!

- Removed trailing space or tabs
- Removed spaces embedded within tabs
- Replaced leading 8 spaces with tabs
- Removed spaces before )
- Removed ClusterCommand as it was unused (noticed it as one triggered by above)
- Replaced scsi_status comparison with 0x02, to compare against SAM_STATUS_CHECK_CONDITION.
- Replaced a long series of spaces with tabs
- Replaced some simple if...defined() with ifdef/ifndef

Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 0995ad38 11-Jan-2008 Salyzyn, Mark <Mark_Salyzyn@adaptec.com>

[SCSI] aacraid: respond to enclosure service events

Added support to respond to enclosure service events
(controller AIFs) to add, online or offline physical targets
reported to sg. Also added online and offlining of arrays.
Removed an automatic variable definition in a sub block that
hid an earlier definition, determined to be inert as the
sub-block use did not interfere. Bumped the driver versioning
to stamp the addition of this feature.

Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# b6ef70f3 08-Jan-2008 Salyzyn, Mark <Mark_Salyzyn@adaptec.com>

[SCSI] aacraid: OS panic after Adapter panic (hardening).

In experiments in the lab we managed to trigger an Adapter firmware
panic (BlinkLED) coincidentally while several pass-through ioctl
command from the management software were outstanding on a bug only
present on a class of RAID Adapters that require a hardware reset
rather than a commanded reset. The net result was an attempt to time
out the management software command as if it came from the SCSI layer
resulting in an OS panic.

Adapters that use commanded reset, management commands are returned
failed by the Adapter correctly. The adapter firmware panic that
resulted in this condition was also resolved, and there were no
adapters in the field with this specific firmware bug so we do not
expect any field reports. This is a rare or unlikely corner condition,
and no reports have ever been forwarded from the field.

Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# a3940da5 08-Jan-2008 Salyzyn, Mark <Mark_Salyzyn@adaptec.com>

[SCSI] aacraid: fix big endian issues

Big endian systems issues discovered in the aacraid driver. Somewhat
reverses a patch from November 7th of last year that removed swap
operations because they formerly were being assigned to an u8 array
when they should have been assigned to an le32 array.

This patch is largely inert for any little endian processor
architecture. It resolves a bug in delivering the BlinkLED AIF event
to registered applications when the adapter or associated hardware was
reset due to ill health. A rare corner case occurrence, also largely
unnoticed by any as it was a new (untested!) feature.

Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 95e852e1 08-Jan-2008 Salyzyn, Mark <Mark_Salyzyn@adaptec.com>

[SCSI] aacraid: add parameter to control FUA and SYNCHRONIZE_CACHE policy

aacraid.cache parameter, Disable Queue Flush commands:
bit 0 - Disable FUA in WRITE SCSI commands
bit 1 - Disable SYNCHRONIZE_CACHE SCSI command
bit 2 - Disable only if Battery not protecting adapter supplied Cache

e.g.: aacraid.cache=7 will disable the FUA and SYNCHRONIZE_CACHE
commands if the adapter has reported that it's cache is battery backed
up.

This parameter permits experimentation with tradeoffs between
performance and caching policy.

Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 94cf6ba1 13-Dec-2007 Salyzyn, Mark <mark_salyzyn@adaptec.com>

[SCSI] aacraid: fix driver failure with Dell PowerEdge Expandable RAID Controller 3/Di

As reported in http://bugzilla.kernel.org/show_bug.cgi?id=3D9133 it was
discovered that the PERC line of controllers lacked a key 64 bit
ScatterGather capable SCSI pass-through function. The adapters are still
capable of 64 bit ScatterGather I/O commands, but these two can not be
mixed. This problem was exacerbated by the introduction of the SCSI
Generic access to the DASD physical devices.

The fix for users before this patch is applied is aacraid.dacmode=3D0 on
the kernel command line to disable 64 bit I/O.

The enclosed patch introduces a new adapter quirk and tries to limp
along by enabling pass-through in situations where memory is 32 bit
addressable on 64 bit machines, or disable the pass-through functions
altogether. I expect that the check for 32 bit addressable memory to be
controversial in that it can be incorrect in non-Dell non-Intel systems
that PERC would never be installed under, the alternative is to disable
pass-through in all cases which could be reported as another regression.

Pass-through is used for SCSI Generic access to the physical devices, or
for the management applications to properly function.

In systems where this patch has disabled pass-through because it is
unsupportable in combination with I/O performance, the user can choose
to enable pass-through by turning off dacmode (aacraid.dacmode=3D0) or
limiting the discovered kernel memory (mem=3D4G) with an associated loss
in runtime performance. If we chose instead to turn off 64 bit dacmode
for the adapters with this quirk, then this would be reported as another
regression.

Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# f3307f72 08-Nov-2007 Christoph Hellwig <hch@infradead.org>

[SCSI] aacraid: don't assign cpu_to_le32(int) to u8

On Wed, Nov 07, 2007 at 01:51:44PM -0500, Salyzyn, Mark wrote:
> Christoph Hellwig [mailto:hch@infradead.org] sez:
> > Did anyone run the driver through sparse to see if we have
> > more issues like this?
>
> There are some warnings from sparse, none like this one. I will deal
> with the warnings ...

Actually there are a lot of endianess warnings, fortunately most of them
harmless. The patch below fixes all of them up (including the ones in
the patch I replied to), except for aac_init_adapter which is really odd
and I don't know what to do.

[jejb fixed up rejections and checkpatch issues]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Mark Salyzyn <mark_salyzyn@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# f858317d 30-Oct-2007 Salyzyn, Mark <mark_salyzyn@adaptec.com>

[SCSI] aacraid: forced reset override

Some of our vendors have requested that our adapters ignore the hardware
reset attempts during recovery and have enforced this with changes in
Adapter Firmware. Some of our customers have requested the option to be
able to reset the adapter under adverse adapter failure, we even had a
few defects reported here considering it a regression that the Adapter
could not be reset. This patch addresses this dichotomy. The user can
force the adapter to be reset if it supports the IOP_RESET_ALWAYS
command, in cases where the adapter has been programmed to ignore the
reset, by setting the aacraid.check_reset parameter to a value of -1.

The driver will not reset an Adapter that does not support the reset
command(s).

This patch also fixes and cleans up some of the logic associated with
resetting the adapter.

Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: James <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# e6096963 07-Nov-2007 Salyzyn, Mark <mark_salyzyn@adaptec.com>

[SCSI] aacraid: fix up le32 issues in BlinkLED

Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 3b2d8712 01-Nov-2007 Stephen Rothwell <sfr@canb.auug.org.au>

[SCSI] aacraid: don't assign cpu_to_le32(constant) to u8

Noticed on PowerPC allmod config build:

drivers/scsi/aacraid/commsup.c:1342: warning: large integer implicitly truncated to unsigned type
drivers/scsi/aacraid/commsup.c:1343: warning: large integer implicitly truncated to unsigned type
drivers/scsi/aacraid/commsup.c:1344: warning: large integer implicitly truncated to unsigned type

Also fix some whitespace on the changed lines.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Acked-by: Mark Salyzyn <mark_salyzyn@adaptec.com>
Signed-off-by: James <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 87f3bda3 10-Aug-2007 Andrew Morton <akpm@linux-foundation.org>

[SCSI] aacraid: rename check_reset

Too generic, clashes with ISDN.

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 9ad5204d 17-Jul-2007 Salyzyn, Mark <mark_salyzyn@adaptec.com>

[SCSI] aacraid: incorrect dma mapping mask during blinkled recover or user initiated reset

Incorrect dma mask was used for blinkled (firmware assert) recovery or
user initiated reset during initialization portion. Ensure that all
callers of aac_fib_map_free null out the fib allocation references to
prevent multiple free. Although serious sounding, no reports of these
problems have surfaced...

Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 29c97684 12-Jun-2007 Salyzyn, Mark <mark_salyzyn@adaptec.com>

[SCSI] aacraid: add user initiated reset

Add the ability for an application to issue a hardware reset to the
adapter via sysfs. Typical uses include restarting the adapter after it
has been flashed. Bumped revision number for the driver and added a
feature to periodically check the adapter's health (check_interval),
update the adapter's concept of time (update_interval) and block
checking/resetting of the adapter (check_reset).

Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 4dbc22d7 16-Apr-2007 Salyzyn, Mark <mark_salyzyn@adaptec.com>

[SCSI] aacraid: kmalloc/memset->kzalloc

Inspired somewhat by Vignesh Babu <vignesh.babu@wipro.com> patch to
dpt_i2o.c to replace kmalloc/memset sequences with kzalloc, doing the
same for the aacraid driver.

Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 912d4e88 26-Mar-2007 Salyzyn, Mark <mark_salyzyn@adaptec.com>

[SCSI] aacraid: Add likely() and unlikely()

Add some likely() and unlikely() compiler hints in some of the aacraid
hardware interface layers. There should be no operational side effects
resulting from this patch and the changes should be mostly benign on x86
platforms.

Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 03d44337 15-Mar-2007 Mark Haverkamp <markh@linux-foundation.org>

[SCSI] aacraid: Improved error handling

Received from Mark Salyzyn,

This set of fixes improve error handling stability of the driver. A popular
manifestation of the problems is an NULL pointer reference in the interrupt
handler when referencing portions of the scsi command context, or in the
scsi_done handling when an offlined device is referenced.

The aacraid driver currently does not get notification of orphaned command
completions due to devices going offline. The driver also fails to handle the
commands that are finished by the error handler, and thus can complete again
later at the hands of the adapter causing situations of completion of an
invalid scsi command context. Test Unit Ready calls abort assuming that the
abort was successful, but are not, and thus when the interrupt from the adapter
occurs, they reference invalid command contexts. We add in a TIMED_OUT flag to
inform the aacraid FIB context that the interrupt service should merely release
the driver resources and not complete the command up. We take advantage of this
with the abort handler as well for select abortable commands. And we detect and
react if a command that can not be aborted is currently still outstanding to
the controller when reissued by the retry mechanism.

Signed-off-by: Mark Haverkamp <markh@linux-foundation.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 33bb3b29 15-Mar-2007 Mark Haverkamp <markh@linux-foundation.org>

[SCSI] aacraid: Fix ioctl handling when adapter resets

Received from Mark Salyzyn,

Outstanding ioctl calls still have some problems with aborting cleanly
in the face of a reset iop recovery action should the adapter ever enter
into a Firmware Assert (BlinkLED) condition. The enclosed patch resolves
some uncovered flawed handling.

Signed-off-by: Mark Haverkamp <markh@linux-foundation.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# a8166a52 15-Mar-2007 Mark Haverkamp <markh@linux-foundation.org>

[SCSI] aacraid: Fix struct element name issue

Received from Mark Salyzyn,

This patch is to resolve a namespace issue that will result from a patch
expected in the future that adds a new interface; rationalized as
correcting a long term issue where hw_fib, instead of hw_fib_va, refers
to the virtual address space and hw_fib_pa refers to the physical
address space. A small fragment of this patch also cleans up an unused
variable that was close to the patch fragments.

Signed-off-by: Mark Haverkamp <markh@linux-foundation.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 8418852d 15-Mar-2007 Mark Haverkamp <markh@linux-foundation.org>

[SCSI] aacraid: add restart adapter platform function

Received from Mark Salyzyn,

This patch updates the adapter restart function to deal with some
adapters that have specific IOP reset needs. Since the code for
restarting the adapter was in two places, changed over to utilizing a
platform function in one place.

Signed-off-by: Mark Haverkamp <markh@linux-foundation.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 28713324 23-Jan-2007 Mark Haverkamp <markh@linux-foundation.org>

[SCSI] aacraid: rework communication support code

Received from Mark Salyzyn,

Replace all if/else communication transports with a platform function call.
This is in recognition of the need to migrate to up-and-coming transports.
Currently the Linux driver does not support two available communication
transports provided by our products, these will be added in future patches, and
will expand the platform function set.

Signed-off-by Mark Haverkamp <markh@linux-foundation.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# d18b448f 21-Nov-2006 Mark Haverkamp <markh@osdl.org>

[SCSI] aacraid: Abort management FIBs

Received from Mark Salyzyn:

Add code to abort outstanding management ioctl fibs when the blinkLED recovery
is performed. This code is 'clunky' and does not have any real feedback in that
the reset could progress before the user application has gotten it's
notification of command completion. We put a schedule() call to delay just the
right amount for most cases, because we tried a spin and still managed to find
cases where we would spin forever waiting for the management application to
acknowledge the impending doom surrounding the cause of the BlinkLED. Will
cause an oops in the context of the management application if we proceed too
quickly. I view this as the lesser of many evils since currently if there are
outstanding management ioctls during a need to reset/recover the adapter, the
management application just locks up and waits forever. The best practices fix
for this problem not going to be simple or easy (at least the fixes I imagine
today); and we found a balance between the needs of the driver to proceed, and
the applications that locked or confused that would hold back the driver. I
just do not like the idea of a kernel oops in an application to deal with low
priority, sluggish or misbehaving applications.

Signed-off-by: Mark Haverkamp <markh@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 33524b70 21-Nov-2006 Mark Haverkamp <markh@osdl.org>

[SCSI] aacraid: Detect Blinkled at startup

Received from Mark Salyzyn:

Blinkled at startup is useful for catching Adapters in a lot of pain, in a
BlinkLED assert, quickly; rather than waiting several minutes for commands to
timeout.

Signed-off-by: Mark Haverkamp <markh@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 6a3670c4 24-Sep-2006 Al Viro <viro@ftp.linux.org.uk>

[PATCH] missing include (free_irq() use)

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# ac5826ca 19-Sep-2006 Mark Haverkamp <markh@osdl.org>

[SCSI] aacraid: remove scsi_remove_device

Received from Mark Salyzyn:

Until the system is stabilized, I am suggesting the enclosed
modification to prevent the driver from tickling the panic. Once sysfs
and friends are stabilized, the patch may be backed out. We have yet to
evaluate if we really want to relinquish existing Scsi Devices in any
case, holding on to them as configuration of arrays comes and goes makes
some sense as well. As a result, we have opted to pull the lines rather
than comment them in legacy.

Signed-off-by: Mark Haverkamp <markh@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 65101355 19-Sep-2006 Mark Haverkamp <markh@osdl.org>

[SCSI] aacraid: misc cleanup

Received from Mark Salyzyn:

Basically cleanup, nothing here will have an affect. Adjusting some
error codes, removing superfluous definitions and code fragments.

Signed-off-by: Mark Haverkamp <markh@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 8c867b25 03-Aug-2006 Mark Haverkamp <markh@osdl.org>

[SCSI] aacraid: Reset adapter in recovery timeout

Received from Mark Salyzyn

If the adapter is in blinkled (Firmware Assert) when error recovery
timeout actions have been triggered, perform an adapter warm reset and
restart the initialization.

Signed-off-by: Mark Haverkamp <markh@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# c8f7b073 03-Aug-2006 Mark Haverkamp <markh@osdl.org>

[SCSI] aacraid: interruptible ioctl

Received from Mark Salyzyn

This patch allows the FSACTL_SEND_LARGE_FIB, FSACTL_SENDFIB and
FSACTL_SEND_RAW_SRB ioctl calls into the aacraid driver to be
interruptible. Only necessary if the adapter and/or the management
software has gone into some sort of misbehavior and the system is being
rebooted, thus permitting the user management software applications to
be killed relatively cleanly. The FIB queue resource is held out of the
free queue until the adapter finally, if ever, completes the command.

Signed-off-by: Mark Haverkamp <markh@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 125e1874 23-Jun-2006 Eric Sesterhenn <snakebyte@gmx.de>

[PATCH] More BUG_ON conversion

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Acked-by: "Salyzyn, Mark" <mark_salyzyn@adaptec.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 5b9851b5 10-May-2006 Mark Haverkamp <markh@osdl.org>

[SCSI] aacraid: remove unneeded list

Received From Mark Salyzyn

The queue tracking is just not being used, not even for debugging. Information
about outstanding commands can be acquired from the scsi structures.

Signed-off-by: Mark Haverkamp <markh@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 404d9a90 10-May-2006 Mark Haverkamp <markh@osdl.org>

[SCSI] aacraid: adjustable timeouts

Received From Mark Salyzyn

Add the ability to adjust for unusual corner case failures. Both of
these additional module parameters deal with embedded, non-intel or
complicated system scenarios.

Aif_timeout can be increased past the default 2 minute timeout to drop
application registrations when a system has an unusually high event load
resulting from continuing management requests, or simultaneous builds,
or sluggish user space as a result of system load.

Startup_timeout can be increased past the default 3 minute timeout to
drop an adapter initialization for systems that have a very large number
of targets, or slow to spin-up targets, or a complicated set of array
configurations that extend the time for the firmware to declare that it
is operational. This timeout would only have an affect on non-intel
based systems, as the (more patient) BIOS would generally be where the
startup delay would be dealt with.

Signed-off-by: Mark Haverkamp <markh@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 1241f359 27-Mar-2006 Mark Haverkamp <markh@osdl.org>

[SCSI] aacraid: General driver cleanup

Received from Mark Salyzyn

Remove superfluous code, optimize code, harden code, cast code, correct
some text, use msleep instead of schedule_timeout_interruptible. No
bugs.

Signed-off-by: Mark Haverkamp <markh@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 31876f32 27-Mar-2006 Mark Haverkamp <markh@osdl.org>

[SCSI] aacraid: Add timeout for events

Received from Mark Salyzyn

Plug and play actions resulting from event sequences shall time out if
they take longer than 30 seconds to complete.

Signed-off-by: Mark Haverkamp <markh@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# fe27381d 14-Feb-2006 Christoph Hellwig <hch@lst.de>

[SCSI] aacraid: use kthread_ API

Use the kthread_ API instead of opencoding lots of hairy code for kernel
thread creation and teardown.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Salyzyn, Mark <mark_salyzyn@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 164006da 30-Nov-2005 Al Viro <viro@zeniv.linux.org.uk>

[PATCH] bogus asm/delay.h includes

asm/delay.h is non-portable; linux/delay.h should be used in generic code.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# bfb35aa8 01-Feb-2006 Mark Haverkamp <markh@osdl.org>

[SCSI] aacraid: Update global function names

Received from Mark Salyzyn,

Reduce the possibility of namespace collision. Prefix with aac_.

Signed-off-by: Mark Haverkamp <markh@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# f64a181d 31-Oct-2005 Christoph Hellwig <hch@lst.de>

[SCSI] remove Scsi_Device typedef

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# c9475cb0 07-Nov-2005 Jesper Juhl <jesper.juhl@gmail.com>

[PATCH] kfree cleanup: drivers/scsi

This is the drivers/scsi/ part of the big kfree cleanup patch.

Remove pointless checks for NULL prior to calling kfree() in drivers/scsi/.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Acked-by: Kai Makisara <kai.makisara@kolumbus.fi>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 8e0c5ebd 24-Oct-2005 Mark Haverkamp <markh@osdl.org>

[SCSI] aacraid: Newer adapter communication iterface support

Received from Mark Salyzyn.

This patch adds the 'new comm' interface, which modern AAC based
adapters that are less than a year old support in the name of much
improved performance. These modern adapters support both the legacy and
the 'new comm' interfaces.

Signed-off-by: Mark Haverkamp <markh@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 1640a2c3 20-Sep-2005 Mark Haverkamp <markh@osdl.org>

[SCSI] aacraid: remove aac_insert_entry

Received from Mark Salyzyn from Adaptec.

High Priority Queues have *never* been used in the entire history of the
aac based adapters. Associated with this, aac_insert_entry can be
removed, SavedIrql can be removed & padding variable can be removed.
With the movement of SavedIrql out & replaced with an automatic variable
qflags, the locking can be refined somewhat. The sparse warnings did not
catch the need for byte swapping in the 'dprintk' debugging print
macros, so fixed this up when this code was moved outside of the now
refined locking.

Signed-off-by: Mark Haverkamp <markh@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 9203344c 20-Sep-2005 Mark Haverkamp <markh@osdl.org>

[SCSI] aacraid: initialization timeout

Received from Mark Salyzyn from Adaptec.

In the rare instances where the adapter, or the motherboard, is
misbehaving; driver initialization or shutdown becomes problematic. By
introducing a 3 minute timeout on the first interrupt driven command
during initialization, or the issuance of the adapter shutdown command
during driver unload, we can resolve the lockup problems induced by
common (but rare) hardware misbehaviors.

The timeout during initialization, should it occur, is accompanied by a
message presented to the console and the logs indicating that the user
should inspect and resolve problems with interrupt routing.

Signed-off-by: Mark Haverkamp <markh@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 131256cf 26-Sep-2005 Mark Haverkamp <markh@osdl.org>

[SCSI] aacraid: handle AIF hotplug events (update)

Received from Mark Salyzyn from Adaptec.

Hotplug sniffs the AIFs (events) from the adapter and if a container
change resulting in the device going offline (container zero), online
(container zero completed) or changing capacity (morph) it will take
actions by calling the appropriate API.

Signed-off-by: Mark Haverkamp <markh@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 2f130980 26-Sep-2005 Mark Haverkamp <markh@osdl.org>

[SCSI] aacraid: aacraid: AIF preallocation (update)

Recevied from Mark Salyzyn from Adaptec.

Aif pre-allocation is used to pull the kmalloc outside of the locks.

Applies to the scsi-misc-2.6 git tree.

Signed-off-by: Mark Haverkamp <markh@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# bed30de4 03-Aug-2005 Mark Haverkamp <markh@osdl.org>

[SCSI] aacraid: interupt mitigation

Received from Mark Salyzyn from Adaptec:

If more than two commands are outstanding to the controller, there is no
need to notify the adapter via a PCI bus transaction of additional
commands added into the queue; it will get to them when it works through
the produce/consumer indexes.

This reduced the PCI traffic in the driver to submit a command to the
queue to near zero allowing a significant number of commands to be
turned around with no need to block for the PCI bridge to flush the
notify request to the adapter.

Interrupt mitigation has always been present in the driver; it was
turned off because of a bug that prevented one from realizing the
usefulness of the feature. This bug is fixed in this patch.

Signed-off-by: Mark Haverkamp <markh@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 7c00ffa3 16-May-2005 Mark Haverkamp <markh@osdl.org>

[SCSI] 2.6 aacraid: Variable FIB size (updated patch)

New code from the Adaptec driver. Performance enhancement for newer
adapters. I hope that this isn't too big for a single patch. I believe
that other than the few small cleanups mentioned, that the changes are
all related.

- Added Variable FIB size negotiation for new adapters.
- Added support to maximize scatter gather tables and thus permit
requests larger than 64KB/each.
- Limit Scatter Gather to 34 elements for ROMB platforms.
- aac_printf is only enabled with AAC_QUIRK_34SG
- Large FIB ioctl support
- some minor cleanup

Passes sparse check.
I have tested it on x86 and ppc64 machines.

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 56b58712 27-Apr-2005 Mark Haverkamp <markh@osdl.org>

[SCSI] aacraid: remove sparse warnings

This patch addresses the sparse -Wbitwise warnings that Christoph wanted
me to eliminate. This mostly consisted of making data structure
elements of hardware associated structures the __le* equivalent.
Although there were a couple places where there was mixing of cpu and le
variable math. These changes have been tested on both an x86 and ppc
machine running bonnie++. The usage of the LE32_ALL_ONES macro has been
eliminated.

Signed-off-by: Mark Haverkamp <markh@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 4833869e 25-Apr-2005 Adrian Bunk <bunk@stusta.de>

[SCSI] drivers/scsi/aacraid/: make some functions static

This patch makes some needlessly global functions static.

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 1da177e4 16-Apr-2005 Linus Torvalds <torvalds@ppc970.osdl.org>

Linux-2.6.12-rc2

Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!