Commit Graph

33 Commits

Author SHA1 Message Date
Stefan Richter
24c7cd0630 [PATCH] sbp2: fix spinlock recursion
sbp2util_mark_command_completed takes a lock which was already taken by
sbp2scsi_complete_all_commands.  This is a regression in Linux 2.6.15.

 Reported by Kristian Harms at
	https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=187394

[ More complete commentary, as response to questions by Andrew: ]

> This changes the call environment for all implementations of
> ->Current_done().  Are they all safe to call under this lock?

Short answer: Yes, trust me.  ;-) Long answer:

The done() callbacks are passed on to sbp2 from the SCSI stack along
with each SCSI command via the queuecommand hook.  The done() callback
is safe to call in atomic context.  So does
Documentation/scsi/scsi_mid_low_api.txt say, and many if not all SCSI
low-level handlers rely on this fact.  So whatever this callback does,
it is "self-contained" and it won't conflict with sbp2's internal ORB
list handling.  In particular, it won't race with the
sbp2_command_orb_lock.

Moreover, sbp2 already calls the done() handler with
sbp2_command_orb_lock taken in sbp2scsi_complete_all_commands().  I
admit this is ultimately no proof of correctness, especially since this
portion of code introduced the spinlock recursion in the first place and
we didn't realize it since this code's submission before 2.6.15 until
now.  (I have learned a lesson from this.)

I stress-tested my patch on x86 uniprocessor with a preemptible SMP
kernel (alas I have no SMP machine yet) and made sure that all code
paths which involve the sbp2_command_orb_lock were gone through multiple
times.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-04-02 12:58:09 -07:00
Stefan Richter
d024ebc67e sbp2: misc debug logging cleanups
- move call of scsi_print_command from sbp2_send_command to the beginning of
   sbp2_queue_command to show also commands which are not sent
 - put sbp2's name into scsi_print_sense
 - use __FUNCTION__ in log messages
 - remove a few less useful log messages and comments

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
2006-03-28 20:03:55 -05:00
Stefan Richter
8f0525ff19 sbp2: proper treatment of DID_OK
Sbp2 relied on DID_OK to be defined as 0. Always shift DID_OK into the right
position anyway, and explicitly return DID_OK together with CHECK_CONDITION.
Also comment on some #if 0 code. The patch does not change current behaviour.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
2006-03-28 20:03:45 -05:00
Stefan Richter
556640510d sbp2: check for ARM failure
Sbp2 did not check for successful registration of the lower address range
when CONFIG_IEEE1394_SBP2_PHYS_DMA was set. If hpsb_register_addrspace
failed, a "login timed-out" would occur which is misleading. Now sbp2 logs
a sensible error message.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
2006-03-28 19:59:42 -05:00
Stefan Richter
147830f297 sbp2: prevent unloading of 1394 low-level driver
When a new SBP-2 unit is added, sbp2 now takes a reference on the 1394
low-level driver (ohci1394 or pcilynx).  This prevents the 1394 host driver
module from being unloaded, e.g. by an administrative routine cleanup of
unused kernel modules or when another 1394 driver which depends on ohci1394
is unloaded.

The reference is dropped when the SBP-2 unit was disconnected, when sbp2 is
unloaded or detached from the unit, or when addition of the SBP-2 unit failed.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
2006-03-28 19:54:52 -05:00
Stefan Richter
a80614d1ad sbp2: update 36byte inquiry workaround (fix compatibility regression)
Since about Linux 2.6.14, sbp2's inquiry workaround did not work anymore
due to changes in the SCSI layer. Update it to become effective again.
Testing one of the two known affected bridges has shown that skip_ms_page_8
is required as well.

Also, make force_inquiry_hack tunable via /sys/module/sbp2/parameters.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
(cherry picked from 99496037c6744fd938ffb8ccfc8fc91762322ff8 commit)
2006-02-23 00:29:31 -05:00
Stefan Richter
35bdddb83f sbp2: variable status FIFO address (fix login timeout)
Let the ieee1394 core select a suitable 1394 address range for sbp2's
status FIFO instead of using a fixed range. Since the core only selects
addresses which are guaranteed to be out of the "physical range" as per
OHCI 1.1, this patch also fixes an old bug:

OHCI controllers which implement a writeable PhysicalUpperBound register
included sbp2's status FIFO in the physical range. That way sbp2 was
never notified of a succesful login and always failed after timeout.
Affected OHCI host adapters include ALi and Fujitsu controllers.

As another side effect of this patch, the status FIFO is no longer
located in a range for which OHCI chips perform "posted writes". Each
status write now requires a response subaction. But since large data
transfers involve only few status writes, there is no measurable
decrease of I/O throughput. What's more, the status FIFO is now safe
from potential host bus errors. Nevertheless, posted writes could be
re-enabled by extensions to the ARM features of the 1394 stack.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
(cherry picked from b2d38cccad4ef80d6b672b8f89aae5fe2907b113 commit)
2006-02-23 00:28:52 -05:00
Stefan Richter
bf637ec3ef sbp2: fix another deadlock after disconnection
If there were commands enqueued but not completed before an SBP-2 unit
was unplugged (or an attempt to reconnect failed), knodemgrd or any
process which tried to remove the device would sleep uninterruptibly
in blk_execute_rq().  Therefore make sure that all commands are
completed when sbp2 retreats.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
(cherry picked from 61daa34c132c5d4ed8630e2c46e9bf2f0c7b3428 commit)
2006-02-23 00:25:08 -05:00
Al Viro
e30809fde5 [PATCH] don't mangle INQUIRY if cmddt or evpd bits are set
sbp2.c mangles INQUIRY response in a way that only applies to standard
inquiry data (i.e. when both cmddt and evpd bits are 0).  Leave other cases
alone; e.g. when asking for VPD the length of reply is in byte 3, not 4
and byte 4 is the first byte of device serial number.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2006-02-18 15:54:13 -05:00
Stefan Richter
eaceec7f6c sbp2: remove duplicate code from sbp2_start_device()
Use sbp2_remove_device() to free FIFO and ORB DMAs in a failure case.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
2005-12-13 11:05:05 -05:00
Stefan Richter
cf8d2c0965 sbp2: split sbp2_create_command_orb() for better readability
sbp2_create_command_orb() code cleanup:
 - add two helper functions to reduce nesting depth
 - omit the return value which was always ignored
 - remove unnecessary declaration from sb2.h

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
2005-12-13 11:05:03 -05:00
Stefan Richter
dc3edd5412 sbp2: did not clean up after scsi_add_device() failed
If scsi_add_device() at the end of sbp2_start_device() fails, e.g. due to
transport errors during SCSI inquiry, sbp2 needs to log out of the device
and release all associated resources.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
2005-12-12 23:03:30 -05:00
Stefan Richter
43863eba76 sbp2: delete sbp2scsi_direction_table
DMA_BIDIRECTIONAL data direction may be handled properly by Linux in the
future.  For now, reject it instead to convert it to another direction.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
2005-12-12 23:03:24 -05:00
Stefan Richter
977545e352 sbp2: slimmer interface to scsi_mod
- sbp2scsi_reset does not need to take host_lock
- sbp2scsi_reset, as our device reset handler, does not need to stand in as
  bus reset or host reset handler
- let scsi_mod use scsi_host_template.name instead of .info
  (sbp2 is not an emulation anway)

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
2005-11-19 21:35:22 -05:00
Stefan Richter
8551158abc kmalloc/kzalloc changes:
dv1394, eth1394, ieee1394, ohci1394, pcilynx, raw1394, sbp2c, video1394:
 - use kzalloc
 - provide safer size arguments to kmalloc and kzalloc
 - omit some casts

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
2005-11-07 06:31:45 -05:00
Stefan Richter
7afa146776 Remove version strings from eth1394, ohci1394, sbp2.
Their version information is not trustworthy.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
2005-11-07 06:31:42 -05:00
Stefan Richter
a237f35fdd sbp2, ohci1394 cleanups:
sbp2: various code formatting cleanups
ohci1394: remove form feed characters

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
2005-11-07 06:31:39 -05:00
Ben Collins
e309fc6d71 sbp2: Remove our tracking of device type,
since we no longer need to worry about it.
Depends on patch "ieee1394: remove sbp2's TYPE_RBC and 10byte handling".

Signed-off-by: Ben Collins <bcollins@debian.org>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
2005-11-07 06:31:34 -05:00
Ben Collins
365c786f0b sbp2: Merge TYPE_RBC and 10byte removal patch from scsi maintainers.
Added more cleanups to remove unused code.

Signed-off-by: Ben Collins <bcollins@debian.org>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
2005-11-07 06:31:24 -05:00
Jody McIntyre
7945619794 sbp2_command_orb_lock must be held when accessing the _orb_inuse list.
Fixes an oops in sbp2util_find_command_for_SCpnt after sbp2scsi_abort:
https://bugzilla.novell.com/show_bug.cgi?id=113734

Signed-off-by: Jody McIntyre <scjody@steamballoon.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2005-11-07 06:29:39 -05:00
Jody McIntyre
2bab359a50 [PATCH] sbp2: default to serialize_io=1
Set serialize_io=1 by default.  This is safer and required by seemingly more
and more hardware.  It causes little or no performance loss for S400 devices.
Performance of S800 1394b devices may drop by 25...30%.  Therefore make the
parameter's description and dmesg message clearer about performance impact.

Update description of the max_speed parameter too.  IEEE1394_SPEED_MAX is
currently S800.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@steamballoon.com>
Cc: Ben Collins <bcollins@debian.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-30 12:41:19 -07:00
Jody McIntyre
abd559b105 [PATCH] sbp2: fix deadlocks and delays on device removal/rmmod
Fixes for deadlocks of the ieee1394 and scsi subsystems and long delays in
futile error recovery attempts when SBP-2 devices are removed or drivers are
unloaded.

 - Complete commands quickly with DID_NO_CONNECT if the 1394 node is gone or if
   the 1394 low-level driver was unloaded.
 - Skip unnecessary work in the eh_abort_handler and eh_device_reset_handler if
   the node or 1394 low-level driver is gone.
 - Let scsi's high-level shut down gracefully when sbp2 is being unloaded or
   detached from the 1394 unit. A call to scsi_remove_device is added for this
   purpose, which requires us to store a scsi_device pointer.
 - scsi_device pointer is obtained from slave_alloc hook and cleared by
   slave_destroy. This avoids usage of the pointer after the scsi device was
   deleted e.g. by the user via scsi_mod's sysfs interface.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Jody McIntyre <scjody@steamballoon.com>
Cc: Ben Collins <bcollins@debian.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-30 12:41:18 -07:00
James Bottomley
146f7262ee [SCSI] Alter the scsi_add_device() API to conform to what users expect
The original API returned either an ERR_PTR() or a refcounted sdev.
Unfortunately, if it's successful, you need to do a scsi_device_put() on
the sdev otherwise the refcounting is wrong.

Everyone seems to expect that scsi_add_device() should be callable
without doing the ref put, so alter the API so it is (we still have
__scsi_add_device with the original behaviour).

The only actual caller that needs altering is the one in firewire ...
not because it gets this right, but because it acts on the error if one
is returned.

Acked-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-09-10 14:43:25 -05:00
Olaf Hering
44456d37b5 [PATCH] turn many #if $undefined_string into #ifdef $undefined_string
turn many #if $undefined_string into #ifdef $undefined_string to fix some
warnings after -Wno-def was added to global CFLAGS

Signed-off-by: Olaf Hering <olh@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-07-27 16:26:08 -07:00
Ben Collins
1934b8b656 [PATCH] Sync up ieee-1394
Lots of this patch is trivial code cleanups (static vars were being
intialized to 0, etc).

There's also some fixes for ISO transmits (max buffer handling).
Aswell, we have a few fixes to disable IRM capabilites correctly.  We've
also disabled, by default some generally unused EXPORT symbols for the
sake of cleanliness in the kernel.  However, instead of removing them
completely, we felt it necessary to have a config option that allowed
them to be enabled for the many projects outside of the main kernel tree
that use our API for driver development.

The primary reason for this patch is to revert a MODE6->MODE10 RBC
conversion patch from the SCSI maintainers.  The new conversions handled
directly in the scsi layer do not seem to work for SBP2.  This patch
reverts to our old working code so that users can enjoy using Firewire
disks and dvd drives again.

We are working with the SCSI maintainers to resolve this issue outside
of the main kernel tree.  We'll merge the patch once the SCSI layer's
handling of the MODE10 conversion is working for us.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-07-10 12:23:23 -07:00
Yani Ioannou
e404e274f6 [PATCH] Driver Core: drivers/i2c/chips/w83781d.c - drivers/s390/block/dcssblk.c: update device attribute callbacks
Signed-off-by: Yani Ioannou <yani.ioannou@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-06-20 15:15:34 -07:00
James Bottomley
3237ee78fc merge by hand (fix up qla_os.c merge error) 2005-06-17 18:42:23 -05:00
Jeff Garzik
94d0e7b805 [SCSI] allow sleeping in ->eh_device_reset_handler()
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-06-17 12:05:03 -05:00
Jeff Garzik
e3df715501 [SCSI] Remove unnecessary locking around completion function calls
The SCSI ->done() hook should not be called from inside a spinlock.

Drivers that do this are mostly cut-n-paste from 2.2.x-era.

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-06-17 12:04:37 -05:00
Alexandre Oliva
a2ef79e184 [PATCH] sbp2 slab corruption fix
This fixed a problem that showed up in the Fedora development tree a few
weeks before the Fedora Core 4 release, initially as slab corruption, later
as hard crashes on boot up, when slab debugging was disabled for the
release.  More details on the history at
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=158424

The problem is caused by sbp2's use of scsi_host->hostdata[0] to hold a
scsi_id, without explicitly requesting space for it.  Since hostdata is
declared as a zero-sized array, we don't get any such space by default, so
it must be explicitly requested.  The patch below implements just that.

Signed-off-by: Alexandre Oliva <aoliva@redhat.com>
Cc: Jody McIntyre <scjody@modernduck.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-16 09:02:59 -07:00
Andrew Morton
644e02ea14 [SCSI] git-scsi-misc-sbp2-warning-fix
drivers/ieee1394/sbp2.c: In function `sbp2_check_sbp2_response':
drivers/ieee1394/sbp2.c:2154: warning: unused variable `device_type'

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-05-26 11:30:57 -04:00
Al Viro
631e8a1398 [SCSI] TYPE_RBC cache fixes (sbp2.c affected)
a) TYPE_SDAD renamed to TYPE_RBC and taken to scsi.h
	b) in sbp2.c remapping of TYPE_RPB to TYPE_DISK turned off
	c) relevant places in midlayer and sd.c taught to accept TYPE_RBC
	d) sd.c::sd_read_cache_type() looks into page 6 when dealing with
TYPE_RBC - these guys have writeback cache flag there and are not guaranteed
to have page 8 at all.
	e) sd_read_cache_type() got an extra sanity check - it checks that
it got the page it asked for before using its contents.  And screams if
mismatch had happened.  Rationale: there are broken devices out there that
are "helpful" enough to go for "I don't have a page you've asked for, here,
have another one".  For example, PL3507 had been caught doing just that...
	f) sbp2 sets sdev->use_10_for_rw and sdev->use_10_for_ms instead
of bothering to remap READ6/WRITE6/MOD_SENSE, so most of the conversions
in there are gone now.

	Incidentally, I wonder if USB storage devices that have no
mode page 8 are simply RBC ones.  I haven't touched that, but it might
be interesting to check...

Signed-off-by: Al Viro <viro@parcelfarce.linux.theplanet.co.uk>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2005-05-26 08:41:15 -05:00
Linus Torvalds
1da177e4c3 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!
2005-04-16 15:20:36 -07:00