History log of /linux-master/drivers/message/fusion/mptbase.c
Revision Date Author Comments
# dbe37c71 30-May-2023 Azeem Shaikh <azeemshaikh38@gmail.com>

scsi: message: fusion: Replace all non-returning strlcpy() with strscpy()

strlcpy() reads the entire source buffer first. This read may exceed the
destination size limit. This is both inefficient and can lead to linear
read overflows if a source string is not NUL-terminated [1]. In an effort
to remove strlcpy() completely [2], replace strlcpy() here with strscpy().
No return values were used, so direct replacement is safe.

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy
[2] https://github.com/KSPP/linux/issues/89

Signed-off-by: Azeem Shaikh <azeemshaikh38@gmail.com>
Link: https://lore.kernel.org/r/20230530160248.411637-1-azeemshaikh38@gmail.com
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 6e36a56a 12-Apr-2023 Josh Poimboeuf <jpoimboe@kernel.org>

scsi: message: fusion: Mark mpt_halt_firmware() __noreturn

mpt_halt_firmware() doesn't return. Mark it as such.

Fixes the following warnings:

vmlinux.o: warning: objtool: mptscsih_abort+0x7f4: unreachable instruction
vmlinux.o: warning: objtool: mptctl_timeout_expired+0x310: unreachable instruction

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Mark Rutland <mark.rutland@arm.com>
Debugged-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/d8129817423422355bf30e90dadc6764261b53e0.1681342859.git.jpoimboe@kernel.org


# 61144d83 17-Mar-2022 Colin Ian King <colin.king@intel.com>

scsi: message: fusion: Remove redundant variable dmp

Variable dmp is being assigned a value that is never read, the variable is
redundant and can be removed.

Cleans up clang scan build warning:
drivers/message/fusion/mptbase.c:6667:39: warning: Although
the value stored to 'dmp' is used in the enclosing expression,
the value is never actually read from 'dmp' [deadcode.DeadStores]

Link: https://lore.kernel.org/r/20220318003927.81471-1-colin.i.king@gmail.com
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 5c5e6b6f 06-Jan-2022 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

scsi: message: fusion: mptbase: Use dma_alloc_coherent()

In [1], Christoph Hellwig has proposed to remove the wrappers in
include/linux/pci-dma-compat.h.

Some reasons why this API should be removed have been given by Julia
Lawall in [2].

In all these places where some memory is allocated GFP_KERNEL can be used
because they already call mpt_config() which has an explicit might_sleep().

[1]: https://lore.kernel.org/kernel-janitors/20200421081257.GA131897@infradead.org/
[2]: https://lore.kernel.org/kernel-janitors/alpine.DEB.2.22.394.2007120902170.2424@hadrien/

Link: https://lore.kernel.org/r/3bea2452deb8cc8be65982e87efa4c6861caa01c.1641500561.git.christophe.jaillet@wanadoo.fr
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 2d506072 06-Jan-2022 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

scsi: message: fusion: Use dma_alloc_coherent() in mpt_alloc_fw_memory()

In [1], Christoph Hellwig has proposed to remove the wrappers in
include/linux/pci-dma-compat.h.

Some reasons why this API should be removed have been given by Julia Lawall
in [2].

mpt_alloc_fw_memory() should still use GFP_ATOMIC, because it can be called
from mpt_do_upload() which might sleep.

[1]: https://lore.kernel.org/kernel-janitors/20200421081257.GA131897@infradead.org/
[2]: https://lore.kernel.org/kernel-janitors/alpine.DEB.2.22.394.2007120902170.2424@hadrien/

Link: https://lore.kernel.org/r/db3db9db219005b75659561d08117d312d0cfb13.1641500561.git.christophe.jaillet@wanadoo.fr
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# b114dda6 06-Jan-2022 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

scsi: message: fusion: Remove usage of the deprecated "pci-dma-compat.h" API

In [1], Christoph Hellwig has proposed to remove the wrappers in
include/linux/pci-dma-compat.h.

Some reasons why this API should be removed have been given by Julia Lawall
in [2].

A coccinelle script has been used to perform the needed transformation. It
can be found in [3].

In this patch, all functions but pci_alloc_consistent() are handled.
pci_alloc_consistent() needs more attention and explanation.

[1]: https://lore.kernel.org/kernel-janitors/20200421081257.GA131897@infradead.org/
[2]: https://lore.kernel.org/kernel-janitors/alpine.DEB.2.22.394.2007120902170.2424@hadrien/
[3]: https://lore.kernel.org/kernel-janitors/20200716192821.321233-1-christophe.jaillet@wanadoo.fr/

Link: https://lore.kernel.org/r/e38e897fbd3314718315b0e357c824e3f01775d6.1641500561.git.christophe.jaillet@wanadoo.fr
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# c27fd25d 05-Dec-2021 Colin Ian King <colin.king@intel.com>

scsi: mptfusion: Remove redundant variable r

Variable r is being assigned a value that is never read. The assignment is
redundant and so is the variable, so remove these. Remove unnecessary the
{} braces in the if statement too.

Link: https://lore.kernel.org/r/20211205225901.54362-1-colin.i.king@gmail.com
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# a534ff3f 04-Oct-2021 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

scsi: message: fusion: Remove unused mpt_pci driver .probe() 'id' parameter

The only two drivers don't make use of the id parameter, so drop it. This
is a step toward removing pci_dev->driver.

Link: https://lore.kernel.org/r/20211004125935.2300113-9-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>


# 96f3903c 12-May-2021 Jiapeng Chong <jiapeng.chong@linux.alibaba.com>

scsi: message: fusion: Remove redundant assignment to rc

Variable rc is set to '-1', but this value is never read as it is
overwritten later. Hence it is a redundant assignment and can be removed.

Clean up the following clang-analyzer warning:

drivers/message/fusion/mptbase.c:6996:2: warning: Value stored to 'rc'
is never read [clang-analyzer-deadcode.DeadStores].

Link: https://lore.kernel.org/r/1620814327-25427-1-git-send-email-jiapeng.chong@linux.alibaba.com
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# c436b41a 08-Apr-2021 Jiapeng Chong <jiapeng.chong@linux.alibaba.com>

scsi: message: fusion: Remove unused local variable 'status'

Fix the following gcc warning:

drivers/message/fusion/mptbase.c:3087:9: warning: variable ‘status’ set
but not used [-Wunused-but-set-variable].

Link: https://lore.kernel.org/r/1617872780-126448-1-git-send-email-jiapeng.chong@linux.alibaba.com
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 690209d5 11-Mar-2021 Wang Qing <wangqing@vivo.com>

scsi: message: fusion: Remove unnecessary cast

Fix the following coccicheck warning:
WARNING: casting value returned by memory allocation function is useless.

Link: https://lore.kernel.org/r/1615515483-777-1-git-send-email-wangqing@vivo.com
Signed-off-by: Wang Qing <wangqing@vivo.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# b8a51443 26-Nov-2020 Thomas Gleixner <tglx@linutronix.de>

scsi: message: fusion: Remove in_interrupt() usage in mpt_config()

in_interrupt() is referenced all over the place in these drivers. Most of
these references are comments which are outdated and wrong.

Aside of that in_interrupt() is deprecated as it does not provide what the
name suggests. It covers more than hard/soft interrupt servicing context
and is semantically ill defined.

>From reading the mpt_config() code and the history this is clearly a debug
mechanism and should probably be replaced by might_sleep() or completely
removed because such checks are already in the subsequent functions.

Remove the in_interrupt() references and replace the usage in mpt_config()
with might_sleep().

Link: https://lore.kernel.org/r/20201126132952.2287996-14-bigeasy@linutronix.de
Cc: Sathya Prakash <sathya.prakash@broadcom.com>
Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
Cc: MPT-FusionLinux.pdl@broadcom.com
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# b9dd44fd 19-Oct-2020 Tom Rix <trix@redhat.com>

scsi: message: fusion: Remove unneeded break

A break is not needed if it is preceded by a return.

Link: https://lore.kernel.org/r/20201019191950.10244-1-trix@redhat.com
Signed-off-by: Tom Rix <trix@redhat.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>


# 311950f8 24-Jun-2020 Christoph Hellwig <hch@lst.de>

scsi: mptfusion: Don't use GFP_ATOMIC for larger DMA allocations

The mpt fusion driver still uses the legacy PCI DMA API which hardcodes
atomic allocations. This caused the driver to fail to load on some powerpc
VMs with incoherent DMA and small memory sizes. Switch to use the modern
DMA API and sleeping allocations for large allocations instead. This is
not a full cleanup of the PCI DMA API usage yet, but just enough to fix the
regression caused by reducing the default atomic pool size.

Link: https://lore.kernel.org/r/20200624165724.1818496-1-hch@lst.de
Fixes: 3ee06a6d532f ("dma-pool: fix too large DMA pools on medium memory size systems")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 4e2dec66 08-Apr-2020 Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

scsi: docs: fusion: get rid of a doc build warning

Use a table for the enum list, to avoid this warning:

./drivers/message/fusion/mptbase.c:5058: WARNING: Definition list ends without a blank line; unexpected unindent.

Link: https://lore.kernel.org/r/9ca049c2d25689c56448afddf4f0d1e619fa87f7.1586359676.git.mchehab+huawei@kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# b3b2a9f6 22-May-2019 Bharath Vedartham <linux.bhar@gmail.com>

scsi: message: fusion: Use kmemdup instead of memcpy and kmalloc

Replace kmalloc + memcpy with kmemdup.

This was reported by coccinelle.

Signed-off-by: Bharath Vedartham <linux.bhar@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# b47b8618 11-Feb-2019 Gustavo A. R. Silva <gustavo@embeddedor.com>

scsi: mptfusion: mark expected switch fall-through

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where
we are expecting to fall through.

This patch fixes the following warning:

drivers/message/fusion/mptbase.c: In function mptbase_reply :
drivers/message/fusion/mptbase.c:643:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
if (event != MPI_EVENT_EVENT_CHANGE)
^
drivers/message/fusion/mptbase.c:646:2: note: here
case MPI_FUNCTION_CONFIG:
^~~~

Warning level 3 was used: -Wimplicit-fallthrough=3

Notice that, in this particular case, the code comment is modified in
accordance with what GCC is expecting to find.

This patch is part of the ongoing efforts to enable
-Wimplicit-fallthrough.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 90ded4e2 15-Sep-2018 Nathan Chancellor <nathan@kernel.org>

scsi: mptfusion: Remove unnecessary parentheses

Clang warns when multiple pairs of parentheses are used for a single
conditional statement.

drivers/message/fusion/mptbase.c:338:11: warning: equality comparison
with extraneous parentheses [-Wparentheses-equality]
if ((ioc == NULL))
~~~~^~~~~~~
drivers/message/fusion/mptbase.c:338:11: note: remove extraneous
parentheses around the comparison to silence this warning
if ((ioc == NULL))
~ ^ ~
drivers/message/fusion/mptbase.c:338:11: note: use '=' to turn this
equality comparison into an assignment
if ((ioc == NULL))
^~
=
drivers/message/fusion/mptbase.c:342:12: warning: equality comparison
with extraneous parentheses [-Wparentheses-equality]
if ((pdev == NULL))
~~~~~^~~~~~~
drivers/message/fusion/mptbase.c:342:12: note: remove extraneous
parentheses around the comparison to silence this warning
if ((pdev == NULL))
~ ^ ~
drivers/message/fusion/mptbase.c:342:12: note: use '=' to turn this
equality comparison into an assignment
if ((pdev == NULL))
^~
=
2 warnings generated.

Remove them and while we're at it, simplify the NULL checks as '!var' is
used more than 'var == NULL'.

Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 94e989de 10-Sep-2018 Colin Ian King <colin.king@canonical.com>

scsi: message: fusion: fix a few trivial spelling mistakes

Trival fix to spelling mistakes:

PrimativeSeqErrCount -> PrimitiveSeqErrCount
Primative -> Primitive
primative -> primitive
mptsas_broadcast_primative_work -> mptsas_broadcast_primitive_work
Broadcase -> Broadcast

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


# 50838500 26-Jul-2018 Jia-Ju Bai <baijiaju1990@gmail.com>

scsi: message: fusion: Replace GFP_ATOMIC with GFP_KERNEL

mpt_attach() and mptfc_probe() are never called in atomic context. They
call kzalloc() and kcalloc() with GFP_ATOMIC, which is not necessary.
GFP_ATOMIC can be replaced with GFP_KERNEL.

This is found by a static analysis tool named DCNS written by myself.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# fc21ae89 03-Jul-2018 Gustavo A. R. Silva <gustavo@embeddedor.com>

scsi: mptfusion: mark expected switch fall-throughs

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where
we are expecting to fall through.

Warning level 2 was used: -Wimplicit-fallthrough=2

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 3f3942ac 15-May-2018 Christoph Hellwig <hch@lst.de>

proc: introduce proc_create_single{,_data}

Variants of proc_create{,_data} that directly take a seq_file show
callback and drastically reduces the boilerplate code in the callers.

All trivial callers converted over.

Signed-off-by: Christoph Hellwig <hch@lst.de>


# b9315530 02-May-2018 Colin Ian King <colin.king@canonical.com>

scsi: mptfusion: fix spelling mistake: "initators" -> "initiators"

Trivial fix to spelling mistake in text string.

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


# 6f5c592c 08-Jan-2018 Xiongfeng Wang <xiongfeng.wang@linaro.org>

scsi: mptfusion: use strlcpy() instead of strncpy()

gcc-8 reports

drivers/message/fusion/mptbase.c: In function 'mpt_display_event_info':
./include/linux/string.h:245:9: warning: '__builtin_strncpy' specified
bound 100 equals destination size [-Wstringop-truncation]

We need to use strlcpy() to make sure the dest string is nul-terminated.

Signed-off-by: Xiongfeng Wang <xiongfeng.wang@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# afcfa2c8 06-Dec-2017 Colin Ian King <colin.king@canonical.com>

scsi: fusion: clean up some indentations

There are several places where the source is not indented correctly with
either too many or too few levels of intentation. Fix these.

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


# e4dca7b7 17-Oct-2017 Kees Cook <keescook@chromium.org>

treewide: Fix function prototypes for module_param_call()

Several function prototypes for the set/get functions defined by
module_param_call() have a slightly wrong argument types. This fixes
those in an effort to clean up the calls when running under type-enforced
compiler instrumentation for CFI. This is the result of running the
following semantic patch:

@match_module_param_call_function@
declarer name module_param_call;
identifier _name, _set_func, _get_func;
expression _arg, _mode;
@@

module_param_call(_name, _set_func, _get_func, _arg, _mode);

@fix_set_prototype
depends on match_module_param_call_function@
identifier match_module_param_call_function._set_func;
identifier _val, _param;
type _val_type, _param_type;
@@

int _set_func(
-_val_type _val
+const char * _val
,
-_param_type _param
+const struct kernel_param * _param
) { ... }

@fix_get_prototype
depends on match_module_param_call_function@
identifier match_module_param_call_function._get_func;
identifier _val, _param;
type _val_type, _param_type;
@@

int _get_func(
-_val_type _val
+char * _val
,
-_param_type _param
+const struct kernel_param * _param
) { ... }

Two additional by-hand changes are included for places where the above
Coccinelle script didn't notice them:

drivers/platform/x86/thinkpad_acpi.c
fs/lockd/svc.c

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jessica Yu <jeyu@kernel.org>


# b192b42a7 17-Jul-2017 Arnd Bergmann <arnd@arndb.de>

scsi: fusion: fix string overflow warning

gcc points out a theorerical string overflow:

drivers/message/fusion/mptbase.c: In function 'mpt_detach':
drivers/message/fusion/mptbase.c:2103:17: error: '%s' directive writing up to 31 bytes into a region of size 28 [-Werror=format-overflow=]
sprintf(pname, MPT_PROCFS_MPTBASEDIR "/%s/summary", ioc->name);
^~~~~
drivers/message/fusion/mptbase.c:2103:2: note: 'sprintf' output between 13 and 44 bytes into a destination of size 32

We can simply double the size of the local buffer here to be on the
safe side, and using snprintf() instead of sprintf() protects us
if ioc->name was not terminated properly.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 6b8accea 22-Apr-2017 Colin Ian King <colin.king@canonical.com>

scsi: fusion: fix spelling mistake: "Persistancy" -> "Persistency"

trivial fix to spelling mistake

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


# 4aaa4065 17-Nov-2016 Helge Deller <deller@gmx.de>

scsi: mptfusion: Fix printk continuations

Fix the printk continuations when running the mptfusion driver.
This patch brings the capabilities into one single syslog line again:
mptbase: ioc1: Initiating bringup
ioc1: LSI53C1030 B2: Capabilities={Initiator,Target}
scsi host3: ioc1: LSI53C1030 B2, FwRev=01032341h, Ports=1, MaxQ=255, IRQ=67

Tested on a parisc C8000 machine.

Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# caf4ebcb 22-Oct-2016 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

scsi: fusion: print lan address via %pMR

LAN MAC addresses can be printed directly using %pMR specifier.

Cc: Sathya Prakash <sathya.prakash@broadcom.com>
Cc: Chaitra P B <chaitra.basappa@broadcom.com>
Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# b2990536 30-Aug-2016 Bhaktipriya Shridhar <bhaktipriya96@gmail.com>

scsi: mpt: Remove deprecated create_singlethread_workqueue

The workqueues "ioc->reset_work_q" and "ioc->fw_event_q" queue a single
work item &ioc->fault_reset_work and &fw_event->work, respectively and
hence don't require ordering. Hence, they have been converted to use
alloc_workqueue().

The WQ_MEM_RECLAIM flag has been set to ensure forward progress under
memory pressure since the workqueue belongs to a storage driver which is
being used on a memory reclaim path.

Since there are fixed number of work items, explicit concurrency limit
is unnecessary here.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# e8c61ecc 23-Feb-2016 Ewan D. Milne <emilne@redhat.com>

mptbase: fixup error handling paths in mpt_attach()

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

Signed-off-by: Ewan D. Milne <emilne@redhat.com>
Reported-by: Insu Yun <wuninsu@gmail.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 28558f5a 27-Jan-2016 Arnd Bergmann <arnd@arndb.de>

mptfusion: hide unused seq_mpt_print_ioc_summary function

The seq_mpt_print_ioc_summary function is used for the
/proc/mpt/iocN/summary implementation and never gets called when
CONFIG_PROC_FS is disabled:

drivers/message/fusion/mptbase.c:6851:13: warning: 'seq_mpt_print_ioc_summary' defined but not used [-Wunused-function]
static void seq_mpt_print_ioc_summary(MPT_ADAPTER *ioc, struct seq_file *m, int showlan)

This adds an #ifdef to hide the function definition in that case and
avoid the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 8cd1943b 21-Apr-2015 Luis R. Rodriguez <mcgrof@suse.com>

fusion: remove dead MTRR code

If and when this gets enabled the driver could should split
up IO memory space properly and that is quite a bit of work.
Just remove the uncommented dead MTRR code then.

There are a few motivations for this:

a) Take advantage of PAT when available

b) Help bury MTRR code away, MTRR is architecture specific and on
x86 its replaced by PAT

c) Help with the goal of eventually using _PAGE_CACHE_UC over
_PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (see commit
de33c442e titled "x86 PAT: fix performance drop for glx,
use UC minus for ioremap(), ioremap_nocache() and
pci_mmap_page_range()")

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Acked-by: Sreekanth Reddy <ureekanth.reddy@avagotech.com>
Signed-off-by: James Bottomley <JBottomley@Odin.com>


# 5d46ad7d 16-Aug-2014 Randy Dunlap <rdunlap@infradead.org>

fusion: fix excess parameter kernel-doc warning

Fix kernel-doc excess parameter warning:

Warning(..//drivers/message/fusion/mptbase.c:1411): Excess function parameter 'prod_name' description in 'mpt_get_product_name'

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>


# f6e495a2 01-Jul-2014 Rasmus Villemoes <linux@rasmusvillemoes.dk>

mptfusion: simplify rounding

Rounding up to a multiple of 4 should be done using the ALIGN
macro. As a bonus, this also makes the generated code smaller.

In GetIocFacts(), sz is assigned to a few lines below without being
read in the meantime, so it is ok that it doesn't end up with the same
value as facts->FWImageSize.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Reviewed-by: Joe Lawrence <joe.lawrence@stratus.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>


# 9f21316f 25-Jun-2014 Joe Lawrence <joe.lawrence@stratus.com>

mptfusion: tweak null pointer checks

Fixes the following smatch warnings:

drivers/message/fusion/mptbase.c:652 mptbase_reply() warn: variable
dereferenced before check 'reply' (see line 639)

[JL: No-brainer, the enclosing switch statement dereferences
reply, so we can't get here unless reply is valid.]

drivers/message/fusion/mptsas.c:1255 mptsas_taskmgmt_complete() error:
we previously assumed 'pScsiTmReply' could be null (see line 1227)

[HCH: Reading the code in mptsas_taskmgmt_complete it's pretty
obvious that it can't do anything useful if mr/pScsiTmReply are
NULL, so I suspect it would be best to just return at the
beginning of the function.

I'd love to understand if it actually could ever be zero, which I
doubt. Maybe the LSI people can shed some light on that?]

drivers/message/fusion/mptsas.c:3888 mptsas_not_responding_devices()
error: we previously assumed 'port_info->phy_info' could be null
(see line 3875)

[HCH: It's pretty obvious from reading mptsas_sas_io_unit_pg0 that
we never register a port_info with a NULL phy_info in the lists,
so all NULL checks on it could be deleted.]

drivers/message/fusion/mptscsih.c:1284 mptscsih_info() error:
we previously assumed 'h' could be null (see line 1274)

[HCH: shost_priv can't return NULL, so the if (h) should be
removed.]

drivers/message/fusion/mptscsih.c:1388 mptscsih_qcmd() error: we
previously assumed 'vdevice' could be null (see line 1373)

[HCH: vdevice can't ever be NULL here, it's allocated in
->slave_alloc and thus guaranteed to be around when
->queuecommand is called.]

Signed-off-by: Joe Lawrence <joe.lawrence@stratus.com>
Acked-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>


# c9834c70 25-Jun-2014 Joe Lawrence <joe.lawrence@stratus.com>

mptfusion: make adapter prod_name[] a pointer

The struct _MPT_ADAPTER doesn't need a full copy of the product string,
so prod_name can point to the string literal storage that the driver
already provides.

Avoids the following smatch warning:

drivers/message/fusion/mptbase.c:2858 MptDisplayIocCapabilities()
warn: this array is probably non-NULL. 'ioc->prod_name'

Signed-off-by: Joe Lawrence <joe.lawrence@stratus.com>
Acked-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>


# 5767d25f 25-Jun-2014 Joe Lawrence <joe.lawrence@stratus.com>

mptfusion: mark file-private functions as static

Fixes the following sparse warnings:

drivers/message/fusion/mptbase.c:7011:1: warning: symbol
'mpt_SoftResetHandler' was not declared. Should it be static?

drivers/message/fusion/mptsas.c:1578:23: warning: symbol
'mptsas_refreshing_device_handles' was not declared. Should it be
static?

drivers/message/fusion/mptsas.c:3653:24: warning: symbol
'mptsas_expander_add' was not declared. Should it be static?

drivers/message/fusion/mptsas.c:5327:1: warning: symbol
'mptsas_shutdown' was not declared. Should it be static?

drivers/message/fusion/mptspi.c:624:1: warning: symbol
'mptscsih_quiesce_raid' was not declared. Should it be static?

Signed-off-by: Joe Lawrence <joe.lawrence@stratus.com>
Acked-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>


# ecc3bc98 27-Mar-2014 Matthew Wilcox <willy@infradead.org>

fusion: Add free msg frames to the head, not tail of list

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

Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Reviewed-by: Nicholas Bellinger <nab@linux-iscsi.org>
Reviewed-by: Praveen Krishnamoorthy <Praveen.krishnamoorthy@lsi.com>
Acked-by: Sreekanth Reddy <Sreekanth.reddy@lsi.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>


# 64cdb418 10-Jan-2014 Rafael J. Wysocki <rafael.j.wysocki@intel.com>

MPT / PCI: Use pci_stop_and_remove_bus_device_locked()

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

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

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>


# d9dda78b 31-Mar-2013 Al Viro <viro@zeniv.linux.org.uk>

procfs: new helper - PDE_DATA(inode)

The only part of proc_dir_entry the code outside of fs/proc
really cares about is PDE(inode)->data. Provide a helper
for that; static inline for now, eventually will be moved
to fs/proc, along with the knowledge of struct proc_dir_entry
layout.

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


# 20953a62 10-Aug-2012 Hanjun Guo <guohanjun@huawei.com>

[SCSI] Fusion MPT: disable pci device when mpt map resoures failed

when probe a pci device, first we enable it, and disable it when
some error happened in the following process, because the power
state of the device is set to D0, and if MSI is disabled,
we will allocate irq and register gsi for this device in the enable process.

In function mpt_mapresources(MPT_ADAPTER *ioc), it forgot disable the
pci device when error happened, the irq and gsi will never be released.
this patch will fix it.

Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Acked-by: "Nandigama, Nagalakshmi" <Nagalakshmi.Nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# 9ceb5c16 31-May-2012 Sergei Shtylyov <sshtylyov@ru.mvista.com>

drivers/message/fusion: use pci_dev->revision

This driver uses PCI_CLASS_REVISION instead of PCI_REVISION_ID, so it
wasn't converted by 44c10138fd4bbc ("PCI: Change all drivers to use
pci_device->revision").

In one case, it even reads PCI revision ID without using it -- that code
is now removed...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Acked-by: "Nandigama, Nagalakshmi" <Nagalakshmi.Nandigama@lsi.com>
Cc: Eric Moore <eric.moore@lsi.com>
Acked-by: Auke Kok <auke-jan.h.kok@intel.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 83ff74e3 26-Aug-2011 Dan Carpenter <error27@gmail.com>

[SCSI] mptfusion: unlock on error in mpt_config()

We introduced a new return here and forgot to unlock the mutex.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: "Nandigama, Nagalakshmi" <Nagalakshmi.Nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# 210647af 25-Feb-2012 Yinghai Lu <yinghai@kernel.org>

PCI: Rename pci_remove_bus_device to pci_stop_and_remove_bus_device

The old pci_remove_bus_device actually did stop and remove.

Make the name reflect that to reduce confusion.

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

Suggested-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>


# 8af3d8d5 25-Aug-2011 Ferenc Wagner <wferi@niif.hu>

[SCSI] fusion: ensure NUL-termination of MptCallbacksName elements

Using strlcpy instead of memcpy makes the strlen() calls superfluous
and also ensures zero-termination of the copied string.
At the same time get rid of the magic constant 50.

Actually, I can't see why copying the callback name is necessary
instead of simply storing a pointer to it (just like to the callback
function itself), but that goes beyond the scope of this fix.

Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Acked-by: "Nandigama, Nagalakshmi" <Nagalakshmi.Nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# 98cbe371 04-Aug-2011 kashyap.desai@lsi.com <kashyap.desai@lsi.com>

[SCSI] mptfusion: Fix for device offline while doing aggressive HBA reset

[Resend patch as per Bernd Schubert comment ]

Issue:

Device goes offline while doing aggressive HBA reset
along with IO using some utility.

Root cause:

FW goes into bad state due to aggressive reset. Softreset does not
help to recover FW. And also aggressive reset open up the window for
Error handling thread to kicked off at the same time HBA will be in
constant RESET loop as part of aggressive reset test case can lead
Device to goes offline.

Changes:

1. Added extra check as below inside eh_timed_out call back as below.
if(ioc->ioc_reset_in_progress) Rc = EH_TIMER_RESET

2. Removed " DOORBELL_ACTIVE" check for SAS controller from task
management context. Since SAS controller uses high priority queue
for task management. This check is not required for SAS controller.

3. Moved SoftReset call to HardReset from Task Mgmt context.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# e62cca19 04-Aug-2011 kashyap.desai@lsi.com <kashyap.desai@lsi.com>

[SCSI] mptfusion: Better handling of DEAD IOC PCI-E Link down error condition

Find Non-Operation IOC and remove it from OS: Detecting
dead(non-functional) ioc will be done reading doorbell register value
from fault reset thread, which has been called from work thread
context after each specific interval. If doorbell value is 0xFFFFFFFF,
it will be considered as IOC is non-operational and marked as dead
ioc.

Once Dead IOC has been detected, it will be removed at pci layer using
"pci_remove_bus_device" API.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# 85ee7a1d 23-Apr-2011 Joe Perches <joe@perches.com>

treewide: cleanup continuations and remove logging message whitespace

Using C line continuation inside format strings is error prone.
Clean up the unintended whitespace introduced by misuse of \.
Neaten correctly used line continations as well for consistency.

drivers/scsi/arcmsr/arcmsr_hba.c has these errors as well,
but arcmsr needs a lot more work and the driver should likely be
moved to staging instead.

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 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>


# d75733d5 09-Feb-2011 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mptfusion: Support SAS2.0 Devices with SAS1.0 Controllers

SAS1.0 Controller was not able to detect SAS2.0 Expanders due to Link
RATE detection was limited to 1.5 Gbps and 3.0 Gbps for SAS1
controllers. Added detection for 6.0 Gbps link. Now, user can mix-up
6.0 Gpbs links with SAS1.0 controller.

e.g SAS1.0 HBA <----> SAS2.0 Expander <------> SAS2.0 Expander <--------> SAS1.0 Drive.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.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>


# 1c1acab0 10-Aug-2010 Julia Lawall <julia@diku.dk>

[SCSI] drivers/message/fusion: Return -ENOMEM on memory allocation failure

In this code, 0 is returned on memory allocation failure, even though other
failures return -ENOMEM or other similar values.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression ret;
expression x,e1,e2,e3;
@@

ret = 0
... when != ret = e1
*x = \(kmalloc\|kcalloc\|kzalloc\)(...)
... when != ret = e2
if (x == NULL) { ... when != ret = e3
return ret;
}
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: "Desai, Kashyap" <Kashyap.Desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# fc58fb18 14-Aug-2010 Randy Dunlap <randy.dunlap@oracle.com>

fusion: add function parameter names to kernel-doc

Fix fusion missing kernel-doc:

Warning(drivers/message/fusion/mptbase.c:649): No description found for parameter 'func_name'
Warning(drivers/message/fusion/mptbase.c:8010): No description found for parameter 'cb_idx'

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 1f5cfe2f 14-Aug-2010 Randy Dunlap <randy.dunlap@oracle.com>

fusion: fix non-kernel-doc comment block

Fix comment begin notation not to look like kernel-doc
since it's not. Removes kernel-doc warnings.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 71740c42 10-Aug-2010 Randy Dunlap <randy.dunlap@oracle.com>

fusion: fix kernel-doc warnings

Fix (delete) empty kernel-doc lines/warnings:
Warning(drivers/message/fusion/mptbase.c:6916): bad line:
Warning(drivers/message/fusion/mptbase.c:7060): bad line:

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Eric Moore <Eric.Moore@lsi.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# eb6edad3 10-Aug-2010 Alexey Dobriyan <adobriyan@gmail.com>

mpt fusion: convert to seq_file

Convert everything except ->proc_info() stuff, it is done within separate
->proc_info path series.

Problem with ->read_proc et al is described here commit
786d7e1612f0b0adb6046f19b906609e4fe8b1ba "Fix rmmod/read/write races in
/proc entries"

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Eric Moore <Eric.Moore@lsi.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 57ba4717 11-Aug-2010 Rusty Russell <rusty@rustcorp.com.au>

param: use module_param in drivers/message/fusion/mptbase.c

No need to open code this!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Reviewed-by: Takashi Iwai <tiwai@suse.de>


# 081f4f4c 05-Aug-2010 Julia Lawall <julia@diku.dk>

[SCSI] drivers/message/fusion: Adjust confusing if indentation

Indent the branch of an if.

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

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

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

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

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

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: "Desai, Kashyap" <Kashyap.Desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 653c42d5 26-Jul-2010 Tomas Henzl <thenzl@redhat.com>

[SCSI] mptfusion: release resources in error return path

We should release the resources in error return code path.
The requested pci bars should be released under an error condition,
when mpt_mapresources fails.

Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Acked-by: "Desai, Kashyap" <Kashyap.Desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 213aaca3 26-Jul-2010 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mptfusion: Extra debug prints added relavent to Device missing delay error handling

Adding function name in original debug prints and few more debug prints are
added.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 97009a29 22-Jun-2010 Kei Tokunaga <tokunaga.keiich@jp.fujitsu.com>

[SCSI] mptfusion: print Doorbell register in a case of hard reset and timeout

Printing Doorbell register in a case of hard reset and timeout
should be useful for figuring out the state of the system.

Signed-off-by: Kei Tokunaga <tokunaga.keiich@jp.fujitsu.com>
Acked-by: "Desai, Kashyap" <Kashyap.Desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 15f7fc06 16-Jun-2010 Bandan Das <bandan.das@Stratus.com>

[SCSI] mpt fusion: Cleanup some duplicate calls in mptbase.c

In mpt_detach, call to pci_set_drvdata is redundant because it
has already been called in mpt_adapter_disable. In mpt_attach,
ioc->pcidev is set to pdev two times.

Signed-off-by: Bandan Das <bandan.das@stratus.com>
Acked-by: "Desai, Kashyap" <Kashyap.Desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# b9a0f872 17-Jun-2010 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mptfusion: Added missing reset for ioc_reset_in_progress in SoftReset

Added missing part which will reset ioc_reset_in_progress before returning from SoftResetHandler.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 8ce13de2 17-Jun-2010 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mptfusion: Set fw_events_off to 1 at driver load time.

fw_events_off is flag checking for driver to do Event handling or not.
Normally it should be OFF at the time of initialization. Only enable it at
the time of INTR enable of device first time. This will always occur only
after resource allocation.

ioc->fw_events_off = 1 is set in mpt_attach()

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 421f91d2 10-Jun-2010 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

fix typos concerning "initiali[zs]e"

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


# b3b97316 18-Mar-2010 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mptfusion: mpt config will do Hard Reset based upon retry counts

mpt_config would only attempt a MUR before retrying the command. The
driver will now retry a second time with a hard reset before leaving
the function.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# d0f698c4 18-Mar-2010 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mptfusion: Added new less expensive RESET (Message Unit Reset)

Message Unit Reset - instructs the IOC to reset the Reply Post and
Free FIFO's. All the Message Frames on Reply Free FIFO are
discarded. All posted buffers are freed, and event notification is
turned off. IOC doesnt reply to any outstanding request. This will
transfer IOC to READY state. Message unit ready is less expensive
operations than Hard Reset. soft reset will not force Firmware to
reload again, it only do clean up of Message units.

mpt_Soft_Hard_ResetHandler will first try for Soft Reset,if
it fails then go for big hammer reset which is Hard Reset.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# e47c11c7 14-Dec-2009 Erik Ekman <erik@kryo.se>

[SCSI] fusion: fix warning when not using procfs

Fixes the following warning:
drivers/message/fusion/mptbase.c:129: warning: 'mpt_proc_root_dir' defined but not used
also moves it from public data section since it is static.

Signed-off-by: Erik Ekman <erik@kryo.se>
Acked-by: "Desai, Kashyap" <Kashyap.Desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# f1053a7c 12-Dec-2009 Anatolij Gustschin <agust@denx.de>

[SCSI] mptsas: Fix issue with chain pools allocation on katmai

Since commit 9d2e9d66a3f032667934144cd61c396ba49f090d
mptsas driver fails to allocate memory for the MPT chain buffers
for second LSI adapter on PPC440SPe Katmai platform:
...
ioc1: LSISAS1068E B3: Capabilities={Initiator}
mptbase: ioc1: ERROR - Unable to allocate Reply, Request, Chain Buffers!
mptbase: ioc1: ERROR - didn't initialize properly! (-3)
mptsas: probe of 0002:31:00.0 failed with error -3

This commit increased MPT_FC_CAN_QUEUE value but initChainBuffers()
doesn't differentiate between SAS and FC causing increased allocation
for SAS case, too. Later pci_alloc_consistent() fails to allocate
increased chain buffer pool size for SAS case.

Provide a fix by looking at the bus type and using appropriate
MPT_SAS_CAN_QUEUE value while calculation of the number of chain
buffers.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Acked-by: Kashyap Desai <kashyap.desai@lsi.com>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# e46b63b3 02-Dec-2009 Pravin Bathija <pbathija@amcc.com>

[SCSI] mpt fusion: Fix 32 bit platforms with 64 bit resources.

Powerpc 44x uses 36 bit real address while the real address defined in
MPT Fusion driver is of type 32 bit. This causes ioremap to fail and
driver fails to initialize. This fix changes the data types
representing the real address from unsigned long 32-bit types to
resource_size_t which is 64-bit. The driver has been tested, the disks
get discovered correctly and can do IO.

[jejb: added printk fix for resource_size_t object]
Signed-off-by: Pravin Bathija <pbathija@amcc.com>
Acked-by: "Desai, Kashyap" <Kashyap.Desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 3dbda77e 23-Jul-2009 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

trivial: fix typos "man[ae]g?ment" -> "management"

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


# c55b89fb 02-Sep-2009 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mptsas : PAE Kernel more than 4 GB kernel panic

This patch is solving problem for PAE kernel DMA operation.
On PAE system dma_addr and unsigned long will have different
values.
Now dma_addr is not type casted using unsigned long.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# d1306917 04-Aug-2009 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mptsas : Code cleanup of host page alloc and diag reset.

Code cleanup of host page alloc and diag reset.

Signed-off-by: James Bottomley <James.Bottomley@suse.de>


# 8e20ce94 18-Jun-2009 Andrew Morton <akpm@linux-foundation.org>

convert some DMA_nnBIT_MASK() callers

We're about to make DMA_nnBIT_MASK() emit `deprecated' warnings. Convert the
remaining stragglers which are visible to the x86_64 build.

Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Eric Moore <Eric.Moore@lsil.com>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Alexander Duyck <alexander.h.duyck@intel.com>
Cc: Yi Zou <yi.zou@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 9cf46a35 13-Jun-2009 Randy Dunlap <randy.dunlap@oracle.com>

fusion: fix recent kernel-doc problems

Fix recent fusion driver kernel-doc fatal error and warnings.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Eric.Moore@lsi.com
Cc: support@lsi.com
Cc: DL-MPTFusionLinux@lsi.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# a7938b0b 29-May-2009 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mpt fusion: RAID device handling and Dual port Raid support is added

1. Handle integrated Raid device(Add/Delete) and error condition and check
related to Raid device. is_logical_volume will represent logical volume
device.
2. Raid device dual port support is added. Main functions to support this
feature are mpt_raid_phys_disk_get_num_paths and mpt_raid_phys_disk_pg1.

Signed-off-by: Kashyap Desai <kadesai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 71278192 29-May-2009 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mpt fusion: Put IOC into ready state if it not already in ready state

Signed-off-by: Kashyap Desai <kadesai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 2f187862 29-May-2009 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mpt fusion: Code Cleanup patch

Resending patch considering Grants G's code review.

Main goal to submit this patch is code cleaup.
1. Better driver debug prints and code indentation.
2. fault_reset_work_lock is not used anywhere. driver is using taskmgmt_lock
instead of fault_reset_work_lock.
3. setting pci_set_drvdata properly.
4. Ingore config request when IOC is in reset state.( ioc_reset_in_progress
is set).
5. Init/clear managment frame proprely.(INITIALIZE_MGMT_STATUS and
CLEAR_MGMT_STATUS)

Signed-off-by: Kashyap Desai <kadesai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 3eb0822c 29-May-2009 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mpt fusion: Firmware event implementation using seperate WorkQueue

Now Firmware events are handled by firmware event queue.
Previously it was handled in interrupt context/WorkQueue of Linux.
Firmware Event handling is restructured and optimized.

Signed-off-by: Kashyap Desai <kadesai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# e7deff33 29-May-2009 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mpt fusion: Adding DeviceResetCtx for internal Device reset frame

1.) Added taskmgmt_quiesce_io flag in IOC and removed resetPending from
_MPT_SCSI_HOST struct.
2.) Reset from Scsi mid layer and internal Reset are seperate context.
Adding DeviceResetCtx for internal Device reset frame.
mptsas_taskmgmt_complete is optimized as part of implementation.

Signed-off-by: Kashyap Desai <kadesai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 1ba9ab2e 29-May-2009 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mpt fusion: rewrite taskmgmt request and completion routines

1.) rewrite taskmanagement request and completion routines, making them
single threaded and using the generic MPT_MGMT struct, deleting
mptscsih_TMHandler, replacing with single request TM handler
mptscsih_IssueTaskMgmt, and killing the watchdog timer functions.
2.) cleanup ioc_reset callback handlers, introducing wrappers for
synchronizing error recovery (mpt_set_taskmgmt_in_progress_flag,
mpt_clear_taskmgmt_in_progress_flag), as the fusion firmware only handles
one task management request at a time

Signed-off-by: Kashyap Desai <kadesai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 37c60f37 29-May-2009 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mpt fusion: rewrite of all internal generated functions

Rewrite of all internal generated functions that issue commands to firmware,
porting them to be single threaded using the generic MPT_MGMT
struct. Implemented using completion Queue.

Signed-off-by: Kashyap Desai <kadesai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# f0f09d3b 29-May-2009 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mpt fusion: config path optimized, completion queue is used

1) Previously we had mutliple #defines to use same values.
Now those #defines are optimized.
MPT_IOCTL_STATUS_* is removed and MPT_MGMT_STATUS_* are new
#defines.
2.) config path is optimized.
Instead of wait Queue and timer, using completion Q.
3.) mpt_timer_expired is not used.

[jejb: elide patch to eliminate mpt_timer_expired]
Signed-off-by: Kashyap Desai <kadesai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# fd76175a 29-May-2009 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mpt fusion: Optimized SendEvent notification Using Doorbell instead FIFO

SendEventNotification was handled through FIFO, now it is using doorbell to
communicate with hardware. Added Sleep Flag as an extra argument to support
Can-Sleep feature. Resending patch including compilation error fix reviewed
by Grant Grundler.

Signed-off-by: Kashyap Desai <kadesai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 7b5a65b9 29-May-2009 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mpt fusion: Added support for MPT discovery completion check

sas_discovery_quiesce_io flag is used to control IO start/resume functionality.
IO will be stoped while doing discovery of topology. Once discovery is completed
It will resume IO. Resending patch including James review.

Signed-off-by: Kashyap Desai <kadesai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 14d0f0b0 29-May-2009 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mpt fusion: Fixing 1078 data corruption issue for 36GB memory region

The reason for this change is there is a data corruption when four different
physical memory regions in the 36GB to 37GB region are
accessed. This is only affecting 1078.

The solution is we need to use different addressing when filling in
the scatter gather table for the effected memory regions. So instead
of snooping on all four different memory holes, we treat any physical
addresses in the 36GB address with the same algorithm.

The fix is explained below
1) Ensure that the message frames are NOT located in the trouble
region. There is no remapping available for message frames, they must
be allocated outside the problem region.
2) Ensure that Sense buffers are NOT in the trouble region. There is
no remapping available.
3) Walk through the SGE entries and if any are inside the trouble region
then they need to be remapped as discussed below.
1) Set the Local Address bit in the SGE Flags field.
MPI_SGE_FLAGS_LOCAL_ADDRESS
2) Ensure we are using 64-bit SGEs
3) Set MSb (Bit 63) of the 64-bit address, this will indicate buffer
location is Host Memory.

Signed-off-by: Kashyap Desai <kadesai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# b298cecb 21-Apr-2009 Eric Paris <eparis@parisplace.org>

scsi: mpt: suppress debugobjects warning

Addresses http://bugzilla.kernel.org/show_bug.cgi?id=13133

ODEBUG: object is on stack, but not annotated
------------[ cut here ]------------
WARNING: at lib/debugobjects.c:253 __debug_object_init+0x1f3/0x276()
Hardware name: VMware Virtual Platform
Modules linked in: mptspi(+) mptscsih mptbase scsi_transport_spi ext3 jbd mbcache
Pid: 540, comm: insmod Not tainted 2.6.28-mm1 #2
Call Trace:
[<c042c51c>] warn_slowpath+0x74/0x8a
[<c0469600>] ? start_critical_timing+0x96/0xb7
[<c060c8ea>] ? _spin_unlock_irqrestore+0x2f/0x3c
[<c0446fad>] ? trace_hardirqs_off_caller+0x18/0xaf
[<c044704f>] ? trace_hardirqs_off+0xb/0xd
[<c060c8ea>] ? _spin_unlock_irqrestore+0x2f/0x3c
[<c042cb84>] ? release_console_sem+0x1a5/0x1ad
[<c05013e6>] __debug_object_init+0x1f3/0x276
[<c0501494>] debug_object_init+0x13/0x17
[<c0433c56>] init_timer+0x10/0x1a
[<e08e5b54>] mpt_config+0x1c1/0x2b7 [mptbase]
[<e08e3b82>] ? kmalloc+0x8/0xa [mptbase]
[<e08e3b82>] ? kmalloc+0x8/0xa [mptbase]
[<e08e6fa2>] mpt_do_ioc_recovery+0x950/0x1212 [mptbase]
[<c04496c2>] ? __lock_acquire+0xa69/0xacc
[<c060c8f1>] ? _spin_unlock_irqrestore+0x36/0x3c
[<c060c3af>] ? _spin_unlock_irq+0x22/0x26
[<c04f2d8b>] ? string+0x2b/0x76
[<c04f310e>] ? vsnprintf+0x338/0x7b3
[<c04496c2>] ? __lock_acquire+0xa69/0xacc
[<c060c8ea>] ? _spin_unlock_irqrestore+0x2f/0x3c
[<c04496c2>] ? __lock_acquire+0xa69/0xacc
[<c044897d>] ? debug_check_no_locks_freed+0xeb/0x105
[<c060c8f1>] ? _spin_unlock_irqrestore+0x36/0x3c
[<c04488bc>] ? debug_check_no_locks_freed+0x2a/0x105
[<c0446b8c>] ? lock_release_holdtime+0x43/0x48
[<c043f742>] ? up_read+0x16/0x29
[<c05076f8>] ? pci_get_slot+0x66/0x72
[<e08e89ca>] mpt_attach+0x881/0x9b1 [mptbase]
[<e091c8e5>] mptspi_probe+0x11/0x354 [mptspi]

Noticing that every caller of mpt_config has its CONFIGPARMS struct
declared on the stack and thus the &pCfg->timer is always on the stack I
changed init_timer() to init_timer_on_stack() and it seems to have shut
up.....

Cc: "Moore, Eric Dean" <Eric.Moore@lsil.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Acked-by: "Desai, Kashyap" <Kashyap.Desai@lsi.com>
Cc: <stable@kernel.org> [2.6.29.x]
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>


# 6a35528a 06-Apr-2009 Yang Hongyang <yanghy@cn.fujitsu.com>

dma-mapping: replace all DMA_64BIT_MASK macro with DMA_BIT_MASK(64)

Replace all DMA_64BIT_MASK macro with DMA_BIT_MASK(64)

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>


# 5ce7868e 18-Feb-2009 Yinghai Lu <yinghai@kernel.org>

[SCSI] mpt: fix disable lsi sas to use msi as default

Impact: fix bug

the third param in module_param(,,) is perm instead of default value.
we still need to assign default at first. Also, the default is now
zero not one, so fix the parameter text to reflect that.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Acked-by: Kashyap Desai <kadesai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 2f4c782c 06-Jan-2009 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mpt fusion: Add Firmware debug support

Signed-off-by: Kashyap Desai <kadesai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# e382968b 08-Jan-2009 Kashyap, Desai <kashyap.desai@lsi.com>

[SCSI] mpt fusion: Add separate msi enable disable for FC,SPI,SAS

Added support for MSI enable/disable for different buses FC,SPI,SAS
instead of having single MSI enable/disable feature.

Signed-off-by: Kashyap Desai <kadesai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# dd7c34e9 09-Nov-2008 Julia Lawall <julia@diku.dk>

[SCSI] fusion: use ARRAY_SIZE

ARRAY_SIZE is more concise to use when the size of an array is divided by
the size of its type or the size of its first element.

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: "Prakash, Sathya" <Sathya.Prakash@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# ef661c5e 29-Oct-2008 Randy Dunlap <randy.dunlap@oracle.com>

[SCSI] fusion: remove excess kernel-doc notation

Remove excess kernel-doc function parameter notation:

Warning(drivers/message/fusion/mptbase.c:964): Excess function parameter or struct member 'handle' description in 'mpt_free_msg_frame'
Warning(drivers/message/fusion/mptbase.c:5434): Excess function parameter or struct member 'portnum' description in 'mpt_findImVolumes'
Warning(drivers/message/fusion/mptbase.c:6949): Excess function parameter or struct member 'mr' description in 'mpt_spi_log_info'

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
cc: Eric.Moore@lsi.com
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# cadbd4a5 04-Jul-2008 Harvey Harrison <harvey.harrison@gmail.com>

[SCSI] replace __FUNCTION__ with __func__

[jejb: fixed up a ton of missed conversions.

All of you are on notice this has happened, driver trees will now
need to be rebased]

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Cc: SCSI List <linux-scsi@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# aab0de24 01-May-2008 Kay Sievers <kay.sievers@vrfy.org>

driver core: remove KOBJ_NAME_LEN define

Kobjects do not have a limit in name size since a while, so stop
pretending that they do.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# d54d48b8 20-May-2008 Prakash, Sathya <sathya.prakash@lsi.com>

[SCSI] mpt fusion : Adding FAULT Reset polling work

When the firmware is in Fault state it will be identifed only when the next time
the driver access the IOC state.
This patch includes a polling function in the driver which will be executed in
regular interval to check the status of the firmware and if it is in Fault
state, then the firmware will be reset by the driver.

Signed-off-by: Sathya Prakash <sathya.prakash@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 27898988 10-Jul-2008 James Bottomley <James.Bottomley@HansenPartnership.com>

[SCSI] fusion: default MSI to disabled for SPI and FC controllers

There's a fault on the FC controllers that makes them not respond
correctly to MSI. The SPI controllers are fine, but are likely to be
onboard on older motherboards which don't handle MSI correctly, so
default both these cases to disabled. Enable by setting the module
parameter mpt_msi_enable=1.

For the SAS case, enable MSI by default, but it can be disabled by
setting the module parameter mpt_msi_enable=0.

Cc: "Prakash, Sathya" <sathya.prakash@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# cddc0ab7 20-May-2008 Prakash, Sathya <sathya.prakash@lsi.com>

[SCSI] mpt fusion : Updated copyright statment with 2008 included

Updating copyright statement to include the year 2008

Signed-off-by: Sathya Prakash <sathya.prakash@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 15424921 21-Apr-2008 Adrian Bunk <bunk@kernel.org>

[SCSI] mpt fusion: make struct mpt_proc_root_dir static

This patch makes the needlessly global struct mpt_proc_root_dir static.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Acked-by: "Prakash, Sathya" <Sathya.Prakash@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# b8e3d3ae 30-Mar-2008 James Bottomley <James.Bottomley@HansenPartnership.com>

[SCSI] mpt fusion: fix up msi_enable in mpt_suspend

There's a problem with the combination of the upstream power
management fixes and the enabling of MSI by default in that the
suspend path still uses the global variable. Convert it to check
ioc->msi_enable.

Cc: "Moore, Eric" <Eric.Moore@lsi.com>
Cc: "Prakash, Sathya" <sathya.prakash@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# ed5f606f 08-Mar-2008 Matthias Kaehlcke <matthias@kaehlcke.net>

[SCSI] mpt fusion: convert inactive_list_mutex to a mutex

the semaphore inactive_list_mutex is used as a mutex, convert it to
the mutex API

Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net>
Acked-by: "Moore, Eric" <Eric.Moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 23a274c8 07-Mar-2008 Prakash, Sathya <sathya.prakash@lsi.com>

[SCSI] mpt fusion: Enable MSI by default for SAS controllers

This patch modifies the driver to enable MSI by default for all SAS chips.

Signed-off-by: Sathya Prakash <sathya.prakash@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 4d4109d0 07-Mar-2008 Prakash, Sathya <sathya.prakash@lsi.com>

[SCSI] mpt fusion: Power Management fixes for MPT SAS PCI-E controllers

The system power state changes like hibernation and standby are not happening
properly with 106XE controllers, this patch modifies the driver to free
resources and allocate resources in power management entry points

[jejb: compile fixes for upstream]

Signed-off-by: Sathya Prakash <sathya.prakash@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# ab3b0be8 29-Feb-2008 Randy Dunlap <randy.dunlap@oracle.com>

[SCSI] docbook: fix fusion source files

Fix docbook problems in fusion source files.
These cause the generated docbook to be incorrect.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Acked-by: Eric Moore <Eric.Moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 7105a387 29-Feb-2008 Randy Dunlap <randy.dunlap@oracle.com>

docbook: fix fusion source files

Fix docbook problems in fusion source files.
These cause the generated docbook to be incorrect.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# ad008d42 19-Feb-2008 Adrian Bunk <bunk@kernel.org>

[SCSI] mptbase: fix use-after-free's

ioc->name is used in the printk's after ioc has been freed. Free
after prinks to fix this.

This patch fixes two use-after-free's introduced by
commit e78d5b8f1e73ab82f3fd041d05824cfee7d83a2c and spotted by the
Coverity checker.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# e78d5b8f 08-Feb-2008 Prakash, Sathya <sathya.prakash@lsi.com>

[SCSI] mpt fusion: Request I/O resources only when required

This patch modifies the I/O resource allocation behavior of FUSION
driver. The current version of driver allocates the I/O resources
even if they are not required and this creates trouble in low resource
environments. This driver now uses
pci_enable_device_mem/pci_enable_device functions to differentiate the
resource allocations.

Signed-off-by: Sathya Prakash <sathya.prakash@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 07df8afa 08-Feb-2008 Prakash, Sathya <sathya.prakash@lsi.com>

[SCSI] mpt fusion: Avoid racing when mptsas and mptcl module are loaded in parallel

This patch sets the IOC pointer in drvrdata of pcidev before adding
the IOC into the list of IOCs. Without this patch the driver oops when
the mptsas and mptctl modules are loaded in parallel.

Signed-off-by: Sathya Prakash <sathya.prakash@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# 984621b4 11-Jan-2008 Prakash, Sathya <sathya.prakash@lsi.com>

[SCSI] mpt fusion: Fix for module unload problem in flash less controller environment

This patch fixes the module unload problem in flash less 1030
controller environment where firmware download boot functionality is
invoked. The problem is due to the firmware download is being done in
the reverse order, which this patch solves by insureing the download
occurs to the last controller being reset.

signed-off-by: Sathya Prakash <sathya.prakash@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>


# bc6e089a 29-Sep-2007 Eric Moore <eric.moore@lsi.com>

[SCSI] mpt fusion: Fix sparse warnings

List below is output from C=2 sparse compilation, which are fixed with
this patch.

1) mptspi: pg0 is defined in x86 version of include/asm/pgtable.h

2) mptsas: context imbalance in 'mptsas_probe' different lock contexts
for basic block

3) mptbase: from mpt_attach - cast adds address space to expression

4) mptbase: from mpt_do_upload - request[] is bad constant expression

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


# 8d6d83e9 14-Sep-2007 Eric Moore <eric.moore@lsi.com>

[SCSI] mpt fusion: adding/removing white space

cleaning up some white space that was introduce in a recent "cb_idx int to u8" patch.

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


# 29dd3609 14-Sep-2007 Eric Moore <eric.moore@lsi.com>

[SCSI] mpt fusion: standardize printks and debug info

Standardize all prints using common MYIOC_s_XXX_FMT macro defined in mptbase.h. Currently the driver uses several different methods to display info, where in some cases the "controller name" generating the printk is not provided.

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


# 56876195 10-Aug-2007 Jesper Juhl <jesper.juhl@gmail.com>

[SCSI] mpt fusion: fix two potential mem leaks

The Coverity checker spotted two potential memory leaks in
drivers/message/fusion/mptbase.c::mpt_attach().

There are two returns that may leak the storage allocated for 'ioc'
(sizeof(MPT_ADAPTER) bytes).

A simple fix would be to simply add two kfree() calls before the return
statements, but a better fix (that this patch implements) is to reorder the
code so that if we hit the first return condition we don't have to do the
allocation at all and then just add a kfree() call for the second case.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Acked-by: "Moore, Eric Dean" <Eric.Moore@lsil.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# f36789e2 14-Aug-2007 Prakash, Sathya <sathya.prakash@lsi.com>

[SCSI] mpt fusion: Change company name from LSI Logic to LSI

Recently LSI Logic Corp was renamed as LSI Corp, so whereever there is
a reference of LSI Logic, it is changed to LSI in mpt fusion driver
code.

signed-off-by: Sathya Prakash <sathya.prakash@lsi.com>
Acked-by: Eric Moore <Eric.Moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# f606f571 14-Aug-2007 Prakash, Sathya <sathya.prakash@lsi.com>

[SCSI] mpt fusion: Change call back indices to u8 from int

The call back index requires only u8 but in lot of places it is
referred as int, now everywhere the call back index variables are
declared as u8 with uniform name cb_idx

signed-off-by: Sathya Prakash <sathya.prakash@lsi.com>
Acked-by: Eric Moore <Eric.Moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 7a195f46 14-Aug-2007 Prakash, Sathya <sathya.prakash@lsi.com>

[SCSI] mpt fusion: Usage of high priority request FIFO to send task management commands

Added support for sending the task management requests through High priority
request FIFO instead of Doorbell writes when firmware support High priority
FIFO.

signed-off-by: Sathya Prakash <sathya.prakash@lsi.com>
Acked-by: Eric Moore <Eric.Moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 232f08fc 14-Aug-2007 Eric Moore <eric.moore@lsi.com>

[SCSI] mpt fusion: Add support for ATTO 4LD: Rebranded LSI 53C1030

Per request from Matthew Wilcox - using PCI_VENDOR_ATTO.

Add support for ATTO UL4D, they are rebranded 53C1030.
The changes are
1. Adding a new PCI vendor ID in pci table
2. The spi_port_page_2 is in different format than that of LSI generic
spi_port_page_2 and hence mapping code is added.

signed-off-by: Sathya Prakash <sathya.prakash@lsi.com>
signed-off-by: Eric Moore <Eric.Moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# db47c2d8 28-Jul-2007 James Bottomley <James.Bottomley@steeleye.com>

[SCSI] mpt fusion: make logging a global sysfs parameter

Wire up the mpt_debug_level module parameter so you can write to the
/sys/module/mptbase/parameters/mpt_debug_level and have it take effect
in every ioc.

Acked-by: "Moore, Eric" <Eric.Moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 436ace72 24-Jul-2007 Prakash, Sathya <sathya.prakash@lsi.com>

[SCSI] mpt fusion: Changes in mptbase.c for logging support

This patch contains changes in mptbase.c to support logging in MPT fusion
drivers.

The changes are majorly in debug printks, the existing debugprintk are
modified accroding to new debug macros defined in the file mptbdebug.h

A new module parameter mpt_debug_level is added to pass the debug level as
module parameter.

signed-off-by: Sathya Prakash <sathya.prakash@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# ef1d8df7 17-Jul-2007 Prakash, Sathya <sathya.prakash@lsi.com>

[SCSI] mpt fusion: add support for Brocade branded LSI FC HBA

Add support for Brocade 410/420 4Gbit FC HBAs.
They are re-branded LSI HBAs [LSI7104EP-LC/LSI7204EP-LC]

Signed-off-by: Sathya Prakash <sathya.prakash@lsi.com>
Acked-by: "Moore, Eric" <Eric.Moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# edb9068d 17-Jul-2007 Prakash, Sathya <sathya.prakash@lsi.com>

[SCSI] mpt fusion: add sysfs attributes to display IOC parameters

New sysfs scsi_host attributes are added to provide information about Firmware
version, BIOS version, MPI version and other product related information

signed-off-by: Sathya Praksh <sathya.prakash@lsi.com>
Acked-by: "Moore, Eric" <Eric.Moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 7c431e5c 13-Jun-2007 Eric Moore <eric.moore@lsi.com>

[SCSI] mpt fusion: fc loginfo using defines from the header

rewrite of mpt_fc_log_info to use the enum/defines from mpi_log_fc.h

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


# 16d20101 13-Jun-2007 Eric Moore <eric.moore@lsi.com>

[SCSI] mpt fusion: update MAINTAINERS (fusion part)

Update assocated fusion sources with new support email address.

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


# 59c51591 09-May-2007 Michael Opdenacker <michael@free-electrons.com>

Fix occurrences of "the the "

Signed-off-by: Michael Opdenacker <michael@free-electrons.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>


# b364fd50 19-Mar-2007 Horms <horms@verge.net.au>

[SCSI] fusion: honour return value of pci_enable_device() in mpt_resume()

Honour the return value of pci_enable_device(), which
seems to be a desirable thing to do:

2.6.20-rc4
gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)

CC [M] drivers/message/fusion/mptbase.o
drivers/message/fusion/mptbase.c: In function `mpt_resume':
drivers/message/fusion/mptbase.c:1541: warning: ignoring return value
of `pci_enable_device', declared with attribute warn_unused_result

It also in turn has mptscsih_resume() honour the return value of
mpt_resume()

I'm not sure about the handling of the other potential error cases
in mpt_resume(), of which there appear to be many. But this does
seem to be a good start.

Signed-off-by: Simon Horman <horms@verge.net.au>
Acked-by: "Moore, Eric" <Eric.Moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 1544d677 20-Feb-2007 Randy Dunlap <randy.dunlap@oracle.com>

[SCSI] fusion: kernel-doc warning fixes

Fix kernel-doc warnings in fusion driver code.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Acked-by: "Moore, Eric" <Eric.Moore@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 07c861d6 29-Jan-2007 Eric Moore <eric.moore@lsi.com>

[SCSI] fusion - bump version - 3.04.04

bump version, and fix email addr for lsi support

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


# cd2c6191 29-Jan-2007 Eric Moore <eric.moore@lsi.com>

[SCSI] fusion - error handling bug fix's

misc error handling bug fix's
- properly interpret iocstatus returned after task management request
- clear tmState after a failed doorbell
- cleanup mptscsih_taskmgmt_complete

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


# b506ade9 29-Jan-2007 Eric Moore <eric.moore@lsi.com>

[SCSI] fusion - inactive raid support, and raid event bug fix's

inactive raid support, e.g. exposing hidden raid components
belonging to a volume that are inactive. Also misc bug fix's for
various raid asyn events.

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


# c6c727a1 29-Jan-2007 Eric Moore <eric.moore@lsi.com>

[SCSI] fusion - iocstatus, loginfo, and event debug updates

various string updates for iocstatus, logingo, and fw asyn events.

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


# 793955f5 29-Jan-2007 Eric Moore <eric.moore@lsi.com>

[SCSI] fusion - Greater than 255 target and lun support

Add support for greater than 255 target and luns.
Kill the hd->Target[] field, and change all references
of bus_id/target_id, to channel/id.

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


# 9f4203b3 04-Jan-2007 Eric Moore <eric.moore@lsil.com>

[SCSI] fusion: MODULE_VERSION support

* Add modinfo driver version support.
* Change copyright year to 2007.

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


# d9489fb6 06-Dec-2006 Randy Dunlap <randy.dunlap@oracle.com>

[PATCH] kernel-doc: fix fusion and i2o docs

Correct lots of typos, kernel-doc warnings, & kernel-doc usage in fusion and
i2o drivers.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 03a67a46 29-Nov-2006 Jan Engelhardt <jengelh@gmx.de>

Fix typos in doc and comments

Changes persistant -> persistent. www.dictionary.com does not know
persistant (with an A), but should it be one of those things you can
spell in more than one correct way, let me know.

Signed-off-by: Jan Engelhardt <jengelh@gmx.de>
Signed-off-by: Adrian Bunk <bunk@stusta.de>


# 7d12e780 05-Oct-2006 David Howells <dhowells@redhat.com>

IRQ: Maintain regs pointer globally rather than passing to IRQ handlers

Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.

The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).

Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.

Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.

I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.

This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:

struct pt_regs *old_regs = set_irq_regs(regs);

And put the old one back at the end:

set_irq_regs(old_regs);

Don't pass regs through to generic_handle_irq() or __do_IRQ().

In timer_interrupt(), this sort of change will be necessary:

- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);

I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().

Some notes on the interrupt handling in the drivers:

(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.

(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.

(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.

Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)


# ba856d32 11-Jul-2006 Eric Moore <eric.moore@lsil.com>

[SCSI] mptfusion: misc fix's

* removing obsolete 1066, 1066E from Kconfig
* initializing aen_event_read_flag after host reset
* remove oem references
* remove obsolete mpt_pq_filter command line option

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


# 0ccdb007 11-Jul-2006 Eric Moore <eric.moore@lsil.com>

[SCSI] mptfusion: firmware download boot fix's

Fix's to insure download boot could occur when
either channel of 1030 is reset. Necessary in order
for onboard controller in flashless environment
to become operational.

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


# 4f766dc6 11-Jul-2006 Eric Moore <eric.moore@lsil.com>

[SCSI] mptfusion: sas loginfo update

Adding more sas loginfo strings.

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


# d58b2725 11-Jul-2006 Eric Moore <eric.moore@lsil.com>

[SCSI] mptfusion: mptctl panic when loading

Fix panic for when mptctl is loading at the same time
when one of the fusion llds (mptsas/mptfc/mptspi) is loading.

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


# dace1453 01-Jul-2006 Thomas Gleixner <tglx@linutronix.de>

[PATCH] irq-flags: misc drivers: Use the new IRQF_ constants

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 3e00a5b2 29-Jun-2006 Eric Moore <eric.moore@lsil.com>

[SCSI] mptbase: mpt_interrupt should return IRQ_NONE

The way mpt_interrupt() was coded, it was impossible for the unhandled
interrupt detection logic to ever trigger. All interrupt handlers should
return IRQ_NONE when they have nothing to do.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Andrew Morton <akpm@osdl.com>
Signed-off-by: Eric Moore <Eric.Moore@lsil.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 6ab3d562 30-Jun-2006 Jörn Engel <joern@wohnheim.fh-wedel.de>

Remove obsolete #include <linux/config.h>

Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de>
Signed-off-by: Adrian Bunk <bunk@stusta.de>


# 80f7228b 30-Jun-2006 Adrian Bunk <bunk@stusta.de>

typo fixes: occuring -> occurring

Signed-off-by: Adrian Bunk <bunk@stusta.de>


# 87cf8986 27-Jun-2006 Eric Moore <eric.moore@lsil.com>

[SCSI] mptsas: Adding 1078 ROC support

* Adding 1078 ROC (Raid On Chip) Support - New host adapter

* Moving all PCI Vendor/Device ids to using internal defines; a request
from Christoph/James B. some time ago for when the next chip was added.

* Removing SAS 1066/1066E Vendor/Device IDs, as there are no plans to
manufacture that controller.

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


# c6387a48 20-Jun-2006 David S. Miller <davem@davemloft.net>

[SPARC]: Kill __irq_itoa().

This ugly hack was long overdue to die.

It was a way to print out Sparc interrupts in a more freindly format,
since IRQ numbers were arbitrary opaque 32-bit integers which vectored
into PIL levels. These 32-bit integers were not necessarily in the
0-->NR_IRQS range, but the PILs they vectored to were.

The idea now is that we will increase NR_IRQS a little bit and use a
virtual<-->real IRQ number mapping scheme similar to PowerPC.

That makes this IRQ printing hack irrelevant, and furthermore only a
handful of drivers actually used __irq_itoa() making it even less
useful.

Signed-off-by: David S. Miller <davem@davemloft.net>


# d6be06c8 24-May-2006 Michael Reed <mdr@sgi.com>

[SCSI] mptfc: abort of board reset leaves port dead requiring reboot

The driver uses msleep_interruptible() in the code path responsible
for resetting the card's ports via the lsiutil command. If a
<ctrl-c> is received during the reset it can leave a port in such
a state that the only way to regain its use is to reboot the system.
Changing from msleep_interruptible() to msleep() corrects the problem.

Signed-off-by: Michael Reed <mdr@sgi.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 80d3ac77 24-May-2006 Michael Reed <mdr@sgi.com>

[SCSI] mptfusion: move fc event/reset handling to mptfc

Move fibre channel event and reset handling to mptfc. This will
result in fewer changes over time that need to be applied to
either mptbase.c or mptscsih.c.

Signed-off-by: Michael Reed <mdr@sgi.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 9bf0a28c 27-Apr-2006 Vivek Goyal <vgoyal@in.ibm.com>

[SCSI] kdump: mpt fusion driver initialization failure fix

MPT fusion driver initialization fails while second kernel is booting,
after a system crash (if kdump kernel is configured). Oops message is
pasted below.

*****************************************************************************
Fusion MPT base driver 3.03.08
Copyright (c) 1999-2005 LSI Logic Corporation
Fusion MPT SAS Host driver 3.03.08 ACPI: PCI Interrupt 0000:01:00.0[A] -> Link [LNKA] -> GSI 5 (level, low) -> IRQ 5
mptbase: Initiating ioc0 bringup
BUG: unable to handle kernel paging request at virtual address 00002608
printing eip:
c11782fd
*pde = 00000000
Oops: 0000 [#1]
Modules linked in:
CPU: 0
EIP: 0060:[<c11782fd>] Not tainted VLI
EFLAGS: 00010046 (2.6.17-rc1-16M #2)
EIP is at mptscsih_io_done+0x27/0x3a3
eax: c4fed000 ebx: c4fed000 ecx: 00002600 edx: 00000298
esi: c11782d6 edi: 00002600 ebp: 00000000 esp: c1332f74
ds: 007b es: 007b ss: 0068
Process swapper (pid: 0, threadinfo=c1332000 task=c128f9c0) Stack: <0>0000006c 00000020 00000298 00002600 c4fed000 c4fed000 c11782d6 0000260 0
00000000 c1172c49 c4fed000 c1305b40 00000005 00000000 c1172d75 c48877e0
c1029687 00000000 c1307fb8 00000000 c1305a00 00000001 00000000 c1307fb8
Call Trace:
<c11782d6> mptscsih_io_done+0x0/0x3a3 <c1172c49> mpt_turbo_reply+0xbb/0xd3
<c1172d75> mpt_interrupt+0x22/0x2b <c1029687> misrouted_irq+0x63/0xcb
<c10297b3> note_interrupt+0x43/0x98 <c10292f9> __do_IRQ+0x68/0x8f
<c1003fac> do_IRQ+0x36/0x4e
=======================
<c1002aa6> common_interrupt+0x1a/0x20 <c1001150> mwait_idle+0x1a/0x2a
<c10010bf> cpu_idle+0x40/0x5c <c1308610> start_kernel+0x17a/0x17c Code: 5e 5f 5d c3 55 89 cd 57 56 53 83 ec 14 89 54 24 0c 89 44 24 10 8b 90 cc 00 00 00 8b 4c 24 0c 81 c2 98 02 00 00 85 ed 89 54 24 08 <0f> b7 79 08 89 fe 74 04 0f b7 75 08 66 39 f7 75 0d 8b 44 24 0c
*******************************************************************************

o Kdump capture kernel boot fails during initialization of MPT fusion driver.
(LSI Logic / Symbios Logic SAS1064E PCI-Express Fusion-MPT SAS (rev 01))

o Problem is easily reproducible, if system crashed while some disk activity
like cp operation was going on.

o After a system crash, devices are not shutdown and capture kernel starts
booting while skipping BIOS. Hence underlying device is left in operational
state. In this case scsi contoller was left with interrupt line asserted
reply FIFO was not empty. When driver starts initializing in the second
kernel, it receives the interrupt the moment request_irq() is called.
Interrupt handler, reads the message from reply FIFO and tries to access
the associated message frame and panics, as in the new kernel's context
that message frame is not valid at all.

o In this scenario, probably we should delay the request_irq() call. First
bring up the IOC, reset it if needed and then should register for irq.

o I have tested the patch with SAS1064E and 53c1030 controllers.

Signed-off-by: Vivek Goyal <vgoyal@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Acked-by: "Moore, Eric Dean" <Eric.Moore@lsil.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 4ff42a66 17-May-2006 James Bottomley <James.Bottomley@steeleye.com>

[SCSI] mptspi: reset handler shouldn't be called for other bus protocols

All registered reset callback handlers are called during reset processing.
The mptspi modules has its own reset callback handler, just recently
added for issuing domain validation after host reset. If either the mptsas or
mptfc driver are loaded, this callback could be called. Thus resulting
in domain validation being issued for sas or fibre end devices.

Fix this by having mptbase.c check the bus type against the driver
type and only call the reset handler if they match (or if it's a
non-bus specific reset handler).

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


# 509e5e5d 26-Apr-2006 Eric Moore <eric.moore@lsil.com>

[SCSI] fusion - bug fix stack overflow in mptbase

Bug fix for stack overflow in EventDescriptionStr, (a function
for debuging firmware events). We allocated 50 bytes on local stack
for buff[], however there are places in the code where we've attempted
copying in greater than 50 bytes into buff[].

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


# 65207fed 21-Apr-2006 Moore, Eric <Eric.Moore@lsil.com>

[SCSI] - fusion - mptfc bug fix's to prevent deadlock situations

mptbase.h

bump version number to 3.03.09

remove unneeded flags
define workq and remove old fc specific locks

mptbase.c

initialize new lock and don't initialize two removed locks

mptscsih.c

when firmware reports target is no longer there, return
DID_REQUEUE for fc hosts so that i/o doesn't get killed until
the transport has an opportunity to manage the loss via its
dev loss timer

when the "eh_abort" routine is called, check to see if the
driver has the command or not before looking to see if a reset
is pending. James Smart and I talked about this and believe
that the API for this routine is: if driver doesn't have
command, return SUCCESS. This change helps prevent a target
from being taken offline. SUCCESS is returned because it's
likely that the command completed after error recovery timed
it out but before it could be aborted.

provide a routine to queue work to newly created workq, and
use it.

remove "ioc" from mptscsih_abort() it was only used one time.
the other references were via hd->ioc, so I just moved it....
net change in references to ioc via hd->ioc is zero

move hd->resetPending test and hd->timeouts increment to after
the test for whether the command to be aborted remains known
to the driver

Make certain that the workq exists before queuing work to it.

mptfc.c

no longer need to lock rport data structures as I was able to
single thread the code! I fixed up the debug code to
eliminate compilation messages due to type mismatch in the
printk. Got rid of some no longer needed rport flags.
Initialize and destroy the workq used for the rescan work.

simplify the logic regarding the increment of
fc_rescan_work_count. use post increment and test for zero
vs. pre increment and test for one; eliminate work_count
variable: queue_work can be called with the work_lock held as
it doesn't sleep

Signed-off-by: Michael Reed <mdr@sgi.com>
Signed-off-by: Eric Moore <Eric.Moore@lsil.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# bd23e94c 17-Apr-2006 Moore, Eric <Eric.Moore@lsil.com>

[SCSI] mptfusion: bug fix's for raid components adding/deleting

This patch handles case where raid hidden components
are not being removed when power turned off to device
attached to expander, as well as the case of
exposing raid components when power is turned back on
to devices attached to an expander. (This is a repost
of this patch, with mptsas_is_end_device declared
further up in the code.)

This patch contains some other miscellaneous bug fix's.

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


# c972c70f 14-Mar-2006 Moore, Eric <Eric.Moore@lsil.com>

[SCSI] fusion - static fix's

Patch previously provided from Adrian Bunk <bunk@stusta.de>,
moving some functions to static. This is already in
the -mm tree.

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


# 3a892bef 14-Mar-2006 Moore, Eric <Eric.Moore@lsil.com>

[SCSI] fusion - move some debug firmware event debug msgs to verbose level

Created a debug level MPT_DEBUG_VERBOSE_EVENTS.
Moving some of the more vebose debug messages
for firwmare events into new debug level. Also
added some more firmware events descriptions.

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


# 5bf52c4f 14-Mar-2006 Moore, Eric <Eric.Moore@lsil.com>

[SCSI] fusion - loginfo header update

This header is provided to better understand
loginfo codes returned by the mpt fusion firmware.

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


# c92f222e 01-Mar-2006 James Bottomley <James.Bottomley@steeleye.com>

[SCSI] mptspi: Add transport class Domain Validation

This is the first half of a patch to add the generic domain validation
to mptspi. It also creates a secondary "virtual" channel for raid
component devices since these are now exported with no_uld_attach.

What Eric and I would have really liked is to export all physical
components on channel 0 and all raid components on channel 1.
Unfortunately, this would result in device renumbering on platforms with
mixed RAID/Physical devices which was considered unacceptable for
userland stability reasons.

Still to be done is to plug back the extra parameter setting and DV
pieces on reset and hotplug.

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


# 592f9c2f 02-Feb-2006 Moore, Eric <Eric.Moore@lsil.com>

[SCSI] fusion - mptctl - backplane istwi fix

Moving the toolbox call from mptbase.c, over to
mptctl.c, and using the mptctl infastructure to issue
the call. The existing code is hanging on certain HP platforms
when this ioctl is issued, and this patch fix's that.

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


# 5b5ef4f6 02-Feb-2006 Moore, Eric <Eric.Moore@lsil.com>

[SCSI] fusion - mptctl - Event Log Fix

Use the hard coded value MPTCTL_EVENT_LOG_SIZE to fix
bug where in certain cases, the ioc->eventLogSize was
initialized.

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


# 335a9412 17-Jan-2006 Moore, Eric <Eric.Moore@lsil.com>

[SCSI] fusion: unloading the driver results in panic - fix

The ioc->alt_ioc->alt_ioc pointer is not getting cleared
during driver unload time. This dangling pointer
can result in panic in certain circumstances, such
as error recovery, or firmware download in flashless
environments. This only impacts dual functions controllers,
such as 1030. Please apply.

This patch also includes a small cosmetic name change
for mpt_spi_log_info.

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


# 4ddce14e 17-Jan-2006 Christoph Hellwig <hch@infradead.org>

[SCSI] fusion: add MSI support

On Mon, Jan 16, 2006 at 06:53:24PM -0700, Moore, Eric wrote:
> Adding MSI support, and command line for enabling
> it. By default, the command line option has MSI disabled.

mpt_msi_enable is initialized to 0 implicitly, no need to do that. Also
replace if (mpt_msi_enable == 1) tests with just if (mpt_msi_enable).

Updated patch below:

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


# ece50914 16-Jan-2006 Moore, Eric <Eric.Moore@lsil.com>

[SCSI] fusion: add verbose messages for RAID actions

A customer request to send raid asyn actions
from firmware to the event syslog. This shows
when raid volumes go degraded, or complete resync,
or volumes created/deleted, etc.

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


# 432b4c8b 16-Jan-2006 Moore, Eric <Eric.Moore@lsil.com>

[SCSI] fusion: mptsas, increase discovery timout to 300 seconds

Increase the port enable timeout only for SAS from 30 to 300 seconds.
A customer request for the handling large topologies.

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


# d8e925dc 16-Jan-2006 Moore, Eric <Eric.Moore@lsil.com>

[SCSI] fusion: spi bus reset when driver loads

This patch is for spi. This issues bus reset when driver
loads. Handling cases when initator has negotiated for packetized,
and target negotiated for non-packetized; effectly this bus reset
is getting both target and initiator on the same sheet of music.

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


# 569b11dc 13-Jan-2006 Moore, Eric <Eric.Moore@lsil.com>

[SCSI] fusion - fix pci express bug

The fix is to write 'MPI_HIM_DIM' to the Host Interrupt Mask
register, when enabling interrupts. Instead of the
tilde of MPI_HIM_RIM.

Apparently writing '1's to some of the reserved bits was causing
all the bits to go to `1`, which effectly disabled all interrupts.

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


# 6d5b0c31 13-Jan-2006 Moore, Eric <Eric.Moore@lsil.com>

[SCSI] fusion - adding support for FC949ES

Add software recognition for the new LSI Logic Fibre Channel controller.

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


# 05e8ec17 13-Jan-2006 Michael Reed <mdr@sgi.com>

[SCSI] mptfusion - fc transport attributes

Signed-off-by: Michael Reed <mdr@sgi.com>
Signed-off-by: Eric Moore <Eric.Moore@lsil.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 1ca00bb7 13-Jan-2006 Christoph Hellwig <hch@lst.de>

[SCSI] fusion: kzalloc / kcalloc conversion

Convert kmalloc + memset to kzalloc or kcalloc in fusion.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# a9b2937a 16-Nov-2005 Moore, Eric Dean <Eric.Moore@lsil.com>

[SCSI] mptfusion - bus_type, change SCSI to SPI

This changes to SPI for the bus_type enumeration.

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


# 2a238ea5 01-Dec-2005 Moore, Eric Dean <Eric.Moore@lsil.com>

[SCSI] mptfusion : dv performance fix

Syncronization for Domain Validation workqueue and the initiation of the
alternate controller. Its possible that dv could be terminated if the
workqueue on the 1st channel doesn complete in time before the 2nd channel
begins initialization.

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


# f747307e 29-Nov-2005 Linus Torvalds <torvalds@g5.osdl.org>

Revert "[PATCH] drivers/message/fusion/mptbase.c: make code static"

This reverts commit 252ac865535e1ea9cc2d28be83f477d8d8b961a2.

It impacts the LSI customers using the mptstm target mode drivers
(source tar-ball at

ftp://ftp.lsil.com/HostAdapterDrivers/linux/Fusion-MPT/mptstm-1.00.13-src.tar.gz

for those who care).

Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 252ac865 08-Nov-2005 Adrian Bunk <bunk@stusta.de>

[PATCH] drivers/message/fusion/mptbase.c: make code static

This patch makes the following previously global and EXPORT_SYMBOL'ed
code static:
- struct mpt_proc_root_dir
- int mpt_stm_index

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 733482e4 08-Nov-2005 Olaf Hering <olh@suse.de>

[PATCH] changing CONFIG_LOCALVERSION rebuilds too much, for no good reason

This patch removes almost all inclusions of linux/version.h. The 3
#defines are unused in most of the touched files.

A few drivers use the simple KERNEL_VERSION(a,b,c) macro, which is
unfortunatly in linux/version.h.

There are also lots of #ifdef for long obsolete kernels, this was not
touched. In a few places, the linux/version.h include was move to where
the LINUX_VERSION_CODE was used.

quilt vi `find * -type f -name "*.[ch]"|xargs grep -El '(UTS_RELEASE|LINUX_VERSION_CODE|KERNEL_VERSION|linux/version.h)'|grep -Ev '(/(boot|coda|drm)/|~$)'`

search pattern:
/UTS_RELEASE\|LINUX_VERSION_CODE\|KERNEL_VERSION\|linux\/\(utsname\|version\).h

Signed-off-by: Olaf Hering <olh@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 466544d8 14-Sep-2005 Moore, Eric Dean <Eric.Moore@lsil.com>

[SCSI] fusion SAS support (mptsas driver) updates

Summary of Changes:
* splitting mpt_interrupt per Christophs suggestion
about a month ago
* rename ScsiCfgData to SpiCfgData structure,
then move all the raid related info into
new structure called RaidCfgData. This is
done because SAS supports RAID, as well as SPI,
so the raid stuff should be seperate.
* incorrect timeout calculation for cntdn
inside WaitForDoorbellAck and WaitForDoortbellInt
* add support for interpreting SAS Log Info
* Increase Event Log Size from 0xA to 0x32
* Fix bug in mptsas/mptfc/mptspi - when controller
has Initiator Mode Disabled, and only running in
TargetMode, the mptctl would panic when loading.
The fix is to return 0, instead of -ENODEV, in
SCSI LLD respective probe routines
* Fix bug in mptlan.c - driver will panic if
there is host reset, due to dev being set to
zero in mpt_lan_ioc_reset
* Fix's for SPI - Echo Buffer
* Several fix's in mptscsih_io_done - FCP Response
info, RESIDUAL_MISMATCH, Data Underrun, etc.
* Cleanup Error Handling - EH handlers,
mptscsih_flush_cmds, and zeroing out ScsiLookup
from mptscsih_qcmd
* Cleanup asyn event handling from
mptscsih -> mptscsih_event_process. Also
added support for SAS Persistent Table Full,
an asyn event

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


# 82ffb671 09-Sep-2005 Christoph Hellwig <hch@lst.de>

[SCSI] fusion core changes for SAS support

- various bits for SAS support from the LSI driver.
- use the device private data for the fusion target private data.
this should be using the midlayer target data framework, but we
can't move over to that until fusion has been switched to the
generic DV code
- use target ID and channel from the fusion target private data,
because those in scsi_device will be different for mptsas

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# c6678e0c 18-Aug-2005 Christoph Hellwig <hch@lst.de>

[SCSI] fusion: whitespace fixes

Acked by: Moore, Eric Dean <Eric.Moore@lsil.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 637fa99b 18-Aug-2005 Christoph Hellwig <hch@lst.de>

[SCSI] fusion: endianess fixes

Assorted endianess fixes. I'll work on full endianess annotations
later.

Acked by: Moore, Eric Dean <Eric.Moore@lsil.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 69218ee5 18-Aug-2005 Christoph Hellwig <hch@lst.de>

[SCSI] fusion: extended config header support

Acked by: Moore, Eric Dean <Eric.Moore@lsil.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>


# 2a569579 07-Jul-2005 Pavel Machek <pavel@ucw.cz>

[PATCH] pm: more u32 vs. pm_message_t fixes

Few more u32 vs. pm_message_t fixes.

Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# d485eb83 11-May-2005 Moore, Eric Dean <Eric.Moore@lsil.com>

[SCSI] fusion-kfree-cleanup

This patch is originally From: Jesper Juhl <juhl-lkml@dif.dk>

This patch gets rid of redundant NULL checks prior to calling kfree() in
drivers/message/* There are also a few small whitespace changes in there.

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


# 3fadc59d 11-May-2005 Moore, Eric Dean <Eric.Moore@lsil.com>

[SCSI] fusion - Adding pci recog support for Fibre 949X and 939X chips

* adding pci id support for new Fibre chips, 949X and 939X
* adding errata workaround - disabling PIO access except during fwdlb.

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


# d335cc38 30-Apr-2005 Moore, Eric Dean <Eric.Moore@lsil.com>

[SCSI] mptfusion: fix panic loading driver statically compiled


Adjust link ordering in the Makefile. Also, the ioc->DoneCtx handles
for mptspi/mptfc in the message frame. And I'm now not seeing the
panic.

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


# 7fadc87e 22-Apr-2005 Moore, Eric Dean <Eric.Moore@lsil.com>

[SCSI] mptfusion: mptbase cleanup, split driver support, DMA 32_BIT_MASK

(1) mptbase.c: Move registering pci ids to scsi lld drivers
(2) mptbase.c: Use the DMA_32BIT_MASK constant
(3) mptbase.c: Fix for multiple pci domains
(4) mptbase.c: Remove le32 conversion from BlockSize, which was u8 size
(5) mptbase.c: Remove credits, -sralston references , update copyright
(6) mptbase.c: split driver support

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


# 8d189f72 16-Apr-2005 Pavel Machek <pavel@ucw.cz>

[PATCH] fix u32 vs. pm_message_t in drivers/message

This fixes u32 vs. pm_message_t in drivers/message.

Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 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!