Commit Graph

31 Commits

Author SHA1 Message Date
Stefan Richter
f412bf440b ieee1394: sbp2: remove unnecessary alignments of struct members
The members "dma_addr_t command_orb_dma" and "dma_addr_t sge_dma" of
sbp2.h::sbp2_command_info do not have to be aligned themselves --- only
the memory which they point to has to be.

The member "struct sbp2_command_orb command_orb" has to be aligned on
4 bytes boundary which is guaranteed because it contains u32 members.

The member "struct sbp2_unrestricted_page_table scatter_gather_element",
i.e. the SBP-2 s/g table, has to be aligned on 8 bytes boundary
according to the SBP-2 spec.  This is not a requirement for FireWire
controllers but could be expected by SBP-2 targets.

I see no need to align the members command_orb and
scatter_gather_element on CPU cacheline boundaries.  It could have
performance benefits, but on the other hand sbp2 has a somewhat wasteful
allocation scheme which should be optimized first before further tweaks
like cacheline alignments.  (E.g. don't always allocate SG_ALL s/g table
elements.)

Note, before as well as after the patch, the code relies on the
assumption that memory alignment in the virtual address space is
preserved in the physical address space after DMA mapping.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2007-04-30 00:00:27 +02:00
Stefan Richter
9b7d9c096d ieee1394: sbp2: convert from PCI DMA to generic DMA
API conversion without change in functionality

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 23:11:43 +01:00
Luca Tettamanti
ff6a4cd2e1 sbp2: make 1bit bitfield unsigned
A signed single-bit bitfield doesn't make much sense. Make it unsigned.

Signed-off-by: Luca Tettamanti <kronos.it@gmail.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 23:05:47 +01:00
Stefan Richter
138c8af864 ieee1394: sbp2: more concise names for types and variables
"struct scsi_id_instance_data" represents a logical unit.
Rename it to "struct sbp2_lu", and "scsi_id" to "lu".
Rename some other variables too.
Wrap almost all lines after at most 80 columns.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 22:59:34 +01:00
Stefan Richter
9117c6dc43 ieee1394: sbp2: remove unused struct members
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 22:52:41 +01:00
Stefan Richter
ca0c745399 ieee1394: sbp2: clean up sbp2_ namespace
Prepend sbp2*_ to anything globally defined in sbp2.c except for some
macros.  Strip sbp2_ from names of struct members.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 22:51:53 +01:00
Stefan Richter
e8ca5668f1 ieee1394: sbp2: remove superfluous comments
And update and reformat remaining comments.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 22:45:41 +01:00
Stefan Richter
d19c776414 ieee1394: sbp2: delayed_work -> work_struct
This work is not delayed.

Also bring the code format in a state which reduces my work to merge
pending sbp2 patchs.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 22:40:33 +01:00
Stefan Richter
424a9642b8 ieee1394: sbp2: coding style of some macros
Adjust parentheses, indentation, line lengths.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 21:46:58 +01:00
Stefan Richter
ea42ea0f58 ieee1394: sbp2: clean up function declarations
Remove unnecessary function prototypes.
Remove variable names from function prototypes.
Move declarations from sbp2.h to sbp2.c.
Move definitions of driver templates together near the top of sbp2.c.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 21:46:10 +01:00
David Howells
c4028958b6 WorkStruct: make allyesconfig
Fix up for make allyesconfig.

Signed-Off-By: David Howells <dhowells@redhat.com>
2006-11-22 14:57:56 +00:00
Stefan Richter
2cccbb555c ieee1394: sbp2: prevent rare deadlock in shutdown
Scsi_remove_device() may go into uninterruptible sleep if blocked.
Therefore sbp2_remove() unblocks the Scsi_Host before the device is
requested to be removed.  But there could be another 1394 bus reset
after that which would block the host again.  The 1394 subsystem won't
call sbp2_update() concurrently to sbp2_remove(), which is why there is
no chance for sbp2_remove() to be unblocked by sbp2_update().

The fix is to tell sbp2's bus reset handler when a device is to be shut
down so that it skips scsi_block_requests() on that host.  As before,
any new commands after a reset without reconnect will be failed quickly
by sbp2scsi_queuecommand().

In the long term, means to go without scsi_block_requests() should be
found.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-09-17 19:34:44 +02:00
Stefan Richter
abbca103a0 ieee1394: sbp2: better handling of transport errors
If the target signals a transport failure via status block, complete the
request with DID_BUSY to indicate to the SCSI subsystem that the command
may succeed when retried.

Also log diagnostic information if the status block shows a transport
related problem.  It may point to hardware faults.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-09-17 19:34:37 +02:00
Stefan Richter
09ee67abe9 ieee1394: sbp2: handle "sbp2util_node_write_no_wait failed"
Fix for http://bugzilla.kernel.org/show_bug.cgi?id=6948

Because sbp2 writes to the target's fetch agent's registers from within
atomic context, it cannot sleep to guaranteedly get a free transaction
label.  This may repeatedly lead to "sbp2util_node_write_no_wait failed"
and consequently to SCSI command abortion after timeout.  A likely cause
is that many queue_command softirqs may occur before khpsbpkt (the
ieee1394 driver's thread which cleans up after finished transactions) is
woken up to recycle tlabels.

Sbp2 now schedules a workqueue job whenever sbp2_link_orb_command fails
in sbp2util_node_write_no_wait.  The job will reliably get a transaction
label because it can sleep.

We use the kernel-wide shared workqueue because it is unlikely that the
job itself actually needs to sleep.  In the improbable case that it has
to sleep, it doesn't need to sleep long since the standard transaction
timeout is 100ms.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-09-17 19:34:14 +02:00
Stefan Richter
e8398bb737 ieee1394: sbp2: convert sbp2util_down_timeout to waitqueue
The waitqueue API is used to replace a custom wait mechanism.  Only one
global waitqueue (instead of per-device waitqueues or completions) is
added because there is usually just one waiter.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-09-17 19:29:31 +02:00
Stefan Richter
6065772d54 ieee1394: sbp2: more checks of status block
- Add checks for the (very unlikely) cases that the target writes too
   little or too much status data or writes unsolicited status.
 - Indicate that these and similar conditions are unlikely().
 - Check the 'resp' and 'sbp_status' fields for possible failure status.
 - Slightly optimize access macros for the status block bitfields.
 - Unify a few related log messages.

TODO:  Check if 'src'==1, then withhold the respective ORB from reuse
until status for any subsequent ORB was received.  This is an old bug
whose fix requires more complex command queue handling.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-09-17 19:29:24 +02:00
Stefan Richter
28212767e5 ieee1394: sbp2: discard return value of sbp2_link_orb_command
Since sbp2 is at the moment unable to do anything with the return value
of sbp2_link_orb_command, just discard it.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-09-17 19:29:01 +02:00
Stefan Richter
cc07818912 ieee1394: sbp2: safer last_orb and next_ORB handling
The sbp2 initiator has two ways to tell a target's fetch agent about new
command ORBs:
 - Write the ORB's address to the ORB_POINTER register.  This must not
   be done while the fetch agent is active.
 - Put the ORB's address into the previously submitted ORB's next_ORB
   field and write to the DOORBELL register.  This may be done while the
   fetch agent is active or suspended.  It must not be done while the
   fetch agent is in reset state.
Sbp2 has a last_orb pointer which indicates in what way a new command
should be announced.  That pointer is concurrently accessed at various
occasions.  Furthermore, initiator and target are accessing the next_ORB
field of ORBs concurrently and asynchronously.

This patch does:
 - Protect all initiator accesses to last_orb by sbp2_command_orb_lock.
 - Add pci_dma_sync_single_for_device before a previously submitted
   ORB's next_ORB field is overwritten.
 - Insert a memory barrier between when next_ORB_lo and next_ORB_hi are
   overwritten.  Next_ORB_hi must not be updated before next_ORB_lo.
 - Remove the rather unspecific and now superfluous qualifier "volatile"
   from the next_ORB fields.
 - Add comments on how last_orb is connected with what is known about
   the target's fetch agent's state.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-09-17 19:19:25 +02:00
Ben Collins
05db5055b1 sbp2: use __attribute__((packed)) for on-the-wire structures
It seems to have worked without the attribute during all the years
just because sizes of all struct members are multiples of 32 bits.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
2006-06-12 18:14:47 -04:00
Ben Collins
fe42b05a99 sbp2: remove manipulation of inquiry response
This code became ineffective a few Linux releases ago and is not
required anyway.

Note from Christoph Hellwig: scsi_cmnd.request_buffer is always a
scatterlist these days.  Checking random bites into it and then
mangling the data in sbp2_check_sbp2_response will cause really bad
memory corruption when you're not lucky enough to have the check not
trigger by luck.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
2006-06-12 18:12:59 -04:00
Stefan Richter
679c0cd2dd [PATCH] sbp2: add ability to override hardwired blacklist
In case the blacklist with workarounds for device bugs yields a false
positive, the module load parameter can now also be used as an override
instead of an addition to the blacklist.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-05-17 21:32:22 -07:00
Stefan Richter
e9a1c52c7b [PATCH] sbp2: add read_capacity workaround for iPod
Apple decided to copy some USB stupidity over to FireWire.

The sector number returned by iPods from read_capacity is one too many.
This may cause I/O errors, especially if the kernel is configured for EFI
partition support. We use the same workaround as usb-storage but have to
check for different model IDs.

	http://marc.theaimsgroup.com/?t=114233262300001
	https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=187409

Acknowledgements:
  Diagnosis and therapy by Mathieu Chouquet-Stringer <ml2news@free.fr>,
  additional data about affected and unaffected Apple hardware from
  Vladimir Kotal, Sander De Graaf, Bryan Olmstead and Hugh Dixon.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-05-17 21:32:21 -07:00
Stefan Richter
24d3bf884e [PATCH] sbp2: consolidate workarounds
Grand unification of the three types of workarounds we have so far.

The "skip mode page 8" workaround is now limited to devices which
pretend to be of TYPE_DISK instead of TYPE_RBC. This workaround is no
longer enabled for Initio bridges.

Patch update in anticipation of more workarounds:
 - Add module parameter "workarounds".
 - Deprecate parameter "force_inquiry_hack".
 - Compose the blacklist of a compound type for better readability and
   extensibility.
 - Remove a now unused #define.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-05-17 21:32:21 -07: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
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
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
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
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