Implement NTB Controller using multiple PCI EP
Subsystems (8)
cover Implement NTB Controller using multiple PCI EP
This series is about implementing SW defined NTB using multiple endpoint instances. This series has been tested using 2 endpoint instances in J7 connected to two DRA7 boards. However there is nothing platform specific for the NTB functionality.
This was presented in Linux Plumbers Conference. The presentation can be found @ [1]
RFC patch series can be found @ [2]
This series has been validated after applying [3] and [4]
Changes from RFC:
1) Converted the DT binding patches to YAML schema and merged the DT binding patches together
2) NTB documentation is converted to .rst
3) One HOST can now interrupt the other HOST using MSI-X interrupts
4) Added support for teardown of memory window and doorbell configuration
5) Add support to provide support 64-bit memory window size from DT
[1] -> https://www.linuxplumbersconf.org/event/4/contributions/395/attachments/284/481/Implementing_NTB_Controller_Using_PCIe_Endpoint_-_final.pdf
[2] -> http://lore.kernel.org/r/[email protected]
[3] -> http://lore.kernel.org/r/[email protected]
[4] -> http://lore.kernel.org/r/[email protected]
Kishon Vijay Abraham I (19):
dt-bindings: PCI: Endpoint: Add DT bindings for PCI EPF NTB Device
Documentation: PCI: Add specification for the *PCI NTB* function
device
PCI: endpoint: Add API to get reference to EPC from device-tree
PCI: endpoint: Add API to create EPF device from device tree
PCI: endpoint: Add "pci-epf-bus" driver
PCI: endpoint: Make *_get_first_free_bar() take into account 64 bit
BAR
PCI: endpoint: Add helper API to get the 'next' unreserved BAR
PCI: endpoint: Make *_free_bar() to return error codes on failure
PCI: endpoint: Remove unused pci_epf_match_device()
PCI: endpoint: Make pci_epf_driver ops optional
PCI: endpoint: Add helper API to populate header with values from DT
PCI: endpoint: Add support to associate secondary EPC with EPF
PCI: endpoint: Add pci_epc_ops to map MSI irq
PCI: cadence: Implement ->msi_map_irq() ops
PCI: endpoint: Add EP function driver to provide NTB functionality
PCI: Add TI J721E device to pci ids
NTB: Add support for EPF PCI-Express Non-Transparent Bridge
NTB: tool: Enable the NTB/PCIe link on the local or remote side of
bridge
NTB: ntb_perf/ntb_tool: Use PCI device for dma_alloc_coherent()
Documentation/PCI/endpoint/index.rst | 1 + Documentation/PCI/endpoint/pci-test-ntb.rst | 344 +++ .../bindings/pci/endpoint/pci-epf-bus.yaml | 42 + .../bindings/pci/endpoint/pci-epf-device.yaml | 69 + .../bindings/pci/endpoint/pci-epf-ntb.yaml | 68 + drivers/misc/pci_endpoint_test.c | 1 - drivers/ntb/hw/Kconfig | 1 + drivers/ntb/hw/Makefile | 1 + drivers/ntb/hw/epf/Kconfig | 5 + drivers/ntb/hw/epf/Makefile | 1 + drivers/ntb/hw/epf/ntb_hw_epf.c | 752 ++++++ drivers/ntb/test/ntb_perf.c | 3 +- drivers/ntb/test/ntb_tool.c | 4 +- .../pci/controller/cadence/pcie-cadence-ep.c | 50 + drivers/pci/endpoint/Makefile | 3 +- drivers/pci/endpoint/functions/Kconfig | 12 + drivers/pci/endpoint/functions/Makefile | 1 + drivers/pci/endpoint/functions/pci-epf-ntb.c | 2038 +++++++++++++++++ drivers/pci/endpoint/functions/pci-epf-test.c | 13 +- drivers/pci/endpoint/pci-ep-cfs.c | 6 +- drivers/pci/endpoint/pci-epc-core.c | 216 +- drivers/pci/endpoint/pci-epf-bus.c | 54 + drivers/pci/endpoint/pci-epf-core.c | 137 +- include/linux/pci-epc.h | 43 +- include/linux/pci-epf.h | 26 +- include/linux/pci_ids.h | 1 + 26 files changed, 3823 insertions(+), 69 deletions(-) create mode 100644 Documentation/PCI/endpoint/pci-test-ntb.rst create mode 100644 Documentation/devicetree/bindings/pci/endpoint/pci-epf-bus.yaml create mode 100644 Documentation/devicetree/bindings/pci/endpoint/pci-epf-device.yaml create mode 100644 Documentation/devicetree/bindings/pci/endpoint/pci-epf-ntb.yaml create mode 100644 drivers/ntb/hw/epf/Kconfig create mode 100644 drivers/ntb/hw/epf/Makefile create mode 100644 drivers/ntb/hw/epf/ntb_hw_epf.c create mode 100644 drivers/pci/endpoint/functions/pci-epf-ntb.c create mode 100644 drivers/pci/endpoint/pci-epf-bus.c
Signature · 1 line
2.17.1
PATCH 1/19 dt-bindings: PCI: Endpoint: Add DT bindings for PCI EPF NTB Device
Add device tree schema for PCI endpoint function bus to which endpoint function devices should be attached. Then add device tree schema for PCI endpoint function device to include bindings thats generic to all endpoint functions. Finally add device tree schema for PCI endpoint NTB function device by including the generic device tree schema for PCIe endpoint function.
--- .../bindings/pci/endpoint/pci-epf-bus.yaml | 42 +++++++++++ .../bindings/pci/endpoint/pci-epf-device.yaml | 69 +++++++++++++++++++ .../bindings/pci/endpoint/pci-epf-ntb.yaml | 68 ++++++++++++++++++ 3 files changed, 179 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/endpoint/pci-epf-bus.yaml create mode 100644 Documentation/devicetree/bindings/pci/endpoint/pci-epf-device.yaml create mode 100644 Documentation/devicetree/bindings/pci/endpoint/pci-epf-ntb.yaml
Documentation/devicetree/bindings/pci/endpoint/pci-epf-bus.yaml new file +42 -0
@@ -0,0 +1,42 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/endpoint/pci-epf-bus.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: PCI Endpoint Function Bus + +maintainers: + - Kishon Vijay Abraham I <[email protected]> + +properties: + compatible: + const: pci-epf-bus + +patternProperties: + "^func@[0-9a-f]+$": + type: object + description: | + PCI Endpoint Function Bus node should have subnodes for each of + the implemented endpoint function. It should follow the bindings + specified for endpoint function in + Documentation/devicetree/bindings/pci/endpoint/ + +examples: + - | + epf_bus { + compatible = "pci-epf-bus"; + + func@0 { + compatible = "pci-epf-ntb"; + epcs = <&pcie0_ep>, <&pcie1_ep>; + epc-names = "primary", "secondary"; + reg = <0>; + epf,vendor-id = /bits/ 16 <0x104c>; + epf,device-id = /bits/ 16 <0xb00d>; + num-mws = <4>; + mws-size = <0x0 0x100000>, <0x0 0x100000>, <0x0 0x100000>, <0x0 0x100000>; + }; + }; +...
Documentation/devicetree/bindings/pci/endpoint/pci-epf-device.yaml new file +69 -0
69 lines not on this page · raw message
Documentation/devicetree/bindings/pci/endpoint/pci-epf-ntb.yaml new file +68 -0
68 lines not on this page · raw message
Signature · 1 line
2.17.1
Rob Herring
maintainerRe: [PATCH 01/19] dt-bindings: PCI: Endpoint: Add DT bindings for PCI EPF NTB Device
Quoted 8 lines · Kishon Vijay Abraham I
Add device tree schema for PCI endpoint function bus to which endpoint function devices should be attached. Then add device tree schema for PCI endpoint function device to include bindings thats generic to all endpoint functions. Finally add device tree schema for PCI endpoint NTB function device by including the generic device tree schema for PCIe endpoint function.
Signed-off-by Kishon Vijay Abraham I <[email protected]>
Quoted 9 lines
--- .../bindings/pci/endpoint/pci-epf-bus.yaml | 42 +++++++++++ .../bindings/pci/endpoint/pci-epf-device.yaml | 69 +++++++++++++++++++ .../bindings/pci/endpoint/pci-epf-ntb.yaml | 68 ++++++++++++++++++ 3 files changed, 179 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/endpoint/pci-epf-bus.yaml create mode 100644 Documentation/devicetree/bindings/pci/endpoint/pci-epf-device.yaml create mode 100644 Documentation/devicetree/bindings/pci/endpoint/pci-epf-ntb.yaml
My bot found errors running 'make dt_binding_check' on your patch:
Traceback (most recent call last):
File "/usr/local/bin/dt-doc-validate", line 64, in <module>
ret = check_doc(args.yamldt)
File "/usr/local/bin/dt-doc-validate", line 25, in check_doc
testtree = dtschema.load(filename, line_number=line_number, duplicate_keys=False)
File "/usr/local/lib/python3.6/dist-packages/dtschema/lib.py", line 592, in load
return yaml.load(f.read())
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/main.py", line 343, in load
return constructor.get_single_data()
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/constructor.py", line 113, in get_single_data
return self.construct_document(node)
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/constructor.py", line 123, in construct_document
for _dummy in generator:
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/constructor.py", line 723, in construct_yaml_map
value = self.construct_mapping(node)
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/constructor.py", line 440, in construct_mapping
return BaseConstructor.construct_mapping(self, node, deep=deep)
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/constructor.py", line 257, in construct_mapping
if self.check_mapping_key(node, key_node, mapping, key, value):
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/constructor.py", line 295, in check_mapping_key
raise DuplicateKeyError(*args)
ruamel.yaml.constructor.DuplicateKeyError: while constructing a mapping
in "<unicode string>", line 5, column 1
found duplicate key "properties" with value "{}" (original value: "{}")
in "<unicode string>", line 17, column 1
To suppress this check see:
http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys
Duplicate keys will become an error in future releases, and are errors by default when using the new API.
Documentation/devicetree/bindings/Makefile:12: recipe for target 'Documentation/devicetree/bindings/pci/endpoint/pci-epf-device.example.dts' failed make[1]: *** [Documentation/devicetree/bindings/pci/endpoint/pci-epf-device.example.dts] Error 1
make[1]: *** Waiting for unfinished jobs....Documentation/devicetree/bindings/pci/endpoint/pci-epf-ntb.yaml: while constructing a mapping
in "<unicode string>", line 5, column 1
found duplicate key "properties" with value "{}" (original value: "{}")
in "<unicode string>", line 17, column 1
To suppress this check see:
http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys
Duplicate keys will become an error in future releases, and are errors by default when using the new API.
Traceback (most recent call last):
File "/usr/local/bin/dt-mk-schema", line 34, in <module>
schemas = dtschema.process_schemas(args.schemas, core_schema=(not args.useronly))
File "/usr/local/lib/python3.6/dist-packages/dtschema/lib.py", line 554, in process_schemas
sch = process_schema(os.path.abspath(filename))
File "/usr/local/lib/python3.6/dist-packages/dtschema/lib.py", line 507, in process_schema
schema = load_schema(filename)
File "/usr/local/lib/python3.6/dist-packages/dtschema/lib.py", line 123, in load_schema
return do_load(os.path.join(schema_basedir, schema))
File "/usr/local/lib/python3.6/dist-packages/dtschema/lib.py", line 108, in do_load
return yaml.load(tmp)
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/main.py", line 343, in load
return constructor.get_single_data()
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/constructor.py", line 113, in get_single_data
return self.construct_document(node)
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/constructor.py", line 123, in construct_document
for _dummy in generator:
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/constructor.py", line 723, in construct_yaml_map
value = self.construct_mapping(node)
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/constructor.py", line 440, in construct_mapping
return BaseConstructor.construct_mapping(self, node, deep=deep)
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/constructor.py", line 257, in construct_mapping
if self.check_mapping_key(node, key_node, mapping, key, value):
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/constructor.py", line 295, in check_mapping_key
raise DuplicateKeyError(*args)
ruamel.yaml.constructor.DuplicateKeyError: while constructing a mapping
in "<unicode string>", line 5, column 1
found duplicate key "properties" with value "{}" (original value: "{}")
in "<unicode string>", line 17, column 1
To suppress this check see:
http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys
Duplicate keys will become an error in future releases, and are errors by default when using the new API.
Documentation/devicetree/bindings/Makefile:41: recipe for target 'Documentation/devicetree/bindings/processed-schema-examples.yaml' failed make[1]: *** [Documentation/devicetree/bindings/processed-schema-examples.yaml] Error 123
make[1]: *** Deleting file 'Documentation/devicetree/bindings/processed-schema-examples.yaml'
Traceback (most recent call last):
File "/usr/local/bin/dt-mk-schema", line 34, in <module>
schemas = dtschema.process_schemas(args.schemas, core_schema=(not args.useronly))
File "/usr/local/lib/python3.6/dist-packages/dtschema/lib.py", line 554, in process_schemas
sch = process_schema(os.path.abspath(filename))
File "/usr/local/lib/python3.6/dist-packages/dtschema/lib.py", line 507, in process_schema
schema = load_schema(filename)
File "/usr/local/lib/python3.6/dist-packages/dtschema/lib.py", line 123, in load_schema
return do_load(os.path.join(schema_basedir, schema))
File "/usr/local/lib/python3.6/dist-packages/dtschema/lib.py", line 108, in do_load
return yaml.load(tmp)
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/main.py", line 343, in load
return constructor.get_single_data()
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/constructor.py", line 113, in get_single_data
return self.construct_document(node)
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/constructor.py", line 123, in construct_document
for _dummy in generator:
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/constructor.py", line 723, in construct_yaml_map
value = self.construct_mapping(node)
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/constructor.py", line 440, in construct_mapping
return BaseConstructor.construct_mapping(self, node, deep=deep)
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/constructor.py", line 257, in construct_mapping
if self.check_mapping_key(node, key_node, mapping, key, value):
File "/usr/local/lib/python3.6/dist-packages/ruamel/yaml/constructor.py", line 295, in check_mapping_key
raise DuplicateKeyError(*args)
ruamel.yaml.constructor.DuplicateKeyError: while constructing a mapping
in "<unicode string>", line 5, column 1
found duplicate key "properties" with value "{}" (original value: "{}")
in "<unicode string>", line 17, column 1
To suppress this check see:
http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys
Duplicate keys will become an error in future releases, and are errors by default when using the new API.
Documentation/devicetree/bindings/Makefile:45: recipe for target 'Documentation/devicetree/bindings/processed-schema.yaml' failed make[1]: *** [Documentation/devicetree/bindings/processed-schema.yaml] Error 123
make[1]: *** Deleting file 'Documentation/devicetree/bindings/processed-schema.yaml'
Makefile:1300: recipe for target 'dt_binding_check' failed
make: *** [dt_binding_check] Error 2
See https://patchwork.ozlabs.org/patch/1290443
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure dt-schema is up to date:
pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade
Please check and re-submit.
Re: [PATCH 01/19] dt-bindings: PCI: Endpoint: Add DT bindings for PCI EPF NTB Device
In reply to Kishon Vijay Abraham IHi RobH,
Quoted 48 lines · Kishon Vijay Abraham I
Add device tree schema for PCI endpoint function bus to which endpoint function devices should be attached. Then add device tree schema for PCI endpoint function device to include bindings thats generic to all endpoint functions. Finally add device tree schema for PCI endpoint NTB function device by including the generic device tree schema for PCIe endpoint function.
Signed-off-by Kishon Vijay Abraham I <[email protected]>--- .../bindings/pci/endpoint/pci-epf-bus.yaml | 42 +++++++++++ .../bindings/pci/endpoint/pci-epf-device.yaml | 69 +++++++++++++++++++ .../bindings/pci/endpoint/pci-epf-ntb.yaml | 68 ++++++++++++++++++ 3 files changed, 179 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/endpoint/pci-epf-bus.yaml create mode 100644 Documentation/devicetree/bindings/pci/endpoint/pci-epf-device.yaml create mode 100644 Documentation/devicetree/bindings/pci/endpoint/pci-epf-ntb.yamlDocumentation/devicetree/bindings/pci/endpoint/pci-epf-bus.yaml new file +25
-0@@ -0,0 +1,42 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/endpoint/pci-epf-bus.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: PCI Endpoint Function Bus + +maintainers: + - Kishon Vijay Abraham I <[email protected]> + +properties: + compatible: + const: pci-epf-bus + +patternProperties: + "^func@[0-9a-f]+$": + type: object + description: | + PCI Endpoint Function Bus node should have subnodes for each of + the implemented endpoint function. It should follow the bindings + specified for endpoint function in + Documentation/devicetree/bindings/pci/endpoint/ +
Documentation/devicetree/bindings/pci/endpoint/pci-epf-bus.yaml line 35
Quoted 10 lines
Documentation/devicetree/bindings/pci/endpoint/pci-epf-bus.yaml new file +10
-0+examples: + - | + epf_bus { + compatible = "pci-epf-bus"; + + func@0 { + compatible = "pci-epf-ntb"; + epcs = <&pcie0_ep>, <&pcie1_ep>; + epc-names = "primary", "secondary"; + reg = <0>;
I'm not sure how to represent "reg" property properly for cases like this where it represents ID and not a memory resource. I seem to get warning for "reg_format" even after adding address-cells and size-cells property in epf_bus. Can you give some hints here please?
Documentation/devicetree/bindings/pci/endpoint/pci-epf-bus.yaml line 36
Quoted 1 line
Documentation/devicetree/bindings/pci/endpoint/pci-epf-bus.yaml new file +1
-0+ epf,vendor-id = /bits/ 16 <0x104c>;
I want to make vendor-id and device-id as 16 bits from the beginning at-least for PCIe endpoint. So I'm prefixing these properties with "epf,". However I get this "do not match any of the regexes:". Can we add "epf" as a standard prefix?
Thanks
Kishon
Quoted 156 lines
Documentation/devicetree/bindings/pci/endpoint/pci-epf-bus.yaml new file +6
-0+ epf,device-id = /bits/ 16 <0xb00d>; + num-mws = <4>; + mws-size = <0x0 0x100000>, <0x0 0x100000>, <0x0 0x100000>, <0x0 0x100000>; + }; + }; +...Documentation/devicetree/bindings/pci/endpoint/pci-epf-device.yaml new file +69
-0@@ -0,0 +1,69 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/endpoint/pci-epf-device.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: PCI Endpoint Function Device + +maintainers: + - Kishon Vijay Abraham I <[email protected]> + +properties: + compatible: + const: pci-epf-bus + +properties: + $nodename: + pattern: "^func@" + + epcs: + description: + Phandle to the endpoint controller device. Should have "2" entries for + NTB endpoint function and "1" entry for others. + minItems: 1 + maxItems: 2 + + epc-names: + description: + Must contain an entry for each entry in "epcs" when "epcs" have more than + one entry. + + reg: + maxItems: 0 + description: Must contain the index number of the function. + + epf,vendor-id: + description: + The PCI vendor ID + allOf: + - $ref: /schemas/types.yaml#/definitions/uint16 + + epf,device-id: + description: + The PCI device ID + allOf: + - $ref: /schemas/types.yaml#/definitions/uint16 + + epf,baseclass-code: + description: Code to classify the type of operation the function performs + allOf: + - $ref: /schemas/types.yaml#/definitions/uint8 + + epf,subclass-code: + description: + Specifies a base class sub-class, which identifies more specifically the + operation of the Function + allOf: + - $ref: /schemas/types.yaml#/definitions/uint8 + + epf,subsys-vendor-id: + description: Code to identify vendor of the add-in card or subsystem + allOf: + - $ref: /schemas/types.yaml#/definitions/uint16 + + epf,subsys-id: + description: Code to specify an id that is specific to a vendor + allOf: + - $ref: /schemas/types.yaml#/definitions/uint16Documentation/devicetree/bindings/pci/endpoint/pci-epf-ntb.yaml new file +68
-0@@ -0,0 +1,68 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/endpoint/pci-epf-ntb.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: PCI Endpoint NTB Function Device + +maintainers: + - Kishon Vijay Abraham I <[email protected]> + +allOf: + - $ref: "pci-epf-device.yaml#" + +properties: + compatible: + const: pci-epf-ntb + + epcs: + minItems: 2 + maxItems: 2 + + epc-names: + items: + - const: primary + - const: secondary + + num-mws: + description: + Specify the number of memory windows + allOf: + - $ref: /schemas/types.yaml#/definitions/uint8 + minimum: 1 + maximum: 4 + + mws-size: + description: + List of 'num-mws' entries containing size of each memory window. + minItems: 1 + maxItems: 4 + +required: + - compatible + - epcs + - epc-names + - epf,vendor-id + - epf,device-id + - num-mws + - mws-size + +examples: + - | + epf_bus { + compatible = "pci-epf-bus"; + + func@0 { + compatible = "pci-epf-ntb"; + reg = <0>; + epcs = <&pcie0_ep>, <&pcie1_ep>; + epc-names = "primary", "secondary"; + epf,vendor-id = /bits/ 16 <0x104c>; + epf,device-id = /bits/ 16 <0xb00d>; + num-mws = <4>; + mws-size = <0x0 0x100000>, <0x0 0x100000>, <0x0 0x100000>, <0x0 0x100000>; + }; + }; +...
PATCH 2/19 Documentation: PCI: Add specification for the *PCI NTB* function device
In reply to Kishon Vijay Abraham IAdd specification for the *PCI NTB* function device. The endpoint function driver and the host PCI driver should be created based on this specification.
--- Documentation/PCI/endpoint/index.rst | 1 + Documentation/PCI/endpoint/pci-test-ntb.rst | 344 ++++++++++++++++++++ 2 files changed, 345 insertions(+) create mode 100644 Documentation/PCI/endpoint/pci-test-ntb.rst
Documentation/PCI/endpoint/index.rst +1 -0
@@ -11,3 +11,4 @@ PCI Endpoint Framework pci-endpoint-cfs pci-test-function pci-test-howto + pci-test-ntb
Documentation/PCI/endpoint/pci-test-ntb.rst new file +344 -0
344 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 3/19 PCI: endpoint: Add API to get reference to EPC from device-tree
In reply to Kishon Vijay Abraham IAdd of_pci_epc_get() and of_pci_epc_get_by_name() to get reference to EPC from device-tree. This is added in preparation to define an endpoint function device in device tree.
--- drivers/pci/endpoint/pci-epc-core.c | 61 +++++++++++++++++++++++++++++ include/linux/pci-epc.h | 3 ++ 2 files changed, 64 insertions(+)
drivers/pci/endpoint/pci-epc-core.c +61 -0
@@ -83,6 +83,66 @@ struct pci_epc *pci_epc_get(const char *epc_name) }EXPORT_SYMBOL_GPL (pci_epc_get); +/** +* of_pci_epc_get() - get PCI endpoint controller from device node and index +* @node: device node which contains the phandle to endpoint controller +* @index: index of the endpoint controller in "epcs" property +* +* Returns the EPC corresponding to the _index_ entry in "epcs" property +* present in device node, after getting a refcount to it or -ENODEV if +* there is no such EPC or -EPROBE_DEFER if there is a phandle to the phy, +* but the device is not yet loaded. +*/ +struct pci_epc *of_pci_epc_get (struct device_node *node,int index) +{ +struct device_node *epc_node; +struct class_dev_iter iter; +struct pci_epc *epc; +struct device *dev; + + epc_node =of_parse_phandle (node,"epcs" , index); +if (!epc_node) +return ERR_PTR (-ENODEV ); + +class_dev_iter_init (&iter, pci_epc_class,NULL ,NULL ); +while ((dev =class_dev_iter_next (&iter))) { + epc =to_pci_epc (dev); +if (epc_node != epc->dev.of_node) +continue ; + +of_node_put (epc_node); +class_dev_iter_exit (&iter); +get_device (&epc->dev); +return epc; + } + +of_node_put (epc_node); +class_dev_iter_exit (&iter); +return ERR_PTR (-EPROBE_DEFER ); +} +EXPORT_SYMBOL_GPL (of_pci_epc_get); + +/** +* of_pci_epc_get_by_name() - get PCI endpoint controller from device node +* and string +* @node: device node which contains the phandle to endpoint controller +* @epc_name: name of endpoint controller as present in "epc-names" property +* +* Returns the EPC corresponding to the epc_name in "epc-names" property +* present in device node. +*/ +struct pci_epc *of_pci_epc_get_by_name (struct device_node *node, +const char *epc_name) +{ +int index =0 ; + +if (epc_name) + index =of_property_match_string (node,"epc-names" , epc_name); + +return of_pci_epc_get (node, index); +} +EXPORT_SYMBOL_GPL (of_pci_epc_get_by_name); +/** * pci_epc_get_first_free_bar() - helper to get first unreserved BAR * @epc_features: pci_epc_features structure that holds the reserved bar bitmap
@@ -629,6 +689,7 @@ __pci_epc_create(struct device *dev, const struct pci_epc_ops *ops,device_initialize (&epc->dev); epc->dev.class = pci_epc_class; epc->dev.parent = dev; + epc->dev.of_node = dev->of_node; epc->ops = ops; ret =dev_set_name (&epc->dev,"%s" ,dev_name (dev));
include/linux/pci-epc.h +3 -0
@@ -211,6 +211,9 @@ int pci_epc_mem_init(struct pci_epc *epc, phys_addr_t base,int pci_epc_multi_mem_init (struct pci_epc *epc,struct pci_epc_mem_window *window,unsigned int num_windows); +struct pci_epc *of_pci_epc_get (struct device_node *node,int index); +struct pci_epc *of_pci_epc_get_by_name (struct device_node *node, +const char *epc_name);void pci_epc_mem_exit (struct pci_epc *epc);void __iomem *pci_epc_mem_alloc_addr (struct pci_epc *epc,phys_addr_t *phys_addr,size_t size);
Signature · 1 line
2.17.1
PATCH 4/19 PCI: endpoint: Add API to create EPF device from device tree
In reply to Kishon Vijay Abraham IAdd API to create EPF device from device tree and the device managed interface corresponding to it. This is added in order to define an endpoint function completely from device tree.
--- drivers/pci/endpoint/pci-epf-core.c | 68 +++++++++++++++++++++++++++++ include/linux/pci-epf.h | 6 +++ 2 files changed, 74 insertions(+)
drivers/pci/endpoint/pci-epf-core.c +68 -0
@@ -280,6 +280,73 @@ struct pci_epf *pci_epf_create(const char *name) }EXPORT_SYMBOL_GPL (pci_epf_create); +/** +* pci_epf_of_create() - create a new PCI EPF device from device tree node +* @node: the device node of the PCI EPF device. +* +* Invoke to create a new PCI EPF device by providing a device tree node +* with compatible property. +*/ +struct pci_epf *pci_epf_of_create (struct device_node *node) +{ +struct pci_epf *epf; +const char *compat; +int ret; + +of_node_get (node); + + ret =of_property_read_string (node,"compatible" , &compat); +if (ret) { +of_node_put (node); +return ERR_PTR (ret); + } + + epf =pci_epf_create (compat); +if (!IS_ERR (epf)) + epf->node = node; + +return epf; +} +EXPORT_SYMBOL_GPL (pci_epf_of_create); + +static void devm_epf_release (struct device *dev,void *res) +{ +struct pci_epf *epf = *(struct pci_epf **)res; + +pci_epf_destroy (epf); +} + +/** +* devm_pci_epf_of_create() - create a new PCI EPF device from device tree node +* @dev: device that is creating the new EPF +* @node: the device node of the PCI EPF device. +* +* Invoke to create a new PCI EPF device by providing a device tree node with +* compatible property. While at that, it also associates the device with the +* EPF using devres. On driver detach, release function is invoked on the devres +* data, where devres data is freed. +*/ +struct pci_epf *devm_pci_epf_of_create (struct device *dev, +struct device_node *node) +{ +struct pci_epf **ptr, *epf; + + ptr =devres_alloc (devm_epf_release,sizeof (*ptr),GFP_KERNEL ); +if (!ptr) +return ERR_PTR (-ENOMEM ); + + epf =pci_epf_of_create (node); +if (!IS_ERR (epf)) { + *ptr = epf; +devres_add (dev, ptr); + }else { +devres_free (ptr); + } + +return epf; +} +EXPORT_SYMBOL_GPL (devm_pci_epf_of_create); +const struct pci_epf_device_id *pci_epf_match_device (const struct pci_epf_device_id *id,struct pci_epf *epf) {
@@ -300,6 +367,7 @@ static void pci_epf_dev_release(struct device *dev) {struct pci_epf *epf =to_pci_epf (dev); +of_node_put (epf->node);kfree (epf->name);kfree (epf); }
include/linux/pci-epf.h +6 -0
@@ -11,6 +11,7 @@#include <linux/device.h> #include <linux/mod_devicetable.h> +#include <linux/of.h> #include <linux/pci.h> struct pci_epf ;
@@ -108,6 +109,7 @@ struct pci_epf_bar {/** * struct pci_epf - represents the PCI EPF device * @dev: the PCI EPF device +* @node: the device tree node of the PCI EPF device * @name: the name of the PCI EPF device * @header: represents standard configuration header * @bar: represents the BAR of EPF device
@@ -121,6 +123,7 @@ struct pci_epf_bar {*/ struct pci_epf {struct device dev; +struct device_node *node;const char *name;struct pci_epf_header *header;struct pci_epf_bar bar[6 ];
@@ -167,6 +170,9 @@ static inline void *epf_get_drvdata(struct pci_epf *epf)const struct pci_epf_device_id *pci_epf_match_device (const struct pci_epf_device_id *id,struct pci_epf *epf);struct pci_epf *pci_epf_create (const char *name); +struct pci_epf *pci_epf_of_create (struct device_node *node); +struct pci_epf *devm_pci_epf_of_create (struct device *dev, +struct device_node *node);void pci_epf_destroy (struct pci_epf *epf);int __pci_epf_register_driver (struct pci_epf_driver *driver,struct module *owner);
Signature · 1 line
2.17.1
PATCH 5/19 PCI: endpoint: Add "pci-epf-bus" driver
In reply to Kishon Vijay Abraham IAdd "pci-epf-bus" driver that helps to create EPF device from device tree. This is added in order to define an endpoint function device completely from device tree.
--- drivers/pci/endpoint/Makefile | 3 +- drivers/pci/endpoint/pci-epf-bus.c | 54 ++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 drivers/pci/endpoint/pci-epf-bus.c
drivers/pci/endpoint/Makefile +2 -1
@@ -5,4 +5,5 @@ obj-$(CONFIG_PCI_ENDPOINT_CONFIGFS) += pci-ep-cfs.o obj-$(CONFIG_PCI_ENDPOINT) += pci-epc-core.o pci-epf-core.o\ - pci-epc-mem.o functions/ + pci-epc-mem.o pci-epf-bus.o \ + functions/
drivers/pci/endpoint/pci-epf-bus.c new file +54 -0
54 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 6/19 PCI: endpoint: Make *_get_first_free_bar() take into account 64 bit BAR
In reply to Kishon Vijay Abraham Ipci_epc_get_first_free_bar() uses only "reserved_bar" member in epc_features to get the first unreserved BAR. However if the reserved BAR is also a 64-bit BAR, then the next BAR shouldn't be returned (since 64-bit BAR uses two BARs).
Make pci_epc_get_first_free_bar() take into account 64 bit BAR while returning the first free unreserved BAR.
--- drivers/pci/endpoint/pci-epc-core.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/pci/endpoint/pci-epc-core.c +10 -2
@@ -153,12 +153,20 @@ EXPORT_SYMBOL_GPL(of_pci_epc_get_by_name);unsigned int pci_epc_get_first_free_bar (const struct pci_epc_features *epc_features) { -int free_bar; +unsigned long free_bar;if (!epc_features)return 0 ; - free_bar =ffz (epc_features->reserved_bar); +/* Find if the reserved BAR is also a 64-bit BAR */ + free_bar = epc_features->reserved_bar & epc_features->bar_fixed_64bit; + +/* Set the adjacent bit if the reserved BAR is also a 64-bit BAR */ + free_bar <<=1 ; + free_bar |= epc_features->reserved_bar; + +/* Now find the free BAR */ + free_bar =ffz (free_bar);if (free_bar >5 )return 0 ;
Signature · 1 line
2.17.1
PATCH 7/19 PCI: endpoint: Add helper API to get the 'next' unreserved BAR
In reply to Kishon Vijay Abraham IAdd an API to get the next unreserved BAR starting from a given BAR number that can be used by the endpoint function.
--- drivers/pci/endpoint/pci-epc-core.c | 26 ++++++++++++++++++++++---- include/linux/pci-epc.h | 2 ++ 2 files changed, 24 insertions(+), 4 deletions(-)
drivers/pci/endpoint/pci-epc-core.c +22 -4
@@ -147,17 +147,36 @@ EXPORT_SYMBOL_GPL(of_pci_epc_get_by_name);* pci_epc_get_first_free_bar() - helper to get first unreserved BAR * @epc_features: pci_epc_features structure that holds the reserved bar bitmap * -* Invoke to get the first unreserved BAR that can be used for endpoint +* Invoke to get the first unreserved BAR that can be used by the endpoint * function. For any incorrect value in reserved_bar return '0'. */ unsigned int pci_epc_get_first_free_bar (const struct pci_epc_features *epc_features) +{ +return pci_epc_get_next_free_bar (epc_features,BAR_0 ); +} +EXPORT_SYMBOL_GPL (pci_epc_get_first_free_bar); + +/** +* pci_epc_get_next_free_bar() - helper to get unreserved BAR starting from @bar +* @epc_features: pci_epc_features structure that holds the reserved bar bitmap +* @bar: the starting BAR number from where unreserved BAR should be searched +* +* Invoke to get the next unreserved BAR starting from @bar that can be used +* for endpoint function. For any incorrect value in reserved_bar return '0'. +*/ +unsigned int pci_epc_get_next_free_bar (const struct pci_epc_features + *epc_features,enum pci_barno bar) {unsigned long free_bar;if (!epc_features)return 0 ; +/* If 'bar - 1' is a 64-bit BAR, move to the next BAR */ +if ((epc_features->bar_fixed_64bit <<1 ) &1 << bar) + bar++; +/* Find if the reserved BAR is also a 64-bit BAR */ free_bar = epc_features->reserved_bar & epc_features->bar_fixed_64bit;
@@ -165,14 +184,13 @@ unsigned int pci_epc_get_first_free_bar(const struct pci_epc_features free_bar <<=1 ; free_bar |= epc_features->reserved_bar; -/* Now find the free BAR */ - free_bar =ffz (free_bar); + free_bar =find_next_zero_bit (&free_bar,6 , bar);if (free_bar >5 )return 0 ;return free_bar; } -EXPORT_SYMBOL_GPL (pci_epc_get_first_free_bar); +EXPORT_SYMBOL_GPL (pci_epc_get_next_free_bar);/** * pci_epc_get_features() - get the features supported by EPC
include/linux/pci-epc.h +2 -0
@@ -203,6 +203,8 @@ const struct pci_epc_features *pci_epc_get_features(struct pci_epc *epc, u8 func_no);unsigned int pci_epc_get_first_free_bar (const struct pci_epc_features *epc_features); +unsigned int pci_epc_get_next_free_bar (const struct pci_epc_features + *epc_features,enum pci_barno bar);struct pci_epc *pci_epc_get (const char *epc_name);void pci_epc_put (struct pci_epc *epc);
Signature · 1 line
2.17.1
PATCH 8/19 PCI: endpoint: Make *_free_bar() to return error codes on failure
In reply to Kishon Vijay Abraham IModify pci_epc_get_next_free_bar() and pci_epc_get_first_free_bar() to return error values if there are no free BARs available.
--- drivers/pci/endpoint/functions/pci-epf-test.c | 2 ++ drivers/pci/endpoint/pci-epc-core.c | 12 ++++++------ include/linux/pci-epc.h | 8 ++++---- include/linux/pci-epf.h | 1 + 4 files changed, 13 insertions(+), 10 deletions(-)
drivers/pci/endpoint/functions/pci-epf-test.c +2 -0
@@ -831,6 +831,8 @@ static int pci_epf_test_bind(struct pci_epf *epf) linkup_notifier = epc_features->linkup_notifier; core_init_notifier = epc_features->core_init_notifier; test_reg_bar =pci_epc_get_first_free_bar (epc_features); +if (test_reg_bar <0 ) +return -EINVAL ;pci_epf_configure_bar (epf, epc_features); }
drivers/pci/endpoint/pci-epc-core.c +6 -6
@@ -150,8 +150,8 @@ EXPORT_SYMBOL_GPL(of_pci_epc_get_by_name);* Invoke to get the first unreserved BAR that can be used by the endpoint * function. For any incorrect value in reserved_bar return '0'. */ -unsigned int pci_epc_get_first_free_bar (const struct pci_epc_features - *epc_features) +enum pci_barno +pci_epc_get_first_free_bar (const struct pci_epc_features *epc_features) {return pci_epc_get_next_free_bar (epc_features,BAR_0 ); }
@@ -165,13 +165,13 @@ EXPORT_SYMBOL_GPL(pci_epc_get_first_free_bar);* Invoke to get the next unreserved BAR starting from @bar that can be used * for endpoint function. For any incorrect value in reserved_bar return '0'. */ -unsigned int pci_epc_get_next_free_bar (const struct pci_epc_features - *epc_features,enum pci_barno bar) +enum pci_barno pci_epc_get_next_free_bar (const struct pci_epc_features + *epc_features,enum pci_barno bar) {unsigned long free_bar;if (!epc_features) -return 0 ; +return BAR_0 ;/* If 'bar - 1' is a 64-bit BAR, move to the next BAR */ if ((epc_features->bar_fixed_64bit <<1 ) &1 << bar)
@@ -186,7 +186,7 @@ unsigned int pci_epc_get_next_free_bar(const struct pci_epc_features free_bar =find_next_zero_bit (&free_bar,6 , bar);if (free_bar >5 ) -return 0 ; +return NO_BAR ;return free_bar; }
include/linux/pci-epc.h +4 -4
@@ -201,10 +201,10 @@ int pci_epc_start(struct pci_epc *epc);void pci_epc_stop (struct pci_epc *epc);const struct pci_epc_features *pci_epc_get_features (struct pci_epc *epc,u8 func_no); -unsigned int pci_epc_get_first_free_bar (const struct pci_epc_features - *epc_features); -unsigned int pci_epc_get_next_free_bar (const struct pci_epc_features - *epc_features,enum pci_barno bar); +enum pci_barno +pci_epc_get_first_free_bar (const struct pci_epc_features *epc_features); +enum pci_barno pci_epc_get_next_free_bar (const struct pci_epc_features + *epc_features,enum pci_barno bar);struct pci_epc *pci_epc_get (const char *epc_name);void pci_epc_put (struct pci_epc *epc);
include/linux/pci-epf.h +1 -0
@@ -22,6 +22,7 @@ enum pci_notify_event { };enum pci_barno { +NO_BAR =-1 ,BAR_0 ,BAR_1 ,BAR_2 ,
Signature · 1 line
2.17.1
PATCH 9/19 PCI: endpoint: Remove unused pci_epf_match_device()
In reply to Kishon Vijay Abraham IRemove unused pci_epf_match_device() function added in pci-epf-core.c
--- drivers/pci/endpoint/pci-epf-core.c | 16 ---------------- include/linux/pci-epf.h | 2 -- 2 files changed, 18 deletions(-)
drivers/pci/endpoint/pci-epf-core.c +0 -16
@@ -347,22 +347,6 @@ struct pci_epf *devm_pci_epf_of_create(struct device *dev, }EXPORT_SYMBOL_GPL (devm_pci_epf_of_create); -const struct pci_epf_device_id * -pci_epf_match_device (const struct pci_epf_device_id *id,struct pci_epf *epf) -{ -if (!id || !epf) -return NULL ; - -while (*id->name) { -if (strcmp (epf->name, id->name) ==0 ) -return id; - id++; - } - -return NULL ; -} -EXPORT_SYMBOL_GPL (pci_epf_match_device); -static void pci_epf_dev_release (struct device *dev) {struct pci_epf *epf =to_pci_epf (dev);
include/linux/pci-epf.h +0 -2
@@ -168,8 +168,6 @@ static inline void *epf_get_drvdata(struct pci_epf *epf)return dev_get_drvdata (&epf->dev); } -const struct pci_epf_device_id * -pci_epf_match_device (const struct pci_epf_device_id *id,struct pci_epf *epf);struct pci_epf *pci_epf_create (const char *name);struct pci_epf *pci_epf_of_create (struct device_node *node); struct pci_epf *devm_pci_epf_of_create(struct device *dev,
Signature · 1 line
2.17.1
PATCH 10/19 PCI: endpoint: Make pci_epf_driver ops optional
In reply to Kishon Vijay Abraham Ipci_epf_driver had two ops for bind and unbind which will be invoked when an endpoint controller is bound to an endpoint function (using configfs). Now that endpoint core has support to define an endpoint function using device tree alone, the bind and unbind ops can be optional. Make pci_epf_driver ops optional here.
--- drivers/pci/endpoint/pci-epf-core.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/pci/endpoint/pci-epf-core.c +3 -5
@@ -201,11 +201,9 @@ int __pci_epf_register_driver(struct pci_epf_driver *driver, {int ret; -if (!driver->ops) -return -EINVAL ; - -if (!driver->ops->bind || !driver->ops->unbind) -return -EINVAL ; +if (!driver->ops || !driver->ops->bind || !driver->ops->unbind) +pr_debug ("%s: Supports only pci_epf device created using DT\n" , + driver->driver.name); driver->driver.bus = &pci_epf_bus_type; driver->driver.owner = owner;
Signature · 1 line
2.17.1
PATCH 11/19 PCI: endpoint: Add helper API to populate header with values from DT
In reply to Kishon Vijay Abraham IAdd helper API pci_epc_of_parse_header() to populate header with values from device tree. These values will be written to the configuration space header in the endpoint controller.
--- drivers/pci/endpoint/pci-epc-core.c | 24 ++++++++++++++++++++++++ include/linux/pci-epc.h | 2 ++ 2 files changed, 26 insertions(+)
drivers/pci/endpoint/pci-epc-core.c +24 -0
@@ -31,6 +31,30 @@ static int devm_pci_epc_match(struct device *dev, void *res, void *match_data)return *epc == match_data; } +/** +* pci_epc_of_parse_header() - parse the device tree to get PCI config space +* header +* @node: The device tree node (of endpoint function) which has the PCI config +* space header values +* @header: standard configuration space header fields that has to be populated +* +* Invoke to populate *header* with the PCI configuration space values populated +* in device tree. +*/ +void pci_epc_of_parse_header (struct device_node *node, +struct pci_epf_header *header) +{ +of_property_read_u16 (node,"epf,vendor-id" , &header->vendorid); +of_property_read_u16 (node,"epf,device-id" , &header->deviceid); +of_property_read_u8 (node,"epf,baseclass-code" , + &header->baseclass_code); +of_property_read_u8 (node,"epf,subclass-code" , &header->subclass_code); +of_property_read_u16 (node,"epf,subsys-vendor-id" , + &header->subsys_vendor_id); +of_property_read_u16 (node,"epf,subsys-id" , &header->subsys_id); +} +EXPORT_SYMBOL_GPL (pci_epc_of_parse_header); +/** * pci_epc_put() - release the PCI endpoint controller * @epc: epc returned by pci_epc_get()
include/linux/pci-epc.h +2 -0
@@ -199,6 +199,8 @@ int pci_epc_raise_irq(struct pci_epc *epc, u8 func_no, enum pci_epc_irq_type type, u16 interrupt_num);int pci_epc_start (struct pci_epc *epc);void pci_epc_stop (struct pci_epc *epc); +void pci_epc_of_parse_header (struct device_node *node, +struct pci_epf_header *header);const struct pci_epc_features *pci_epc_get_features (struct pci_epc *epc,u8 func_no);enum pci_barno
Signature · 1 line
2.17.1
PATCH 12/19 PCI: endpoint: Add support to associate secondary EPC with EPF
In reply to Kishon Vijay Abraham IIn the case of standard endpoint functions, only one endpoint controller (EPC) will be associated with an endpoint function (EPF). However for providing NTB (non transparent bridge) functionality, two EPCs should be associated with a single EPF. Add support to associate secondary EPC with EPF. This is in preparation for adding NTB endpoint function driver.
--- drivers/pci/endpoint/functions/pci-epf-test.c | 11 ++-- drivers/pci/endpoint/pci-ep-cfs.c | 6 +- drivers/pci/endpoint/pci-epc-core.c | 50 ++++++++++++---- drivers/pci/endpoint/pci-epf-core.c | 57 +++++++++++++------ include/linux/pci-epc.h | 25 +++++++- include/linux/pci-epf.h | 17 +++++- 6 files changed, 128 insertions(+), 38 deletions(-)
drivers/pci/endpoint/functions/pci-epf-test.c +7 -4
@@ -616,7 +616,8 @@ static void pci_epf_test_unbind(struct pci_epf *epf)if (epf_test->reg[bar]) {pci_epc_clear_bar (epc, epf->func_no, epf_bar); -pci_epf_free_space (epf, epf_test->reg[bar], bar); +pci_epf_free_space (epf, epf_test->reg[bar], bar, +PRIMARY_INTERFACE ); } } }
@@ -648,7 +649,8 @@ static int pci_epf_test_set_bar(struct pci_epf *epf) ret =pci_epc_set_bar (epc, epf->func_no, epf_bar);if (ret) { -pci_epf_free_space (epf, epf_test->reg[bar], bar); +pci_epf_free_space (epf, epf_test->reg[bar], bar, +PRIMARY_INTERFACE );dev_err (dev,"Failed to set BAR%d\n" , bar);if (bar == test_reg_bar)return ret;
@@ -768,7 +770,7 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf) } base =pci_epf_alloc_space (epf, test_reg_size, test_reg_bar, - epc_features->align); + epc_features->align,PRIMARY_INTERFACE );if (!base) {dev_err (dev,"Failed to allocated register space\n" );return -ENOMEM ;
@@ -786,7 +788,8 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf)continue ; base =pci_epf_alloc_space (epf, bar_size[bar], bar, - epc_features->align); + epc_features->align, +PRIMARY_INTERFACE );if (!base)dev_err (dev,"Failed to allocate space for BAR%d\n" , bar);
drivers/pci/endpoint/pci-ep-cfs.c +3 -3
@@ -94,13 +94,13 @@ static int pci_epc_epf_link(struct config_item *epc_item,struct pci_epc *epc = epc_group->epc;struct pci_epf *epf = epf_group->epf; - ret =pci_epc_add_epf (epc, epf); + ret =pci_epc_add_epf (epc, epf,PRIMARY_INTERFACE );if (ret)return ret; ret =pci_epf_bind (epf);if (ret) { -pci_epc_remove_epf (epc, epf); +pci_epc_remove_epf (epc, epf,PRIMARY_INTERFACE );return ret; }
@@ -120,7 +120,7 @@ static void pci_epc_epf_unlink(struct config_item *epc_item, epc = epc_group->epc; epf = epf_group->epf;pci_epf_unbind (epf); -pci_epc_remove_epf (epc, epf); +pci_epc_remove_epf (epc, epf,PRIMARY_INTERFACE ); }static struct configfs_item_operations pci_epc_item_ops = {
drivers/pci/endpoint/pci-epc-core.c +39 -11
86 lines not on this page · raw message
drivers/pci/endpoint/pci-epf-core.c +41 -16
97 lines not on this page · raw message
include/linux/pci-epc.h +23 -2
@@ -13,6 +13,12 @@struct pci_epc ; +enum pci_epc_interface_type { +UNKNOWN_INTERFACE =-1 , +PRIMARY_INTERFACE , +SECONDARY_INTERFACE , +}; +enum pci_epc_irq_type {PCI_EPC_IRQ_UNKNOWN ,PCI_EPC_IRQ_LEGACY ,
@@ -20,6 +26,19 @@ enum pci_epc_irq_type { PCI_EPC_IRQ_MSIX, }; +static inline const char * +pci_epc_interface_string (enum pci_epc_interface_type type) +{ +switch (type) { +case PRIMARY_INTERFACE : +return "primary" ; +case SECONDARY_INTERFACE : +return "secondary" ; +default : +return "UNKNOWN interface" ; + } +} +/** * struct pci_epc_ops - set of function pointers for performing EPC operations * @write_header: ops to populate configuration space header
@@ -175,10 +194,12 @@ __pci_epc_create(struct device *dev, const struct pci_epc_ops *ops, struct module *owner);void devm_pci_epc_destroy (struct device *dev,struct pci_epc *epc);void pci_epc_destroy (struct pci_epc *epc); -int pci_epc_add_epf (struct pci_epc *epc,struct pci_epf *epf); +int pci_epc_add_epf (struct pci_epc *epc,struct pci_epf *epf, +enum pci_epc_interface_type type);void pci_epc_linkup (struct pci_epc *epc);void pci_epc_init_notify (struct pci_epc *epc); -void pci_epc_remove_epf (struct pci_epc *epc,struct pci_epf *epf); +void pci_epc_remove_epf (struct pci_epc *epc,struct pci_epf *epf, +enum pci_epc_interface_type type);int pci_epc_write_header (struct pci_epc *epc,u8 func_no,struct pci_epf_header *hdr); int pci_epc_set_bar(struct pci_epc *epc, u8 func_no,
include/linux/pci-epf.h +15 -2
@@ -15,6 +15,7 @@#include <linux/pci.h> struct pci_epf ; +enum pci_epc_interface_type ;enum pci_notify_event {CORE_INIT ,
@@ -121,6 +122,11 @@ struct pci_epf_bar {* @list: to add pci_epf as a list of PCI endpoint functions to pci_epc * @nb: notifier block to notify EPF of any EPC events (like linkup) * @lock: mutex to protect pci_epf_ops +* @sec_epc: the secondary EPC device to which this EPF device is bound +* @sec_epc_list: to add pci_epf as list of PCI endpoint functions to secondary +* EPC device +* @sec_epc_bar: represents the BAR of EPF device associated with secondary EPC +* @sec_epc_func_no: unique (physical) function number within the secondary EPC */ struct pci_epf {struct device dev;
@@ -138,6 +144,12 @@ struct pci_epf {struct notifier_block nb;/* mutex to protect against concurrent access of pci_epf_ops */ struct mutex lock; + +/* Below members are to attach secondary EPC to an endpoint function */ +struct pci_epc *sec_epc; +struct list_head sec_epc_list; +struct pci_epf_bar sec_epc_bar[6 ]; +u8 sec_epc_func_no; };/**
@@ -177,8 +189,9 @@ int __pci_epf_register_driver(struct pci_epf_driver *driver, struct module *owner);void pci_epf_unregister_driver (struct pci_epf_driver *driver);void *pci_epf_alloc_space (struct pci_epf *epf,size_t size,enum pci_barno bar, -size_t align); -void pci_epf_free_space (struct pci_epf *epf,void *addr,enum pci_barno bar); +size_t align,enum pci_epc_interface_type type); +void pci_epf_free_space (struct pci_epf *epf,void *addr,enum pci_barno bar, +enum pci_epc_interface_type type);int pci_epf_bind (struct pci_epf *epf);void pci_epf_unbind (struct pci_epf *epf);#endif /* __LINUX_PCI_EPF_H */
Signature · 1 line
2.17.1
PATCH 13/19 PCI: endpoint: Add pci_epc_ops to map MSI irq
In reply to Kishon Vijay Abraham IAdd pci_epc_ops to map physical address to MSI address and return MSI data. The physical address is an address in the outbound region. This is required to implement doorbell functionality of NTB (non transparent bridge) wherein EPC on either side of the interface (primary and secondary) can directly write to the physical address (in outbound region) of the other interface to ring doorbell using MSI.
--- drivers/pci/endpoint/pci-epc-core.c | 40 +++++++++++++++++++++++++++++ include/linux/pci-epc.h | 7 +++++ 2 files changed, 47 insertions(+)
drivers/pci/endpoint/pci-epc-core.c +40 -0
@@ -314,6 +314,46 @@ int pci_epc_raise_irq(struct pci_epc *epc, u8 func_no, }EXPORT_SYMBOL_GPL (pci_epc_raise_irq); +/** +* pci_epc_map_msi_irq() - Map physical address to MSI address and return +* MSI data +* @epc: the EPC device which has the MSI capability +* @func_no: the physical endpoint function number in the EPC device +* @vfunc_no: the virtual endpoint function number in the physical function +* @phys_addr: the physical address of the outbound region +* @interrupt_num: the MSI interrupt number +* @entry_size: Size of Outbound address region for each interrupt +* @msi_data: the data that should be written in order to raise MSI interrupt +* with interrupt number as 'interrupt num' +* +* Invoke to map physical address to MSI address and return MSI data. The +* physical address should be an address in the outbound region. This is +* required to implement doorbell functionality of NTB wherein EPC on either +* side of the interface (primary and secondary) can directly write to the +* physical address (in outbound region) of the other interface to ring +* doorbell. +*/ +int pci_epc_map_msi_irq (struct pci_epc *epc,u8 func_no,u8 vfunc_no, +phys_addr_t phys_addr,u8 interrupt_num,u32 entry_size, +u32 *msi_data) +{ +int ret; + +if (IS_ERR_OR_NULL (epc)) +return -EINVAL ; + +if (!epc->ops->map_msi_irq) +return -EINVAL ; + +mutex_lock (&epc->lock); + ret = epc->ops->map_msi_irq (epc, func_no, vfunc_no, phys_addr, + interrupt_num, entry_size, msi_data); +mutex_unlock (&epc->lock); + +return ret; +} +EXPORT_SYMBOL_GPL (pci_epc_map_msi_irq); +/** * pci_epc_get_msi() - get the number of MSI interrupt numbers allocated * @epc: the EPC device to which MSI interrupts was requested
include/linux/pci-epc.h +7 -0
@@ -55,6 +55,7 @@ pci_epc_interface_string(enum pci_epc_interface_type type)* @get_msix: ops to get the number of MSI-X interrupts allocated by the RC * from the MSI-X capability register * @raise_irq: ops to raise a legacy, MSI or MSI-X interrupt +* @map_msi_irq: ops to map physical address to MSI address and return MSI data * @start: ops to start the PCI link * @stop: ops to stop the PCI link * @owner: the module owner containing the ops
@@ -77,6 +78,9 @@ struct pci_epc_ops {int (*get_msix)(struct pci_epc *epc,u8 func_no);int (*raise_irq)(struct pci_epc *epc,u8 func_no,enum pci_epc_irq_type type,u16 interrupt_num); +int (*map_msi_irq)(struct pci_epc *epc,u8 func_no,u8 vfunc_no, +phys_addr_t phys_addr,u8 interrupt_num, +u32 entry_size,u32 *msi_data);int (*start)(struct pci_epc *epc);void (*stop)(struct pci_epc *epc); const struct pci_epc_features* (*get_features)(struct pci_epc *epc,
@@ -216,6 +220,9 @@ int pci_epc_get_msi(struct pci_epc *epc, u8 func_no);int pci_epc_set_msix (struct pci_epc *epc,u8 func_no,u16 interrupts,enum pci_barno ,u32 offset);int pci_epc_get_msix (struct pci_epc *epc,u8 func_no); +int pci_epc_map_msi_irq (struct pci_epc *epc,u8 func_no, +phys_addr_t phys_addr,u8 interrupt_num, +u32 entry_size,u32 *msi_data);int pci_epc_raise_irq (struct pci_epc *epc,u8 func_no,enum pci_epc_irq_type type,u16 interrupt_num);int pci_epc_start (struct pci_epc *epc);
Signature · 1 line
2.17.1
PATCH 14/19 PCI: cadence: Implement ->msi_map_irq() ops
In reply to Kishon Vijay Abraham IImplement ->msi_map_irq() ops in order to map physical address to MSI address and return MSI data.
--- .../pci/controller/cadence/pcie-cadence-ep.c | 50 +++++++++++++++++++ drivers/pci/endpoint/pci-epc-core.c | 7 ++- include/linux/pci-epc.h | 2 +- 3 files changed, 54 insertions(+), 5 deletions(-)
drivers/pci/controller/cadence/pcie-cadence-ep.c +50 -0
@@ -380,6 +380,54 @@ static int cdns_pcie_ep_send_msi_irq(struct cdns_pcie_ep *ep, u8 fn,return 0 ; } +static int cdns_pcie_ep_map_msi_irq (struct pci_epc *epc,u8 fn, +phys_addr_t addr,u8 interrupt_num, +u32 entry_size,u32 *msi_data) +{ +struct cdns_pcie_ep *ep =epc_get_drvdata (epc); +u32 cap =CDNS_PCIE_EP_FUNC_MSI_CAP_OFFSET ; +struct cdns_pcie *pcie = &ep->pcie; +u16 flags, mme, data, data_mask; +u8 msi_count; +u64 pci_addr; +int ret; +int i; + +/* Check whether the MSI feature has been enabled by the PCI host. */ + flags =cdns_pcie_ep_fn_readw (pcie, fn, cap +PCI_MSI_FLAGS ); +if (!(flags &PCI_MSI_FLAGS_ENABLE )) +return -EINVAL ; + +/* Get the number of enabled MSIs */ + mme = (flags &PCI_MSI_FLAGS_QSIZE ) >>4 ; + msi_count =1 << mme; +if (!interrupt_num || interrupt_num > msi_count) +return -EINVAL ; + +/* Compute the data value to be written. */ + data_mask = msi_count -1 ; + data =cdns_pcie_ep_fn_readw (pcie, fn, cap +PCI_MSI_DATA_64 ); + data = data & ~data_mask; + +/* Get the PCI address where to write the data into. */ + pci_addr =cdns_pcie_ep_fn_readl (pcie, fn, cap +PCI_MSI_ADDRESS_HI ); + pci_addr <<=32 ; + pci_addr |=cdns_pcie_ep_fn_readl (pcie, fn, cap +PCI_MSI_ADDRESS_LO ); + pci_addr &=GENMASK_ULL (63 ,2 ); + +for (i =0 ; i < interrupt_num; i++) { + ret =cdns_pcie_ep_map_addr (epc, fn, addr, pci_addr, + entry_size); +if (ret) +return ret; + addr = addr + entry_size; + } + + *msi_data = data; + +return 0 ; +} +static int cdns_pcie_ep_send_msix_irq (struct cdns_pcie_ep *ep,u8 fn,u16 interrupt_num) {
@@ -480,6 +528,7 @@ static const struct pci_epc_features cdns_pcie_epc_features = { .linkup_notifier = false, .msi_capable = true, .msix_capable = true, + .align = 256, }; static const struct pci_epc_features*
@@ -499,6 +548,7 @@ static const struct pci_epc_ops cdns_pcie_epc_ops = { .set_msix = cdns_pcie_ep_set_msix, .get_msix = cdns_pcie_ep_get_msix, .raise_irq = cdns_pcie_ep_raise_irq, + .map_msi_irq = cdns_pcie_ep_map_msi_irq, .start = cdns_pcie_ep_start, .get_features = cdns_pcie_ep_get_features, };
drivers/pci/endpoint/pci-epc-core.c +3 -4
@@ -319,7 +319,6 @@ EXPORT_SYMBOL_GPL(pci_epc_raise_irq);* MSI data * @epc: the EPC device which has the MSI capability * @func_no: the physical endpoint function number in the EPC device -* @vfunc_no: the virtual endpoint function number in the physical function * @phys_addr: the physical address of the outbound region * @interrupt_num: the MSI interrupt number * @entry_size: Size of Outbound address region for each interrupt
@@ -333,7 +332,7 @@ EXPORT_SYMBOL_GPL(pci_epc_raise_irq);* physical address (in outbound region) of the other interface to ring * doorbell. */ -int pci_epc_map_msi_irq (struct pci_epc *epc,u8 func_no,u8 vfunc_no, +int pci_epc_map_msi_irq (struct pci_epc *epc,u8 func_no,phys_addr_t phys_addr,u8 interrupt_num,u32 entry_size,u32 *msi_data) {
@@ -346,8 +345,8 @@ int pci_epc_map_msi_irq(struct pci_epc *epc, u8 func_no, u8 vfunc_no,return -EINVAL ;mutex_lock (&epc->lock); - ret = epc->ops->map_msi_irq (epc, func_no, vfunc_no, phys_addr, - interrupt_num, entry_size, msi_data); + ret = epc->ops->map_msi_irq (epc, func_no, phys_addr, interrupt_num, + entry_size, msi_data);mutex_unlock (&epc->lock);return ret;
include/linux/pci-epc.h +1 -1
@@ -78,7 +78,7 @@ struct pci_epc_ops {int (*get_msix)(struct pci_epc *epc,u8 func_no);int (*raise_irq)(struct pci_epc *epc,u8 func_no,enum pci_epc_irq_type type,u16 interrupt_num); -int (*map_msi_irq)(struct pci_epc *epc,u8 func_no,u8 vfunc_no, +int (*map_msi_irq)(struct pci_epc *epc,u8 func_no,phys_addr_t phys_addr,u8 interrupt_num,u32 entry_size,u32 *msi_data);int (*start)(struct pci_epc *epc);
Signature · 1 line
2.17.1
PATCH 15/19 PCI: endpoint: Add EP function driver to provide NTB functionality
In reply to Kishon Vijay Abraham IAdd a new endpoint function driver to provide NTB functionality using multiple PCIe endpoint instances.
--- drivers/pci/endpoint/functions/Kconfig | 12 + drivers/pci/endpoint/functions/Makefile | 1 + drivers/pci/endpoint/functions/pci-epf-ntb.c | 2038 ++++++++++++++++++ 3 files changed, 2051 insertions(+) create mode 100644 drivers/pci/endpoint/functions/pci-epf-ntb.c
drivers/pci/endpoint/functions/Kconfig +12 -0
@@ -12,3 +12,15 @@ config PCI_EPF_TEST for PCI Endpoint. If in doubt, say "N" to disable Endpoint test driver. + +config PCI_EPF_NTB + tristate "PCI Endpoint NTB driver" + depends on PCI_ENDPOINT + help + Select this configuration option to enable the NTB driver + for PCI Endpoint. NTB driver implements NTB controller + functionality using multiple PCIe endpoint instances. It + can support NTB endpoint function devices created using + device tree. + + If in doubt, say "N" to disable Endpoint NTB driver.
drivers/pci/endpoint/functions/Makefile +1 -0
@@ -4,3 +4,4 @@ # obj-$(CONFIG_PCI_EPF_TEST) += pci-epf-test.o +obj-$(CONFIG_PCI_EPF_NTB) += pci-epf-ntb.o
drivers/pci/endpoint/functions/pci-epf-ntb.c new file +2038 -0
2,038 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 16/19 PCI: Add TI J721E device to pci ids
In reply to Kishon Vijay Abraham IAdd TI J721E device to the pci id database. Since this device has a configurable PCIe endpoint, it could be used with different drivers.
--- drivers/misc/pci_endpoint_test.c | 1 - include/linux/pci_ids.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-)
drivers/misc/pci_endpoint_test.c +0 -1
@@ -68,7 +68,6 @@#define PCI_ENDPOINT_TEST_FLAGS 0x2c#define FLAG_USE_DMA BIT(0) -#define PCI_DEVICE_ID_TI_J721E 0xb00d#define PCI_DEVICE_ID_TI_AM654 0xb00c#define is_am654_pci_dev (pdev) \
include/linux/pci_ids.h +1 -0
@@ -879,6 +879,7 @@#define PCI_DEVICE_ID_TI_X620 0xac8d#define PCI_DEVICE_ID_TI_X420 0xac8e#define PCI_DEVICE_ID_TI_XX20_FM 0xac8f +#define PCI_DEVICE_ID_TI_J721E 0xb00d#define PCI_DEVICE_ID_TI_DRA74x 0xb500#define PCI_DEVICE_ID_TI_DRA72x 0xb501
Signature · 1 line
2.17.1
PATCH 17/19 NTB: Add support for EPF PCI-Express Non-Transparent Bridge
In reply to Kishon Vijay Abraham IAdd support for EPF PCI-Express Non-Transparent Bridge (NTB) device. This driver is platform independent and could be used by any platform which have multiple PCIe endpoint instances configured using the pci-epf-ntb driver. The driver connnects to the standard NTB sub-system interface. The EPF NTB device has configurable number of memory windows (Max 4), configurable number of doorbell (Max 32), and configurable number of scratch-pad registers.
--- drivers/ntb/hw/Kconfig | 1 + drivers/ntb/hw/Makefile | 1 + drivers/ntb/hw/epf/Kconfig | 5 + drivers/ntb/hw/epf/Makefile | 1 + drivers/ntb/hw/epf/ntb_hw_epf.c | 752 ++++++++++++++++++++++++++++++++ 5 files changed, 760 insertions(+) create mode 100644 drivers/ntb/hw/epf/Kconfig create mode 100644 drivers/ntb/hw/epf/Makefile create mode 100644 drivers/ntb/hw/epf/ntb_hw_epf.c
drivers/ntb/hw/Kconfig +1 -0
@@ -2,4 +2,5 @@ source "drivers/ntb/hw/amd/Kconfig" source "drivers/ntb/hw/idt/Kconfig" source "drivers/ntb/hw/intel/Kconfig" +source "drivers/ntb/hw/epf/Kconfig" source "drivers/ntb/hw/mscc/Kconfig"
drivers/ntb/hw/Makefile +1 -0
@@ -2,4 +2,5 @@ obj-$(CONFIG_NTB_AMD) += amd/ obj-$(CONFIG_NTB_IDT) += idt/ obj-$(CONFIG_NTB_INTEL) += intel/ +obj-$(CONFIG_NTB_EPF) += epf/ obj-$(CONFIG_NTB_SWITCHTEC) += mscc/
drivers/ntb/hw/epf/Kconfig new file +5 -0
@@ -0,0 +1,5 @@ +config NTB_EPF + tristate "Generic EPF Non-Transparent Bridge support" + help + This driver supports EPF NTB on configurable endpoint. + If unsure, say N.
drivers/ntb/hw/epf/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_NTB_EPF) += ntb_hw_epf.o
drivers/ntb/hw/epf/ntb_hw_epf.c new file +752 -0
752 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 18/19 NTB: tool: Enable the NTB/PCIe link on the local or remote side of bridge
In reply to Kishon Vijay Abraham IInvoke ntb_link_enable() to enable the NTB/PCIe link on the local or remote side of the bridge.
--- drivers/ntb/test/ntb_tool.c | 1 + 1 file changed, 1 insertion(+)
drivers/ntb/test/ntb_tool.c +1 -0
@@ -1638,6 +1638,7 @@ static int tool_probe(struct ntb_client *self, struct ntb_dev *ntb)tool_setup_dbgfs (tc); +ntb_link_enable (ntb,NTB_SPEED_AUTO ,NTB_WIDTH_AUTO );return 0 ; err_clear_mws:
Signature · 1 line
2.17.1
PATCH 19/19 NTB: ntb_perf/ntb_tool: Use PCI device for dma_alloc_coherent()
In reply to Kishon Vijay Abraham INTB device is not a real device and the piece of hardware actually doing the DMA is the PCI device itself. Fix ntb_perf.c and ntb_tool.c to use PCI device for dma_alloc_coherent() instead of NTB device. ntb_transport.c already uses PCI device for dma_alloc_coherent().
--- drivers/ntb/test/ntb_perf.c | 3 ++- drivers/ntb/test/ntb_tool.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/ntb/test/ntb_perf.c +2 -1
@@ -566,6 +566,7 @@ static int perf_setup_inbuf(struct perf_peer *peer) {resource_size_t xlat_align, size_align, size_max;struct perf_ctx *perf = peer->perf; +struct pci_dev *pdev = perf->ntb->pdev;int ret;/* Get inbound MW parameters */
@@ -586,7 +587,7 @@ static int perf_setup_inbuf(struct perf_peer *peer)perf_free_inbuf (peer); - peer->inbuf =dma_alloc_coherent (&perf->ntb->dev, peer->inbuf_size, + peer->inbuf =dma_alloc_coherent (&pdev->dev, peer->inbuf_size, &peer->inbuf_xlat,GFP_KERNEL );if (!peer->inbuf) { dev_err(&perf->ntb->dev, "Failed to alloc inbuf of %pa\n",
drivers/ntb/test/ntb_tool.c +2 -1
@@ -576,6 +576,7 @@ static int tool_setup_mw(struct tool_ctx *tc, int pidx, int widx, {resource_size_t size, addr_align, size_align;struct tool_mw *inmw = &tc->peers[pidx].inmws[widx]; +struct pci_dev *pdev = tc->ntb->pdev;char buf[TOOL_BUF_LEN ];int ret;
@@ -590,7 +591,7 @@ static int tool_setup_mw(struct tool_ctx *tc, int pidx, int widx, inmw->size =min_t (resource_size_t, req_size, size); inmw->size =round_up (inmw->size, addr_align); inmw->size =round_up (inmw->size, size_align); - inmw->mm_base =dma_alloc_coherent (&tc->ntb->dev, inmw->size, + inmw->mm_base =dma_alloc_coherent (&pdev->dev, inmw->size, &inmw->dma_base,GFP_KERNEL );if (!inmw->mm_base)return -ENOMEM ;
Signature · 1 line
2.17.1
Quoted 8 lines · Kishon Vijay Abraham I
This series is about implementing SW defined NTB using multiple endpoint instances. This series has been tested using 2 endpoint instances in J7 connected to two DRA7 boards. However there is nothing platform specific for the NTB functionality.
This was presented in Linux Plumbers Conference. The presentation can be found @ [1]
I'd like to know why putting this into DT is better than configfs. Does it solve some problem? Doing things in userspace is so much easier and more flexible than modifying and updating a DT.
I don't really think the PCI endpoint stuff is mature enough to be putting into DT either.
Rob
Hi Rob,
Quoted 7 lines · Rob Herring
Quoted 6 lines · Kishon Vijay Abraham I
This series is about implementing SW defined NTB using multiple endpoint instances. This series has been tested using 2 endpoint instances in J7 connected to two DRA7 boards. However there is nothing platform specific for the NTB functionality.
Quoted 6 lines
Quoted 2 lines
This was presented in Linux Plumbers Conference. The presentation can be found @ [1]
I'd like to know why putting this into DT is better than configfs. Does it solve some problem? Doing things in userspace is so much easier and more flexible than modifying and updating a DT.
It's a lot cleaner to have an endpoint function bound to two different endpoint controller using device tree than configfs.
+ epf_bus {
+ compatible = "pci-epf-bus";
+
+ func@0 {
+ compatible = "pci-epf-ntb"; + epcs = <&pcie0_ep>, <&pcie1_ep>; + epc-names = "primary", "secondary"; + reg = <0>; + epf,vendor-id = /bits/ 16 <0x104c>; + epf,device-id = /bits/ 16 <0xb00d>; + num-mws = <4>; + mws-size = <0x0 0x100000>, <0x0 0x100000>, <0x0 0x100000>, <0x0 0x100000>;
+ };
For device tree, just using phandles is enough and the driver can easily parse DT to get EPCs bound to the endpoint function
+ epcs = <&pcie0_ep>, <&pcie1_ep>;
+ epc-names = "primary", "secondary";
This would be
ln -s functions/pci-epf-ntb/func1 controllers/2900000.pcie-ep/ ln -s functions/pci-epf-ntb/func1 controllers/2910000.pcie-ep/
pci_epc_epf_link() should then maintain the order of EPC bound to EPF and designate one as PRIMARY_INTERFACE and the second as SECONDARY_INTERFACE. pci_epf_bind() should be made to behave differently for NTB case.
While the standard properties (like vendorid, deviceid) has configfs entries, additional logic would be required for adding function specific fields like num-mws and mws-size above.
While all this support could be added in configfs, it looks simpler to represent then in DT.
Quoted 3 lines
I don't really think the PCI endpoint stuff is mature enough to be putting into DT either.
I think this will anyways come when we have to export real HW peripherals to the remote HOST using EP controller.
Thanks
Kishon