summaryrefslogtreecommitdiffstats
path: root/include/linux/io.h
diff options
context:
space:
mode:
authorLorenzo Pieralisi <lorenzo.pieralisi@arm.com>2017-04-19 12:48:51 -0400
committerBjorn Helgaas <bhelgaas@google.com>2017-04-19 14:58:51 -0400
commitcf9ea8ca4a0bea7eda12f8fb04dc34146839a215 (patch)
tree62d20057f6cd62f15bc8019b07278a5e82f4d69b /include/linux/io.h
parent7b309aef0463340d3ad5449d1f605d14e10a4225 (diff)
linux/io.h: Add pci_remap_cfgspace() interface
The PCI specifications (Rev 3.0, 3.2.5 "Transaction Ordering and Posting") mandate non-posted configuration transactions. As further highlighted in the PCIe specifications (4.0 - Rev0.3, "Ordering Considerations for the Enhanced Configuration Access Mechanism"), through ECAM and ECAM-derivative configuration mechanism, the memory mapped transactions from the host CPU into Configuration Requests on the PCI express fabric may create ordering problems for software because writes to memory address are typically posted transactions (unless the architecture can enforce through virtual address mapping non-posted write transactions behaviour) but writes to Configuration Space are not posted on the PCI express fabric. Current DT and ACPI host bridge controllers map PCI configuration space (ECAM and ECAM-derivative) into the virtual address space through ioremap() calls, that are non-cacheable device accesses on most architectures, but may provide "bufferable" or "posted" write semantics in architecture like eg ARM/ARM64 that allow ioremap'ed regions writes to be buffered in the bus connecting the host CPU to the PCI fabric; this behaviour, as underlined in the PCIe specifications, may trigger transactions ordering rules and must be prevented. Introduce a new generic and explicit API to create a memory mapping for ECAM and ECAM-derivative config space area that defaults to ioremap_nocache() (which should provide a sane default behaviour) but still allowing architectures on which ioremap_nocache() results in posted write transactions to override the function call with an arch specific implementation that complies with the PCI specifications for configuration transactions. [bhelgaas: fold in #ifdef CONFIG_PCI wrapper] Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Will Deacon <will.deacon@arm.com> Cc: Russell King <linux@armlinux.org.uk> Cc: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'include/linux/io.h')
-rw-r--r--include/linux/io.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/io.h b/include/linux/io.h
index 82ef36eac8a1..2195d9ea4aaa 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -90,6 +90,27 @@ void devm_memunmap(struct device *dev, void *addr);
90 90
91void *__devm_memremap_pages(struct device *dev, struct resource *res); 91void *__devm_memremap_pages(struct device *dev, struct resource *res);
92 92
93#ifdef CONFIG_PCI
94/*
95 * The PCI specifications (Rev 3.0, 3.2.5 "Transaction Ordering and
96 * Posting") mandate non-posted configuration transactions. There is
97 * no ioremap API in the kernel that can guarantee non-posted write
98 * semantics across arches so provide a default implementation for
99 * mapping PCI config space that defaults to ioremap_nocache(); arches
100 * should override it if they have memory mapping implementations that
101 * guarantee non-posted writes semantics to make the memory mapping
102 * compliant with the PCI specification.
103 */
104#ifndef pci_remap_cfgspace
105#define pci_remap_cfgspace pci_remap_cfgspace
106static inline void __iomem *pci_remap_cfgspace(phys_addr_t offset,
107 size_t size)
108{
109 return ioremap_nocache(offset, size);
110}
111#endif
112#endif
113
93/* 114/*
94 * Some systems do not have legacy ISA devices. 115 * Some systems do not have legacy ISA devices.
95 * /dev/port is not a valid interface on these systems. 116 * /dev/port is not a valid interface on these systems.