Commit 474fee3d authored by Tejun Heo's avatar Tejun Heo Committed by Samuel Ortiz
Browse files

NFC: Use system_nrt_wq instead of custom ones



NFC is using a number of custom ordered workqueues w/ WQ_MEM_RECLAIM.
WQ_MEM_RECLAIM is unnecessary unless NFC is gonna be used as transport
for storage device, and all use cases match one work item to one
ordered workqueue - IOW, there's no actual ordering going on at all
and using system_nrt_wq gives the same behavior.

There's nothing to be gained by using custom workqueues.  Use
system_nrt_wq instead and drop all the custom ones.

Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 5db327f9
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -74,7 +74,6 @@ struct nfc_hci_dev {

	struct list_head msg_tx_queue;

	struct workqueue_struct *msg_tx_wq;
	struct work_struct msg_tx_work;

	struct timer_list cmd_timer;
@@ -82,7 +81,6 @@ struct nfc_hci_dev {

	struct sk_buff_head rx_hcp_frags;

	struct workqueue_struct *msg_rx_wq;
	struct work_struct msg_rx_work;

	struct sk_buff_head msg_rx_queue;
+0 −1
Original line number Diff line number Diff line
@@ -113,7 +113,6 @@ struct nfc_dev {
	int tx_tailroom;

	struct timer_list check_pres_timer;
	struct workqueue_struct *check_pres_wq;
	struct work_struct check_pres_work;

	struct nfc_ops *ops;
+0 −1
Original line number Diff line number Diff line
@@ -79,7 +79,6 @@ struct nfc_shdlc {

	struct sk_buff_head ack_pending_q;

	struct workqueue_struct *sm_wq;
	struct work_struct sm_work;

	struct nfc_shdlc_ops *ops;
+2 −11
Original line number Diff line number Diff line
@@ -679,7 +679,7 @@ static void nfc_release(struct device *d)

	if (dev->ops->check_presence) {
		del_timer_sync(&dev->check_pres_timer);
		destroy_workqueue(dev->check_pres_wq);
		cancel_work_sync(&dev->check_pres_work);
	}

	nfc_genl_data_exit(&dev->genl_data);
@@ -715,7 +715,7 @@ static void nfc_check_pres_timeout(unsigned long data)
{
	struct nfc_dev *dev = (struct nfc_dev *)data;

	queue_work(dev->check_pres_wq, &dev->check_pres_work);
	queue_work(system_nrt_wq, &dev->check_pres_work);
}

struct class nfc_class = {
@@ -784,20 +784,11 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops,
	dev->targets_generation = 1;

	if (ops->check_presence) {
		char name[32];
		init_timer(&dev->check_pres_timer);
		dev->check_pres_timer.data = (unsigned long)dev;
		dev->check_pres_timer.function = nfc_check_pres_timeout;

		INIT_WORK(&dev->check_pres_work, nfc_check_pres_work);
		snprintf(name, sizeof(name), "nfc%d_check_pres_wq", dev->idx);
		dev->check_pres_wq = alloc_workqueue(name, WQ_NON_REENTRANT |
						     WQ_UNBOUND |
						     WQ_MEM_RECLAIM, 1);
		if (dev->check_pres_wq == NULL) {
			kfree(dev);
			return NULL;
		}
	}

	return dev;
+6 −36
Original line number Diff line number Diff line
@@ -141,7 +141,7 @@ static void __nfc_hci_cmd_completion(struct nfc_hci_dev *hdev, int err,
	kfree(hdev->cmd_pending_msg);
	hdev->cmd_pending_msg = NULL;

	queue_work(hdev->msg_tx_wq, &hdev->msg_tx_work);
	queue_work(system_nrt_wq, &hdev->msg_tx_work);
}

void nfc_hci_resp_received(struct nfc_hci_dev *hdev, u8 result,
@@ -326,7 +326,7 @@ static void nfc_hci_cmd_timeout(unsigned long data)
{
	struct nfc_hci_dev *hdev = (struct nfc_hci_dev *)data;

	queue_work(hdev->msg_tx_wq, &hdev->msg_tx_work);
	queue_work(system_nrt_wq, &hdev->msg_tx_work);
}

static int hci_dev_connect_gates(struct nfc_hci_dev *hdev, u8 gate_count,
@@ -659,23 +659,11 @@ EXPORT_SYMBOL(nfc_hci_free_device);

int nfc_hci_register_device(struct nfc_hci_dev *hdev)
{
	struct device *dev = &hdev->ndev->dev;
	const char *devname = dev_name(dev);
	char name[32];
	int r = 0;

	mutex_init(&hdev->msg_tx_mutex);

	INIT_LIST_HEAD(&hdev->msg_tx_queue);

	INIT_WORK(&hdev->msg_tx_work, nfc_hci_msg_tx_work);
	snprintf(name, sizeof(name), "%s_hci_msg_tx_wq", devname);
	hdev->msg_tx_wq = alloc_workqueue(name, WQ_NON_REENTRANT | WQ_UNBOUND |
					  WQ_MEM_RECLAIM, 1);
	if (hdev->msg_tx_wq == NULL) {
		r = -ENOMEM;
		goto exit;
	}

	init_timer(&hdev->cmd_timer);
	hdev->cmd_timer.data = (unsigned long)hdev;
@@ -684,27 +672,10 @@ int nfc_hci_register_device(struct nfc_hci_dev *hdev)
	skb_queue_head_init(&hdev->rx_hcp_frags);

	INIT_WORK(&hdev->msg_rx_work, nfc_hci_msg_rx_work);
	snprintf(name, sizeof(name), "%s_hci_msg_rx_wq", devname);
	hdev->msg_rx_wq = alloc_workqueue(name, WQ_NON_REENTRANT | WQ_UNBOUND |
					  WQ_MEM_RECLAIM, 1);
	if (hdev->msg_rx_wq == NULL) {
		r = -ENOMEM;
		goto exit;
	}

	skb_queue_head_init(&hdev->msg_rx_queue);

	r = nfc_register_device(hdev->ndev);

exit:
	if (r < 0) {
		if (hdev->msg_tx_wq)
			destroy_workqueue(hdev->msg_tx_wq);
		if (hdev->msg_rx_wq)
			destroy_workqueue(hdev->msg_rx_wq);
	}

	return r;
	return nfc_register_device(hdev->ndev);
}
EXPORT_SYMBOL(nfc_hci_register_device);

@@ -725,9 +696,8 @@ void nfc_hci_unregister_device(struct nfc_hci_dev *hdev)

	nfc_unregister_device(hdev->ndev);

	destroy_workqueue(hdev->msg_tx_wq);

	destroy_workqueue(hdev->msg_rx_wq);
	cancel_work_sync(&hdev->msg_tx_work);
	cancel_work_sync(&hdev->msg_rx_work);
}
EXPORT_SYMBOL(nfc_hci_unregister_device);

@@ -827,7 +797,7 @@ void nfc_hci_recv_frame(struct nfc_hci_dev *hdev, struct sk_buff *skb)
		nfc_hci_hcp_message_rx(hdev, pipe, type, instruction, hcp_skb);
	} else {
		skb_queue_tail(&hdev->msg_rx_queue, hcp_skb);
		queue_work(hdev->msg_rx_wq, &hdev->msg_rx_work);
		queue_work(system_nrt_wq, &hdev->msg_rx_work);
	}
}
EXPORT_SYMBOL(nfc_hci_recv_frame);
Loading