Adding support for Versal CPM as Root Port driver.
Subsystems (5)
v4 cover Adding support for Versal CPM as Root Port driver.
- Add support for Versal CPM as Root port.
- The Versal ACAP devices include CCIX-PCIe Module (CPM). The integrated block for CPM along with the integrated bridge can function as PCIe Root Port.
- Versal CPM uses GICv3 ITS feature for assigning MSI/MSI-X vectors and handling MSI/MSI-X interrupts.
- Bridge error and legacy interrupts in Versal CPM are handled using Versal CPM specific MISC interrupt line.
Bharat Kumar Gogada (2):
PCI: xilinx-cpm: Add device tree binding for Versal CPM host bridge.
PCI: xilinx-cpm: Add Versal CPM Root Port driver
.../devicetree/bindings/pci/xilinx-versal-cpm.txt | 66 +++ drivers/pci/controller/Kconfig | 8 + drivers/pci/controller/Makefile | 1 + drivers/pci/controller/pcie-xilinx-cpm.c | 506 +++++++++++++++++++++ 4 files changed, 581 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/xilinx-versal-cpm.txt create mode 100644 drivers/pci/controller/pcie-xilinx-cpm.c
Signature · 1 line
2.7.4
PATCH v4 1/2 PCI: xilinx-cpm: Add device tree binding for Versal CPM host bridge.
Add device tree binding documentation for Versal CPM Root Port driver.
--- .../devicetree/bindings/pci/xilinx-versal-cpm.txt | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/xilinx-versal-cpm.txt
Documentation/devicetree/bindings/pci/xilinx-versal-cpm.txt new file +66 -0
@@ -0,0 +1,66 @@ +* Xilinx Versal CPM DMA Root Port Bridge DT description + +Required properties: +- #address-cells: Address representation for root ports, set to <3> +- #size-cells: Size representation for root ports, set to <2> +- #interrupt-cells: specifies the number of cells needed to encode an + interrupt source. The value must be 1. +- compatible: Should contain "xlnx,versal-cpm-host-1.00" +- reg: Should contain configuration space (includes bridge registers) and + CPM system level control and status registers, and length +- reg-names: Must include the following entries: + "cfg": configuration space region and bridge registers + "cpm_slcr": CPM system level control and status registers +- interrupts: Should contain AXI PCIe interrupt +- interrupt-map-mask, + interrupt-map: standard PCI properties to define the mapping of the + PCI interface to interrupt numbers. +- ranges: ranges for the PCI memory regions (I/O space region is not + supported by hardware) + Please refer to the standard PCI bus binding document for a more + detailed explanation +- msi-map: Maps a Requester ID to an MSI controller and associated MSI + sideband data +- interrupt-names: Must include the following entries: + "misc": interrupt asserted when legacy or error interrupt is received + +Interrupt controller child node ++++++++++++++++++++++++++++++++ +Required properties: +- interrupt-controller: identifies the node as an interrupt controller +- #address-cells: specifies the number of cells needed to encode an + address. The value must be 0. +- #interrupt-cells: specifies the number of cells needed to encode an + interrupt source. The value must be 1. + + +Refer to the following binding document for more detailed description on +the use of 'msi-map': + Documentation/devicetree/bindings/pci/pci-msi.txt + +Example: + pci@fca10000 { + #address-cells = <3>; + #interrupt-cells = <1>; + #size-cells = <2>; + compatible = "xlnx,versal-cpm-host-1.00"; + interrupt-map = <0 0 0 1 &pcie_intc_0 1>, + <0 0 0 2 &pcie_intc_0 2>, + <0 0 0 3 &pcie_intc_0 3>, + <0 0 0 4 &pcie_intc_0 4>; + interrupt-map-mask = <0 0 0 7>; + interrupt-parent = <&gic>; + interrupt-names = "misc"; + interrupts = <0 72 4>; + ranges = <0x02000000 0x00000000 0xE0000000 0x0 0xE0000000 0x00000000 0x10000000>, + <0x43000000 0x00000080 0x00000000 0x00000080 0x00000000 0x00000000 0x80000000>; + msi-map = <0x0 &its_gic 0x0 0x10000>; + reg = <0x6 0x00000000 0x0 0x1000000>, + <0x0 0xFCA10000 0x0 0x1000>; + reg-names = "cfg", "cpm_slcr"; + pcie_intc_0: pci-interrupt-controller { + #address-cells = <0>; + #interrupt-cells = <1>; + interrupt-controller ; + }; + };
Signature · 1 line
2.7.4
PATCH v4 2/2 PCI: xilinx-cpm: Add Versal CPM Root Port driver
In reply to Bharat Kumar Gogada- Add support for Versal CPM as Root Port.
- The Versal ACAP devices include CCIX-PCIe Module (CPM). The integrated block for CPM along with the integrated bridge can function as PCIe Root Port.
- CPM Versal uses GICv3 ITS feature for achieving assigning MSI/MSI-X vectors and handling MSI/MSI-X interrupts.
- Bridge error and legacy interrupts in Versal CPM are handled using Versal CPM specific MISC interrupt line.
Changes v4:
- change commit subject.
- Remove unnecessary comments and type cast.
- Added comments for CPM block register access using readl/writel.
--- drivers/pci/controller/Kconfig | 8 + drivers/pci/controller/Makefile | 1 + drivers/pci/controller/pcie-xilinx-cpm.c | 506 +++++++++++++++++++++++++++++++ 3 files changed, 515 insertions(+) create mode 100644 drivers/pci/controller/pcie-xilinx-cpm.c
drivers/pci/controller/Kconfig +8 -0
@@ -81,6 +81,14 @@ config PCIE_XILINX Say 'Y' here if you want kernel to support the Xilinx AXI PCIe Host Bridge driver. +config PCIE_XILINX_CPM + bool "Xilinx Versal CPM host bridge support" + depends on ARCH_ZYNQMP || COMPILE_TEST + help + Say 'Y' here if you want kernel support for the + Xilinx Versal CPM host bridge. The driver supports + MSI/MSI-X interrupts using GICv3 ITS feature. + config PCI_XGENE bool "X-Gene PCIe controller" depends on ARM64 || COMPILE_TEST
drivers/pci/controller/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_PCI_HOST_COMMON) += pci-host-common.o obj-$(CONFIG_PCI_HOST_GENERIC) += pci-host-generic.o obj-$(CONFIG_PCIE_XILINX) += pcie-xilinx.o obj-$(CONFIG_PCIE_XILINX_NWL) += pcie-xilinx-nwl.o +obj-$(CONFIG_PCIE_XILINX_CPM) += pcie-xilinx-cpm.o obj-$(CONFIG_PCI_V3_SEMI) += pci-v3-semi.o obj-$(CONFIG_PCI_XGENE_MSI) += pci-xgene-msi.o obj-$(CONFIG_PCI_VERSATILE) += pci-versatile.o
drivers/pci/controller/pcie-xilinx-cpm.c new file +506 -0
506 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v4 2/2] PCI: xilinx-cpm: Add Versal CPM Root Port driver
Quoted 17 lines · Bharat Kumar Gogada
- Add support for Versal CPM as Root Port.
- The Versal ACAP devices include CCIX-PCIe Module (CPM). The integrated block for CPM along with the integrated bridge can function as PCIe Root Port.
- CPM Versal uses GICv3 ITS feature for achieving assigning MSI/MSI-X vectors and handling MSI/MSI-X interrupts.
- Bridge error and legacy interrupts in Versal CPM are handled using Versal CPM specific MISC interrupt line.Changes v4:
- change commit subject.
- Remove unnecessary comments and type cast.
- Added comments for CPM block register access using readl/writel.Signed-off-by Bharat Kumar Gogada <[email protected]>...
drivers/pci/controller/pcie-xilinx-cpm.c line 136
Quoted 8 lines
drivers/pci/controller/pcie-xilinx-cpm.c new file +8
-0+static bool xilinx_cpm_pcie_valid_device (struct pci_bus *bus, +unsigned int devfn) +{ +struct xilinx_cpm_pcie_port *port = bus->sysdata; + +/* Only one device down on each root port */ +if (bus->number == port->root_busno && devfn >0 ) +return false;
This whole *_valid_device() thing is a mess. We shouldn't need it at all. But if we *do* need it, I don't think you should check the entire devfn because that means you can't attach a multifunction device.
Several other drivers with similar *_valid_device() implementations check only PCI_SLOT():
dw_pcie_valid_device()
advk_pcie_valid_device()
pci_dw_valid_device()
altera_pcie_valid_device()
mobiveil_pcie_valid_device()
rockchip_pcie_valid_device()
Even checking just PCI_SLOT() is problematic because I think an ARI device with more than 8 functions will not work correctly.
What exactly happens if you omit this function, i.e., if we just go ahead and attempt config accesses when the device is not present? We *should* get something like an Unsupported Request completion, and that *should* be a recoverable error. Most hardware turns this error into read data of 0xffffffff. The OS should be able to figure out that there's no device there and continue with no ill effects.
Quoted 33 lines
drivers/pci/controller/pcie-xilinx-cpm.c new file +33
-0+return true; +} + +/** +* xilinx_cpm_pcie_map_bus - Get configuration base +* @bus: PCI Bus structure +* @devfn: Device/function +* @where: Offset from base +* +* Return: Base address of the configuration space needed to be +* accessed. +*/ +static void __iomem *xilinx_cpm_pcie_map_bus (struct pci_bus *bus, +unsigned int devfn,int where) +{ +struct xilinx_cpm_pcie_port *port = bus->sysdata; +int relbus; + +if (!xilinx_cpm_pcie_valid_device (bus, devfn)) +return NULL ; + + relbus = (bus->number <<ECAM_BUS_NUM_SHIFT ) | + (devfn <<ECAM_DEV_NUM_SHIFT ); + +return port->reg_base + relbus + where; +} + +/* PCIe operations */ +static struct pci_ops xilinx_cpm_pcie_ops = { + .map_bus = xilinx_cpm_pcie_map_bus, + .read = pci_generic_config_read, + .write = pci_generic_config_write, +};
RE: [PATCH v4 2/2] PCI: xilinx-cpm: Add Versal CPM Root Port driver
Quoted 46 lines
Subject: Re: [PATCH v4 2/2] PCI: xilinx-cpm: Add Versal CPM Root Port driver
Quoted 17 lines · Bharat Kumar Gogada
- Add support for Versal CPM as Root Port.
- The Versal ACAP devices include CCIX-PCIe Module (CPM). The integrated block for CPM along with the integrated bridge can function as PCIe Root Port.
- CPM Versal uses GICv3 ITS feature for achieving assigning MSI/MSI-X vectors and handling MSI/MSI-X interrupts.
- Bridge error and legacy interrupts in Versal CPM are handled using Versal CPM specific MISC interrupt line.Changes v4:
- change commit subject.
- Remove unnecessary comments and type cast.
- Added comments for CPM block register access using readl/writel.Signed-off-by Bharat Kumar Gogada <[email protected]>...
drivers/pci/controller/pcie-xilinx-cpm.c line 136
Quoted 8 lines
drivers/pci/controller/pcie-xilinx-cpm.c new file +8
-0+static bool xilinx_cpm_pcie_valid_device (struct pci_bus *bus, +unsigned int devfn) +{ +struct xilinx_cpm_pcie_port *port = bus->sysdata; + +/* Only one device down on each root port */ +if (bus->number == port->root_busno && devfn >0 ) +return false;This whole
*_valid_device()thing is a mess. We shouldn't need it at all. But if we *do* need it, I don't think you should check the entire devfn because that means you can't attach a multifunction device.Several other drivers with similar
*_valid_device()implementations check onlyPCI_SLOT():
dw_pcie_valid_device()
advk_pcie_valid_device()
pci_dw_valid_device()
altera_pcie_valid_device()
mobiveil_pcie_valid_device()
rockchip_pcie_valid_device()Even checking just
PCI_SLOT()is problematic because I think an ARI device with more than 8 functions will not work correctly.
Quoted 7 lines
What exactly happens if you omit this function, i.e., if we just go ahead and attempt config accesses when the device is not present? We *should* get something like an Unsupported Request completion, and that *should* be a recoverable error. Most hardware turns this error into read data of
0xffffffff. The OS should be able to figure out that there's no device there and continue with no ill effects.
Thanks Bjorn. I did test and I do not see any issue without this. Will resend patch with this change.
Quoted 23 lines
Quoted 23 lines
drivers/pci/controller/pcie-xilinx-cpm.c new file +23
-0+return true; +} + +/** +* xilinx_cpm_pcie_map_bus - Get configuration base +* @bus: PCI Bus structure +* @devfn: Device/function +* @where: Offset from base +* +* Return: Base address of the configuration space needed to be +* accessed. +*/ +static void __iomem *xilinx_cpm_pcie_map_bus (struct pci_bus *bus, +unsigned int devfn,int where) { +struct xilinx_cpm_pcie_port *port = bus->sysdata; +int relbus; + +if (!xilinx_cpm_pcie_valid_device (bus, devfn)) +return NULL ; + + relbus = (bus->number <<ECAM_BUS_NUM_SHIFT ) | + (devfn <<ECAM_DEV_NUM_SHIFT ); +
Quoted 8 lines
drivers/pci/controller/pcie-xilinx-cpm.c line 170
Quoted 8 lines
drivers/pci/controller/pcie-xilinx-cpm.c new file +8
-0+return port->reg_base + relbus + where; } + +/* PCIe operations */ +static struct pci_ops xilinx_cpm_pcie_ops = { + .map_bus = xilinx_cpm_pcie_map_bus, + .read = pci_generic_config_read, + .write = pci_generic_config_write, +};
Regards,
bharat
Re: [PATCH v4 2/2] PCI: xilinx-cpm: Add Versal CPM Root Port driver
Quoted 53 lines · Bharat Kumar Gogada
Quoted 46 lines
Subject: Re: [PATCH v4 2/2] PCI: xilinx-cpm: Add Versal CPM Root Port driver
Quoted 17 lines · Bharat Kumar Gogada
- Add support for Versal CPM as Root Port.
- The Versal ACAP devices include CCIX-PCIe Module (CPM). The integrated block for CPM along with the integrated bridge can function as PCIe Root Port.
- CPM Versal uses GICv3 ITS feature for achieving assigning MSI/MSI-X vectors and handling MSI/MSI-X interrupts.
- Bridge error and legacy interrupts in Versal CPM are handled using Versal CPM specific MISC interrupt line.Changes v4:
- change commit subject.
- Remove unnecessary comments and type cast.
- Added comments for CPM block register access using readl/writel.Signed-off-by Bharat Kumar Gogada <[email protected]>...
drivers/pci/controller/pcie-xilinx-cpm.c line 136
Quoted 8 lines
drivers/pci/controller/pcie-xilinx-cpm.c new file +8
-0+static bool xilinx_cpm_pcie_valid_device (struct pci_bus *bus, +unsigned int devfn) +{ +struct xilinx_cpm_pcie_port *port = bus->sysdata; + +/* Only one device down on each root port */ +if (bus->number == port->root_busno && devfn >0 ) +return false;This whole
*_valid_device()thing is a mess. We shouldn't need it at all. But if we *do* need it, I don't think you should check the entire devfn because that means you can't attach a multifunction device.Several other drivers with similar
*_valid_device()implementations check onlyPCI_SLOT():
dw_pcie_valid_device()
advk_pcie_valid_device()
pci_dw_valid_device()
altera_pcie_valid_device()
mobiveil_pcie_valid_device()
rockchip_pcie_valid_device()Even checking just
PCI_SLOT()is problematic because I think an ARI device with more than 8 functions will not work correctly.Quoted 7 lines
What exactly happens if you omit this function, i.e., if we just go ahead and attempt config accesses when the device is not present? We *should* get something like an Unsupported Request completion, and that *should* be a recoverable error. Most hardware turns this error into read data of
0xffffffff. The OS should be able to figure out that there's no device there and continue with no ill effects.
Quoted 2 lines
Thanks Bjorn. I did test and I do not see any issue without this. Will resend patch with this change.
That's great, thanks for testing that! I wonder how many other drivers could just drop that code.
Bjorn
Quoted 9 lines · Bharat Kumar Gogada
- Add support for Versal CPM as Root port.
- The Versal ACAP devices include CCIX-PCIe Module (CPM). The integrated block for CPM along with the integrated bridge can function as PCIe Root Port.
- Versal CPM uses GICv3 ITS feature for assigning MSI/MSI-X vectors and handling MSI/MSI-X interrupts.
- Bridge error and legacy interrupts in Versal CPM are handled using Versal CPM specific MISC interrupt line.
Quoted 3 lines
Bharat Kumar Gogada (2):
PCI: xilinx-cpm: Add device tree binding for Versal CPM host bridge.
PCI: xilinx-cpm: Add Versal CPM Root Port driver
Nit for next time: Omit the period at the end of the subject. No need to repost just for that.
Quoted 11 lines
.../devicetree/bindings/pci/xilinx-versal-cpm.txt | 66 +++ drivers/pci/controller/Kconfig | 8 + drivers/pci/controller/Makefile | 1 + drivers/pci/controller/pcie-xilinx-cpm.c | 506 +++++++++++++++++++++ 4 files changed, 581 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/xilinx-versal-cpm.txt create mode 100644 drivers/pci/controller/pcie-xilinx-cpm.cSignature · 1 line
2.7.4