Skip to content

Commit 9662cbc

Browse files
committed
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/padovan/bluetooth-next
2 parents 640f595 + 4b0b2f0 commit 9662cbc

15 files changed

Lines changed: 1015 additions & 975 deletions

File tree

‎include/net/bluetooth/hci.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ enum {
210210

211211
#define LMP_EV4 0x01
212212
#define LMP_EV5 0x02
213+
#define LMP_NO_BREDR 0x20
213214
#define LMP_LE 0x40
214215

215216
#define LMP_SNIFF_SUBR 0x02
@@ -745,6 +746,14 @@ struct hci_rp_read_bd_addr {
745746
bdaddr_t bdaddr;
746747
} __packed;
747748

749+
#define HCI_OP_READ_DATA_BLOCK_SIZE 0x100a
750+
struct hci_rp_read_data_block_size {
751+
__u8 status;
752+
__le16 max_acl_len;
753+
__le16 block_len;
754+
__le16 num_blocks;
755+
} __packed;
756+
748757
#define HCI_OP_WRITE_PAGE_SCAN_ACTIVITY 0x0c1c
749758
struct hci_cp_write_page_scan_activity {
750759
__le16 interval;

‎include/net/bluetooth/hci_core.h‎

Lines changed: 57 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,11 @@ struct inquiry_cache {
6161

6262
struct hci_conn_hash {
6363
struct list_head list;
64-
spinlock_t lock;
6564
unsigned int acl_num;
6665
unsigned int sco_num;
6766
unsigned int le_num;
6867
};
6968

70-
struct hci_chan_hash {
71-
struct list_head list;
72-
spinlock_t lock;
73-
unsigned int num;
74-
};
75-
7669
struct bdaddr_list {
7770
struct list_head list;
7871
bdaddr_t bdaddr;
@@ -124,7 +117,7 @@ struct adv_entry {
124117
#define NUM_REASSEMBLY 4
125118
struct hci_dev {
126119
struct list_head list;
127-
spinlock_t lock;
120+
struct mutex lock;
128121
atomic_t refcnt;
129122

130123
char name[8];
@@ -188,6 +181,11 @@ struct hci_dev {
188181
unsigned int sco_pkts;
189182
unsigned int le_pkts;
190183

184+
__u16 block_len;
185+
__u16 block_mtu;
186+
__u16 num_blocks;
187+
__u16 block_cnt;
188+
191189
unsigned long acl_last_tx;
192190
unsigned long sco_last_tx;
193191
unsigned long le_last_tx;
@@ -200,10 +198,13 @@ struct hci_dev {
200198
__u16 discov_timeout;
201199
struct delayed_work discov_off;
202200

201+
struct delayed_work service_cache;
202+
203203
struct timer_list cmd_timer;
204-
struct tasklet_struct cmd_task;
205-
struct tasklet_struct rx_task;
206-
struct tasklet_struct tx_task;
204+
205+
struct work_struct rx_work;
206+
struct work_struct cmd_work;
207+
struct work_struct tx_work;
207208

208209
struct sk_buff_head rx_q;
209210
struct sk_buff_head raw_q;
@@ -232,7 +233,7 @@ struct hci_dev {
232233
struct list_head remote_oob_data;
233234

234235
struct list_head adv_entries;
235-
struct timer_list adv_timer;
236+
struct delayed_work adv_work;
236237

237238
struct hci_dev_stats stat;
238239

@@ -301,15 +302,12 @@ struct hci_conn {
301302
unsigned int sent;
302303

303304
struct sk_buff_head data_q;
304-
struct hci_chan_hash chan_hash;
305+
struct list_head chan_list;
305306

306-
struct timer_list disc_timer;
307+
struct delayed_work disc_work;
307308
struct timer_list idle_timer;
308309
struct timer_list auto_accept_timer;
309310

310-
struct work_struct work_add;
311-
struct work_struct work_del;
312-
313311
struct device dev;
314312
atomic_t devref;
315313

@@ -390,15 +388,15 @@ static inline void hci_conn_hash_init(struct hci_dev *hdev)
390388
{
391389
struct hci_conn_hash *h = &hdev->conn_hash;
392390
INIT_LIST_HEAD(&h->list);
393-
spin_lock_init(&h->lock);
394391
h->acl_num = 0;
395392
h->sco_num = 0;
393+
h->le_num = 0;
396394
}
397395

398396
static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)
399397
{
400398
struct hci_conn_hash *h = &hdev->conn_hash;
401-
list_add(&c->list, &h->list);
399+
list_add_rcu(&c->list, &h->list);
402400
switch (c->type) {
403401
case ACL_LINK:
404402
h->acl_num++;
@@ -416,7 +414,10 @@ static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)
416414
static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c)
417415
{
418416
struct hci_conn_hash *h = &hdev->conn_hash;
419-
list_del(&c->list);
417+
418+
list_del_rcu(&c->list);
419+
synchronize_rcu();
420+
420421
switch (c->type) {
421422
case ACL_LINK:
422423
h->acl_num--;
@@ -451,67 +452,59 @@ static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev,
451452
__u16 handle)
452453
{
453454
struct hci_conn_hash *h = &hdev->conn_hash;
454-
struct list_head *p;
455455
struct hci_conn *c;
456456

457-
list_for_each(p, &h->list) {
458-
c = list_entry(p, struct hci_conn, list);
459-
if (c->handle == handle)
457+
rcu_read_lock();
458+
459+
list_for_each_entry_rcu(c, &h->list, list) {
460+
if (c->handle == handle) {
461+
rcu_read_unlock();
460462
return c;
463+
}
461464
}
465+
rcu_read_unlock();
466+
462467
return NULL;
463468
}
464469

465470
static inline struct hci_conn *hci_conn_hash_lookup_ba(struct hci_dev *hdev,
466471
__u8 type, bdaddr_t *ba)
467472
{
468473
struct hci_conn_hash *h = &hdev->conn_hash;
469-
struct list_head *p;
470474
struct hci_conn *c;
471475

472-
list_for_each(p, &h->list) {
473-
c = list_entry(p, struct hci_conn, list);
474-
if (c->type == type && !bacmp(&c->dst, ba))
476+
rcu_read_lock();
477+
478+
list_for_each_entry_rcu(c, &h->list, list) {
479+
if (c->type == type && !bacmp(&c->dst, ba)) {
480+
rcu_read_unlock();
475481
return c;
482+
}
476483
}
484+
485+
rcu_read_unlock();
486+
477487
return NULL;
478488
}
479489

480490
static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev,
481491
__u8 type, __u16 state)
482492
{
483493
struct hci_conn_hash *h = &hdev->conn_hash;
484-
struct list_head *p;
485494
struct hci_conn *c;
486495

487-
list_for_each(p, &h->list) {
488-
c = list_entry(p, struct hci_conn, list);
489-
if (c->type == type && c->state == state)
496+
rcu_read_lock();
497+
498+
list_for_each_entry_rcu(c, &h->list, list) {
499+
if (c->type == type && c->state == state) {
500+
rcu_read_unlock();
490501
return c;
502+
}
491503
}
492-
return NULL;
493-
}
494-
495-
static inline void hci_chan_hash_init(struct hci_conn *c)
496-
{
497-
struct hci_chan_hash *h = &c->chan_hash;
498-
INIT_LIST_HEAD(&h->list);
499-
spin_lock_init(&h->lock);
500-
h->num = 0;
501-
}
502504

503-
static inline void hci_chan_hash_add(struct hci_conn *c, struct hci_chan *chan)
504-
{
505-
struct hci_chan_hash *h = &c->chan_hash;
506-
list_add(&chan->list, &h->list);
507-
h->num++;
508-
}
505+
rcu_read_unlock();
509506

510-
static inline void hci_chan_hash_del(struct hci_conn *c, struct hci_chan *chan)
511-
{
512-
struct hci_chan_hash *h = &c->chan_hash;
513-
list_del(&chan->list);
514-
h->num--;
507+
return NULL;
515508
}
516509

517510
void hci_acl_connect(struct hci_conn *conn);
@@ -527,7 +520,7 @@ void hci_conn_check_pending(struct hci_dev *hdev);
527520

528521
struct hci_chan *hci_chan_create(struct hci_conn *conn);
529522
int hci_chan_del(struct hci_chan *chan);
530-
void hci_chan_hash_flush(struct hci_conn *conn);
523+
void hci_chan_list_flush(struct hci_conn *conn);
531524

532525
struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
533526
__u8 sec_level, __u8 auth_type);
@@ -538,15 +531,14 @@ int hci_conn_change_link_key(struct hci_conn *conn);
538531
int hci_conn_switch_role(struct hci_conn *conn, __u8 role);
539532

540533
void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active);
541-
void hci_conn_enter_sniff_mode(struct hci_conn *conn);
542534

543535
void hci_conn_hold_device(struct hci_conn *conn);
544536
void hci_conn_put_device(struct hci_conn *conn);
545537

546538
static inline void hci_conn_hold(struct hci_conn *conn)
547539
{
548540
atomic_inc(&conn->refcnt);
549-
del_timer(&conn->disc_timer);
541+
cancel_delayed_work_sync(&conn->disc_work);
550542
}
551543

552544
static inline void hci_conn_put(struct hci_conn *conn)
@@ -565,7 +557,9 @@ static inline void hci_conn_put(struct hci_conn *conn)
565557
} else {
566558
timeo = msecs_to_jiffies(10);
567559
}
568-
mod_timer(&conn->disc_timer, jiffies + timeo);
560+
cancel_delayed_work_sync(&conn->disc_work);
561+
queue_delayed_work(conn->hdev->workqueue,
562+
&conn->disc_work, jiffies + timeo);
569563
}
570564
}
571565

@@ -597,10 +591,8 @@ static inline struct hci_dev *__hci_dev_hold(struct hci_dev *d)
597591
try_module_get(d->owner) ? __hci_dev_hold(d) : NULL; \
598592
})
599593

600-
#define hci_dev_lock(d) spin_lock(&d->lock)
601-
#define hci_dev_unlock(d) spin_unlock(&d->lock)
602-
#define hci_dev_lock_bh(d) spin_lock_bh(&d->lock)
603-
#define hci_dev_unlock_bh(d) spin_unlock_bh(&d->lock)
594+
#define hci_dev_lock(d) mutex_lock(&d->lock)
595+
#define hci_dev_unlock(d) mutex_unlock(&d->lock)
604596

605597
struct hci_dev *hci_dev_get(int index);
606598
struct hci_dev *hci_get_route(bdaddr_t *src, bdaddr_t *dst);
@@ -960,12 +952,16 @@ int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr);
960952
/* HCI info for socket */
961953
#define hci_pi(sk) ((struct hci_pinfo *) sk)
962954

955+
/* HCI socket flags */
956+
#define HCI_PI_MGMT_INIT 0
957+
963958
struct hci_pinfo {
964959
struct bt_sock bt;
965960
struct hci_dev *hdev;
966961
struct hci_filter filter;
967962
__u32 cmsg_mask;
968963
unsigned short channel;
964+
unsigned long flags;
969965
};
970966

971967
/* HCI security filter */

‎include/net/bluetooth/l2cap.h‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,11 @@ struct l2cap_chan {
482482
__u32 remote_acc_lat;
483483
__u32 remote_flush_to;
484484

485-
struct timer_list chan_timer;
486-
struct timer_list retrans_timer;
487-
struct timer_list monitor_timer;
488-
struct timer_list ack_timer;
485+
struct delayed_work chan_timer;
486+
struct delayed_work retrans_timer;
487+
struct delayed_work monitor_timer;
488+
struct delayed_work ack_timer;
489+
489490
struct sk_buff *tx_send_head;
490491
struct sk_buff_head tx_q;
491492
struct sk_buff_head srej_q;
@@ -521,7 +522,7 @@ struct l2cap_conn {
521522
__u8 info_state;
522523
__u8 info_ident;
523524

524-
struct timer_list info_timer;
525+
struct delayed_work info_work;
525526

526527
spinlock_t lock;
527528

@@ -535,7 +536,7 @@ struct l2cap_conn {
535536
struct smp_chan *smp_chan;
536537

537538
struct list_head chan_l;
538-
rwlock_t chan_lock;
539+
struct mutex chan_lock;
539540
};
540541

541542
#define L2CAP_INFO_CL_MTU_REQ_SENT 0x01
@@ -595,16 +596,16 @@ enum {
595596
};
596597

597598
#define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t))
598-
#define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer)
599+
#define __clear_chan_timer(c) l2cap_clear_timer(&c->chan_timer)
599600
#define __set_retrans_timer(c) l2cap_set_timer(c, &c->retrans_timer, \
600601
L2CAP_DEFAULT_RETRANS_TO);
601-
#define __clear_retrans_timer(c) l2cap_clear_timer(c, &c->retrans_timer)
602+
#define __clear_retrans_timer(c) l2cap_clear_timer(&c->retrans_timer)
602603
#define __set_monitor_timer(c) l2cap_set_timer(c, &c->monitor_timer, \
603604
L2CAP_DEFAULT_MONITOR_TO);
604-
#define __clear_monitor_timer(c) l2cap_clear_timer(c, &c->monitor_timer)
605+
#define __clear_monitor_timer(c) l2cap_clear_timer(&c->monitor_timer)
605606
#define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \
606607
L2CAP_DEFAULT_ACK_TO);
607-
#define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer)
608+
#define __clear_ack_timer(c) l2cap_clear_timer(&c->ack_timer)
608609

609610
static inline int __seq_offset(struct l2cap_chan *chan, __u16 seq1, __u16 seq2)
610611
{
@@ -805,7 +806,8 @@ int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid);
805806
struct l2cap_chan *l2cap_chan_create(struct sock *sk);
806807
void l2cap_chan_close(struct l2cap_chan *chan, int reason);
807808
void l2cap_chan_destroy(struct l2cap_chan *chan);
808-
int l2cap_chan_connect(struct l2cap_chan *chan);
809+
inline int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
810+
bdaddr_t *dst);
809811
int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len,
810812
u32 priority);
811813
void l2cap_chan_busy(struct l2cap_chan *chan, int busy);

0 commit comments

Comments
 (0)