From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-kernel@vger.kernel.org
Cc: Hans de Goede <hdegoede@redhat.com>,
Tomas Winkler <tomas.winkler@intel.com>,
Wentong Wu <wentong.wu@intel.com>, Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH 1/3] mei: vsc: Call wake_up() and event handler in a workqueue
Date: Mon, 12 Feb 2024 11:46:16 +0200 [thread overview]
Message-ID: <20240212094618.344921-2-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <20240212094618.344921-1-sakari.ailus@linux.intel.com>
The event handler, in this case that of mei_vsc_event_cb() of
platform-vsc.c, is called from a threaded interrupt handler in
uninterruptible context. However there are multiple places where the
handler may sleep. This patch creates a per-device workqueue and calls
wake_up() and the event callback from queued work where sleeping is
allowed.
Fixes: 566f5ca97680 ("mei: Add transport driver for IVSC device")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/misc/mei/vsc-tp.c | 35 ++++++++++++++++++++++++-----------
1 file changed, 24 insertions(+), 11 deletions(-)
diff --git a/drivers/misc/mei/vsc-tp.c b/drivers/misc/mei/vsc-tp.c
index 6f4a4be6ccb5..264ece72f0bf 100644
--- a/drivers/misc/mei/vsc-tp.c
+++ b/drivers/misc/mei/vsc-tp.c
@@ -72,6 +72,8 @@ struct vsc_tp {
atomic_t assert_cnt;
wait_queue_head_t xfer_wait;
+ struct workqueue_struct *event_workqueue;
+ struct work_struct event_work;
vsc_tp_event_cb_t event_notify;
void *event_notify_context;
@@ -416,19 +418,19 @@ static irqreturn_t vsc_tp_isr(int irq, void *data)
atomic_inc(&tp->assert_cnt);
- wake_up(&tp->xfer_wait);
+ queue_work(tp->event_workqueue, &tp->event_work);
- return IRQ_WAKE_THREAD;
+ return IRQ_HANDLED;
}
-static irqreturn_t vsc_tp_thread_isr(int irq, void *data)
+static void vsc_tp_event_work(struct work_struct *work)
{
- struct vsc_tp *tp = data;
+ struct vsc_tp *tp = container_of(work, struct vsc_tp, event_work);;
+
+ wake_up(&tp->xfer_wait);
if (tp->event_notify)
tp->event_notify(tp->event_notify_context);
-
- return IRQ_HANDLED;
}
static int vsc_tp_match_any(struct acpi_device *adev, void *data)
@@ -481,13 +483,18 @@ static int vsc_tp_probe(struct spi_device *spi)
init_waitqueue_head(&tp->xfer_wait);
tp->spi = spi;
+ tp->event_workqueue = create_singlethread_workqueue(dev_name(dev));
+ if (!tp->event_workqueue)
+ return -ENOMEM;
+
+ INIT_WORK(&tp->event_work, vsc_tp_event_work);
+
irq_set_status_flags(spi->irq, IRQ_DISABLE_UNLAZY);
- ret = devm_request_threaded_irq(dev, spi->irq, vsc_tp_isr,
- vsc_tp_thread_isr,
- IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
- dev_name(dev), tp);
+ ret = devm_request_irq(dev, spi->irq, vsc_tp_isr,
+ IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+ dev_name(dev), tp);
if (ret)
- return ret;
+ goto err_destroy_workqueue;
mutex_init(&tp->mutex);
@@ -516,6 +523,10 @@ static int vsc_tp_probe(struct spi_device *spi)
return 0;
+err_destroy_workqueue:
+ destroy_workqueue(tp->event_workqueue);
+ kfree(tp->event_workqueue);
+
err_destroy_lock:
mutex_destroy(&tp->mutex);
@@ -528,6 +539,8 @@ static void vsc_tp_remove(struct spi_device *spi)
platform_device_unregister(tp->pdev);
+ destroy_workqueue(tp->event_workqueue);
+ kfree(tp->event_workqueue);
mutex_destroy(&tp->mutex);
}
--
2.39.2
next prev parent reply other threads:[~2024-02-12 9:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-12 9:46 [PATCH 0/3] MEI VSC fixes and cleanups Sakari Ailus
2024-02-12 9:46 ` Sakari Ailus [this message]
2024-02-18 1:23 ` [PATCH 1/3] mei: vsc: Call wake_up() and event handler in a workqueue Wu, Wentong
2024-02-19 18:18 ` Sakari Ailus
2024-02-12 9:46 ` [PATCH 2/3] mei: vsc: Don't use sleeping condition in wait_event_timeout() Sakari Ailus
2024-02-12 9:46 ` [PATCH 3/3] mei: vsc: Assign pinfo fields in variable declaration Sakari Ailus
2024-02-12 10:02 ` Greg Kroah-Hartman
2024-02-12 10:14 ` Arnd Bergmann
2024-02-12 10:41 ` Greg Kroah-Hartman
2024-02-12 10:14 ` Sakari Ailus
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=20240212094618.344921-2-sakari.ailus@linux.intel.com \
--to=sakari.ailus@linux.intel.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tomas.winkler@intel.com \
--cc=wentong.wu@intel.com \
/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
all inboxes | Powered by JetHome®