소스 검색

Bluetooth: Move command task to workqueue

As part of the moving on all the Bluetooth processing to Process context.

Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Gustavo F. Padovan 13 년 전
부모
커밋
c347b765fe
4개의 변경된 파일15개의 추가작업 그리고 15개의 파일을 삭제
  1. 1 1
      include/net/bluetooth/hci_core.h
  2. 11 11
      net/bluetooth/hci_core.c
  3. 2 2
      net/bluetooth/hci_event.c
  4. 1 1
      net/bluetooth/hci_sock.c

+ 1 - 1
include/net/bluetooth/hci_core.h

@@ -196,7 +196,7 @@ struct hci_dev {
 	struct timer_list	cmd_timer;
 	struct timer_list	cmd_timer;
 
 
 	struct work_struct	rx_work;
 	struct work_struct	rx_work;
-	struct tasklet_struct	cmd_task;
+	struct work_struct	cmd_work;
 	struct tasklet_struct	tx_task;
 	struct tasklet_struct	tx_task;
 
 
 	struct sk_buff_head	rx_q;
 	struct sk_buff_head	rx_q;

+ 11 - 11
net/bluetooth/hci_core.c

@@ -57,7 +57,7 @@
 int enable_hs;
 int enable_hs;
 
 
 static void hci_rx_work(struct work_struct *work);
 static void hci_rx_work(struct work_struct *work);
-static void hci_cmd_task(unsigned long arg);
+static void hci_cmd_work(struct work_struct *work);
 static void hci_tx_task(unsigned long arg);
 static void hci_tx_task(unsigned long arg);
 
 
 static DEFINE_MUTEX(hci_task_lock);
 static DEFINE_MUTEX(hci_task_lock);
@@ -209,7 +209,7 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
 		skb->dev = (void *) hdev;
 		skb->dev = (void *) hdev;
 
 
 		skb_queue_tail(&hdev->cmd_q, skb);
 		skb_queue_tail(&hdev->cmd_q, skb);
-		tasklet_schedule(&hdev->cmd_task);
+		queue_work(hdev->workqueue, &hdev->cmd_work);
 	}
 	}
 	skb_queue_purge(&hdev->driver_init);
 	skb_queue_purge(&hdev->driver_init);
 
 
@@ -548,7 +548,7 @@ int hci_dev_open(__u16 dev)
 	} else {
 	} else {
 		/* Init failed, cleanup */
 		/* Init failed, cleanup */
 		tasklet_kill(&hdev->tx_task);
 		tasklet_kill(&hdev->tx_task);
-		tasklet_kill(&hdev->cmd_task);
+		flush_work(&hdev->cmd_work);
 		flush_work(&hdev->rx_work);
 		flush_work(&hdev->rx_work);
 
 
 		skb_queue_purge(&hdev->cmd_q);
 		skb_queue_purge(&hdev->cmd_q);
@@ -617,8 +617,8 @@ static int hci_dev_do_close(struct hci_dev *hdev)
 		clear_bit(HCI_INIT, &hdev->flags);
 		clear_bit(HCI_INIT, &hdev->flags);
 	}
 	}
 
 
-	/* Kill cmd task */
-	tasklet_kill(&hdev->cmd_task);
+	/* flush cmd  work */
+	flush_work(&hdev->cmd_work);
 
 
 	/* Drop queues */
 	/* Drop queues */
 	skb_queue_purge(&hdev->rx_q);
 	skb_queue_purge(&hdev->rx_q);
@@ -1207,7 +1207,7 @@ static void hci_cmd_timer(unsigned long arg)
 
 
 	BT_ERR("%s command tx timeout", hdev->name);
 	BT_ERR("%s command tx timeout", hdev->name);
 	atomic_set(&hdev->cmd_cnt, 1);
 	atomic_set(&hdev->cmd_cnt, 1);
-	tasklet_schedule(&hdev->cmd_task);
+	queue_work(hdev->workqueue, &hdev->cmd_work);
 }
 }
 
 
 struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev,
 struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev,
@@ -1458,8 +1458,8 @@ int hci_register_dev(struct hci_dev *hdev)
 	hdev->sniff_min_interval = 80;
 	hdev->sniff_min_interval = 80;
 
 
 	INIT_WORK(&hdev->rx_work, hci_rx_work);
 	INIT_WORK(&hdev->rx_work, hci_rx_work);
+	INIT_WORK(&hdev->cmd_work, hci_cmd_work);
 
 
-	tasklet_init(&hdev->cmd_task, hci_cmd_task,(unsigned long) hdev);
 	tasklet_init(&hdev->tx_task, hci_tx_task, (unsigned long) hdev);
 	tasklet_init(&hdev->tx_task, hci_tx_task, (unsigned long) hdev);
 
 
 	skb_queue_head_init(&hdev->rx_q);
 	skb_queue_head_init(&hdev->rx_q);
@@ -1922,7 +1922,7 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param)
 		hdev->init_last_cmd = opcode;
 		hdev->init_last_cmd = opcode;
 
 
 	skb_queue_tail(&hdev->cmd_q, skb);
 	skb_queue_tail(&hdev->cmd_q, skb);
-	tasklet_schedule(&hdev->cmd_task);
+	queue_work(hdev->workqueue, &hdev->cmd_work);
 
 
 	return 0;
 	return 0;
 }
 }
@@ -2560,9 +2560,9 @@ static void hci_rx_work(struct work_struct *work)
 	mutex_unlock(&hci_task_lock);
 	mutex_unlock(&hci_task_lock);
 }
 }
 
 
-static void hci_cmd_task(unsigned long arg)
+static void hci_cmd_work(struct work_struct *work)
 {
 {
-	struct hci_dev *hdev = (struct hci_dev *) arg;
+	struct hci_dev *hdev = container_of(work, struct hci_dev, cmd_work);
 	struct sk_buff *skb;
 	struct sk_buff *skb;
 
 
 	BT_DBG("%s cmd %d", hdev->name, atomic_read(&hdev->cmd_cnt));
 	BT_DBG("%s cmd %d", hdev->name, atomic_read(&hdev->cmd_cnt));
@@ -2586,7 +2586,7 @@ static void hci_cmd_task(unsigned long arg)
 				  jiffies + msecs_to_jiffies(HCI_CMD_TIMEOUT));
 				  jiffies + msecs_to_jiffies(HCI_CMD_TIMEOUT));
 		} else {
 		} else {
 			skb_queue_head(&hdev->cmd_q, skb);
 			skb_queue_head(&hdev->cmd_q, skb);
-			tasklet_schedule(&hdev->cmd_task);
+			queue_work(hdev->workqueue, &hdev->cmd_work);
 		}
 		}
 	}
 	}
 }
 }

+ 2 - 2
net/bluetooth/hci_event.c

@@ -2112,7 +2112,7 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk
 	if (ev->ncmd) {
 	if (ev->ncmd) {
 		atomic_set(&hdev->cmd_cnt, 1);
 		atomic_set(&hdev->cmd_cnt, 1);
 		if (!skb_queue_empty(&hdev->cmd_q))
 		if (!skb_queue_empty(&hdev->cmd_q))
-			tasklet_schedule(&hdev->cmd_task);
+			queue_work(hdev->workqueue, &hdev->cmd_work);
 	}
 	}
 }
 }
 
 
@@ -2194,7 +2194,7 @@ static inline void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb)
 	if (ev->ncmd && !test_bit(HCI_RESET, &hdev->flags)) {
 	if (ev->ncmd && !test_bit(HCI_RESET, &hdev->flags)) {
 		atomic_set(&hdev->cmd_cnt, 1);
 		atomic_set(&hdev->cmd_cnt, 1);
 		if (!skb_queue_empty(&hdev->cmd_q))
 		if (!skb_queue_empty(&hdev->cmd_q))
-			tasklet_schedule(&hdev->cmd_task);
+			queue_work(hdev->workqueue, &hdev->cmd_work);
 	}
 	}
 }
 }
 
 

+ 1 - 1
net/bluetooth/hci_sock.c

@@ -538,7 +538,7 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
 			tasklet_schedule(&hdev->tx_task);
 			tasklet_schedule(&hdev->tx_task);
 		} else {
 		} else {
 			skb_queue_tail(&hdev->cmd_q, skb);
 			skb_queue_tail(&hdev->cmd_q, skb);
-			tasklet_schedule(&hdev->cmd_task);
+			queue_work(hdev->workqueue, &hdev->cmd_work);
 		}
 		}
 	} else {
 	} else {
 		if (!capable(CAP_NET_RAW)) {
 		if (!capable(CAP_NET_RAW)) {