Commit Graph

1645 Commits

Author SHA1 Message Date
Brian Gix
f5bca82175 Bluetooth: prevent dup DISCOVERY_STOP's pending
It is possible to redundently request Discovery
operations.  This fix cleans up some stored state to
prevent MGMT event overload when discovery finally completes.

Change-Id: I2ffb5c0749df95e40cd39e8c64c87a62a93fb896
CRs-fixed: 329657
Signed-off-by: Brian Gix <bgix@codeaurora.org>
2013-02-25 11:38:55 -08:00
Srinivas Krovvidi
6fefa46cee Bluetooth: Reading remote device lmp_version from controller.
On ACL connection complete with a remote device, the remote
device lmp version should be available with Controller. The
current change is to read this information from controller to
host and update to bluez userspace through management APIs.

Change-Id: Ie152ed98fa0a6cf9ab170a6bb8c6a05b5b9dfcb0
Signed-off-by: Srinivas Krovvidi <skrovvid@codeaurora.org>
2013-02-25 11:38:54 -08:00
Mat Martineau
b3d0386b2f Bluetooth: Fix timeout configuration for AMP channels
When doing L2CAP configuration, use the correct retransmit and monitor
timeouts when configuring (or reconfiguring) AMP channels. The host
stack needs to use the timeouts read from incoming configuration
responses, and write appropriate timeouts when sending configuration
responses.

Change-Id: I1271ade93dbfee58a1cac115280704a327e901b2
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
2013-02-25 11:38:54 -08:00
Brian Gix
a0bfd58531 Bluetooth: Discovery Timer stability fixes
This change prevents running timers from being re-initialized
which causes system instablility. Also prevents starting a
discovery operation when already in progress.

CRs-fixed: 328673
Change-Id: Icda36a25fdcb40dab4f95f9cc39ca124b299e308
Signed-off-by: Brian Gix <bgix@codeaurora.org>
2013-02-25 11:38:53 -08:00
Srinivas Krovvidi
ea33fe6962 Bluetooth: Support for writing hci flush timeout parameter.
Added Flush Timeout parameter setting for l2cap channel. Bluetooth
profiles using l2cap can set this parameter to flush out the data
when it cannot be sent over the air with in timeout duration.

Change-Id: I60420c5be3a790aff26bc30e8089fdca47a99222
Signed-off-by: Srinivas Krovvidi <skrovvid@codeaurora.org>
2013-02-25 11:38:52 -08:00
Brian Gix
e91d8317a1 Bluetooth: Explicitly stop all timers before frees
As a preventative measure, timers on dynamic memory structures must be
not running, or stopped, prior to freeing. Since it is safe to delete
timers whether running or not, all timers are deleted.

CRs-fixed: 328673
Change-Id: I255d99cb2419fad07caf445920050cf2d05ffe4d
Signed-off-by: Brian Gix <bgix@codeaurora.org>
2013-02-25 11:38:51 -08:00
Mat Martineau
e8b0b4033e Bluetooth: Fix HCI channel reference counting
When an incoming HCI logical link event came in at the same time
a socket structure was deleted, it was possible to end up with a stale
pointer to the socket.  The socket and associated HCI channel struct
need to be properly reference counted so they are not freed
prematurely.

CRs-Fixed: 325023
Change-Id: Ia5724a9ce2000acd60a174c354be04029bac5324
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
2013-02-25 11:38:50 -08:00
Rahul Kashyap
62b2bac8ca Bluetooth: Initialize incoming connection link policy
Upon properly initializing the incoming connection
link policy, the link is able to enter sniff mode.

CRs-fixed: 327571
Change-Id: Ib21c09234f823f011aad158ae232f3060085183e
Signed-off-by: Rahul Kashyap <rkashyap@codeaurora.org>
2013-02-25 11:38:49 -08:00
Srinivas Krovvidi
94010817b9 Bluetooth: Management API changes in Bluetooth to update remote Class.
When connection initiated from the remote device the class of device
information is required to be updated to userspace through this
event.

Change-Id: I97d715a0b80e12d414ecf03d099955c8b12c82b4
Signed-off-by: Srinivas Krovvidi <skrovvid@codeaurora.org>
2013-02-25 11:38:48 -08:00
Mat Martineau
2bf7a110c1 Bluetooth: Update ERTM state before sending packets
Since l2cap_ertm_send() runs in process context, it may be preempted
by incoming data being processed in tasklet context.  In order to
avoid race conditions where a packet is acknowledged before the
transmit queue is properly updated, ERTM state should be set up for
the next transmit before the packet is actually sent.

CRs-fixed: 326238
Change-Id: I3df0e93118a357dbd34ff26ad74d7c0c38bf5121
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
2013-02-25 11:38:48 -08:00
Bhasker Neti
709b462d6f Bluetooth: Send power off notification earlier in the device close process
Notifying Bluez userspace of a shutdown earlier prevents new commands from
being sent. The extra commands were interfering with reinitialization of
the device

Change-Id: I862a658585ffa69348fbb4bdfba96f3916d0e5ef
Signed-off-by: Bhasker Neti <bneti@codeaurora.org>
2013-02-25 11:38:47 -08:00
Mat Martineau
4989e57511 Bluetooth: Clear sk_send_head when purging ERTM transmit queue
In ERTM, the outgoing data queue contains both unsent data and unacked
data, and sk_send_head points to the first unsent packet. When
disconnecting a socket, it's possible for a process to attempt a
socket send while a disconnection is in progress and the outgoing data
queue has been purged. When this purge happens, sk_send_head must also
be set to NULL because the packet it was pointing to has been freed.

Change-Id: I87b37a13583fac705241549dfc492950c7c0ec0b
CRs-fixed: 326238
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
2013-02-25 11:38:46 -08:00
AnubhavGupta
1361551474 Bluetooth: Schedule HCI_TX task after connection cleanup
After ACL  disconnection and removal of pending acl
acknowledgement, we have to schedule HCI_TX task. This will
allow other active connection to send ACL packets.

Change-Id: I3ddf61a3c7ff149b05e963159e10af0ab6ef6143
Signed-off-by: AnubhavGupta <anubhavg@codeaurora.org>
2013-02-25 11:38:45 -08:00
Bhakthavatsala Raghavendra
48a39fa02b Bluetooth: Setting security level based on remote device capabilities
Security level will be set to MEDIUM in case where the remote device
is 2.0 device. This would prevent it from going to 16 digit pairing
in case where the remote device sends the EIR and still doesn't
support SSP

CRs-fixed: 318469
Change-Id: I9d03b2b628cc188de44f44cfc3f8e81fbf3cb79d
Signed-off-by: Bhakthavatsala Raghavendra <braghave@codeaurora.org>
2013-02-25 11:38:44 -08:00
Mat Martineau
083a77e14b Bluetooth: Check for skb copy/clone failures
During normal ERTM sends and resends, buffers are copied or cloned.
If the copy/clone fails, take sensible action rather than causing a
kernel panic.

Change-Id: Ib491cfb38dab30014ed08571dbd721dad0cc3714
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
2013-02-25 11:38:43 -08:00
Peter Krystad
8f3273f187 Bluetooth: Check for possible divide by zero
Change-Id: Iee0bdf14f9fe7bfbe21e5344ec407356b23a69f4
CRs-fixed: 319934
Signed-off-by: Peter Krystad <pkrystad@codeaurora.org>
2013-02-25 11:38:42 -08:00
Peter Krystad
f349a2f099 Bluetooth: Fix possible access of hci_chan after it is deleted
When the connection is not in BT_CONNECTED state it was possible
for code in hci_chan_modify() to attempt to access the hci_chan
structure after it had already been deleted by hci_chan_put().

Change-Id: I5ae352ac12aa3b456e7bcf30633015d98b03e44b
CRs-fixed: 319934
Signed-off-by: Peter Krystad <pkrystad@codeaurora.org>
2013-02-25 11:38:41 -08:00
Mat Martineau
a8905386f2 Bluetooth: Use correct endianness in L2CAP configuration fallback
Default RFC values should use le16 byte ordering. These values are
used only as a fallback when poorly-behaved remote devices do not send
a proper RFC option in an ERTM or streaming configuration response.

Change-Id: I51c9ae892f18229f568b354c92b64e3a8054b619
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
2013-02-25 11:38:40 -08:00
Peter Hurley
cb3cbaf984 Bluetooth: bnep: Fix deadlock in session deletion
Commit f4d7cd4a4c introduced the usage of kthread API.
kthread_stop is a blocking function which returns only when
the thread exits. In this case, the thread can't exit because it's
waiting for the write lock, which is being held by bnep_del_connection()
which is waiting for the thread to exit -- deadlock.

Use atomic_t/wake_up_process instead to signal to the thread to exit.

Change-Id: I538cd17c102cb31b3212c794086a9c2baedb4b14
Signed-off-by: Jaikumar Ganesh <jaikumar@google.com>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
[skrovvid@codeaurora.org: kthread_should_stop api call is avoided]
Signed-off-by: Srinivas Krovvidi <skrovvid@codeaurora.org>
2013-02-25 11:38:40 -08:00
Peter Krystad
0e7ab77b55 Bluetooth: Do not disconnect channel before failover complete
When the logical link disconnects clear the reference to the
l2cap connection before moving the channel. This prevents the
channel from being disconnected before failover to BR-EDR is
complete.

Change-Id: Id55a472a8dac49fbfca4fa47cffea59acf76ed1f
Signed-off-by: Peter Krystad <pkrystad@codeaurora.org>
CRs-fixed: 321202
2013-02-25 11:38:39 -08:00
Brian Gix
387921f639 Bluetooth: Move Discovery timers to hci_dev struct
To prevent timers from expiring on potentiatially free'd dynamic memory.

Change-Id: I8b9685150bcee72fa7ca71b221bc54b54516021e
Signed-off-by: Brian Gix <bgix@codeaurora.org>
2013-02-25 11:38:38 -08:00
Subramanian Srinivasan
3c5ce6e5cb Bluetooth: Avoid deadlock in management ops code
Fixes a deadlock issue due to spinlock being acquired
first in the process context and followed by a second
acquisition in the interrupt context

CRs-fixed: 319052
Change-Id: If17be9fa6f020dd1abd248f8999c2614251fc509
Signed-off-by: Subramanian Srinivasan <subrsrin@codeaurora.org>
2013-02-25 11:38:37 -08:00
Prabhakaran Mc
17c20ba4e9 Bluetooth: changes to implement mgmt_encrypt_link procedure
mgmt_encrypt_link procedure is added by implementing
MGMT_OP_ENCRYPT_LINK and MGMT_EV_ENCRYPT_CHANGE

Change-Id: Ibed6e24c67bbea83318a67c636e02a93518de29d
Signed-off-by: Prabhakaran Mc <prabhakaranmc@codeaurora.org>
2013-02-25 11:38:36 -08:00
Mat Martineau
3daabeaa61 Bluetooth: Use default RFC values if none received
A well-behaved remote device should always send a reconfiguration and
flow control (RFC) option in the configuration response when using
ERTM or Streaming mode.  By using default RFC option values, the
configuration code can avoid using uninitialized data.

Change-Id: I8f9ef687b694d0b34c6d65d40b934bc7946d515e
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
2013-02-25 11:38:35 -08:00
Peter Krystad
bd53fa1368 Bluetooth: Use hci dev number as AMP controller ID
Previously an offset was added to the hci dev number to generate the
AMP controller ID, because it was possible for the PAL to register
as hci0, and 0 is invalid for an AMP controller ID. Since this commit
462bf76d294a480c775a040476bd7eb81f718ec2 it is not possible for
the PAL to register as hci0, so this offset is no longer necessary.

Change-Id: I4b01ddca5fad3aebeb4c138b5aee8819bb146f3d
Signed-off-by: Peter Krystad <pkrystad@codeaurora.org>
2013-02-25 11:38:34 -08:00
Peter Krystad
3f1b7befbd Bluetooth: Release module reference counts
In three places a reference was taken without being returned.

Change-Id: I15b9ab7de530a77832d8b10fe756cfdf0b01760f
Signed-off-by: Peter Krystad <pkrystad@codeaurora.org>
2013-02-25 11:38:34 -08:00
Brian Gix
335c44f045 Bluetooth: Fix erroneous Pairing Failure condition
When local device is done sending LE pairing keys, it should not
be sending a pairing failure event to User space.

Change-Id: I49d77040e8f72567c0c7ece053aa58227c87a0f0
Signed-off-by: Brian Gix <bgix@codeaurora.org>
2013-02-25 11:38:33 -08:00
Mat Martineau
0c6e7f02a5 Bluetooth: Keep persistent hdev flags after the device is closed.
Change-Id: Ifb9ccf93be53f2f3e6bb7773b4d39a6328dce73f
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
2013-02-25 11:38:32 -08:00
Mat Martineau
a17e839acb Bluetooth: Clear RFCOMM session timer when disconnecting last channel
When the last RFCOMM data channel is closed, a timer is normally set
up to disconnect the control channel at a later time.  If the control
channel disconnect command is sent with the timer pending, the timer
needs to be cancelled.

If the timer is not cancelled in this situation, the reference
counting logic for the RFCOMM session does not work correctly when the
remote device closes the L2CAP connection.  The session is freed at
the wrong time, leading to a kernel panic.

CRs-fixed: 317859
Change-Id: I778fdf8dbff8afe0a1c157b02d39872262088584
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
2013-02-25 11:38:31 -08:00
Peter Krystad
cc2c4bc328 Bluetooth: Remove _bh locking for AMP Manager
Since all AMP Manager processing is done on work queues no
bottom-half locking is required.

CRs-fixed: 318632
Change-Id: I3a07c412ccf30d62d68cc80124fad5700bcc0917
Signed-off-by: Peter Krystad <pkrystad@codeaurora.org>
2013-02-25 11:38:30 -08:00
Brian Gix
5fe493aaf9 Bluetooth: Allow auto-accept if remote NoInNoOut
If we initiated a Dedicated pairing, and the remote device
is a NoInputNoOutput capable device, allow auto-acceptance
of pairing.

Change-Id: Ia5cc3e3d458cee98aef0493a423d29e9955638c3
CRs-fixed: 318144
Signed-off-by: Brian Gix <bgix@codeaurora.org>
2013-02-25 11:38:29 -08:00
Brian Gix
145f2334b6 Bluetooth: Fix Init sequence when device is restarted
On some platforms, device state data can be left around, and some
commands may take longer than 1 second to execute. This change increases
the per command time-out, and reinitializes the features mask.

Change-Id: Ib707996b97139c97e9a0deacd4a11019cf75da8c
Signed-off-by: Brian Gix <bgix@codeaurora.org>
2013-02-25 11:38:28 -08:00
Brian Gix
3fb0b0ba88 Bluetooth: Add API to set LE Connection Parameters
Include auto-setting connection parameters during Pairing for
low latenecy, and default (high latency) settings for non-Pairing
connections.

Change-Id: Ie8e3f65da52213451dcc01fce38d95ae07d1b13b
Signed-off-by: Brian Gix <bgix@codeaurora.org>
2013-02-25 11:38:27 -08:00
Mat Martineau
bad519927b Bluetooth: Use proper sock reference counting in L2CAP
A socket can be shut down while pointer to that socket is stored in a
queued skbuff or in a pending workqueue struct. Correct use of socket
reference counting will make sure the socket struct stays around until
there are no remaining references.

Change-Id: Ic3679e023a46b224929b3cefb6370d7871e3368a
CRs-fixed: 313736
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
2013-02-25 11:38:27 -08:00
Royston Rodrigues
cab30986ca Bluetooth: EIR to carry update local device name.
Whenever local device name is changed, EIR payload
is updated with the modified local device name.

CRs-fixed: 314228
Change-Id: Ib2ec05b6ac4f4a55612716f0567ee04056579ed6
Signed-off-by: Royston Rodrigues <roystonr@codeaurora.org>
2013-02-25 11:38:26 -08:00
Mat Martineau
90e0ae6107 Bluetooth: Align socket option definitions with upstream kernel
The upstream kernel has acquired new BT socket options since
BT_AMP_POLICY was first defined, now BT_FLUSHABLE is option 8 and
BT_POWER is option 9.  It will save us some future pain if we align
with upstream code now and make BT_AMP_POLICY be option 10.

In addition, the option values for BT_AMP_POLICY were changed during
the upstreaming process.

CRs-fixed: 313757
Change-Id: Ia31e9c8cfd5207a6dd44e40a605d3021f5ce9fd9
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
2013-02-25 11:38:25 -08:00
Brian Gix
064afd8708 Bluetooth: Cache LE Address Type with LTK, and use for reconnections
LE-Only devices require that an Address Type (Public or Random) be
included in Connection Requests. This info is available at Pairing
but must be cached so that it is available at reconnection time.
This change includes the Address type with the Pairing data.

Change-Id: I50c78ad31d8be70f5c3f49a0529039e4a26daaac
Signed-off-by: Brian Gix <bgix@codeaurora.org>
2013-02-25 11:38:24 -08:00
Brian Gix
260dc21726 Bluetooth: Don't use incomplete LE LTKs to secure link
If LE link gets terminated during the pairing process, it
may leave SMP with half of a Long Term Key. This fix ensures
that this partial information is not used for future links.

Change-Id: Ib834fc81d7b4b558cc3d242522acef80dd1d8827
Signed-off-by: Brian Gix <bgix@codeaurora.org>
2013-02-25 11:38:23 -08:00
Peter Krystad
129db6fdb3 Bluetooth: Check that remote supports A2MP before creating channel
Before attempting to create a channel directly on an AMP check
that the remote device supports A2MP signalling before starting
the physical link creation process.

Change-Id: Iac2bcebf9630368685e24e636e39ffa82651705d
Signed-off-by: Peter Krystad <pkrystad@codeaurora.org>
2013-02-25 11:38:21 -08:00
Brian Gix
8d6e23ed66 Bluetooth: Generate generic Fails for undeliverable ATT messages
Change-Id: I04f9ec62b15abb090cb90d81442a83caf8caa447
Signed-off-by: Brian Gix <bgix@codeaurora.org>
2013-02-25 11:38:21 -08:00
Brian Gix
caeb7623c8 Bluetooth: Fix Limited Discoverability for MGMTOPS
CRs-fixed: 309551
Change-Id: I42c46c62dcb4b227d9ac48146ee61cb52063a6ae
Signed-off-by: Brian Gix <bgix@codeaurora.org>
2013-02-25 11:38:20 -08:00
Brian Gix
bd7586d763 Bluetooth: Fix error returned to bluez on LE Pairing Failure
Change-Id: I1e7908e133d53b41bdd58a54a2e293526e96e160
Signed-off-by: Brian Gix <bgix@codeaurora.org>
2013-02-25 11:38:19 -08:00
Brian Gix
82c88a73d9 Bluetooth: Fix LE pairing scenarios when initiated remotely
Fix setting of ENCRYPTION_PENDING and Connection refcnt's that could
be out of sync due to remote slave issued security requests.

Change-Id: Ie72abd0648182db0ef60693820139f40ef2e4bf6
Signed-off-by: Brian Gix <bgix@codeaurora.org>
2013-02-25 11:38:18 -08:00
Inga Stotland
7b18f01664 Bluetooth: Socket lookup for a fixed L2CAP channel
Socket lookup for a fixed channel should be done based on both remote and
local device addresses.

Change-Id: I35f39bea8ade6fd5d8695640251efc54bf21beae
Signed-off-by: Inga Stotland <ingas@codeaurora.org>
2013-02-25 11:38:17 -08:00
Brian Gix
326abc1bd7 Bluetooth: Timeout LE Connection requests
If LE devices stop advertising or go out of range, we need
to apply a timeout because the baseband doesn't.

Change-Id: I115672e21fd8aef56ac688b2df4664bb74b725e4
Signed-off-by: Brian Gix <bgix@codeaurora.org>
2013-02-25 11:38:16 -08:00
Mat Martineau
dab4d4a92c Bluetooth: Revert "Bluetooth: Increase AUTO_OFF timeout for HCI devices"
This reverts commit 24fac10d7e110035f61cf4bd69018adc84f15fc1.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
2013-02-25 11:38:15 -08:00
Mat Martineau
89a2ae611a Bluetooth: Increase AUTO_OFF timeout for HCI devices
The previous timeout (2 seconds) was too short for use with the 8960.
New timeout is 20 seconds.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
2013-02-25 11:38:14 -08:00
Peter Krystad
360e44a15c Bluetooth: Add support for L2CAP Extended Flow Spec option.
Add send and receive of Extended Flow Spec option during L2CAP
lockstep configuration and passing the flow specs to HCI.

Signed-off-by: Peter Krystad <pkrystad@codeaurora.org>

Conflicts:

	include/net/bluetooth/hci.h
	include/net/bluetooth/hci_core.h
	net/bluetooth/l2cap_core.c
2013-02-25 11:38:13 -08:00
Matt Wagantall
25b7dead80 msm: clock-8x60: Add local control of vpe_axi_clk and vpe_axi_clk
The MAXI_EN2 register is no longer owned by the RPM. Add local
control of the VPE and Rotator AXI clocks which are in it.

Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
2013-02-25 11:38:13 -08:00
Brian Gix
396b6c6960 Bluetooth: Complete LE Auth failure notification
Change-Id: Iccfe8abb7e1043196765748accbcc89fbd31578b
Signed-off-by: Brian Gix <bgix@codeaurora.org>
2013-02-25 11:38:11 -08:00