From: ddaney.cavm@gmail.com (David Daney)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64/pci: Add quirks for Cavium Thunder PCI bridges.
Date: Tue, 22 Sep 2015 17:09:56 -0700 [thread overview]
Message-ID: <1442966996-13419-1-git-send-email-ddaney.cavm@gmail.com> (raw)
From: David Daney <david.daney@cavium.com>
The Cavium ThunderX SoC needs a PCI quirk for its on-chip bridges.
Since it is arm64, create a new quirks.c file there to contain arm64
related quirks. Add the ThunderX bridge quirk, gated by a new config
variable, so that it can be disabled for kernels that aren't expected
to be used on ThunderX.
Signed-off-by: David Daney <david.daney@cavium.com>
---
arch/arm64/Kconfig | 11 +++++++++++
arch/arm64/kernel/Makefile | 2 +-
arch/arm64/kernel/quirks.c | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 48 insertions(+), 1 deletion(-)
create mode 100644 arch/arm64/kernel/quirks.c
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 8bd55c5..7fdf94a 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -359,6 +359,17 @@ config CAVIUM_ERRATUM_23154
If unsure, say Y.
+config CAVIUM_THUNDER_PCI_QUIRKS
+ bool "Cavium PCI quirk workarounds"
+ depends on PCI
+ help
+
+ Some ThunderX systems have PCI quirk workarounds that must
+ be enabled to be able to use PCI devices. This option
+ enables the workarounds.
+
+ If unsure, say Y.
+
endmenu
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index 22dc9bc..f80aa01 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -33,7 +33,7 @@ arm64-obj-$(CONFIG_CPU_IDLE) += cpuidle.o
arm64-obj-$(CONFIG_JUMP_LABEL) += jump_label.o
arm64-obj-$(CONFIG_KGDB) += kgdb.o
arm64-obj-$(CONFIG_EFI) += efi.o efi-stub.o efi-entry.o
-arm64-obj-$(CONFIG_PCI) += pci.o
+arm64-obj-$(CONFIG_PCI) += pci.o quirks.o
arm64-obj-$(CONFIG_ARMV8_DEPRECATED) += armv8_deprecated.o
arm64-obj-$(CONFIG_ACPI) += acpi.o
diff --git a/arch/arm64/kernel/quirks.c b/arch/arm64/kernel/quirks.c
new file mode 100644
index 0000000..7352bd4
--- /dev/null
+++ b/arch/arm64/kernel/quirks.c
@@ -0,0 +1,36 @@
+/*
+ * PCIe quirks for arm64
+ *
+ * Copyright (C) 2015 Cavium, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/pci.h>
+
+#ifdef CONFIG_CAVIUM_THUNDER_PCI_QUIRKS
+static void thunder_bridge_fixup(struct pci_dev *dev)
+{
+ /*
+ * This bridge is broken in that it doesn't have correct
+ * resource ranges for the buses behind it.
+ *
+ * The upstream bus resources are a close enough approximation
+ * to what is needed, that they can be used instead. Copy
+ * upstream root bus resources so that resource claiming for
+ * downstream devices can be done.
+ */
+ int resno;
+ struct pci_bus *bus = dev->subordinate;
+
+ for (resno = 0; resno < PCI_BRIDGE_RESOURCE_NUM; resno++) {
+ bus->resource[resno] =
+ pci_bus_resource_n(bus->parent,
+ PCI_BRIDGE_RESOURCE_NUM + resno);
+ }
+}
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CAVIUM, 0xa002, thunder_bridge_fixup);
+#endif /* CONFIG_CAVIUM_THUNDER_PCI_QUIRKS */
--
1.9.1
next reply other threads:[~2015-09-23 0:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-23 0:09 David Daney [this message]
2015-09-23 7:51 ` [PATCH] arm64/pci: Add quirks for Cavium Thunder PCI bridges Arnd Bergmann
2015-09-23 16:00 ` David Daney
2015-09-23 19:36 ` Arnd Bergmann
2015-09-23 18:40 ` Will Deacon
2015-09-23 18:48 ` David Daney
2015-11-24 21:52 ` Bjorn Helgaas
2015-11-24 22:26 ` David Daney
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=1442966996-13419-1-git-send-email-ddaney.cavm@gmail.com \
--to=ddaney.cavm@gmail.com \
--cc=linux-arm-kernel@lists.infradead.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).