@@ -61,18 +61,11 @@ struct inquiry_cache {
6161
6262struct 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-
7669struct bdaddr_list {
7770 struct list_head list;
7871 bdaddr_t bdaddr;
@@ -124,7 +117,7 @@ struct adv_entry {
124117#define NUM_REASSEMBLY 4
125118struct 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
398396static 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)
416414static 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
465470static 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
480490static 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
517510void hci_acl_connect (struct hci_conn *conn);
@@ -527,7 +520,7 @@ void hci_conn_check_pending(struct hci_dev *hdev);
527520
528521struct hci_chan *hci_chan_create (struct hci_conn *conn);
529522int 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
532525struct 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);
538531int hci_conn_switch_role (struct hci_conn *conn, __u8 role);
539532
540533void hci_conn_enter_active_mode (struct hci_conn *conn, __u8 force_active);
541- void hci_conn_enter_sniff_mode (struct hci_conn *conn);
542534
543535void hci_conn_hold_device (struct hci_conn *conn);
544536void hci_conn_put_device (struct hci_conn *conn);
545537
546538static 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
552544static 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
605597struct hci_dev *hci_dev_get (int index);
606598struct 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+
963958struct 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 */
0 commit comments