Commit 0dba4d31 authored by Stanislaw Gruszka's avatar Stanislaw Gruszka Committed by Greg Kroah-Hartman

rtl8187: fix regression on MIPS without coherent DMA

commit b6213e41 upstream.

This patch fixes regression caused by commit a16dad77 "MIPS: Fix
potencial corruption". That commit fixes one corruption scenario in
cost of adding another one, which actually start to cause crashes
on Yeeloong laptop when rtl8187 driver is used.

For correct DMA read operation on machines without DMA coherence, kernel
have to invalidate cache, such it will refill later with new data that
device wrote to memory, when that data is needed to process. We can only
invalidate full cache line. Hence when cache line includes both dma
buffer and some other data (written in cache, but not yet in main
memory), the other data can not hit memory due to invalidation. That
happen on rtl8187 where struct rtl8187_priv fields are located just
before and after small buffers that are passed to USB layer and DMA
is performed on them.

To fix the problem we align buffers and reserve space after them to make
them match cache line.

This patch does not resolve all possible MIPS problems entirely, for
that we have to assure that we always map cache aligned buffers for DMA,
what can be complex or even not possible. But patch fixes visible and
reproducible regression and seems other possible corruptions do not
happen in practice, since Yeeloong laptop works stable without rtl8187
driver.

Bug report:
https://bugzilla.kernel.org/show_bug.cgi?id=54391Reported-by: default avatarPetr Pisar <petr.pisar@atlas.cz>
Bisected-by: default avatarTom Li <biergaizi2009@gmail.com>
Reported-and-tested-by: default avatarTom Li <biergaizi2009@gmail.com>
Signed-off-by: default avatarStanislaw Gruszka <stf_xl@wp.pl>
Acked-by: default avatarLarry Finger <Larry.Finger@lwfinger.next>
Acked-by: default avatarHin-Tak Leung <htl10@users.sourceforge.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 32c36d88
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#ifndef RTL8187_H #ifndef RTL8187_H
#define RTL8187_H #define RTL8187_H
#include <linux/cache.h>
#include "rtl818x.h" #include "rtl818x.h"
#include "leds.h" #include "leds.h"
...@@ -139,7 +141,10 @@ struct rtl8187_priv { ...@@ -139,7 +141,10 @@ struct rtl8187_priv {
u8 aifsn[4]; u8 aifsn[4];
u8 rfkill_mask; u8 rfkill_mask;
struct { struct {
__le64 buf; union {
__le64 buf;
u8 dummy1[L1_CACHE_BYTES];
} ____cacheline_aligned;
struct sk_buff_head queue; struct sk_buff_head queue;
} b_tx_status; /* This queue is used by both -b and non-b devices */ } b_tx_status; /* This queue is used by both -b and non-b devices */
struct mutex io_mutex; struct mutex io_mutex;
...@@ -147,7 +152,8 @@ struct rtl8187_priv { ...@@ -147,7 +152,8 @@ struct rtl8187_priv {
u8 bits8; u8 bits8;
__le16 bits16; __le16 bits16;
__le32 bits32; __le32 bits32;
} *io_dmabuf; u8 dummy2[L1_CACHE_BYTES];
} *io_dmabuf ____cacheline_aligned;
bool rfkill_off; bool rfkill_off;
u16 seqno; u16 seqno;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment