]>
Commit | Line | Data |
---|---|---|
feffe874 GKH |
1 | From b6213e413a4e0c66548153516b074df14f9d08e0 Mon Sep 17 00:00:00 2001 |
2 | From: Stanislaw Gruszka <stf_xl@wp.pl> | |
3 | Date: Mon, 10 Feb 2014 22:38:28 +0100 | |
4 | Subject: rtl8187: fix regression on MIPS without coherent DMA | |
5 | ||
6 | From: Stanislaw Gruszka <stf_xl@wp.pl> | |
7 | ||
8 | commit b6213e413a4e0c66548153516b074df14f9d08e0 upstream. | |
9 | ||
10 | This patch fixes regression caused by commit a16dad77634 "MIPS: Fix | |
11 | potencial corruption". That commit fixes one corruption scenario in | |
12 | cost of adding another one, which actually start to cause crashes | |
13 | on Yeeloong laptop when rtl8187 driver is used. | |
14 | ||
15 | For correct DMA read operation on machines without DMA coherence, kernel | |
16 | have to invalidate cache, such it will refill later with new data that | |
17 | device wrote to memory, when that data is needed to process. We can only | |
18 | invalidate full cache line. Hence when cache line includes both dma | |
19 | buffer and some other data (written in cache, but not yet in main | |
20 | memory), the other data can not hit memory due to invalidation. That | |
21 | happen on rtl8187 where struct rtl8187_priv fields are located just | |
22 | before and after small buffers that are passed to USB layer and DMA | |
23 | is performed on them. | |
24 | ||
25 | To fix the problem we align buffers and reserve space after them to make | |
26 | them match cache line. | |
27 | ||
28 | This patch does not resolve all possible MIPS problems entirely, for | |
29 | that we have to assure that we always map cache aligned buffers for DMA, | |
30 | what can be complex or even not possible. But patch fixes visible and | |
31 | reproducible regression and seems other possible corruptions do not | |
32 | happen in practice, since Yeeloong laptop works stable without rtl8187 | |
33 | driver. | |
34 | ||
35 | Bug report: | |
36 | https://bugzilla.kernel.org/show_bug.cgi?id=54391 | |
37 | ||
38 | Reported-by: Petr Pisar <petr.pisar@atlas.cz> | |
39 | Bisected-by: Tom Li <biergaizi2009@gmail.com> | |
40 | Reported-and-tested-by: Tom Li <biergaizi2009@gmail.com> | |
41 | Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl> | |
42 | Acked-by: Larry Finger <Larry.Finger@lwfinger.next> | |
43 | Acked-by: Hin-Tak Leung <htl10@users.sourceforge.net> | |
44 | Signed-off-by: John W. Linville <linville@tuxdriver.com> | |
45 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
46 | ||
47 | --- | |
48 | drivers/net/wireless/rtl818x/rtl8187/rtl8187.h | 10 ++++++++-- | |
49 | 1 file changed, 8 insertions(+), 2 deletions(-) | |
50 | ||
51 | --- a/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h | |
52 | +++ b/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h | |
53 | @@ -15,6 +15,8 @@ | |
54 | #ifndef RTL8187_H | |
55 | #define RTL8187_H | |
56 | ||
57 | +#include <linux/cache.h> | |
58 | + | |
59 | #include "rtl818x.h" | |
60 | #include "leds.h" | |
61 | ||
62 | @@ -139,7 +141,10 @@ struct rtl8187_priv { | |
63 | u8 aifsn[4]; | |
64 | u8 rfkill_mask; | |
65 | struct { | |
66 | - __le64 buf; | |
67 | + union { | |
68 | + __le64 buf; | |
69 | + u8 dummy1[L1_CACHE_BYTES]; | |
70 | + } ____cacheline_aligned; | |
71 | struct sk_buff_head queue; | |
72 | } b_tx_status; /* This queue is used by both -b and non-b devices */ | |
73 | struct mutex io_mutex; | |
74 | @@ -147,7 +152,8 @@ struct rtl8187_priv { | |
75 | u8 bits8; | |
76 | __le16 bits16; | |
77 | __le32 bits32; | |
78 | - } *io_dmabuf; | |
79 | + u8 dummy2[L1_CACHE_BYTES]; | |
80 | + } *io_dmabuf ____cacheline_aligned; | |
81 | bool rfkill_off; | |
82 | u16 seqno; | |
83 | }; |