1. 17 4月, 2013 1 次提交
    • D
      Bluetooth: remove unneeded hci_conn_hold/put_device() · fc225c3f
      David Herrmann 提交于
      hci_conn_hold/put_device() is used to control when hci_conn->dev is no
      longer needed and can be deleted from the system. Lets first look how they
      are currently used throughout the code (excluding HIDP!).
      
      All code that uses hci_conn_hold_device() looks like this:
          ...
          hci_conn_hold_device();
          hci_conn_add_sysfs();
          ...
      On the other side, hci_conn_put_device() is exclusively used in
      hci_conn_del().
      
      So, considering that hci_conn_del() must not be called twice (which would
      fail horribly), we know that hci_conn_put_device() is only called _once_
      (which is in hci_conn_del()).
      On the other hand, hci_conn_add_sysfs() must not be called twice, either
      (it would call device_add twice, which breaks the device, see
      drivers/base/core.c). So we know that hci_conn_hold_device() is also
      called only once (it's only called directly before hci_conn_add_sysfs()).
      
      So hold and put are known to be called only once. That means we can safely
      remove them and directly call hci_conn_del_sysfs() in hci_conn_del().
      
      But there is one issue left: HIDP also uses hci_conn_hold/put_device().
      However, this case can be ignored and simply removed as it is totally
      broken. The issue is, the only thing HIDP delays with
      hci_conn_hold_device() is the removal of the hci_conn->dev from sysfs.
      But, the hci_conn device has no mechanism to get notified when its own
      parent (hci_dev) gets removed from sysfs. hci_dev_hold/put() does _not_
      control when it is removed but only when the device object is created
      and destroyed.
      And hci_dev calls hci_conn_flush_*() when it removes itself from sysfs,
      which itself causes hci_conn_del() to be called, but it does _not_ cause
      hci_conn_del_sysfs() to be called, which is wrong.
      
      Hence, we fix it to call hci_conn_del_sysfs() in hci_conn_del(). This
      guarantees that a hci_conn object is removed from sysfs _before_ its
      parent hci_dev is removed.
      
      The changes to HIDP look scary, wrong and broken. However, if you look at
      the HIDP session management, you will notice they're already broken in the
      exact _same_ way (ever tried "unplugging" HIDP devices? Breaks _all_ the
      time).
      So this patch only makes HIDP look _scary_ and _obviously broken_. It does
      not break HIDP itself, it already is!
      
      See later patches in this series which fix HIDP to use proper
      session-management.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Acked-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NGustavo Padovan <gustavo.padovan@collabora.co.uk>
      fc225c3f
  2. 12 4月, 2013 2 次提交
    • C
      Bluetooth: Fix SCO connection reference · ea323c11
      Claudio Takahasi 提交于
      This patch fixes decrementing SCO connection reference right after
      stablishing the SCO connection with defer setup enabled. The dump below
      shows a disconnection command with handle 0, the connection is still in
      BT_CONNECT2 state and there isn't a handle associated with it.
      
      < HCI Command: Accept Synchronous Connection (0x01|0x0029) plen 21
        bdaddr 78:47:1D:B3:72:6C
      > HCI Event: Command Status (0x0f) plen 4
        Accept Synchronous Connection (0x01|0x0029) status 0x00 ncmd 1
      < HCI Command: Disconnect (0x01|0x0006) plen 3
        handle 0 reason 0x13
        Reason: Remote User Terminated Connection
      > HCI Event: Command Status (0x0f) plen 4
        Disconnect (0x01|0x0006) status 0x00 ncmd 1
      > HCI Event: Synchronous Connect Complete (0x2c) plen 17
        status 0x00 handle 46 bdaddr 78:47:1D:B3:72:6C
        type eSCO
        Air mode: CVSD
      < SCO data: handle 46 flags 0x00 dlen 48
      Signed-off-by: NClaudio Takahasi <claudio.takahasi@openbossa.org>
      Signed-off-by: NVinicius Costa Gomes <vinicius.gomes@openbossa.org>
      Signed-off-by: NGustavo Padovan <gustavo.padovan@collabora.co.uk>
      ea323c11
    • D
      Bluetooth: rename hci_conn_put to hci_conn_drop · 76a68ba0
      David Herrmann 提交于
      We use _get() and _put() for device ref-counting in the kernel. However,
      hci_conn_put() is _not_ used for ref-counting, hence, rename it to
      hci_conn_drop() so we can later fix ref-counting and introduce
      hci_conn_put().
      
      hci_conn_hold() and hci_conn_put() are currently used to manage how long a
      connection should be held alive. When the last user drops the connection,
      we spawn a delayed work that performs the disconnect. Obviously, this has
      nothing to do with ref-counting for the _object_ but rather for the
      keep-alive of the connection.
      
      But we really _need_ proper ref-counting for the _object_ to allow
      connection-users like rfcomm-tty, HIDP or others.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Acked-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NGustavo Padovan <gustavo.padovan@collabora.co.uk>
      76a68ba0
  3. 05 4月, 2013 2 次提交
  4. 04 4月, 2013 2 次提交
    • A
      Bluetooth: Fix hci_inquiry ioctl usage · 3e13fa1e
      Andre Guedes 提交于
      Since the HCI request framework was properly fixed, the hci_req_sync
      call, in hci_inquiry, will return as soon as the HCI command completes
      (not the Inquiry procedure). However, in inquiry ioctl implementation,
      we want to sleep the user process until the inquiry procedure finishes.
      
      This patch changes hci_inquiry so, in case the HCI Inquiry command
      was executed successfully, it waits the HCI_INQUIRY flag to be cleared.
      This way, the user process will sleep until the inquiry procedure
      finishes.
      Signed-off-by: NAndre Guedes <andre.guedes@openbossa.org>
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      3e13fa1e
    • A
      Bluetooth: Fix HCI request framework · 33720450
      Andre Guedes 提交于
      Some HCI commands don't send a Command Complete Event once the HCI
      command has completed so they require some special handling from the
      HCI request framework. These HCI commands, however, send a Command
      Status Event to indicate that the command has been received, and
      that the controller is currently performing the task for the command.
      
      So, in order to properly handle those HCI commands, the HCI request
      framework should consider the HCI command has completed once the
      Command Status Event is received.
      
      This way, we fix some issues regarding the Inquiry command support,
      as well as add support for all those HCI commands which would require
      some special handling from the HCI request framework.
      Signed-off-by: NAndre Guedes <andre.guedes@openbossa.org>
      Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
      33720450
  5. 19 3月, 2013 5 次提交
  6. 10 3月, 2013 1 次提交
  7. 08 3月, 2013 5 次提交
  8. 02 2月, 2013 1 次提交
  9. 23 1月, 2013 3 次提交
  10. 10 1月, 2013 1 次提交
    • S
      Bluetooth: Fix sending HCI commands after reset · dbccd791
      Szymon Janc 提交于
      After sending reset command wait for its command complete event before
      sending next command. Some chips sends CC event for command received
      before reset if reset was send before chip replied with CC.
      
      This is also required by specification that host shall not send
      additional HCI commands before receiving CC for reset.
      
      < HCI Command: Reset (0x03|0x0003) plen 0                              [hci0] 18.404612
      > HCI Event: Command Complete (0x0e) plen 4                            [hci0] 18.405850
            Write Extended Inquiry Response (0x03|0x0052) ncmd 1
              Status: Success (0x00)
      < HCI Command: Read Local Supported Features (0x04|0x0003) plen 0      [hci0] 18.406079
      > HCI Event: Command Complete (0x0e) plen 4                            [hci0] 18.407864
            Reset (0x03|0x0003) ncmd 1
              Status: Success (0x00)
      < HCI Command: Read Local Supported Features (0x04|0x0003) plen 0      [hci0] 18.408062
      > HCI Event: Command Complete (0x0e) plen 12                           [hci0] 18.408835
      Signed-off-by: NSzymon Janc <szymon.janc@tieto.com>
      Cc: stable@vger.kernel.org
      Acked-by: NJohan Hedberg <johan.hedberg@intel.com>
      Signed-off-by: NGustavo Padovan <gustavo.padovan@collabora.co.uk>
      dbccd791
  11. 04 12月, 2012 2 次提交
  12. 19 11月, 2012 3 次提交
  13. 02 11月, 2012 11 次提交
  14. 24 10月, 2012 1 次提交