[PATCH 8/8] char: xillybus: Cancel delayed work items before teardown
From: Eli Billauer
Date: Mon Nov 09 2026 - 06:35:50 EST
xillybus_core queues only delayed work items in its workqueue. Use
cancel_delayed_work_sync() instead of flush_workqueue() to clean up
queued work items, as the latter does not wait for or cancel delayed
work items whose timers have not yet expired.
Assisted-by: Sashiko-0.2.5:gemini-3.1-pro-preview
Link: https://sashiko.dev/#/patchset/20260630092330.43534-1-eli.billauer@xxxxxxxxx
Signed-off-by: Eli Billauer <eli.billauer@xxxxxxxxx>
---
drivers/char/xillybus/xillybus_core.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/drivers/char/xillybus/xillybus_core.c b/drivers/char/xillybus/xillybus_core.c
index ab8ac78b28dc..644447502d09 100644
--- a/drivers/char/xillybus/xillybus_core.c
+++ b/drivers/char/xillybus/xillybus_core.c
@@ -1926,9 +1926,10 @@ struct xilly_endpoint *xillybus_init_endpoint(struct device *dev)
}
EXPORT_SYMBOL(xillybus_init_endpoint);
-static int xilly_quiesce(struct xilly_endpoint *endpoint)
+static int xilly_quiesce(struct xilly_endpoint *endpoint, int to_cancel)
{
long t;
+ int i;
endpoint->idtlen = -1;
endpoint->num_channels = 0;
@@ -1944,6 +1945,9 @@ static int xilly_quiesce(struct xilly_endpoint *endpoint)
xilly_allow_isr(endpoint, false);
+ for (i = 1; i <= to_cancel; i++)
+ cancel_delayed_work_sync(&endpoint->channels[i]->rd_workitem);
+
if (t <= 0) {
dev_err(endpoint->dev,
"Failed to quiesce the device on exit.\n");
@@ -1956,6 +1960,7 @@ int xillybus_endpoint_discovery(struct xilly_endpoint *endpoint)
{
int rc;
long t;
+ int quiesce_channels = 0;
void *bootstrap_resources;
int idtbuffersize = (1 << PAGE_SHIFT);
@@ -2058,6 +2063,7 @@ int xillybus_endpoint_discovery(struct xilly_endpoint *endpoint)
goto failed_idt;
xilly_allow_isr(endpoint, true);
+ quiesce_channels = endpoint->num_channels;
rc = xillybus_init_chrdev(dev, &xillybus_fops,
endpoint->owner, endpoint,
@@ -2074,8 +2080,7 @@ int xillybus_endpoint_discovery(struct xilly_endpoint *endpoint)
return 0;
failed_idt:
- xilly_quiesce(endpoint);
- flush_workqueue(xillybus_wq);
+ xilly_quiesce(endpoint, quiesce_channels);
return rc;
}
@@ -2085,13 +2090,7 @@ void xillybus_endpoint_remove(struct xilly_endpoint *endpoint)
{
xillybus_cleanup_chrdev(endpoint, endpoint->dev);
- xilly_quiesce(endpoint);
-
- /*
- * Flushing is done upon endpoint release to prevent access to memory
- * just about to be released. This makes the quiesce complete.
- */
- flush_workqueue(xillybus_wq);
+ xilly_quiesce(endpoint, endpoint->num_channels);
}
EXPORT_SYMBOL(xillybus_endpoint_remove);
@@ -2106,7 +2105,7 @@ static int __init xillybus_init(void)
static void __exit xillybus_exit(void)
{
- /* flush_workqueue() was called for each endpoint released */
+ /* Work items have been canceled for each endpoint separately */
destroy_workqueue(xillybus_wq);
}
--
2.17.1