[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230427133350.31064-7-oneukum@suse.com>
Date: Thu, 27 Apr 2023 15:33:48 +0200
From: Oliver Neukum <oneukum@...e.com>
To: wim@...ux-watchdog.org, linux@...ck-us.net,
linux-watchdog@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: Oliver Neukum <oneukum@...e.com>
Subject: [PATCH 6/8] pcwd_usb: memory ordering of interrupt and waiter
The driver manually waits in a loop for an atomic flag.
Hence memory ordering must be constrained, so that
the waiters read what the interrupt handler writes
before it touches the flag.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Oliver Neukum <oneukum@...e.com>
---
drivers/watchdog/pcwd_usb.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/watchdog/pcwd_usb.c b/drivers/watchdog/pcwd_usb.c
index b99b8fee2873..50ba88019ed6 100644
--- a/drivers/watchdog/pcwd_usb.c
+++ b/drivers/watchdog/pcwd_usb.c
@@ -193,6 +193,7 @@ static void usb_pcwd_intr_done(struct urb *urb)
usb_pcwd->cmd_command = data[0];
usb_pcwd->cmd_data_msb = data[1];
usb_pcwd->cmd_data_lsb = data[2];
+ smp_wmb(); /* make sure waiters read them */
/* notify anyone waiting that the cmd has finished */
atomic_set(&usb_pcwd->cmd_received, 1);
@@ -250,6 +251,7 @@ static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd,
got_response = 1;
}
+ smp_rmb(); /* ordering with respect to interrupt handler */
if ((got_response) && (cmd == usb_pcwd->cmd_command)) {
/* read back response */
*msb = usb_pcwd->cmd_data_msb;
--
2.40.0
Powered by blists - more mailing lists