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>
- 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>
Sbp2's copy of the status fifo was cleared when management ORBs or new
command ORBs were prepared. The latter had potential for a race
condition if the block layer's soft IRQ and the 1394 LLD's interrupt
handler ran on different CPUs. It would also yield wrong status if a
command was completed with non-zero completion status before other
commands that had zero completion status, and no new command was
enqueued in the meantime.
Now, the status buffer is cleared right before it is written. Thus it
ends up in the following simpler and safer access pattern:
- sbp2_alloc_device: allocates and implicitly clears once,
- sbp2_handle_status_write: clears, writes, and reads,
- sbp2_query_logins, sbp2_login_device, sbp2_reconnect_device: read.
The latter three do not race with sbp2_handle_status_write because of
how the protocol works.
As a tiny optimization, the first two quadlets of the status never need
to be cleared.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Only the driver writes ORBs, the device just reads them. Therefore
PCI_DMA_BIDIRECTIONAL can be replaced by PCI_DMA_TODEVICE which may be
cheaper on some architectures.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
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>
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>
This patch reduces the size of struct hpsb_host and also removes
semaphores from ieee1394_transactions.c. On i386, struct hpsb_host
shrinks from 10656 bytes to 6688 bytes. This is accomplished by
- using a single wait_queue for hpsb_get_tlabel instead of many
instances of semaphores,
- using a single lock to serialize access to all tlabel pools (the
protected code regions are small, i.e. lock contention very low),
- omitting the sysfs attribute tlabels_allocations.
Drawback: In the rare case that a process needs to sleep because all
transaction labels for the node are temporarily exhausted, it is also
woken up if a tlabel for a different node became free, checks for an
available tlabel, and is put to sleep again. The check is not costly
and the situation occurs extremely rarely. (Tlabels are typically
only exhausted if there was no context switch to the khpsbpkt thread
which recycles tlables.) Therefore the benefit of reduced tpool size
outweighs this drawback.
The sysfs attributes tlabels_free and tlabels_mask are not compiled
anymore unless CONFIG_IEEE1394_VERBOSEDEBUG is set.
The by far biggest member of struct hpsb_host, the struct csr_control
csr (5272 bytes on i386), is now placed at the end of struct hpsb_host.
Note, hpsb_get_tlabel calls the macro wait_event_interruptible with a
condition argument which has a side effect (allocation of a tlabel and
manipulation of the packet). This side effect happens only if the
condition is true. The patch relies on wait_event_interruptible not
evaluating the condition again after it became true.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Recently a patch was added for preliminary suspend/resume handling on
!PPC_PMAC. However, this broke both suspend and firewire on powerpc
because it saves the pci state after the device has already been disabled.
This moves the save state to before the pmac specific code.
Signed-off-by: Danny Tholen <obiwan@mailmij.org>
Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Ben Collins <bcollins@ubuntu.com>
Cc: Jody McIntyre <scjody@modernduck.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
At least Maxtor OneTouch III require a "start stop unit" command after auto
spin-down before the next access can proceed. This patch activates the
responsible code in scsi_mod for all Maxtor SBP-2 disks.
https://bugzilla.novell.com/show_bug.cgi?id=183011
Maybe that should be done for all SBP-2 disks, but better be cautious.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: Jody McIntyre <scjody@modernduck.com>
Cc: Ben Collins <bcollins@ubuntu.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
ieee1394 reuses the skb infrastructure of the networking code, and uses two
skb-head queues: ->pending_packet_queue and hpsbpkt_queue. The latter is used
in the usual fashion: processed from a kernel thread. The other one,
->pending_packet_queue is also processed from hardirq context (f.e. in
hpsb_bus_reset()), which is not what the networking code usually does (which
completes from softirq or process context). This locking assymetry can be
totally correct if done carefully, but it can also be dangerous if networking
helper functions are reused, which could assume traditional networking use.
It would probably be more robust to push this completion into a workqueue -
but technically the code can be 100% correct, and lockdep has to be taught
about it. The solution is to split the ->pending_packet_queue skb-head->lock
class from the networking lock-class by using a private lock-validator key.
Has no effect on non-lockdep kernels.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: Jody McIntyre <scjody@modernduck.com>
Cc: Ben Collins <bcollins@debian.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
There was stuff between the comment and the function.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
Another trivial sem2mutex conversion.
Side note: nodemgr_serialize's purpose, when introduced in linux1394's
revision 529 in July 2002, was to protect several data structures which
are now largely handled by or together with Linux' driver core and are
now protected by the LDM's own mechanisms. It may very well be possible
to remove this mutex now. But fully parallelized node scanning is on
our long-term TODO list anyway; the mutex will certainly go away then.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
Convert nodemgr's host thread from kernel_thread to kthread and its
sleep/restart mechanism from a counting semaphore to a schedule()/
wake_up_process() scheme.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
Nodemgr's ignore_drivers variable is exposed as a module load parameter
(therefore also as a sysfs attribute below /sys/module) and additionally
as an attribute below /sys/bus/ieee1394. Since the latter is writable,
make the former writable too.
Note, the bus's attribute ignore_drivers is only relevant to newly added
units, not to present or suspended or resuming units. Those have their
own attribute ignore_driver.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
nodemgr.c::fw_set_rescan() is used to re-run the driver core over
nodemgr's representation of unit directories in order to initiate
protocol driver probes. It is initiated via write access to one of
nodemgr's sysfs attributes. The purpose is to attach drivers to
units after switching a unit's ignore_driver attribute from 1 to 0.
It is not really necessary to fork a kernel_thread for this job. The
call to kernel_thread() can be eliminated to avoid the deprecated API
and to simplify the code a bit.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
An already existing wait queue replaces raw1394's complete_sem which was
maintained in parallel to the wait queue. The role of the semaphore's
counter is taken over by a direct check of what was really counted: The
presence of items in the list of completed requests.
Notes:
- raw1394_release() sleeps uninterruptibly until all requests were
completed. This is the same behaviour as before the patch.
- The macros wait_event and wait_event_interruptible are called with a
condition argument which has a side effect, i.e. manipulation of the
requests list. This side effect happens only if the condition is
true. The patch relies on the fact that wait_event[_interruptible]
does not evaluate the condition again after it became true.
- The diffstat looks unfavorable with respect to added lines of code.
However 19 of them are comments, and some are due to separation of
existing code blocks into two small helper functions.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
hpsb_update_config_rom() is defined in csr.c, not hosts.c.
hpsb_get_config_rom() does not exist.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
Remove unnecessary includes, add missing includes.
Use forward type declarations for some structs.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
Adjust tabulators, line wraps, empty lines, and comment style.
Update comments in ieee1394_transactions.h and highlevel.h.
Fix typo in comment in csr.h.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
The last loop in ieee1394 core's speed calculation is not required
unless ieee1394.h::IEEE1394_SPEED_MAX is changed from its current value
of 3.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
This variant of calculate_expire() is more correct and easier to read.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
At least Maxtor OneTouch III require a "start stop unit" command after
auto spin-down before the next access can proceed. This patch activates
the responsible code in scsi_mod for all Maxtor SBP-2 disks.
https://bugzilla.novell.com/show_bug.cgi?id=183011
Maybe that should be done for all SBP-2 disks, but better be cautious.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
If ieee1394.h::IEEE1394_SPEED_MAX is bigger than the actual speed of an
1394b host adapter and the speed to another 1394b node was probed, a
bigger speed than actually used was kept in host->speed[n]. The only
resulting problem so far was sbp2 displaying bogus values in the syslog,
e.g. S3200 for actual S800 connections if IEEE1394_SPEED_MAX was S3200.
But other high-level drivers which access this field could get into more
trouble. (Eth1394 is the only other in-tree driver which does so. It
seems it is not affected.)
Nodemgr now clips this value according to the host adapter's link speed.
A pointer expression in nodemgr_check_speed is also changed for clarity.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
Based on a patch series originally from Vivek Goyal <vgoyal@in.ibm.com>
Cc: Vivek Goyal <vgoyal@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This is needed if we wish to change the size of the resource structures.
Based on an original patch from Vivek Goyal <vgoyal@in.ibm.com>
Cc: Vivek Goyal <vgoyal@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial:
typo fixes
Clean up 'inline is not at beginning' warnings for usb storage
Storage class should be first
i386: Trivial typo fixes
ixj: make ixj_set_tone_off() static
spelling fixes
fix paniced->panicked typos
Spelling fixes for Documentation/atomic_ops.txt
move acknowledgment for Mark Adler to CREDITS
remove the bouncing email address of David Campbell
This patch converts the combination of list_del(A) and list_add(A, B) to
list_move(A, B) under drivers/.
Acked-by: Corey Minyard <minyard@mvista.com>
Cc: Ben Collins <bcollins@debian.org>
Acked-by: Roland Dreier <rolandd@cisco.com>
Cc: Alasdair Kergon <dm-devel@redhat.com>
Cc: Gerd Knorr <kraxel@bytesex.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Frank Pavlic <fpavlic@de.ibm.com>
Acked-by: Matthew Wilcox <matthew@wil.cx>
Cc: Andrew Vasquez <linux-driver@qlogic.com>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Greg Kroah-Hartman <greg@kroah.com>
Signed-off-by: Akinobu Mita <mita@miraclelinux.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Also revert patch "frv: ieee1394 is borken on frv", as it no longer is.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: David Howells <dhowells@redhat.com>
Cc: Jody McIntyre <scjody@modernduck.com>
Cc: Ben Collins <bcollins@ubuntu.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
The ieee1394 assumes it may make direct use of ->count in the semaphore
structure.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David Howells <dhowells@redhat.com>
Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: Ben Collins <bcollins@ubuntu.com>
Cc: Jody McIntyre <scjody@modernduck.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* git://git.kernel.org/pub/scm/linux/kernel/git/bcollins/linux1394-2.6: (28 commits)
eth1394: replace __constant_htons by htons
ieee1394: adjust code formatting in highlevel.c
ieee1394: hl_irqs_lock is taken in hardware interrupt context
ieee1394_core: switch to kthread API
ieee1394: sbp2: Kconfig fix
ieee1394: add preprocessor constant for invalid csr address
sbp2: fix deregistration of status fifo address space
[PATCH] eth1394: endian fixes
Fix broken suspend/resume in ohci1394
sbp2: use __attribute__((packed)) for on-the-wire structures
sbp2: provide helptext for CONFIG_IEEE1394_SBP2_PHYS_DMA and mark it experimental
Update feature removal of obsolete raw1394 ISO requests.
sbp2: fix S800 transfers if phys_dma is off
sbp2: remove ohci1394 specific constant
ohci1394: make phys_dma parameter read-only
ohci1394: set address range properties
ieee1394: extend lowlevel API for address range properties
sbp2: log number of supported concurrent logins
sbp2: remove manipulation of inquiry response
ieee1394: save RAM by using a single tlabel for broadcast transactions
...
This ugly hack was long overdue to die.
It was a way to print out Sparc interrupts in a more freindly format,
since IRQ numbers were arbitrary opaque 32-bit integers which vectored
into PIL levels. These 32-bit integers were not necessarily in the
0-->NR_IRQS range, but the PILs they vectored to were.
The idea now is that we will increase NR_IRQS a little bit and use a
virtual<-->real IRQ number mapping scheme similar to PowerPC.
That makes this IRQ printing hack irrelevant, and furthermore only a
handful of drivers actually used __irq_itoa() making it even less
useful.
Signed-off-by: David S. Miller <davem@davemloft.net>
...and __constant_ntohs, __constant_ntohl, __constant_cpu_to_be32 too
where possible. Htons and friends are resolved to constants in these
places anyway. Also fix an endianess glitch in a log message, spotted
by Alexey Dobriyan.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
Replace spaces by tabulators, wrap lines at 80 columns, delete some
blank lines and superfluous braces. Collapse some if()-within-if()
constructs. Replace a literal CSR address by its preprocessor constant.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
ohci1394 and pcilynx call highlevel_host_reset from their hardware
interrupt handler (via hpsb_selfid_complete). Therefore all readers and
writers of hl_irqs_lock have to disable interrupts. Reported by Jiri
Slaby and J. A. Magallon.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
This gets also rid of the MODPOST warning "drivers/ieee1394/ieee1394.o -
Section mismatch: reference to .exit.text: from .smp_locks after '' (at
offset 0x18)".
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jody McIntyre <scjody@modernduck.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
We only support x86 and ppc, due to the use of bus_to_virt() and friends.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
Replace occurrences of the magic value ~(u64)0 for invalid
CSR address spaces by a named constant for better readability.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
The proper designator of an invalid CSR address is ~(u64)0, not (u64)0.
Use the correct value in initialization and deregistration.
Also, scsi_id->sbp2_lun does not need to be initialized twice.
(scsi_id was kzalloc'd.)
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
I've been experimenting to track down the cause of suspend/resume problems
on my Compaq Presario X1050 laptop:
http://bugzilla.kernel.org/show_bug.cgi?id=6075
Essentially the ACPI Embedded Controller and keyboard controller would
get into a bizarre, confused state after resume.
I found that unloading the ohci1394 module before suspend and reloading it
after resume made the problem go away. Diffing the dmesg output from
resume, with and without the module loaded, I found that with the module
loaded I was missing these:
PM: Writing back config space on device 0000:02:00.0 at offset 1. (Was 2100080, writing 2100007)
PM: Writing back config space on device 0000:02:00.0 at offset 3. (Was 0, writing 8008)
PM: Writing back config space on device 0000:02:00.0 at offset 4. (Was 0, writing 90200000)
PM: Writing back config space on device 0000:02:00.0 at offset 5. (Was 1, writing 2401)
PM: Writing back config space on device 0000:02:00.0 at offset f. (Was 20000100, writing 2000010a)
The default PCI driver performs the pci_restore_state when no driver is
loaded for the device. When the ohci1394 driver is loaded, it is supposed
to do this, however it appears not to do so.
I created the patch below and tested it, and it appears to resolve the
suspend problems I was having with the module loaded. I only added in the
pci_save_state and pci_restore_state - however, though I know little of
this hardware, surely the driver should really be doing more than this when
suspending and resuming? Currently it does almost nothing, what if there
are commands in progress, etc?
Signed-off-by: Robert Hancock <hancockr@shaw.ca>
Cc: Jody McIntyre <scjody@modernduck.com>
Cc: Ben Collins <bcollins@debian.org>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>