Commit Graph

104 Commits

Author SHA1 Message Date
Stefan Richter a2ee3f9bbb ieee1394: sbp2: fix sbp2_remove_device for error cases
Bug found by Olaf Hering <olh@suse.de>:
sbp2util_remove_command_orb_pool requires a valid lu->hi pointer.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2007-08-25 18:00:26 +02:00
Stefan Richter a9c2f18800 ieee1394: revert "sbp2: enforce 32bit DMA mapping"
Revert commit 0555659d63 from 2.6.22-rc1.
The dma_set_mask call somehow failed on a PowerMac G5, PPC64:
http://lkml.org/lkml/2007/8/1/344

Should there ever occur a DMA mapping beyond the physical DMA range, a
proper SBP-2 firmware will report transport errors.  So let's leave it
at that.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Tested-by: Olaf Hering <olh@suse.de>
2007-08-02 20:34:16 +02:00
Linus Torvalds bc06cffdec Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (166 commits)
  [SCSI] ibmvscsi: convert to use the data buffer accessors
  [SCSI] dc395x: convert to use the data buffer accessors
  [SCSI] ncr53c8xx: convert to use the data buffer accessors
  [SCSI] sym53c8xx: convert to use the data buffer accessors
  [SCSI] ppa: coding police and printk levels
  [SCSI] aic7xxx_old: remove redundant GFP_ATOMIC from kmalloc
  [SCSI] i2o: remove redundant GFP_ATOMIC from kmalloc from device.c
  [SCSI] remove the dead CYBERSTORMIII_SCSI option
  [SCSI] don't build scsi_dma_{map,unmap} for !HAS_DMA
  [SCSI] Clean up scsi_add_lun a bit
  [SCSI] 53c700: Remove printk, which triggers because of low scsi clock on SNI RMs
  [SCSI] sni_53c710: Cleanup
  [SCSI] qla4xxx: Fix underrun/overrun conditions
  [SCSI] megaraid_mbox: use mutex instead of semaphore
  [SCSI] aacraid: add 51245, 51645 and 52245 adapters to documentation.
  [SCSI] qla2xxx: update version to 8.02.00-k1.
  [SCSI] qla2xxx: add support for NPIV
  [SCSI] stex: use resid for xfer len information
  [SCSI] Add Brownie 1200U3P to blacklist
  [SCSI] scsi.c: convert to use the data buffer accessors
  ...
2007-07-15 16:51:54 -07:00
Stefan Richter 77bba7aea7 ieee1394: sbp2: change some module parameters from int to bool
This is upwards compatible, except that integer values other than 0 or 1
are no longer accepted.  But values like "Y", "N", "no", "nnoooh!" work
now.

Also, improve a comment on the serialize_io parameter and make the
ORB_SET_EXCLUSIVE macro ultra-safe.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2007-07-10 00:07:41 +02:00
Stefan Richter d7794c8668 ieee1394: sbp2: offer SAM-conforming target port ID in sysfs
With "modprobe sbp2 long_ieee1394_id=y", the format of
/sys/bus/scsi/devices/*:*:*:*/ieee1394_id is changed from e.g.
0001041010004beb:0:0 to 0001041010004beb:00042c:0000.

The longer format fully conforms to object identifier sizes as per
SAM(-2...4) and reflects what the SAM target port identifier is meant to
contain:  A Discovery ID allegedly specified by ISO/IEC 13213:1994 ---
however there is no such thing; the authors of SAM probably meant
Directory ID).  Especially target nodes with multiple dynamically added
targets may use Directory IDs to persistently identify target ports.

The new format is independent of implementation details of nodemgr.
Thus the same ieee1394_id attribute format can be implemented in the new
firewire stack.

The ieee1394_id is typically used to create persistently named links in
/dev/disk/by-id.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2007-05-31 21:40:13 +02:00
James Bottomley 5bc65793cb [SCSI] Merge up to linux-2.6 head
Conflicts:

	drivers/scsi/jazz_esp.c

Same changes made by both SCSI and SPARC trees: problem with UTF-8
conversion in the copyright.

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2007-05-30 23:57:05 -05:00
Stefan Richter 20e2008e1f ieee1394: sbp2: include workqueue.h
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2007-05-27 23:20:58 +02:00
FUJITA Tomonori d7dea2cf80 [SCSI] sbp2: convert to use the data buffer accessors
- remove the unnecessary map_single path.

- convert to use the new accessors for the sg lists and the
parameters.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2007-05-27 13:10:08 -05:00
Andrew Morton f84c922ba1 ieee1394: sbp2: include fixes
drivers/ieee1394/sbp2.c: In function 'sbp2util_access_timeout':
drivers/ieee1394/sbp2.c:399: error: 'TASK_INTERRUPTIBLE' undeclared (first use in this function)
drivers/ieee1394/sbp2.c:399: error: (Each undeclared identifier is reported only once
drivers/ieee1394/sbp2.c:399: error: for each function it appears in.)
drivers/ieee1394/sbp2.c:399: warning: implicit declaration of function 'signal_pending'
drivers/ieee1394/sbp2.c:399: warning: implicit declaration of function 'schedule_timeout'
drivers/ieee1394/sbp2.c: In function 'sbp2_prep_command_orb_sg':
drivers/ieee1394/sbp2.c:1438: warning: implicit declaration of function 'page_address'
drivers/ieee1394/sbp2.c:1438: warning: passing argument 2 of 'dma_map_single' makes pointer from integer without a cast
drivers/ieee1394/sbp2.c: In function 'sbp2_handle_status_write':
drivers/ieee1394/sbp2.c:1842: error: 'TASK_INTERRUPTIBLE' undeclared (first use in this function)

Possibly due to changes in -mm, but this file should explicitly include the
headers for the stuff it uses.

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> (brought into alphabetic order)
2007-04-30 00:00:27 +02:00
Stefan Richter 3d269cb50c ieee1394: sbp2: move some memory allocations into non-atomic context
When the command ORB pool is created, the ORB list won't be accessed
concurrently.  Therefore we don't have to take the spinlock there.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2007-04-30 00:00:27 +02:00
Stefan Richter 2446a79f4f ieee1394: sbp2: optimize DMA direction of s/g tables
Unlike the name suggests, "cmd->scatter_gather_element" holds only the
s/g table, not the actual s/g elements.  Since the table is only read
but never written by the device, DMA_BIDIRECTIONAL can be replaced by
DMA_TO_DEVICE which may be cheaper on some architectures.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2007-04-30 00:00:27 +02:00
Stefan Richter 0555659d63 ieee1394: sbp2: enforce 32bit DMA mapping
In order to use OHCI-1394 physical DMA, all s/g elements, s/g tables,
ORBs, and response buffers have to reside within the first 4 GB of the
FireWire controller's physical address space.  Set the correct mask for
DMA mappings.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2007-04-30 00:00:27 +02:00
Stefan Richter beb2fdcad1 ieee1394: sbp2: lower block queue alignment requirement
The old setting is copy & waste from usb-storage and doesn't apply to
sbp2.  There is only 4-byte alignment required for everything, except
for S/G table elements which have to be 8-byte aligned according to the
SBP-2 spec.  (They happen to be ____cacheline_aligned in our
implementation.  Whether that's good is another question.)

We now simply don't tune block queue alignment at all.  The default
alignment would surely never become anything else than a multiple of 4,
else tons of calls to blk_queue_dma_alignment would have to be added
everywhere in drivers/...

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2007-02-08 20:59:54 +01:00
Stefan Richter 9c31b38723 ieee1394: sbp2: remove bogus "emulated" host flag
There is no emulation going on here.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2007-02-08 20:59:48 +01:00
Stefan Richter 4618fd3001 ieee1394: sbp2: use a better wildcard for blacklist
0x000000 could be a valid value to match against, but anything bigger
than 0xffffff cannot.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2007-02-08 20:57:08 +01:00
Stefan Richter 1a74bc68e4 ieee1394: sbp2: fix probing of some DVD-ROM/RWs
Since commit 98e238cd42 in Linux 2.6.19,
"ieee1394: sbp2: don't prefer MODE SENSE 10", some FireWire DVD-ROMs and
DVD-RWs were mistaken as CD-ROM because sr_mod now sent MODE SENSE 6.
The MMC command set includes only MODE SENSE 10.
http://bugzilla.kernel.org/show_bug.cgi?id=7800

This fix lets sbp2 switch scsi_device.use_10_for_rw on for MMC LUs.
This should rather be done in the command set driver sr_mod, not in the
sbp2 transport driver, and an according patch will follow for a next
Linux release.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2007-01-10 20:24:42 +01:00
Stefan Richter 97d552e35d ieee1394: sbp2: fix bogus dma mapping
Need to use a PCI device, not a FireWire host device.  Problem found by
Andreas Schwab, mistake pointed out by Benjamin Herrenschmidt.
http://ozlabs.org/pipermail/linuxppc-dev/2006-December/029595.html

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Tested-by: Andreas Schwab <schwab@suse.de>
2006-12-30 14:26:59 +01:00
Stefan Richter b2bb550c4a ieee1394: sbp2: pass REQUEST_SENSE through to the target
Delete some incorrect code, left over from the initial driver submission
in March 2001.

SBP-2 targets should provide sense data via the SBP-2 status block
(autosense).  We have to pass the REQUEST_SENSE command through to
targets which don't implement autosense, if there are any, and to
accomodate application clients which use this command.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-30 14:26:41 +01:00
Stefan Richter ec9b7e1044 ieee1394: sbp2: code formatting around work_struct stuff
Merge is finished, can bring the code in readable style again.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 23:23:25 +01:00
Ben Collins ed30c26ee8 ieee1394: Consolidate driver registering
This patch consolidates some bookkeeping for driver registering. It
closely models what pci_register_driver() does. The main addition is
that the owner of the driver is set, so we get a proper symlink
for /sys/bus/ieee1394/driver/*/module.

Also moves setting of name and bus type into nodemgr. Because of this,
we can remove the EXPORT_SYMBOL for ieee1394_bus_type, since it's now
only used in ieee1394.ko.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 23:11:55 +01: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
Stefan Richter 58272c1c03 ieee1394: sbp2: wrap two functions into one
Move the body of a function into its only caller.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 23:04:03 +01:00
Stefan Richter 2a533b179d ieee1394: sbp2: update comment on things to do
Some people actually look at those comments.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 23:03:49 +01:00
Stefan Richter cd641f68d6 ieee1394: sbp2: use list_move_tail()
It's OK to reorder list_del() and sbp2util_free_command_dma() here.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 23:03:38 +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 28b066795f ieee1394: sbp2: proper unit in module parameter description
It's 2^20 bit/s, not 0.001 bit.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 22:52:29 +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 5796aa7b11 ieee1394: sbp2: some conditions in queue_command are unlikely
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 22:49:39 +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 edf1fb213e ieee1394: sbp2: remove debug macros
No need to keep them in released sources.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 21:46:48 +01:00
Stefan Richter 35644090d8 ieee1394: sbp2: consolidate log levels
Replace some calls to SBP2_ERR and SBP2_WARN by SBP2_INFO.
Remove logging macros SBP2_NOTICE and SBP2_WARN.
Remove direct usage of HPSB_ logging macros.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 21:46:40 +01:00
Stefan Richter 0b885449ac ieee1394: sbp2: remove duplicate code
The same case is handled further below in sbp2scsi_complete_command.
Note, the second version behaves slightly different but looks
preferable.  It's an extremely unlikely case by the way.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 21:46:30 +01:00
Stefan Richter 8c8009e69b ieee1394: sbp2: remove dead code
This has been within #if 0 for a long time and is wrong anyway.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 21:46:20 +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
Stefan Richter 66743e061f ieee1394: sbp2: remove irritating log message
The queue depth can be read from /sys/bus/scsi/devices/*/queue_depth,
so don't log it.  And the hint about speed improvements is misleading,
at least under current kernels.  If serialization is switched off, read
performance is typically increased by less than 10%.  (I did not test
write performance recently.)  On the other hand, serialize_io=0 is not
yet safe due to some implementation issues that are not trivial to fix.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 21:45:58 +01:00
Stefan Richter 23077f1d72 ieee1394: sbp2: slightly reorder sbp2scsi_abort
Put the target's fetch agent into reset state before the underlying ORB
DMA is unmapped and the ->done handler is called.  It is highly unlikely
but the target could access that ORB right before sbp2 sends the reset
request.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-12-07 21:27:30 +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 c394f1eafe ieee1394: sbp2: enable auto spin-up for all SBP-2 devices
This is a follow-up to patch "ieee1394: sbp2: enable auto spin-up for
Maxtor disks".  When I 'ejected' an OXUF922 based HDD from a Mac OS X
box, it was spun down by the Mac and did not spin up by itself when
attached to a Linux box right after that.  The first SCSI command that
required the bridge to access the drive ended in
sda:<6>sd 18:0:0:0: Device not ready: <6>: Current: sense key: Not Ready
    Additional sense: Logical unit not ready, initializing cmd. required

Therefore the flag which instructs scsi_mod to send START STOP UNIT with
START=1 ("make medium ready") after such a condition is now enabled
unconditionally for all FireWire storage devices.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-09-17 19:53:01 +02:00
Stefan Richter 98e238cd42 ieee1394: sbp2: don't prefer MODE SENSE 10
In the old days, sbp2 used to coerce all MODE SENSE commands into the
10 bytes version.  When all command set conversions were removed from
sbp2 several months ago, sdev->use_10_for_ms = 1 was added.  Meaning,
higher SCSI layers preferred the 10 bytes version but would try the 6
bytes version if the former failed.

Recently, a problem with the 10 bytes version was discovered.  An Initio
INIC-1530 firmware accepted the 10 bytes version but replied with bogus
data, showing the HDD incorrectly as write-protected.  Since RBC
actually mandates MODE SENSE (6), I checked which version was sent by
Windows XP and Mac OS X 10.3 to an SBP-2 target hosted by Linux --- it
was the 6 bytes version.  (Exception: OS X sent the 10 bytes version to
an MMC target.  RBC and SBC got MODE SENSE (6).)

Therefore, drop the use_10_for_ms flag from sbp2.  Now the upper layers
will try MODE SENSE (6) before MODE SENSE (10) on all SBP-2 devices.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-09-17 19:38:52 +02: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 902abed158 ieee1394: sbp2: update includes
Remove unused includes.  Add missing includes, i.e. explicitly include
all used headers.  Sort includes alphabetically.  Replace one call to
signal_pending(current) to avoid to include headers just for this line.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-09-17 19:34:41 +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 4fc383c09d ieee1394: sbp2: recheck node generation in sbp2_update
While sbp2_update() is doing its duties after a bus reset, another reset
could happen.  Don't accept new requests until the next undisturbed
sbp2_update() or until sbp2_remove().

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-09-17 19:34:33 +02:00
Stefan Richter 1f427e8055 ieee1394: sbp2: safer agent reset in error handlers
The scsi_host_template's eh_abort_handler and eh_device_reset_handler
are allowed to sleep.  Use this to run sbp2_agent_reset in the more
reliable mode which returns _after_ its write transaction was finished.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-09-17 19:34:30 +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 611aa19fd6 ieee1394: safer definition of empty macros
A deactivated macro, defined as "#define foo(bar)", will result in
silent corruption if somebody forgets a semicolon after a call to foo.
Replace it by "#define foo(bar) do {} while (0)" which will reveal any
respective syntax errors.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-09-17 19:31:20 +02:00
Adrian Bunk a1b3206b36 the scheduled removal of drivers/ieee1394/sbp2.c:force_inquiry_hack
This patch contains the scheduled removal of the force_inquiry_hack
module parameter.

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2006-09-17 19:31:08 +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