1. 21 6月, 2010 5 次提交
    • S
      firewire: cdev: freeze FW_CDEV_VERSION due to libraw1394 bug · 604f4516
      Stefan Richter 提交于
      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: NStefan Richter <stefanr@s5r6.in-berlin.de>
      604f4516
    • S
      firewire: cdev: count references of cards during inbound transactions · 0244f573
      Stefan Richter 提交于
      If a request comes in to an address range managed by a userspace driver
      i.e. <linux/firewire-cdev.h> 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: NStefan Richter <stefanr@s5r6.in-berlin.de>
      0244f573
    • J
      firewire: cdev: fix responses to nodes at different card · 08bd34c9
      Jay Fenlason 提交于
      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: NJay Fenlason <fenlason@redhat.com>
      
      Reference counting to be addressed in a separate change.
      
      Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> (whitespace)
      08bd34c9
    • C
      firewire: cdev: fix race in iso context creation · bdfe273e
      Clemens Ladisch 提交于
      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: NClemens Ladisch <clemens@ladisch.de>
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      bdfe273e
    • S
      firewire: remove an unused function argument · 33e553fe
      Stefan Richter 提交于
      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: NStefan Richter <stefanr@s5r6.in-berlin.de>
      33e553fe
  2. 20 6月, 2010 1 次提交
  3. 19 6月, 2010 8 次提交
    • S
      firewire: core: remove unused variable · ae86e81e
      Stefan Richter 提交于
      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: NJustin P. Mattock <justinmattock@gmail.com>
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      ae86e81e
    • S
      ieee1394: remove unused variables · 5030c807
      Stefan Richter 提交于
      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: NJustin P. Mattock <justinmattock@gmail.com>
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      5030c807
    • S
      firewire: rename CSR access driver methods · 0fcff4e3
      Stefan Richter 提交于
      Rather than "read a Control and Status Registers (CSR) Architecture
      register" I prefer to say "read a Control and Status Register".
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      0fcff4e3
    • S
      firewire: core: combine some repeated code · b384cf18
      Stefan Richter 提交于
      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: NStefan Richter <stefanr@s5r6.in-berlin.de>
      b384cf18
    • S
      firewire: normalize STATE_CLEAR/SET CSR access interface · c8a94ded
      Stefan Richter 提交于
      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: NStefan Richter <stefanr@s5r6.in-berlin.de>
      c8a94ded
    • S
      firewire: replace get_features card driver hook · db3c9cc1
      Stefan Richter 提交于
      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: NStefan Richter <stefanr@s5r6.in-berlin.de>
      db3c9cc1
    • S
      firewire: drop sizeof expressions from some request size arguments · e847cc83
      Stefan Richter 提交于
      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: NStefan Richter <stefanr@s5r6.in-berlin.de>
      e847cc83
    • S
      firewire: 'add CSR_... support' addendum · 65b2742a
      Stefan Richter 提交于
      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: NStefan Richter <stefanr@s5r6.in-berlin.de>
      65b2742a
  4. 10 6月, 2010 20 次提交
  5. 01 6月, 2010 1 次提交
  6. 26 5月, 2010 1 次提交
    • S
      ieee1394: schedule for removal · 3014420b
      Stefan Richter 提交于
      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: NStefan Richter <stefanr@s5r6.in-berlin.de>
      Acked-by: NJarod Wilson <jarod@redhat.com>
      3014420b
  7. 19 5月, 2010 2 次提交
  8. 20 4月, 2010 2 次提交
    • C
      firewire: core: make transaction label allocation more robust · 7906054f
      Clemens Ladisch 提交于
      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: NClemens Ladisch <clemens@ladisch.de>
      Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
      7906054f
    • S
      firewire: core: clean up config ROM related defined constants · edd5bdaf
      Stefan Richter 提交于
      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: NStefan Richter <stefanr@s5r6.in-berlin.de>
      edd5bdaf