Skip to content

Commit b78752c

Browse files
holtmannGustavo F. Padovan
authored andcommitted
Bluetooth: Process recv path in a workqueue instead of a tasklet
Run recv process in workqueue helps a lot with our processing as the recv path will also be in the process context, i.e., now all our tx and rx are in process context. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
1 parent 416dc94 commit b78752c

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

‎include/net/bluetooth/hci_core.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,9 @@ struct hci_dev {
194194
struct delayed_work discov_off;
195195

196196
struct timer_list cmd_timer;
197+
198+
struct work_struct rx_work;
197199
struct tasklet_struct cmd_task;
198-
struct tasklet_struct rx_task;
199200
struct tasklet_struct tx_task;
200201

201202
struct sk_buff_head rx_q;

‎net/bluetooth/hci_core.c‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656

5757
int enable_hs;
5858

59+
static void hci_rx_work(struct work_struct *work);
5960
static void hci_cmd_task(unsigned long arg);
60-
static void hci_rx_task(unsigned long arg);
6161
static void hci_tx_task(unsigned long arg);
6262

6363
static DEFINE_RWLOCK(hci_task_lock);
@@ -547,9 +547,9 @@ int hci_dev_open(__u16 dev)
547547
}
548548
} else {
549549
/* Init failed, cleanup */
550-
tasklet_kill(&hdev->rx_task);
551550
tasklet_kill(&hdev->tx_task);
552551
tasklet_kill(&hdev->cmd_task);
552+
flush_work(&hdev->rx_work);
553553

554554
skb_queue_purge(&hdev->cmd_q);
555555
skb_queue_purge(&hdev->rx_q);
@@ -586,8 +586,8 @@ static int hci_dev_do_close(struct hci_dev *hdev)
586586
}
587587

588588
/* Kill RX and TX tasks */
589-
tasklet_kill(&hdev->rx_task);
590589
tasklet_kill(&hdev->tx_task);
590+
flush_work(&hdev->rx_work);
591591

592592
if (hdev->discov_timeout > 0) {
593593
cancel_delayed_work(&hdev->discov_off);
@@ -1456,8 +1456,9 @@ int hci_register_dev(struct hci_dev *hdev)
14561456
hdev->sniff_max_interval = 800;
14571457
hdev->sniff_min_interval = 80;
14581458

1459-
tasklet_init(&hdev->cmd_task, hci_cmd_task, (unsigned long) hdev);
1460-
tasklet_init(&hdev->rx_task, hci_rx_task, (unsigned long) hdev);
1459+
INIT_WORK(&hdev->rx_work, hci_rx_work);
1460+
1461+
tasklet_init(&hdev->cmd_task, hci_cmd_task,(unsigned long) hdev);
14611462
tasklet_init(&hdev->tx_task, hci_tx_task, (unsigned long) hdev);
14621463

14631464
skb_queue_head_init(&hdev->rx_q);
@@ -1623,9 +1624,8 @@ int hci_recv_frame(struct sk_buff *skb)
16231624
/* Time stamp */
16241625
__net_timestamp(skb);
16251626

1626-
/* Queue frame for rx task */
16271627
skb_queue_tail(&hdev->rx_q, skb);
1628-
tasklet_schedule(&hdev->rx_task);
1628+
queue_work(hdev->workqueue, &hdev->rx_work);
16291629

16301630
return 0;
16311631
}
@@ -2486,9 +2486,9 @@ static inline void hci_scodata_packet(struct hci_dev *hdev, struct sk_buff *skb)
24862486
kfree_skb(skb);
24872487
}
24882488

2489-
static void hci_rx_task(unsigned long arg)
2489+
static void hci_rx_work(struct work_struct *work)
24902490
{
2491-
struct hci_dev *hdev = (struct hci_dev *) arg;
2491+
struct hci_dev *hdev = container_of(work, struct hci_dev, rx_work);
24922492
struct sk_buff *skb;
24932493

24942494
BT_DBG("%s", hdev->name);
@@ -2519,6 +2519,7 @@ static void hci_rx_task(unsigned long arg)
25192519
/* Process frame */
25202520
switch (bt_cb(skb)->pkt_type) {
25212521
case HCI_EVENT_PKT:
2522+
BT_DBG("%s Event packet", hdev->name);
25222523
hci_event_packet(hdev, skb);
25232524
break;
25242525

0 commit comments

Comments
 (0)