]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-3.18/mac8390-fix-mmio-access-size-probe.patch
fix up powerpc patch headers, I messed up.
[thirdparty/kernel/stable-queue.git] / queue-3.18 / mac8390-fix-mmio-access-size-probe.patch
1 From foo@baz Thu Mar 28 21:57:57 CET 2019
2 From: Finn Thain <fthain@telegraphics.com.au>
3 Date: Sat, 16 Mar 2019 14:21:19 +1100
4 Subject: mac8390: Fix mmio access size probe
5
6 From: Finn Thain <fthain@telegraphics.com.au>
7
8 [ Upstream commit bb9e5c5bcd76f4474eac3baf643d7a39f7bac7bb ]
9
10 The bug that Stan reported is as follows. After a restart, a 16-bit NIC
11 may be incorrectly identified as a 32-bit NIC and stop working.
12
13 mac8390 slot.E: Memory length resource not found, probing
14 mac8390 slot.E: Farallon EtherMac II-C (type farallon)
15 mac8390 slot.E: MAC 00:00:c5:30:c2:99, IRQ 61, 32 KB shared memory at 0xfeed0000, 32-bit access.
16
17 The bug never arises after a cold start and only intermittently after a
18 warm start. (I didn't investigate why the bug is intermittent.)
19
20 It turns out that memcpy_toio() is deprecated and memcmp_withio() also
21 has issues. Replacing these calls with mmio accessors fixes the problem.
22
23 Reported-and-tested-by: Stan Johnson <userm57@yahoo.com>
24 Fixes: 2964db0f5904 ("m68k: Mac DP8390 update")
25 Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
26 Signed-off-by: David S. Miller <davem@davemloft.net>
27 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28 ---
29 drivers/net/ethernet/8390/mac8390.c | 19 ++++++++++++-------
30 1 file changed, 12 insertions(+), 7 deletions(-)
31
32 --- a/drivers/net/ethernet/8390/mac8390.c
33 +++ b/drivers/net/ethernet/8390/mac8390.c
34 @@ -156,8 +156,6 @@ static void dayna_block_output(struct ne
35 #define memcpy_fromio(a, b, c) memcpy((a), (void *)(b), (c))
36 #define memcpy_toio(a, b, c) memcpy((void *)(a), (b), (c))
37
38 -#define memcmp_withio(a, b, c) memcmp((a), (void *)(b), (c))
39 -
40 /* Slow Sane (16-bit chunk memory read/write) Cabletron uses this */
41 static void slow_sane_get_8390_hdr(struct net_device *dev,
42 struct e8390_pkt_hdr *hdr, int ring_page);
43 @@ -237,19 +235,26 @@ static enum mac8390_type __init mac8390_
44
45 static enum mac8390_access __init mac8390_testio(volatile unsigned long membase)
46 {
47 - unsigned long outdata = 0xA5A0B5B0;
48 - unsigned long indata = 0x00000000;
49 + u32 outdata = 0xA5A0B5B0;
50 + u32 indata = 0;
51 +
52 /* Try writing 32 bits */
53 - memcpy_toio(membase, &outdata, 4);
54 - /* Now compare them */
55 - if (memcmp_withio(&outdata, membase, 4) == 0)
56 + nubus_writel(outdata, membase);
57 + /* Now read it back */
58 + indata = nubus_readl(membase);
59 + if (outdata == indata)
60 return ACCESS_32;
61 +
62 + outdata = 0xC5C0D5D0;
63 + indata = 0;
64 +
65 /* Write 16 bit output */
66 word_memcpy_tocard(membase, &outdata, 4);
67 /* Now read it back */
68 word_memcpy_fromcard(&indata, membase, 4);
69 if (outdata == indata)
70 return ACCESS_16;
71 +
72 return ACCESS_UNKNOWN;
73 }
74