History log of /drivers/scsi/gdth.c
Revision Date Author Comments
9ffc93f203c18a70623f21950f1dd473c9ec48cd 28-Mar-2012 David Howells <dhowells@redhat.com> Remove all #inclusions of asm/system.h

Remove all #inclusions of asm/system.h preparatory to splitting and killing
it. Performed with the following command:

perl -p -i -e 's!^#\s*include\s*<asm/system[.]h>.*\n!!' `grep -Irl '^#\s*include\s*<asm/system[.]h>' *`

Signed-off-by: David Howells <dhowells@redhat.com>
77dfce076cbd76c04e90abff188d058cdbff78dd 25-Nov-2011 Cong Wang <amwang@redhat.com> scsi: remove the second argument of k[un]map_atomic()

Signed-off-by: Cong Wang <amwang@redhat.com>
5c10007560589a2335a77cbc92347b1474518296 29-Dec-2010 Julia Lawall <julia@diku.dk> [SCSI] gdth: Add missing call to gdth_ioctl_free

Add missing call to gdth_ioctl_free before aborting.

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

// <smpl>
@@
expression buf,ha,len,addr,E;
@@

buf = gdth_ioctl_alloc(ha, len, FALSE, &addr)
... when != false buf != NULL
when != true buf == NULL
when != \(E = buf\|buf = E\)
when != gdth_ioctl_free(ha, len, buf, addr)
*return ...;
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
f281233d3eba15fb225d21ae2e228fd4553d824a 16-Nov-2010 Jeff Garzik <jeff@garzik.org> SCSI host lock push-down

Move the mid-layer's ->queuecommand() invocation from being locked
with the host lock to being unlocked to facilitate speeding up the
critical path for drivers who don't need this lock taken anyway.

The patch below presents a simple SCSI host lock push-down as an
equivalent transformation. No locking or other behavior should change
with this patch. All existing bugs and locking orders are preserved.

Additionally, add one parameter to queuecommand,
struct Scsi_Host *
and remove one parameter from queuecommand,
void (*done)(struct scsi_cmnd *)

Scsi_Host* is a convenient pointer that most host drivers need anyway,
and 'done' is redundant to struct scsi_cmnd->scsi_done.

Minimal code disturbance was attempted with this change. Most drivers
needed only two one-line modifications for their host lock push-down.

Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Acked-by: James Bottomley <James.Bottomley@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
f63ae56e4e97fb12053590e41a4fa59e7daa74a4 08-Oct-2010 Dan Carpenter <error27@gmail.com> [SCSI] gdth: integer overflow in ioctl

gdth_ioctl_alloc() takes the size variable as an int.
copy_from_user() takes the size variable as an unsigned long.
gen.data_len and gen.sense_len are unsigned longs.
On x86_64 longs are 64 bit and ints are 32 bit.

We could pass in a very large number and the allocation would truncate
the size to 32 bits and allocate a small buffer. Then when we do the
copy_from_user(), it would result in a memory corruption.

CC: stable@kernel.org
Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
6038f373a3dc1f1c26496e60b6c40b164716f07e 15-Aug-2010 Arnd Bergmann <arnd@arndb.de> llseek: automatically add .llseek fop

All file_operations should get a .llseek operation so we can make
nonseekable_open the default for future file operations without a
.llseek pointer.

The three cases that we can automatically detect are no_llseek, seq_lseek
and default_llseek. For cases where we can we can automatically prove that
the file offset is always ignored, we use noop_llseek, which maintains
the current behavior of not returning an error from a seek.

New drivers should normally not use noop_llseek but instead use no_llseek
and call nonseekable_open at open time. Existing drivers can be converted
to do the same when the maintainer knows for certain that no user code
relies on calling seek on the device file.

The generated code is often incorrectly indented and right now contains
comments that clarify for each added line why a specific variant was
chosen. In the version that gets submitted upstream, the comments will
be gone and I will manually fix the indentation, because there does not
seem to be a way to do that using coccinelle.

Some amount of new code is currently sitting in linux-next that should get
the same modifications, which I will do at the end of the merge window.

Many thanks to Julia Lawall for helping me learn to write a semantic
patch that does all this.

===== begin semantic patch =====
// This adds an llseek= method to all file operations,
// as a preparation for making no_llseek the default.
//
// The rules are
// - use no_llseek explicitly if we do nonseekable_open
// - use seq_lseek for sequential files
// - use default_llseek if we know we access f_pos
// - use noop_llseek if we know we don't access f_pos,
// but we still want to allow users to call lseek
//
@ open1 exists @
identifier nested_open;
@@
nested_open(...)
{
<+...
nonseekable_open(...)
...+>
}

@ open exists@
identifier open_f;
identifier i, f;
identifier open1.nested_open;
@@
int open_f(struct inode *i, struct file *f)
{
<+...
(
nonseekable_open(...)
|
nested_open(...)
)
...+>
}

@ read disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}

@ read_no_fpos disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
... when != off
}

@ write @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}

@ write_no_fpos @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
... when != off
}

@ fops0 @
identifier fops;
@@
struct file_operations fops = {
...
};

@ has_llseek depends on fops0 @
identifier fops0.fops;
identifier llseek_f;
@@
struct file_operations fops = {
...
.llseek = llseek_f,
...
};

@ has_read depends on fops0 @
identifier fops0.fops;
identifier read_f;
@@
struct file_operations fops = {
...
.read = read_f,
...
};

@ has_write depends on fops0 @
identifier fops0.fops;
identifier write_f;
@@
struct file_operations fops = {
...
.write = write_f,
...
};

@ has_open depends on fops0 @
identifier fops0.fops;
identifier open_f;
@@
struct file_operations fops = {
...
.open = open_f,
...
};

// use no_llseek if we call nonseekable_open
////////////////////////////////////////////
@ nonseekable1 depends on !has_llseek && has_open @
identifier fops0.fops;
identifier nso ~= "nonseekable_open";
@@
struct file_operations fops = {
... .open = nso, ...
+.llseek = no_llseek, /* nonseekable */
};

@ nonseekable2 depends on !has_llseek @
identifier fops0.fops;
identifier open.open_f;
@@
struct file_operations fops = {
... .open = open_f, ...
+.llseek = no_llseek, /* open uses nonseekable */
};

// use seq_lseek for sequential files
/////////////////////////////////////
@ seq depends on !has_llseek @
identifier fops0.fops;
identifier sr ~= "seq_read";
@@
struct file_operations fops = {
... .read = sr, ...
+.llseek = seq_lseek, /* we have seq_read */
};

// use default_llseek if there is a readdir
///////////////////////////////////////////
@ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier readdir_e;
@@
// any other fop is used that changes pos
struct file_operations fops = {
... .readdir = readdir_e, ...
+.llseek = default_llseek, /* readdir is present */
};

// use default_llseek if at least one of read/write touches f_pos
/////////////////////////////////////////////////////////////////
@ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read.read_f;
@@
// read fops use offset
struct file_operations fops = {
... .read = read_f, ...
+.llseek = default_llseek, /* read accesses f_pos */
};

@ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write.write_f;
@@
// write fops use offset
struct file_operations fops = {
... .write = write_f, ...
+ .llseek = default_llseek, /* write accesses f_pos */
};

// Use noop_llseek if neither read nor write accesses f_pos
///////////////////////////////////////////////////////////

@ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
identifier write_no_fpos.write_f;
@@
// write fops use offset
struct file_operations fops = {
...
.write = write_f,
.read = read_f,
...
+.llseek = noop_llseek, /* read and write both use no f_pos */
};

@ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write_no_fpos.write_f;
@@
struct file_operations fops = {
... .write = write_f, ...
+.llseek = noop_llseek, /* write uses no f_pos */
};

@ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
@@
struct file_operations fops = {
... .read = read_f, ...
+.llseek = noop_llseek, /* read uses no f_pos */
};

@ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
@@
struct file_operations fops = {
...
+.llseek = noop_llseek, /* no read or write fn */
};
===== End semantic patch =====

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Julia Lawall <julia@diku.dk>
Cc: Christoph Hellwig <hch@infradead.org>
c45d15d24eb2b49bf734e1e5e7e103befb76b19b 02-Jun-2010 Arnd Bergmann <arnd@arndb.de> scsi: autoconvert trivial BKL users to private mutex

All these files use the big kernel lock in a trivial
way to serialize their private file operations,
typically resulting from an earlier semi-automatic
pushdown from VFS.

None of these drivers appears to want to lock against
other code, and they all use the BKL as the top-level
lock in their file operations, meaning that there
is no lock-order inversion problem.

Consequently, we can remove the BKL completely,
replacing it with a per-file mutex in every case.
Using a scripted approach means we can avoid
typos.

file=$1
name=$2
if grep -q lock_kernel ${file} ; then
if grep -q 'include.*linux.mutex.h' ${file} ; then
sed -i '/include.*<linux\/smp_lock.h>/d' ${file}
else
sed -i 's/include.*<linux\/smp_lock.h>.*$/include <linux\/mutex.h>/g' ${file}
fi
sed -i ${file} \
-e "/^#include.*linux.mutex.h/,$ {
1,/^\(static\|int\|long\)/ {
/^\(static\|int\|long\)/istatic DEFINE_MUTEX(${name}_mutex);

} }" \
-e "s/\(un\)*lock_kernel\>[ ]*()/mutex_\1lock(\&${name}_mutex)/g" \
-e '/[ ]*cycle_kernel_lock();/d'
else
sed -i -e '/include.*\<smp_lock.h\>/d' ${file} \
-e '/cycle_kernel_lock()/d'
fi

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: linux-scsi@vger.kernel.org
Cc: "James E.J. Bottomley" <James.Bottomley@suse.de>
2c076eea6d3005c54f6e7be5938477fdc7027686 11-Aug-2010 Roel Kluin <roel.kluin@gmail.com> gdth: unmap ccb_phys when scsi_add_host() fails in gdth_eisa_probe_one()

unmap ccb_phys as well when scsi_add_host() fails

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Cc: Achim Leubner <achim_leubner@adaptec.com>
Cc: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
f4927c45beda9a70e5c3bda0bd9f12b4f713c00b 27-Apr-2010 Arnd Bergmann <arnd@arndb.de> scsi: Push down BKL into ioctl functions

Push down the bkl into ioctl functions on the scsi layer.

[jkacur: Forward declaration missing ';'.
Conflicting declaraction in megaraid.h changed
Fixed missing inodes declarations]

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: John Kacur <jkacur@redhat.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
6ce00cae684e7c6310e14634320184ca3c011750 11-Mar-2010 Roel Kluin <roel.kluin@gmail.com> [SCSI] gdth: fix buffer overflow

This allows i == MAXHA, which is out of range

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
5a0e3ad6af8660be21ca98a971cd00f331318c05 24-Mar-2010 Tejun Heo <tj@kernel.org> include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h

percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.

2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).

* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
1fe6dbf4d0afba52ad0249f398e6296a1433a004 04-Jan-2010 Dave Jones <davej@redhat.com> [SCSI] gdth: Convert to use regular kernel types.

converted using this script..

perl -p -i -e 's|ulong32|u32|g' drivers/scsi/gdth*
perl -p -i -e 's|ulong64|u64|g' drivers/scsi/gdth*
perl -p -i -e 's|ushort|u16|g' drivers/scsi/gdth*
perl -p -i -e 's|unchar|u8|g' drivers/scsi/gdth*
perl -p -i -e 's|ulong|unsigned long|g' drivers/scsi/gdth*
perl -p -i -e 's|PACKED|__attribute__((packed))|g' drivers/scsi/gdth*

sha1sum of the generated code was identical before and after.

Signed-off-by: Dave Jones <davej@redhat.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
690e744869f3262855b83b4fb59199cf142765b0 20-Oct-2009 Dave Jones <davej@redhat.com> [SCSI] gdth: Prevent negative offsets in ioctl CVE-2009-3080

A negative offset could be used to index before the event buffer and
lead to a security breach.

Signed-off-by: Dave Jones <davej@redhat.com>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
284901a90a9e0b812ca3f5f852cbbfb60d10249d 07-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>
6a35528a8346f6e6fd32ed7e51f04d1fa4ca2c01 07-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>
ced7172ad94713f9023a3c279082402ac7750ba8 22-Nov-2008 Al Viro <viro@ftp.linux.org.uk> gdth section fixes

PCI side of driver should be devinit, not init

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
242f9dcb8ba6f68fcd217a119a7648a4f69290e9 14-Sep-2008 Jens Axboe <jens.axboe@oracle.com> block: unify request timeout handling

Right now SCSI and others do their own command timeout handling.
Move those bits to the block layer.

Instead of having a timer per command, we try to be a bit more clever
and simply have one per-queue. This avoids the overhead of having to
tear down and setup a timer for each command, so it will result in a lot
less timer fiddling.

Signed-off-by: Mike Anderson <andmike@linux.vnet.ibm.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
46787b481be00d5443d385480d12470728406cf4 16-May-2008 Jonathan Corbet <corbet@lwn.net> gdth: cdev lock_kernel() pushdown

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
a85591fd0baf4ed3f03ee1aaac6a985e400cf089 05-May-2008 James Bottomley <James.Bottomley@HansenPartnership.com> [SCSI] gdth: fix Error: Driver 'gdth' is already registered, aborting...

This message appears on modprobe/rmmod/modprobe of the driver. It's
caused because if the driver has no instances, it returns an error
from gdth_init, which causes the module to fail to load.
Unfortunately, the module's pci driver is still registered at this
point.

Fix this by making gdth behave like a modern driver and insert even if
it doesn't find any instances (in case of hot plug or software driven
binding).

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2d6f0d0cd94f9b8b24102300d8dd9cbbd1688826 05-May-2008 James Bottomley <James.Bottomley@HansenPartnership.com> [SCSI] gdth: fix timer handling

The global timer handling is problematic in that if someone unbinds a
PCI gdth instance, the BUG_ON() in the timer will cause a panic.

Fix this by making the timer start and stop depending on whether there
are instances present. This should also permit binding and unbinding
to work.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
64a87b244b9297667ca80264aab849a36f494884 30-Apr-2008 Boaz Harrosh <bharrosh@panasas.com> [SCSI] Let scsi_cmnd->cmnd use request->cmd buffer

- struct scsi_cmnd had a 16 bytes command buffer of its own.
This is an unnecessary duplication and copy of request's
cmd. It is probably left overs from the time that scsi_cmnd
could function without a request attached. So clean that up.

- Once above is done, few places, apart from scsi-ml, needed
adjustments due to changing the data type of scsi_cmnd->cmnd.

- Lots of drivers still use MAX_COMMAND_SIZE. So I have left
that #define but equate it to BLK_MAX_CDB. The way I see it
and is reflected in the patch below is.
MAX_COMMAND_SIZE - means: The longest fixed-length (*) SCSI CDB
as per the SCSI standard and is not related
to the implementation.
BLK_MAX_CDB. - The allocated space at the request level

- I have audit all ISA drivers and made sure none use ->cmnd in a DMA
Operation. Same audit was done by Andi Kleen.

(*)fixed-length here means commands that their size can be determined
by their opcode and the CDB does not carry a length specifier, (unlike
the VARIABLE_LENGTH_CMD(0x7f) command). This is actually not exactly
true and the SCSI standard also defines extended commands and
vendor specific commands that can be bigger than 16 bytes. The kernel
will support these using the same infrastructure used for VARLEN CDB's.
So in effect MAX_COMMAND_SIZE means the maximum size command
scsi-ml supports without specifying a cmd_len by ULD's

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
d35055a0f2637f29f95001a67b464fe833b09ebc 28-Feb-2008 Boaz Harrosh <bharrosh@panasas.com> [SCSI] gdth: remove command accessors

These are no longer necessary.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Tested-by: Joerg Dorchain: <joerg@dorchain.net>
Tested-by: Stefan Priebe <s.priebe@allied-internet.ag>
Tested-by: Jon Chelton <jchelton@ffpglobal.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
cff2680643f9288a1cd4e27c241e1da51f476d66 16-Feb-2008 Jeff Garzik <jeff@garzik.org> [SCSI] gdth: convert to PCI hotplug API

- remove PCI device sort, which greatly simplifies PCI probe,
permitting direct, per-HBA function calls rather than an indirect
route to the same end result.

- remove need for pcistr[]

Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
4c9c8d782c8dddc5e97d33210e8a993cec6bc168 16-Feb-2008 Jeff Garzik <jeff@garzik.org> [SCSI] gdth: PCI probe cleanups, prep for PCI hotplug API conversion

- Reduce uses of gdth_pci_str::pdev, preferring a local variable
(or function arg) 'pdev' instead.

- Reduce uses of gdth_pcistr array, preferring local variable
(or function arg) 'pcistr' instead.

- Eliminate lone use of gdth_pci_str::irq, using equivalent
pdev->irq instead

- Eliminate assign-only gdth_pci_str::io_mm

Note: If the indentation seems weird, that's because a line was
converted from spaces to tabs, when it was modified.

Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
1b96f8955aaeeb05f7fb7ff548aa12415fbf3904 10-Mar-2008 Sven Schnelle <svens@bitebene.org> [SCSI] gdth: Allocate sense_buffer to prevent NULL pointer dereference

Fix NULL pointer dereference during execution of Internal commands,
where gdth only allocates scp, but not scp->sense_buffer. The rest of
the code assumes that sense_buffer is allocated, which leads to a kernel
oops e.g. on reboot (during cache flush).

Signed-off-by: Sven Schnelle <svens@stackframe.org>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
ee54cc6af95a7fa09da298493b853a9e64fa8abd 28-Feb-2008 Boaz Harrosh <bharrosh@panasas.com> [SCSI] gdth: fix to internal commands execution

The recent patch named:
[SCSI] gdth: !use_sg cleanup and use of scsi accessors

has done a bad job in handling internal commands issued by gdth_execute().

Internal commands are issued with device gdth_cmd_str ready made directly
to the card, without any mapping or translations of scsi commands. So here
I added a gdth_cmd_str pointer to the gdth_cmndinfo private structure which
is then copied directly to host.

following this patch is a cleanup that removes the home cooked accessors
and reverts them to regular scsi_cmnd accessors. Since they are not used
anymore. After review maybe the 2 patches should be squashed together.

FIXME: There is still a problem with gdth_get_info(). as reported there
is a WARN_ON trigerd in dma_free_coherent() when doing:
$ cat /proc/sys/gdth/0

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Tested-by: Joerg Dorchain: <joerg@dorchain.net>
Tested-by: Stefan Priebe <s.priebe@allied-internet.ag>
Tested-by: Jon Chelton <jchelton@ffpglobal.com>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
b31ddd31c266c2ad1b708cad0d3d8e0aa7fa2737 28-Feb-2008 Boaz Harrosh <bharrosh@panasas.com> [SCSI] gdth: bugfix for the at-exit problems

gdth_exit would first remove all cards then stop the timer
and would not sync with the timer function. This caused a crash
in gdth_timer() when module was unloaded.
So del_timer_sync the timer before we delete the cards.

also the reboot notifier function would crash. So clean
that up and fix the crashes.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Tested-by: Joerg Dorchain: <joerg@dorchain.net>
Tested-by: Stefan Priebe <s.priebe@allied-internet.ag>
Tested-by: Jon Chelton <jchelton@ffpglobal.com>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
99109301d103fbf0de43fc5a580a406c12a501e0 13-Feb-2008 Sergio Luis <sergio@larces.uece.br> [SCSI] gdth: update deprecated pci_find_device

Fix compilation warning in gdth.c, which was using the deprecated
pci_find_device.

drivers/scsi/gdth.c:645: warning: 'pci_find_device' is deprecated (declared at include/linux/pci.h:495)

Changing it to use pci_get_device, instead.

Signed-off-by: Sergio Luis <sergio@larces.uece.br>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
61c92814dc324b541391757062ff02fbf3b08086 12-Feb-2008 Boaz Harrosh <bharrosh@panasas.com> [SCSI] gdth: scan for scsi devices

The patch: "gdth: switch to modern scsi host registration"

missed one simple fact when moving a way from scsi_module.c.
That is to call scsi_scan_host() on the probed host.
With this the gdth driver from 2.6.24 is again able to
see drives and boot.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Tested-by: Joerg Dorchain <joerg@dorchain.net>
Tested-by: Stefan Priebe <s.priebe@allied-internet.ag>
Tested-by: Jon Chelton <jchelton@ffpglobal.com>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
230e886e7bd663ff2e83cdeede12d7f09b9d3711 14-Dec-2007 Jeff Garzik <jeff@garzik.org> [SCSI] gdth: kill unneeded 'irq' argument

Neither gdth_get_status() nor __gdth_interrupt() need their 'irq' argument,
so remove it.

[akpm@linux-foundation.org: coding style fixes]
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Acked-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
45711f1af6eff1a6d010703b4862e0d2b9afd056 22-Oct-2007 Jens Axboe <jens.axboe@oracle.com> [SG] Update drivers to use sg helpers

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
05dd7ed2c7e22d0fc3027fc27a072664bbdf8274 18-Oct-2007 Adrian Bunk <bunk@kernel.org> [SCSI] gdth: __init fixes

This patch fixes the following build warnings:

WARNING: vmlinux.o(.text+0xbcffdb): Section mismatch: reference to .init.text.20:gdth_search_drives (between 'gdth_pci_probe_one' and 'gdth_start_timeout')
WARNING: vmlinux.o(.text+0xbd0102): Section mismatch: reference to .init.text.20:gdth_enable_int (between 'gdth_pci_probe_one' and 'gdth_start_timeout')

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
c596cc46ba1c5769866efe586daff3422bc31afe 15-Oct-2007 Linus Torvalds <torvalds@woody.linux-foundation.org> scsi/gdth: fix crash in gdth_timeout if no gdth controllers found

If the gdth module is loaded (or compiled in), the gdth_timeout function
gets started even if no actual gdth controllers are found b the probing.

That ends up not only being unnecessary, but also causes a crash due to
the function blindly just trying to pick the first entry off the
"gdth_instances" list, and accessing it - which obviously doesn't work
if the list is empty!

Noticed by Ingo Molnar.

Tested-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
c8e91b0a8fc8493e3bf3efcb3c8f866e9453cf1c 12-Oct-2007 Dhaval Giani <dhaval@linux.vnet.ibm.com> [SCSI] gdth: fix CONFIG_ISA build failure

drivers/scsi/gdth.c: In function ‘gdth_search_dev’:
drivers/scsi/gdth.c:646: warning: ‘pci_find_device’ is deprecated
(declared at include/linux/pci.h:482)
drivers/scsi/gdth.c: In function ‘gdth_init_isa’:
drivers/scsi/gdth.c:857: error: ‘gdth_irq_tab’ undeclared (first use in
this function)
drivers/scsi/gdth.c:857: error: (Each undeclared identifier is reported
only once
drivers/scsi/gdth.c:857: error: for each function it appears in.)
drivers/scsi/gdth.c: In function ‘gdth_copy_internal_data’:
drivers/scsi/gdth.c:2362: warning: unused variable ‘sg’

Looking into the code I notice that gdth_irq_tab is not declared with
CONFIG_ISA=y and !CONFIG_EISA.

The values seem to be same in 2.6.23 (I am not sure why it has been put
with #ifdefs in -mm) so I have just modified the #ifdef to take care of
CONFIG_ISA as well.

Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
3892d88ae6fb186ff6205f764213b556d70800b0 02-Oct-2007 Boaz Harrosh <bharrosh@panasas.com> [SCSI] gdth: !use_sg cleanup and use of scsi accessors

gdth_execute() will issue an internal, none scsi-standard commands
onto __gdth_queuecommand(). Since it is not recommended to set
struct scsi_cmnd IO members in llds, gdth now uses internal IO
members for IO. In the case of gdth_execute() these members will be
set properly. In case the command was issued from scsi-ml
(by gdth_queuecommand) they will be set from scsi IO accessors.

* define gdth IO accessors and use them throughout the driver.
* use an sg-of-one in gdth_execute() and fix gdth_special_cmd()
accordingly.
* Clean the not use_sg code path and company

Signed-off-by Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
f842b64e0ffbcc9ce48a3bf799d0b005094107c1 02-Oct-2007 Boaz Harrosh <bharrosh@panasas.com> [SCSI] gdth: Move members from SCp to gdth_cmndinfo, stage 2

- Cleanup the rest of the scsi_cmnd->SCp members and move them
to gdth_cmndinfo:
SCp.this_residual => priority
SCp.buffers_residual => timeout
SCp.Status => status and dma_dir
SCp.Message => info
SCp.have_data_in => volatile wait_for_completion
SCp.sent_command => OpCode
SCp.phase => phase

- Two more members will be naturally removed in the !use_sg cleanup

TODO: What is the meaning of gdth_cmndinfo.phase? (rhetorically)

Signed-off-by Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
3058d5de47ce09ac0e531290566937c7d94d0653 02-Oct-2007 Boaz Harrosh <bharrosh@panasas.com> [SCSI] gdth: Setup proper per-command private data

- scsi_cmnd and specifically ->SCp of, where heavily abused
with internal meaning members and flags. So introduce a new
struct gdth_cmndinfo, put it on ->host_scribble and define a
gdth_cmnd_priv() accessor to retrieve it from a scsi_cmnd.

- The structure now holds two members:
internal_command - replaces the IS_GDTH_INTERNAL_CMD() croft.
sense_paddr - which was a 64-bit spanning on 2 32-bit members of SCp.
More overloaded members from SCp and scsi_cmnd will be moved in a later
patch (For easy review).

- Split up gdth_queuecommand to an additional internal_function. The later
is the one called by gdth_execute(). This will be more evident later in
the scsi accessors patch, but it also facilitates in the differentiation
between internal_command and external. And the setup of gdth_cmndinfo of
each command.

Signed-off-by Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
884f7fba09646714f94d945162e698f0822a6fdd 02-Oct-2007 Boaz Harrosh <bharrosh@panasas.com> [SCSI] gdth: Remove gdth_ctr_tab[]

- Places like Initialization and Reset that Just loop on all devices can
use the link list with the list_for_each_entry macro.
But the io_ctrl from user mode now suffers performance-wise because
code has to do a sequential search for the requested host number.
I have isolated this search in a gdth_find_ha(int hanum) member
for future enhancement if needed.

Signed-off-by Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
835cc24aff0fd4b9da9d0a45d9bd043adcb2cf89 02-Oct-2007 Christoph Hellwig <hch@lst.de> [SCSI] gdth: switch to modern scsi host registration

- Use scsi_add_host and friends and track instances ourselves. And
generally modernize the driver's structure.

- TODO: Next we can remove the controller table
- TODO: Fix use of deprecated pci_find_device()

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
10e1b4bc9238687a4b1311bd5b6769d6b8c704e6 02-Oct-2007 Boaz Harrosh <bharrosh@panasas.com> [SCSI] gdth: gdth_interrupt() gdth_get_status() & gdth_wait() fixes

- gdth_get_status() returns a single device interrupt IStatus
- gdth_interrupt split to __gdth_interrupt() that receives
flags if is called from gdth_wait().
- Use dev_id passed from kernel and do not loop on all
controllers.
- gdth_wait(), get read of all global variables and call the new
__gdth_interrupt with these variables on the stack

Signed-off-by Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
45f1a41b2b2e02e91d29bde66a8da4d050959f65 02-Oct-2007 Boaz Harrosh <bharrosh@panasas.com> [SCSI] gdth: clean up host private data

- Based on same patch from Christoph Hellwig <hch@lst.de>

- Get rid of all the indirection in the Scsi_Host private data and always
put the gdth_ha_str directly into it.

- Change all internal functions prototype to recieve an "gdth_ha_str *ha"
pointer directlly and kill all that redundent access to the "gdth_ctr_tab[]"
controller-table.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
52759e6abc88fe007a080772ee01ef1154f96f30 02-Oct-2007 Christoph Hellwig <hch@lst.de> [SCSI] gdth: Remove virt hosts

The virt_ctr option allows to register a new scsi_host for each bus
on the raid controller. This non-default option makes no sense with
the current scsi code and prevents cleaning up the host registration,
so remove it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
69916b7ceac0dfbbc868ae5451062cb789b1b58a 02-Oct-2007 Jeff Garzik <jeff@garzik.org> [SCSI] gdth: Reorder scsi_host_template intitializers

shuffle scsi_host_template members such that they appear in the
order in which they are defined in the header. this makes is easier
to verify when initializers are missing members.

Signed-off-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
a52667f3cd84fa395e98b505967070b984fac4df 02-Oct-2007 Jeff Garzik <jeff@garzik.org> [SCSI] gdth: kill gdth_{read,write}[bwl] wrappers

They are direct equivalents to {read,write}[bwl].

Signed-off-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
8d7a5da4fc95cb6210cd66e7c886161e10a1307f 02-Oct-2007 Jeff Garzik <jeff@garzik.org> [SCSI] gdth: Remove 2.4.x support, in-kernel changelog

* Remove in-source changelog. It's archived permanently in git and
various kernel archives, and changelogs should exist purely in git.

* Remove 2.4.x kernel support. It is an active obstacle to
modernizing this driver, at this point. This includes killing
gdth_kcompat.h which is 100% redundant in modern kernels.

Signed-off-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
8514ef27ee462747454f26a77982f670d9c3c391 02-Oct-2007 Christoph Hellwig <hch@lst.de> [SCSI] gdth: split out pci probing

Split out per-device pci probing and put it under proper CONFIG_PCI.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
706a5d456762e77e199903e55377a9c00814c007 02-Oct-2007 Christoph Hellwig <hch@lst.de> [SCSI] gdth: split out eisa probing

Split eisa probing into it's own helper, and do proper error unwinding.
Protect EISA probind by the proper CONFIG_EISA symbol.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
aed91cb520747d08dd5cb0220d0dd3492bead220 02-Oct-2007 Christoph Hellwig <hch@lst.de> [SCSI] gdth: split out isa probing

(note: this is ontop of Jeff's pci cleanup patch)

Split out isa probing into a helper of it's own. Error handling is
cleaned up, but errors are not propagated yet. Also enclose the isa
probe under the proper CONFIG_ISA symbol instead of the !IA64 hack.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
b8bff2aeafb1959de27bd889d1c103577b36712f 02-Oct-2007 Matthew Wilcox <willy@linux.intel.com> gdth: Make one abuse of scsi_cmnd less obvious

Rather than having internal commands abuse scsi_done to call
gdth_scsi_done, have all the places that use to call scsi_done directly
call gdth_scsi_done, which now checks whether the command was internal,
and calls scsi_done if not.

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
687d2bc4877081a44c41b5b312e012cc69edda53 25-Sep-2007 Matthew Wilcox <matthew@wil.cx> [SCSI] gdth: Stop abusing ->done for internal commands

The ->done member was being used to mark commands as being internal.
I decided to put a magic number in ->underflow instead. I believe this
to be safe as no current user of ->underflow has any of the bottom 9
bits set.

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
bbfbbbc1182f8b44c8cc4c99f4a3f3a512149022 11-Aug-2007 Mariusz Kozlowski <m.kozlowski@tuxland.pl> [SCSI] kmalloc + memset conversion to kzalloc

In NCR_D700, a4000t, aic7xxx_old, bvme6000, dpt_i2o, gdth, lpfc,
megaraid, mvme16x osst, pluto, qla2xxx, zorro7xx

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
8e9a8a0d56c5d9d87adbefbbc8c8728c529fd95a 17-Jul-2007 Jeff Garzik <jeff@garzik.org> [SCSI] gdth: remove redundant PCI stuff

This patch

* removes struct members that duplicate pci_dev members
* replaces ha->stype usage with ha->pdev->device usage where feasible

Signed-off-by: Jeff Garzik <jeff@garzik.org>
Acked-by: Christoph Hellwig <hch@lst.de>
Acked-by: Achim Leubner <Achim_Leubner@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
7a960b76ed1878a208e8bc68fe436b40aaff3ab5 23-May-2007 Robert P. J. Day <rpjday@mindspring.com> [SCSI] gdth: Fix obvious typo "spin_lock_irqrestore()"

Fix misspelled "spin_lock_irqrestore" to read "spin_unlock_irqrestore"
instead.

Presumably, GDTH_RTC doesn't get used a lot.

Signed-off-by: Robert P. J. Day <rpjday@mindspring.com>
Acked-by: Achim Leubner <achim_leubner@adaptec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
6c4b7e4fdf702136891f802bdf7ad52076594721 23-May-2007 David Rientjes <rientjes@google.com> [SCSI] gdth: fix ambiguous gdthtable definition

Labeling a variable as __attribute_used__ is ambiguous: it means
__attribute__((unused)) for gcc <3.4 and __attribute__((used)) for gcc >=3.4.
There is no such thing as labeling a variable as __attribute__((used)). We
assume that we're simply suppressing a warning here if gdthtable[] is declared
but unreferenced.

Acked-by: Achim Leubner <achim_leubner@adaptec.com>
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
bb9ba31ca3b88fd396e38950d1caedf2f83521c6 06-Mar-2007 Joerg Dorchain <joerg@dorchain.net> [SCSI] gdth: fix oops in gdth_copy_cmd()

Recent alterations to the gdth_fill_raw_cmd() path no longer set the
sg_ranz field for zero transfer commands. However, this field is used
lower down in the function to initialise ha->cmd_len to the size of
the firmware packet. If this uninitialised field contains a bogus
value, ha->cmd_len can become much larger than the actual firmware
packet and end up oopsing in gdth_copy_cmd() as it tries to copy this
huge packet to the device (usually because it runs into an unallocated
page).

The fix is to initialise the sg_ranz field to zero at the start of
gdth_fill_raw_cmd().

Signed-off-by: Joerg Dorchain <joerg@dorchain.net>
Acked-by: "Leubner, Achim" <Achim_Leubner@adaptec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
cd354f1ae75e6466a7e31b727faede57a1f89ca5 14-Feb-2007 Tim Schmielau <tim@physik3.uni-rostock.de> [PATCH] remove many unneeded #includes of sched.h

After Al Viro (finally) succeeded in removing the sched.h #include in module.h
recently, it makes sense again to remove other superfluous sched.h includes.
There are quite a lot of files which include it but don't actually need
anything defined in there. Presumably these includes were once needed for
macros that used to live in sched.h, but moved to other header files in the
course of cleaning it up.

To ease the pain, this time I did not fiddle with any header files and only
removed #includes from .c-files, which tend to cause less trouble.

Compile tested against 2.6.20-rc2 and 2.6.20-rc2-mm2 (with offsets) on alpha,
arm, i386, ia64, mips, powerpc, and x86_64 with allnoconfig, defconfig,
allmodconfig, and allyesconfig as well as a few randconfigs on x86_64 and all
configs in arch/arm/configs on arm. I also checked that no new warnings were
introduced by the patch (actually, some warnings are removed that were emitted
by unnecessarily included header files).

Signed-off-by: Tim Schmielau <tim@physik3.uni-rostock.de>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
00977a59b951207d38380c75f03a36829950265c 12-Feb-2007 Arjan van de Ven <arjan@linux.intel.com> [PATCH] mark struct file_operations const 6

Many struct file_operations in the kernel can be "const". Marking them const
moves these to the .rodata section, which avoids false sharing with potential
dirty data. In addition it'll catch accidental writes at compile time to
these shared resources.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
107e716b3487df5e2940ebe3338d935306efc78b 09-Nov-2006 Jean Delvare <khali@linux-fr.org> [SCSI] gdth: Fix && typos

Fix uses of "&&" where "&" was obviously intended instead.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
7d12e780e003f93433d49ce78cfedf4b4c52adc5 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)
6e9a4738c9fadb7cbdcabc1e3b415159f3741ed9 01-Oct-2006 Peter Zijlstra <a.p.zijlstra@chello.nl> [PATCH] completions: lockdep annotate on stack completions

All on stack DECLARE_COMPLETIONs should be replaced by:
DECLARE_COMPLETION_ONSTACK

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Ingo Molnar <mingo@elte.hu>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1d6f359a2e06296418481239f8054a878f36e819 02-Jul-2006 Thomas Gleixner <tglx@linutronix.de> [PATCH] irq-flags: scsi: 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>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
beb40487508290f5d6565598c60a3f44261beef2 10-Jun-2006 Christoph Hellwig <hch@lst.de> [SCSI] remove scsi_request infrastructure

With Achim patch the last user (gdth) is switched away from scsi_request
so we an kill it now. Also disables some code in i2o_scsi that was
broken since the sg driver stopped using scsi_requests.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
6391a11375de5e2bb1eb8481e54619761dc65d9f 09-Jun-2006 Tobias Klauser <tklauser@nuerscht.ch> [SCSI] drivers/scsi: Use ARRAY_SIZE macro

Use ARRAY_SIZE macro instead of sizeof(x)/sizeof(x[0]) and remove
duplicates of the macro.

Signed-off-by: Tobias Klauser <tklauser@nuerscht.ch>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
cbd5f69b98bb5d7a0d207230bcf8fa51fca3f3cf 09-Jun-2006 Leubner, Achim <Achim_Leubner@adaptec.com> [SCSI] remove the scsi_request interface from the gdth driver

Initial pass at converting the gdth driver away from the scsi_request
interface so that the request interface can be removed post 2.6.18
without breaking gdth. Based on changes from Christoph Hellwig
<hch@lst.de>

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
5d5ff44fe6775ccb922fd1f7d478b2ba9ca95068 03-Jun-2006 Christoph Hellwig <hch@lst.de> [SCSI] fix up request buffer reference in various scsi drivers

Various scsi drivers use scsi_cmnd.buffer and scsi_cmnd.bufflen in their
queuecommand functions. Those fields are internal storage for the
midlayer only and are used to restore the original payload after
request_buffer and request_bufflen have been overwritten for EH. Using
the buffer and bufflen fields means they do very broken things in error
handling.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
910638ae7ed4be27d6af55f6c9b5bf54b838e78b 28-Mar-2006 Matthias Gehre <M.Gehre@gmx.de> [PATCH] Replace 0xff.. with correct DMA_xBIT_MASK

Replace all occurences of 0xff.. in calls to function pci_set_dma_mask()
and pci_set_consistant_dma_mask() with the corresponding DMA_xBIT_MASK from
linux/dma-mapping.h.

Signed-off-by: Matthias Gehre <M.Gehre@gmx.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
e041c683412d5bf44dc2b109053e3b837b71742d 27-Mar-2006 Alan Stern <stern@rowland.harvard.edu> [PATCH] Notifier chain update: API changes

The kernel's implementation of notifier chains is unsafe. There is no
protection against entries being added to or removed from a chain while the
chain is in use. The issues were discussed in this thread:

http://marc.theaimsgroup.com/?l=linux-kernel&m=113018709002036&w=2

We noticed that notifier chains in the kernel fall into two basic usage
classes:

"Blocking" chains are always called from a process context
and the callout routines are allowed to sleep;

"Atomic" chains can be called from an atomic context and
the callout routines are not allowed to sleep.

We decided to codify this distinction and make it part of the API. Therefore
this set of patches introduces three new, parallel APIs: one for blocking
notifiers, one for atomic notifiers, and one for "raw" notifiers (which is
really just the old API under a new name). New kinds of data structures are
used for the heads of the chains, and new routines are defined for
registration, unregistration, and calling a chain. The three APIs are
explained in include/linux/notifier.h and their implementation is in
kernel/sys.c.

With atomic and blocking chains, the implementation guarantees that the chain
links will not be corrupted and that chain callers will not get messed up by
entries being added or removed. For raw chains the implementation provides no
guarantees at all; users of this API must provide their own protections. (The
idea was that situations may come up where the assumptions of the atomic and
blocking APIs are not appropriate, so it should be possible for users to
handle these things in their own way.)

There are some limitations, which should not be too hard to live with. For
atomic/blocking chains, registration and unregistration must always be done in
a process context since the chain is protected by a mutex/rwsem. Also, a
callout routine for a non-raw chain must not try to register or unregister
entries on its own chain. (This did happen in a couple of places and the code
had to be changed to avoid it.)

Since atomic chains may be called from within an NMI handler, they cannot use
spinlocks for synchronization. Instead we use RCU. The overhead falls almost
entirely in the unregister routine, which is okay since unregistration is much
less frequent that calling a chain.

Here is the list of chains that we adjusted and their classifications. None
of them use the raw API, so for the moment it is only a placeholder.

ATOMIC CHAINS
-------------
arch/i386/kernel/traps.c: i386die_chain
arch/ia64/kernel/traps.c: ia64die_chain
arch/powerpc/kernel/traps.c: powerpc_die_chain
arch/sparc64/kernel/traps.c: sparc64die_chain
arch/x86_64/kernel/traps.c: die_chain
drivers/char/ipmi/ipmi_si_intf.c: xaction_notifier_list
kernel/panic.c: panic_notifier_list
kernel/profile.c: task_free_notifier
net/bluetooth/hci_core.c: hci_notifier
net/ipv4/netfilter/ip_conntrack_core.c: ip_conntrack_chain
net/ipv4/netfilter/ip_conntrack_core.c: ip_conntrack_expect_chain
net/ipv6/addrconf.c: inet6addr_chain
net/netfilter/nf_conntrack_core.c: nf_conntrack_chain
net/netfilter/nf_conntrack_core.c: nf_conntrack_expect_chain
net/netlink/af_netlink.c: netlink_chain

BLOCKING CHAINS
---------------
arch/powerpc/platforms/pseries/reconfig.c: pSeries_reconfig_chain
arch/s390/kernel/process.c: idle_chain
arch/x86_64/kernel/process.c idle_notifier
drivers/base/memory.c: memory_chain
drivers/cpufreq/cpufreq.c cpufreq_policy_notifier_list
drivers/cpufreq/cpufreq.c cpufreq_transition_notifier_list
drivers/macintosh/adb.c: adb_client_list
drivers/macintosh/via-pmu.c sleep_notifier_list
drivers/macintosh/via-pmu68k.c sleep_notifier_list
drivers/macintosh/windfarm_core.c wf_client_list
drivers/usb/core/notify.c usb_notifier_list
drivers/video/fbmem.c fb_notifier_list
kernel/cpu.c cpu_chain
kernel/module.c module_notify_list
kernel/profile.c munmap_notifier
kernel/profile.c task_exit_notifier
kernel/sys.c reboot_notifier_list
net/core/dev.c netdev_chain
net/decnet/dn_dev.c: dnaddr_chain
net/ipv4/devinet.c: inetaddr_chain

It's possible that some of these classifications are wrong. If they are,
please let us know or submit a patch to fix them. Note that any chain that
gets called very frequently should be atomic, because the rwsem read-locking
used for blocking chains is very likely to incur cache misses on SMP systems.
(However, if the chain's callout routines may sleep then the chain cannot be
atomic.)

The patch set was written by Alan Stern and Chandra Seetharaman, incorporating
material written by Keith Owens and suggestions from Paul McKenney and Andrew
Morton.

[jes@sgi.com: restructure the notifier chain initialization macros]
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
40cdc840dc337cb17d81bcf028b40834e78c1038 05-Feb-2006 Jenx Axboe <axboe@suse.de> [SCSI] gdth: don't map zero-length requests

Don't map zero-length requests in gdth, zome architectures don't like
that in their dma mapping routines.

[ I'm pretty sure Jens posted this before, but for some reason it got
forgotten --hch ]

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
575c96871832e91983248aebb02fc072e5fd17c9 15-Jan-2006 Adrian Bunk <bunk@stusta.de> spelling: s/appropiate/appropriate/

Signed-off-by: Adrian Bunk <bunk@stusta.de>
f64a181d898e0518d5ae90c4870069510de977e1 31-Oct-2005 Christoph Hellwig <hch@lst.de> [SCSI] remove Scsi_Device typedef

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
d0be4a7d29ad0bd3ce2209dd9e46d410b632db59 31-Oct-2005 Christoph Hellwig <hch@lst.de> [SCSI] remove Scsi_Host_Template typedef

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
12413197eef2a29e0b9fb0fa541f5cbaeb1d3f3f 11-Jun-2005 Christoph Hellwig <hch@lst.de> [SCSI] remove scsi_set_device

scsi_add_host is the proper place to set the device, but people copy
the scsi_set_device usage from older drivers again and again.

note that this leaves some legacy drivers like qlogicisp/qlogicfc
without pci association in sysfs, but they're scheduled to go away soon
anyway.

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
3471c288036bf0835a82d0b1bbce2002f6e68390 28-May-2005 Jeff Garzik <jgarzik@pobox.com> [SCSI] Remove no-op implementations of SCSI EH hooks

Drivers need not implement a hook that returns FAILED, and does nothing
else, since the SCSI midlayer code will do that for us.

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
8e8790415e91964096f862a58cacb55d2bc9a817 17-Apr-2005 <bunk@stusta.de> [PATCH] drivers/scsi/gdth.c: cleanups

This patch contains the following cleanups:
- make some needlessly global functions static
- remove one more kernel 2.2 #ifdef

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 17-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!