Skip to contentSkip to conversation

PCI: brcmstb: Add Broadcom Settopbox PCIe support (resend)

PATCH In review Jim Quinlan 9 participants 36 messages Sep 19, 2018 – Jun 27, 2019

Subsystems (12)
lore
Share & tools
lore

Jim Quinlan

author maintainer
#0 lore raw

v5 cover PCI: brcmstb: Add Broadcom Settopbox PCIe support (resend)

This patch series adds support for the Broadcom Settopbox PCIe host controller. It is targeted to Broadcom Settopbox chips running on ARM, ARM64, and MIPS platforms.

V5 Changes:
- V4 had its own DMA ops structure in the PCIe driver which would override/coexist with the default arch DMA ops. This approach was scrapped, and this version instead essentially implements custom definitions of the __phys_to_dma and __dma_to_phys operations for the three target arches: MIPs, ARM64, ARM. This was the course suggested by one of the V4 reviewers (ChristophH).

For MIPs and ARM64, the DMA remapping is easily accomplished by having custom definitions of __phys_to_dma and __dma_to_phys. For MIPs/BMIPs, ARCH_HAS_PHYS_TO_DMA is already selected and the two functions are just modified. For ARM64, this driver selects ARCH_HAS_PHYS_TO_DMA and declares and defines __phys_to_dma() and __dma_to_phys(). For ARM, things were not so simple. The default functions like __arch_pfn_to_dma() had to be overridden by custom ones defined in arch/arm/mach-bcm/include/mach/memory.h. For these functions to be "seen", we had to declare our own brcmstb_defconfig and no longer use multi_v7_defconfig. This is unfortunate.

- Commits have been better organized to first implement the main driver, then add features (MSI, DMA remap infrastructure), and then add the DMA remapping modifications for MIPs, ARM64, and ARM.

V4 Changes:
- Merged all BrcmSTB PCIe controller files into a single file.
- All new files now have the SPDX identifier.
- Removed the list of PCIe controllers.
- Removed "link-up" race.
- Removed probe of msi psuedo-device.
- Multiple comment text changes, as requested.
- "SSC" => "Spread Spectrum Clocking".
- Set 'memc' variable.
- Unnecessary variable initializations removed (eg rc_bar2_size).
- Added comment on "L23" link state.
- Removed use of "__refdata".
- Formatting of structure elements.

V3 Changes:
- Fold pcie-brcmstb-msi.c into pcie-brcmstb.c
- Use PCI_XXX constants for PCIe capability registers
- Removal of any unused constants
- Change s/pci/pcie/ for filenames, comment text
- Config space access now uses 8/16/32 read/writes
- Use proper multi-line comment style
- Use function names, structure that are common in other host drivers
- DT binding 'brcm,ssc' is now 'brcm,enable-ssc'
- Dropped DT binding 'xyz-supply'
- Not setting CRS support as Linux does it if it is advertised.
- Removed code that was considered "debug code".
- Use of_get_pcie_domain_nr()
- Variable 'bridge_setup_done' removed.

V2 Changes:
* Patch brcmstb-add-memory-API:
- fix DT_PROP_DATA_TO_U32 macro.
- dropped one EXPORT_SYMBOL, changed the other to GPL.
* Patch DT-docs-for-Brcmstb-PCIe:
- change 'brcm,gen' prop to standard 'max-link-speed'.
- rewrite bindings commit to omit standard prop defs.
- change props "supplies", "supply-names" to "xyz-supply"
* Patch removed: export-symbol-arch_setup_dma_ops [4/9]
* Patch brcmstb-add-dma-ranges:
- use get_dma_ops(); also use a const dma_map_ops structure.
- rewrite map_sg(), unmap_sg(), other calls like syng_sg_*()
- omit brcm_mapping_error(), but added code in brcm_dma_supported()
- put all of the notifier code in one compilation unit.

Florian Fainelli (1):
soc: bcm: brcmstb: add memory API

Jim Quinlan (11):
dt-bindings: pci: add DT docs for Brcmstb PCIe device
PCI: brcmstb: add Broadcom STB PCIe host controller driver
PCI: brcmstb: add dma-range mapping for inbound traffic
PCI: brcmstb: add MSI capability
MIPS: BMIPS: add dma remap for BrcmSTB PCIe PCI/MSI: enable PCI_MSI_IRQ_DOMAIN support for MIPS
MIPS: BMIPS: add PCI bindings for 7425, 7435
MIPS: BMIPS: enable PCI
ARM64: declare __phys_to_dma on ARCH_HAS_PHYS_TO_DMA
ARM64: add dma remap for BrcmSTB PCIe
ARM: add dma remap for BrcmSTB PCIe

 .../devicetree/bindings/pci/brcmstb-pcie.txt       |   59 +
 arch/arm/Kconfig                                   |   33 +
 arch/arm/configs/brcmstb_defconfig                 |  204 +++
 arch/arm/configs/multi_v7_defconfig                |    3 -
 arch/arm/mach-bcm/Kconfig                          |   21 +-
 arch/arm/mach-bcm/Makefile.boot                    |    0
 arch/arm/mach-bcm/include/mach/irqs.h              |    3 +
 arch/arm/mach-bcm/include/mach/memory.h            |   47 +
 arch/arm/mach-bcm/include/mach/uncompress.h        |    8 +
 arch/arm64/include/asm/dma-direct.h                |   16 +
 arch/mips/Kconfig                                  |    3 +
 arch/mips/bmips/dma.c                              |    9 +
 arch/mips/boot/dts/brcm/bcm7425.dtsi               |   28 +
 arch/mips/boot/dts/brcm/bcm7435.dtsi               |   28 +
 arch/mips/boot/dts/brcm/bcm97425svmb.dts           |    4 +
 arch/mips/boot/dts/brcm/bcm97435svmb.dts           |    4 +
 drivers/pci/Kconfig                                |    2 +-
 drivers/pci/controller/Kconfig                     |   13 +
 drivers/pci/controller/Makefile                    |    1 +
 drivers/pci/controller/pcie-brcmstb.c              | 1554 ++++++++++++++++++++
 drivers/soc/bcm/brcmstb/Makefile                   |    2 +-
 drivers/soc/bcm/brcmstb/memory.c                   |  158 ++
 include/soc/brcmstb/common.h                       |   16 +
 include/soc/brcmstb/memory_api.h                   |   26 +
 24 files changed, 2217 insertions(+), 25 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pci/brcmstb-pcie.txt
 create mode 100644 arch/arm/configs/brcmstb_defconfig
 create mode 100644 arch/arm/mach-bcm/Makefile.boot
 create mode 100644 arch/arm/mach-bcm/include/mach/irqs.h
 create mode 100644 arch/arm/mach-bcm/include/mach/memory.h
 create mode 100644 arch/arm/mach-bcm/include/mach/uncompress.h
 create mode 100644 arch/arm64/include/asm/dma-direct.h
 create mode 100644 drivers/pci/controller/pcie-brcmstb.c
 create mode 100644 drivers/soc/bcm/brcmstb/memory.c
 create mode 100644 include/soc/brcmstb/memory_api.h
Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#1 lore raw

PATCH v5 1/12 soc: bcm: brcmstb: add memory API

From: Florian Fainelli <[email protected]>

This commit adds a memory API suitable for ascertaining the sizes of each of the N memory controllers in a Broadcom STB chip. Its first user will be the Broadcom STB PCIe root complex driver, which needs to know these sizes to properly set up DMA mappings for inbound regions.

We cannot use memblock here or anything like what Linux provides because it collapses adjacent regions within a larger block, and here we actually need per-memory controller addresses and sizes, which is why we resort to manual DT parsing.

---
 drivers/soc/bcm/brcmstb/Makefile |   2 +-
 drivers/soc/bcm/brcmstb/memory.c | 158 +++++++++++++++++++++++++++++++++++++++
 include/soc/brcmstb/memory_api.h |  26 +++++++
 3 files changed, 185 insertions(+), 1 deletion(-)
 create mode 100644 drivers/soc/bcm/brcmstb/memory.c
 create mode 100644 include/soc/brcmstb/memory_api.h
drivers/soc/bcm/brcmstb/Makefile +1 -1
index 01687c2..e4ccd3a 100644
@@ -1,2 +1,2 @@
-obj-y				+= common.o biuctrl.o
+obj-y				+= common.o biuctrl.o memory.o
 obj-$(CONFIG_BRCMSTB_PM)	+= pm/
drivers/soc/bcm/brcmstb/memory.c new file +158 -0

158 lines not on this page · raw message

include/soc/brcmstb/memory_api.h new file +26 -0
new file mode 100644
index 0000000..6546845
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __MEMORY_API_H
+#define __MEMORY_API_H
+
+/*
+ * Bus Interface Unit control register setup, must happen early during boot,
+ * before SMP is brought up, called by machine entry point.
+ */
+void brcmstb_biuctrl_init(void);
+
+#ifdef CONFIG_SOC_BRCMSTB
+int brcmstb_memory_phys_addr_to_memc(phys_addr_t pa);
+u64 brcmstb_memory_memc_size(int memc);
+#else
+static inline int brcmstb_memory_phys_addr_to_memc(phys_addr_t pa)
+{
+	return -EINVAL;
+}
+
+static inline u64 brcmstb_memory_memc_size(int memc)
+{
+	return -1;
+}
+#endif
+
+#endif /* __MEMORY_API_H */
Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#2 lore raw

PATCH v5 2/12 dt-bindings: pci: add DT docs for Brcmstb PCIe device

In reply to Jim Quinlan

The DT bindings description of the Brcmstb PCIe device is described. This node can be used by almost all Broadcom settop box chips, using ARM, ARM64, or MIPS CPU architectures.

---
 .../devicetree/bindings/pci/brcmstb-pcie.txt       | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/brcmstb-pcie.txt
Documentation/devicetree/bindings/pci/brcmstb-pcie.txt new file +59 -0
new file mode 100644
index 0000000..a1a9ad5
@@ -0,0 +1,59 @@
+Brcmstb PCIe Host Controller Device Tree Bindings
+
+Required Properties:
+- compatible
+  "brcm,bcm7425-pcie" -- for 7425 family MIPS-based SOCs.
+  "brcm,bcm7435-pcie" -- for 7435 family MIPS-based SOCs.
+  "brcm,bcm7445-pcie" -- for 7445 and later ARM based SOCs (not including
+      the 7278).
+  "brcm,bcm7278-pcie"  -- for 7278 family ARM-based SOCs.
+
+- reg -- the register start address and length for the PCIe reg block.
+- interrupts -- two interrupts are specified; the first interrupt is for
+     the PCI host controller and the second is for MSI if the built-in
+     MSI controller is to be used.
+- interrupt-names -- names of the interrupts (above): "pcie" and "msi".
+- #address-cells -- set to <3>.
+- #size-cells -- set to <2>.
+- #interrupt-cells: set to <1>.
+- interrupt-map-mask and interrupt-map, standard PCI properties to define the
+     mapping of the PCIe interface to interrupt numbers.
+- ranges: ranges for the PCI memory and I/O regions.
+- linux,pci-domain -- should be unique per host controller.
+
+Optional Properties:
+- clocks -- phandle of pcie clock.
+- clock-names -- set to "sw_pcie" if clocks is used.
+- dma-ranges -- Specifies the inbound memory mapping regions when
+     an "identity map" is not possible.
+- msi-controller -- this property is typically specified to have the
+     PCIe controller use its internal MSI controller.
+- msi-parent -- set to use an external MSI interrupt controller.
+- brcm,enable-ssc -- (boolean) indicates usage of spread-spectrum clocking.
+- max-link-speed --  (integer) indicates desired generation of link:
+     1 => 2.5 Gbps (gen1), 2 => 5.0 Gbps (gen2), 3 => 8.0 Gbps (gen3).
+
+Example Node:
+
+pcie0: pcie at f0460000 {
+		reg = <0x0 0xf0460000 0x0 0x9310>;
+		interrupts = <0x0 0x0 0x4>;
+		compatible = "brcm,bcm7445-pcie";
+		#address-cells = <3>;
+		#size-cells = <2>;
+		ranges = <0x02000000 0x00000000 0x00000000 0x00000000 0xc0000000 0x00000000 0x08000000
+			  0x02000000 0x00000000 0x08000000 0x00000000 0xc8000000 0x00000000 0x08000000>;
+		#interrupt-cells = <1>;
+		interrupt-map-mask = <0 0 0 7>;
+		interrupt-map = <0 0 0 1 &intc 0 47 3
+				 0 0 0 2 &intc 0 48 3
+				 0 0 0 3 &intc 0 49 3
+				 0 0 0 4 &intc 0 50 3>;
+		clocks = <&sw_pcie0>;
+		clock-names = "sw_pcie";
+		msi-parent = <&pcie0>;  /* use PCIe's internal MSI controller */
+		msi-controller;         /* use PCIe's internal MSI controller */
+		brcm,ssc;
+		max-link-speed = <1>;
+		linux,pci-domain = <0>;
+	};
Signature · 1 line
1.9.0.138.g2de3478
#3 lore raw

Re: [PATCH v5 02/12] dt-bindings: pci: add DT docs for Brcmstb PCIe device

Quoted 3 lines · Jim Quinlan

The DT bindings description of the Brcmstb PCIe device is described. This node can be used by almost all Broadcom settop box chips, using ARM, ARM64, or MIPS CPU architectures.

Oh, hey, *one* email made it finally through :P

Quoted 44 lines
---
 .../devicetree/bindings/pci/brcmstb-pcie.txt       | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/brcmstb-pcie.txt
Documentation/devicetree/bindings/pci/brcmstb-pcie.txt new file +30 -0
new file mode 100644
index 0000000..a1a9ad5
@@ -0,0 +1,59 @@
+Brcmstb PCIe Host Controller Device Tree Bindings
+
+Required Properties:
+- compatible
+  "brcm,bcm7425-pcie" -- for 7425 family MIPS-based SOCs.
+  "brcm,bcm7435-pcie" -- for 7435 family MIPS-based SOCs.
+  "brcm,bcm7445-pcie" -- for 7445 and later ARM based SOCs (not including
+      the 7278).
+  "brcm,bcm7278-pcie"  -- for 7278 family ARM-based SOCs.
+
+- reg -- the register start address and length for the PCIe reg block.
+- interrupts -- two interrupts are specified; the first interrupt is for
+     the PCI host controller and the second is for MSI if the built-in
+     MSI controller is to be used.
+- interrupt-names -- names of the interrupts (above): "pcie" and "msi".
+- #address-cells -- set to <3>.
+- #size-cells -- set to <2>.
+- #interrupt-cells: set to <1>.
+- interrupt-map-mask and interrupt-map, standard PCI properties to define the
+     mapping of the PCIe interface to interrupt numbers.
+- ranges: ranges for the PCI memory and I/O regions.
+- linux,pci-domain -- should be unique per host controller.
+
+Optional Properties:
+- clocks -- phandle of pcie clock.
+- clock-names -- set to "sw_pcie" if clocks is used.
+- dma-ranges -- Specifies the inbound memory mapping regions when
+     an "identity map" is not possible.
+- msi-controller -- this property is typically specified to have the
+     PCIe controller use its internal MSI controller.

Documentation/devicetree/bindings/pci/brcmstb-pcie.txt line 40

Quoted 10 lines
Documentation/devicetree/bindings/pci/brcmstb-pcie.txt new file +10 -0
+- msi-parent -- set to use an external MSI interrupt controller.
+- brcm,enable-ssc -- (boolean) indicates usage of spread-spectrum clocking.
+- max-link-speed --  (integer) indicates desired generation of link:
+     1 => 2.5 Gbps (gen1), 2 => 5.0 Gbps (gen2), 3 => 8.0 Gbps (gen3).
+
+Example Node:
+
+pcie0: pcie at f0460000 {
+               reg = <0x0 0xf0460000 0x0 0x9310>;
+               interrupts = <0x0 0x0 0x4>;

Your binding says two interrupts, your example has three - what's the third interrupt for? Also you define the same for MSI and PCIe (I assume) - is that expected? Are there systems where they are different? I would expect the msi interrupt to be optional for the case where its the same as the pcie one, and only required if it is different.

Also your binding requires an interrupt-names propery, but it's missing from the example.

Quoted 20 lines
Documentation/devicetree/bindings/pci/brcmstb-pcie.txt new file +19 -1
+               compatible = "brcm,bcm7445-pcie";
+               #address-cells = <3>;
+               #size-cells = <2>;
+               ranges = <0x02000000 0x00000000 0x00000000 0x00000000 0xc0000000 0x00000000 0x08000000
+                         0x02000000 0x00000000 0x08000000 0x00000000 0xc8000000 0x00000000 0x08000000>;
+               #interrupt-cells = <1>;
+               interrupt-map-mask = <0 0 0 7>;
+               interrupt-map = <0 0 0 1 &intc 0 47 3
+                                0 0 0 2 &intc 0 48 3
+                                0 0 0 3 &intc 0 49 3
+                                0 0 0 4 &intc 0 50 3>;
+               clocks = <&sw_pcie0>;
+               clock-names = "sw_pcie";
+               msi-parent = <&pcie0>;  /* use PCIe's internal MSI controller */
+               msi-controller;         /* use PCIe's internal MSI controller */
+               brcm,ssc;
+               max-link-speed = <1>;
+               linux,pci-domain = <0>;
+       };
--
Quoted 2 lines

1.9.0.138.g2de3478

Regards
Jonas

author maintainer
#4 lore raw

Re: [PATCH v5 02/12] dt-bindings: pci: add DT docs for Brcmstb PCIe device

Quoted 7 lines · Jonas Gorski
Quoted 3 lines · Jim Quinlan

The DT bindings description of the Brcmstb PCIe device is described. This node can be used by almost all Broadcom settop box chips, using ARM, ARM64, or MIPS CPU architectures.

Oh, hey, *one* email made it finally through :P

Sigh, I'm still having email issues, my apologies.

Quoted 50 lines
Quoted 50 lines
---
 .../devicetree/bindings/pci/brcmstb-pcie.txt       | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/brcmstb-pcie.txt
Documentation/devicetree/bindings/pci/brcmstb-pcie.txt new file +35 -0
new file mode 100644
index 0000000..a1a9ad5
@@ -0,0 +1,59 @@
+Brcmstb PCIe Host Controller Device Tree Bindings
+
+Required Properties:
+- compatible
+  "brcm,bcm7425-pcie" -- for 7425 family MIPS-based SOCs.
+  "brcm,bcm7435-pcie" -- for 7435 family MIPS-based SOCs.
+  "brcm,bcm7445-pcie" -- for 7445 and later ARM based SOCs (not including
+      the 7278).
+  "brcm,bcm7278-pcie"  -- for 7278 family ARM-based SOCs.
+
+- reg -- the register start address and length for the PCIe reg block.
+- interrupts -- two interrupts are specified; the first interrupt is for
+     the PCI host controller and the second is for MSI if the built-in
+     MSI controller is to be used.
+- interrupt-names -- names of the interrupts (above): "pcie" and "msi".
+- #address-cells -- set to <3>.
+- #size-cells -- set to <2>.
+- #interrupt-cells: set to <1>.
+- interrupt-map-mask and interrupt-map, standard PCI properties to define the
+     mapping of the PCIe interface to interrupt numbers.
+- ranges: ranges for the PCI memory and I/O regions.
+- linux,pci-domain -- should be unique per host controller.
+
+Optional Properties:
+- clocks -- phandle of pcie clock.
+- clock-names -- set to "sw_pcie" if clocks is used.
+- dma-ranges -- Specifies the inbound memory mapping regions when
+     an "identity map" is not possible.
+- msi-controller -- this property is typically specified to have the
+     PCIe controller use its internal MSI controller.
+- msi-parent -- set to use an external MSI interrupt controller.
+- brcm,enable-ssc -- (boolean) indicates usage of spread-spectrum clocking.
+- max-link-speed --  (integer) indicates desired generation of link:
+     1 => 2.5 Gbps (gen1), 2 => 5.0 Gbps (gen2), 3 => 8.0 Gbps (gen3).
+
Quoted 8 lines

Documentation/devicetree/bindings/pci/brcmstb-pcie.txt line 40

Quoted 5 lines
Documentation/devicetree/bindings/pci/brcmstb-pcie.txt new file +5 -0
+Example Node:
+
+pcie0: pcie at f0460000 {
+               reg = <0x0 0xf0460000 0x0 0x9310>;
+               interrupts = <0x0 0x0 0x4>;

Your binding says two interrupts, your example has three - what's the third interrupt for?

Actually that's a single interrupt with three cells. I need to add another interrupt. Note that we have #interrupt-cells set to 1 because that is for the legacy interrupts given in the interrupt-map.

Quoted 1 line

Also you define the same for MSI and PCIe (I assume) - is that expected?

No, these will be updated to two different interrupts.

Are there systems where they are

Quoted 6 lines

different? I would expect the msi interrupt to be optional for the case where its the same as the pcie one, and only required if it is different.

Also your binding requires an interrupt-names propery, but it's missing from the example.

Will fix.

Thanks,
Jim

Quoted 26 lines
Quoted 21 lines
Documentation/devicetree/bindings/pci/brcmstb-pcie.txt new file +19 -1
+               compatible = "brcm,bcm7445-pcie";
+               #address-cells = <3>;
+               #size-cells = <2>;
+               ranges = <0x02000000 0x00000000 0x00000000 0x00000000 0xc0000000 0x00000000 0x08000000
+                         0x02000000 0x00000000 0x08000000 0x00000000 0xc8000000 0x00000000 0x08000000>;
+               #interrupt-cells = <1>;
+               interrupt-map-mask = <0 0 0 7>;
+               interrupt-map = <0 0 0 1 &intc 0 47 3
+                                0 0 0 2 &intc 0 48 3
+                                0 0 0 3 &intc 0 49 3
+                                0 0 0 4 &intc 0 50 3>;
+               clocks = <&sw_pcie0>;
+               clock-names = "sw_pcie";
+               msi-parent = <&pcie0>;  /* use PCIe's internal MSI controller */
+               msi-controller;         /* use PCIe's internal MSI controller */
+               brcm,ssc;
+               max-link-speed = <1>;
+               linux,pci-domain = <0>;
+       };
--
Quoted 2 lines

1.9.0.138.g2de3478

Regards
Jonas

author maintainer
#5 lore raw

PATCH v5 3/12 PCI: brcmstb: add Broadcom STB PCIe host controller driver

In reply to Jim Quinlan

This commit adds the basic Broadcom STB PCIe controller. Missing is the ability to process MSI and also handle dma-ranges for inbound memory accesses. These two functionalities are added in subsequent commits.

The PCIe block contains an MDIO interface. This is a local interface only accessible by the PCIe controller. It cannot be used or shared by any other HW. As such, the small amount of code for this controller is included in this driver as there is little upside to put it elsewhere.

---
 drivers/pci/controller/Kconfig        |   12 +
 drivers/pci/controller/Makefile       |    1 +
 drivers/pci/controller/pcie-brcmstb.c | 1099 +++++++++++++++++++++++++++++++++
 3 files changed, 1112 insertions(+)
 create mode 100644 drivers/pci/controller/pcie-brcmstb.c
drivers/pci/controller/Kconfig +12 -0
index 028b287..c863c67 100644
@@ -278,5 +278,17 @@ config VMD
 	  To compile this driver as a module, choose M here: the
 	  module will be called vmd.
 
+config PCIE_BRCMSTB
+	bool "Broadcom Brcmstb PCIe host controller"
+	depends on ARCH_BRCMSTB || BMIPS_GENERIC
+	depends on OF
+	depends on SOC_BRCMSTB
+	default ARCH_BRCMSTB || BMIPS_GENERIC
+	help
+	  Say Y here to enable PCIe host controller support for
+	  Broadcom Settop Box SOCs.  A Broadcom SOC will may have
+	  multiple host controllers as opposed to a single host
+	  controller with multiple ports.
+
 source "drivers/pci/controller/dwc/Kconfig"
 endmenu
drivers/pci/controller/Makefile +1 -0
index d56a507..e76bfb2 100644
@@ -29,6 +29,7 @@ obj-$(CONFIG_PCIE_MEDIATEK) += pcie-mediatek.o
 obj-$(CONFIG_PCIE_MOBIVEIL) += pcie-mobiveil.o
 obj-$(CONFIG_PCIE_TANGO_SMP8759) += pcie-tango.o
 obj-$(CONFIG_VMD) += vmd.o
+obj-$(CONFIG_PCIE_BRCMSTB) += pcie-brcmstb.o
 # pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW
 obj-y				+= dwc/
 
drivers/pci/controller/pcie-brcmstb.c new file +1099 -0

1,099 lines not on this page · raw message

Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#6 lore raw

PATCH v5 4/12 PCI: brcmstb: add dma-range mapping for inbound traffic

In reply to Jim Quinlan

The Broadcom STB PCIe host controller is intimately related to the memory subsystem. This close relationship adds complexity to how cpu system memory is mapped to PCIe memory. Ideally, this mapping is an identity mapping, or an identity mapping off by a constant. Not so in this case.

Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB of system memory. Here is how the PCIe controller maps the system memory to PCIe memory:

memc0-a@[ 0....3fffffff] <=> pci@[ 0....3fffffff]
memc0-b@[100000000...13fffffff] <=> pci@[ 40000000....7fffffff] memc1-a@[ 40000000....7fffffff] <=> pci@[ 80000000....bfffffff] memc1-b@[300000000...33fffffff] <=> pci@[ c0000000....ffffffff] memc2-a@[ 80000000....bfffffff] <=> pci@[100000000...13fffffff] memc2-b@[c00000000...c3fffffff] <=> pci@[140000000...17fffffff]

Although there are some "gaps" that can be added between the individual mappings by software, the permutation of memory regions for the most part is fixed by HW. The solution of having something close to an identity mapping is not possible.

The idea behind this HW design is that the same PCIe module can act as an RC or EP, and if it acts as an EP it concatenates all of system memory into a BAR so anything can be accessed. Unfortunately, when the PCIe block is in the role of an RC it also presents this "BAR" to downstream PCIe devices, rather than offering an identity map between its system memory and PCIe space.

Suppose that an endpoint driver allocs some DMA memory. Suppose this memory is located at 0x6000_0000, which is in the middle of memc1-a. The driver wants a dma_addr_t value that it can pass on to the EP to use. Without doing any custom mapping, the EP will use this value for
DMA: the driver will get a dma_addr_t equal to 0x6000_0000. But this won't work; the device needs a dma_addr_t that reflects the PCIe space address, namely 0xa000_0000.

So, essentially the solution to this problem must modify the dma_addr_t returned by the DMA routines routines. The method to do this is to redefine the __dma_to_phys() and __phys_to_dma() functions of the ARM, ARM64, and MIPS architectures. This commit sets up the infrastructure in the Brcm PCIe controller to prepare for this, while there is three other subsequent commits to implement/redefine these two functions for the three target architectures.

---
 drivers/pci/controller/pcie-brcmstb.c | 130 ++++++++++++++++++++++++++++++----
 include/soc/brcmstb/common.h          |  16 +++++
 2 files changed, 133 insertions(+), 13 deletions(-)
drivers/pci/controller/pcie-brcmstb.c +117 -13
index 9c87d10..abfa429 100644
@@ -21,6 +21,7 @@
 #include <linux/printk.h>
 #include <linux/sizes.h>
 #include <linux/slab.h>
+#include <soc/brcmstb/common.h>
 #include <soc/brcmstb/memory_api.h>
 #include <linux/string.h>
 #include <linux/types.h>
@@ -321,6 +322,7 @@ static void __iomem *brcm_pcie_map_conf(struct pci_bus *bus, unsigned int devfn,
 	(((val) & ~reg##_##field##_MASK) | \
 	 (reg##_##field##_MASK & (field_val << reg##_##field##_SHIFT)))
 
+static struct of_pci_range *brcm_dma_ranges;
 static phys_addr_t scb_size[BRCM_MAX_SCB];
 static int num_memc;
 static int num_pcie;
@@ -599,6 +601,79 @@ static inline void brcm_pcie_perst_set(struct brcm_pcie *pcie,
 		WR_FLD_RB(pcie->base, PCIE_MISC_PCIE_CTRL, PCIE_PERSTB, !val);
 }
 
+static int brcm_pcie_parse_map_dma_ranges(struct brcm_pcie *pcie)
+{
+	int i;
+	struct of_pci_range_parser parser;
+	struct device_node *dn = pcie->dn;
+
+	/*
+	 * Parse dma-ranges property if present.  If there are multiple
+	 * PCIe controllers, we only have to parse from one of them since
+	 * the others will have an identical mapping.
+	 */
+	if (!of_pci_dma_range_parser_init(&parser, dn)) {
+		struct of_pci_range *p;
+		unsigned int max_ranges = (parser.end - parser.range)
+			/ parser.np;
+
+		/* Add a null entry to indicate the end of the array */
+		brcm_dma_ranges = kcalloc(max_ranges + 1,
+					  sizeof(struct of_pci_range),
+					  GFP_KERNEL);
+		if (!brcm_dma_ranges)
+			return -ENOMEM;
+
+		p = brcm_dma_ranges;
+		while (of_pci_range_parser_one(&parser, p))
+			p++;
+	}
+
+	for (i = 0, num_memc = 0; i < BRCM_MAX_SCB; i++) {
+		u64 size = brcmstb_memory_memc_size(i);
+
+		if (size == (u64)-1) {
+			dev_err(pcie->dev, "cannot get memc%d size", i);
+			return -EINVAL;
+		} else if (size) {
+			scb_size[i] = roundup_pow_of_two_64(size);
+			num_memc++;
+		} else {
+			break;
+		}
+	}
+
+	return 0;
+}
+
+dma_addr_t brcm_phys_to_dma(struct device *dev, phys_addr_t paddr)
+{
+	struct of_pci_range *p;
+
+	if (!dev || !dev_is_pci(dev))
+		return (dma_addr_t)paddr;
+	for (p = brcm_dma_ranges; p && p->size; p++)
+		if (paddr >= p->cpu_addr && paddr < (p->cpu_addr + p->size))
+			return (dma_addr_t)(paddr - p->cpu_addr + p->pci_addr);
+
+	return (dma_addr_t)paddr;
+}
+
+phys_addr_t brcm_dma_to_phys(struct device *dev, dma_addr_t dev_addr)
+{
+	struct of_pci_range *p;
+
+	if (!dev || !dev_is_pci(dev))
+		return (phys_addr_t)dev_addr;
+	for (p = brcm_dma_ranges; p && p->size; p++)
+		if (dev_addr >= p->pci_addr
+		    && dev_addr < (p->pci_addr + p->size))
+			return (phys_addr_t)
+				(dev_addr - p->pci_addr + p->cpu_addr);
+
+	return (phys_addr_t)dev_addr;
+}
+
 static int brcm_pcie_add_controller(struct brcm_pcie *pcie)
 {
 	int i, ret = 0;
@@ -610,6 +685,10 @@ static int brcm_pcie_add_controller(struct brcm_pcie *pcie)
 		goto done;
 	}
 
+	ret = brcm_pcie_parse_map_dma_ranges(pcie);
+	if (ret)
+		goto done;
+
 	/* Determine num_memc and their sizes */
 	for (i = 0, num_memc = 0; i < BRCM_MAX_SCB; i++) {
 		u64 size = brcmstb_memory_memc_size(i);
@@ -639,8 +718,13 @@ static int brcm_pcie_add_controller(struct brcm_pcie *pcie)
 static void brcm_pcie_remove_controller(struct brcm_pcie *pcie)
 {
 	mutex_lock(&brcm_pcie_lock);
-	if (--num_pcie == 0)
-		num_memc = 0;
+	if (--num_pcie > 0)
+		goto out;
+
+	kfree(brcm_dma_ranges);
+	brcm_dma_ranges = NULL;
+	num_memc = 0;
+out:
 	mutex_unlock(&brcm_pcie_lock);
 }
 
@@ -747,11 +831,37 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
 	 */
 	rc_bar2_size = roundup_pow_of_two_64(total_mem_size);
 
-	/*
-	 * Set simple configuration based on memory sizes
-	 * only.  We always start the viewport at address 0.
-	 */
-	rc_bar2_offset = 0;
+	if (brcm_dma_ranges) {
+		/*
+		 * The best-case scenario is to place the inbound
+		 * region in the first 4GB of pcie-space, as some
+		 * legacy devices can only address 32bits.
+		 * We would also like to put the MSI under 4GB
+		 * as well, since some devices require a 32bit
+		 * MSI target address.
+		 */
+		if (total_mem_size <= 0xc0000000ULL &&
+		    rc_bar2_size <= 0x100000000ULL) {
+			rc_bar2_offset = 0;
+		} else {
+			/*
+			 * The system memory is 4GB or larger so we
+			 * cannot start the inbound region at location
+			 * 0 (since we have to allow some space for
+			 * outbound memory @ 3GB).  So instead we
+			 * start it at the 1x multiple of its size
+			 */
+			rc_bar2_offset = rc_bar2_size;
+		}
+
+	} else {
+		/*
+		 * Set simple configuration based on memory sizes
+		 * only.  We always start the viewport@address 0,
+		 * and set the MSI target address accordingly.
+		 */
+		rc_bar2_offset = 0;
+	}
 
 	tmp = lower_32_bits(rc_bar2_offset);
 	tmp = INSERT_FIELD(tmp, PCIE_MISC_RC_BAR2_CONFIG_LO, SIZE,
@@ -969,7 +1079,6 @@ static int brcm_pcie_probe(struct platform_device *pdev)
 	struct brcm_pcie *pcie;
 	struct resource *res;
 	void __iomem *base;
-	u32 tmp;
 	struct pci_host_bridge *bridge;
 	struct pci_bus *child;
 
@@ -986,11 +1095,6 @@ static int brcm_pcie_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	if (of_property_read_u32(dn, "dma-ranges", &tmp) == 0) {
-		dev_err(&pdev->dev, "cannot yet handle dma-ranges\n");
-		return -EINVAL;
-	}
-
 	data = of_id->data;
 	pcie->reg_offsets = data->offsets;
 	pcie->reg_field_info = data->reg_field_info;
include/soc/brcmstb/common.h +16 -0
index cfb5335..a7f19e0 100644
@@ -12,4 +12,20 @@
 
 bool soc_is_brcmstb(void);
 
+#if defined(CONFIG_PCIE_BRCMSTB)
+dma_addr_t brcm_phys_to_dma(struct device *dev, phys_addr_t paddr);
+phys_addr_t brcm_dma_to_phys(struct device *dev, dma_addr_t dev_addr);
+#else
+static inline dma_addr_t brcm_phys_to_dma(struct device *dev, phys_addr_t paddr)
+{
+	return (dma_addr_t)paddr;
+}
+
+static inline phys_addr_t brcm_dma_to_phys(struct device *dev,
+					   dma_addr_t dev_addr)
+{
+	return (phys_addr_t)dev_addr;
+}
+#endif
+
 #endif /* __SOC_BRCMSTB_COMMON_H__ */
Signature · 1 line
1.9.0.138.g2de3478
#7 lore raw

Re: [PATCH v5 04/12] PCI: brcmstb: add dma-range mapping for inbound traffic

Quoted 10 lines · Jim Quinlan

The Broadcom STB PCIe host controller is intimately related to the memory subsystem. This close relationship adds complexity to how cpu system memory is mapped to PCIe memory. Ideally, this mapping is an identity mapping, or an identity mapping off by a constant. Not so in this case.

Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB of system memory. Here is how the PCIe controller maps the system memory to PCIe memory:

Quoted 7 lines

memc0-a@[ 0....3fffffff] <=> pci@[ 0....3fffffff]
memc0-b@[100000000...13fffffff] <=> pci@[ 40000000....7fffffff] memc1-a@[ 40000000....7fffffff] <=> pci@[ 80000000....bfffffff] memc1-b@[300000000...33fffffff] <=> pci@[ c0000000....ffffffff] memc2-a@[ 80000000....bfffffff] <=> pci@[100000000...13fffffff] memc2-b@[c00000000...c3fffffff] <=> pci@[140000000...17fffffff]

So is describing this as

dma-ranges = <0x0 0x0 0x0 0x0 0x0 0x40000000>,

             <0x0 0x40000000 0x1 0x0 0x0 0x40000000>,
             <0x0 0x80000000 0x0 0x40000000 0x0 0x40000000>,
             <0x0 0xc0000000 0x3 0x0 0x0 0x40000000>,
             <0x1 0x0 0x0 0x80000000 0x0 0x40000000>,
             <0x1 0x40000000 0x0 0xc0000000 0x0 0x40000000>;

not working for you? I haven't tried this myself, but since DT permits describing the inbound mappings this way, we should fix the code if it doesn't work at the moment.

Quoted 257 lines

Although there are some "gaps" that can be added between the individual mappings by software, the permutation of memory regions for the most part is fixed by HW. The solution of having something close to an identity mapping is not possible.

The idea behind this HW design is that the same PCIe module can act as an RC or EP, and if it acts as an EP it concatenates all of system memory into a BAR so anything can be accessed. Unfortunately, when the PCIe block is in the role of an RC it also presents this "BAR" to downstream PCIe devices, rather than offering an identity map between its system memory and PCIe space.

Suppose that an endpoint driver allocs some DMA memory. Suppose this memory is located at 0x6000_0000, which is in the middle of memc1-a. The driver wants a dma_addr_t value that it can pass on to the EP to use. Without doing any custom mapping, the EP will use this value for
DMA: the driver will get a dma_addr_t equal to 0x6000_0000. But this won't work; the device needs a dma_addr_t that reflects the PCIe space address, namely 0xa000_0000.

So, essentially the solution to this problem must modify the dma_addr_t returned by the DMA routines routines. The method to do this is to redefine the __dma_to_phys() and __phys_to_dma() functions of the ARM, ARM64, and MIPS architectures. This commit sets up the infrastructure in the Brcm PCIe controller to prepare for this, while there is three other subsequent commits to implement/redefine these two functions for the three target architectures.

---
 drivers/pci/controller/pcie-brcmstb.c | 130 ++++++++++++++++++++++++++++++----
 include/soc/brcmstb/common.h          |  16 +++++
 2 files changed, 133 insertions(+), 13 deletions(-)
drivers/pci/controller/pcie-brcmstb.c +117 -13
index 9c87d10..abfa429 100644
@@ -21,6 +21,7 @@
 #include <linux/printk.h>
 #include <linux/sizes.h>
 #include <linux/slab.h>
+#include <soc/brcmstb/common.h>
 #include <soc/brcmstb/memory_api.h>
 #include <linux/string.h>
 #include <linux/types.h>
@@ -321,6 +322,7 @@ static void __iomem *brcm_pcie_map_conf(struct pci_bus *bus, unsigned int devfn,
        (((val) & ~reg##_##field##_MASK) | \
         (reg##_##field##_MASK & (field_val << reg##_##field##_SHIFT)))
 
+static struct of_pci_range *brcm_dma_ranges;
 static phys_addr_t scb_size[BRCM_MAX_SCB];
 static int num_memc;
 static int num_pcie;
@@ -599,6 +601,79 @@ static inline void brcm_pcie_perst_set(struct brcm_pcie *pcie,
                WR_FLD_RB(pcie->base, PCIE_MISC_PCIE_CTRL, PCIE_PERSTB, !val);
 }
 
+static int brcm_pcie_parse_map_dma_ranges(struct brcm_pcie *pcie)
+{
+       int i;
+       struct of_pci_range_parser parser;
+       struct device_node *dn = pcie->dn;
+
+       /*
+        * Parse dma-ranges property if present.  If there are multiple
+        * PCIe controllers, we only have to parse from one of them since
+        * the others will have an identical mapping.
+        */
+       if (!of_pci_dma_range_parser_init(&parser, dn)) {
+               struct of_pci_range *p;
+               unsigned int max_ranges = (parser.end - parser.range)
+                       / parser.np;
+
+               /* Add a null entry to indicate the end of the array */
+               brcm_dma_ranges = kcalloc(max_ranges + 1,
+                                         sizeof(struct of_pci_range),
+                                         GFP_KERNEL);
+               if (!brcm_dma_ranges)
+                       return -ENOMEM;
+
+               p = brcm_dma_ranges;
+               while (of_pci_range_parser_one(&parser, p))
+                       p++;
+       }
+
+       for (i = 0, num_memc = 0; i < BRCM_MAX_SCB; i++) {
+               u64 size = brcmstb_memory_memc_size(i);
+
+               if (size == (u64)-1) {
+                       dev_err(pcie->dev, "cannot get memc%d size", i);
+                       return -EINVAL;
+               } else if (size) {
+                       scb_size[i] = roundup_pow_of_two_64(size);
+                       num_memc++;
+               } else {
+                       break;
+               }
+       }
+
+       return 0;
+}
+
+dma_addr_t brcm_phys_to_dma(struct device *dev, phys_addr_t paddr)
+{
+       struct of_pci_range *p;
+
+       if (!dev || !dev_is_pci(dev))
+               return (dma_addr_t)paddr;
+       for (p = brcm_dma_ranges; p && p->size; p++)
+               if (paddr >= p->cpu_addr && paddr < (p->cpu_addr + p->size))
+                       return (dma_addr_t)(paddr - p->cpu_addr + p->pci_addr);
+
+       return (dma_addr_t)paddr;
+}
+
+phys_addr_t brcm_dma_to_phys(struct device *dev, dma_addr_t dev_addr)
+{
+       struct of_pci_range *p;
+
+       if (!dev || !dev_is_pci(dev))
+               return (phys_addr_t)dev_addr;
+       for (p = brcm_dma_ranges; p && p->size; p++)
+               if (dev_addr >= p->pci_addr
+                   && dev_addr < (p->pci_addr + p->size))
+                       return (phys_addr_t)
+                               (dev_addr - p->pci_addr + p->cpu_addr);
+
+       return (phys_addr_t)dev_addr;
+}
+
 static int brcm_pcie_add_controller(struct brcm_pcie *pcie)
 {
        int i, ret = 0;
@@ -610,6 +685,10 @@ static int brcm_pcie_add_controller(struct brcm_pcie *pcie)
                goto done;
        }
 
+       ret = brcm_pcie_parse_map_dma_ranges(pcie);
+       if (ret)
+               goto done;
+
        /* Determine num_memc and their sizes */
        for (i = 0, num_memc = 0; i < BRCM_MAX_SCB; i++) {
                u64 size = brcmstb_memory_memc_size(i);
@@ -639,8 +718,13 @@ static int brcm_pcie_add_controller(struct brcm_pcie *pcie)
 static void brcm_pcie_remove_controller(struct brcm_pcie *pcie)
 {
        mutex_lock(&brcm_pcie_lock);
-       if (--num_pcie == 0)
-               num_memc = 0;
+       if (--num_pcie > 0)
+               goto out;
+
+       kfree(brcm_dma_ranges);
+       brcm_dma_ranges = NULL;
+       num_memc = 0;
+out:
        mutex_unlock(&brcm_pcie_lock);
 }
 
@@ -747,11 +831,37 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
         */
        rc_bar2_size = roundup_pow_of_two_64(total_mem_size);
 
-       /*
-        * Set simple configuration based on memory sizes
-        * only.  We always start the viewport at address 0.
-        */
-       rc_bar2_offset = 0;
+       if (brcm_dma_ranges) {
+               /*
+                * The best-case scenario is to place the inbound
+                * region in the first 4GB of pcie-space, as some
+                * legacy devices can only address 32bits.
+                * We would also like to put the MSI under 4GB
+                * as well, since some devices require a 32bit
+                * MSI target address.
+                */
+               if (total_mem_size <= 0xc0000000ULL &&
+                   rc_bar2_size <= 0x100000000ULL) {
+                       rc_bar2_offset = 0;
+               } else {
+                       /*
+                        * The system memory is 4GB or larger so we
+                        * cannot start the inbound region at location
+                        * 0 (since we have to allow some space for
+                        * outbound memory @ 3GB).  So instead we
+                        * start it at the 1x multiple of its size
+                        */
+                       rc_bar2_offset = rc_bar2_size;
+               }
+
+       } else {
+               /*
+                * Set simple configuration based on memory sizes
+                * only.  We always start the viewport at address 0,
+                * and set the MSI target address accordingly.
+                */
+               rc_bar2_offset = 0;
+       }
 
        tmp = lower_32_bits(rc_bar2_offset);
        tmp = INSERT_FIELD(tmp, PCIE_MISC_RC_BAR2_CONFIG_LO, SIZE,
@@ -969,7 +1079,6 @@ static int brcm_pcie_probe(struct platform_device *pdev)
        struct brcm_pcie *pcie;
        struct resource *res;
        void __iomem *base;
-       u32 tmp;
        struct pci_host_bridge *bridge;
        struct pci_bus *child;
 
@@ -986,11 +1095,6 @@ static int brcm_pcie_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       if (of_property_read_u32(dn, "dma-ranges", &tmp) == 0) {
-               dev_err(&pdev->dev, "cannot yet handle dma-ranges\n");
-               return -EINVAL;
-       }
-
        data = of_id->data;
        pcie->reg_offsets = data->offsets;
        pcie->reg_field_info = data->reg_field_info;
include/soc/brcmstb/common.h +16 -1
index cfb5335..a7f19e0 100644
@@ -12,4 +12,20 @@
 
 bool soc_is_brcmstb(void);
 
+#if defined(CONFIG_PCIE_BRCMSTB)
+dma_addr_t brcm_phys_to_dma(struct device *dev, phys_addr_t paddr);
+phys_addr_t brcm_dma_to_phys(struct device *dev, dma_addr_t dev_addr);
+#else
+static inline dma_addr_t brcm_phys_to_dma(struct device *dev, phys_addr_t paddr)
+{
+       return (dma_addr_t)paddr;
+}
+
+static inline phys_addr_t brcm_dma_to_phys(struct device *dev,
+                                          dma_addr_t dev_addr)
+{
+       return (phys_addr_t)dev_addr;
+}
+#endif
+
 #endif /* __SOC_BRCMSTB_COMMON_H__ */
--

1.9.0.138.g2de3478

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#8 lore raw

Re: [PATCH v5 04/12] PCI: brcmstb: add dma-range mapping for inbound traffic

Quoted 28 lines · Ard Biesheuvel
Quoted 10 lines · Jim Quinlan

The Broadcom STB PCIe host controller is intimately related to the memory subsystem. This close relationship adds complexity to how cpu system memory is mapped to PCIe memory. Ideally, this mapping is an identity mapping, or an identity mapping off by a constant. Not so in this case.

Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB of system memory. Here is how the PCIe controller maps the system memory to PCIe memory:

Quoted 7 lines

memc0-a@[ 0....3fffffff] <=> pci@[ 0....3fffffff]
memc0-b@[100000000...13fffffff] <=> pci@[ 40000000....7fffffff] memc1-a@[ 40000000....7fffffff] <=> pci@[ 80000000....bfffffff] memc1-b@[300000000...33fffffff] <=> pci@[ c0000000....ffffffff] memc2-a@[ 80000000....bfffffff] <=> pci@[100000000...13fffffff] memc2-b@[c00000000...c3fffffff] <=> pci@[140000000...17fffffff]

So is describing this as

dma-ranges = <0x0 0x0 0x0 0x0 0x0 0x40000000>,

             <0x0 0x40000000 0x1 0x0 0x0 0x40000000>,
             <0x0 0x80000000 0x0 0x40000000 0x0 0x40000000>,
             <0x0 0xc0000000 0x3 0x0 0x0 0x40000000>,
             <0x1 0x0 0x0 0x80000000 0x0 0x40000000>,
             <0x1 0x40000000 0x0 0xc0000000 0x0 0x40000000>;
Quoted 3 lines

not working for you? I haven't tried this myself, but since DT permits describing the inbound mappings this way, we should fix the code if it doesn't work at the moment.

You mean encoding the memory controller index in the first cell? If that works, that's indeed a much cleaner solution, though is it standard compliant in any form?

Signature · 1 line
Florian
#9 lore raw

Re: [PATCH v5 04/12] PCI: brcmstb: add dma-range mapping for inbound traffic

Quoted 29 lines · Florian Fainelli
Quoted 28 lines · Ard Biesheuvel
Quoted 10 lines · Jim Quinlan

The Broadcom STB PCIe host controller is intimately related to the memory subsystem. This close relationship adds complexity to how cpu system memory is mapped to PCIe memory. Ideally, this mapping is an identity mapping, or an identity mapping off by a constant. Not so in this case.

Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB of system memory. Here is how the PCIe controller maps the system memory to PCIe memory:

Quoted 7 lines

memc0-a@[ 0....3fffffff] <=> pci@[ 0....3fffffff]
memc0-b@[100000000...13fffffff] <=> pci@[ 40000000....7fffffff] memc1-a@[ 40000000....7fffffff] <=> pci@[ 80000000....bfffffff] memc1-b@[300000000...33fffffff] <=> pci@[ c0000000....ffffffff] memc2-a@[ 80000000....bfffffff] <=> pci@[100000000...13fffffff] memc2-b@[c00000000...c3fffffff] <=> pci@[140000000...17fffffff]

So is describing this as

dma-ranges = <0x0 0x0 0x0 0x0 0x0 0x40000000>,

             <0x0 0x40000000 0x1 0x0 0x0 0x40000000>,
             <0x0 0x80000000 0x0 0x40000000 0x0 0x40000000>,
             <0x0 0xc0000000 0x3 0x0 0x0 0x40000000>,
             <0x1 0x0 0x0 0x80000000 0x0 0x40000000>,
             <0x1 0x40000000 0x0 0xc0000000 0x0 0x40000000>;
Quoted 7 lines
Quoted 3 lines

not working for you? I haven't tried this myself, but since DT permits describing the inbound mappings this way, we should fix the code if it doesn't work at the moment.

You mean encoding the memory controller index in the first cell? If that works, that's indeed a much cleaner solution, though is it standard compliant in any form?

No those are just memory addresses (although I may have screwed up the order). From Documentation/devicetree/booting-without-of.txt:

"""
Optional property:
- dma-ranges: <prop-encoded-array> encoded as arbitrary number of triplets of (child-bus-address, parent-bus-address, length). Each triplet specified describes a contiguous DMA address range.
"""

#10 lore raw

Re: [PATCH v5 04/12] PCI: brcmstb: add dma-range mapping for inbound traffic

Quoted 41 lines · Ard Biesheuvel
Quoted 29 lines · Florian Fainelli
Quoted 28 lines · Ard Biesheuvel
Quoted 10 lines · Jim Quinlan

The Broadcom STB PCIe host controller is intimately related to the memory subsystem. This close relationship adds complexity to how cpu system memory is mapped to PCIe memory. Ideally, this mapping is an identity mapping, or an identity mapping off by a constant. Not so in this case.

Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB of system memory. Here is how the PCIe controller maps the system memory to PCIe memory:

Quoted 7 lines

memc0-a@[ 0....3fffffff] <=> pci@[ 0....3fffffff]
memc0-b@[100000000...13fffffff] <=> pci@[ 40000000....7fffffff] memc1-a@[ 40000000....7fffffff] <=> pci@[ 80000000....bfffffff] memc1-b@[300000000...33fffffff] <=> pci@[ c0000000....ffffffff] memc2-a@[ 80000000....bfffffff] <=> pci@[100000000...13fffffff] memc2-b@[c00000000...c3fffffff] <=> pci@[140000000...17fffffff]

So is describing this as

dma-ranges = <0x0 0x0 0x0 0x0 0x0 0x40000000>,

             <0x0 0x40000000 0x1 0x0 0x0 0x40000000>,
             <0x0 0x80000000 0x0 0x40000000 0x0 0x40000000>,
             <0x0 0xc0000000 0x3 0x0 0x0 0x40000000>,
             <0x1 0x0 0x0 0x80000000 0x0 0x40000000>,
             <0x1 0x40000000 0x0 0xc0000000 0x0 0x40000000>;
Quoted 7 lines
Quoted 3 lines

not working for you? I haven't tried this myself, but since DT permits describing the inbound mappings this way, we should fix the code if it doesn't work at the moment.

You mean encoding the memory controller index in the first cell? If that works, that's indeed a much cleaner solution, though is it standard compliant in any form?

No those are just memory addresses (although I may have screwed up the order). From Documentation/devicetree/booting-without-of.txt:

Quoted 7 lines

"""
Optional property:
- dma-ranges: <prop-encoded-array> encoded as arbitrary number of triplets of (child-bus-address, parent-bus-address, length). Each triplet specified describes a contiguous DMA address range.
"""

Then I am confused by your comment, that's what this patch does, it adds support for reading "dma-ranges" from Device Tree and setting up inbound windows using that. The only caveat is that because the PCIe root complex has some ties with the memory bus architecture it is connected to (SCB in our case) there is still a requirement to know the translation between a given physical address and its backing memory controller/aperture.

Signature · 1 line
Florian
#11 lore raw

Re: [PATCH v5 04/12] PCI: brcmstb: add dma-range mapping for inbound traffic

Quoted 50 lines · Florian Fainelli
Quoted 41 lines · Ard Biesheuvel
Quoted 29 lines · Florian Fainelli
Quoted 28 lines · Ard Biesheuvel
Quoted 10 lines · Jim Quinlan

The Broadcom STB PCIe host controller is intimately related to the memory subsystem. This close relationship adds complexity to how cpu system memory is mapped to PCIe memory. Ideally, this mapping is an identity mapping, or an identity mapping off by a constant. Not so in this case.

Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB of system memory. Here is how the PCIe controller maps the system memory to PCIe memory:

Quoted 7 lines

memc0-a@[ 0....3fffffff] <=> pci@[ 0....3fffffff]
memc0-b@[100000000...13fffffff] <=> pci@[ 40000000....7fffffff] memc1-a@[ 40000000....7fffffff] <=> pci@[ 80000000....bfffffff] memc1-b@[300000000...33fffffff] <=> pci@[ c0000000....ffffffff] memc2-a@[ 80000000....bfffffff] <=> pci@[100000000...13fffffff] memc2-b@[c00000000...c3fffffff] <=> pci@[140000000...17fffffff]

So is describing this as

dma-ranges = <0x0 0x0 0x0 0x0 0x0 0x40000000>,

             <0x0 0x40000000 0x1 0x0 0x0 0x40000000>,
             <0x0 0x80000000 0x0 0x40000000 0x0 0x40000000>,
             <0x0 0xc0000000 0x3 0x0 0x0 0x40000000>,
             <0x1 0x0 0x0 0x80000000 0x0 0x40000000>,
             <0x1 0x40000000 0x0 0xc0000000 0x0 0x40000000>;
Quoted 7 lines
Quoted 3 lines

not working for you? I haven't tried this myself, but since DT permits describing the inbound mappings this way, we should fix the code if it doesn't work at the moment.

You mean encoding the memory controller index in the first cell? If that works, that's indeed a much cleaner solution, though is it standard compliant in any form?

No those are just memory addresses (although I may have screwed up the order). From Documentation/devicetree/booting-without-of.txt:

Quoted 7 lines

"""
Optional property:
- dma-ranges: <prop-encoded-array> encoded as arbitrary number of triplets of (child-bus-address, parent-bus-address, length). Each triplet specified describes a contiguous DMA address range.
"""

Quoted 8 lines

Then I am confused by your comment, that's what this patch does, it adds support for reading "dma-ranges" from Device Tree and setting up inbound windows using that. The only caveat is that because the PCIe root complex has some ties with the memory bus architecture it is connected to (SCB in our case) there is still a requirement to know the translation between a given physical address and its backing memory controller/aperture.

Ah ok, apologies for the noise then.

I was hoping that having working support for dma-ranges would remove the need for the special phys<->dma conversion routines.

#12 lore raw

Re: [PATCH v5 04/12] PCI: brcmstb: add dma-range mapping for inbound traffic

Quoted 60 lines · Ard Biesheuvel
Quoted 50 lines · Florian Fainelli
Quoted 41 lines · Ard Biesheuvel
Quoted 29 lines · Florian Fainelli
Quoted 28 lines · Ard Biesheuvel
Quoted 10 lines · Jim Quinlan

The Broadcom STB PCIe host controller is intimately related to the memory subsystem. This close relationship adds complexity to how cpu system memory is mapped to PCIe memory. Ideally, this mapping is an identity mapping, or an identity mapping off by a constant. Not so in this case.

Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB of system memory. Here is how the PCIe controller maps the system memory to PCIe memory:

Quoted 7 lines

memc0-a@[ 0....3fffffff] <=> pci@[ 0....3fffffff]
memc0-b@[100000000...13fffffff] <=> pci@[ 40000000....7fffffff] memc1-a@[ 40000000....7fffffff] <=> pci@[ 80000000....bfffffff] memc1-b@[300000000...33fffffff] <=> pci@[ c0000000....ffffffff] memc2-a@[ 80000000....bfffffff] <=> pci@[100000000...13fffffff] memc2-b@[c00000000...c3fffffff] <=> pci@[140000000...17fffffff]

So is describing this as

dma-ranges = <0x0 0x0 0x0 0x0 0x0 0x40000000>,

             <0x0 0x40000000 0x1 0x0 0x0 0x40000000>,
             <0x0 0x80000000 0x0 0x40000000 0x0 0x40000000>,
             <0x0 0xc0000000 0x3 0x0 0x0 0x40000000>,
             <0x1 0x0 0x0 0x80000000 0x0 0x40000000>,
             <0x1 0x40000000 0x0 0xc0000000 0x0 0x40000000>;
Quoted 7 lines
Quoted 3 lines

not working for you? I haven't tried this myself, but since DT permits describing the inbound mappings this way, we should fix the code if it doesn't work at the moment.

You mean encoding the memory controller index in the first cell? If that works, that's indeed a much cleaner solution, though is it standard compliant in any form?

No those are just memory addresses (although I may have screwed up the order). From Documentation/devicetree/booting-without-of.txt:

Quoted 7 lines

"""
Optional property:
- dma-ranges: <prop-encoded-array> encoded as arbitrary number of triplets of (child-bus-address, parent-bus-address, length). Each triplet specified describes a contiguous DMA address range.
"""

Quoted 8 lines

Then I am confused by your comment, that's what this patch does, it adds support for reading "dma-ranges" from Device Tree and setting up inbound windows using that. The only caveat is that because the PCIe root complex has some ties with the memory bus architecture it is connected to (SCB in our case) there is still a requirement to know the translation between a given physical address and its backing memory controller/aperture.

Quoted 4 lines

Ah ok, apologies for the noise then.

I was hoping that having working support for dma-ranges would remove the need for the special phys<->dma conversion routines.

What you describe definitively works with platform devices, but I am not sure this is working for PCIe devices, although, conceptually it should, yes.

Signature · 1 line
Florian
author maintainer
#13 lore raw

Re: [PATCH v5 04/12] PCI: brcmstb: add dma-range mapping for inbound traffic

Quoted 62 lines · Florian Fainelli
Quoted 60 lines · Ard Biesheuvel
Quoted 58 lines · Florian Fainelli
Quoted 41 lines · Ard Biesheuvel
Quoted 29 lines · Florian Fainelli
Quoted 28 lines · Ard Biesheuvel
Quoted 10 lines · Jim Quinlan

The Broadcom STB PCIe host controller is intimately related to the memory subsystem. This close relationship adds complexity to how cpu system memory is mapped to PCIe memory. Ideally, this mapping is an identity mapping, or an identity mapping off by a constant. Not so in this case.

Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB of system memory. Here is how the PCIe controller maps the system memory to PCIe memory:

Quoted 7 lines

memc0-a@[ 0....3fffffff] <=> pci@[ 0....3fffffff]
memc0-b@[100000000...13fffffff] <=> pci@[ 40000000....7fffffff] memc1-a@[ 40000000....7fffffff] <=> pci@[ 80000000....bfffffff] memc1-b@[300000000...33fffffff] <=> pci@[ c0000000....ffffffff] memc2-a@[ 80000000....bfffffff] <=> pci@[100000000...13fffffff] memc2-b@[c00000000...c3fffffff] <=> pci@[140000000...17fffffff]

So is describing this as

dma-ranges = <0x0 0x0 0x0 0x0 0x0 0x40000000>,

             <0x0 0x40000000 0x1 0x0 0x0 0x40000000>,
             <0x0 0x80000000 0x0 0x40000000 0x0 0x40000000>,
             <0x0 0xc0000000 0x3 0x0 0x0 0x40000000>,
             <0x1 0x0 0x0 0x80000000 0x0 0x40000000>,
             <0x1 0x40000000 0x0 0xc0000000 0x0 0x40000000>;
Quoted 7 lines
Quoted 3 lines

not working for you? I haven't tried this myself, but since DT permits describing the inbound mappings this way, we should fix the code if it doesn't work at the moment.

You mean encoding the memory controller index in the first cell? If that works, that's indeed a much cleaner solution, though is it standard compliant in any form?

No those are just memory addresses (although I may have screwed up the order). From Documentation/devicetree/booting-without-of.txt:

Quoted 7 lines

"""
Optional property:
- dma-ranges: <prop-encoded-array> encoded as arbitrary number of triplets of (child-bus-address, parent-bus-address, length). Each triplet specified describes a contiguous DMA address range.
"""

Then I am confused by your comment, that's what this patch does, it adds support for reading "dma-ranges" from Device Tree and setting up inbound windows using that. The only caveat is that because the PCIe root complex has some ties with the memory bus architecture it is connected to (SCB in our case) there is still a requirement to know the translation between a given physical address and its backing memory controller/aperture.

Quoted 8 lines
Quoted 4 lines

Ah ok, apologies for the noise then.

I was hoping that having working support for dma-ranges would remove the need for the special phys<->dma conversion routines.

What you describe definitively works with platform devices, but I am not sure this is working for PCIe devices, although, conceptually it should, yes.

Sorry for my delay in responding. One problem is that of_dma_configure() only looks at the first dma-range given and then converts it to dev->dma_pfn_offset which is respected by the DMA API. However, we often have multiple dma-ranges, not just one. This is the big issue.

There is another issue with of_dma_configure() being invoked by the EP driver on "bridge->parent->of_node", which is our RC device, Of_dma_configure() calls of_dma_range() on the of_get_next_parent() of our RC's device node and this misses the dma-ranges property which is contained within the RC. I think I could workaround this but there is no getting around the first problem.

Thanks,
Jim

Quoted 2 lines

--
Florian

#14 lore raw

Re: [PATCH v5 04/12] PCI: brcmstb: add dma-range mapping for inbound traffic

Quoted 69 lines · Jim Quinlan
Quoted 67 lines · Florian Fainelli
Quoted 64 lines · Ard Biesheuvel
Quoted 50 lines · Florian Fainelli
Quoted 41 lines · Ard Biesheuvel
Quoted 29 lines · Florian Fainelli
Quoted 28 lines · Ard Biesheuvel
Quoted 10 lines · Jim Quinlan

The Broadcom STB PCIe host controller is intimately related to the memory subsystem. This close relationship adds complexity to how cpu system memory is mapped to PCIe memory. Ideally, this mapping is an identity mapping, or an identity mapping off by a constant. Not so in this case.

Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB of system memory. Here is how the PCIe controller maps the system memory to PCIe memory:

Quoted 7 lines

memc0-a@[ 0....3fffffff] <=> pci@[ 0....3fffffff]
memc0-b@[100000000...13fffffff] <=> pci@[ 40000000....7fffffff] memc1-a@[ 40000000....7fffffff] <=> pci@[ 80000000....bfffffff] memc1-b@[300000000...33fffffff] <=> pci@[ c0000000....ffffffff] memc2-a@[ 80000000....bfffffff] <=> pci@[100000000...13fffffff] memc2-b@[c00000000...c3fffffff] <=> pci@[140000000...17fffffff]

So is describing this as

dma-ranges = <0x0 0x0 0x0 0x0 0x0 0x40000000>,

             <0x0 0x40000000 0x1 0x0 0x0 0x40000000>,
             <0x0 0x80000000 0x0 0x40000000 0x0 0x40000000>,
             <0x0 0xc0000000 0x3 0x0 0x0 0x40000000>,
             <0x1 0x0 0x0 0x80000000 0x0 0x40000000>,
             <0x1 0x40000000 0x0 0xc0000000 0x0 0x40000000>;
Quoted 7 lines
Quoted 3 lines

not working for you? I haven't tried this myself, but since DT permits describing the inbound mappings this way, we should fix the code if it doesn't work at the moment.

You mean encoding the memory controller index in the first cell? If that works, that's indeed a much cleaner solution, though is it standard compliant in any form?

No those are just memory addresses (although I may have screwed up the order). From Documentation/devicetree/booting-without-of.txt:

Quoted 7 lines

"""
Optional property:
- dma-ranges: <prop-encoded-array> encoded as arbitrary number of triplets of (child-bus-address, parent-bus-address, length). Each triplet specified describes a contiguous DMA address range.
"""

Quoted 8 lines

Then I am confused by your comment, that's what this patch does, it adds support for reading "dma-ranges" from Device Tree and setting up inbound windows using that. The only caveat is that because the PCIe root complex has some ties with the memory bus architecture it is connected to (SCB in our case) there is still a requirement to know the translation between a given physical address and its backing memory controller/aperture.

Ah ok, apologies for the noise then.

I was hoping that having working support for dma-ranges would remove the need for the special phys<->dma conversion routines.

Quoted 9 lines
Quoted 3 lines

What you describe definitively works with platform devices, but I am not sure this is working for PCIe devices, although, conceptually it should, yes.

Sorry for my delay in responding. One problem is that of_dma_configure() only looks at the first dma-range given and then converts it to dev->dma_pfn_offset which is respected by the DMA API. However, we often have multiple dma-ranges, not just one. This is the big issue.

Given the recent attention to getting these APIs in shape, this may be something Robin or Christoph may care to look into?

In any case, the description of dma-ranges should be in sync with the way Linux interprets it, so this is either a documentation bug or a DMA layer bug.

Quoted 7 lines

There is another issue with of_dma_configure() being invoked by the EP driver on "bridge->parent->of_node", which is our RC device, Of_dma_configure() calls of_dma_range() on the of_get_next_parent() of our RC's device node and this misses the dma-ranges property which is contained within the RC. I think I could workaround this but there is no getting around the first problem.

IIUC dma-ranges should be added to the parent bus of a device, which I guess is slightly ambiguous for a root complex that incorporates a host bridge.

author maintainer
#15 lore raw

Re: [PATCH v5 04/12] PCI: brcmstb: add dma-range mapping for inbound traffic

Quoted 81 lines · Ard Biesheuvel
Quoted 69 lines · Jim Quinlan
Quoted 67 lines · Florian Fainelli
Quoted 64 lines · Ard Biesheuvel
Quoted 50 lines · Florian Fainelli
Quoted 41 lines · Ard Biesheuvel
Quoted 29 lines · Florian Fainelli
Quoted 28 lines · Ard Biesheuvel
Quoted 10 lines · Jim Quinlan

The Broadcom STB PCIe host controller is intimately related to the memory subsystem. This close relationship adds complexity to how cpu system memory is mapped to PCIe memory. Ideally, this mapping is an identity mapping, or an identity mapping off by a constant. Not so in this case.

Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB of system memory. Here is how the PCIe controller maps the system memory to PCIe memory:

Quoted 7 lines

memc0-a@[ 0....3fffffff] <=> pci@[ 0....3fffffff]
memc0-b@[100000000...13fffffff] <=> pci@[ 40000000....7fffffff] memc1-a@[ 40000000....7fffffff] <=> pci@[ 80000000....bfffffff] memc1-b@[300000000...33fffffff] <=> pci@[ c0000000....ffffffff] memc2-a@[ 80000000....bfffffff] <=> pci@[100000000...13fffffff] memc2-b@[c00000000...c3fffffff] <=> pci@[140000000...17fffffff]

So is describing this as

dma-ranges = <0x0 0x0 0x0 0x0 0x0 0x40000000>,

             <0x0 0x40000000 0x1 0x0 0x0 0x40000000>,
             <0x0 0x80000000 0x0 0x40000000 0x0 0x40000000>,
             <0x0 0xc0000000 0x3 0x0 0x0 0x40000000>,
             <0x1 0x0 0x0 0x80000000 0x0 0x40000000>,
             <0x1 0x40000000 0x0 0xc0000000 0x0 0x40000000>;
Quoted 7 lines
Quoted 3 lines

not working for you? I haven't tried this myself, but since DT permits describing the inbound mappings this way, we should fix the code if it doesn't work at the moment.

You mean encoding the memory controller index in the first cell? If that works, that's indeed a much cleaner solution, though is it standard compliant in any form?

No those are just memory addresses (although I may have screwed up the order). From Documentation/devicetree/booting-without-of.txt:

Quoted 7 lines

"""
Optional property:
- dma-ranges: <prop-encoded-array> encoded as arbitrary number of triplets of (child-bus-address, parent-bus-address, length). Each triplet specified describes a contiguous DMA address range.
"""

Quoted 8 lines

Then I am confused by your comment, that's what this patch does, it adds support for reading "dma-ranges" from Device Tree and setting up inbound windows using that. The only caveat is that because the PCIe root complex has some ties with the memory bus architecture it is connected to (SCB in our case) there is still a requirement to know the translation between a given physical address and its backing memory controller/aperture.

Ah ok, apologies for the noise then.

I was hoping that having working support for dma-ranges would remove the need for the special phys<->dma conversion routines.

Quoted 9 lines
Quoted 3 lines

What you describe definitively works with platform devices, but I am not sure this is working for PCIe devices, although, conceptually it should, yes.

Sorry for my delay in responding. One problem is that of_dma_configure() only looks at the first dma-range given and then converts it to dev->dma_pfn_offset which is respected by the DMA API. However, we often have multiple dma-ranges, not just one. This is the big issue.

Quoted 2 lines

Given the recent attention to getting these APIs in shape, this may be something Robin or Christoph may care to look into?

It looks like this has been brought up before in the "[RFC PATCH] of:
Fix DMA configuration for non-DT masters" thread aka

https://lists.linuxfoundation.org/pipermail/iommu/2017-April/021325.html

In the thread "Oza Oza", a Broadcom coworker probably dealing with the
same exact problem as I, enumerates three problems. #1 and #2 are
the exact same ones I've just given: the "dma-ranges" prop of the RC DT node is "skipped", and of_dma_get_range() only considers the first entry in any "dma-ranges".

Thanks, Jim

Quoted 16 lines

In any case, the description of dma-ranges should be in sync with the way Linux interprets it, so this is either a documentation bug or a DMA layer bug.

Quoted 7 lines

There is another issue with of_dma_configure() being invoked by the EP driver on "bridge->parent->of_node", which is our RC device, Of_dma_configure() calls of_dma_range() on the of_get_next_parent() of our RC's device node and this misses the dma-ranges property which is contained within the RC. I think I could workaround this but there is no getting around the first problem.

IIUC dma-ranges should be added to the parent bus of a device, which I guess is slightly ambiguous for a root complex that incorporates a host bridge.

#16 lore raw

Re: [PATCH v5 04/12] PCI: brcmstb: add dma-range mapping for inbound traffic

Quoted 89 lines · Jim Quinlan
Quoted 81 lines · Ard Biesheuvel
Quoted 69 lines · Jim Quinlan
Quoted 67 lines · Florian Fainelli
Quoted 64 lines · Ard Biesheuvel
Quoted 50 lines · Florian Fainelli
Quoted 41 lines · Ard Biesheuvel
Quoted 29 lines · Florian Fainelli
Quoted 28 lines · Ard Biesheuvel
Quoted 10 lines · Jim Quinlan

The Broadcom STB PCIe host controller is intimately related to the memory subsystem. This close relationship adds complexity to how cpu system memory is mapped to PCIe memory. Ideally, this mapping is an identity mapping, or an identity mapping off by a constant. Not so in this case.

Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB of system memory. Here is how the PCIe controller maps the system memory to PCIe memory:

Quoted 7 lines
   memc0-a@[        0....3fffffff] <=> pci@[        0....3fffffff]
   memc0-b@[100000000...13fffffff] <=> pci@[ 40000000....7fffffff]
   memc1-a@[ 40000000....7fffffff] <=> pci@[ 80000000....bfffffff]
   memc1-b@[300000000...33fffffff] <=> pci@[ c0000000....ffffffff]
   memc2-a@[ 80000000....bfffffff] <=> pci@[100000000...13fffffff]
   memc2-b@[c00000000...c3fffffff] <=> pci@[140000000...17fffffff]

So is describing this as

dma-ranges = <0x0 0x0 0x0 0x0 0x0 0x40000000>,

              <0x0 0x40000000 0x1 0x0 0x0 0x40000000>,
              <0x0 0x80000000 0x0 0x40000000 0x0 0x40000000>,
              <0x0 0xc0000000 0x3 0x0 0x0 0x40000000>,
              <0x1 0x0 0x0 0x80000000 0x0 0x40000000>,
              <0x1 0x40000000 0x0 0xc0000000 0x0 0x40000000>;
Quoted 7 lines
Quoted 3 lines

not working for you? I haven't tried this myself, but since DT permits describing the inbound mappings this way, we should fix the code if it doesn't work at the moment.

You mean encoding the memory controller index in the first cell? If that works, that's indeed a much cleaner solution, though is it standard compliant in any form?

No those are just memory addresses (although I may have screwed up the order). From Documentation/devicetree/booting-without-of.txt:

Quoted 7 lines

"""
Optional property:
- dma-ranges: <prop-encoded-array> encoded as arbitrary number of triplets of (child-bus-address, parent-bus-address, length). Each triplet specified describes a contiguous DMA address range.
"""

Quoted 8 lines

Then I am confused by your comment, that's what this patch does, it adds support for reading "dma-ranges" from Device Tree and setting up inbound windows using that. The only caveat is that because the PCIe root complex has some ties with the memory bus architecture it is connected to (SCB in our case) there is still a requirement to know the translation between a given physical address and its backing memory controller/aperture.

Ah ok, apologies for the noise then.

I was hoping that having working support for dma-ranges would remove the need for the special phys<->dma conversion routines.

Quoted 9 lines
Quoted 3 lines

What you describe definitively works with platform devices, but I am not sure this is working for PCIe devices, although, conceptually it should, yes.

Sorry for my delay in responding. One problem is that of_dma_configure() only looks at the first dma-range given and then converts it to dev->dma_pfn_offset which is respected by the DMA API. However, we often have multiple dma-ranges, not just one. This is the big issue.

Quoted 2 lines

Given the recent attention to getting these APIs in shape, this may be something Robin or Christoph may care to look into?

It looks like this has been brought up before in the "[RFC PATCH] of:
Fix DMA configuration for non-DT masters" thread aka

Quoted 7 lines

https://lists.linuxfoundation.org/pipermail/iommu/2017-April/021325.html

In the thread "Oza Oza", a Broadcom coworker probably dealing with the
same exact problem as I, enumerates three problems. #1 and #2 are
the exact same ones I've just given: the "dma-ranges" prop of the RC DT node is "skipped", and of_dma_get_range() only considers the first entry in any "dma-ranges".

Robin, is that something that is expected or should the "dma-ranges" somehow propagate from host bridge down the PCIe end-point drivers?

Quoted 19 lines

Thanks, Jim

Quoted 16 lines

In any case, the description of dma-ranges should be in sync with the way Linux interprets it, so this is either a documentation bug or a DMA layer bug.

Quoted 7 lines

There is another issue with of_dma_configure() being invoked by the EP driver on "bridge->parent->of_node", which is our RC device, Of_dma_configure() calls of_dma_range() on the of_get_next_parent() of our RC's device node and this misses the dma-ranges property which is contained within the RC. I think I could workaround this but there is no getting around the first problem.

IIUC dma-ranges should be added to the parent bus of a device, which I guess is slightly ambiguous for a root complex that incorporates a host bridge.

Humm, why is that ambiguous for a host bridge/root complex?

Signature · 1 line
Florian
#17 lore raw

Re: [PATCH v5 04/12] PCI: brcmstb: add dma-range mapping for inbound traffic

Quoted 120 lines · Florian Fainelli
Quoted 89 lines · Jim Quinlan
Quoted 81 lines · Ard Biesheuvel
Quoted 69 lines · Jim Quinlan
Quoted 67 lines · Florian Fainelli
Quoted 64 lines · Ard Biesheuvel
Quoted 50 lines · Florian Fainelli
Quoted 41 lines · Ard Biesheuvel
Quoted 29 lines · Florian Fainelli
Quoted 28 lines · Ard Biesheuvel
Quoted 10 lines · Jim Quinlan

The Broadcom STB PCIe host controller is intimately related to the memory subsystem. This close relationship adds complexity to how cpu system memory is mapped to PCIe memory. Ideally, this mapping is an identity mapping, or an identity mapping off by a constant. Not so in this case.

Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB of system memory. Here is how the PCIe controller maps the system memory to PCIe memory:

Quoted 7 lines
   memc0-a@[        0....3fffffff] <=> pci@[        0....3fffffff]
   memc0-b@[100000000...13fffffff] <=> pci@[ 40000000....7fffffff]
   memc1-a@[ 40000000....7fffffff] <=> pci@[ 80000000....bfffffff]
   memc1-b@[300000000...33fffffff] <=> pci@[ c0000000....ffffffff]
   memc2-a@[ 80000000....bfffffff] <=> pci@[100000000...13fffffff]
   memc2-b@[c00000000...c3fffffff] <=> pci@[140000000...17fffffff]

So is describing this as

dma-ranges = <0x0 0x0 0x0 0x0 0x0 0x40000000>,

              <0x0 0x40000000 0x1 0x0 0x0 0x40000000>,
              <0x0 0x80000000 0x0 0x40000000 0x0 0x40000000>,
              <0x0 0xc0000000 0x3 0x0 0x0 0x40000000>,
              <0x1 0x0 0x0 0x80000000 0x0 0x40000000>,
              <0x1 0x40000000 0x0 0xc0000000 0x0 0x40000000>;
Quoted 7 lines
Quoted 3 lines

not working for you? I haven't tried this myself, but since DT permits describing the inbound mappings this way, we should fix the code if it doesn't work at the moment.

You mean encoding the memory controller index in the first cell? If that works, that's indeed a much cleaner solution, though is it standard compliant in any form?

No those are just memory addresses (although I may have screwed up the order). From Documentation/devicetree/booting-without-of.txt:

Quoted 7 lines

"""
Optional property:
- dma-ranges: <prop-encoded-array> encoded as arbitrary number of triplets of (child-bus-address, parent-bus-address, length). Each triplet specified describes a contiguous DMA address range.
"""

Quoted 8 lines

Then I am confused by your comment, that's what this patch does, it adds support for reading "dma-ranges" from Device Tree and setting up inbound windows using that. The only caveat is that because the PCIe root complex has some ties with the memory bus architecture it is connected to (SCB in our case) there is still a requirement to know the translation between a given physical address and its backing memory controller/aperture.

Ah ok, apologies for the noise then.

I was hoping that having working support for dma-ranges would remove the need for the special phys<->dma conversion routines.

Quoted 9 lines
Quoted 3 lines

What you describe definitively works with platform devices, but I am not sure this is working for PCIe devices, although, conceptually it should, yes.

Sorry for my delay in responding. One problem is that of_dma_configure() only looks at the first dma-range given and then converts it to dev->dma_pfn_offset which is respected by the DMA API. However, we often have multiple dma-ranges, not just one. This is the big issue.

Quoted 2 lines

Given the recent attention to getting these APIs in shape, this may be something Robin or Christoph may care to look into?

It looks like this has been brought up before in the "[RFC PATCH] of:
Fix DMA configuration for non-DT masters" thread aka

Quoted 7 lines

https://lists.linuxfoundation.org/pipermail/iommu/2017-April/021325.html

In the thread "Oza Oza", a Broadcom coworker probably dealing with the
same exact problem as I, enumerates three problems. #1 and #2 are
the exact same ones I've just given: the "dma-ranges" prop of the RC DT node is "skipped", and of_dma_get_range() only considers the first entry in any "dma-ranges".

Robin, is that something that is expected or should the "dma-ranges" somehow propagate from host bridge down the PCIe end-point drivers?

Quoted 16 lines

Thanks, Jim

Quoted 13 lines

In any case, the description of dma-ranges should be in sync with the way Linux interprets it, so this is either a documentation bug or a DMA layer bug.

Quoted 7 lines

There is another issue with of_dma_configure() being invoked by the EP driver on "bridge->parent->of_node", which is our RC device, Of_dma_configure() calls of_dma_range() on the of_get_next_parent() of our RC's device node and this misses the dma-ranges property which is contained within the RC. I think I could workaround this but there is no getting around the first problem.

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

IIUC dma-ranges should be added to the parent bus of a device, which I guess is slightly ambiguous for a root complex that incorporates a host bridge.

Humm, why is that ambiguous for a host bridge/root complex?

Well, perhaps I am the only one who is slightly confused by this, but the fact that the device node describes both the host bridge and the root port/bridge (which is arguably a device behind the bus) makes it somewhat non-intuitive to me.

#18 lore raw

Re: [PATCH v5 04/12] PCI: brcmstb: add dma-range mapping for inbound traffic

In reply to Florian Fainelli
Quoted 121 lines · Florian Fainelli
Quoted 118 lines · Jim Quinlan
Quoted 108 lines · Ard Biesheuvel
Quoted 99 lines · Jim Quinlan
Quoted 88 lines · Florian Fainelli
Quoted 86 lines · Ard Biesheuvel
Quoted 70 lines · Florian Fainelli
Quoted 59 lines · Ard Biesheuvel
Quoted 47 lines · Florian Fainelli
Quoted 40 lines · Ard Biesheuvel
Quoted 15 lines · Jim Quinlan

The Broadcom STB PCIe host controller is intimately related to the
memory subsystem.? This close relationship adds complexity to how cpu
system memory is mapped to PCIe memory.? Ideally, this mapping is an
identity mapping, or an identity mapping off by a constant. Not so in
this case.

Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB
of system memory.? Here is how the PCIe controller maps the system memory to PCIe memory:

Quoted 13 lines

?? memc0-a@[??????? 0....3fffffff] <=> pci@[
0....3fffffff]
?? memc0-b@[100000000...13fffffff] <=> pci@[
40000000....7fffffff]
?? memc1-a@[ 40000000....7fffffff] <=> pci@[
80000000....bfffffff]
?? memc1-b@[300000000...33fffffff] <=> pci@[
c0000000....ffffffff]
?? memc2-a@[ 80000000....bfffffff] <=>
pci@[100000000...13fffffff]
?? memc2-b@[c00000000...c3fffffff] <=>
pci@[140000000...17fffffff]

So is describing this as

dma-ranges = <0x0 0x0 0x0 0x0 0x0 0x40000000>, ????????????? <0x0 0x40000000 0x1 0x0 0x0 0x40000000>, ????????????? <0x0 0x80000000 0x0 0x40000000 0x0 0x40000000>, ????????????? <0x0 0xc0000000 0x3 0x0 0x0 0x40000000>, ????????????? <0x1 0x0 0x0 0x80000000 0x0 0x40000000>, ????????????? <0x1 0x40000000 0x0 0xc0000000 0x0 0x40000000>;

Quoted 5 lines

not working for you? I haven't tried this myself, but since DT permits
describing the inbound mappings this way, we should fix the code if it
doesn't work at the moment.

Quoted 5 lines

You mean encoding the memory controller index in the first cell? If that
works, that's indeed a much cleaner solution, though is it standard
compliant in any form?

No those are just memory addresses (although I may have screwed up the
order). From Documentation/devicetree/booting-without-of.txt:

Quoted 9 lines

"""
Optional property:
- dma-ranges: <prop-encoded-array> encoded as arbitrary number of triplets of
???????? (child-bus-address, parent-bus-address, length). Each triplet specified
???????? describes a contiguous DMA address range. """

Quoted 11 lines

Then I am confused by your comment, that's what this patch does, it adds
support for reading "dma-ranges" from Device Tree and setting up inbound
windows using that. The only caveat is that because the PCIe root complex has some ties with the memory bus architecture it is connected
to (SCB in our case) there is still a requirement to know the translation between a given physical address and its backing memory controller/aperture.

Ah ok, apologies for the noise then.

Quoted 8 lines
Quoted 2 lines

I was hoping that having working support for dma-ranges would remove the need for the special phys<->dma conversion routines.

What you describe definitively works with platform devices, but I am not
sure this is working for PCIe devices, although, conceptually it should,
yes.

Quoted 6 lines

Sorry for my delay in responding.? One problem is that of_dma_configure() only looks at the first dma-range given and then converts it to dev->dma_pfn_offset which is respected by the DMA API. However, we often have multiple dma-ranges, not just one.? This is the big issue.

Quoted 2 lines

Given the recent attention to getting these APIs in shape, this may be something Robin or Christoph may care to look into?

It looks like this has been brought up before in the "[RFC PATCH] of:
Fix DMA configuration for non-DT masters" thread aka

https://lists.linuxfoundation.org/pipermail/iommu/2017-April/021325.html

Quoted 8 lines
Quoted 5 lines

In the thread "Oza Oza", a Broadcom coworker probably dealing with the same exact problem as I,? enumerates three problems.?? #1 and #2 are the exact same ones I've just given: the "dma-ranges" prop of the RC DT node is "skipped", and of_dma_get_range() only considers the first entry in any "dma-ranges".

Robin, is that something that is expected or should the "dma-ranges" somehow propagate from host bridge down the PCIe end-point drivers?

Nope, the code is most definitely incomplete - it's sufficient to support the system it was originally needed for (i.e. platform devices with a single range), but can by no means even pretend to support the binding fully. Furthermore, the way that PCI support was later grafted into of_dma_configure() was *only* in support of dma-coherent without consideration for dma-ranges. Hence the current mess.

Quoted 16 lines
Quoted 16 lines

Thanks, Jim

Quoted 13 lines

In any case, the description of dma-ranges should be in sync with the way Linux interprets it, so this is either a documentation bug or a DMA layer bug.

Quoted 7 lines

There is another issue with of_dma_configure() being invoked by the EP driver on "bridge->parent->of_node", which is our RC device, Of_dma_configure() calls of_dma_range() on the of_get_next_parent() of our RC's device node and this misses the dma-ranges property which is contained within the RC.? I think I could workaround this but there is no getting around the first problem.

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

IIUC dma-ranges should be added to the parent bus of a device, which I guess is slightly ambiguous for a root complex that incorporates a host bridge.

Humm, why is that ambiguous for a host bridge/root complex?

The real problem is that FDT machines don't describe the PCI hierarchy in DT as proper OF does, so we have this awkward crossing between the DT model and the Linux device model where the devices have no DT representation and the "parent bus" is a DT leaf node, which cocks up the way the current code is expecting to work.

Robin.

#19 lore raw

Re: [PATCH v5 04/12] PCI: brcmstb: add dma-range mapping for inbound traffic

Quoted 131 lines · Robin Murphy
Quoted 121 lines · Florian Fainelli
Quoted 118 lines · Jim Quinlan
Quoted 108 lines · Ard Biesheuvel
Quoted 99 lines · Jim Quinlan
Quoted 88 lines · Florian Fainelli
Quoted 86 lines · Ard Biesheuvel
Quoted 70 lines · Florian Fainelli
Quoted 59 lines · Ard Biesheuvel
Quoted 47 lines · Florian Fainelli
Quoted 40 lines · Ard Biesheuvel
Quoted 15 lines · Jim Quinlan

The Broadcom STB PCIe host controller is intimately related to the
memory subsystem.? This close relationship adds complexity to how cpu
system memory is mapped to PCIe memory.? Ideally, this mapping is an
identity mapping, or an identity mapping off by a constant.? Not so in
this case.

Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB
of system memory.? Here is how the PCIe controller maps the system memory to PCIe memory:

Quoted 13 lines

?? memc0-a@[??????? 0....3fffffff] <=> pci@[??????? 0....3fffffff]
?? memc0-b@[100000000...13fffffff] <=> pci@[ 40000000....7fffffff]
?? memc1-a@[ 40000000....7fffffff] <=> pci@[ 80000000....bfffffff]
?? memc1-b@[300000000...33fffffff] <=> pci@[ c0000000....ffffffff]
?? memc2-a@[ 80000000....bfffffff] <=> pci@[100000000...13fffffff]
?? memc2-b@[c00000000...c3fffffff] <=> pci@[140000000...17fffffff]

So is describing this as

dma-ranges = <0x0 0x0 0x0 0x0 0x0 0x40000000>, ????????????? <0x0 0x40000000 0x1 0x0 0x0 0x40000000>, ????????????? <0x0 0x80000000 0x0 0x40000000 0x0 0x40000000>, ????????????? <0x0 0xc0000000 0x3 0x0 0x0 0x40000000>, ????????????? <0x1 0x0 0x0 0x80000000 0x0 0x40000000>, ????????????? <0x1 0x40000000 0x0 0xc0000000 0x0 0x40000000>;

Quoted 5 lines

not working for you? I haven't tried this myself, but since DT permits
describing the inbound mappings this way, we should fix the code if it
doesn't work at the moment.

Quoted 5 lines

You mean encoding the memory controller index in the first cell? If that
works, that's indeed a much cleaner solution, though is it standard
compliant in any form?

No those are just memory addresses (although I may have screwed up the
order). From Documentation/devicetree/booting-without-of.txt:

Quoted 9 lines

"""
Optional property:
- dma-ranges: <prop-encoded-array> encoded as arbitrary number of triplets of
???????? (child-bus-address, parent-bus-address, length). Each triplet specified
???????? describes a contiguous DMA address range. """

Quoted 11 lines

Then I am confused by your comment, that's what this patch does, it adds
support for reading "dma-ranges" from Device Tree and setting up inbound
windows using that. The only caveat is that because the PCIe root complex has some ties with the memory bus architecture it is connected
to (SCB in our case) there is still a requirement to know the translation between a given physical address and its backing memory controller/aperture.

Ah ok, apologies for the noise then.

Quoted 8 lines
Quoted 2 lines

I was hoping that having working support for dma-ranges would remove the need for the special phys<->dma conversion routines.

What you describe definitively works with platform devices, but I am not
sure this is working for PCIe devices, although, conceptually it should,
yes.

Quoted 6 lines

Sorry for my delay in responding.? One problem is that of_dma_configure() only looks at the first dma-range given and then converts it to dev->dma_pfn_offset which is respected by the DMA API. However, we often have multiple dma-ranges, not just one.? This is the big issue.

Quoted 2 lines

Given the recent attention to getting these APIs in shape, this may be something Robin or Christoph may care to look into?

It looks like this has been brought up before in the "[RFC PATCH] of:
Fix DMA configuration for non-DT masters" thread aka

https://lists.linuxfoundation.org/pipermail/iommu/2017-April/021325.html

Quoted 8 lines
Quoted 5 lines

In the thread "Oza Oza", a Broadcom coworker probably dealing with the same exact problem as I,? enumerates three problems.?? #1 and #2 are the exact same ones I've just given: the "dma-ranges" prop of the RC DT node is "skipped", and of_dma_get_range() only considers the first entry in any "dma-ranges".

Robin, is that something that is expected or should the "dma-ranges" somehow propagate from host bridge down the PCIe end-point drivers?

Quoted 6 lines

Nope, the code is most definitely incomplete - it's sufficient to support the system it was originally needed for (i.e. platform devices with a single range), but can by no means even pretend to support the binding fully. Furthermore, the way that PCI support was later grafted into of_dma_configure() was *only* in support of dma-coherent without consideration for dma-ranges. Hence the current mess.

Is this the way we should go? If the PCIe root complex has a "dma-ranges" property, we need to make sure that all child devices behind it get that translation applied as well? Right now we tried to follow Christoph's recommendations from the v1 through v4 submissions, but that does not really seem to be working well.

I am really not a fan of having to go audit every architecture, and possibly insert the right translation in there, while introducing a possible layering problem too...

Quoted 21 lines
Quoted 21 lines
Quoted 20 lines

Thanks, Jim

Quoted 16 lines

In any case, the description of dma-ranges should be in sync with the way Linux interprets it, so this is either a documentation bug or a DMA layer bug.

Quoted 7 lines

There is another issue with of_dma_configure() being invoked by the EP driver on "bridge->parent->of_node", which is our RC device, Of_dma_configure() calls of_dma_range() on the of_get_next_parent() of our RC's device node and this misses the dma-ranges property which is contained within the RC.? I think I could workaround this but there is no getting around the first problem.

IIUC dma-ranges should be added to the parent bus of a device, which I guess is slightly ambiguous for a root complex that incorporates a host bridge.

Quoted 7 lines
Quoted 1 line

Humm, why is that ambiguous for a host bridge/root complex?

The real problem is that FDT machines don't describe the PCI hierarchy in DT as proper OF does, so we have this awkward crossing between the DT model and the Linux device model where the devices have no DT representation and the "parent bus" is a DT leaf node, which cocks up the way the current code is expecting to work.

OK, I see what you mean, we still have to work with what we have here, which is FDT...

Signature · 1 line
Florian
#20 lore raw

Re: [PATCH v5 04/12] PCI: brcmstb: add dma-range mapping for inbound traffic

In reply to Jim Quinlan

Hi Jim,

Am 24.09.18 um 17:01 schrieb Jim Quinlan:

Quoted 7 lines
Quoted 5 lines · Ard Biesheuvel
Quoted 4 lines · Jim Quinlan
Quoted 3 lines · Florian Fainelli
Quoted 2 lines · Ard Biesheuvel
Quoted 1 line · Florian Fainelli

On 09/20/2018 02:04 PM, Ard Biesheuvel wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines · Florian Fainelli
Quoted 7 lines · Ard Biesheuvel
Quoted 6 lines · Jim Quinlan
Quoted 5 lines

The Broadcom STB PCIe host controller is intimately related to the memory subsystem. This close relationship adds complexity to how cpu system memory is mapped to PCIe memory. Ideally, this mapping is an identity mapping, or an identity mapping off by a constant. Not so in this case.

are there any plans to release a new version of this series?

The Raspberry Pi 4 uses a similiar PCIe controller, so it would be nice to get this upstream. Unfortunately i have no clue about PCI, so i the only thing i can do is testing.

Regards
Stefan

author maintainer
#21 lore raw

PATCH v5 5/12 PCI: brcmstb: add MSI capability

In reply to Jim Quinlan

This commit adds MSI to the Broadcom STB PCIe host controller. It does not add MSIX since that functionality is not in the HW. The MSI controller is physically located within the PCIe block, however, there is no reason why the MSI controller could not be moved elsewhere in the future.

Since the internal Brcmstb MSI controller is intertwined with the PCIe controller, it is not its own platform device but rather part of the PCIe platform device.

---
 drivers/pci/controller/Kconfig        |   2 +-
 drivers/pci/controller/pcie-brcmstb.c | 361 ++++++++++++++++++++++++++++++++--
 2 files changed, 351 insertions(+), 12 deletions(-)
drivers/pci/controller/Kconfig +1 -1
index c863c67..8daa621 100644
@@ -281,7 +281,7 @@ config VMD
 config PCIE_BRCMSTB
 	bool "Broadcom Brcmstb PCIe host controller"
 	depends on ARCH_BRCMSTB || BMIPS_GENERIC
-	depends on OF
+	depends on OF && PCI_MSI
 	depends on SOC_BRCMSTB
 	default ARCH_BRCMSTB || BMIPS_GENERIC
 	help
drivers/pci/controller/pcie-brcmstb.c +350 -11

477 lines not on this page · raw message

Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#22 lore raw

PATCH v5 6/12 MIPS: BMIPS: add dma remap for BrcmSTB PCIe

In reply to Jim Quinlan

The design of the Broadcom PCIe RC controller requires us to remap its DMA addresses for inbound traffic. We do this by modifying the definitions of __phys_to_dma() and __dma_to_phys().

In arch/mips/bmips/dma.c, these functions are already in use to remap DMA addresses for the 338x SOC chips. We leave this code alone -- and give its mapping priority -- but if it is not in use, the PCIe DMA mapping is in effect.

One might think that the two DMA remapping systems of dma.c could be combined, but they cannot: one governs only DMA addresses for the PCIe controller of BrcmSTB ARM/ARM64/MIPs chips, while the other governs the PCIe controller *and* other peripherals for only MIPs 338x chips.

---
 arch/mips/bmips/dma.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/mips/bmips/dma.c +9 -0
index 3d13c77..292994f 100644
@@ -18,6 +18,7 @@
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <asm/bmips.h>
+#include <soc/brcmstb/common.h>
 
 /*
  * BCM338x has configurable address translation windows which allow the
@@ -44,6 +45,10 @@ dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t pa)
 {
 	struct bmips_dma_range *r;
 
+#ifdef CONFIG_PCIE_BRCMSTB
+	if (!bmips_dma_ranges)
+		return brcm_phys_to_dma(dev, pa);
+#endif
 	for (r = bmips_dma_ranges; r && r->size; r++) {
 		if (pa >= r->child_addr &&
 		    pa < (r->child_addr + r->size))
@@ -56,6 +61,10 @@ phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dma_addr)
 {
 	struct bmips_dma_range *r;
 
+#ifdef CONFIG_PCIE_BRCMSTB
+	if (!bmips_dma_ranges)
+		return (unsigned long)brcm_dma_to_phys(dev, dma_addr);
+#endif
 	for (r = bmips_dma_ranges; r && r->size; r++) {
 		if (dma_addr >= r->parent_addr &&
 		    dma_addr < (r->parent_addr + r->size))
Signature · 1 line
1.9.0.138.g2de3478
#23 lore raw

Re: [PATCH v5 06/12] MIPS: BMIPS: add dma remap for BrcmSTB PCIe

Hi Jim,

Quoted 15 lines · Jim Quinlan

The design of the Broadcom PCIe RC controller requires us to remap its DMA addresses for inbound traffic. We do this by modifying the definitions of __phys_to_dma() and __dma_to_phys().

In arch/mips/bmips/dma.c, these functions are already in use to remap DMA addresses for the 338x SOC chips. We leave this code alone -- and give its mapping priority -- but if it is not in use, the PCIe DMA mapping is in effect.

One might think that the two DMA remapping systems of dma.c could be combined, but they cannot: one governs only DMA addresses for the PCIe controller of BrcmSTB ARM/ARM64/MIPs chips, while the other governs the PCIe controller *and* other peripherals for only MIPs 338x chips.

Quoted 4 lines
---
 arch/mips/bmips/dma.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Please copy me/linux-mips on the whole series next time - I seem to have only received patches 6, 8 & 9 which means I have no idea whether they have dependencies & if so whether those dependencies have been accepted or rejected. I also have no clue whether these patches make sense to take through the MIPS tree or if it would make more sense for someone else to take them with acks.

Quoted 13 lines
arch/mips/bmips/dma.c +1 -0
index 3d13c77..292994f 100644
@@ -18,6 +18,7 @@
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <asm/bmips.h>
+#include <soc/brcmstb/common.h>
 
 /*
  * BCM338x has configurable address translation windows which allow the

arch/mips/bmips/dma.c dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t pa) · line 54

Quoted 10 lines
arch/mips/bmips/dma.c +4 -0
@@ -44,6 +45,10 @@ dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t pa)
 {
 	struct bmips_dma_range *r;
 
+#ifdef CONFIG_PCIE_BRCMSTB
+	if (!bmips_dma_ranges)
+		return brcm_phys_to_dma(dev, pa);
+#endif
 	for (r = bmips_dma_ranges; r && r->size; r++) {
 		if (pa >= r->child_addr &&
 		    pa < (r->child_addr + r->size))

I can't tell because I presume brcm_phys_to_dma() is added in one of those patches I wasn't copied on, but perhaps you could avoid the #ifdef by just returning brcm_phys_to_dma(dev, pa) after the loop?

arch/mips/bmips/dma.c phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dma_addr) · line 70

Quoted 11 lines
arch/mips/bmips/dma.c +4 -0
@@ -56,6 +61,10 @@ phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dma_addr)
 {
 	struct bmips_dma_range *r;
 
+#ifdef CONFIG_PCIE_BRCMSTB
+	if (!bmips_dma_ranges)
+		return (unsigned long)brcm_dma_to_phys(dev, dma_addr);
+#endif
 	for (r = bmips_dma_ranges; r && r->size; r++) {
 		if (dma_addr >= r->parent_addr &&
 		    dma_addr < (r->parent_addr + r->size))

And similar here.

Thanks,
Paul

author maintainer
#24 lore raw

Re: [PATCH v5 06/12] MIPS: BMIPS: add dma remap for BrcmSTB PCIe

Quoted 24 lines · Paul Burton

Hi Jim,

Quoted 15 lines · Jim Quinlan

The design of the Broadcom PCIe RC controller requires us to remap its DMA addresses for inbound traffic. We do this by modifying the definitions of __phys_to_dma() and __dma_to_phys().

In arch/mips/bmips/dma.c, these functions are already in use to remap DMA addresses for the 338x SOC chips. We leave this code alone -- and give its mapping priority -- but if it is not in use, the PCIe DMA mapping is in effect.

One might think that the two DMA remapping systems of dma.c could be combined, but they cannot: one governs only DMA addresses for the PCIe controller of BrcmSTB ARM/ARM64/MIPs chips, while the other governs the PCIe controller *and* other peripherals for only MIPs 338x chips.

Quoted 4 lines
---
 arch/mips/bmips/dma.c | 9 +++++++++
 1 file changed, 9 insertions(+)
Quoted 6 lines

Please copy me/linux-mips on the whole series next time - I seem to have only received patches 6, 8 & 9 which means I have no idea whether they have dependencies & if so whether those dependencies have been accepted or rejected. I also have no clue whether these patches make sense to take through the MIPS tree or if it would make more sense for someone else to take them with acks.

Hi Paul,
I had problem with the first time I sent this out and someone said I should reduce me email list so I used the "git email --cc_cmd get_mainters.pl". I'll switch back to an aggregate email list.

Quoted 17 lines
Quoted 17 lines
arch/mips/bmips/dma.c +1 -0
index 3d13c77..292994f 100644
@@ -18,6 +18,7 @@
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <asm/bmips.h>
+#include <soc/brcmstb/common.h>
 
 /*
  * BCM338x has configurable address translation windows which allow the
@@ -44,6 +45,10 @@ dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t pa)
 {
      struct bmips_dma_range *r;
 
Quoted 11 lines

arch/mips/bmips/dma.c dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t pa) · line 54

Quoted 7 lines
arch/mips/bmips/dma.c +4 -0
+#ifdef CONFIG_PCIE_BRCMSTB
+     if (!bmips_dma_ranges)
+             return brcm_phys_to_dma(dev, pa);
+#endif
      for (r = bmips_dma_ranges; r && r->size; r++) {
              if (pa >= r->child_addr &&
                  pa < (r->child_addr + r->size))

I can't tell because I presume brcm_phys_to_dma() is added in one of those patches I wasn't copied on, but perhaps you could avoid the #ifdef by just returning brcm_phys_to_dma(dev, pa) after the loop?

Yes, will rectify in next version.

Quoted 5 lines
Quoted 5 lines
arch/mips/bmips/dma.c +0 -0
@@ -56,6 +61,10 @@ phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dma_addr)
 {
      struct bmips_dma_range *r;
 
Quoted 10 lines

arch/mips/bmips/dma.c phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dma_addr) · line 70

Quoted 7 lines
arch/mips/bmips/dma.c +4 -0
+#ifdef CONFIG_PCIE_BRCMSTB
+     if (!bmips_dma_ranges)
+             return (unsigned long)brcm_dma_to_phys(dev, dma_addr);
+#endif
      for (r = bmips_dma_ranges; r && r->size; r++) {
              if (dma_addr >= r->parent_addr &&
                  dma_addr < (r->parent_addr + r->size))

And similar here.

Okay, thanks,
Jim

Quoted 2 lines

Thanks,
Paul

author maintainer
#25 lore raw

PATCH v5 7/12 PCI/MSI: enable PCI_MSI_IRQ_DOMAIN support for MIPS

In reply to Jim Quinlan

Add MIPS as an arch that supports PCI_MSI_IRQ_DOMAIN and add generation of msi.h in the MIPS arch.

---
 drivers/pci/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/Kconfig +1 -1
index 56ff8f6..61a9539 100644
@@ -22,7 +22,7 @@ config PCI_MSI
 	   If you don't know what to do here, say Y.
 
 config PCI_MSI_IRQ_DOMAIN
-	def_bool ARC || ARM || ARM64 || X86
+	def_bool ARC || ARM || ARM64 || MIPS || X86
 	depends on PCI_MSI
 	select GENERIC_MSI_IRQ_DOMAIN
 
Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#26 lore raw

PATCH v5 8/12 MIPS: BMIPS: add PCI bindings for 7425, 7435

In reply to Jim Quinlan

Adds the PCIe nodes for the Broadcom STB PCIe root complex.

---
 arch/mips/boot/dts/brcm/bcm7425.dtsi     | 28 ++++++++++++++++++++++++++++
 arch/mips/boot/dts/brcm/bcm7435.dtsi     | 28 ++++++++++++++++++++++++++++
 arch/mips/boot/dts/brcm/bcm97425svmb.dts |  4 ++++
 arch/mips/boot/dts/brcm/bcm97435svmb.dts |  4 ++++
 4 files changed, 64 insertions(+)
arch/mips/boot/dts/brcm/bcm7425.dtsi +28 -0
index 410e61e..0edcbe4 100644
@@ -584,4 +584,32 @@
 			};
 		};
 	};
+
+	pcie: pcie@10410000 {
+		reg = <0x10410000 0x830c>;
+		compatible = "brcm,bcm7425-pcie";
+		interrupts = <37>, <37>;
+		interrupt-names = "pcie", "msi";
+		interrupt-parent = <&periph_intc>;
+		#address-cells = <3>;
+		#size-cells = <2>;
+		linux,pci-domain = <0>;
+		brcm,enable-ssc;
+		bus-range = <0x00 0xff>;
+		msi-controller;
+		#interrupt-cells = <1>;
+		/* 4x128mb windows */
+		ranges = <0x2000000 0x0 0xd0000000 0xd0000000 0x0 0x20000000>;
+		/* 768M or 1GB memc0, 0-1GB memc1 */
+		dma-ranges =
+			<0x02000000 0x0 0x00000000 0x00000000 0x0 0x10000000>,
+			<0x02000000 0x0 0x10000000 0x20000000 0x0 0x30000000>,
+			<0x02000000 0x0 0x40000000 0x90000000 0x0 0x40000000>;
+		interrupt-map-mask = <0 0 0 7>;
+		interrupt-map = <0 0 0 1 &periph_intc 33
+				 0 0 0 2 &periph_intc 34
+				 0 0 0 3 &periph_intc 35
+				 0 0 0 4 &periph_intc 36>;
+	};
+
 };
arch/mips/boot/dts/brcm/bcm7435.dtsi +28 -0
index 8398b7f..50bc7a0 100644
@@ -599,4 +599,32 @@
 			};
 		};
 	};
+
+	pcie: pcie@10410000 {
+		reg = <0x10410000 0x930c>;
+		interrupts = <0x27>, <0x27>;
+		interrupt-names = "pcie", "msi";
+		interrupt-parent = <&periph_intc>;
+		compatible = "brcm,bcm7435-pcie";
+		#address-cells = <3>;
+		#size-cells = <2>;
+		linux,pci-domain = <0>;
+		brcm,enable-ssc;
+		bus-range = <0x00 0xff>;
+		msi-controller;
+		#interrupt-cells = <1>;
+		ranges = <0x2000000 0x0 0xd0000000 0xd0000000 0x0 0x20000000>;
+		/* 768M or 1GB memc0, 0-1GB memc1 */
+		dma-ranges =
+			<0x02000000 0x0 0x00000000 0x00000000 0x0 0x10000000>,
+			<0x02000000 0x0 0x10000000 0x20000000 0x0 0x30000000>,
+			<0x02000000 0x0 0x40000000 0x90000000 0x0 0x40000000>;
+		interrupt-map-mask = <0 0 0 7>;
+		interrupt-map = <0 0 0 1 &periph_intc 35
+				 0 0 0 2 &periph_intc 36
+				 0 0 0 3 &periph_intc 37
+				 0 0 0 4 &periph_intc 38>;
+		status = "disabled";
+	};
+
 };
arch/mips/boot/dts/brcm/bcm97425svmb.dts +4 -0
index 0ed2221..22270a9 100644
@@ -152,3 +152,7 @@
 &waketimer {
 	status = "okay";
 };
+
+&pcie {
+	status = "okay";
+};
arch/mips/boot/dts/brcm/bcm97435svmb.dts +4 -0
index 2c145a8..91bc1ec 100644
@@ -128,3 +128,7 @@
 &waketimer {
 	status = "okay";
 };
+
+&pcie {
+	status = "okay";
+};
Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#27 lore raw

PATCH v5 9/12 MIPS: BMIPS: enable PCI

In reply to Jim Quinlan

Adds the Kconfig hooks to enable the Broadcom STB PCIe root complex driver for Broadcom MIPS systems.

---
 arch/mips/Kconfig | 3 +++
 1 file changed, 3 insertions(+)
arch/mips/Kconfig +3 -0
index 3551199..a15c0da 100644
@@ -220,6 +220,9 @@ config BMIPS_GENERIC
 	select BOOT_RAW
 	select NO_EXCEPT_FILL
 	select USE_OF
+	select HW_HAS_PCI
+	select PCI_DRIVERS_GENERIC
+	select PCI
 	select CEVT_R4K
 	select CSRC_R4K
 	select SYNC_R4K
Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#28 lore raw

PATCH v5 10/12 ARM64: declare __phys_to_dma on ARCH_HAS_PHYS_TO_DMA

In reply to Jim Quinlan

This change allows one to define custom routines for __phys_to_dma() and __dma_to_phys() for the ARM64 architecture by selecting ARCH_HAS_PHYS_TO_DMA. This is done for similar reasons that caused arch/x86/include/asm/dma-direct.h to exist (see CONFIG_STA2X11).

---
 arch/arm64/include/asm/dma-direct.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 arch/arm64/include/asm/dma-direct.h
arch/arm64/include/asm/dma-direct.h new file +16 -0
new file mode 100644
index 0000000..d87da92
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ARM64_DMA_DIRECT_H
+#define _ARM64_DMA_DIRECT_H 1
+
+static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
+{
+	if (!dev->dma_mask)
+		return false;
+
+	return addr + size - 1 <= *dev->dma_mask;
+}
+
+dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr);
+phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t daddr);
+
+#endif /* _ARM64_DMA_DIRECT_H */
Signature · 1 line
1.9.0.138.g2de3478
#29 lore raw

Re: [PATCH v5 10/12] ARM64: declare __phys_to_dma on ARCH_HAS_PHYS_TO_DMA

This is useless on its own. Please merge it into whatever patch selects ARCH_HAS_PHYS_TO_DMA and actually implements the functions.

author maintainer
#30 lore raw

PATCH v5 11/12 ARM64: add dma remap for BrcmSTB PCIe

In reply to Jim Quinlan

The BrcmSTB PCIe controller needs to remap DMA accesses to it because of the requirements of its interface with the SOC memory controllers.

---
 drivers/pci/controller/Kconfig        |  1 +
 drivers/pci/controller/pcie-brcmstb.c | 12 ++++++++++++
 2 files changed, 13 insertions(+)
drivers/pci/controller/Kconfig +1 -0
index 8daa621..4394430 100644
@@ -284,6 +284,7 @@ config PCIE_BRCMSTB
 	depends on OF && PCI_MSI
 	depends on SOC_BRCMSTB
 	default ARCH_BRCMSTB || BMIPS_GENERIC
+	select ARCH_HAS_PHYS_TO_DMA if ARM64
 	help
 	  Say Y here to enable PCIe host controller support for
 	  Broadcom Settop Box SOCs.  A Broadcom SOC will may have
drivers/pci/controller/pcie-brcmstb.c +12 -0
index a805d87..ae9df8e 100644
@@ -974,6 +974,18 @@ phys_addr_t brcm_dma_to_phys(struct device *dev, dma_addr_t dev_addr)
 	return (phys_addr_t)dev_addr;
 }
 
+#if defined(CONFIG_ARM64)
+dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr)
+{
+	return brcm_phys_to_dma(dev, paddr);
+}
+
+phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dev_addr)
+{
+	return brcm_dma_to_phys(dev, dev_addr);
+}
+#endif
+
 static int brcm_pcie_add_controller(struct brcm_pcie *pcie)
 {
 	int i, ret = 0;
Signature · 1 line
1.9.0.138.g2de3478
#31 lore raw

Re: [PATCH v5 11/12] ARM64: add dma remap for BrcmSTB PCIe

Quoted 1 line · Jim Quinlan

+#if defined(CONFIG_ARM64)

Please use plain #ifdef where possible.

drivers/pci/controller/pcie-brcmstb.c phys_addr_t brcm_dma_to_phys(struct device *dev, dma_addr_t dev_addr) · line 987

Quoted 10 lines
drivers/pci/controller/pcie-brcmstb.c +10 -0
+dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr)
+{
+	return brcm_phys_to_dma(dev, paddr);
+}
+
+phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dev_addr)
+{
+	return brcm_dma_to_phys(dev, dev_addr);
+}
+#endif

How is this going to work for a kernel with BrcmSTB built in, but running on a more standard arm64 SOC?

I suspect we really just want a set of ranges hanging off struct device (conditional on a config option). Each SoC can then fill it at boot time, and if it is non-NULL the DMA code will use it instead of calling __phys_to_dma and __dma_to_phys. In fact the single range version could probably just replace the existing dma_pfn_offset field.

author maintainer
#32 lore raw

Re: [PATCH v5 11/12] ARM64: add dma remap for BrcmSTB PCIe

Quoted 6 lines · Christoph Hellwig
Quoted 1 line · Jim Quinlan

+#if defined(CONFIG_ARM64)

Please use plain #ifdef where possible.

Quoted 13 lines

drivers/pci/controller/pcie-brcmstb.c phys_addr_t brcm_dma_to_phys(struct device *dev, dma_addr_t dev_addr) · line 987

Quoted 10 lines
drivers/pci/controller/pcie-brcmstb.c +10 -0
+dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr)
+{
+     return brcm_phys_to_dma(dev, paddr);
+}
+
+phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dev_addr)
+{
+     return brcm_dma_to_phys(dev, dev_addr);
+}
+#endif

How is this going to work for a kernel with BrcmSTB built in, but running on a more standard arm64 SOC?

Sorry for the delay in my response. It would work because the dma_ranges would be empty/null and identity mapping would happen, but yes, all __dma_to_phys and __phys_to_dma calls would be wasting time going through the brcm functions. We would have to take BRCMSTB=y out of the defconfig. Florian would probably NAK that idea.

Please remember that the reason for this approach is because in your response to V4 you suggested that "Override phys_to_dma and dma_to_phys as mips and x86 [sta2x11] do for similar situations" and "Overriding phys_to_dma and dma_to_phys is required if you need to support swiotlb, and chances are with a broken PCIe controller on arm64 or mips64 you eventuall will".

Quoted 7 lines

I suspect we really just want a set of ranges hanging off struct device (conditional on a config option). Each SoC can then fill it at boot time, and if it is non-NULL the DMA code will use it instead of calling __phys_to_dma and __dma_to_phys. In fact the single range version could probably just replace the existing dma_pfn_offset field.

If this was a config option then BRCMSTB=y in defconfig would set this for all ARM64, just like the above case, correct? And would this work
with SWIOTLB? Also, do you think others would use it, or would I be
adding code in the DMA API only because of one unusual PCIe host
controller design? Keep in mind that although you didn't like the
approach of V4 -- which intercepted DMA ops to make the appropriate mapping and was not compatible with SWIOTLB -- at least it kept the code restricted to oru driver.

Thanks,
Jim

author maintainer
#33 lore raw

PATCH v5 12/12 ARM: add dma remap for BrcmSTB PCIe

In reply to Jim Quinlan

The BrcmSTB PCIe controller needs to remap DMA accesses to it because of the requirements of its interface with the SOC memory controllers. In the ARM64 and MIPs architectures, this is accomplished by CONFIG_ARCH_HAS_PHYS_TO_DMA=y and then defining the functions __dma_to_phys() and __phys_to_dma() accordingly.

Doing so for the ARM architecture is not as easy as ARM64 and MIPS; the two functions are already defined as static inline functions. Howevery, the behavior of these functions may be changed by redefining the sub-functions that these two functions invoke.

Specifically, this commit defines

	__arch_pfn_to_dma()
	__arch_dma_to_pfn()
	__arch_dma_to_virt()
	__arch_virt_to_dma()

as these are the functions invoked by __dma_to_phys() and __phys_to_dma(). Unfortunately, the only apparent approach to do this is to declare and define the four sub-functions in arch/arm/mach-bcm/include/mach/memory.h, and in doing so we must move out of ARCH_MULTIPLATFORM and create brcmstb_defconfig, as we were previously using multi_v7_defconfig.

---
 arch/arm/Kconfig                            |  33 +++++
 arch/arm/configs/brcmstb_defconfig          | 204 ++++++++++++++++++++++++++++
 arch/arm/configs/multi_v7_defconfig         |   3 -
 arch/arm/mach-bcm/Kconfig                   |  21 +--
 arch/arm/mach-bcm/Makefile.boot             |   0
 arch/arm/mach-bcm/include/mach/irqs.h       |   3 +
 arch/arm/mach-bcm/include/mach/memory.h     |  47 +++++++
 arch/arm/mach-bcm/include/mach/uncompress.h |   8 ++
 8 files changed, 296 insertions(+), 23 deletions(-)
 create mode 100644 arch/arm/configs/brcmstb_defconfig
 create mode 100644 arch/arm/mach-bcm/Makefile.boot
 create mode 100644 arch/arm/mach-bcm/include/mach/irqs.h
 create mode 100644 arch/arm/mach-bcm/include/mach/memory.h
 create mode 100644 arch/arm/mach-bcm/include/mach/uncompress.h
arch/arm/Kconfig +33 -0
index e8cd55a..913765b 100644
@@ -637,6 +637,39 @@ config ARCH_OMAP1
 	help
 	  Support for older TI OMAP1 (omap7xx, omap15xx or omap16xx)
 
+config ARCH_BRCMSTB
+	bool "Broadcom BCM7XXX based boards"
+	select ARM_HAS_SG_CHAIN
+	select ARM_PATCH_PHYS_VIRT
+	select TIMER_OF
+	select COMMON_CLK
+	select GENERIC_CLOCKEVENTS
+	select MULTI_IRQ_HANDLER
+	select MIGHT_HAVE_PCI
+	select PCI_DOMAINS if PCI
+	select USE_OF
+
+	select CPU_V7
+	select ARCH_BCM
+	select HAVE_SMP
+	select AUTO_ZRELADDR
+	select ARM_GIC
+	select ARM_GIC_V3
+	select HAVE_ARM_ARCH_TIMER
+	select SPARSE_IRQ
+	select BRCMSTB_L2_IRQ
+	select BCM7120_L2_IRQ
+	select ARCH_HAS_HOLES_MEMORYMODEL
+	select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE
+	select ZONE_DMA if ARM_LPAE
+	select NEED_MACH_MEMORY_H
+	help
+	  Say Y if you intend to run the kernel on a Broadcom ARM-based STB
+	  chipset.
+
+	  This enables support for Broadcom ARM-based set-top box chipsets,
+	  including the 7445 family of chips.
+
 endchoice
 
 menu "Multiple platform selection"
arch/arm/configs/brcmstb_defconfig new file +204 -0

204 lines not on this page · raw message

arch/arm/configs/multi_v7_defconfig +0 -3
index fc33444..33c91f8 100644
@@ -17,7 +17,6 @@ CONFIG_ARCH_AT91=y
 CONFIG_SOC_SAMA5D2=y
 CONFIG_SOC_SAMA5D3=y
 CONFIG_SOC_SAMA5D4=y
-CONFIG_ARCH_BCM=y
 CONFIG_ARCH_BCM_CYGNUS=y
 CONFIG_ARCH_BCM_HR2=y
 CONFIG_ARCH_BCM_NSP=y
@@ -26,7 +25,6 @@ CONFIG_ARCH_BCM_281XX=y
 CONFIG_ARCH_BCM_21664=y
 CONFIG_ARCH_BCM2835=y
 CONFIG_ARCH_BCM_63XX=y
-CONFIG_ARCH_BRCMSTB=y
 CONFIG_ARCH_BERLIN=y
 CONFIG_MACH_BERLIN_BG2=y
 CONFIG_MACH_BERLIN_BG2CD=y
@@ -229,7 +227,6 @@ CONFIG_B53_MMAP_DRIVER=m
 CONFIG_B53_SRAB_DRIVER=m
 CONFIG_NET_DSA_BCM_SF2=m
 CONFIG_SUN4I_EMAC=y
-CONFIG_BCMGENET=m
 CONFIG_BGMAC_BCMA=y
 CONFIG_SYSTEMPORT=m
 CONFIG_MACB=y
arch/arm/mach-bcm/Kconfig +1 -20
index 25aac6e..2c3ad42 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 menuconfig ARCH_BCM
 	bool "Broadcom SoC Support"
-	depends on ARCH_MULTI_V6_V7
+	depends on ARCH_BRCMSTB
 	help
 	  This enables support for Broadcom ARM based SoC chips
 
@@ -203,23 +203,4 @@ config ARCH_BCM_63XX
 	  It currently supports the 'BCM63XX' ARM-based family, which includes
 	  the BCM63138 variant.
 
-config ARCH_BRCMSTB
-	bool "Broadcom BCM7XXX based boards"
-	depends on ARCH_MULTI_V7
-	select ARM_GIC
-	select ARM_ERRATA_798181 if SMP
-	select HAVE_ARM_ARCH_TIMER
-	select BRCMSTB_L2_IRQ
-	select BCM7120_L2_IRQ
-	select ARCH_HAS_HOLES_MEMORYMODEL
-	select ZONE_DMA if ARM_LPAE
-	select SOC_BRCMSTB
-	select SOC_BUS
-	help
-	  Say Y if you intend to run the kernel on a Broadcom ARM-based STB
-	  chipset.
-
-	  This enables support for Broadcom ARM-based set-top box chipsets,
-	  including the 7445 family of chips.
-
 endif
arch/arm/mach-bcm/Makefile.boot new file +0 -0
new file mode 100644
index 0000000..e69de29
arch/arm/mach-bcm/include/mach/irqs.h new file +3 -0
new file mode 100644
index 0000000..f1f3f22
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#define NR_IRQS NR_IRQS_LEGACY
arch/arm/mach-bcm/include/mach/memory.h new file +47 -0

47 lines not on this page · raw message

arch/arm/mach-bcm/include/mach/uncompress.h new file +8 -0
new file mode 100644
index 0000000..b297333
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifdef CONFIG_DEBUG_UNCOMPRESS
+void putc(int c);
+#else
+static inline void putc(int c) {}
+#endif
+static inline void flush(void) {}
+static inline void arch_decomp_setup(void) {}
Signature · 1 line
1.9.0.138.g2de3478
#34 lore raw
In reply to Jim Quinlan
Quoted 3 lines · Jim Quinlan

This patch series adds support for the Broadcom Settopbox PCIe host controller. It is targeted to Broadcom Settopbox chips running on ARM, ARM64, and MIPS platforms.

Whatever happened with this series? I saw some discussion that suggests it's not quite ready to be merged, but there's a lot of good work here, so I hope it can get finished up.

Bjorn

#35 lore raw
Quoted 8 lines · Bjorn Helgaas
Quoted 3 lines · Jim Quinlan

This patch series adds support for the Broadcom Settopbox PCIe host controller. It is targeted to Broadcom Settopbox chips running on ARM, ARM64, and MIPS platforms.

Whatever happened with this series? I saw some discussion that suggests it's not quite ready to be merged, but there's a lot of good work here, so I hope it can get finished up.

Thanks, these are encouraging words! We've been side tracked with a number of things but it is still planned to get this included upstream sooner rather than later. I am not sure how we will approach the mangling of DMA addresses to fit the PCIe's quirky address map, but hopefully with Christoph's latest chunk of work, there is even less to be done by drivers.

Signature · 1 line
Florian