From 3d82346c5d0ff0a413c387c6edaadc0ca29a0971 Mon Sep 17 00:00:00 2001 From: Adam Baker Date: Sat, 27 Oct 2007 13:43:29 +0200 Subject: rt2x00: Place mutex around USB register access There is a buffer, csr_cache which is used to hold copies of data being passed to the USB stack which can get corrupted if multiple threads attempt to access CSR registers simultaneously. There is also the possibility if multiple threads try to access BBP or RF registers for the multiple USB operations needed to get interleaved leading to incorrect results. This patch introduces a mutex to prevent such simultaneous access. The interleaved access problem may also affect the PCI devices but if so that will be handled in a follow-up patch. Signed-off-by: Adam Baker Signed-off-by: Ivo van Doorn Signed-off-by: John W. Linville Signed-off-by: David S. Miller --- drivers/net/wireless/rt2x00/rt2x00.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'drivers/net/wireless/rt2x00/rt2x00.h') diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h index 2cd2c9fab1a5..75c9a766e421 100644 --- a/drivers/net/wireless/rt2x00/rt2x00.h +++ b/drivers/net/wireless/rt2x00/rt2x00.h @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -658,6 +659,18 @@ struct rt2x00_dev { void __iomem *csr_addr; void *csr_cache; + /* + * Mutex to protect register accesses on USB devices. + * There are 2 reasons this is needed, one is to ensure + * use of the csr_cache (for USB devices) by one thread + * isn't corrupted by another thread trying to access it. + * The other is that access to BBP and RF registers + * require multiple BUS transactions and if another thread + * attempted to access one of those registers at the same + * time one of the writes could silently fail. + */ + struct mutex usb_cache_mutex; + /* * Interface configuration. */ -- cgit v1.2.3