aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo F. Padovan <padovan@profusion.mobi>2011-12-14 21:50:02 -0500
committerGustavo F. Padovan <padovan@profusion.mobi>2011-12-18 14:07:57 -0500
commit3eff45eaf81780dad25c167bbaafa7d25ae407da (patch)
treef20254e5ded21e81b0313b1f8b56dd0165a09821
parentc347b765fe70d718c721cd6d0b979cfbaed83125 (diff)
Bluetooth: convert tx_task to workqueue
This should simplify Bluetooth core processing a lot. Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
-rw-r--r--include/net/bluetooth/hci_core.h2
-rw-r--r--net/bluetooth/hci_core.c20
-rw-r--r--net/bluetooth/hci_event.c6
-rw-r--r--net/bluetooth/hci_sock.c4
4 files changed, 13 insertions, 19 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 051fd7fd2992..5d1bb51c43c3 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -197,7 +197,7 @@ struct hci_dev {
197 197
198 struct work_struct rx_work; 198 struct work_struct rx_work;
199 struct work_struct cmd_work; 199 struct work_struct cmd_work;
200 struct tasklet_struct tx_task; 200 struct work_struct tx_work;
201 201
202 struct sk_buff_head rx_q; 202 struct sk_buff_head rx_q;
203 struct sk_buff_head raw_q; 203 struct sk_buff_head raw_q;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index e2db2551b158..2b20941ebcb1 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -58,7 +58,7 @@ int enable_hs;
58 58
59static void hci_rx_work(struct work_struct *work); 59static void hci_rx_work(struct work_struct *work);
60static void hci_cmd_work(struct work_struct *work); 60static void hci_cmd_work(struct work_struct *work);
61static void hci_tx_task(unsigned long arg); 61static void hci_tx_work(struct work_struct *work);
62 62
63static DEFINE_MUTEX(hci_task_lock); 63static DEFINE_MUTEX(hci_task_lock);
64 64
@@ -547,7 +547,7 @@ int hci_dev_open(__u16 dev)
547 } 547 }
548 } else { 548 } else {
549 /* Init failed, cleanup */ 549 /* Init failed, cleanup */
550 tasklet_kill(&hdev->tx_task); 550 flush_work(&hdev->tx_work);
551 flush_work(&hdev->cmd_work); 551 flush_work(&hdev->cmd_work);
552 flush_work(&hdev->rx_work); 552 flush_work(&hdev->rx_work);
553 553
@@ -585,8 +585,8 @@ static int hci_dev_do_close(struct hci_dev *hdev)
585 return 0; 585 return 0;
586 } 586 }
587 587
588 /* Kill RX and TX tasks */ 588 /* Flush RX and TX works */
589 tasklet_kill(&hdev->tx_task); 589 flush_work(&hdev->tx_work);
590 flush_work(&hdev->rx_work); 590 flush_work(&hdev->rx_work);
591 591
592 if (hdev->discov_timeout > 0) { 592 if (hdev->discov_timeout > 0) {
@@ -672,7 +672,6 @@ int hci_dev_reset(__u16 dev)
672 return -ENODEV; 672 return -ENODEV;
673 673
674 hci_req_lock(hdev); 674 hci_req_lock(hdev);
675 tasklet_disable(&hdev->tx_task);
676 675
677 if (!test_bit(HCI_UP, &hdev->flags)) 676 if (!test_bit(HCI_UP, &hdev->flags))
678 goto done; 677 goto done;
@@ -697,7 +696,6 @@ int hci_dev_reset(__u16 dev)
697 msecs_to_jiffies(HCI_INIT_TIMEOUT)); 696 msecs_to_jiffies(HCI_INIT_TIMEOUT));
698 697
699done: 698done:
700 tasklet_enable(&hdev->tx_task);
701 hci_req_unlock(hdev); 699 hci_req_unlock(hdev);
702 hci_dev_put(hdev); 700 hci_dev_put(hdev);
703 return ret; 701 return ret;
@@ -1459,8 +1457,8 @@ int hci_register_dev(struct hci_dev *hdev)
1459 1457
1460 INIT_WORK(&hdev->rx_work, hci_rx_work); 1458 INIT_WORK(&hdev->rx_work, hci_rx_work);
1461 INIT_WORK(&hdev->cmd_work, hci_cmd_work); 1459 INIT_WORK(&hdev->cmd_work, hci_cmd_work);
1460 INIT_WORK(&hdev->tx_work, hci_tx_work);
1462 1461
1463 tasklet_init(&hdev->tx_task, hci_tx_task, (unsigned long) hdev);
1464 1462
1465 skb_queue_head_init(&hdev->rx_q); 1463 skb_queue_head_init(&hdev->rx_q);
1466 skb_queue_head_init(&hdev->cmd_q); 1464 skb_queue_head_init(&hdev->cmd_q);
@@ -2012,7 +2010,7 @@ void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags)
2012 2010
2013 hci_queue_acl(conn, &chan->data_q, skb, flags); 2011 hci_queue_acl(conn, &chan->data_q, skb, flags);
2014 2012
2015 tasklet_schedule(&hdev->tx_task); 2013 queue_work(hdev->workqueue, &hdev->tx_work);
2016} 2014}
2017EXPORT_SYMBOL(hci_send_acl); 2015EXPORT_SYMBOL(hci_send_acl);
2018 2016
@@ -2035,7 +2033,7 @@ void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb)
2035 bt_cb(skb)->pkt_type = HCI_SCODATA_PKT; 2033 bt_cb(skb)->pkt_type = HCI_SCODATA_PKT;
2036 2034
2037 skb_queue_tail(&conn->data_q, skb); 2035 skb_queue_tail(&conn->data_q, skb);
2038 tasklet_schedule(&hdev->tx_task); 2036 queue_work(hdev->workqueue, &hdev->tx_work);
2039} 2037}
2040EXPORT_SYMBOL(hci_send_sco); 2038EXPORT_SYMBOL(hci_send_sco);
2041 2039
@@ -2399,9 +2397,9 @@ static inline void hci_sched_le(struct hci_dev *hdev)
2399 hci_prio_recalculate(hdev, LE_LINK); 2397 hci_prio_recalculate(hdev, LE_LINK);
2400} 2398}
2401 2399
2402static void hci_tx_task(unsigned long arg) 2400static void hci_tx_work(struct work_struct *work)
2403{ 2401{
2404 struct hci_dev *hdev = (struct hci_dev *) arg; 2402 struct hci_dev *hdev = container_of(work, struct hci_dev, tx_work);
2405 struct sk_buff *skb; 2403 struct sk_buff *skb;
2406 2404
2407 mutex_lock(&hci_task_lock); 2405 mutex_lock(&hci_task_lock);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 23466bb48423..74f758363c2d 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2239,8 +2239,6 @@ static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *s
2239 return; 2239 return;
2240 } 2240 }
2241 2241
2242 tasklet_disable(&hdev->tx_task);
2243
2244 for (i = 0, ptr = (__le16 *) skb->data; i < ev->num_hndl; i++) { 2242 for (i = 0, ptr = (__le16 *) skb->data; i < ev->num_hndl; i++) {
2245 struct hci_conn *conn; 2243 struct hci_conn *conn;
2246 __u16 handle, count; 2244 __u16 handle, count;
@@ -2274,9 +2272,7 @@ static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *s
2274 } 2272 }
2275 } 2273 }
2276 2274
2277 tasklet_schedule(&hdev->tx_task); 2275 queue_work(hdev->workqueue, &hdev->tx_work);
2278
2279 tasklet_enable(&hdev->tx_task);
2280} 2276}
2281 2277
2282static inline void hci_mode_change_evt(struct hci_dev *hdev, struct sk_buff *skb) 2278static inline void hci_mode_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index d10a724810ec..cd064068d94a 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -535,7 +535,7 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
535 535
536 if (test_bit(HCI_RAW, &hdev->flags) || (ogf == 0x3f)) { 536 if (test_bit(HCI_RAW, &hdev->flags) || (ogf == 0x3f)) {
537 skb_queue_tail(&hdev->raw_q, skb); 537 skb_queue_tail(&hdev->raw_q, skb);
538 tasklet_schedule(&hdev->tx_task); 538 queue_work(hdev->workqueue, &hdev->tx_work);
539 } else { 539 } else {
540 skb_queue_tail(&hdev->cmd_q, skb); 540 skb_queue_tail(&hdev->cmd_q, skb);
541 queue_work(hdev->workqueue, &hdev->cmd_work); 541 queue_work(hdev->workqueue, &hdev->cmd_work);
@@ -547,7 +547,7 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
547 } 547 }
548 548
549 skb_queue_tail(&hdev->raw_q, skb); 549 skb_queue_tail(&hdev->raw_q, skb);
550 tasklet_schedule(&hdev->tx_task); 550 queue_work(hdev->workqueue, &hdev->tx_work);
551 } 551 }
552 552
553 err = len; 553 err = len;