Skip to content

Commit 52c05fc

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 2017-05-23 Here's the first Bluetooth & 802.15.4 pull request targeting the 4.13 kernel release. - Bluetooth 5.0 improvements (Data Length Extensions and alternate PHY) - Support for new Intel Bluetooth adapter [[8087:0aaa] - Various fixes to ieee802154 code - Various fixes to HCI UART code ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents a0a32d3 + 7dab546 commit 52c05fc

File tree

13 files changed

+107
-36
lines changed

13 files changed

+107
-36
lines changed

MAINTAINERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ S: Maintained
155155
F: drivers/scsi/53c700*
156156

157157
6LOWPAN GENERIC (BTLE/IEEE 802.15.4)
158-
M: Alexander Aring <[email protected]>
158+
M: Alexander Aring <[email protected]>
159159
M: Jukka Rissanen <[email protected]>
160160
161161
@@ -6427,7 +6427,7 @@ F: Documentation/cdrom/ide-cd
64276427
F: drivers/ide/ide-cd*
64286428

64296429
IEEE 802.15.4 SUBSYSTEM
6430-
M: Alexander Aring <[email protected]>
6430+
M: Alexander Aring <[email protected]>
64316431
M: Stefan Schmidt <[email protected]>
64326432
64336433
W: http://wpan.cakelab.org/

drivers/bluetooth/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ config BT_HCIUART_NOKIA
9797
depends on BT_HCIUART
9898
depends on BT_HCIUART_SERDEV
9999
depends on PM
100+
select BT_HCIUART_H4
100101
help
101102
Nokia H4+ is serial protocol for communication between Bluetooth
102103
device and host. This protocol is required for Bluetooth devices
@@ -131,7 +132,7 @@ config BT_HCIUART_ATH3K
131132

132133
config BT_HCIUART_LL
133134
bool "HCILL protocol support"
134-
depends on BT_HCIUART
135+
depends on BT_HCIUART_SERDEV
135136
help
136137
HCILL (HCI Low Level) is a serial protocol for communication
137138
between Bluetooth device and host. This protocol is required for

drivers/bluetooth/btintel.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,3 +575,5 @@ MODULE_VERSION(VERSION);
575575
MODULE_LICENSE("GPL");
576576
MODULE_FIRMWARE("intel/ibt-11-5.sfi");
577577
MODULE_FIRMWARE("intel/ibt-11-5.ddc");
578+
MODULE_FIRMWARE("intel/ibt-12-16.sfi");
579+
MODULE_FIRMWARE("intel/ibt-12-16.ddc");

drivers/bluetooth/btusb.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ static const struct usb_device_id blacklist_table[] = {
336336
{ USB_DEVICE(0x8087, 0x0a2a), .driver_info = BTUSB_INTEL },
337337
{ USB_DEVICE(0x8087, 0x0a2b), .driver_info = BTUSB_INTEL_NEW },
338338
{ USB_DEVICE(0x8087, 0x0aa7), .driver_info = BTUSB_INTEL },
339+
{ USB_DEVICE(0x8087, 0x0aaa), .driver_info = BTUSB_INTEL_NEW },
339340

340341
/* Other Intel Bluetooth devices */
341342
{ USB_VENDOR_AND_INTERFACE_INFO(0x8087, 0xe0, 0x01, 0x01),
@@ -2036,6 +2037,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
20362037
switch (ver.hw_variant) {
20372038
case 0x0b: /* SfP */
20382039
case 0x0c: /* WsP */
2040+
case 0x11: /* JfP */
20392041
case 0x12: /* ThP */
20402042
break;
20412043
default:
@@ -2138,6 +2140,8 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
21382140
* Currently the supported hardware variants are:
21392141
* 11 (0x0b) for iBT3.0 (LnP/SfP)
21402142
* 12 (0x0c) for iBT3.5 (WsP)
2143+
* 17 (0x11) for iBT3.5 (JfP)
2144+
* 18 (0x12) for iBT3.5 (ThP)
21412145
*/
21422146
snprintf(fwname, sizeof(fwname), "intel/ibt-%u-%u.sfi",
21432147
le16_to_cpu(ver.hw_variant),

drivers/bluetooth/btwilink.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ static int ti_st_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
262262
pkt_type = hci_skb_pkt_type(skb);
263263
len = hst->st_write(skb);
264264
if (len < 0) {
265-
kfree_skb(skb);
266265
BT_ERR("ST write failed (%ld)", len);
267266
/* Try Again, would only fail if UART has gone bad */
268267
return -EAGAIN;

drivers/bluetooth/hci_ldisc.c

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,12 @@ static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu)
114114
struct sk_buff *skb = hu->tx_skb;
115115

116116
if (!skb) {
117+
read_lock(&hu->proto_lock);
118+
117119
if (test_bit(HCI_UART_PROTO_READY, &hu->flags))
118120
skb = hu->proto->dequeue(hu);
121+
122+
read_unlock(&hu->proto_lock);
119123
} else {
120124
hu->tx_skb = NULL;
121125
}
@@ -125,18 +129,23 @@ static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu)
125129

126130
int hci_uart_tx_wakeup(struct hci_uart *hu)
127131
{
132+
read_lock(&hu->proto_lock);
133+
128134
if (!test_bit(HCI_UART_PROTO_READY, &hu->flags))
129-
return 0;
135+
goto no_schedule;
130136

131137
if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) {
132138
set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state);
133-
return 0;
139+
goto no_schedule;
134140
}
135141

136142
BT_DBG("");
137143

138144
schedule_work(&hu->write_work);
139145

146+
no_schedule:
147+
read_unlock(&hu->proto_lock);
148+
140149
return 0;
141150
}
142151
EXPORT_SYMBOL_GPL(hci_uart_tx_wakeup);
@@ -237,9 +246,13 @@ static int hci_uart_flush(struct hci_dev *hdev)
237246
tty_ldisc_flush(tty);
238247
tty_driver_flush_buffer(tty);
239248

249+
read_lock(&hu->proto_lock);
250+
240251
if (test_bit(HCI_UART_PROTO_READY, &hu->flags))
241252
hu->proto->flush(hu);
242253

254+
read_unlock(&hu->proto_lock);
255+
243256
return 0;
244257
}
245258

@@ -261,10 +274,15 @@ static int hci_uart_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
261274
BT_DBG("%s: type %d len %d", hdev->name, hci_skb_pkt_type(skb),
262275
skb->len);
263276

264-
if (!test_bit(HCI_UART_PROTO_READY, &hu->flags))
277+
read_lock(&hu->proto_lock);
278+
279+
if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) {
280+
read_unlock(&hu->proto_lock);
265281
return -EUNATCH;
282+
}
266283

267284
hu->proto->enqueue(hu, skb);
285+
read_unlock(&hu->proto_lock);
268286

269287
hci_uart_tx_wakeup(hu);
270288

@@ -460,6 +478,8 @@ static int hci_uart_tty_open(struct tty_struct *tty)
460478
INIT_WORK(&hu->init_ready, hci_uart_init_work);
461479
INIT_WORK(&hu->write_work, hci_uart_write_work);
462480

481+
rwlock_init(&hu->proto_lock);
482+
463483
/* Flush any pending characters in the driver */
464484
tty_driver_flush_buffer(tty);
465485

@@ -475,6 +495,7 @@ static void hci_uart_tty_close(struct tty_struct *tty)
475495
{
476496
struct hci_uart *hu = tty->disc_data;
477497
struct hci_dev *hdev;
498+
unsigned long flags;
478499

479500
BT_DBG("tty %p", tty);
480501

@@ -490,7 +511,11 @@ static void hci_uart_tty_close(struct tty_struct *tty)
490511

491512
cancel_work_sync(&hu->write_work);
492513

493-
if (test_and_clear_bit(HCI_UART_PROTO_READY, &hu->flags)) {
514+
if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) {
515+
write_lock_irqsave(&hu->proto_lock, flags);
516+
clear_bit(HCI_UART_PROTO_READY, &hu->flags);
517+
write_unlock_irqrestore(&hu->proto_lock, flags);
518+
494519
if (hdev) {
495520
if (test_bit(HCI_UART_REGISTERED, &hu->flags))
496521
hci_unregister_dev(hdev);
@@ -549,13 +574,18 @@ static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data,
549574
if (!hu || tty != hu->tty)
550575
return;
551576

552-
if (!test_bit(HCI_UART_PROTO_READY, &hu->flags))
577+
read_lock(&hu->proto_lock);
578+
579+
if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) {
580+
read_unlock(&hu->proto_lock);
553581
return;
582+
}
554583

555584
/* It does not need a lock here as it is already protected by a mutex in
556585
* tty caller
557586
*/
558587
hu->proto->recv(hu, data, count);
588+
read_unlock(&hu->proto_lock);
559589

560590
if (hu->hdev)
561591
hu->hdev->stat.byte_rx += count;

drivers/bluetooth/hci_ll.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ static int download_firmware(struct ll_device *lldev)
624624
skb = __hci_cmd_sync(lldev->hu.hdev, cmd->opcode, cmd->plen, &cmd->speed, HCI_INIT_TIMEOUT);
625625
if (IS_ERR(skb)) {
626626
bt_dev_err(lldev->hu.hdev, "send command failed\n");
627+
err = PTR_ERR(skb);
627628
goto out_rel_fw;
628629
}
629630
kfree_skb(skb);

drivers/bluetooth/hci_uart.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ struct hci_uart {
8787
struct work_struct write_work;
8888

8989
const struct hci_uart_proto *proto;
90+
rwlock_t proto_lock; /* Stop work for proto close */
9091
void *priv;
9192

9293
struct sk_buff *tx_skb;

drivers/net/ieee802154/ca8210.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ static int ca8210_spi_transfer(
912912
)
913913
{
914914
int i, status = 0;
915-
struct ca8210_priv *priv = spi_get_drvdata(spi);
915+
struct ca8210_priv *priv;
916916
struct cas_control *cas_ctl;
917917

918918
if (!spi) {
@@ -923,6 +923,7 @@ static int ca8210_spi_transfer(
923923
return -ENODEV;
924924
}
925925

926+
priv = spi_get_drvdata(spi);
926927
reinit_completion(&priv->spi_transfer_complete);
927928

928929
dev_dbg(&spi->dev, "ca8210_spi_transfer called\n");
@@ -1808,10 +1809,9 @@ static int ca8210_skb_rx(
18081809

18091810
/* Allocate mtu size buffer for every rx packet */
18101811
skb = dev_alloc_skb(IEEE802154_MTU + sizeof(hdr));
1811-
if (!skb) {
1812-
dev_crit(&priv->spi->dev, "dev_alloc_skb failed\n");
1812+
if (!skb)
18131813
return -ENOMEM;
1814-
}
1814+
18151815
skb_reserve(skb, sizeof(hdr));
18161816

18171817
msdulen = data_ind[22]; /* msdu_length */
@@ -3143,10 +3143,6 @@ static int ca8210_probe(struct spi_device *spi_device)
31433143

31443144
pdata = kmalloc(sizeof(*pdata), GFP_KERNEL);
31453145
if (!pdata) {
3146-
dev_crit(
3147-
&spi_device->dev,
3148-
"Could not allocate platform data\n"
3149-
);
31503146
ret = -ENOMEM;
31513147
goto error;
31523148
}

include/net/bluetooth/hci.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ enum {
399399
#define HCI_LE_PING 0x10
400400
#define HCI_LE_DATA_LEN_EXT 0x20
401401
#define HCI_LE_EXT_SCAN_POLICY 0x80
402+
#define HCI_LE_CHAN_SEL_ALG2 0x40
402403

403404
/* Connection modes */
404405
#define HCI_CM_ACTIVE 0x0000
@@ -1498,6 +1499,13 @@ struct hci_rp_le_read_max_data_len {
14981499
__le16 rx_time;
14991500
} __packed;
15001501

1502+
#define HCI_OP_LE_SET_DEFAULT_PHY 0x2031
1503+
struct hci_cp_le_set_default_phy {
1504+
__u8 all_phys;
1505+
__u8 tx_phys;
1506+
__u8 rx_phys;
1507+
} __packed;
1508+
15011509
/* ---- HCI Events ---- */
15021510
#define HCI_EV_INQUIRY_COMPLETE 0x01
15031511

net/bluetooth/ecdh_helper.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,9 @@ bool compute_ecdh_secret(const u8 public_key[64], const u8 private_key[32],
8989
p.curve_id = ECC_CURVE_NIST_P256;
9090
buf_len = crypto_ecdh_key_len(&p);
9191
buf = kmalloc(buf_len, GFP_KERNEL);
92-
if (!buf) {
93-
pr_err("alg: kpp: Failed to allocate %d bytes for buf\n",
94-
buf_len);
92+
if (!buf)
9593
goto free_req;
96-
}
94+
9795
crypto_ecdh_encode_key(buf, buf_len, &p);
9896

9997
/* Set A private Key */
@@ -170,11 +168,8 @@ bool generate_ecdh_keys(u8 public_key[64], u8 private_key[32])
170168
p.key_size = 32;
171169
buf_len = crypto_ecdh_key_len(&p);
172170
buf = kmalloc(buf_len, GFP_KERNEL);
173-
if (!buf) {
174-
pr_err("alg: kpp: Failed to allocate %d bytes for buf\n",
175-
buf_len);
171+
if (!buf)
176172
goto free_req;
177-
}
178173

179174
do {
180175
if (tries++ >= max_tries)

net/bluetooth/hci_core.c

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,13 @@ static ssize_t vendor_diag_write(struct file *file, const char __user *user_buf,
148148
return -EINVAL;
149149

150150
/* When the diagnostic flags are not persistent and the transport
151-
* is not active, then there is no need for the vendor callback.
152-
*
153-
* Instead just store the desired value. If needed the setting
154-
* will be programmed when the controller gets powered on.
151+
* is not active or in user channel operation, then there is no need
152+
* for the vendor callback. Instead just store the desired value and
153+
* the setting will be programmed when the controller gets powered on.
155154
*/
156155
if (test_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks) &&
157-
!test_bit(HCI_RUNNING, &hdev->flags))
156+
(!test_bit(HCI_RUNNING, &hdev->flags) ||
157+
hci_dev_test_flag(hdev, HCI_USER_CHANNEL)))
158158
goto done;
159159

160160
hci_req_sync_lock(hdev);
@@ -635,6 +635,14 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
635635
* Report
636636
*/
637637

638+
/* If the controller supports Channel Selection Algorithm #2
639+
* feature, enable the corresponding event.
640+
*/
641+
if (hdev->le_features[1] & HCI_LE_CHAN_SEL_ALG2)
642+
events[2] |= 0x08; /* LE Channel Selection
643+
* Algorithm
644+
*/
645+
638646
/* If the controller supports the LE Set Scan Enable command,
639647
* enable the corresponding advertising report event.
640648
*/
@@ -677,6 +685,12 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
677685
if (hdev->commands[34] & 0x04)
678686
events[1] |= 0x01; /* LE Generate DHKey Complete */
679687

688+
/* If the controller supports the LE Set Default PHY or
689+
* LE Set PHY commands, enable the corresponding event.
690+
*/
691+
if (hdev->commands[35] & (0x20 | 0x40))
692+
events[1] |= 0x08; /* LE PHY Update Complete */
693+
680694
hci_req_add(req, HCI_OP_LE_SET_EVENT_MASK, sizeof(events),
681695
events);
682696

@@ -771,6 +785,27 @@ static int hci_init4_req(struct hci_request *req, unsigned long opt)
771785
sizeof(support), &support);
772786
}
773787

788+
/* Set Suggested Default Data Length to maximum if supported */
789+
if (hdev->le_features[0] & HCI_LE_DATA_LEN_EXT) {
790+
struct hci_cp_le_write_def_data_len cp;
791+
792+
cp.tx_len = hdev->le_max_tx_len;
793+
cp.tx_time = hdev->le_max_tx_time;
794+
hci_req_add(req, HCI_OP_LE_WRITE_DEF_DATA_LEN, sizeof(cp), &cp);
795+
}
796+
797+
/* Set Default PHY parameters if command is supported */
798+
if (hdev->commands[35] & 0x20) {
799+
struct hci_cp_le_set_default_phy cp;
800+
801+
/* No transmitter PHY or receiver PHY preferences */
802+
cp.all_phys = 0x03;
803+
cp.tx_phys = 0;
804+
cp.rx_phys = 0;
805+
806+
hci_req_add(req, HCI_OP_LE_SET_DEFAULT_PHY, sizeof(cp), &cp);
807+
}
808+
774809
return 0;
775810
}
776811

@@ -1384,6 +1419,7 @@ static int hci_dev_do_open(struct hci_dev *hdev)
13841419
* completed.
13851420
*/
13861421
if (test_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks) &&
1422+
!hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
13871423
hci_dev_test_flag(hdev, HCI_VENDOR_DIAG) && hdev->set_diag)
13881424
ret = hdev->set_diag(hdev, true);
13891425

0 commit comments

Comments
 (0)