linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Allen Pais <apais@linux.microsoft.com>
To: linux-kernel@vger.kernel.org
Cc: tj@kernel.org, keescook@chromium.org, kys@microsoft.com,
	haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com,
	linux-hyperv@vger.kernel.org
Subject: [PATCH v2 2/2] PCI: hv: Convert from tasklet to BH workqueue
Date: Wed,  3 Apr 2024 16:55:42 +0000	[thread overview]
Message-ID: <20240403165542.21738-2-apais@linux.microsoft.com> (raw)
In-Reply-To: <20240403165542.21738-1-apais@linux.microsoft.com>

The only generic interface to execute asynchronously in the BH context is
tasklet; however, it's marked deprecated and has some design flaws. To
replace tasklets, BH workqueue support was recently added. A BH workqueue
behaves similarly to regular workqueues except that the queued work items
are executed in the BH context.

This patch converts drivers/pci/pci-hyperv.c from tasklet to BH workqueue.

Based on the work done by Tejun Heo <tj@kernel.org>
Branch:https://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-6.10

Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 drivers/pci/controller/pci-hyperv.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
index 5992280e8110..2823fd50a69c 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -50,6 +50,7 @@
 #include <linux/irqdomain.h>
 #include <linux/acpi.h>
 #include <linux/sizes.h>
+#include <linux/workqueue.h>
 #include <asm/mshyperv.h>
 
 /*
@@ -2000,7 +2001,7 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
 		udelay(100);
 	}
 
-	tasklet_enable(&channel->callback_event);
+	enable_and_queue_work(system_bh_wq, &channel->callback_event);
 
 	if (comp.comp_pkt.completion_status < 0) {
 		dev_err(&hbus->hdev->device,
@@ -2026,7 +2027,7 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
 	return;
 
 enable_tasklet:
-	tasklet_enable(&channel->callback_event);
+	enable_and_queue_work(system_bh_wq, &channel->callback_event);
 	/*
 	 * The completion packet on the stack becomes invalid after 'return';
 	 * remove the ID from the VMbus requestor if the identifier is still
@@ -3890,9 +3891,9 @@ static void hv_pci_remove(struct hv_device *hdev)
 
 	hbus = hv_get_drvdata(hdev);
 	if (hbus->state == hv_pcibus_installed) {
-		tasklet_disable(&hdev->channel->callback_event);
+		disable_work_sync(&hdev->channel->callback_event);
 		hbus->state = hv_pcibus_removing;
-		tasklet_enable(&hdev->channel->callback_event);
+		enable_and_queue_work(system_bh_wq, &hdev->channel->callback_event);
 		destroy_workqueue(hbus->wq);
 		hbus->wq = NULL;
 		/*
@@ -3948,14 +3949,14 @@ static int hv_pci_suspend(struct hv_device *hdev)
 	 * it knows that no new work item can be scheduled, and then it flushes
 	 * hbus->wq and safely closes the vmbus channel.
 	 */
-	tasklet_disable(&hdev->channel->callback_event);
+	disable_work_sync(&hdev->channel->callback_event);
 
 	/* Change the hbus state to prevent new work items. */
 	old_state = hbus->state;
 	if (hbus->state == hv_pcibus_installed)
 		hbus->state = hv_pcibus_removing;
 
-	tasklet_enable(&hdev->channel->callback_event);
+	enable_and_queue_work(system_bh_wq, &hdev->channel->callback_event);
 
 	if (old_state != hv_pcibus_installed)
 		return -EINVAL;
-- 
2.17.1


  reply	other threads:[~2024-04-03 16:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-03 16:55 [PATCH v2 1/2] hyperv: Convert from tasklet to BH workqueue Allen Pais
2024-04-03 16:55 ` Allen Pais [this message]
2024-04-10 18:08 ` Michael Kelley
2024-04-11 23:58   ` Allen Pais

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240403165542.21738-2-apais@linux.microsoft.com \
    --to=apais@linux.microsoft.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=keescook@chromium.org \
    --cc=kys@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=wei.liu@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).