IEEE 1394 updates for Linux 2.6.34.y (v1306 2011-07-12) Documentation/ABI/stable/firewire-cdev | 103 Documentation/ABI/stable/sysfs-bus-firewire | 122 Documentation/feature-removal-schedule.txt | 10 Documentation/ioctl/ioctl-number.txt | 1 Documentation/sound/alsa/ALSA-Configuration.txt | 7 drivers/Makefile | 2 drivers/firewire/Kconfig | 33 drivers/firewire/Makefile | 2 drivers/firewire/core-card.c | 271 + drivers/firewire/core-cdev.c | 497 ++- drivers/firewire/core-device.c | 33 drivers/firewire/core-iso.c | 84 drivers/firewire/core-topology.c | 24 drivers/firewire/core-transaction.c | 442 ++- drivers/firewire/core.h | 37 drivers/firewire/init_ohci1394_dma.c | 309 ++ drivers/firewire/net.c | 247 + drivers/firewire/nosy-user.h | 25 drivers/firewire/nosy.c | 722 +++++ drivers/firewire/nosy.h | 237 + drivers/firewire/ohci.c | 1898 +++++++++---- drivers/firewire/ohci.h | 3 drivers/firewire/sbp2.c | 31 drivers/ieee1394/Kconfig | 4 drivers/ieee1394/Makefile | 2 drivers/ieee1394/dv1394.c | 29 drivers/ieee1394/eth1394.c | 3 drivers/ieee1394/init_ohci1394_dma.c | 285 - drivers/ieee1394/ohci1394.c | 2 drivers/ieee1394/raw1394.c | 10 drivers/ieee1394/sbp2.c | 11 drivers/ieee1394/video1394.c | 22 drivers/media/dvb/Kconfig | 2 drivers/media/dvb/firewire/Kconfig | 8 drivers/media/dvb/firewire/Makefile | 5 drivers/media/dvb/firewire/firedtv-1394.c | 300 -- drivers/media/dvb/firewire/firedtv-avc.c | 93 drivers/media/dvb/firewire/firedtv-ci.c | 34 drivers/media/dvb/firewire/firedtv-dvb.c | 135 drivers/media/dvb/firewire/firedtv-fe.c | 44 drivers/media/dvb/firewire/firedtv-fw.c | 151 - drivers/media/dvb/firewire/firedtv-rc.c | 9 drivers/media/dvb/firewire/firedtv.h | 45 include/linux/firewire-cdev.h | 535 ++- include/linux/firewire.h | 80 include/sound/Kbuild | 1 include/sound/asound.h | 3 include/sound/firewire.h | 51 sound/Kconfig | 2 sound/Makefile | 2 sound/firewire/Kconfig | 65 sound/firewire/Makefile | 12 sound/firewire/amdtp.c | 567 +++ sound/firewire/amdtp.h | 174 + sound/firewire/cmp.c | 300 ++ sound/firewire/cmp.h | 41 sound/firewire/dice.c | 1282 ++++++++ sound/firewire/fcp.c | 224 + sound/firewire/fcp.h | 12 sound/firewire/fireworks.c | 2283 ++++++++++++++++ sound/firewire/fireworks.h | 201 + sound/firewire/isight.c | 756 +++++ sound/firewire/iso-resources.c | 231 + sound/firewire/iso-resources.h | 38 sound/firewire/lib.c | 85 sound/firewire/lib.h | 19 sound/firewire/packets-buffer.c | 76 sound/firewire/packets-buffer.h | 26 sound/firewire/speakers.c | 857 ++++++ tools/firewire/Makefile | 19 tools/firewire/decode-fcp.c | 213 + tools/firewire/list.h | 62 tools/firewire/nosy-dump.c | 1031 +++++++ tools/firewire/nosy-dump.h | 173 + 74 files changed, 13680 insertions(+), 2075 deletions(-) Date: Sun, 10 Jul 2011 00:23:03 +0200 From: Stefan Richter firewire: ohci: do not bind to Pinnacle cards, prevent panic When firewire-ohci is bound to a Pinnacle MovieBoard, eventually a "Register access failure" is logged and an interrupt storm or a kernel panic happens. https://bugzilla.kernel.org/show_bug.cgi?id=36622 Until this is sorted out (if that is going to succeed at all), let's just prevent firewire-ohci from touching these devices. Signed-off-by: Stefan Richter Cc: --- drivers/firewire/ohci.c | 6 ++++++ 1 file changed, 6 insertions(+) Date: Sat, 9 Jul 2011 16:48:29 +0200 From: Stefan Richter firewire: document the sysfs ABIs of firewire-core and firewire-sbp2. Signed-off-by: Stefan Richter --- Documentation/ABI/stable/sysfs-bus-firewire | 122 ++++++++++++++++++++ 1 file changed, 122 insertions(+) Date: Sat, 9 Jul 2011 17:05:06 +0200 From: Stefan Richter firewire: cdev: ABI documentation enhancements Add overview documentation in Documentation/ABI/stable/firewire-cdev. Improve the inline reference documentation in firewire-cdev.h: - Add /* available since kernel... */ comments to event numbers consistent with the comments on ioctl numbers. - Shorten some documentation on an event and an ioctl that are less interesting to current programming because there are newer preferable variants. - Spell Configuration ROM (name of an IEEE 1212 register) in upper case. - Move the dummy FW_CDEV_VERSION out of the reader's field of vision. We should remove it from the header next year or so. Signed-off-by: Stefan Richter --- Documentation/ABI/stable/firewire-cdev | 103 +++++++++++++++++++++++++ include/linux/firewire-cdev.h | 75 ++++++++---------- 2 files changed, 137 insertions(+), 41 deletions(-) Date: Sat, 9 Jul 2011 16:43:22 +0200 From: Stefan Richter firewire: cdev: prevent race between first get_info ioctl and bus reset event queuing Between open(2) of a /dev/fw* and the first FW_CDEV_IOC_GET_INFO ioctl(2) on it, the kernel already queues FW_CDEV_EVENT_BUS_RESET events to be read(2) by the client. The get_info ioctl is practically always issued right away after open, hence this condition only occurs if the client opens during a bus reset, especially during a rapid series of bus resets. The problem with this condition is two-fold: - These bus reset events carry the (as yet undocumented) @closure value of 0. But it is not the kernel's place to choose closures; they are privat to the client. E.g., this 0 value forced from the kernel makes it unsafe for clients to dereference it as a pointer to a closure object without NULL pointer check. - It is impossible for clients to determine the relative order of bus reset events from get_info ioctl(2) versus those from read(2), except in one way: By comparison of closure values. Again, such a procedure imposes complexity on clients and reduces freedom in use of the bus reset closure. So, change the ABI to suppress queuing of bus reset events before the first FW_CDEV_IOC_GET_INFO ioctl was issued by the client. Note, this ABI change cannot be version-controlled. The kernel cannot distinguish old from new clients before the first FW_CDEV_IOC_GET_INFO ioctl. We will try to back-merge this change into currently maintained stable/ longterm series, and we only document the new behaviour. The old behavior is now considered a kernel bug, which it basically is. Signed-off-by: Stefan Richter Cc: --- drivers/firewire/core-cdev.c | 18 ++++++++++-------- include/linux/firewire-cdev.h | 3 +++ 2 files changed, 13 insertions(+), 8 deletions(-) Date: Sat, 9 Jul 2011 16:42:26 +0200 From: Stefan Richter firewire: cdev: return -ENOTTY for unimplemented ioctls, not -EINVAL On Jun 27 Linus Torvalds wrote: > The correct error code for "I don't understand this ioctl" is ENOTTY. > The naming may be odd, but you should think of that error value as a > "unrecognized ioctl number, you're feeding me random numbers that I > don't understand and I assume for historical reasons that you tried to > do some tty operation on me". [...] > The EINVAL thing goes way back, and is a disaster. It predates Linux > itself, as far as I can tell. You'll find lots of man-pages that have > this line in it: > > EINVAL Request or argp is not valid. > > and it shows up in POSIX etc. And sadly, it generally shows up > _before_ the line that says > > ENOTTY The specified request does not apply to the kind of object > that the descriptor d references. > > so a lot of people get to the EINVAL, and never even notice the ENOTTY. [...] > At least glibc (and hopefully other C libraries) use a _string_ that > makes much more sense: strerror(ENOTTY) is "Inappropriate ioctl for > device" So let's correct this in the ABI while it is still young, relative to distributor adoption. Side note: We return -ENOTTY not only on _IOC_TYPE or _IOC_NR mismatch, but also on _IOC_SIZE mismatch. An ioctl with an unsupported size of argument structure can be seen as an unsupported version of that ioctl. Signed-off-by: Stefan Richter Cc: --- drivers/firewire/core-cdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Date: Wed, 6 Jul 2011 19:33:15 +0200 From: Stefan Richter [media] firedtv: change some -EFAULT returns to more fitting error codes Mauro Carvalho Chehab wrote: > I'm validating if all drivers are behaving equally with respect to the > error codes returned to userspace, and double-checking with the API. > > On almost all places, -EFAULT code is used only to indicate when > copy_from_user/copy_to_user fails. However, firedtv uses a lot of > -EFAULT, where it seems to me that other error codes should be used > instead (like -EIO for bus transfer errors and -EINVAL/-ERANGE for > invalid/out of range parameters). This concerns only the CI (CAM) related code of firedtv of which I know little. Let's just pass through the error returns of lower level I/O code where applicable, and -EACCES (permission denied) when a seemingly valid but negative FCP response or an unknown-to-firedtv CA message is received. Signed-off-by: Stefan Richter Cc: Henrik Kurelid --- drivers/media/dvb/firewire/firedtv-avc.c | 2 drivers/media/dvb/firewire/firedtv-ci.c | 34 +++++++++++------------ 2 files changed, 17 insertions(+), 19 deletions(-) Date: Sun, 3 Jul 2011 17:39:26 +0200 From: Stefan Richter firewire: ohci: skip soft reset retries after card ejection The software reset in firewire-ohci's pci_remove does not have a great prospect of success if the card was already physically removed at this point. So let's skip the 500 ms that were spent in retries here. Also, replace a defined constant by its open-coded value. This is not a constant from a specification but an arbitrarily chosen retry limit. It was only used in this single place. Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) Date: Wed, 22 Jun 2011 21:05:08 +0200 From: Stefan Richter firewire: ohci: fix PHY reg access after card ejection Detect and handle ejection of FireWire CardBus cards in PHY register accesses: - The last attempt of firewire-core to reset the bus during shutdown caused a spurious "firewire_ohci: failed to write phy reg" error message in the log. Skip this message as well as the prior retry loop that needlessly took 100 milliseconds. - In the unlikely case that a PHY register was read right after card ejection, a bogus value was obtained and possibly acted upon. Instead, fail the read attempt. Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 6 ++++++ 1 file changed, 6 insertions(+) Date: Tue, 21 Jun 2011 15:24:26 +0200 From: Stefan Richter firewire: ohci: add a comment on PHY reg access serialization Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 6 ++++++ 1 file changed, 6 insertions(+) From cf6f1ff17f56c275424c5a341fc4d27ccbbfa71c Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Fri, 17 Jun 2011 08:18:35 +0200 [PATCH] ALSA: isight: adjust for new queueing API Since commit 13882a82ee16 (optimize iso queueing by setting wake only after the last packet), drivers are required to call fw_iso_context_queue_flush() after queueing a batch of packets. The missing call would have an effect only if the controller queue underruns, but then the DMA would stop completely. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/firewire/isight.c | 1 + 1 file changed, 1 insertion(+) Date: Wed, 22 Jun 2011 20:39:03 +0200 From: Stefan Richter ALSA: fireworks: adjust for new queueing API --- sound/firewire/fireworks.c | 6 ++++++ 1 file changed, 6 insertions(+) Date: Sun, 12 Jun 2011 17:00:56 +0200 From: Stefan Richter ALSA: fireworks: avoid duplicate variable name 'index' Pointed out by sparse: "symbol 'index' shadows an earlier one". Could also be fixed by static int interface_index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; module_param_array_named(index, interface_index, int, NULL, 0444); [...] err = snd_card_create(interface_index[card_index], id[card_index], THIS_MODULE, --- sound/firewire/fireworks.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) Date: Sun, 12 Jun 2011 17:00:56 +0200 From: Stefan Richter ALSA: fireworks: fix lock imbalance in an error path Pointed out by sparse: "context imbalance in 'capture_iso_callback' - different lock contexts for basic block". --- sound/firewire/fireworks.c | 1 + 1 file changed, 1 insertion(+) From 2a2405fac5f900608eff5ea89926480aad475877 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 30 Sep 2010 14:49:53 +0200 [PATCH 12/12] ALSA: fireworks: add MIDI output --- sound/firewire/fireworks.c | 195 ++++++++++++++++++++++++++++++------- 1 file changed, 158 insertions(+), 37 deletions(-) From 331f4c14546bbfd5ab42dc646b087898bc18df62 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 30 Sep 2010 14:49:42 +0200 [PATCH 11/12] ALSA: fireworks: allow PCM streams to be started synchronously --- sound/firewire/fireworks.c | 75 ++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 42 deletions(-) From bad1f8034d68fd4c7d722cf7cd27573d4d556277 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 30 Sep 2010 14:49:31 +0200 [PATCH 10/12] ALSA: fireworks: add PCM playback --- sound/firewire/fireworks.c | 627 ++++++++++++++++++++++++++++++++++++- 1 file changed, 617 insertions(+), 10 deletions(-) From 513450c9e03dbf56f238019f232dcad2b6016470 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 30 Sep 2010 14:49:19 +0200 [PATCH 09/12] ALSA: fireworks: check received CIP headers for consistency --- sound/firewire/fireworks.c | 97 ++++++++++++++++++++++++++++++------- 1 file changed, 78 insertions(+), 19 deletions(-) From 4c0e62d5d862d187b2e92070e6016a7037380da9 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 30 Sep 2010 14:49:07 +0200 [PATCH 08/12] ALSA: fireworks: add identify control --- sound/firewire/fireworks.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) From b5fcebfec4f6e6a8858e708d97979d83d2ccb471 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 30 Sep 2010 14:48:55 +0200 [PATCH 07/12] ALSA: fireworks: add polled values control --- sound/firewire/fireworks.c | 60 +++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) From 86b939359167083c1e6d6edc3181ee2fb3229a66 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 30 Sep 2010 14:48:43 +0200 [PATCH 06/12] ALSA: fireworks: add hardware capabilities control --- sound/firewire/fireworks.c | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) From dd80a554f38649b8768717e772e8b0d0b8dd0e49 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 30 Sep 2010 14:48:26 +0200 [PATCH 05/12] ALSA: fireworks: synchronize PCM stream start with fw data --- sound/firewire/fireworks.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) From 6afe12c0d1ef003fb6e57e6d34df01b1f391a50d Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 30 Sep 2010 14:48:10 +0200 [PATCH 04/12] ALSA: fireworks: add PCM capture --- sound/firewire/fireworks.c | 236 +++++++++++++++++++++++++++++++++++++ 1 file changed, 236 insertions(+) From 38d7d9f0974b2265ba50931b9d0be3066d0bb210 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 30 Sep 2010 14:47:49 +0200 [PATCH 03/12] ALSA: fireworks: fix bus reset handling --- sound/firewire/fireworks.c | 74 +++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 4 deletions(-) From bfd3510a4340c9cf2d3722baf262d84756acd970 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 30 Sep 2010 14:46:27 +0200 [PATCH 02/12] ALSA: fireworks: add MIDI capture --- sound/firewire/fireworks.c | 431 +++++++++++++++++++++++++++++++++++++ 1 file changed, 431 insertions(+) From fb9ed6a705e827f49f65de123d698171ad72d6e3 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 30 Sep 2010 14:46:10 +0200 [PATCH 01/12] ALSA: add Echo Fireworks support skeleton driver only [StefanR: - forward-merge to 2.6.39 + firewire patches + snd-dice patches, - added #include ] --- Documentation/sound/alsa/ALSA-Configuration.txt | 7 + sound/firewire/Kconfig | 15 + sound/firewire/Makefile | 2 + sound/firewire/fireworks.c | 606 ++++++++++++++++ sound/firewire/fireworks.h | 201 +++++ 5 files changed, 831 insertions(+) create mode 100644 sound/firewire/Kconfig create mode 100644 sound/firewire/Makefile create mode 100644 sound/firewire/fireworks.c create mode 100644 sound/firewire/fireworks.h Date: Sun, 12 Jun 2011 14:30:57 +0200 From: Stefan Richter firewire: ohci: reduce potential context_stop latency Stopping an isochronous reception DMA context takes two loop iterations in context_stop on several controllers (JMicron, NEC, VIA). But there is no extra delay necessary between these two reg_read trials; the MMIO reads themselves are slow enough. Hence bring back the behavior from before commit dd6254e5c0efe01ad255188898cb3dadf98cb56d "firewire: ohci: remove superfluous posted write flushes" on these controllers by means of an "if (i)" condition. Isochronous context stop is performed in preemptible contexts (and only rarely), hence this change is of little impact. (Besides, Agere and TI controllers always, or almost always, have the context stopped already at the first ContextControl read.) More important is asynchronous transmit context stop, which is performed while local interrupts are disabled (on the two AT DMAs in bus_reset_tasklet, i.e. after a self-ID-complete event). In my experience with several controllers, tested with a usermode AT-request transmitter as well as with FTP transmission over firewire-net, the AT contexts were luckily already stopped at the first ContextControl read, i.e. never required another MMIO read let alone mdelay. A possible explanation for this is that the controllers which I tested perhaps stop AT DMA before they perform the self-ID reception DMA. But we cannot be sure about that and should keep the interrupts-disabled busy loop as short as possible. Hence, query the ContextControl register in 1000 udelay(10) intervals instead of 10 udelay(1000) intervals. I understand from an estimation by Clemens Ladisch that stopping a busy DMA context should take microseconds or at worst tens of microseconds, not milliseconds. Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) Date: Mon, 16 May 2011 08:10:10 +0200 From: Clemens Ladisch firewire: ohci: remove superfluous posted write flushes The call to flush_writes() in context_stop() is superfluous because another register read is done immediately afterwards. The call to flush_writes() in ar_context_run() does not need to be done individually for each AR context, so move it to ohci_enable(). This also makes ohci_enable() clearer because it no longer depends on a side effect of ar_context_run() to flush its own register writes. Finally, the setting of a context's wake bit does not need to be flushed because neither the driver logic nor the API require the CPU to wait for this action. This removes the last MMIO reads from the packet queueing code paths. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) Date: Sun, 29 May 2011 19:07:19 +0200 From: August Lilleaas firewire: net: replacing deprecated __attribute__((packed)) with __packed Fixing a deprecation, replacing __attribute__((packed)) with __packed. It was deprecated for portability, specifically to avoid GCC specific code. See commit 82ddcb040570411fc2d421d96b3e69711c670328. Signed-off-by: August Lilleaas Signed-off-by: Stefan Richter (added include compiler.h) --- drivers/firewire/net.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) From ed4d975dde2fd0ea129d7043f0c98c90b96dcb2e Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 28 Apr 2011 08:03:43 +0200 ALSA: dice: clear device lock when closing hwdep device Ensure that misbehaving or aborted userspace programs do not accidentally keep the lock. Signed-off-by: Clemens Ladisch --- sound/firewire/dice.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) Date: Wed, 11 May 2011 11:07:09 +0200 From: Clemens Ladisch ALSA: isight: fix locking Lockdep complains about conflicts between isight->mutex, ALSA's register_mutex, mm->mmap_sem, and pcm->open_mutex. This can be fixed by moving the calls to isight_pcm_abort(), snd_card_disconnect(), and fw_iso_resources_update() out of isight->mutex. These functions are designed to be called asynchronously; the mutex needs to protect only the device streaming state modified by isight_start/stop_streaming(). Signed-off-by: Clemens Ladisch Reported-by: Stefan Richter Signed-off-by: Takashi Iwai --- sound/firewire/isight.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) Date: Wed, 11 May 2011 10:54:41 +0200 From: Clemens Ladisch ALSA: isight: remove experimental status Experiments have shown this driver to work now. Signed-off-by: Clemens Ladisch Tested-by: Stefan Richter Signed-off-by: Takashi Iwai --- sound/firewire/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) Date: Mon, 02 May 2011 09:33:56 +0200 From: Clemens Ladisch firewire: optimize iso queueing by setting wake only after the last packet When queueing iso packets, the run time is dominated by the two MMIO accesses that set the DMA context's wake bit. Because most drivers submit packets in batches, we can save much time by removing all but the last wakeup. The internal kernel API is changed to require a call to fw_iso_context_queue_flush() after a batch of queued packets. The user space API does not change, so one call to FW_CDEV_IOC_QUEUE_ISO must specify multiple packets to take advantage of this optimization. In my measurements, this patch reduces the time needed to queue fifty skip packets from userspace to one sixth on a 2.5 GHz CPU, or to one third at 800 MHz. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/core-card.c | 5 +++++ drivers/firewire/core-cdev.c | 1 + drivers/firewire/core-iso.c | 6 ++++++ drivers/firewire/core.h | 2 ++ drivers/firewire/net.c | 4 +++- drivers/firewire/ohci.c | 19 +++++++++++++++---- drivers/media/dvb/firewire/firedtv-fw.c | 1 + include/linux/firewire.h | 1 + sound/firewire/amdtp.c | 1 + 9 files changed, 35 insertions(+), 5 deletions(-) Date: Mon, 2 May 2011 13:33:42 -0400 From: "B.J. Buchalter" firewire: Fix for broken configrom updates in quick succession Current implementation of ohci_set_config_rom() uses a deferred bus reset via fw_schedule_bus_reset(). If clients add multiple unit descriptors to the config_rom in quick succession, the deferred bus reset may not have fired before succeeding update requests have come in. This can lead to an incorrect partial update of the config_rom for both addition and removal of config_rom descriptors, as the ohci_set_config_rom() routine will return -EBUSY if a previous pending update has not been completed yet; the requested update just gets dropped on the floor. This patch recognizes that the "in-flight" update can be modified until it has been processed by the bus-reset, and the locking in the bus_reset_tasklet ensures that the update is done atomically with respect to modifications made by ohci_set_config_rom(). The -EBUSY error case is simply removed. [Stefan R: The bug always existed at least theoretically. But it became easy to trigger since 2.6.36 commit 02d37bed188c "firewire: core: integrate software-forced bus resets with bus management" which introduced long mandatory delays between janitorial bus resets.] Signed-off-by: Benjamin Buchalter Signed-off-by: Stefan Richter (trivial style changes) Cc: # 2.6.36.y and newer --- drivers/firewire/ohci.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) Date: Sun, 1 May 2011 21:06:42 +0200 From: Stefan Richter firewire: sbp2: octlet AT payloads can be stack-allocated We do not need slab allocations for ORB pointer write transactions anymore in order to satisfy streaming DMA mapping constraints, thanks to commit da28947e7e36 "firewire: ohci: avoid separate DMA mapping for small AT payloads". (Besides, the slab-allocated buffers that firewire-sbp2 used to provide for 8-byte write requests were still not fully portable since they shared a cacheline with unrelated CPU-accessed data.) Signed-off-by: Stefan Richter --- drivers/firewire/sbp2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) Date: Fri, 22 Apr 2011 15:13:54 +0200 From: Stefan Richter firewire: octlet AT payloads can be stack-allocated We do not need slab allocations anymore in order to satisfy streaming DMA mapping constraints, thanks to commit da28947e7e36 "firewire: ohci: avoid separate DMA mapping for small AT payloads". (Besides, the slab-allocated buffers that firewire-core, firewire-sbp2, and firedtv used to provide for 8-byte write and lock requests were still not fully portable since they crossed cacheline boundaries or shared a cacheline with unrelated CPU-accessed data. snd-firewire-lib got this aspect right by using an extra kmalloc/ kfree just for the 8-byte transaction buffer.) This change replaces kmalloc'ed lock transaction scratch buffers in firewire-core, firedtv, and snd-firewire-lib by local stack allocations. Perhaps the most notable result of the change is simpler locking because there is no need to serialize usages of preallocated per-device buffers anymore. Also, allocations and deallocations are simpler. Signed-off-by: Stefan Richter Acked-by: Clemens Ladisch --- drivers/firewire/core-card.c | 16 ++++++++-------- drivers/firewire/core-cdev.c | 4 +--- drivers/firewire/core-iso.c | 21 +++++++++++---------- drivers/firewire/core-transaction.c | 7 ++++--- drivers/media/dvb/firewire/firedtv-avc.c | 15 +-------------- include/linux/firewire.h | 3 +-- sound/firewire/cmp.c | 3 +-- sound/firewire/iso-resources.c | 12 +++--------- sound/firewire/iso-resources.h | 1 - 9 files changed, 30 insertions(+), 52 deletions(-) From 793175a06225da8a2c06102092bf7ab97c8eeb8c Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Wed, 13 Apr 2011 08:25:04 +0200 ALSA: dice: msleep needs delay.h build requirement on 2.6.39 x86-64 Signed-off-by: Stefan Richter Signed-off-by: Clemens Ladisch --- sound/firewire/dice.c | 1 + 1 file changed, 1 insertion(+) Date: Tue, 12 Apr 2011 07:54:59 +0200 From: Clemens Ladisch firewire: ohci: optimize find_branch_descriptor() When z==2, the condition "key == 2" is superfluous because it cannot occur without "b == 3", as a descriptor with b!=3 and key==2 would be an OUTPUT_MORE_IMMEDIATE descriptor which cannot be used alone. Also remove magic numbers and needless computations on the b field. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) Date: Mon, 11 Apr 2011 09:57:54 +0200 From: Clemens Ladisch firewire: ohci: avoid separate DMA mapping for small AT payloads For AT packet payloads of up to eight bytes, we have enough unused space in the DMA descriptors list so that we can put a copy of the payload there and thus avoid having to create a separate streaming DMA mapping for the payload buffer. In a CPU-bound microbenchmark that just sends 8-byte packets, bandwidth was measured to increase by 5.7 %, from 1009 KB/s to 1067 KB/s. In practice, the only performance-sensitive usage of small asynchronous packets is the SBP-2 driver's write to the ORB_POINTER register during SCSI command submission. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) Date: Mon, 11 Apr 2011 09:56:12 +0200 From: Clemens Ladisch firewire: ohci: do not start DMA contexts before link is enabled OHCI 1.1 5.7.3 not only forbids enabling or starting any DMA contexts before the linkEnable bit is set, but also explicitly warns of undefined behaviour if this order is violated. Don't violate it then. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) From 619f53e05526e5edaf8ac0c198f25cc650161524 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 4 Apr 2011 08:48:06 +0200 ALSA: dice: implement hwdep device Implement the hwdep locking and notification mechanisms. Signed-off-by: Clemens Ladisch --- sound/firewire/dice.c | 225 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 203 insertions(+), 22 deletions(-) From 4546822e8450e4d13a19c447f4c544d575df16c2 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 4 Apr 2011 08:44:30 +0200 ALSA: dice: fix typo in firewire.h Signed-off-by: Clemens Ladisch --- include/sound/firewire.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) From f8e8bb824aac9472b0a40d195e14f13877715c4b Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 31 Mar 2011 08:07:13 +0200 ALSA: dice: change ioctl numbers Change the (fortunately not yet implemented) ioctl numbers from F1..F3 to F8..FA to prevent a conflict with the new hid-roccat driver. Signed-off-by: Clemens Ladisch --- Documentation/ioctl/ioctl-number.txt | 2 +- include/sound/firewire.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) From f075c67d8bd5736fd612e5cec5ceafa4d58ef47d Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Wed, 30 Mar 2011 08:28:09 +0200 ALSA: dice: fix hang when unplugging a running device When aborting a PCM stream, the xrun is signaled only if the stream is running. When disconnecting a PCM stream, calling snd_card_disconnect() too early would change the stream into a non-running state and thus prevent the xrun from being noticed by user space. To prevent this, move the snd_card_disconnect() call after the xrun. Signed-off-by: Clemens Ladisch --- sound/firewire/dice.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) From 8a495f6184eb533d5641d7dd5703d5582fa834a5 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Wed, 30 Mar 2011 08:27:46 +0200 ALSA: isight: fix hang when unplugging a running device When aborting a PCM stream, the xrun is signaled only if the stream is running. When disconnecting a PCM stream, calling snd_card_disconnect() too early would change the stream into a non-running state and thus prevent the xrun from being noticed by user space. To prevent this, move the snd_card_disconnect() call after the xrun. Signed-off-by: Clemens Ladisch --- sound/firewire/isight.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) From 2725fb2c0e7081f99dd2a24b3b2ea9a93b0d236d Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Wed, 30 Mar 2011 08:27:26 +0200 ALSA: firewire-speakers: fix hang when unplugging a running device When aborting a PCM stream, the xrun is signaled only if the stream is running. When disconnecting a PCM stream, calling snd_card_disconnect() too early would change the stream into a non-running state and thus prevent the xrun from being noticed by user space. To prevent this, move the snd_card_disconnect() call after the xrun. Signed-off-by: Clemens Ladisch --- sound/firewire/speakers.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) From 7365ec51bd8653d141bc98b5632f2c53580d2b36 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Tue, 29 Mar 2011 10:12:55 +0200 ALSA: dice, firewire-lib: add blocking mode Allow AMDTP output streams to use blocking mode. Use it for DICE devices, because the old DICE-II chip will in some cases not be able to lock to non-blocking streams (erratum E7). Signed-off-by: Clemens Ladisch --- sound/firewire/amdtp.c | 54 ++++++++++++++++++++++------------------- sound/firewire/amdtp.h | 7 ++++- sound/firewire/dice.c | 2 +- 3 files changed, 36 insertions(+), 27 deletions(-) From bc0bfef119e31d419e65b6758260e9d26e4828f8 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Tue, 29 Mar 2011 10:11:40 +0200 ALSA: dice: reduce noisy logging The notification bits are not of general interest; log them only when debugging. Signed-off-by: Clemens Ladisch --- sound/firewire/dice.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) From 00725b6b475b19d1146543003675e76b5d01d926 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Tue, 29 Mar 2011 10:11:15 +0200 ALSA: dice: allow all sample rates Instead of forcing a constant 44.1 kHz, read the current sample rate from the device when opening the PCM device. Actually changing the sample rate requires some separate controller application. Signed-off-by: Clemens Ladisch --- sound/firewire/dice.c | 55 ++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 13 deletions(-) From 86b653383da011338ead9e6cfc2fcda26d49b3d4 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Tue, 29 Mar 2011 10:05:07 +0200 ALSA: isight: msleep needs delay.h Fixes compilation on some non-x86 architectures. Signed-off-by: Clemens Ladisch --- sound/firewire/isight.c | 1 + 1 file changed, 1 insertion(+) From 7184c2aeb0e086f1e574951f89729d94e5ca864b Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Tue, 29 Mar 2011 10:03:12 +0200 ALSA: isight: wrap up register accesses Signed-off-by: Stefan Richter [cl: removed superfluous variable] Signed-off-by: Clemens Ladisch --- sound/firewire/isight.c | 76 ++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 46 deletions(-) From d0c2f9d61f33aed11c9f15d92aeddb9a373afb18 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Tue, 29 Mar 2011 09:58:05 +0200 ALSA: isight: add AudioEnable register write which is needed to get the iSight to talk. Signed-off-by: Stefan Richter Signed-off-by: Clemens Ladisch --- sound/firewire/isight.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) From e7e8eaf935563e2aa15980702c2737294f5b04b0 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Fri, 25 Mar 2011 08:04:20 +0100 ALSA: isight: fix divide error when queueing packets Set the .header_size field when queueing packets to avoid a division by zero. Signed-off-by: Clemens Ladisch --- sound/firewire/isight.c | 1 + 1 file changed, 1 insertion(+) From 2101f62975990add05d60ae70f93422722c3aaef Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Fri, 25 Mar 2011 07:59:49 +0100 ALSA: isight: fix packet requeueing After handling a received packet, we want to resubmit the same packet, so do not increase the packet index too early. Signed-off-by: Clemens Ladisch --- sound/firewire/isight.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) From afb74299dd59eace12ccd7f1e79fdf6c6c867076 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Tue, 22 Mar 2011 17:14:47 +0100 ALSA: isight: fix isight_pcm_abort() crashes Fix crashes in isight_pcm_abort() that happen when the driver tries to access isight->pcm->runtime which does not exist when the device is not open. Introduce a new field pcm_active to track this state. Signed-off-by: Clemens Ladisch Reported-by: Stefan Richter --- sound/firewire/isight.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) From 49120234746353325aedf5148f71997a264fda6f Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Mon, 21 Mar 2011 08:34:20 +0100 ALSA: dice: depends on snd_hwdep Signed-off-by: Stefan Richter Signed-off-by: Clemens Ladisch --- sound/firewire/Kconfig | 1 + 1 file changed, 1 insertion(+) From 5f2e1b69fadb9dbe23215e3cdee4643ceec41dbf Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Fri, 18 Mar 2011 11:12:50 +0100 ALSA: dice: optimize bus reset handling After a bus reset, do not stop the stream completely to avoid having to reconfigure the device when restarting the stream. Signed-off-by: Clemens Ladisch --- sound/firewire/dice.c | 148 ++++++++++++++++++++++++++---------------- 1 file changed, 93 insertions(+), 55 deletions(-) From c9d4b44721322a091f358466342fcee1b7ba0e4e Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 17 Mar 2011 08:39:29 +0100 ALSA: add DICE driver incomplete driver for DICE devices: * only playback (so no clock source except the bus clock) * only 44.1 kHz * no MIDI * recovery after bus reset is slow * hwdep device is created, but not actually implemented Signed-off-by: Clemens Ladisch --- Documentation/ioctl/ioctl-number.txt | 1 + include/sound/Kbuild | 1 + include/sound/asound.h | 3 + include/sound/firewire.h | 51 + sound/firewire/Kconfig | 13 + sound/firewire/Makefile | 2 + sound/firewire/dice.c | 1017 +++++++++++++++++++++++++++ 7 files changed, 1087 insertions(+), 1 deletion(-) create mode 100644 include/sound/firewire.h create mode 100644 sound/firewire/dice.c From 876f1d82e2f62bbfa99d75176f637f2669cc4320 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 17 Mar 2011 08:37:14 +0100 ALSA: add Apple iSight microphone driver WARNING: extremely untested! Signed-off-by: Clemens Ladisch --- sound/firewire/Kconfig | 12 + sound/firewire/Makefile | 2 + sound/firewire/isight.c | 743 ++++++++++++++++++++++++++++++++ sound/firewire/iso-resources.c | 5 + sound/firewire/packets-buffer.c | 2 + 5 files changed, 764 insertions(+) create mode 100644 sound/firewire/isight.c From 5de0ee574be8f6922a6c33f2fbc7e9b130a2f626 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Wed, 16 Mar 2011 17:39:28 +1100 ALSA: firewire - msleep needs delay.h fixes this error: sound/firewire/fcp.c: In function 'fcp_avc_transaction': sound/firewire/fcp.c:103: error: implicit declaration of function 'msleep' Signed-off-by: Stephen Rothwell Signed-off-by: Takashi Iwai --- sound/firewire/fcp.c | 1 + 1 file changed, 1 insertion(+) From ec00f5e444706cb1902731655f3dcd04fc3df7b0 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Tue, 15 Mar 2011 07:57:24 +0100 ALSA: firewire-lib, firewire-speakers: handle packet queueing errors Add an AMDTP stream error state that occurs when we fail to queue another packet. In this case, the stream is stopped, and the error can be reported when the application tries to restart the PCM stream. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/firewire/amdtp.c | 33 +++++++++++++++++++++------------ sound/firewire/amdtp.h | 14 +++++++++++++- sound/firewire/speakers.c | 3 +++ 3 files changed, 37 insertions(+), 13 deletions(-) From 5b2599a07eaee53d713fb68f5343eba88fa249c0 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Tue, 15 Mar 2011 07:55:50 +0100 ALSA: firewire-lib: allocate DMA buffer separately For correct cache coherency on some architectures, DMA buffers must be allocated in a different cache line than data that is concurrently used by the CPU. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/firewire/cmp.c | 5 ++++- sound/firewire/iso-resources.c | 10 +++++++++- sound/firewire/iso-resources.h | 6 +++--- 3 files changed, 16 insertions(+), 5 deletions(-) From be454366324b31922a2460c63c65d5e3cebe9641 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Tue, 15 Mar 2011 07:55:02 +0100 ALSA: firewire-lib: use no-info SYT for packets without SYT sample In non-blocking mode, the SYT_INTERVAL is larger than the number of audio frames in each packet, so there are packets that do not contain any frame to which the SYT could be applied. For these packets, the SYT must not be the timestamp of the next valid SYT frame, but the special no-info SYT value. This fixes broken playback on the FireWave at 44.1 kHz. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/firewire/amdtp.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) From 31ef9134eb52636d383a7d0626cbbd345cb94f2f Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Tue, 15 Mar 2011 07:53:21 +0100 ALSA: add LaCie FireWire Speakers/Griffin FireWave Surround driver Add a driver for two playback-only FireWire devices based on the OXFW970 chip. v2: better AMDTP API abstraction; fix fw_unit leak; small fixes v3: cache the iPCR value v4: FireWave constraints; fix fw_device reference counting; fix PCR caching; small changes and fixes v5: volume/mute support; fix crashing due to pcm stop races v6: fix build; one-channel volume for LaCie v7: use signed values to make volume (range checks) work; fix function block IDs for volume/mute; always use channel 0 for LaCie volume Signed-off-by: Clemens Ladisch Acked-by: Stefan Richter Tested-by: Jay Fenlason Signed-off-by: Takashi Iwai --- drivers/firewire/core-iso.c | 1 + drivers/firewire/core.h | 3 - include/linux/firewire.h | 7 + sound/Kconfig | 2 + sound/Makefile | 2 sound/firewire/Kconfig | 25 + sound/firewire/Makefile | 6 + sound/firewire/amdtp.c | 549 +++++++++++++++++++++ sound/firewire/amdtp.h | 157 ++++++ sound/firewire/cmp.c | 298 +++++++++++ sound/firewire/cmp.h | 41 ++ sound/firewire/fcp.c | 223 ++++++++ sound/firewire/fcp.h | 12 + sound/firewire/iso-resources.c | 224 ++++++++ sound/firewire/iso-resources.h | 39 + sound/firewire/lib.c | 85 +++ sound/firewire/lib.h | 19 + sound/firewire/packets-buffer.c | 74 +++ sound/firewire/packets-buffer.h | 26 + sound/firewire/speakers.c | 855 ++++++++++++++++++++++++++++++++ 20 files changed, 2644 insertions(+), 4 deletions(-) create mode 100644 sound/firewire/Kconfig create mode 100644 sound/firewire/Makefile create mode 100644 sound/firewire/amdtp.c create mode 100644 sound/firewire/amdtp.h create mode 100644 sound/firewire/cmp.c create mode 100644 sound/firewire/cmp.h create mode 100644 sound/firewire/fcp.c create mode 100644 sound/firewire/fcp.h create mode 100644 sound/firewire/iso-resources.c create mode 100644 sound/firewire/iso-resources.h create mode 100644 sound/firewire/lib.c create mode 100644 sound/firewire/lib.h create mode 100644 sound/firewire/packets-buffer.c create mode 100644 sound/firewire/packets-buffer.h create mode 100644 sound/firewire/speakers.c Date: Tue, 15 Mar 2011 00:08:41 +0100 From: Stefan Richter firewire: core: ignore link-active bit of new nodes, fix device recognition Like the older ieee1394 core driver, firewire-core skipped scanning of any new node whose PHY sent a self ID without "link active" bit. If a device had this bit off mistakenly, it meant that it was inaccessible to kernel drivers with the old IEEE 1394 driver stack but could still be accessed by userspace drivers through the raw1394 interface. But with firewire-core, userspace drivers don't get to see such buggy devices anymore. This is effectively a driver regression since this device bug is otherwise harmless. We now attempt to scan all devices, even repeaters that don't have a link or powered-down devices that have everything but their PHY shut down when plugged in. This results in futile repeated scanning attempts in case of such devices that really don't have an active link, but this doesn't hurt since recent workqueue infrastructure lets us run more concurrent scanning jobs than we can shake a stick at. This should fix accessibility of Focusrite Saffire PRO 26 I/O: http://sourceforge.net/mailarchive/forum.php?thread_name=20110314215622.5c751bb0%40stein&forum_name=ffado-user Signed-off-by: Stefan Richter --- drivers/firewire/core-device.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) Date: Tue, 15 Mar 2011 00:04:42 +0100 From: Stefan Richter firewire: sbp2: revert obsolete 'fix stall with "Unsolicited response"' Now that firewire-core sets the local node's SPLIT_TIMEOUT to 2 seconds per default, commit a481e97d3cdc40b9d58271675bd4f0abb79d4872 is no longer required. Signed-off-by: Stefan Richter --- drivers/firewire/sbp2.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) Date: Mon, 07 Mar 2011 11:21:15 +0100 From: Clemens Ladisch firewire: core: increase default SPLIT_TIMEOUT value The SPLIT_TIMEOUT mechanism is intended to detect requests that somehow got lost. However, when the timeout value is too low, transactions that could have been completed successfully will be cancelled. Furthermore, there are chips whose firmwares ignore the configured split timeout and send late split response; known examples are the DM1x00 (BeBoB), TCD22x0 (DICE), and some OXUF936QSE firmwares. This patch changes the default timeout to two seconds, which happens to be the default on other OSes, too. Actual lost requests are extremely rare, so there should be no practical downside to increasing the split timeout even on devices that work correctly. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/core-card.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) Date: Fri, 11 Mar 2011 04:17:27 +0300 From: Oleg Drokin firewire: ohci: Misleading kfree in ohci.c::pci_probe/remove It seems drivers/firewire/ohci.c is making some optimistic assumptions about struct fw_ohci and that member "card" will always remain the first member of the struct. Plus it's probably going to confuse a lot of static code analyzers too. So I wonder if there is a good reason not to free the ohci struct just like it was allocated instead of the tricky &ohci->card way? Signed-off-by: Oleg Drokin It is perhaps just a rudiment from before mainline submission of the driver. Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Date: Sat, 26 Feb 2011 15:08:35 +0100 From: Stefan Richter firewire: ohci: omit IntEvent.busReset check rom AT queueing Since commit 82b662dc4102 "flush AT contexts after bus reset for OHCI 1.2", the driver takes care of any AT packets that were enqueued during a bus reset phase. The check from commit 76f73ca1b291 is therefore no longer necessary and the MMIO read can be avoided. Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) Date: Sun, 6 Feb 2011 15:41:44 +0100 From: Stefan Richter firedtv: drop obsolete backend abstraction Since the drivers/ieee1394/ backend was removed from firedtv, its I/O no longer needs to be abstracted as exchangeable backend methods. Also, ieee1394 variants of module and device probe and removal are no longer there. Move module probe and removal into firedtv-fw.c where device probe and removal are implemented. Signed-off-by: Stefan Richter --- drivers/media/dvb/firewire/firedtv-avc.c | 15 +- drivers/media/dvb/firewire/firedtv-dvb.c | 130 -------------------- drivers/media/dvb/firewire/firedtv-fe.c | 8 drivers/media/dvb/firewire/firedtv-fw.c | 146 +++++++++++++++++++---- drivers/media/dvb/firewire/firedtv.h | 31 ++--- 5 files changed, 140 insertions(+), 190 deletions(-) Date: Sat, 5 Feb 2011 13:07:39 +0000 (+0100) From: Hans Verkuil firedtv: remove dependency on the deleted ieee1394 stack. X-Git-Url: http://git.linuxtv.org/hverkuil/media_tree.git?a=commitdiff_plain;h=f02c316436eef3baf349c489545edc7ade419ff6 The IEEE1394 stack was removed in 2.6.37, but not in this driver. Due to incorrect Kconfig dependencies this driver wasn't build since 2.6.37. This patch removes the IEEE1394 dependencies and fixes the Kconfig dependency, allowing it to be compiled once again. Signed-off-by: Hans Verkuil CC: Stefan Richter --- --- drivers/media/dvb/Kconfig | 2 drivers/media/dvb/firewire/Kconfig | 8 - drivers/media/dvb/firewire/Makefile | 5 - drivers/media/dvb/firewire/firedtv-1394.c | 300 ---------------------- drivers/media/dvb/firewire/firedtv-dvb.c | 5 - drivers/media/dvb/firewire/firedtv.h | 14 - 6 files changed, 3 insertions(+), 331 deletions(-) Date: Wed, 23 Feb 2011 09:27:40 +0100 From: Clemens Ladisch firewire: ohci: prevent starting of iso contexts with empty queue If a misguided program tried to start an isochronous context before it has queued any packets, the call would appear to succeed, but the context would not actually go into the running state, and the OHCI controller would then raise an unrecoverableError interrupt because the first Z value is zero and thus invalid. The driver logs such errors, but there is no mechanism to report this back to the program. Add an explicit check so that this error can be returned synchronously. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 4 ++++ 1 file changed, 4 insertions(+) Date: Wed, 16 Feb 2011 10:32:11 +0100 From: Clemens Ladisch firewire: ohci: prevent iso completion callbacks after context stop To prevent the iso packet callback from being called after fw_iso_context_stop() has returned, make sure that the context's tasklet has finished executing before that. This fixes access-after-free bugs that have so far been observed only in the upcoming snd-firewire-speakers driver, but can theoretically also happen in the firedtv driver. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 1 + 1 file changed, 1 insertion(+) Date: Mon, 31 Jan 2011 11:58:58 +0100 From: Clemens Ladisch firewire: core: rename some variables In manage_channel(), rename the variables "c" and "i" to the more expressive "bit" and "channel". Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/core-iso.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) Date: Sun, 23 Jan 2011 12:26:51 +0100 From: Stefan Richter firewire: nosy: should work on Power Mac G4 PCI too The first board generation of Power Mac G4 ("Yikes!", those with PCI graphics) still had a PCILynx controller like their G3 predecessors, but not the later AGP models. (Jonathan Woithe recalls to have heard of it, and some web sources reinforce it.) Signed-off-by: Stefan Richter --- drivers/firewire/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) Date: Sat, 22 Jan 2011 15:05:03 +0100 From: Clemens Ladisch firewire: core: fix card->reset_jiffies overflow On a 32-bit machine with, e.g., HZ=1000, jiffies will overflow after about 50 days, so if there are between 25 and 50 days between bus resets, the card->reset_jiffies comparisons can get wrong results. To fix this, ensure that this timestamp always uses 64 bits. Signed-off-by: Clemens Ladisch Signed-off-by: "Stefan Richter" --- drivers/firewire/core-card.c | 5 +++-- drivers/firewire/core-cdev.c | 3 ++- drivers/firewire/core-device.c | 3 ++- drivers/firewire/core-topology.c | 2 +- include/linux/firewire.h | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) Date: Mon, 10 Jan 2011 17:29:03 +0100 From: Clemens Ladisch firewire: cdev: remove unneeded reference For outbound transactions, the IDR's and the callback's references now have exactly the same lifetime, so we do not need both of them. Signed-off-by: Clemens Ladisch Signed-off-by: "Stefan Richter" --- drivers/firewire/core-cdev.c | 5 ----- 1 file changed, 5 deletions(-) Date: Mon, 10 Jan 2011 17:28:39 +0100 From: Clemens Ladisch firewire: cdev: always wait for outbound transactions to complete We must not use fw_cancel_transaction() because it cannot correctly abort still-active transactions. The only place in core-cdev where this matters is when the file is released. Instead of trying to abort the transactions, we wait for them to complete normally, i.e., until all outbound transaction resources have been removed from the IDR tree. Signed-off-by: Clemens Ladisch Signed-off-by: "Stefan Richter" --- drivers/firewire/core-cdev.c | 42 +++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 14 deletions(-) Date: Mon, 10 Jan 2011 17:28:27 +0100 From: Clemens Ladisch firewire: cdev: remove unneeded idr_find() from complete_transaction() Outbound transactions are never aborted with release_client_resource(), so it is not necessary for complete_transaction() to check whether the resource is still registered. Only shutdown_resource() can abort such an transaction, and this is already handled with the in_shutdown check. Signed-off-by: Clemens Ladisch Signed-off-by: "Stefan Richter" --- drivers/firewire/core-cdev.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) Date: Mon, 10 Jan 2011 17:21:35 +0100 From: Clemens Ladisch firewire: ohci: log dead DMA contexts When a DMA context goes into the dead state (and the controller thus stops working correctly), logging this error and the controller's error code might be helpful for debugging. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 59 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 4 deletions(-) Date: Thu, 20 Jan 2011 00:07:46 +0100 From: Stefan Richter firewire: net: is not experimental anymore thanks to Clemens' and Maxim's fixes to firewire-ohci and -net in the last two kernel releases. Signed-off-by: Stefan Richter --- drivers/firewire/Kconfig | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) Date: Sun, 16 Jan 2011 05:39:21 -0300 From: Stefan Richter [media] firedtv: fix remote control with newer Xorg evdev After a recent update of xf86-input-evdev and xorg-server, I noticed that X11 applications did not receive keypresses from the FireDTV infrared remote control anymore. Instead, the Xorg log featured lots of "FireDTV remote control: dropping event due to full queue!" exclamations. The Linux console did not have an issue with the FireDTV's RC though. The fix is to insert EV_SYN events after the key-down/-up events. Signed-off-by: Stefan Richter Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/firewire/firedtv-rc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) Date: Sat, 15 Jan 2011 18:19:48 +0100 From: Stefan Richter firewire: core: fix unstable I/O with Canon camcorder Regression since commit 10389536742c, "firewire: core: check for 1394a compliant IRM, fix inaccessibility of Sony camcorder": The camcorder Canon MV5i generates lots of bus resets when asynchronous requests are sent to it (e.g. Config ROM read requests or FCP Command write requests) if the camcorder is not root node. This causes drop- outs in videos or makes the camcorder entirely inaccessible. https://bugzilla.redhat.com/show_bug.cgi?id=633260 Fix this by allowing any Canon device, even if it is a pre-1394a IRM like MV5i are, to remain root node (if it is at least Cycle Master capable). With the FireWire controller cards that I tested, MV5i always becomes root node when plugged in and left to its own devices. Reported-by: Ralf Lange Signed-off-by: Stefan Richter Cc: # 2.6.32.y and newer --- drivers/firewire/core-card.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) Date: Thu, 13 Jan 2011 10:12:17 +0100 From: Clemens Ladisch firewire: ohci: fix compilation on arches without PAGE_KERNEL_RO PAGE_KERNEL_RO is not available on all architectures, so its use in the new AR code broke compilation on sparc64. Because the read-only mapping was just a debugging aid, just use PAGE_KERNEL instead. Signed-off-by: Clemens Ladisch James Bottomley wrote: > On Thu, 2011-01-13 at 08:27 +0100, Clemens Ladisch wrote: >> firewire: ohci: fix compilation on arches without PAGE_KERNEL_RO, e.g. sparc >> >> PAGE_KERNEL_RO is not available on all architectures, so its use in the >> new AR code broke compilation on sparc64. >> >> Because the R/O mapping is only used to catch drivers that try to write >> to the reception buffer and not actually required for correct operation, >> we can just use a normal PAGE_KERNEL mapping where _RO is not available. [...] >> +/* >> + * For archs where PAGE_KERNEL_RO is not supported; >> + * mapping the AR buffers readonly for the CPU is just a debugging aid. >> + */ >> +#ifndef PAGE_KERNEL_RO >> +#define PAGE_KERNEL_RO PAGE_KERNEL >> +#endif > > This might cause interesting issues on sparc64 if it ever acquired a > PAGE_KERNEL_RO. Sparc64 has extern pgprot_t for it's PAGE_KERNEL types > rather than #defines, so the #ifdef check wouldn't see this. > > I think either PAGE_PROT_RO becomes part of our arch API (so all > architectures are forced to add it), or, if it's not part of the API, > ohci isn't entitled to use it. The latter seems simplest since you have > no real use for write protection anyway. Reported-by: Andrew Morton Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Date: Mon, 13 Dec 2010 14:56:02 +0100 From: Clemens Ladisch firewire: use split transaction timeout only for split transactions Instead of starting the split transaction timeout timer when any request is submitted, start it only when the destination's ACK_PENDING has been received. This prevents us from using a timeout that is too short, and, if the controller's AT queue is emptying very slowly, from cancelling a packet that has not yet been sent. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/core-transaction.c | 45 ++++++++++++++++++++-------- include/linux/firewire.h | 2 2 files changed, 33 insertions(+), 14 deletions(-) Date: Sat, 1 Jan 2011 15:17:05 +0100 From: Stefan Richter firewire: ohci: consolidate context status flags "firewire: ohci: restart iso DMA contexts on resume from low power mode" added the flag struct context.active and "firewire: ohci: cache the context run bit" added struct context.running. These flags contain the same information; combine them. Also, normalize whitespace in pci_resume(). Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) Date: Fri, 24 Dec 2010 14:42:46 +0100 From: Clemens Ladisch firewire: ohci: cache the context run bit The DMA context run control bit is entirely controlled by software, so it is safe to cache it. This allows the driver to avoid doing an additional MMIO read when queueing an AT packet. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) Date: Sat, 1 Jan 2011 15:15:40 +0100 From: Stefan Richter firewire: ohci: flush AT contexts after bus reset - addendum Add comments - on why bus_reset_tasklet flushes AT queues, - that commit 76f73ca1b291 can possibly be reverted now. Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 7 +++++++ 1 file changed, 7 insertions(+) Date: Fri, 24 Dec 2010 14:40:15 +0100 From: Clemens Ladisch firewire: ohci: flush AT contexts after bus reset for OHCI 1.2 The OHCI 1.2 (draft) specification, clause 7.2.3.3, allows and recommends that, after a bus reset, the controller does not flush all the packets in the AT queues. Therefore, the driver has to do this itself. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 46 ++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 7 deletions(-) Date: Fri, 17 Dec 2010 22:22:33 +0100 From: Stefan Richter firewire: net: set carrier state at ifup At ifup, carrier status would be shown on even if it actually was off. [[On 2.6.37, also add an include for ethtool_ops rather than to rely on the one from netdevice.h.]] Note, we can alas not use fwnet_device_mutex to serialize access to dev->peer_count (as I originally wanted). This would cause a lock inversion: - fwnet_probe | takes fwnet_device_mutex + register_netdev | takes rtnl_mutex - devinet_ioctl | takes rtnl_mutex + fwnet_open | ...must not take fwnet_device_mutex Hence use the dev->lock spinlock for serialization. Signed-off-by: Stefan Richter --- drivers/firewire/net.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) Date: Wed, 8 Dec 2010 04:22:57 +0200 From: Maxim Levitsky firewire: net: add carrier detection To make userland, e.g. NetworkManager work with firewire, we need to detect whether cable is plugged or not. Simple and correct way of doing that is just counting number of peers. No peers - no link and vice versa. Signed-off-by: Stefan Richter --- drivers/firewire/net.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) Date: Mon, 29 Nov 2010 04:09:53 +0200 From: Maxim Levitsky firewire: net: ratelimit error messages Unfortunately its easy to trigger such error messages by removing the cable while sending streams of data over the link. Such errors are normal, and therefore this patch stops firewire-net from flooding the kernel log with these errors, by combining series of same errors together. Signed-off-by: Maxim Levitsky (Stefan R:) Eventually we should remove this logging when firewire-net and related firewire-ohci facilities have been stabilized. Signed-off-by: Stefan Richter --- drivers/firewire/net.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) Date: Mon, 29 Nov 2010 04:09:50 +0200 From: Maxim Levitsky firewire: ohci: restart iso DMA contexts on resume from low power mode Restore iso channels DMA so that iso channels could continue to work after resume from RAM/disk. Signed-off-by: Maxim Levitsky Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 54 ++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 8 deletions(-) Date: Mon, 29 Nov 2010 04:09:49 +0200 From: Maxim Levitsky firewire: ohci: restore GUID on resume. Some lousy BIOSes, e.g. my Aspire 5720 BIOS forget to restore the GUID register on resume from RAM. Fix that by setting it to the last value that was read from it. Signed-off-by: Maxim Levitsky Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 7 +++++++ 1 file changed, 7 insertions(+) Date: Tue, 30 Nov 2010 08:25:17 +0100 From: Clemens Ladisch firewire: ohci: use common buffer for self IDs and AR descriptors The buffers used for the selfIDs packets and the AR request and response descriptors end up using three pages because dma_alloc_coherent() allocates at least one page per call. However, these data structures would all fit into 4 KB, so we can save space by using a common buffer for them. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 66 +++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 32 deletions(-) Date: Tue, 30 Nov 2010 08:25:05 +0100 From: Clemens Ladisch firewire: ohci: optimize iso context checks in the interrupt handler When the isochRx/isochTx bit is clear, we do not need to read the corresponding iso interrupt event register. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) Date: Tue, 30 Nov 2010 08:24:47 +0100 From: Clemens Ladisch firewire: make PHY packet header format consistent Change the header of PHY packets to be sent to include a pseudo transaction code. This makes the header consistent with that of received PHY packets, and allows at_context_queue_packet() and log_ar_at_event() to see the packet type directly instead of having to deduce it from the header length or even from the header contents. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 7 ++-- drivers/firewire/core-transaction.c | 7 ++-- drivers/firewire/core.h | 4 ++- drivers/firewire/ohci.c | 44 ++++++++++++++-------------- 4 files changed, 33 insertions(+), 29 deletions(-) Date: Tue, 30 Nov 2010 08:24:32 +0100 From: Clemens Ladisch firewire: ohci: properly clear posted write errors To remove the error information from the controller's queue and to allow more posted writes, the driver has to read the failed posted write address before clearing the postedWriteErr interrupt bit. Signed-off-by: Clemens Ladisch (Stefan R:) The spec is somewhat fuzzy about the actual requirements. To err on the safe side, let's do these two read accesses. Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) Date: Tue, 30 Nov 2010 08:24:19 +0100 From: Clemens Ladisch firewire: ohci: flush MMIO writes in the interrupt handler Make sure that interrupt event clear bit writes are executed before the interrupt handler returns. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) Date: Tue, 30 Nov 2010 08:24:01 +0100 From: Clemens Ladisch firewire: ohci: fix AT context initialization error handling Add proper error handling for the context_init() calls. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) From 88393161210493e317ae391696ee8ef463cb3c23 Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Tue, 16 Mar 2010 11:47:56 +0100 [PATCH] Fix typos in comments [Ss]ytem => [Ss]ystem udpate => update paramters => parameters orginal => original Signed-off-by: Thomas Weber Acked-by: Randy Dunlap Signed-off-by: Jiri Kosina [[ Stefan R: only firewire-part included here ]] --- drivers/firewire/ohci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Date: Fri, 26 Nov 2010 08:57:31 +0100 From: Clemens Ladisch firewire: ohci: Asynchronous Reception rewrite Move the AR DMA descriptors out of the buffer pages, and map the buffer pages linearly into the kernel's address space. This allows the driver to ignore any page boundaries in the DMA data and thus to avoid any copying around of packet payloads. This fixes the bug where S800 packets that are so big (> 4080 bytes) that they can be split over three pages were not handled correctly. Due to the changed algorithm, we can now use arbitrarily many buffer pages, which improves performance because the controller can more easily unload its DMA FIFO. Furthermore, using streaming DMA mappings should improve perfomance on architectures where coherent DMA mappings are not cacheable. Even on other architectures, the caching behaviour should be improved slightly because the CPU no longer writes to the buffer pages. v2: Detect the last filled buffer page by searching the descriptor's residual count value fields in order (like in the old code), instead of going backwards through the transfer status fields; it looks as if some controllers do not set the latter correctly. v3: Fix an old resume bug that would now make the handler run into a BUG_ON, and replace that check with more useful error handling. Increase the buffer size for better performance with non-TI chips. Signed-off-by: Clemens Ladisch Maxim Levitsky writes: Works almost perfectly. I can still see RCODE_BUSY errors sometimes, not very often though. 64K here eliminates these errors completely. This is most likely due to nouveau drivers and lowest perf level I use to lower card temperature. That increases latencies too much I think. Besides that the IO is just perfect. Tested-by: Maxim Levitsky Signed-off-by: Stefan Richter --- drivers/firewire/Kconfig | 2 drivers/firewire/Kconfig | 2 drivers/firewire/ohci.c | 415 ++++++++++++++++++++++++++------------- 2 files changed, 280 insertions(+), 137 deletions(-) Date: Tue, 7 Dec 2010 20:32:40 +0100 From: Stefan Richter firewire: ohci: fix regression with Agere FW643 rev 06, disable MSI Agere FW643 rev 06, listed as "11c1:5901 (rev 06) (prog-if 10 [OHCI])", produced SBP-2 I/O errors since kernel 2.6.36. Disabling MSI fixes it. Since MSI work on Agere FW643-E (same vendor and device ID, but rev 07), introduce a device revision field into firewire-ohci's quirks list so that different quirks can be defined for older and newer revisions. Reported-by: Jonathan Isom Signed-off-by: Stefan Richter Cc: # 2.6.36.y --- drivers/firewire/ohci.c | 48 +++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 15 deletions(-) Date: Tue, 7 Dec 2010 19:16:02 +0100 From: Stefan Richter firewire: ohci: fix regression with VIA VT6315, disable MSI "VIA Technologies, Inc. VT6315 Series Firewire Controller [1106:3403]" does not generate any interrupts if Message Signaled Interrupts were enabled. This is a regression since kernel 2.6.36 in which MSI support was added to firewire-ohci. Hence blacklist MSI on all VIA controllers. Reported-by: Robin Cook Signed-off-by: Stefan Richter Cc: # 2.6.36.y --- drivers/firewire/ohci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) Date: Sun, 14 Nov 2010 14:35:40 +0100 (CET) From: Stefan Richter firewire: net: throttle TX queue before running out of tlabels This prevents firewire-net from submitting write requests in fast succession until failure due to all 64 transaction labels were used up for unfinished split transactions. The netif_stop/wake_queue API is used for this purpose. Without this stop/wake mechanism, datagrams were simply lost whenever the tlabel pool was exhausted. Plus, tlabel exhaustion by firewire-net also prevented other unrelated outbound transactions to be initiated. The chosen queue depth was checked by me to hit the maximum possible throughput with an OS X peer whose receive DMA is good enough to never reject requests due to busy inbound request FIFO. Current Linux peers show a mixed picture of -5%...+15% change in bandwidth; their current bottleneck are RCODE_BUSY situations (fewer or more, depending on TX queue depth) due to too small AR buffer in firewire-ohci. Maxim Levitsky tested this change with similar watermarks with a Linux peer and some pending firewire-ohci improvements that address the RCODE_BUSY problem and confirmed that these TX queue limits are good. Note: This removes some netif_wake_queue from reception code paths. They were apparently copy&paste artefacts from a nonsensical netif_wake_queue use in the older eth1394 driver. This belongs only into the transmit path. Signed-off-by: Stefan Richter Tested-by: Maxim Levitsky --- drivers/firewire/net.c | 59 ++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 24 deletions(-) Date: Sat, 6 Nov 2010 23:18:23 +0100 (CET) From: Stefan Richter firewire: net: replace lists by counters The current transmit code does not at all make use of - fwnet_device.packet_list and only very limited use of - fwnet_device.broadcasted_list, - fwnet_device.queued_packets. Their current function is to track whether the TX soft-IRQ finished dealing with an skb when the AT-req tasklet takes over, and to discard pending tx datagrams (if there are any) when the local node is removed. The latter does actually contain a race condition bug with TX soft-IRQ and AT-req tasklet. Instead of these lists and the corresponding link in fwnet_packet_task, - a flag in fwnet_packet_task to track whether fwnet_tx is done, - a counter of queued datagrams in fwnet_device do the job as well. The above mentioned theoretic race condition is resolved by letting fwnet_remove sleep until all datagrams were flushed. It may sleep almost arbitrarily long since fwnet_remove is executed in the context of a multithreaded (concurrency managed) workqueue. The type of max_payload is changed to u16 here to avoid waste in struct fwnet_packet_task. This value cannot exceed 4096 per IEEE 1394:2008 table 16-18 (or 32678 per specification of packet headers, if there is ever going to be something else than beta mode). Signed-off-by: Stefan Richter --- drivers/firewire/net.c | 73 +++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 47 deletions(-) Date: Sat, 6 Nov 2010 16:57:28 +0100 (CET) From: Stefan Richter firewire: net: fix memory leaks a) fwnet_transmit_packet_done used to poison ptask->pt_link by list_del. If fwnet_send_packet checked later whether it was responsible to clean up (in the border case that the TX soft IRQ was outpaced by the AT-req tasklet on another CPU), it missed this because ptask->pt_link was no longer shown as empty. b) If fwnet_write_complete got an rcode other than RCODE_COMPLETE, we missed to free the skb and ptask entirely. Also, count stats.tx_dropped and stats.tx_errors when rcode != 0. Signed-off-by: Stefan Richter --- drivers/firewire/net.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) Date: Sat, 6 Nov 2010 12:36:13 +0100 (CET) From: Stefan Richter firewire: net: count stats.tx_packets and stats.tx_bytes Signed-off-by: Stefan Richter --- drivers/firewire/net.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) Date: Sat, 30 Oct 2010 14:08:27 -0700 From: Joe Perches firewire: core: Update WARN uses Add missing newlines. Signed-off-by: Joe Perches Signed-off-by: Stefan Richter --- drivers/firewire/core-transaction.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) Date: Mon, 25 Oct 2010 11:43:05 +0200 From: Clemens Ladisch firewire: ohci: fix race when reading count in AR descriptor If the controller is storing a split packet and therefore changing d->res_count to zero between the two reads by the driver, we end up with an end pointer that is not at a packet boundary, and therefore overflow the buffer when handling the split packet. To fix this, read the field once, atomically. The compiler usually merges the two reads anyway, but for correctness, we have to enforce it. Signed-off-by: Clemens Ladisch Tested-by: Maxim Levitsky Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) Date: Mon, 25 Oct 2010 11:42:42 +0200 From: Clemens Ladisch firewire: ohci: avoid reallocation of AR buffers Freeing an AR buffer page just to allocate a new page immediately afterwards is not only a pointless effort but also dangerous because the allocation can fail, which would result in an oops later. Split ar_context_add_page() into two functions so that we can reuse the old page directly. Signed-off-by: Clemens Ladisch Tested-by: Maxim Levitsky Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) Date: Mon, 1 Mar 2010 11:56:42 +0000 (-0300) From: Henrik Kurelid firedtv: add parameter to fake ca_system_ids in CA_INFO The Digital Everywhere firmware have the shortcoming that ca_info_enq and ca_info are not supported. This means that we can never retrieve the correct ca_system_id to present in the CI message CA_INFO. Currently the driver uses the application id retrieved using app_info_req and app_info, but this id only match the correct ca_system_id as given in ca_info in some cases. This patch adds a parameter to the driver in order for the user to override what will be returned in the CA_INFO CI message. Up to four ca_system_ids can be specified. This is needed for users with CAMs that have different manufacturer id and ca_system_id and that uses applications that take this into account, like MythTV. Signed-off-by: Henrik Kurelid Signed-off-by: Stefan Richter Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/firewire/firedtv-avc.c | 31 ++++++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) Date: Sun, 17 Oct 2010 13:50:26 +0200 (CEST) From: Stefan Richter firewire: ohci: fix TI TSB82AA2 regression since 2.6.35 Revert commit 54672386ccf36ffa21d1de8e75624af83f9b0eeb "firewire: ohci: fix up configuration of TI chips". It caused massive slow-down and data corruption with a TSB82AA2 based StarTech EC1394B2 ExpressCard and FireWire 800 harddisks. https://bugs.launchpad.net/ubuntu/+source/linux/+bug/657081 http://thread.gmane.org/gmane.linux.kernel.firewire.user/4013 The fact that some card EEPROMs do not program these enhancements may be related to TSB81BA3 phy chip errata, if not to bugs of TSB82AA2 itself. We could re-add these configuration steps, but only conditional on a whitelist of cards on which these enhancements bring a proven positive effect. Reported-and-tested-by: Eric Shattow Cc: Clemens Ladisch Cc: 2.6.35 Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 19 +------------------ drivers/firewire/ohci.h | 8 -------- 2 files changed, 1 insertion(+), 26 deletions(-) Date: Wed, 13 Oct 2010 14:25:44 +0200 (CEST) From: Stefan Richter firewire: nosy: char device is not seekable Amend .open handler accordingly and add proper .llseek handler. (The only client that uses this interface is nosy-dump in linux/tools/firewire and it knows not to seek in this char dev.) Signed-off-by: Stefan Richter --- drivers/firewire/nosy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) Date: Sun, 10 Oct 2010 00:54:02 +0200 From: Stefan Richter ieee1394: move init_ohci1394_dma to drivers/firewire/ because drivers/ieee1394/ will be deleted. Additional changes: - add some #include directives - adjust to use firewire/ohci.h instead of ieee1394/ohci1394.h, replace struct ti_ohci by a minimal struct ohci, replace quadlet_t from ieee1394_types.h by u32 - two or three trivial stylistic changes - __iomem annotation Signed-off-by: Stefan Richter --- drivers/firewire/Makefile | 1 + drivers/firewire/init_ohci1394_dma.c | 309 +++++++++++++++++++++++++++ drivers/ieee1394/Makefile | 2 - drivers/ieee1394/init_ohci1394_dma.c | 285 ------------------------- 4 files changed, 310 insertions(+), 287 deletions(-) Date: Sun, 12 Sep 2010 21:03:45 +0200 From: Tommy Jonsson V4L/DVB: firedtv: support for PSK8 for S2 devices. To watch HD. This is the first i have ever developed for linux, cant really wrap my head around how to submit this.. Hope im sending this correctly, diff made with 'hg diff' from latest "hg clone http://linuxtv.org/hg/v4l-dvb" It adds support for tuning with PSK8 modulation, pilot and rolloff with the S2 versions of firedtv. Signed-off-by: Tommy Jonsson Signed-off-by: Stefan Richter (trivial simplification) --- drivers/media/dvb/firewire/firedtv-avc.c | 30 +++++++++++++++++-- drivers/media/dvb/firewire/firedtv-fe.c | 36 ++++++++++++++++++++++- 2 files changed, 60 insertions(+), 6 deletions(-) Date: Wed, 15 Sep 2010 13:02:44 +0200 (CEST) From: Stefan Richter firewire: nosy: fix build when CONFIG_FIREWIRE=N drivers/firewire/nosy* is a stand-alone driver that does not depend on CONFIG_FIREWIRE. Hence let make descend into drivers/firewire/ also if that option is off. The stand-alone driver drivers/ieee1394/init_ohci1394_dma* will soon be moved into drivers/firewire/ too and will require the same makefile fix. Side effect: As mentioned in https://bugzilla.novell.com/show_bug.cgi?id=586172#c24 this influences the order in which either firewire-ohci or ohci1394 is going to be bound to an OHCI-1394 controller in case of a modular build of both drivers if no modprobe blacklist entries are configured. However, a user of such a setup cannot expect deterministic behavior anyway. The Kconfig help and the migration guide at ieee1394.wiki.kernel.org recommend blacklist entries when a dual IEEE 1394 stack build is being used. (The coexistence period of the two stacks is planned to end soon.) Cc: Michal Marek Signed-off-by: Stefan Richter --- drivers/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Date: Mon, 6 Sep 2010 22:30:45 +0300 From: Heikki Lindholm firewire: ohci: activate cycle timer register quirk on Ricoh chips The Ricoh FireWire controllers appear to have the non-atomic cycle timer register access bug, so, activate the driver workaround by default. The behaviour was observed on: Ricoh Co Ltd R5C552 IEEE 1394 Controller [1180:0552] and Ricoh Co Ltd R5C832 IEEE 1394 Controller [1180:0832] (rev 04). Signed-off-by: Heikki Lindholm Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 1 + 1 file changed, 1 insertion(+) Date: Sat, 28 Aug 2010 14:21:26 +0200 (CEST) From: Stefan Richter firewire: ohci: work around VIA and NEC PHY packet reception bug VIA VT6306, VIA VT6308, and NEC OrangeLink controllers do not write packet event codes for received PHY packets (or perhaps write evt_no_status, hard to tell). Work around it by overwriting the packet's ACK by ack_complete, so that upper layers that listen to PHY packet reception get to see these packets. (Also tested: TI TSB82AA2, TI TSB43AB22/A, TI XIO2213A, Agere FW643, JMicron JMB381 --- these do not exhibit this bug.) Clemens proposed a quirks flag for that, IOW whitelist known misbehaving controllers for this workaround. Though to me it seems harmless enough to enable for all controllers. The log_ar_at_event() debug log will continue to show the original status from the DMA unit. Reported-by: Clemens Ladisch (VT6308) Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) Date: Wed, 18 Aug 2010 15:05:02 +0200 From: Clemens Ladisch firewire: core: do not use del_timer_sync() in interrupt context Because we might be in interrupt context, replace del_timer_sync() with del_timer(). If the timer is already running, we know that it will clean up the transaction, so we do not need to do any further processing in the normal transaction handler. Many thanks to Yong Zhang for diagnosing this. Reported-by: Stefan Richter Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/core-transaction.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) Date: Mon, 16 Aug 2010 23:45:54 +0200 (CEST) From: Stefan Richter firewire: net: fix unicast reception RCODE in failure paths The incoming request hander fwnet_receive_packet() expects subsequent datagram handling code to return non-zero on errors. However, almost none of the failure paths did so. Fix them all. (This error reporting is used to send and RCODE_CONFLICT_ERROR to the sender node in such failure cases. Two modes of failure exist: Out of memory, or firewire-net is unaware of any peer node to which a fragment or an ARP packet belongs. However, it is unclear whether a sender can actually make use of such information. A Linux peer apparently can't. Maybe it should all be simplified to void functions.) Reported-by: Julia Lawall Signed-off-by: Stefan Richter --- drivers/firewire/net.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) Date: Mon, 16 Aug 2010 22:13:34 +0200 (CEST) From: Stefan Richter firewire: sbp2: fix stall with "Unsolicited response" Fix I/O stalls with some 4-bay RAID enclosures which are based on OXUF936QSE: - Onnto dataTale RSM4QO, old firmware (not anymore with current firmware), - inXtron Hydra Super-S LCM, old as well as current firmware when used in RAID-5 mode, perhaps also in other RAID modes. The stalls happen during heavy or moderate disk traffic in periods that are a multiple of 5 minutes, roughly twice per hour. They are caused by the target responding too late to an ORB_Pointer register write: The target responds after Split_Timeout, hence firewire-core cancels the transaction, and firewire-sbp2 fails the SCSI request. The SCSI core retries the request, that fails again (and again), hence SCSI core calls firewire-sbp2's abort handler (and even the Management_Agent register write in the abort handler has the transaction timeout problem). During all that, the process which issued the I/O is stalled in I/O wait state. Meanwhile, the target actually acts on the first failed SCSI request: It responds to the ORB_Pointer write later (seen in the kernel log as "firewire_core: Unsolicited response") and also finishes the SCSI request with proper status (seen in the kernel log as "firewire_sbp2: status write for unknown orb"). So let's just ignore RCODE_CANCELLED in the transaction callback and wait for the target to complete the ORB nevertheless. This requires a small modification is sbp2_cancel_orbs(); it now needs to call orb->callback() regardless whether fw_cancel_transaction() found the transaction unfinished or finished. A different solution is to increase Split_Timeout on the local node. (Tested: 2000ms timeout; maybe 1000ms or something like that works too. 200ms is insufficient. Standard is 100ms.) However, I rather not do this because any software on any node could change the Split_Timeout to something unsuitable. Or such a large Split_Timeout may be undesirable for other purposes. Signed-off-by: Stefan Richter --- drivers/firewire/sbp2.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) Date: Mon, 16 Aug 2010 21:58:03 +0200 (CEST) From: Stefan Richter firewire: sbp2: fix memory leak in sbp2_cancel_orbs or at send error When an ORB was canceled (Command ORB i.e. SCSI request timed out, or Management ORB timed out), or there was a send error in the initial transaction, we missed to drop one of the ORB's references and thus leaked memory. Background: In total, we hold 3 references to each Operation Request Block: - 1 during sbp2_scsi_queuecommand() or sbp2_send_management_orb() respectively, - 1 for the duration of the write transaction to the ORB_Pointer or Management_Agent register of the target, - 1 for as long as the ORB stays within the lu->orb_list, until the ORB is unlinked from the list and the orb->callback was executed. The latter one of these 3 references is finished - normally by sbp2_status_write() when the target wrote status for a pending ORB, - or by sbp2_cancel_orbs() in case of an ORB time-out, - or by complete_transaction() in case of a send error. Of them, the latter two lacked the kref_put. Add the missing kref_put()s. Add comments to the gets and puts of references for transaction callbacks and ORB callbacks so that it is easier to see what is supposed to happen. Signed-off-by: Stefan Richter --- drivers/firewire/sbp2.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) Date: Thu, 5 Aug 2010 22:20:09 +0200 (CEST) From: Julia Lawall ieee1394: Adjust confusing if indentation Indent the branch of an if. Signed-off-by: Julia Lawall Signed-off-by: Stefan Richter --- drivers/ieee1394/ohci1394.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Date: Mon, 2 Aug 2010 10:09:04 +0200 (CEST) From: Stefan Richter Merge firewire branches to be released post v2.6.35 Add forgotten #include in drivers/firewire/ohci.c. Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 1 + 1 file changed, 1 insertion(+) Date: Sun, 1 Aug 2010 12:23:14 +0200 (CEST) From: Stefan Richter firewire: core: add forgotten dummy driver methods, remove unused ones There is an at least theoretic race condition in which .start_iso etc. could still be called between when the dummy driver is bound to the card and when the children devices are being shut down. Add dummy_start_iso and friends. On the other hand, .enable, .set_config_rom, .read_csr, write_csr do not need to be implemented by the dummy driver, as commented. Signed-off-by: Stefan Richter --- drivers/firewire/core-card.c | 64 +++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 26 deletions(-) Date: Thu, 29 Jul 2010 18:19:22 +0200 From: Stefan Richter firewire: add isochronous multichannel reception This adds the DMA context programming and userspace ABI for multichannel reception, i.e. for listening on multiple channel numbers by means of a single DMA context. The use case is reception of more streams than there are IR DMA units offered by the link layer. This is already implemented by the older ohci1394 + ieee1394 + raw1394 stack. And as discussed recently on linux1394-devel, this feature is occasionally used in practice. The big drawbacks of this mode are that buffer layout and interrupt generation necessarily differ from single-channel reception: Headers and trailers are not stripped from packets, packets are not aligned with buffer chunks, interrupts are per buffer chunk, not per packet. These drawbacks also cause a rather hefty code footprint to support this rarely used OHCI-1394 feature. (367 lines added, among them 94 lines of added userspace ABI documentation.) This implementation enforces that a multichannel reception context may only listen to channels to which no single-channel context on the same link layer is presently listening to. OHCI-1394 would allow to overlay single-channel contexts by the multi-channel context, but this would be a departure from the present first-come-first-served policy of IR context creation. The implementation is heavily based on an earlier one by Jay Fenlason. Thanks Jay. Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 93 ++++++++-- drivers/firewire/core-iso.c | 32 ++- drivers/firewire/core.h | 2 + drivers/firewire/ohci.c | 316 +++++++++++++++++++++++++++------- include/linux/firewire-cdev.h | 281 +++++++++++++++++++++--------- include/linux/firewire.h | 29 ++- 6 files changed, 560 insertions(+), 193 deletions(-) Date: Thu, 29 Jul 2010 09:31:56 +0200 (CEST) From: Stefan Richter firewire: core: small clarifications in core-cdev Make a note on the seemingly unused linux/sched.h. Rename an irritatingly named variable. Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) Date: Wed, 28 Jul 2010 23:49:45 +0200 (CEST) From: Stefan Richter firewire: core: remove unused code ioctl_create_iso_context enforces ctx->header_size >= 4. Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) Date: Wed, 28 Jul 2010 15:50:00 +0200 (CEST) From: Stefan Richter firewire: ohci: release channel in error path firewire-ohci keeps book of which isochronous channels are occupied by IR DMA contexts, so that there cannot be more than one context listening to a certain channel. If IR context creation failed due to an out-of-memory condition, this bookkeeping leaked a channel. Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 1 + 1 file changed, 1 insertion(+) Date: Tue, 27 Jul 2010 13:20:33 +0200 (CEST) From: Stefan Richter firewire: ohci: use memory barriers to order descriptor updates When we append to a DMA program, we need to ensure that the order in which initialization of the new descriptors and update of the branch_address of the old tail descriptor, as seen by the PCI device, happen as intended. Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 3 +++ 1 file changed, 3 insertions(+) Date: Fri, 23 Jul 2010 13:05:39 +0200 (CEST) From: Stefan Richter firewire: cdev: improve FW_CDEV_IOC_ALLOCATE In both the ieee1394 stack and the firewire stack, the core treats kernelspace drivers better than userspace drivers when it comes to CSR address range allocation: The former may request a register to be placed automatically at a free spot anywhere inside a specified address range. The latter may only request a register at a fixed offset. Hence, userspace drivers which do not require a fixed offset potentially need to implement a retry loop with incremented offset in each retry until the kernel does not fail allocation with EBUSY. This awkward procedure is not fundamentally necessary as the core already provides a superior allocation API to kernelspace drivers. Therefore change the ioctl() ABI by addition of a region_end member in the existing struct fw_cdev_allocate. Userspace and kernelspace APIs work the same way now. There is a small cost to pay by clients though: If client source code is required to compile with older kernel headers too, then any use of the new member fw_cdev_allocate.region_end needs to be enclosed by #ifdef/#endif directives. However, any client program that seriously wants to use address range allocations will require a kernel of cdev ABI version >= 4 at runtime and a linux/firewire-cdev.h header of >= 4 anyway. This is because v4 brings FW_CDEV_EVENT_REQUEST2. The only client program in which build-time compatibility with struct fw_cdev_allocate as found in older kernel headers makes sense is libraw1394. (libraw1394 uses the older broken FW_CDEV_EVENT_REQUEST to implement a makeshift, incorrect transaction responder that does at least work somewhat in many simple scenarios, relying on guesswork by libraw1394 and by libraw1394 based applications. Plus, address range allocation and transaction responder is only one of many features that libraw1394 needs to provide, and these other features need to work with kernel and kernel-headers as old as possible. Any new linux/firewire-cdev.h based client that implements a transaction responder should never attempt to do it like libraw1394; instead it should make a header and kernel of v4 or later a hard requirement.) While we are at it, update the struct fw_cdev_allocate documentation to better reflect the recent fw_cdev_event_request2 ABI addition. Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 12 +++++++++--- include/linux/firewire-cdev.h | 29 ++++++++++++++++++++++++----- 2 files changed, 33 insertions(+), 8 deletions(-) Date: Fri, 23 Jul 2010 13:02:54 +0200 (CEST) From: Stefan Richter firewire: core: fix upper bound of possible CSR allocations region->end is defined as an upper bound of the requested address range, exclusive --- i.e. as an address outside of the range in which the requested CSR is to be placed. Hence 0x0001,0000,0000,0000 is the biggest valid region->end, not 0x0000,ffff,ffff,fffc like the current check asserted. For simplicity, the fix drops the region->end & 3 test because there is no actual problem with these bits set in region->end. The allocated address range will be quadlet aligned and of a size of multiple quadlets due to the checks for region->start & 3 and handler->length & 3 alone. Signed-off-by: Stefan Richter --- drivers/firewire/core-transaction.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Date: Thu, 22 Jul 2010 11:58:05 +0200 (CEST) From: Stefan Richter tools/firewire: nosy-dump: increment program version Since version 0.3 from Kristian's repository, there should actually be no change in functionality except for the x86-64 fix. Nevertheless, make it distinct from the original nosy-dump --- just in case and also because of potential future changes. Signed-off-by: Stefan Richter --- tools/firewire/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Date: Thu, 22 Jul 2010 11:58:05 +0200 (CEST) From: Stefan Richter tools/firewire: nosy-dump: remove unused code Signed-off-by: Stefan Richter --- tools/firewire/nosy-dump.c | 113 +++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 60 deletions(-) Date: Thu, 22 Jul 2010 11:58:05 +0200 (CEST) From: Stefan Richter tools/firewire: nosy-dump: use linux/firewire-constants.h Signed-off-by: Stefan Richter --- tools/firewire/decode-fcp.c | 6 ++++-- tools/firewire/nosy-dump.c | 7 ++++--- tools/firewire/nosy-dump.h | 29 +++-------------------------- 3 files changed, 11 insertions(+), 31 deletions(-) Date: Thu, 22 Jul 2010 11:58:05 +0200 (CEST) From: Stefan Richter tools/firewire: nosy-dump: break up a deeply nested function Signed-off-by: Stefan Richter --- tools/firewire/nosy-dump.c | 255 ++++++++++++++++++++----------------- 1 file changed, 137 insertions(+), 118 deletions(-) Date: Thu, 22 Jul 2010 11:58:05 +0200 (CEST) From: Stefan Richter tools/firewire: nosy-dump: make some symbols static or const Signed-off-by: Stefan Richter --- tools/firewire/nosy-dump.c | 56 +++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 27 deletions(-) Date: Thu, 22 Jul 2010 11:58:05 +0200 (CEST) From: Stefan Richter tools/firewire: nosy-dump: change to kernel coding style This changes only - whitespace - C99 initializers - comment style - order of #includes - if { } else { } bracing Signed-off-by: Stefan Richter --- tools/firewire/decode-fcp.c | 364 ++++---- tools/firewire/list.h | 24 tools/firewire/nosy-dump.c | 1641 ++++++++++++++++++------------------ tools/firewire/nosy-dump.h | 280 +++--- 4 files changed, 1128 insertions(+), 1181 deletions(-) Date: Thu, 22 Jul 2010 11:58:05 +0200 (CEST) From: Stefan Richter tools/firewire: nosy-dump: work around segfault in decode_fcp If I run "nosy-dump --view=transaction" with my camcorder on battery instead of mains, it segfaults very quickly because of !t->request. Perhaps this is because of increased likelyhood of incomplete transactions (ack_busy when host writes to camcorder's FCP_Request) and a bug deeper in nosy-dump's transaction housekeeping. This is a quick workaround to get me going. Signed-off-by: Stefan Richter --- tools/firewire/nosy-dump.c | 5 +++++ 1 file changed, 5 insertions(+) Date: Thu, 22 Jul 2010 11:58:05 +0200 (CEST) From: Stefan Richter tools/firewire: nosy-dump: fix it on x86-64 Replace 'unsigned long' and the (unaffected) 'unsigned int' by uint32_t if they represent quadlets. Signed-off-by: Stefan Richter --- tools/firewire/decode-fcp.c | 12 +- tools/firewire/nosy-dump.c | 37 ++--- tools/firewire/nosy-dump.h | 272 ++++++++++++------------------------ 3 files changed, 112 insertions(+), 209 deletions(-) Date: Thu, 22 Jul 2010 11:58:05 +0200 (CEST) From: Stefan Richter tools/firewire: add userspace front-end of nosy This adds nosy-dump, the userspace part of nosy, the IEEE 1394 traffic sniffer for Texas Instruments PCILynx/ PCILynx2 based cards. Author is Kristian Høgsberg. The files added here are taken from git://anongit.freedesktop.org/~krh/nosy commit ee29be97 (2009-11-10) with the following changes by Stefan Richter: - Parts pertaining to the kernel module removed from Makefile. - dist target removed from the Makefile. - Mentioned nosy-dump in the Kconfig help to nosy's kernel component. - Add copyright notice to nosy-dump.c. This is a duplicate of the respective notice in the kernel component nosy.c except for a time span of 2002 - 2006, according to Kristian's git log. "git shortlog decode-fcp.c list.h nosy-dump.[ch]" from nosy's git repository: Jonathan Woithe (1): Save logs on Ctrl-C Kristian Høgsberg (11): Pull over nosy from mercurial repo. Remove some fields from default view, add logging feature. Use infinite time out for poll(), mark more detail fields. Fix byte ordering macro. Add decoding of iso data and lock packets. Add flag to indicate data length field. Add cycle start packet decoding, add --iso and --cycle-start flags. Distinguish between phy-packets and 0-length iso data. Fix transaction and stats view. Add simple AV/C decoder. Don't break down on big payloads. Signed-off-by: Stefan Richter Acked-by: Kristian Høgsberg [[ backport patch without MAINTAINERS hunk ]] --- drivers/firewire/Kconfig | 3 + tools/firewire/Makefile | 19 + tools/firewire/decode-fcp.c | 239 ++++++++ tools/firewire/list.h | 62 ++ tools/firewire/nosy-dump.c | 1037 ++++++++++++++++++++++++++++++++++++ tools/firewire/nosy-dump.h | 292 ++++++++++ 6 files changed, 1651 insertions(+), 1 deletion(-) Date: Thu, 22 Jul 2010 11:56:38 +0200 (CEST) From: Stefan Richter firewire: nosy: use generic printk macros Replace home-grown printk wrapper macros by ones from kernel.h and device.h. Also raise the log level in set_phy_reg() from debug to error because these are really error conditions. Could even be WARN_ON. Lower the log level in the device probe and driver shutdown from notice to info. Signed-off-by: Stefan Richter --- drivers/firewire/nosy.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) Date: Thu, 22 Jul 2010 11:56:38 +0200 (CEST) From: Stefan Richter firewire: nosy: endianess fixes and annotations 1.) The DMA programs (struct pcl) are PCI-endian = little endian data (except for the 3rd quadlet in a PCL which the controller does not touch). Annotate them as such. Fix all accesses of the PCL to work with big endian CPUs also. Not actually tested, I only have a little endian PC to test with. This includes replacement of a bitfield struct pcl_status by open-coded shift and mask operations. 2.) The two __attribute__ ((packed)) at struct pcl are not really required since it consists of u32/__le32 only, i.e. there will be no padding with or without the attribute. 3.) The received IEEE 1394 data are byteswapped by the controller from IEEE 1394 endian = big endian to PCI endian = little endian because the PCL_BIGENDIAN control bit is set. Therefore annotate the DMA buffer as a __le32 array. Fix the one access of the DMA buffer (the check of the transaction code of link packets) to work with big endian CPUs. Also fix the two accesses of the client bounce buffer (the reading of packet length). 4.) Add a comment to the userspace ABI header that all of the data gets out as little endian data, except for the timestamp which is CPU endian. (We could make it little endian too, but why? Vice versa, an ioctl could be added to dump packet data in big endian byte order...) Signed-off-by: Stefan Richter --- drivers/firewire/nosy-user.h | 6 +- drivers/firewire/nosy.c | 74 ++++++++++++----------------------- 2 files changed, 29 insertions(+), 51 deletions(-) Date: Thu, 22 Jul 2010 11:56:38 +0200 (CEST) From: Stefan Richter firewire: nosy: annotate __user pointers and __iomem pointers Signed-off-by: Stefan Richter --- drivers/firewire/nosy.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) Date: Thu, 22 Jul 2010 11:56:38 +0200 (CEST) From: Stefan Richter firewire: nosy: fix device shutdown with active client Fix race between nosy_open() and remove_card() by replacing the unprotected array of card pointers by a mutex-protected list of cards. Make card instances reference-counted and let each client hold a reference. Notify clients about card removal via POLLHUP in poll()'s events bitmap; also let read() fail with errno=ENODEV if the card was removed and everything in the buffer was read. Signed-off-by: Stefan Richter --- drivers/firewire/nosy.c | 109 ++++++++++++++++++++++++++++++---------- 1 file changed, 81 insertions(+), 28 deletions(-) Date: Thu, 22 Jul 2010 11:56:38 +0200 (CEST) From: Stefan Richter firewire: nosy: handle errors in device probe and add a missing pci_disable_device() to device shutdown. Signed-off-by: Stefan Richter --- drivers/firewire/nosy.c | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) Date: Thu, 22 Jul 2010 11:56:38 +0200 (CEST) From: Stefan Richter firewire: nosy: fix IRQ handler for card ejection Untested, I don't have a PCILynx CardBus card. Signed-off-by: Stefan Richter --- drivers/firewire/nosy.c | 4 ++++ 1 file changed, 4 insertions(+) Date: Thu, 22 Jul 2010 11:56:38 +0200 (CEST) From: Stefan Richter firewire: nosy: unroll some simple functions nosy_start/stop_snoop() and nosy_add/remove_client() are simple enough to be inlined into their callers. Signed-off-by: Stefan Richter --- drivers/firewire/nosy.c | 75 +++++++++++++++------------------------- 1 file changed, 29 insertions(+), 46 deletions(-) Date: Thu, 22 Jul 2010 11:56:38 +0200 (CEST) From: Stefan Richter firewire: nosy: use flagless variants of spinlock accessors nosy_start/stop_snoop() are always only called by the ioctl method, i.e. with IRQs enabled. packet_handler() and bus_reset_handler() are always only called by the IRQ handler. Hence neither one needs to track IRQ flags. To underline the call context of packet_handler() and bus_reset_handler(), rename these functions to *_irq_handler(). Signed-off-by: Stefan Richter --- drivers/firewire/nosy.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) Date: Thu, 22 Jul 2010 11:56:38 +0200 (CEST) From: Stefan Richter firewire: nosy: fix list corruption by NOSY_IOC_STOP nosy_stop_snoop() would blow up the second time it was called without nosy_start_snoop() in between. Signed-off-by: Stefan Richter --- drivers/firewire/nosy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Date: Thu, 22 Jul 2010 11:56:38 +0200 (CEST) From: Stefan Richter firewire: nosy: convert to unlocked ioctl The required serialization of NOSY_IOC_START and NOSY_IOC_STOP is already provided by the client_list_lock. NOSY_IOC_FILTER does not really require serialization since accesses to tcode_mask are atomic on any sane CPU architecture. Nevertheless, make it explicit that we want this to be atomic by means of client_list_lock (which also surrounds the other tcode_mask access in the IRQ handler). While we are at it, change the type of tcode_mask to u32 for consistency with the user API. NOSY_IOC_GET_STATS does not require serialization against itself. But there is a bug here regarding concurrent updates of the two counters by the IRQ handler. Fix it by taking the client_list_lock in this ioctl too. Signed-off-by: Stefan Richter --- drivers/firewire/nosy.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) Date: Thu, 27 Jul 2010 10:28:30 +0200 (CEST) From: Stefan Richter firewire: nosy: misc cleanups Extend copyright note to 2007, c.f. Kristian's git log. Includes: - replace some by - add required indirectly included - order alphabetically Coding style related changes: - change to utf8 - normalize whitespace - normalize comment style - remove usages of __FUNCTION__ - remove an unnecessary cast from void * Const and static declarations: - driver_name is not const in pci_driver.name, drop const qualifier - driver_name can be taken from KBUILD_MODNAME - the global variable minors[] can and should be static - constify struct file_operations instance Data types: - Remove unused struct member struct packet.code. struct packet is only used for driver-internal bookkeeping; it does not appear on the wire or in DMA programs or the userspace ABI. Hence the unused member .code can be removed without worries. Preprocessor macros: - unroll a preprocessor macro that containd a return - use list_for_each_entry Printk: - add missing terminating \n in some format strings Signed-off-by: Stefan Richter --- drivers/firewire/nosy-user.h | 10 drivers/firewire/nosy.c | 318 +++++++++++++++++------------------ drivers/firewire/nosy.h | 27 +-- 3 files changed, 169 insertions(+), 186 deletions(-) Date: Thu, 27 Jul 2010 10:26:33 +0200 (CEST) From: Stefan Richter firewire: new driver: nosy - IEEE 1394 traffic sniffer This adds the traffic sniffer driver for Texas Instruments PCILynx/ PCILynx2 based cards. The use cases for nosy are analysis of nonstandard protocols and as an aid in development of drivers, applications, or firmwares. Author of the driver is Kristian Høgsberg. Known contributers are Jody McIntyre and Jonathan Woithe. Nosy programs PCILynx chips to operate in promiscuous mode, which is a feature that is not found in OHCI-1394 controllers. Hence, only special hardware as mentioned in the Kconfig help text is suitable for nosy. This is only the kernelspace part of nosy. There is a userspace interface to it, called nosy-dump, proposed to be added into the tools/ subdirectory of the kernel sources in a subsequent change. Kernelspace and userspave component of nosy communicate via a 'misc' character device file called /dev/nosy with a simple ioctl() and read() based protocol, as described by nosy-user.h. The files added here are taken from git://anongit.freedesktop.org/~krh/nosy commit ee29be97 (2009-11-10) with the following changes by Stefan Richter: - Kconfig and Makefile hunks are written from scratch. - Commented out version printk in nosy.c. - Included missing , reported by Stephen Rothwell. "git shortlog nosy{-user.h,.c,.h}" from nosy's git repository: Jonathan Woithe (2): Nosy updates for recent kernels Fix uninitialised memory (needed for 2.6.31 kernel) Kristian Høgsberg (5): Pull over nosy from mercurial repo. Use a misc device instead. Add simple AV/C decoder. Don't break down on big payloads. Set parent device for misc device. As a low-level IEEE 1394 driver, its files are placed into drivers/firewire/ although nosy is not part of the firewire driver stack. I am aware of the following literature from Texas Instruments about PCILynx programming: SCPA020A - PCILynx 1394 to PCI Bus Interface TSB12LV21BPGF Functional Specification SLLA023 - Initialization and Asynchronous Programming of the TSB12LV21A 1394 Device Signed-off-by: Stefan Richter Acked-by: Kristian Høgsberg --- drivers/firewire/Kconfig | 23 + drivers/firewire/Makefile | 1 + drivers/firewire/nosy-user.h | 25 + drivers/firewire/nosy.c | 695 +++++++++++++++++++++++++++++++++++ drivers/firewire/nosy.h | 238 ++++++++++++ 5 files changed, 982 insertions(+) Date: Sun, 18 Jul 2010 13:00:50 +0200 (CEST) From: Stefan Richter firewire: cdev: add PHY pinging This extends the FW_CDEV_IOC_SEND_PHY_PACKET ioctl() for /dev/fw* to be useful for ping time measurements. One application for it would be gap count optimization in userspace that is based on ping times rather than hop count. (The latter is implemented in firewire-core itself but is not applicable to beta PHYs that act as repeater.) Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 9 ++++++--- drivers/firewire/core.h | 5 +++++ drivers/firewire/ohci.c | 3 +++ include/linux/firewire-cdev.h | 5 ++++- 4 files changed, 18 insertions(+), 4 deletions(-) Date: Fri, 16 Jul 2010 22:25:51 +0200 (CEST) From: Stefan Richter firewire: cdev: add PHY packet reception Add an FW_CDEV_IOC_RECEIVE_PHY_PACKETS ioctl() and FW_CDEV_EVENT_PHY_PACKET_RECEIVED poll()/read() event for /dev/fw*. This can be used to get information from remote PHYs by remote access PHY packets. This is also the 2nd half of the functionality (the receive part) to support a userspace implementation of a VersaPHY transaction layer. Safety considerations: - PHY packets are generally broadcasts, hence some kind of elevated privileges should be required of a process to be able to listen in on PHY packets. This implementation assumes that a process that is allowed to open the /dev/fw* of a local node does have this privilege. There was an inconclusive discussion about introducing POSIX capabilities as a means to check for user privileges for these kinds of operations. Other limitations: - PHY packet reception may be switched on by ioctl() but cannot be switched off again. It would be trivial to provide an off switch, but this is not worth the code. The client should simply close() the fd then, or just ignore further events. - For sake of simplicity of API and kernel-side implementation, no filter per packet content is provided. Signed-off-by: Stefan Richter --- drivers/firewire/core-card.c | 1 + drivers/firewire/core-cdev.c | 73 ++++++++++++++++++++++++++-- drivers/firewire/core-transaction.c | 5 ++ drivers/firewire/core.h | 2 + drivers/firewire/ohci.c | 3 - include/linux/firewire-cdev.h | 39 ++++++++++++--- include/linux/firewire.h | 3 + 7 files changed, 111 insertions(+), 15 deletions(-) Date: Fri, 16 Jul 2010 22:25:14 +0200 (CEST) From: Stefan Richter firewire: cdev: add PHY packet transmission Add an FW_CDEV_IOC_SEND_PHY_PACKET ioctl() for /dev/fw* which can be used to implement bus management related functionality in userspace. This is also half of the functionality (the transmit part) that is needed to support a userspace implementation of a VersaPHY transaction layer. Safety considerations: - PHY packets are generally broadcasts and may have interesting effects on PHYs and the bus, e.g. make asynchronous arbitration impossible due to too low gap count. Hence some kind of elevated privileges should be required of a process to be able to send PHY packets. This implementation assumes that a process that is allowed to open the /dev/fw* of a local node does have this privilege. There was an inconclusive discussion about introducing POSIX capabilities as a means to check for user privileges for these kinds of operations. - The kernel does not check integrity of the supplied packet data. That would be far too much code, considering the many kinds of PHY packets. A process which got the privilege to send these packets is trusted to do it correctly. Just like with the other "send packet" ioctls, a non-blocking API is chosen; i.e. the ioctl may return even before AT DMA started. After transmission, an event for poll()/read() is enqueued. Most users are going to need a blocking API, but a blocking userspace wrapper is easy to implement, and the second of the two existing libraw1394 calls raw1394_phy_packet_write() and raw1394_start_phy_packet_write() can be better supported that way. Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 64 ++++++++++++++++++++++++++++++++++ include/linux/firewire-cdev.h | 44 +++++++++++++++++++++++ 2 files changed, 107 insertions(+), 1 deletion(-) Date: Fri, 16 Jul 2010 22:24:29 +0200 (CEST) From: Stefan Richter firewire: core: use C99 initializer in array of ioctl handlers to make the correspondence of ioctl numbers and handlers more obvious. Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 42 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) Date: Sat, 17 Jul 2010 21:36:02 +0200 (CEST) From: Stefan Richter firewire: cdev: some clarifications to the API documentation Response events: - are generated on more occasions than their documentation claimed. CSR allocation: - An already occupied CSR can be determined from errno==EBUSY. Bus resets: - Note that FW_CDEV_IOC_INITIATE_BUS_RESET is nonblocking and that the client is not required to observe a grace period since kernels 2.6.36+ will enforce it now (commit 02d37bed). - The possible values of fw_cdev_initiate_bus_reset.type are listed in the kerneldoc comment already. - Clarify that an application that uses FW_CDEV_IOC_ADD_DESCRIPTOR and FW_CDEV_IOC_REMOVE_DESCRIPTOR does not have to issue a bus reset. Isochronous I/O contexts: - At most one can be created per open file descriptor. Signed-off-by: Stefan Richter --- include/linux/firewire-cdev.h | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) Date: Sun, 18 Jul 2010 12:44:01 +0200 (CEST) From: Stefan Richter firewire: normalize status values in packet callbacks core-transaction.c transmit_complete_callback() and close_transaction() expect packet callback status to be an ACK or RCODE, and ACKs get translated to RCODEs for transaction callbacks. An old comment on the packet callback API (been there from the initial submission of the stack) and the dummy_driver implementation of send_request/send_response deviated from this as they also included -ERRNO in the range of status values. Let's narrow status values down to ACK and RCODE to prevent surprises. RCODE_CANCELLED is chosen as the dummy_driver's RCODE as its meaning of "transaction timed out" comes closest to what happens when a transaction coincides with card removal. Signed-off-by: Stefan Richter --- Supersedes patch "correct comment on packet callback API" from July 16. drivers/firewire/core-card.c | 4 ++-- drivers/firewire/core-transaction.c | 5 ++++- include/linux/firewire.h | 8 ++++---- 3 files changed, 10 insertions(+), 7 deletions(-) Date: Mon, 12 Jul 2010 13:50:00 -0700 From: Joe Perches ieee1394: Remove unnecessary casts of private_data Signed-off-by: Joe Perches Signed-off-by: Stefan Richter --- drivers/ieee1394/dv1394.c | 4 ++-- drivers/ieee1394/raw1394.c | 4 ++-- drivers/ieee1394/video1394.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) Date: Thu, 8 Jul 2010 16:09:06 +0200 (CEST) From: Stefan Richter firewire: core: integrate software-forced bus resets with bus management Bus resets which are triggered - by the kernel drivers after updates of the local nodes' config ROM, - by userspace software via ioctl shall be deferred until after >=2 seconds after the last bus reset. If multiple modifications of the local nodes' config ROM happen in a row, only a single bus reset should happen after them. When the local node's link goes from inactive to active or vice versa, and at the two occasions of bus resets mentioned above --- and if the current gap count differs from 63 --- the bus reset should be preceded by a PHY configuration packet that reaffirms the gap count. Otherwise a bus manager would have to reset the bus again right after that. This is necessary to promote bus stability, e.g. leave grace periods for allocations and reallocations of isochronous channels and bandwidth, SBP-2 reconnections etc.; see IEEE 1394 clause 8.2.1. This change implements all of the above by moving bus reset initiation into a delayed work (except for bus resets which are triggered by the bus manager workqueue job and are performed there immediately). It comes with a necessary addition to the card driver methods that allows to get the current gap count from PHY registers. Signed-off-by: Stefan Richter --- drivers/firewire/core-card.c | 68 +++++++++++++++++++++------- drivers/firewire/core-cdev.c | 3 + drivers/firewire/core-transaction.c | 18 ++++++- drivers/firewire/core.h | 6 ++ drivers/firewire/ohci.c | 53 ++++++++++++++++------ include/linux/firewire.h | 6 +- 6 files changed, 116 insertions(+), 38 deletions(-) Date: Wed, 7 Jul 2010 15:36:07 +0200 (CEST) From: Stefan Richter firewire: cdev: fix fw_cdev_event_bus_reset emission after local config ROM changes When a descriptor was added or removed to the local node's config ROM, userspace clients which had a local node's /dev/fw* open did not receive any fw_cdev_event_bus_reset for poll()/read() consumption. The cause was that the core-device.c facility which re-reads the config ROM of the bus reset initiator node missed to call the fw_device update function. The fw_units are destroyed and newly added, but their parent stays and needs to be updated. Reported-by: Jay Fenlason Signed-off-by: Stefan Richter --- drivers/firewire/core-device.c | 1 + 1 file changed, 1 insertion(+) Date: Wed, 7 Jul 2010 14:13:14 +0200 (CEST) From: Stefan Richter firewire: core: ensure some userspace API constants match corresponding kernel API constants The FW_ISO_ constants of the in-kernel API of firewire-core and FW_CDEV_ISO_ constants of the userspace API of firewire-core have nothing to do with each other --- except that the core-cdev.c implementation relies on them having the same values. Hence put some compile-time assertions into core-cdev.c. It's lame but I prefer it over including the userspace API header into the kernelspace API header and defining kernelspace API constants from userspace API constants. Nor do I want to expose the kernelspace constants in one of the two firewire headers that are exported to userland since this only concerns the core-cdev.c implementation. Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 11 +++++++++++ 1 file changed, 11 insertions(+) Date: Wed, 7 Jul 2010 13:26:18 +0200 (CEST) From: Stefan Richter firewire: core: fix fw_send_request kerneldoc comment The present inline documentation of the fw_send_request() in-kernel API refers to userland code that is not applicable to kernel drivers at all. Reported-by: Ben Gamari While we are at fixing the whole documentation of fw_send_request(), also improve the rest of firewire-core's kerneldoc comments: - Add a bit of text concerning fw_run_transaction()'s call parameters. - Append () to function names and tab-align parameter descriptions as suggested by the example in Documentation/kernel-doc-nano-HOWTO.txt. - Remove kerneldoc markers from comments on static functions. - Remove outdated parameter descriptions at build_tree(). Signed-off-by: Stefan Richter --- drivers/firewire/core-device.c | 10 +- drivers/firewire/core-iso.c | 2 drivers/firewire/core-topology.c | 16 ++--- drivers/firewire/core-transaction.c | 90 +++++++++++++++------------- 4 files changed, 60 insertions(+), 58 deletions(-) Date: Wed, 7 Jul 2010 14:37:30 +0200 (CEST) From: Clemens Ladisch firewire: cdev: check write quadlet request length to avoid buffer overflow Check that the data length of a write quadlet request actually is large enough for a quadlet. Otherwise, fw_fill_request could access the four bytes after the end of the outbound_transaction_event structure. Signed-off-by: Clemens Ladisch Modification of Clemens' change: Consolidate the check into init_request() which is used by the affected ioctl_send_request() and ioctl_send_broadcast_request() and the unaffected ioctl_send_stream_packet(), to save a few lines of code. Note, since struct outbound_transaction_event *e is slab-allocated, such an out-of-bounds access won't hit unallocated memory but may result in a (virtually impossible to exploit) information disclosure. Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 4 ++++ 1 file changed, 4 insertions(+) Date: Mon, 21 Jun 2010 23:24:35 +0200 (CEST) From: Stefan Richter firewire: cdev: fix fw_cdev_event_bus_reset.bm_node_id Fix an obscure ABI feature that is a bit of a hassle to implement. However, somebody put it into the ABI, so let's fill in a sensible value there. Signed-off-by: Stefan Richter --- drivers/firewire/core-card.c | 12 +++++++++--- drivers/firewire/core-cdev.c | 2 +- drivers/firewire/core-topology.c | 1 + include/linux/firewire-cdev.h | 5 +++++ include/linux/firewire.h | 1 + 5 files changed, 17 insertions(+), 4 deletions(-) Date: Mon, 21 Jun 2010 23:23:52 +0200 (CEST) From: Stefan Richter firewire: core: no need to track irq flags in bm_work This is a workqueue job and always entered with IRQs enabled. Signed-off-by: Stefan Richter --- drivers/firewire/core-card.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) Date: Sun, 20 Jun 2010 22:54:22 +0200 (CEST) From: Stefan Richter firewire: cdev: extend fw_cdev_event_iso_interrupt documentation Add information regarding the 2.6.32 update to the xmit variant of fw_cdev_event_iso_interrupt. Signed-off-by: Stefan Richter --- include/linux/firewire-cdev.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) Date: Sun, 20 Jun 2010 22:53:55 +0200 (CEST) From: Stefan Richter firewire: cdev: fix ABI for FCP and address range mapping, add fw_cdev_event_request2 The problem: A target-like userspace driver, e.g. AV/C target or SBP-2/3 target, needs to be able to act as responder and requester. In the latter role, it needs to send requests to nods from which it received requests. This is currently impossible because fw_cdev_event_request lacks information about sender node ID. Reported-by: Jay Fenlason Libffado + libraw1394 + firewire-core is currently unable to drive two or more audio devices on the same bus. Reported-by: Arnold Krille This is because libffado requires destination node ID of FCP requests and sender node ID of FCP responses to match. It even prohibits libffado from working with a bus on which libraw1394 opens a /dev/fw* as default ioctl device that does not correspond with the audio device. This is because libraw1394 does not receive the sender node ID from the kernel. Moreover, fw_cdev_event_request makes it impossible to tell unicast and broadcast write requests apart. The fix: Add a replacement of struct fw_cdev_event_request request, boringly called struct fw_cdev_event_request2. The new event will be sent to a userspace client instead of the old one if the client claims compatibility with ABI version 4 or later. libraw1394 needs to be extended to make use of the new event, in order to properly support libffado and other FCP or address range mapping users who require correct sender node IDs. Further notes: While we are at it, change back the range of possible values of fw_cdev_event_request.tcode to 0x0...0xb like in ABI version <= 3. The preceding change "firewire: expose extended tcode of incoming lock requests to (userspace) drivers" expanded it to 0x0...0x17 which could catch sloppily coded clients by surprise. The extended range of codes is only used in the new fw_cdev_event_request2.tcode. Jay and I also suggested an alternative approach to fix the ABI for incoming requests: Add an FW_CDEV_IOC_GET_REQUEST_INFO ioctl which can be called after reception of an fw_cdev_event_request, before issuing of the closing FW_CDEV_IOC_SEND_RESPONSE ioctl. The new ioctl would reveal the vital information about a request that fw_cdev_event_request lacks. Jay showed an implementation of this approach. The former event approach adds 27 LOC of rather trivial code to core-cdev.c, the ioctl approach 34 LOC, some of which is nontrivial. The ioctl approach would certainly also add more LOC to userspace programs which require the expanded information on inbound requests. This approach is probably only on the lighter-weight side in case of clients that want to be compatible with kernels that lack the new capability, like libraw1394. However, the code to be added to such libraw1394-like clients in case of the event approach is a straight- forward additional switch () case in its event handler. Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 45 ++++++++++++++++---- include/linux/firewire-cdev.h | 76 +++++++++++++++++++++++++++++++++- 2 files changed, 110 insertions(+), 11 deletions(-) Date: Tue, 18 May 2010 10:57:33 -0400 From: Jay Fenlason firewire: expose extended tcode of incoming lock requests to (userspace) drivers When a remote device does a LOCK_REQUEST, the core does not pass the extended tcode to userspace. This patch makes it use the juju-specific tcodes listed in firewire-constants.h for incoming requests. Signed-off-by: Jay Fenlason This matches how tcode in the API for outbound requests is treated. Affects kernelspace and userspace drivers alike, but at the moment there are no kernespace drivers that receive lock requests. Split out from a combo patch, slightly reordered, changelog reworded. Signed-off-by: Stefan Richter --- drivers/firewire/core-transaction.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) Date: Sun, 20 Jun 2010 22:52:55 +0200 (CEST) From: Stefan Richter firewire: cdev: freeze FW_CDEV_VERSION due to libraw1394 bug libraw1394 v2.0.0...v2.0.5 takes FW_CDEV_VERSION from an externally installed header file and uses it to declare its own implementation level in FW_CDEV_IOC_GET_INFO. This is wrong; it should set the real version for which it was actually written. If we add features to the kernel ABI that require the kernel to check a client's implementation level, we can not trust the client version if it was set from FW_CDEV_VERSION. Hence freeze FW_CDEV_VERSION at the current value (no damage has been done yet), clearly document FW_CDEV_VERSION as a dummy version and what clients are expected to do with fw_cdev_get_info.version, and use a new defined constant (which is not placed into the exported header file) as kernel implementation level. Note, in order to check in client program source code which features are present in an externally installed linux/firewire-cdev.h, use preprocessor directives like #ifdef FW_CDEV_IOC_ALLOCATE_ISO_RESOURCE or #ifdef FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED instead of a check of FW_CDEV_VERSION. Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 7 ++++++- include/linux/firewire-cdev.h | 22 ++++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) Date: Sun, 20 Jun 2010 22:52:27 +0200 (CEST) From: Stefan Richter firewire: cdev: count references of cards during inbound transactions If a request comes in to an address range managed by a userspace driver i.e. client, the card instance of request and response may differ from the card instance of the client device. Therefore we need to take a reference of the card until the response was sent. I thought about putting the reference counting into core-transaction.c, but the various high-level drivers besides cdev clients (firewire-net, firewire-sbp2, firedtv) use the card pointer in their fw_address_handler address_callback method only to look up devices of which they already hold the necessary references. So this seems to be a specific firewire-cdev issue which is better addressed locally. We do not need the reference - in case of FCP_REQUEST or FCP_RESPONSE requests because then the firewire-core will send the split transaction response for us already in the context of the request handler, - if it is the same card as the client device's because we hold a card reference indirectly via teh client->device reference. To keep things simple, we take the reference nevertheless. Jay Fenlason wrote: > there's no way for the core to tell cdev "this card is gone, > kill any inbound transactions on it", while cdev holds the transaction > open until userspace issues a SEND_RESPONSE ioctl, which may be a very, > very long time. But when it does, it calls fw_send_response(), which > will dereference the card... > > So how unhappy are we about userspace potentially holding a fw_card > open forever? While termination of inbound transcations at card removal could be implemented, it is IMO not worth the effort. Currently, the effect of holding a reference of a card that has been removed is to block the process that called the pci_remove of the card. This is - either a user process ran by root. Root can find and kill processes that have /dev/fw* open, if desired. - a kernel thread (which one?) in case of hot removal of a PCCard or ExpressCard. The latter case could be a problem indeed. firewire-core's card shutdown and card release should probably be improved not to block in shutdown, just to defer freeing of memory until release. This is not a new problem though; the same already always happens with the client->device->card without the need of inbound transactions or other special conditions involved, other than the client not closing the file. Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 8 ++++++++ 1 file changed, 8 insertions(+) Date: Tue, 18 May 2010 14:02:45 -0400 From: Jay Fenlason firewire: cdev: fix responses to nodes at different card My box has two firewire cards in it: card0 and card1. My application opens /dev/fw0 (card 0) and allocates an address space. The core makes the address space available on both cards. Along comes the remote device, which sends a READ_QUADLET_REQUEST to card1. The request gets passed up to my application, which calls ioctl_send_response(). ioctl_send_response() then calls fw_send_response() with card0, because that's the card it's bound to. Card0's driver drops the response, because it isn't part of a transaction that it has outstanding. So in core-cdev: handle_request(), we need to stash the card of the inbound request in the struct inbound_transaction_resource and use that card to send the response to. The hard part will be refcounting the card correctly so it can't get deallocated while we hold a pointer to it. Here's a trivial patch, which does not do the card refcounting, but at least demonstrates what the problem is. Note that we can't depend on the fact that the core-cdev:client structure holds a card open, because in this case the card it holds open is not the card the request came in on. ..and there's no way for the core to tell cdev "this card is gone, kill any inbound transactions on it", while cdev holds the transaction open until userspace issues a SEND_RESPONSE ioctl, which may be a very, very long time. But when it does, it calls fw_send_response(), which will dereference the card... So how unhappy are we about userspace potentially holding a fw_card open forever? Signed-off-by: Jay Fenlason Reference counting to be addressed in a separate change. Signed-off-by: Stefan Richter (whitespace) --- drivers/firewire/core-cdev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) Date: Mon, 14 Jun 2010 11:46:25 +0200 From: Clemens Ladisch firewire: cdev: fix race in iso context creation Protect the client's iso context pointer against a race that can happen when more than one creation call is executed at the same time. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) Date: Sun, 20 Jun 2010 22:50:35 +0200 (CEST) From: Stefan Richter firewire: remove an unused function argument void (*fw_address_callback_t)(..., int speed, ...) is the speed that a remote node chose to transmit a request to us. In case of split transactions, firewire-core will transmit the response at that speed. Upper layer drivers on the other hand (firewire-net, -sbp2, firedtv, and userspace drivers) cannot do anything useful with that speed datum, except log it for debug purposes. But data that is merely potentially (not even actually) used for debug purposes does not belong into the API. Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 3 +-- drivers/firewire/core-transaction.c | 14 +++++++------- drivers/firewire/net.c | 4 ++-- drivers/firewire/sbp2.c | 3 +-- drivers/media/dvb/firewire/firedtv-fw.c | 4 ++-- include/linux/firewire.h | 2 +- 6 files changed, 14 insertions(+), 16 deletions(-) Date: Tue, 8 Jun 2010 00:20:10 +0200 (CEST) From: Stefan Richter firewire: core: remove an unnecessary zero initialization All of the fields of the iso_interrupt_event instance are overwritten right after it was allocated. Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Date: Tue, 15 Jun 2010 01:22:45 +0200 (CEST) From: Stefan Richter firewire: core: remove unused variable which caused gcc 4.6 to warn about variable 'destination' set but not used. Since the hardware ensures that we receive only response packets with proper destination node ID (in a given bus generation), we have no use for destination here in the core as well as in upper layers. (This is different with request packets. There we pass destination node ID to upper layers because they may for example need to check whether this was an unicast or broadcast request.) Reported-and-Tested-By: Justin P. Mattock Signed-off-by: Stefan Richter --- drivers/firewire/core-transaction.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) Date: Tue, 15 Jun 2010 02:00:11 +0200 (CEST) From: Stefan Richter ieee1394: remove unused variables which caused gcc 4.6 to warn about variable 'XYZ' set but not used. sbp2.c, unit_characteristics: The underlying problem which was spotted here --- an incomplete implementation --- is already 50% fixed in drivers/firewire/sbp2.c which observes mgt_ORB_timeout but not yet ORB_size. raw1394.c, length_conflict; dv1394.c, ts_off: Impossible to tell why these variables are there. We can safely remove them though because we don't need a compiler warning to realize that we are dealing with (at least stylistically) flawed code here. dv1394.c, packet_time: This was used in debug macro that is only compiled in with DV1394_DEBUG_LEVEL >= 2 defined at compile-time. Just drop it since nobody debugs dv1394 anymore. Avoids noise in regular kernel builds. dv1394.c, ohci; eth1394.c, priv: These variables clearly can go away. Somebody wanted to use them but then didn't (or not anymore). Note, all of this code is considered to be at its end of life and is thus not really meant to receive janitorial updates anymore. But if we can easily remove noisy warnings from kernel builds, we should. Reported-by: Justin P. Mattock Signed-off-by: Stefan Richter --- drivers/ieee1394/dv1394.c | 14 ++------------ drivers/ieee1394/eth1394.c | 3 --- drivers/ieee1394/raw1394.c | 3 +-- drivers/ieee1394/sbp2.c | 11 ++++------- 4 files changed, 7 insertions(+), 24 deletions(-) Date: Sat, 12 Jun 2010 20:35:52 +0200 (CEST) From: Stefan Richter firewire: rename CSR access driver methods Rather than "read a Control and Status Registers (CSR) Architecture register" I prefer to say "read a Control and Status Register". Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 2 +- drivers/firewire/core-transaction.c | 10 ++++------ drivers/firewire/core.h | 4 ++-- drivers/firewire/ohci.c | 8 ++++---- 4 files changed, 11 insertions(+), 13 deletions(-) Date: Sat, 12 Jun 2010 20:35:21 +0200 (CEST) From: Stefan Richter firewire: core: combine some repeated code All of these CSRs have the same read/ write/ aynthing-else handling, except for CSR_PRIORITY_BUDGET which might not be implemented. The CSR_CYCLE_TIME read handler implementation accepted 4-byte-sized block write requests before this change but this is just silly; the register is only required to support quadlet read and write requests like the other r/w CSR core and Serial-Bus-dependent registers. Signed-off-by: Stefan Richter --- drivers/firewire/core-transaction.c | 84 +++++----------------------- 1 file changed, 15 insertions(+), 69 deletions(-) Date: Sat, 12 Jun 2010 20:34:50 +0200 (CEST) From: Stefan Richter firewire: normalize STATE_CLEAR/SET CSR access interface Push the maintenance of STATE_CLEAR/SET.abdicate down into the card driver. This way, the read/write_csr_reg driver method works uniformly across all CSR offsets. Signed-off-by: Stefan Richter --- drivers/firewire/core-topology.c | 5 +-- drivers/firewire/core-transaction.c | 41 ++++++++-------------------- drivers/firewire/core.h | 2 drivers/firewire/ohci.c | 19 ++++++++++--- include/linux/firewire.h | 3 +- 5 files changed, 30 insertions(+), 40 deletions(-) Date: Sat, 12 Jun 2010 20:30:21 +0200 (CEST) From: Stefan Richter firewire: replace get_features card driver hook by feature variables in the fw_card struct. The hook appeared to be an unnecessary abstraction in the card driver interface. Cleaner would be to pass those feature flags as arguments to fw_card_initialize() or fw_card_add(), but the FairnessControl register is in the SCLK domain and may therefore not be accessible while Link Power Status is off, i.e. before the card->driver->enable call from fw_card_add(). Signed-off-by: Stefan Richter --- drivers/firewire/core-topology.c | 3 +-- drivers/firewire/core-transaction.c | 3 +-- drivers/firewire/core.h | 5 ----- drivers/firewire/ohci.c | 14 ++------------ include/linux/firewire.h | 3 +++ 5 files changed, 7 insertions(+), 21 deletions(-) Date: Sat, 12 Jun 2010 20:29:07 +0200 (CEST) From: Stefan Richter firewire: drop sizeof expressions from some request size arguments In case of fw_card_bm_work()'s lock request, the present sizeof expression is going to be wrong if somebody changes the fw_card's DMA scratch buffer's size in the future. In case of quadlet write requests, sizeof(u32) is just silly; it's 4. In case of SBP-2 ORB pointer write requests, 8 is arguably quicker to understand as the correct and only possible value than sizeof(some_datum). Signed-off-by: Stefan Richter --- drivers/firewire/core-card.c | 5 ++--- drivers/firewire/sbp2.c | 10 ++++------ 2 files changed, 6 insertions(+), 9 deletions(-) Date: Sat, 12 Jun 2010 20:26:51 +0200 (CEST) From: Stefan Richter firewire: 'add CSR_... support' addendum Add a comment on which of the conflicting NODE_IDS specifications we implement. Reduce a comment on rather irrelevant register bits that can all be looked up in the spec (or from now on in the code history). Directly include the required indirectly included bug.h. Signed-off-by: Stefan Richter --- drivers/firewire/core-transaction.c | 27 ++++++--------------------- drivers/firewire/ohci.c | 1 + 2 files changed, 7 insertions(+), 21 deletions(-) Date: Thu, 10 Jun 2010 08:41:51 +0200 From: Clemens Ladisch firewire: core: always enable cycle master packets As part of the bus manager responsibilities, make sure that the cycle master sends cycle start packets. This is needed when the old bus manager disabled the cycle master's cmstr bit and there are iso-capable nodes on the new bus. Signed-off-by: Clemens Ladisch --- drivers/firewire/core-card.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) Date: Thu, 10 Jun 2010 08:40:49 +0200 From: Clemens Ladisch firewire: allocate broadcast channel in hardware On OHCI 1.1 controllers, let the hardware allocate the broadcast channel automatically. This removes a theoretical race condition directly after a bus reset where it could be possible to read the channel allocation register with channel 31 still being unallocated. Signed-off-by: Clemens Ladisch --- drivers/firewire/core-card.c | 16 +++++++++++----- drivers/firewire/core-topology.c | 3 ++- drivers/firewire/core.h | 1 + drivers/firewire/ohci.c | 18 ++++++++++++------ 4 files changed, 26 insertions(+), 12 deletions(-) Date: Thu, 10 Jun 2010 08:37:15 +0200 From: Clemens Ladisch firewire: core: add CSR abdicate support Implement the abdicate bit, which is required for bus manager capable nodes and tested by the Base 1394 Test Suite. Finally, something to do at a command reset! :-) Signed-off-by: Clemens Ladisch --- drivers/firewire/core-card.c | 3 ++- drivers/firewire/core-topology.c | 2 ++ drivers/firewire/core-transaction.c | 13 +++++++++++-- drivers/firewire/core.h | 1 + include/linux/firewire.h | 2 ++ 5 files changed, 18 insertions(+), 3 deletions(-) Date: Thu, 10 Jun 2010 08:36:37 +0200 From: Clemens Ladisch firewire: add CSR cmstr support Implement the cmstr bit, which is required for cycle master capable nodes and tested for by the Base 1394 Test Suite. This bit allows the bus master to disable cycle start packets; there are bus master implementations that actually do this. Signed-off-by: Clemens Ladisch --- drivers/firewire/core-transaction.c | 12 ++++++++-- drivers/firewire/core.h | 2 ++ drivers/firewire/ohci.c | 35 ++++++++++++++++++++++++++++ drivers/firewire/ohci.h | 1 + 4 files changed, 48 insertions(+), 2 deletions(-) Date: Thu, 10 Jun 2010 08:35:37 +0200 From: Clemens Ladisch firewire: core: add CSR MAINT_UTILITY support Implement the MAIN_UTILITY register, which is utterly optional but useful as a safe target for diagnostic read/write/broadcast transactions. Signed-off-by: Clemens Ladisch --- drivers/firewire/core-transaction.c | 9 +++++++++ include/linux/firewire.h | 3 +++ 2 files changed, 12 insertions(+) Date: Thu, 10 Jun 2010 08:35:06 +0200 From: Clemens Ladisch firewire: add CSR PRIORITY_BUDGET support If supported by the OHCI controller, implement the PRIORITY_BUDGET register, which is required for nodes that can use asynchronous priority arbitration. To allow the core to determine what features the lowlevel device supports, add a new card driver callback. Signed-off-by: Clemens Ladisch --- drivers/firewire/core-transaction.c | 14 ++++++++++++++ drivers/firewire/core.h | 4 ++++ drivers/firewire/ohci.c | 27 +++++++++++++++++++++++++++ include/linux/firewire.h | 1 + 4 files changed, 46 insertions(+) Date: Thu, 10 Jun 2010 08:34:13 +0200 From: Clemens Ladisch firewire: add CSR BUSY_TIMEOUT support Implement the BUSY_TIMEOUT register, which is required for nodes that support retries. Signed-off-by: Clemens Ladisch --- drivers/firewire/core-transaction.c | 14 +++++++++++--- drivers/firewire/ohci.c | 14 +++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) Date: Thu, 10 Jun 2010 08:33:07 +0200 From: Clemens Ladisch firewire: add CSR BUS_TIME support Implement the BUS_TIME register, which is required for cycle master capable nodes and tested for by the Base 1393 Test Suite. Even when there is not yet bus master initialization support, this register allows us to work together with other bus masters. Signed-off-by: Clemens Ladisch --- drivers/firewire/core-transaction.c | 14 ++ drivers/firewire/ohci.c | 168 ++++++++++++++++++---------- 2 files changed, 120 insertions(+), 62 deletions(-) Date: Thu, 10 Jun 2010 08:26:48 +0200 From: Clemens Ladisch firewire: add CSR CYCLE_TIME write support The specification requires that CYCLE_TIME is writable so that it can be initialized, so we better implement it. Signed-off-by: Clemens Ladisch --- drivers/firewire/core-transaction.c | 3 +++ drivers/firewire/ohci.c | 7 +++++++ 2 files changed, 10 insertions(+) Date: Thu, 10 Jun 2010 08:26:28 +0200 From: Clemens Ladisch firewire: core: add CSR SPLIT_TIMEOUT support Implement the SPLIT_TIMEOUT registers. Besides being required by the spec, this is desirable for some IIDC devices and necessary for many audio devices to be able to increase the timeout from userspace. Signed-off-by: Clemens Ladisch --- drivers/firewire/core-card.c | 4 + drivers/firewire/core-transaction.c | 76 ++++++++++++++++++++++++---- include/linux/firewire.h | 5 ++ 3 files changed, 74 insertions(+), 11 deletions(-) Date: Thu, 10 Jun 2010 08:25:46 +0200 From: Clemens Ladisch firewire: core: add CSR RESET_START support This implements the RESET_START register (as a dummy) to make the Base 1394 Test Suite happy. Signed-off-by: Clemens Ladisch --- drivers/firewire/core-transaction.c | 5 +++++ 1 file changed, 5 insertions(+) Date: Thu, 10 Jun 2010 08:25:19 +0200 From: Clemens Ladisch firewire: add CSR NODE_IDS support The NODE_IDS register, and especially its bus_id field, is quite useless because 1394.1 requires that the bus_id field always stays 0x3ff. However, the 1394 specification requires this register on all transaction capable nodes, and the Base 1394 Test Suite tests for it, so we better implement it. Signed-off-by: Clemens Ladisch --- drivers/firewire/core-transaction.c | 11 +++++++++++ drivers/firewire/core.h | 1 + drivers/firewire/ohci.c | 20 ++++++++++++++++++++ 3 files changed, 32 insertions(+) Date: Thu, 10 Jun 2010 08:24:35 +0200 From: Clemens Ladisch firewire: add read_csr_reg driver callback To prepare for the following additions of more OHCI-implemented CSR registers, replace the get_cycle_time driver callback with a generic CSR register callback. Signed-off-by: Clemens Ladisch --- drivers/firewire/core-cdev.c | 2 +- drivers/firewire/core-transaction.c | 3 ++- drivers/firewire/core.h | 2 +- drivers/firewire/ohci.c | 19 ++++++++++++++++--- 4 files changed, 20 insertions(+), 6 deletions(-) Date: Thu, 10 Jun 2010 08:24:03 +0200 From: Clemens Ladisch firewire: core: add CSR STATE_CLEAR/STATE_SET support The state registers are zero and read-only in this implementation, so they are not of much use. However, the specification requires that they are present for transaction capable nodes, and the Base 1394 Test Suite tests for them, so we better implement them. Signed-off-by: Clemens Ladisch --- drivers/firewire/core-transaction.c | 44 ++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) Date: Thu, 10 Jun 2010 08:23:28 +0200 From: Clemens Ladisch firewire: core: retry on local errors in bus manager election When the candidate bus manager fails to do the lock request with which it tries to become bus manager, it assumes that the current IRM is not actually IRM capable and forces itself to become root. However, if that lock request failed because the local node itself was not able to send it, then we cannot blame the current IRM and should not steal its rootness. In this case, RCODE_SEND_ERROR is likely to indicate a temporary error condition such as exhausted tlabels or low memory, so we better try again later. Signed-off-by: Clemens Ladisch --- drivers/firewire/core-card.c | 10 ++++++++++ 1 file changed, 10 insertions(+) Date: Thu, 10 Jun 2010 08:22:07 +0200 From: Clemens Ladisch firewire: ohci: speed up PHY register accesses Most PHY chips, when idle, can complete a register access in the time needed for two or three PCI read transactions; bigger delays occur only when data is currently being moved over the link/PHY interface. So if we busy-wait a few times when waiting for the register access to finish, it is likely that we can finish without having to sleep. Signed-off-by: Clemens Ladisch --- drivers/firewire/ohci.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) Date: Sat, 5 Jun 2010 20:32:50 +0200 (CEST) From: Stefan Richter firewire: core: trivial fix for warning strings WARN's format string argument should not carry a printk level prefix. Signed-off-by: Stefan Richter --- drivers/firewire/core-transaction.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) Date: Wed, 19 May 2010 08:28:32 +0200 From: Clemens Ladisch firewire: check cdev response length Add a check that the data length in the SEND_RESPONSE ioctl is correct. Incidentally, this also fixes the previously wrong response length of software-handled lock requests. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 9 ++++-- drivers/firewire/core-transaction.c | 38 +++++++++++++++++++++++++++- drivers/firewire/core.h | 1 drivers/firewire/core-cdev.c | 9 +++++-- drivers/firewire/core-transaction.c | 38 +++++++++++++++++++++++++++- drivers/firewire/core.h | 1 + 3 files changed, 44 insertions(+), 4 deletions(-) Date: Thu, 27 May 2010 14:36:45 +0200 (CEST) From: Julia Lawall drivers/media: Eliminate a NULL pointer dereference In each case, the print involves dereferencing a value that is NULL or is near NULL. Signed-off-by: Julia Lawall Firewire-only backport patch: drivers/media/video/hdpvr/hdpvr-video.c | 2 +- drivers/media/video/usbvision/usbvision-video.c | 3 +-- omitted. Signed-off-by: Stefan Richter --- drivers/media/dvb/firewire/firedtv-1394.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Date: Sat, 5 Jun 2010 12:31:25 +0200 (CEST) From: Clemens Ladisch firewire: ohci: add MSI support This patch adds support for message-signaled interrupts. Any native PCI-Express OHCI controller should support MSI, but most are just PCI cores behind a PCI-E/PCI bridge. The only chips that are known to claim to support MSI are the Lucent/Agere/LSI FW643 and the VIA VT6315, none of which I have been able to test. Due to the high level of trust I have in the competence of these and any future chip makers, I thought it a good idea to add a disable-MSI quirk. Signed-off-by: Clemens Ladisch Tested Agere FW643 rev 07 [11c1:5901] and JMicron JMB381 [197b:2380]. Added a quirks list entry for JMB38X since it kept its count of MSI events consistently at zero. Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) Date: Sat, 5 Jun 2010 11:46:49 +0200 (CEST) From: Stefan Richter firewire: ohci: do not enable interrupts without the handler On 26 Apr 2010, Clemens Ladisch wrote: > In theory, none of the interrupts should occur before the link is > enabled. In practice, I'd rather make sure to not set the master > interrupt enable bit until we have installed the interrupt handler. and proposed to move OHCI1394_masterIntEnable out of the present reg_write() into a new one before the HCControl.linkEnable reg_write(). Why not defer setting /all/ of the bits until right before linkEnable? Reviewed-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) Date: Sat, 22 May 2010 10:22:00 +0200 (CEST) From: Julia Lawall ieee1394: video1394: Use memdup_user ...when user data is immediately copied into the allocated region. Signed-off-by: Julia Lawall Signed-off-by: Stefan Richter (changelog) --- drivers/ieee1394/video1394.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) Date: Mon, 24 May 2010 21:31:23 +0200 (CEST) From: Stefan Richter ieee1394: schedule for removal All application domains that are supported by the old ieee1394 driver stack are supported by the newer firewire driver stack too. There is now good and extensive experience with the newer stack from deployment in Fedora since F7 as well as by enthusiast users of other distributions. The new drivers have consequently been recommended as the default ones since 2.6.33, in order to fix some severe usability problems of FireWire on Linux due to limitations of the old stack. It is now high time to announce when the obsolete drivers will be removed. Signed-off-by: Stefan Richter Acked-by: Jarod Wilson --- Documentation/feature-removal-schedule.txt | 10 ++++++++++ drivers/ieee1394/Kconfig | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) Date: Tue, 27 Apr 2010 09:07:00 +0200 From: Clemens Ladisch firewire: core: use separate timeout for each transaction Using a single timeout for all transaction that need to be flushed does not work if the submission of new transactions can defer the timeout indefinitely into the future. We need to have timeouts that do not change due to other transactions; the simplest way to do this is with a separate timer for each transaction. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter (+ one lockdep annotation) --- drivers/firewire/core-card.c | 11 ---- drivers/firewire/core-transaction.c | 70 +++++++++++++++------------- drivers/firewire/core.h | 1 - include/linux/firewire.h | 3 + 4 files changed, 39 insertions(+), 46 deletions(-) Date: Fri, 23 Apr 2010 19:27:25 -0400 From: Peter Hurley firewire: core: Fix tlabel exhaustion problem fw_core_handle_response() was not properly clearing tlabel_mask. This was resulting in premature tlabel exhaustion. Signed-off-by: Peter Hurley This fixes an omission in 2.6.31-rc1 commit 1e626fdc "firewire: core: use more outbound tlabels" which prevented to really use 64 instead of 32 transaction labels, as soon as split transactions occurred that had their AR-resp tasklet run after the AT-req tasklet. Signed-off-by: Stefan Richter --- drivers/firewire/core-transaction.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Date: Mon, 19 Apr 2010 17:29:14 +0200 From: Clemens Ladisch firewire: core: make transaction label allocation more robust If one request is so long-lived that it does not get a response before the following 63 requests, its bit in tlabel_mask is still set when the next request tries to allocate a transaction label for that number. In this state, while the first request is not completed or timed out, no new requests can be submitted. To fix this, skip over any label still in use, and do not error out unless we have entirely run out of labels. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/core-transaction.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) Date: Wed, 14 Apr 2010 22:30:18 +0200 (CEST) From: Stefan Richter firewire: core: clean up config ROM related defined constants Clemens Ladisch pointed out that - BIB_IMC is not named like the field is called in the standard, - readers of the code may get worried about the magic 0x0c0083c0, - a CSR_NODE_CAPABILITIES key is there in the header but not put to good use. So let's rename BIB_IMC, add a defined constant for Node_Capabilities and a comment which reassures people that somebody thought about it and they don't have to (or if they still do, tell them where they have to look for confirmation), and prune our incomplete and arbitrary set of defined constants of CSR key IDs. And there is a nother magic number, that of Bus_Information_Block.Bus_Name, to be defined and commented. Signed-off-by: Stefan Richter --- drivers/firewire/core-card.c | 11 ++++++----- include/linux/firewire.h | 2 -- 2 files changed, 6 insertions(+), 7 deletions(-) Date: Sat, 10 Apr 2010 16:47:18 +0100 (CET) From: Stefan Richter ieee1394: mark char device files as not seekable The - raw1394 (/dev/raw1394), - video1394 (/dev/video1394/*), - dv1394 (/dev/dv1394/*) character device file ABIs do not make any use of lseek(), pread(), or pwrite(). Therefore use nonseekable_open() and, redundantly, set file_operations.llseek to no_llseek to remove any doubt whether the BKL- grabbing default_llseek handler is used. Although all this is legacy code which should be left in peace until it is eventually removed (as it is superseded by firewire-core's ABI), this change seems still worth doing to further minimize the presence of BKL usage in the kernel. Signed-off-by: Stefan Richter --- drivers/ieee1394/dv1394.c | 11 ++++++----- drivers/ieee1394/raw1394.c | 3 ++- drivers/ieee1394/video1394.c | 5 +++-- 3 files changed, 11 insertions(+), 8 deletions(-) Date: Sat, 10 Apr 2010 16:38:05 +0100 (CET) From: Stefan Richter firewire: cdev: mark char device files as not seekable The character device file ABI (i.e. /dev/fw* character device file interface) does not make any use of lseek(), pread(), pwrite() (or any kind of write() at all). Use nonseekable_open() and, redundantly, set file_operations.llseek to no_llseek to remove any doubt whether the BKL-grabbing default_llseek handler is used. (Also shuffle file_operations initialization according to the order of handler definitions.) Signed-off-by: Stefan Richter --- drivers/firewire/core-cdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) Date: Fri, 2 Apr 2010 14:05:02 +0200 (CEST) From: Stefan Richter firewire: ohci: cleanups and fix for nonstandard build without debug facility 1) Clean up two function names: The ohci_ prefix is only used in names of fw_card_driver hooks. There were two unnecessary exceptions. 2) Replace empty macros by empty inline functions so that call parameter type checking is available in #ifndef'd builds. 3) CONFIG_FIREWIRE_OHCI_DEBUG is currently a hidden kconfig variable, hence is not going to be switched off by anybody. Still, it can be switched off but then compilation will fail in ohci_enable() at the expression param_debug & OHCI_PARAM_DEBUG_BUSRESETS. Add the necessary definitions in the nonstandard case. Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) Date: Sat, 10 Apr 2010 16:04:56 +0200 (CEST) From: Stefan Richter firewire: ohci: wait for PHY register accesses to complete Rather than having the arbitrary msleep(2) pause, let read_phy_reg() loop until the link--phy access was finished. Factor write_phy_reg() out of ohci_update_phy_reg() and of read_paged_phy_reg() and let it loop too until the link--phy access was finished. Like in the older ohci1394 driver, a timeout of 100 milliseconds is chosen. Unlike the old driver, we sleep instead of busy-wait in each waiting loop iteration. Instead of a loop, the waiting could probably also be implemented interrupt driven, but why bother. It would require up and running interrupt handling before the link was fully configured and enabled. Also modify functions a bit: Error return and value return can be combined in read_phy_reg() since the domain of values is only u8. Likewise in read_paged_phy_reg(). Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 112 ++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 55 deletions(-) Date: Thu, 01 Apr 2010 16:43:59 +0200 From: Clemens Ladisch firewire: ohci: fix up configuration of TI chips On TI chips (OHCI-Lynx and later), enable link enhancements features that TI recommends to be used. None of these are required for proper operation, but they are safe and nice to have. In theory, these bits should have been set by default, but in practice, some BIOS/EEPROM writers apparently do not read the datasheet, or get spooked by names like "unfair". Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 19 ++++++++++++++++++- drivers/firewire/ohci.h | 8 ++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) Date: Sun, 04 Apr 2010 15:19:54 +0200 From: "Clemens Ladisch" firewire: ohci: enable 1394a enhancements The OHCI spec says that, if the programPhyEnable bit is set, the driver is responsible for configuring the IEEE1394a enhancements within the PHY and the link consistently. So do this. Also add a quirk to allow disabling these enhancements; this is needed for the TSB12LV22 where ack accelerations are buggy (erratum b). Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/core.h | 4 ++ drivers/firewire/ohci.c | 83 +++++++++++++++++++++++++++++++++++++++- drivers/firewire/ohci.h | 2 3 files changed, 86 insertions(+), 3 deletions(-) Date: Thu, 01 Apr 2010 16:40:18 +0200 From: Clemens Ladisch firewire: ohci: do not clear PHY interrupt status inadvertently The interrupt status bits in PHY register 5 are cleared by writing a one bit. To avoid clearing them unadvertently, do not write them back when they were read as set, but only when they have been explicitly requested to be set. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/core.h | 1 + drivers/firewire/ohci.c | 7 +++++++ 2 files changed, 8 insertions(+) Date: Sun, 04 Apr 2010 15:19:52 +0200 From: "Clemens Ladisch" firewire: ohci: add a function for reading PHY registers Move the register reading code from ohci_update_phy_reg() into a function which can be used separately. Signed-off-by: Clemens Ladisch Signed-off-by: Stefan Richter --- drivers/firewire/ohci.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) Date: Tue, 21 Jul 2009 18:45:50 +0200 From: Henrik Kurelid firedtv: correct version number and current/next in CA_PMT The version number in the CA_PMT message sent to the hardware was alwaysed set to zero. This could cause problems if the PMT would change during decryption of a channel since the new CA_PMT would have the same version number as the old. The version number is now copied from the original PMT. Signed-off-by: Henrik Kurelid Signed-off-by: Stefan Richter --- drivers/media/dvb/firewire/firedtv-avc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)