1. 25 2月, 2010 14 次提交
    • S
      firewire: ohci: extend initialization log message · 6fdb2ee2
      Stefan Richter 提交于
      by the number of available isochronous DMA contexts and active quirks
      which is occasionally useful information.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      6fdb2ee2
    • S
      firewire: ohci: fix IR/IT context mask mixup · 4802f16d
      Stefan Richter 提交于
      This bug was present in firewire-ohci since day one:  The number of
      available isochronous receive DMA contexts was mixed up with that of
      available isochronous transmit DMA contexts.
      
      This is harmless on a few chips which offer the same number of contexts
      in both directions, but most chips nowadays implement only the standard
      minimum of 4 IR contexts, but 8 IT contexts.  If a user attempted to run
      a lot of IR contexts at once, results with more than four were therefore
      unpredictable.  I suppose the controller would simply refuse to start
      DMA of any unimplemented context.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      4802f16d
    • S
      firewire: ohci: add module parameter to activate quirk fixes · 3e9cc2f3
      Stefan Richter 提交于
      This way, we can advise users of precompiled kernel packages to test
      existing quirk fixes on chips which have not been listed yet, without
      them having to build a kernel from source.
      
      Note, to use this feature on a machine with more than one controller,
      steps like these are necessary:
      # lspci | grep 1394
      # ls /sys/bus/pci/drivers/firewire_ohci/
      # echo -n "0000:03:02.0" > /sys/bus/pci/drivers/firewire_ohci/unbind
      # echo 2 > /sys/module/firewire_ohci/parameters/quirks
      # echo -n "0000:03:02.0" > /sys/bus/pci/drivers/firewire_ohci/bind
      # echo 0 > /sys/module/firewire_ohci/parameters/quirks
      
      The parameter can also be used to switch off quirk flags that were
      hardwired into firewire-ohci's quirks table.  Simply specify a non-zero
      quirks value but without any known flags, e.g. 0x100.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      3e9cc2f3
    • S
      firewire: ohci: use an ID table for quirks detection · 4a635593
      Stefan Richter 提交于
      We don't have a lot of quirks to take into account (especially since
      dual-buffer IR is out of the picture), but still, a table-based approach
      is more organized than a series of if () clauses.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      4a635593
    • S
      firewire: ohci: reorder struct fw_ohci for better cache efficiency · ecb1cf9c
      Stefan Richter 提交于
      The config_rom struct members are only accessed during relatively
      infrequent self-ID-complete interrupts and only if the local config ROM
      was changed, while the ar_, at_, ir_, it_ members are used very
      frequently during I/O.  Hence move the config_rom members further down.
      
      More importantly, make the huge self_id_buffer member the last one; this
      is only accessed in self-ID-complete interrupts.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      ecb1cf9c
    • S
      firewire: ohci: remove unused dualbuffer IR code · 6498ba04
      Stefan Richter 提交于
      This code was no longer used since 2.6.33, "firewire: ohci: always use
      packet-per-buffer mode for isochronous reception" commit 090699c0.  If
      anybody needs this code in the future for special purposes, it can be
      brought back in.  But it must not be re-enabled by default; drivers
      (kernelspace or userspace drivers) should only get this mode if they
      explicitly request it.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      6498ba04
    • S
      64582298
    • S
      firewire: core: change type of a data buffer · 6e95dea7
      Stefan Richter 提交于
      from array of char to union of structs.  I already used a union to size
      the buffer which holds ioctl arguments; more consequent is to define it
      as an instance of this union in the first place.
      
      Also rename several local variables from "request" to "a"(rgument) since
      the term request can be mistaken to mean a transaction subaction, e.g.
      an instance of struct fw_request.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      6e95dea7
    • S
      firewire: cdev: add more flexible cycle timer ioctl · abfe5a01
      Stefan Richter 提交于
      The system time from CLOCK_REALTIME is not monotonic, hence problematic
      for the main user of the FW_CDEV_IOC_GET_CYCLE_TIMER ioctl.  This issue
      exists in its successor ABI, i.e. raw1394, too.
      http://subversion.ffado.org/ticket/242
      
      We now offer an alternative ioctl which lets the caller choose between
      CLOCK_REALTIME, CLOCK_MONOTONIC, and CLOCK_MONOTONIC_RAW as source of
      the local time, very similar to the clock_gettime libc function.  The
      format of the local time return value matches that of clock_gettime
      (seconds and nanoseconds, instead of a single microseconds value from
      the existing ioctl).
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      abfe5a01
    • S
      firewire: core: rename an internal function · fd6e0c51
      Stefan Richter 提交于
      according to what it really does.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      fd6e0c51
    • S
      firewire: core: fix an information leak · 137d9ebf
      Stefan Richter 提交于
      If a device exposes a sparsely populated configuration ROM,
      firewire-core's sysfs interface and character device file interface
      showed random data in the gaps between config ROM blocks.  Fix this by
      zero-initialization of the config ROM reader's scratch buffer.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      137d9ebf
    • S
      firewire: core: increase stack size of config ROM reader · 58aaa542
      Stefan Richter 提交于
      The stack size of 16 was artificially chosen and may be too small in
      extreme cases.  A device won't be accessible then.
      
      Since it doesn't really matter to the slab allocator whether we ask for
      1088 bytes or 2048 bytes of scratch memory, just allocate 2048 bytes for
      the sum of temporary config ROM image and stack, and we will never ever
      overflow the stack (because there simply can't be more stack items than
      ROM entries).
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      58aaa542
    • S
      firewire: core: don't fail device creation in case of too large config ROM blocks · 2799d5c5
      Stefan Richter 提交于
      It never happened yet, but better safe than sorry:  If a device's config
      ROM contains a block which overlaps the boundary at 0xfffff00007ff, just
      ignore that one block instead of refusing to add the device
      representation.  That way, upper layers (kernelspace or userspace
      drivers) might still be able to use the device to some degree.
      
      That's better than total inaccessibility of the device.  Worse, the core
      would have logged only a generic "giving up on config rom" message which
      could only be debugged by feeding a firewire-ohci debug logging session
      through a config ROM interpreter, IOW would likely remain undiagnosed.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      2799d5c5
    • S
      firewire: core: fix "giving up on config rom" with Panasonic AG-DV2500 · d54423c6
      Stefan Richter 提交于
      The Panasonic AG-DV2500 tape deck contains an invalid entry in its
      configuration ROM root directory:  A leaf pointer with the undefined key
      ID 0 and an offset that points way out of the standard config ROM area.
      This caused firewire-core to dismiss the device with the generic log
      message "giving up on config rom for node id...", after which it was of
      course impossible to access the tape deck with dvgrab or any other
      program.  https://bugzilla.redhat.com/show_bug.cgi?id=449252#c29
      
      The fix is to simply ignore this invalid ROM entry and proceed to read
      the valid rest of the ROM.  There is a catch though:  When the kernel
      later iterates over the ROM, it would be nasty having to check again for
      such too large ROM offsets.  Therefore we manipulate the defective or
      unsupported ROM entry to become a harmless immediate entry that won't
      have any side effects later (an entry with the value 0x00000000).
      
      Reported-by: George Chriss
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      d54423c6
  2. 21 2月, 2010 2 次提交
    • S
      firewire: remove incomplete Bus_Time CSR support · 168cf9af
      Stefan Richter 提交于
      The current implementation of Bus_Time read access was buggy since it
      did not ensure that Bus_Time.second_count_hi and second_count_lo came
      from the same 128 seconds period.
      Reported-by: NHåkan Johansson <f96hajo@chalmers.se>
      
      Instead of a fix, remove Bus_Time register support altogether.  The spec
      requires all cycle master capable nodes to implement this (all Linux
      nodes are cycle master capable) while it also says that it "may" be
      initialized by the bus manager or by the IRM standing in for a bus
      manager.  (Neither Linux' firewire-core nor ieee1394 nodemgr implement
      this.)
      
      Since we cannot rely on Bus_Time having been initialized by a bus
      manager, it is better to return an error instead of a nonsensical value
      on a read request to Bus_Time.
      
      Alternatively, we could fix the Bus_Time read integrity bug _and_
      implement (a) cycle master's write support of the register as well as
      (b) bus manager's Bus_Time initialization service, i.e. preservation of
      the Bus_Time when the cycle master node of a bus changes.  However, that
      would be quite some code for a feature that is unreliable to begin with
      and very likely unused in practice.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      168cf9af
    • S
      firewire: get_cycle_timer optimization and cleanup · 4a9bde9b
      Stefan Richter 提交于
      ohci:  Break out of the retry loop if too many attempts were necessary.
      This may theoretically happen if the chip is fatally defective or if the
      get_cycle_timer ioctl was performed after a CardBus controller was
      ejected.
      
      Also micro-optimize the loop by re-using the last two register reads in
      the next iteration, remove a questionable inline keyword, and shuffle a
      comment around.
      
      core:  ioctl_get_cycle_timer() is always called with interrupts on,
      therefore local_irq_save() can be replaced by local_irq_disable().
      Disabled local IRQs imply disabled preemption, hence preempt_disable()
      can be removed.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      4a9bde9b
  3. 20 2月, 2010 2 次提交
  4. 14 2月, 2010 1 次提交
    • C
      firewire: ohci: retransmit isochronous transmit packets on cycle loss · 7f51a100
      Clemens Ladisch 提交于
      In isochronous transmit DMA descriptors, link the skip address pointer
      back to the descriptor itself.  When a cycle is lost, the controller
      will send the packet in the next cycle, instead of terminating the
      entire DMA program.
      
      There are two reasons for this:
      
      * This behaviour is compatible with the old IEEE1394 stack.  Old
        applications would not expect the DMA program to stop in this case.
      
      * Since the OHCI driver does not report any uncompleted packets, the
        context would stop silently; clients would not have any chance to
        detect and handle this error without a watchdog timer.
      Signed-off-by: NClemens Ladisch <clemens@ladisch.de>
      
      Pieter Palmers notes:
      
      "The reason I added this retry behavior to the old stack is because some
      cards now and then fail to send a packet (e.g. the o2micro card in my
      dell laptop).  I couldn't figure out why exactly this happens, my best
      guess is that the card cannot fetch the payload data on time.  This
      happens much more frequently when sending large packets, which leads me
      to suspect that there are some contention issues with the DMA that fills
      the transmit FIFO.
      
      In the old stack it was a pretty critical issue as it resulted in a
      freeze of the userspace application.
      
      The omission of a packet doesn't necessarily have to be an issue.  E.g.
      in IEC61883 streams the DBC field can be used to detect discontinuities
      in the stream.  So as long as the other side doesn't bail when no
      [packet] is present in a cycle, there is not really a problem.
      
      I'm not convinced though that retrying is the proper solution, but it is
      simple and effective for what it had to do.  And I think there are no
      reasons not to do it this way.  Userspace can still detect this by
      checking the cycle the descriptor was sent in."
      
      Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> (changelog, comment)
      7f51a100
  5. 02 2月, 2010 1 次提交
    • S
      firewire: net: fix panic in fwnet_write_complete · 110f82d7
      Stefan Richter 提交于
      In the transmit path of firewire-net (IPv4 over 1394), the following
      race condition may occur:
        - The networking soft IRQ inserts a datagram into the 1394 async
          request transmit DMA.
        - The 1394 async transmit completion tasklet runs to finish cleaning
          up (unlink datagram from list of pending ones, release skb and
          outbound 1394 transaction object) --- before the networking soft IRQ
          had a chance to proceed and add the datagram to the list of pending
          datagrams.
      
      This caused a panic in the 1394 async transmit completion tasklet when
      it dereferenced unitialized list heads:
      http://bugzilla.kernel.org/show_bug.cgi?id=15077
      
      The fix is to add checks in the tx soft IRQ and in the tasklet to
      determine which of these two is the last referrer to the transaction
      object.  Then handle the cleanup of the object by the last referrer
      rather than assuming that the tasklet is always the last one.
      
      There is another similar race:  Between said tasklet and fwnet_close,
      i.e. at ifdown.  However, that race is much less likely to occur in
      practice and shall be fixed in a separate update.
      Reported-by: NИлья Басин <basinilya@gmail.com>
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      110f82d7
  6. 28 1月, 2010 1 次提交
  7. 27 1月, 2010 2 次提交
    • S
      firewire: core: fix use-after-free regression in FCP handler · 281e2032
      Stefan Richter 提交于
      Commit db5d247a "firewire: fix use of multiple AV/C devices, allow
      multiple FCP listeners" introduced a regression into 2.6.33-rc3:
      The core freed payloads of incoming requests to FCP_Request or
      FCP_Response before a userspace driver accessed them.
      
      We need to copy such payloads for each registered userspace client
      and free the copies according to the lifetime rules of non-FCP client
      request resources.
      
      (This could possibly be optimized by reference counts instead of
      copies.)
      
      The presently only kernelspace driver which listens for FCP requests,
      firedtv, was not affected because it already copies FCP frames into an
      own buffer before returning to firewire-core's FCP handler dispatcher.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      281e2032
    • S
      firewire: core: add_descriptor size check · e300839d
      Stefan Richter 提交于
      Presently, firewire-core only checks whether descriptors that are to be
      added by userspace drivers to the local node's config ROM do not exceed
      a size of 256 quadlets.  However, the sum of the bare minimum ROM plus
      all descriptors (from firewire-core, from firewire-net, from userspace)
      must not exceed 256 quadlets.
      
      Otherwise, the bounds of a statically allocated buffer will be
      overwritten.  If the kernel survives that, firewire-core will
      subsequently be unable to parse the local node's config ROM.
      
      (Note, userspace drivers can add descriptors only through device files
      of local nodes.  These are usually only accessible by root, unlike
      device files of remote nodes which may be accessible to lesser
      privileged users.)
      
      Therefore add a test which takes the actual present and required ROM
      size into account for all descriptors of kernelspace and userspace
      drivers.
      
      Cc: stable@kernel.org
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      e300839d
  8. 11 1月, 2010 1 次提交
  9. 30 12月, 2009 7 次提交
    • S
      firewire: qualify config ROM cache pointers as const pointers · 13b302d0
      Stefan Richter 提交于
      Several config ROM related functions only peek at the ROM cache; mark
      their arguments as const pointers.  Ditto fw_device.config_rom and
      fw_unit.directory, as the memory behind them is meant to be write-once.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      13b302d0
    • S
      firewire, ieee1394: update Kconfig help · 5d7db049
      Stefan Richter 提交于
      Update the Kconfig help texts of both stacks to encourage a general move
      from the older to the newer drivers.  However, do not label ieee1394 as
      "Obsolete" yet, as the newer drivers have not been deployed as default
      stack in the majority of Linux distributions yet, and those who start
      doing so now may still want to install the old drivers as fallback for
      unforeseen issues.
      
      Since Linux 2.6.32, FireWire audio devices can be driven by the newer
      firewire driver stack too, hence remove an outdated comment about audio
      devices.  Also remove comments about library versions since the 2nd
      generation of libraw1394 and libdc1394 is now in common use; details on
      library versions can be read at the wiki link from the help texts.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      5d7db049
    • S
      firewire: core: fw_csr_string addendum · 3c2c58cb
      Stefan Richter 提交于
      Witespace and comment changes, and a different way to say i + 1 < end.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      3c2c58cb
    • C
      firewire: add fw_csr_string() helper function · 1f8fef7b
      Clemens Ladisch 提交于
      The core (sysfs attributes), the firedtv driver, and possible future
      drivers all read strings from some configuration ROM directory.  Factor
      out the generic code from show_text_leaf() into a new helper function,
      modified slightly to handle arbitrary buffer sizes.
      Signed-off-by: NClemens Ladisch <clemens@ladisch.de>
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      1f8fef7b
    • S
      firewire: ohci: always use packet-per-buffer mode for isochronous reception · 090699c0
      Stefan Richter 提交于
      This is a minimal change meant for the short term:  Never set the
      ohci->use_dualbuffer flag to true.
      
      There are two reasons to do so:
      
        - Packet-per-buffer mode and dual-buffer mode do not behave the same
          under certain circumstances, notably if several packets are covered
          by a single fw_cdev_iso_packet descriptor.
          http://marc.info/?l=linux1394-devel&m=124965653718313
          Therefore the driver stack should not silently choose one or the
          other mode but should leave the choice to the high-level driver
          (regardless if kernel driver or userspace driver).  Or simply always
          only offer packet-per-buffer mode, since a considerable number of
          controllers, even current ones, does not offer dual-buffer support.
      
        - Even under circumstances where packet-per-buffer mode and
          dual-buffer mode behave exactly the same --- notably when used
          through libraw1394, libdc1394, as well as the current two kernel
          drivers which use isochronous reception (firewire-net and firedtv)
          --- we are still faced with the problem that several OHCI 1.1
          controllers have bugs in dual-buffer mode.  Although it looks like
          we have identified most of those buggy controllers by now, we
          cannot be quite sure about that.
      
      So, use packet-per-buffer by default from now on.  This change should
      be followed up by a more complete solution:  Either extend the
      in-kernel API and the userspace ABI by a choice between the two IR modes
      or remove all dual-buffer related code from firewire-ohci.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      090699c0
    • S
      firewire: cdev: fix another memory leak in an error path · cf0e575d
      Stefan Richter 提交于
      If copy_from_user in an FW_CDEV_IOC_SEND_RESPONSE ioctl failed, the
      fw_request pointed to by the inbound_transaction_resource is no
      longer referenced and needs to be freed.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      cf0e575d
    • C
      firewire: fix use of multiple AV/C devices, allow multiple FCP listeners · db5d247a
      Clemens Ladisch 提交于
      Control of more than one AV/C device at once --- e.g. camcorders, tape
      decks, audio devices, TV tuners --- failed or worked only unreliably,
      depending on driver implementation.  This affected kernelspace and
      userspace drivers alike and was caused by firewire-core's inability to
      accept multiple registrations of FCP listeners.
      
      The fix allows multiple address handlers to be registered for the FCP
      command and response registers.  When a request for these registers is
      received, all handlers are invoked, and the Firewire response is
      generated by the core and not by any handler.
      
      The cdev API does not change, i.e., userspace is still expected to send
      a response for FCP requests; this response is silently ignored.
      Signed-off-by: NClemens Ladisch <clemens@ladisch.de>
      Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> (changelog, rebased, whitespace)
      db5d247a
  10. 12 12月, 2009 1 次提交
  11. 04 12月, 2009 1 次提交
  12. 21 11月, 2009 1 次提交
    • J
      firewire: ohci: pass correct iso xmit timestamps to core · 31769cef
      Jay Fenlason 提交于
      Here is the final set of patches I used to get ffado to work with the
      new firewire stack.  With these patches, I was able to start ardour
      and record from and playback to my PreSonus Inspire1394 from a
      (mostly) Fedora 12 system.
      Signed-off-by: NJay Fenlason <fenlason@redhat.com>
      
      Until now, firewire-ohci exposed only the transmit cycle of the last
      transmitted packet at each isochronous transmit complete event.  This
      made it impossible for FFADO (FireWire audio drivers in userspace) to
      synchronize audio-out streams.  The fix is to store the timestamp of
      each packet in the iso xmit event.  As a bonus, the transfer status is
      stored too.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      31769cef
  13. 19 11月, 2009 1 次提交
    • J
      firewire: ohci: Make cycleMatch ISO transmission work · 5ed1f321
      Jay Fenlason 提交于
      Calling the START_ISO ioctl with a nonnegative cycle paramater has
      never worked.  Last night I got around to figuring out why.  Most of
      this patch is a big comment explaining why we enable an interrupt
      source then don't actually do anything when we get one.  As the
      comment says, we should do more, but we don't have a way to tell
      userspace what happened. . .
      Signed-off-by: NJay Fenlason <fenlason@redhat.com>
      Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> (edited comment)
      5ed1f321
  14. 31 10月, 2009 3 次提交
  15. 15 10月, 2009 2 次提交
    • S
      firewire: core: optimize Topology Map creation · cb7c96da
      Stefan Richter 提交于
      The Topology Map of the local node was created in CPU byte order,
      then a temporary big endian copy was created to compute the CRC,
      and when a read request to the Topology Map arrived it had to be
      converted to big endian byte order again.
      
      We now generate it in big endian byte order in the first place.
      This also rids us of 1000 bytes stack usage in tasklet context.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      cb7c96da
    • S
      firewire: core: clarify generate_config_rom usage · fe242579
      Stefan Richter 提交于
      Move the static config ROM buffer into the scope of the two callers of
      generate_config_rom().  That way the ROM length can be passed over as
      return value rather than through a pointer argument.
      
      It also becomes more obvious that accesses to the config ROM buffer have
      to be serialized and how this is accomplished.  And firewire-core.ko
      shrinks a bit as well.
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      fe242579