0dead7d61dfb4713de9a1033a318ea7f2700ac0d
[openwrt/staging/pepe2k.git] /
1 From patchwork Thu Sep 28 12:58:32 2017
2 Content-Type: text/plain; charset="utf-8"
3 MIME-Version: 1.0
4 Content-Transfer-Encoding: 7bit
5 Subject: [v2, 1/7] PCI: aardvark: fix logic in PCI configuration read/write
6 functions
7 X-Patchwork-Submitter: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
8 X-Patchwork-Id: 819586
9 Message-Id: <20170928125838.11887-2-thomas.petazzoni@free-electrons.com>
10 To: Bjorn Helgaas <bhelgaas@google.com>, linux-pci@vger.kernel.org
11 Cc: Jason Cooper <jason@lakedaemon.net>, Andrew Lunn <andrew@lunn.ch>,
12 Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>, Gregory Clement
13 <gregory.clement@free-electrons.com>,
14 Nadav Haklai <nadavh@marvell.com>, Hanna Hawa <hannah@marvell.com>,
15 Yehuda Yitschak <yehuday@marvell.com>,
16 linux-arm-kernel@lists.infradead.org, Antoine Tenart
17 <antoine.tenart@free-electrons.com>, =?utf-8?q?Miqu=C3=A8l_Raynal?=
18 <miquel.raynal@free-electrons.com>, Victor Gu <xigu@marvell.com>,
19 stable@vger.kernel.org, Thomas Petazzoni
20 <thomas.petazzoni@free-electrons.com>
21 Date: Thu, 28 Sep 2017 14:58:32 +0200
22 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
23 List-Id: <linux-pci.vger.kernel.org>
24
25 From: Victor Gu <xigu@marvell.com>
26
27 The PCI configuration space read/write functions were special casing
28 the situation where PCI_SLOT(devfn) != 0, and returned
29 PCIBIOS_DEVICE_NOT_FOUND in this case.
30
31 However, will this is what is intended for the root bus, it is not
32 intended for the child busses, as it prevents discovering devices with
33 PCI_SLOT(x) != 0. Therefore, we return PCIBIOS_DEVICE_NOT_FOUND only
34 if we're on the root bus.
35
36 Fixes: 8c39d710363c1 ("PCI: aardvark: Add Aardvark PCI host controller driver")
37 Cc: <stable@vger.kernel.org>
38 Signed-off-by: Victor Gu <xigu@marvell.com>
39 Reviewed-by: Wilson Ding <dingwei@marvell.com>
40 Reviewed-by: Nadav Haklai <nadavh@marvell.com>
41 [Thomas: tweak commit log.]
42 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
43 ---
44 drivers/pci/host/pci-aardvark.c | 4 ++--
45 1 file changed, 2 insertions(+), 2 deletions(-)
46
47 --- a/drivers/pci/host/pci-aardvark.c
48 +++ b/drivers/pci/host/pci-aardvark.c
49 @@ -440,7 +440,7 @@ static int advk_pcie_rd_conf(struct pci_
50 u32 reg;
51 int ret;
52
53 - if (PCI_SLOT(devfn) != 0) {
54 + if ((bus->number == pcie->root_bus_nr) && (PCI_SLOT(devfn) != 0)) {
55 *val = 0xffffffff;
56 return PCIBIOS_DEVICE_NOT_FOUND;
57 }
58 @@ -494,7 +494,7 @@ static int advk_pcie_wr_conf(struct pci_
59 int offset;
60 int ret;
61
62 - if (PCI_SLOT(devfn) != 0)
63 + if ((bus->number == pcie->root_bus_nr) && (PCI_SLOT(devfn) != 0))
64 return PCIBIOS_DEVICE_NOT_FOUND;
65
66 if (where % size)