From: Huacai Chen <chenhuacai@loongson.cn>
To: "Bjorn Helgaas" <bhelgaas@google.com>,
"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>
Cc: linux-pci@vger.kernel.org, Jianmin Lv <lvjianmin@loongson.cn>,
Xuefeng Li <lixuefeng@loongson.cn>,
Huacai Chen <chenhuacai@gmail.com>,
Jiaxun Yang <jiaxun.yang@flygoat.com>,
Huacai Chen <chenhuacai@loongson.cn>
Subject: [PATCH V14 4/7] PCI: loongson: Don't access non-existant devices
Date: Fri, 17 Jun 2022 15:43:27 +0800 [thread overview]
Message-ID: <20220617074330.12605-5-chenhuacai@loongson.cn> (raw)
In-Reply-To: <20220617074330.12605-1-chenhuacai@loongson.cn>
On LS2K/LS7A, some non-existant devices don't return 0xffffffff when
scanning. This is a hardware flaw but we can only avoid it by software
now.
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
drivers/pci/controller/pci-loongson.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/controller/pci-loongson.c b/drivers/pci/controller/pci-loongson.c
index a1222fc15454..e22142f75d97 100644
--- a/drivers/pci/controller/pci-loongson.c
+++ b/drivers/pci/controller/pci-loongson.c
@@ -134,10 +134,20 @@ static void __iomem *cfg0_map(struct loongson_pci *priv, int bus,
return priv->cfg0_base + addroff;
}
+static bool pdev_is_existant(unsigned char bus, unsigned int device, unsigned int function)
+{
+ if ((bus == 0) && (device >= 9 && device <= 20) && (function > 0))
+ return false;
+
+ return true;
+}
+
static void __iomem *pci_loongson_map_bus(struct pci_bus *bus, unsigned int devfn,
int where)
{
unsigned char busnum = bus->number;
+ unsigned int device = PCI_SLOT(devfn);
+ unsigned int function = PCI_FUNC(devfn);
struct loongson_pci *priv = pci_bus_to_loongson_pci(bus);
if (pci_is_root_bus(bus))
@@ -147,8 +157,13 @@ static void __iomem *pci_loongson_map_bus(struct pci_bus *bus, unsigned int devf
* Do not read more than one device on the bus other than
* the host bus.
*/
- if (priv->data->flags & FLAG_DEV_FIX &&
- !pci_is_root_bus(bus) && PCI_SLOT(devfn) > 0)
+ if ((priv->data->flags & FLAG_DEV_FIX) && bus->self) {
+ if (!pci_is_root_bus(bus) && (device > 0))
+ return NULL;
+ }
+
+ /* Don't access non-existant devices */
+ if (!pdev_is_existant(busnum, device, function))
return NULL;
/* CFG0 can only access standard space */
--
2.27.0
next prev parent reply other threads:[~2022-06-17 7:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-17 7:43 [PATCH V14 0/7] PCI: Loongson pci improvements and quirks Huacai Chen
2022-06-17 7:43 ` [PATCH V14 1/7] PCI/ACPI: Guard ARM64-specific mcfg_quirks Huacai Chen
2022-06-27 21:53 ` Bjorn Helgaas
2022-06-28 2:52 ` Huacai Chen
2022-06-17 7:43 ` [PATCH V14 2/7] PCI: loongson: Use generic 8/16/32-bit config ops on LS2K/LS7A Huacai Chen
2022-06-17 7:43 ` [PATCH V14 3/7] PCI: loongson: Add ACPI init support Huacai Chen
2022-06-17 7:43 ` Huacai Chen [this message]
2022-06-27 21:38 ` [PATCH V14 4/7] PCI: loongson: Don't access non-existant devices Bjorn Helgaas
2022-06-28 13:03 ` Jianmin Lv
2022-06-28 16:04 ` Bjorn Helgaas
2022-06-29 0:33 ` Jianmin Lv
2022-06-29 10:03 ` Huacai Chen
2022-06-17 7:43 ` [PATCH V14 5/7] PCI: loongson: Improve the MRRS quirk for LS7A Huacai Chen
2022-06-17 7:43 ` [PATCH V14 6/7] PCI: Add quirk for LS7A to avoid reboot failure Huacai Chen
2022-06-17 7:43 ` [PATCH V14 7/7] PCI: Add quirk for multifunction devices of LS7A Huacai Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220617074330.12605-5-chenhuacai@loongson.cn \
--to=chenhuacai@loongson.cn \
--cc=bhelgaas@google.com \
--cc=chenhuacai@gmail.com \
--cc=jiaxun.yang@flygoat.com \
--cc=kw@linux.com \
--cc=linux-pci@vger.kernel.org \
--cc=lixuefeng@loongson.cn \
--cc=lorenzo.pieralisi@arm.com \
--cc=lvjianmin@loongson.cn \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).