Skip to content

Commit 342149c

Browse files
committed
Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next
Johan Hedberg says: ==================== pull request: bluetooth-next 2018-10-20 Here's one more bluetooth-next pull request for the 4.20 kernel. - Added new USB ID for QCA_ROME controller - Added debug trace support from QCA wcn3990 controllers - Updated L2CAP to conform to latest Errata Service Release - Fix binding to non-removable BCM43430 devices Please let me know if there are any issues pulling. Thanks. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents a4efbaf + c614ca3 commit 342149c

File tree

6 files changed

+80
-47
lines changed

6 files changed

+80
-47
lines changed

drivers/bluetooth/btsdio.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,17 @@ static int btsdio_probe(struct sdio_func *func,
293293
tuple = tuple->next;
294294
}
295295

296-
/* BCM43341 devices soldered onto the PCB (non-removable) use an
297-
* uart connection for bluetooth, ignore the BT SDIO interface.
296+
/* Broadcom devices soldered onto the PCB (non-removable) use an
297+
* UART connection for Bluetooth, ignore the BT SDIO interface.
298298
*/
299299
if (func->vendor == SDIO_VENDOR_ID_BROADCOM &&
300-
func->device == SDIO_DEVICE_ID_BROADCOM_43341 &&
301-
!mmc_card_is_removable(func->card->host))
302-
return -ENODEV;
300+
!mmc_card_is_removable(func->card->host)) {
301+
switch (func->device) {
302+
case SDIO_DEVICE_ID_BROADCOM_43341:
303+
case SDIO_DEVICE_ID_BROADCOM_43430:
304+
return -ENODEV;
305+
}
306+
}
303307

304308
data = devm_kzalloc(&func->dev, sizeof(*data), GFP_KERNEL);
305309
if (!data)

drivers/bluetooth/btusb.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ static const struct usb_device_id blacklist_table[] = {
264264
{ USB_DEVICE(0x0489, 0xe03c), .driver_info = BTUSB_ATH3012 },
265265

266266
/* QCA ROME chipset */
267+
{ USB_DEVICE(0x0cf3, 0x535b), .driver_info = BTUSB_QCA_ROME },
267268
{ USB_DEVICE(0x0cf3, 0xe007), .driver_info = BTUSB_QCA_ROME },
268269
{ USB_DEVICE(0x0cf3, 0xe009), .driver_info = BTUSB_QCA_ROME },
269270
{ USB_DEVICE(0x0cf3, 0xe010), .driver_info = BTUSB_QCA_ROME },

drivers/bluetooth/hci_qca.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <linux/platform_device.h>
4141
#include <linux/regulator/consumer.h>
4242
#include <linux/serdev.h>
43+
#include <asm/unaligned.h>
4344

4445
#include <net/bluetooth/bluetooth.h>
4546
#include <net/bluetooth/hci_core.h>
@@ -63,6 +64,9 @@
6364
/* susclk rate */
6465
#define SUSCLK_RATE_32KHZ 32768
6566

67+
/* Controller debug log header */
68+
#define QCA_DEBUG_HANDLE 0x2EDC
69+
6670
/* HCI_IBS transmit side sleep protocol states */
6771
enum tx_ibs_states {
6872
HCI_IBS_TX_ASLEEP,
@@ -849,6 +853,19 @@ static int qca_ibs_wake_ack(struct hci_dev *hdev, struct sk_buff *skb)
849853
return 0;
850854
}
851855

856+
static int qca_recv_acl_data(struct hci_dev *hdev, struct sk_buff *skb)
857+
{
858+
/* We receive debug logs from chip as an ACL packets.
859+
* Instead of sending the data to ACL to decode the
860+
* received data, we are pushing them to the above layers
861+
* as a diagnostic packet.
862+
*/
863+
if (get_unaligned_le16(skb->data) == QCA_DEBUG_HANDLE)
864+
return hci_recv_diag(hdev, skb);
865+
866+
return hci_recv_frame(hdev, skb);
867+
}
868+
852869
#define QCA_IBS_SLEEP_IND_EVENT \
853870
.type = HCI_IBS_SLEEP_IND, \
854871
.hlen = 0, \
@@ -871,7 +888,7 @@ static int qca_ibs_wake_ack(struct hci_dev *hdev, struct sk_buff *skb)
871888
.maxlen = HCI_MAX_IBS_SIZE
872889

873890
static const struct h4_recv_pkt qca_recv_pkts[] = {
874-
{ H4_RECV_ACL, .recv = hci_recv_frame },
891+
{ H4_RECV_ACL, .recv = qca_recv_acl_data },
875892
{ H4_RECV_SCO, .recv = hci_recv_frame },
876893
{ H4_RECV_EVENT, .recv = hci_recv_frame },
877894
{ QCA_IBS_WAKE_IND_EVENT, .recv = qca_ibs_wake_ind },

include/net/bluetooth/l2cap.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,19 @@ struct l2cap_conn_rsp {
277277
#define L2CAP_CR_SEC_BLOCK 0x0003
278278
#define L2CAP_CR_NO_MEM 0x0004
279279
#define L2CAP_CR_BAD_AMP 0x0005
280-
#define L2CAP_CR_AUTHENTICATION 0x0005
281-
#define L2CAP_CR_AUTHORIZATION 0x0006
282-
#define L2CAP_CR_BAD_KEY_SIZE 0x0007
283-
#define L2CAP_CR_ENCRYPTION 0x0008
284-
#define L2CAP_CR_INVALID_SCID 0x0009
285-
#define L2CAP_CR_SCID_IN_USE 0x000A
280+
#define L2CAP_CR_INVALID_SCID 0x0006
281+
#define L2CAP_CR_SCID_IN_USE 0x0007
282+
283+
/* credit based connect results */
284+
#define L2CAP_CR_LE_SUCCESS 0x0000
285+
#define L2CAP_CR_LE_BAD_PSM 0x0002
286+
#define L2CAP_CR_LE_NO_MEM 0x0004
287+
#define L2CAP_CR_LE_AUTHENTICATION 0x0005
288+
#define L2CAP_CR_LE_AUTHORIZATION 0x0006
289+
#define L2CAP_CR_LE_BAD_KEY_SIZE 0x0007
290+
#define L2CAP_CR_LE_ENCRYPTION 0x0008
291+
#define L2CAP_CR_LE_INVALID_SCID 0x0009
292+
#define L2CAP_CR_LE_SCID_IN_USE 0X000A
286293

287294
/* connect/create channel status */
288295
#define L2CAP_CS_NO_INFO 0x0000

net/bluetooth/hci_event.c

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4937,31 +4937,27 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
49374937
hci_debugfs_create_conn(conn);
49384938
hci_conn_add_sysfs(conn);
49394939

4940-
if (!status) {
4941-
/* The remote features procedure is defined for master
4942-
* role only. So only in case of an initiated connection
4943-
* request the remote features.
4944-
*
4945-
* If the local controller supports slave-initiated features
4946-
* exchange, then requesting the remote features in slave
4947-
* role is possible. Otherwise just transition into the
4948-
* connected state without requesting the remote features.
4949-
*/
4950-
if (conn->out ||
4951-
(hdev->le_features[0] & HCI_LE_SLAVE_FEATURES)) {
4952-
struct hci_cp_le_read_remote_features cp;
4940+
/* The remote features procedure is defined for master
4941+
* role only. So only in case of an initiated connection
4942+
* request the remote features.
4943+
*
4944+
* If the local controller supports slave-initiated features
4945+
* exchange, then requesting the remote features in slave
4946+
* role is possible. Otherwise just transition into the
4947+
* connected state without requesting the remote features.
4948+
*/
4949+
if (conn->out ||
4950+
(hdev->le_features[0] & HCI_LE_SLAVE_FEATURES)) {
4951+
struct hci_cp_le_read_remote_features cp;
49534952

4954-
cp.handle = __cpu_to_le16(conn->handle);
4953+
cp.handle = __cpu_to_le16(conn->handle);
49554954

4956-
hci_send_cmd(hdev, HCI_OP_LE_READ_REMOTE_FEATURES,
4957-
sizeof(cp), &cp);
4955+
hci_send_cmd(hdev, HCI_OP_LE_READ_REMOTE_FEATURES,
4956+
sizeof(cp), &cp);
49584957

4959-
hci_conn_hold(conn);
4960-
} else {
4961-
conn->state = BT_CONNECTED;
4962-
hci_connect_cfm(conn, status);
4963-
}
4958+
hci_conn_hold(conn);
49644959
} else {
4960+
conn->state = BT_CONNECTED;
49654961
hci_connect_cfm(conn, status);
49664962
}
49674963

net/bluetooth/l2cap_core.c

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,9 @@ static void l2cap_chan_le_connect_reject(struct l2cap_chan *chan)
680680
u16 result;
681681

682682
if (test_bit(FLAG_DEFER_SETUP, &chan->flags))
683-
result = L2CAP_CR_AUTHORIZATION;
683+
result = L2CAP_CR_LE_AUTHORIZATION;
684684
else
685-
result = L2CAP_CR_BAD_PSM;
685+
result = L2CAP_CR_LE_BAD_PSM;
686686

687687
l2cap_state_change(chan, BT_DISCONN);
688688

@@ -3670,7 +3670,7 @@ void __l2cap_le_connect_rsp_defer(struct l2cap_chan *chan)
36703670
rsp.mtu = cpu_to_le16(chan->imtu);
36713671
rsp.mps = cpu_to_le16(chan->mps);
36723672
rsp.credits = cpu_to_le16(chan->rx_credits);
3673-
rsp.result = cpu_to_le16(L2CAP_CR_SUCCESS);
3673+
rsp.result = cpu_to_le16(L2CAP_CR_LE_SUCCESS);
36743674

36753675
l2cap_send_cmd(conn, chan->ident, L2CAP_LE_CONN_RSP, sizeof(rsp),
36763676
&rsp);
@@ -3816,9 +3816,17 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
38163816

38173817
result = L2CAP_CR_NO_MEM;
38183818

3819+
/* Check for valid dynamic CID range (as per Erratum 3253) */
3820+
if (scid < L2CAP_CID_DYN_START || scid > L2CAP_CID_DYN_END) {
3821+
result = L2CAP_CR_INVALID_SCID;
3822+
goto response;
3823+
}
3824+
38193825
/* Check if we already have channel with that dcid */
3820-
if (__l2cap_get_chan_by_dcid(conn, scid))
3826+
if (__l2cap_get_chan_by_dcid(conn, scid)) {
3827+
result = L2CAP_CR_SCID_IN_USE;
38213828
goto response;
3829+
}
38223830

38233831
chan = pchan->ops->new_connection(pchan);
38243832
if (!chan)
@@ -5280,7 +5288,7 @@ static int l2cap_le_connect_rsp(struct l2cap_conn *conn,
52805288
credits = __le16_to_cpu(rsp->credits);
52815289
result = __le16_to_cpu(rsp->result);
52825290

5283-
if (result == L2CAP_CR_SUCCESS && (mtu < 23 || mps < 23 ||
5291+
if (result == L2CAP_CR_LE_SUCCESS && (mtu < 23 || mps < 23 ||
52845292
dcid < L2CAP_CID_DYN_START ||
52855293
dcid > L2CAP_CID_LE_DYN_END))
52865294
return -EPROTO;
@@ -5301,7 +5309,7 @@ static int l2cap_le_connect_rsp(struct l2cap_conn *conn,
53015309
l2cap_chan_lock(chan);
53025310

53035311
switch (result) {
5304-
case L2CAP_CR_SUCCESS:
5312+
case L2CAP_CR_LE_SUCCESS:
53055313
if (__l2cap_get_chan_by_dcid(conn, dcid)) {
53065314
err = -EBADSLT;
53075315
break;
@@ -5315,8 +5323,8 @@ static int l2cap_le_connect_rsp(struct l2cap_conn *conn,
53155323
l2cap_chan_ready(chan);
53165324
break;
53175325

5318-
case L2CAP_CR_AUTHENTICATION:
5319-
case L2CAP_CR_ENCRYPTION:
5326+
case L2CAP_CR_LE_AUTHENTICATION:
5327+
case L2CAP_CR_LE_ENCRYPTION:
53205328
/* If we already have MITM protection we can't do
53215329
* anything.
53225330
*/
@@ -5459,7 +5467,7 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn,
54595467
pchan = l2cap_global_chan_by_psm(BT_LISTEN, psm, &conn->hcon->src,
54605468
&conn->hcon->dst, LE_LINK);
54615469
if (!pchan) {
5462-
result = L2CAP_CR_BAD_PSM;
5470+
result = L2CAP_CR_LE_BAD_PSM;
54635471
chan = NULL;
54645472
goto response;
54655473
}
@@ -5469,28 +5477,28 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn,
54695477

54705478
if (!smp_sufficient_security(conn->hcon, pchan->sec_level,
54715479
SMP_ALLOW_STK)) {
5472-
result = L2CAP_CR_AUTHENTICATION;
5480+
result = L2CAP_CR_LE_AUTHENTICATION;
54735481
chan = NULL;
54745482
goto response_unlock;
54755483
}
54765484

54775485
/* Check for valid dynamic CID range */
54785486
if (scid < L2CAP_CID_DYN_START || scid > L2CAP_CID_LE_DYN_END) {
5479-
result = L2CAP_CR_INVALID_SCID;
5487+
result = L2CAP_CR_LE_INVALID_SCID;
54805488
chan = NULL;
54815489
goto response_unlock;
54825490
}
54835491

54845492
/* Check if we already have channel with that dcid */
54855493
if (__l2cap_get_chan_by_dcid(conn, scid)) {
5486-
result = L2CAP_CR_SCID_IN_USE;
5494+
result = L2CAP_CR_LE_SCID_IN_USE;
54875495
chan = NULL;
54885496
goto response_unlock;
54895497
}
54905498

54915499
chan = pchan->ops->new_connection(pchan);
54925500
if (!chan) {
5493-
result = L2CAP_CR_NO_MEM;
5501+
result = L2CAP_CR_LE_NO_MEM;
54945502
goto response_unlock;
54955503
}
54965504

@@ -5526,7 +5534,7 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn,
55265534
chan->ops->defer(chan);
55275535
} else {
55285536
l2cap_chan_ready(chan);
5529-
result = L2CAP_CR_SUCCESS;
5537+
result = L2CAP_CR_LE_SUCCESS;
55305538
}
55315539

55325540
response_unlock:

0 commit comments

Comments
 (0)