From: Eli Billauer <eli.billauer@gmail.com>
To: gregkh@linuxfoundation.org
Cc: arnd@arndb.de, linux-kernel@vger.kernel.org,
Eli Billauer <eli.billauer@gmail.com>
Subject: [PATCH 8/8] char: xillybus: Cancel delayed work items before teardown
Date: Mon, 9 Nov 2026 12:28:00 +0100 [thread overview]
Message-ID: <20261109112800.48663-9-eli.billauer@gmail.com> (raw)
In-Reply-To: <20261109112800.48663-1-eli.billauer@gmail.com>
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@gmail.com
Signed-off-by: Eli Billauer <eli.billauer@gmail.com>
---
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
prev parent reply other threads:[~2026-11-09 11:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 11:27 [PATCH 0/8] char: xillybus: Fix issues reported by Sashiko Eli Billauer
2026-11-09 11:27 ` [PATCH 1/8] char: xillybus: Use unsigned int literal Eli Billauer
2026-11-09 11:27 ` [PATCH 2/8] char: xillybus: Safer access of unaligned pointers Eli Billauer
2026-11-09 11:27 ` [PATCH 3/8] char: xillybus: Return error in fops read method handler Eli Billauer
2026-11-09 11:27 ` [PATCH 4/8] char: xillybus: Rely on FMODE flags in poll method Eli Billauer
2026-11-09 11:27 ` [PATCH 5/8] char: xillybus: Refactor flush function Eli Billauer
2026-11-09 11:27 ` [PATCH 6/8] char: xillybus: Correct handling of wait queue Eli Billauer
2026-11-09 11:27 ` [PATCH 7/8] char: xillybus: Avoid indefinite sleep of work item Eli Billauer
2026-11-09 11:28 ` Eli Billauer [this message]
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=20261109112800.48663-9-eli.billauer@gmail.com \
--to=eli.billauer@gmail.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.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
all inboxes | Powered by JetHome®