afb104a581e0332449c0d2d784b189ed57a507d8
[openwrt.git] / target / linux / mvebu / patches-3.10 / 0036-PCI-mvebu-Disable-prefetchable-memory-support-in-PCI.patch
1 From 71a32c9519ba223d1dafcbe58d1699710720c5a8 Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Thu, 1 Aug 2013 15:44:19 +0200
4 Subject: [PATCH 036/203] PCI: mvebu: Disable prefetchable memory support in
5  PCI-to-PCI bridge
6
7 The Marvell PCIe driver uses an emulated PCI-to-PCI bridge to be able
8 to dynamically set up MBus address decoding windows for PCI I/O and
9 memory regions depending on the PCI devices enumerated by Linux.
10
11 However, this emulated PCI-to-PCI bridge logic makes the Linux PCI
12 core believe that prefetchable memory regions are supported (because
13 the registers are read/write), while in fact no adress decoding window
14 is ever created for such regions. Since the Marvell MBus address
15 decoding windows do not distinguish memory regions and prefetchable
16 memory regions, this patch takes a simple approach: change the
17 PCI-to-PCI bridge emulation to let the Linux PCI core know that we
18 don't support prefetchable memory regions.
19
20 To achieve this, we simply make the prefetchable memory base a
21 read-only register that always returns 0. Reading/writing all the
22 other prefetchable memory related registers has no effect.
23
24 This problem was originally reported by Finn Hoffmann
25 <finn@uni-bremen.de>, who couldn't get a RTL8111/8168B PCI NIC working
26 on the NSA310 Kirkwood platform after updating to 3.11-rc. The problem
27 was that the PCI-to-PCI bridge emulation was making the Linux PCI core
28 believe that we support prefetchable memory, so the Linux PCI core was
29 only filling the prefetchable memory base and limit registers, which
30 does not lead to a MBus window being created. The below patch has been
31 confirmed by Finn Hoffmann to fix his problem on Kirkwood, and has
32 otherwise been successfully tested on the Armada XP GP platform with a
33 e1000e PCIe NIC and a Marvell SATA PCIe card.
34
35 Reported-by: Finn Hoffmann <finn@uni-bremen.de>
36 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
37 Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
38 ---
39  drivers/pci/host/pci-mvebu.c | 27 +--------------------------
40  1 file changed, 1 insertion(+), 26 deletions(-)
41
42 --- a/drivers/pci/host/pci-mvebu.c
43 +++ b/drivers/pci/host/pci-mvebu.c
44 @@ -86,10 +86,6 @@ struct mvebu_sw_pci_bridge {
45         u16 secondary_status;
46         u16 membase;
47         u16 memlimit;
48 -       u16 prefmembase;
49 -       u16 prefmemlimit;
50 -       u32 prefbaseupper;
51 -       u32 preflimitupper;
52         u16 iobaseupper;
53         u16 iolimitupper;
54         u8 cappointer;
55 @@ -419,15 +415,7 @@ static int mvebu_sw_pci_bridge_read(stru
56                 break;
57  
58         case PCI_PREF_MEMORY_BASE:
59 -               *value = (bridge->prefmemlimit << 16 | bridge->prefmembase);
60 -               break;
61 -
62 -       case PCI_PREF_BASE_UPPER32:
63 -               *value = bridge->prefbaseupper;
64 -               break;
65 -
66 -       case PCI_PREF_LIMIT_UPPER32:
67 -               *value = bridge->preflimitupper;
68 +               *value = 0;
69                 break;
70  
71         case PCI_IO_BASE_UPPER16:
72 @@ -501,19 +489,6 @@ static int mvebu_sw_pci_bridge_write(str
73                 mvebu_pcie_handle_membase_change(port);
74                 break;
75  
76 -       case PCI_PREF_MEMORY_BASE:
77 -               bridge->prefmembase = value & 0xffff;
78 -               bridge->prefmemlimit = value >> 16;
79 -               break;
80 -
81 -       case PCI_PREF_BASE_UPPER32:
82 -               bridge->prefbaseupper = value;
83 -               break;
84 -
85 -       case PCI_PREF_LIMIT_UPPER32:
86 -               bridge->preflimitupper = value;
87 -               break;
88 -
89         case PCI_IO_BASE_UPPER16:
90                 bridge->iobaseupper = value & 0xffff;
91                 bridge->iolimitupper = value >> 16;