]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.4.83/rtl8187-fix-regression-on-mips-without-coherent-dma.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.4.83 / rtl8187-fix-regression-on-mips-without-coherent-dma.patch
CommitLineData
feffe874
GKH
1From b6213e413a4e0c66548153516b074df14f9d08e0 Mon Sep 17 00:00:00 2001
2From: Stanislaw Gruszka <stf_xl@wp.pl>
3Date: Mon, 10 Feb 2014 22:38:28 +0100
4Subject: rtl8187: fix regression on MIPS without coherent DMA
5
6From: Stanislaw Gruszka <stf_xl@wp.pl>
7
8commit b6213e413a4e0c66548153516b074df14f9d08e0 upstream.
9
10This patch fixes regression caused by commit a16dad77634 "MIPS: Fix
11potencial corruption". That commit fixes one corruption scenario in
12cost of adding another one, which actually start to cause crashes
13on Yeeloong laptop when rtl8187 driver is used.
14
15For correct DMA read operation on machines without DMA coherence, kernel
16have to invalidate cache, such it will refill later with new data that
17device wrote to memory, when that data is needed to process. We can only
18invalidate full cache line. Hence when cache line includes both dma
19buffer and some other data (written in cache, but not yet in main
20memory), the other data can not hit memory due to invalidation. That
21happen on rtl8187 where struct rtl8187_priv fields are located just
22before and after small buffers that are passed to USB layer and DMA
23is performed on them.
24
25To fix the problem we align buffers and reserve space after them to make
26them match cache line.
27
28This patch does not resolve all possible MIPS problems entirely, for
29that we have to assure that we always map cache aligned buffers for DMA,
30what can be complex or even not possible. But patch fixes visible and
31reproducible regression and seems other possible corruptions do not
32happen in practice, since Yeeloong laptop works stable without rtl8187
33driver.
34
35Bug report:
36https://bugzilla.kernel.org/show_bug.cgi?id=54391
37
38Reported-by: Petr Pisar <petr.pisar@atlas.cz>
39Bisected-by: Tom Li <biergaizi2009@gmail.com>
40Reported-and-tested-by: Tom Li <biergaizi2009@gmail.com>
41Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
42Acked-by: Larry Finger <Larry.Finger@lwfinger.next>
43Acked-by: Hin-Tak Leung <htl10@users.sourceforge.net>
44Signed-off-by: John W. Linville <linville@tuxdriver.com>
45Signed-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 };