PCI: Support for configurable PCI endpoint
Subsystems (11)
Hi Bjorn,
Please find the pull request for PCI endpoint support below. I've also included all the history here.
Changes from v5:
*) remove #syscon-cells property added in v5 and used
of_parse_phandle_with_fixed_args
*) fix compilation error in make.cross ARCH=blackfin that was because
pci_endpoint_test.c driver depends on COMPILE_TEST.
Changes from v4:
*) add #syscon-cells property and used of_parse_phandle_with_args
to perform a configuration in syscon module (as suggested by Rob Herring)
*) Remove unnecessary white space.
Changes from v3:
*) fixed a typo and adapted to https://lkml.org/lkml/2017/3/13/562.
Changes from v2:
*) changed the configfs structure as suggested by Christoph Hellwig. With
this change the framework creates configfs entry for EP function driver and EP controller. Previously these entries have to be created by the the user. (Haven't changed the epc core or epf core except for invoking configfs APIs to create entries for EP function driver and EP controller. That's mostly because the EP function device can still be created by directly invoking the epf core API without using configfs).
*) Now the user has to use configfs entry 'start' to start the link.
This was previously done by the function driver. However in the case of multi function EP, the function driver shouldn't start the link.
Changes from v1:
*) The preparation patches for adding EP support is removed and is sent
separately
*) Added device ID for DRA74x/DRA72x and used it instead of
using "PCI_ANY_ID"
*) Added userguide for PCI endpoint test function
Major Improvements from RFC:
*) support multi-function devices (hw supported not virtual) *) Access host side buffers
*) Raise MSI interrupts
*) Add user space program to use the host side PCI driver *) Adapt all other users of designware to use the new design (only
compile tested. Since I have only dra7xx boards, the new design has only been tested in dra7xx. I'd require the help of others to test the platforms they have access to).
This is based ongit://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
pci/host-designware
Thanks
Kishon
The following changes since commit 7ea64dcf602c21b3e5062ca90111ca4459fab403:
__end__ (2017-04-04 15:29:37 -0500)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kishon/pci-endpoint.git tags/pci-endpoint-for-4.12
for you to fetch changes up to a5c85ba45c9682456077d7277196e91f8ea5fd5c:
ARM: DRA7: clockdomain: Change the CLKTRCTRL of CM_PCIE_CLKSTCTRL to SW_WKUP (2017-04-05 14:05:28 +0530)
----------------------------------------------------------------
pci: endpoint: for 4.12
*) Add PCI endpoint core layer
*) Modify designware and dra7xx driver to be configured in EP mode *) Add a PCI endpoint *test* function driver and corresponding host
driver
----------------------------------------------------------------
Kishon Vijay Abraham I (23):
PCI: endpoint: Add EP core layer to enable EP controller and EP functions
Documentation: PCI: Guide to use PCI Endpoint Core Layer
PCI: endpoint: Introduce configfs entry for configuring EP functions
Documentation: PCI: Guide to use PCI endpoint configfs
PCI: endpoint: Create configfs entry for EPC device and EPF driver
Documentation: PCI: Add specification for the *PCI test* function device
PCI: endpoint: functions: Add an EP function to test PCI
Documentation: PCI: Add binding documentation for pci-test endpoint function
PCI: dwc: designware: Add EP mode support
dt-bindings: PCI: Add DT bindings for PCI designware EP mode
PCI: dwc: dra7xx: Facilitate wrapper and MSI interrupts to be enabled independently
PCI: dwc: dra7xx: Add EP mode support
dt-bindings: PCI: dra7xx: Add DT bindings for PCI dra7xx EP mode
PCI: dwc: dra7xx: Workaround for errata id i870
dt-bindings: PCI: dra7xx: Add DT bindings to enable unaligned access
PCI: Add device IDs for DRA74x and DRA72x
misc: Add host side PCI driver for PCI test function device
Documentation: misc-devices: Add Documentation for pci-endpoint-test driver
tools: PCI: Add a userspace tool to test PCI endpoint
tools: PCI: Add sample test script to invoke pcitest
Documentation: PCI: Add userguide for PCI endpoint test function
MAINTAINERS: Add PCI Endpoint maintainer
ARM: DRA7: clockdomain: Change the CLKTRCTRL of CM_PCIE_CLKSTCTRL to SW_WKUP
Documentation/PCI/00-INDEX | 10 +++ Documentation/PCI/endpoint/function/binding/pci-test.txt | 17 +++++ Documentation/PCI/endpoint/pci-endpoint-cfs.txt | 105 ++++++++++++++++++++++++++ Documentation/PCI/endpoint/pci-endpoint.txt | 215 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Documentation/PCI/endpoint/pci-test-function.txt | 66 ++++++++++++++++ Documentation/PCI/endpoint/pci-test-howto.txt | 179 +++++++++++++++++++++++++++++++++++++++++++ Documentation/devicetree/bindings/pci/designware-pcie.txt | 26 +++++-- Documentation/devicetree/bindings/pci/ti-pci.txt | 42 +++++++++-- Documentation/misc-devices/pci-endpoint-test.txt | 35 +++++++++ MAINTAINERS | 9 +++ arch/arm/mach-omap2/clockdomains7xx_data.c | 2 +- drivers/Makefile | 2 + drivers/misc/Kconfig | 7 ++ drivers/misc/Makefile | 1 + drivers/misc/pci_endpoint_test.c | 534 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/Kconfig | 1 + drivers/pci/dwc/Kconfig | 36 ++++++++- drivers/pci/dwc/Makefile | 5 +- drivers/pci/dwc/pci-dra7xx.c | 270 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- drivers/pci/dwc/pcie-designware-ep.c | 342 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/dwc/pcie-designware.c | 125 ++++++++++++++++++++++++++++++ drivers/pci/dwc/pcie-designware.h | 112 +++++++++++++++++++++++++++ drivers/pci/endpoint/Kconfig | 31 ++++++++ drivers/pci/endpoint/Makefile | 7 ++ drivers/pci/endpoint/functions/Kconfig | 12 +++ drivers/pci/endpoint/functions/Makefile | 5 ++ drivers/pci/endpoint/functions/pci-epf-test.c | 510 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/endpoint/pci-ep-cfs.c | 509 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/endpoint/pci-epc-core.c | 579 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/endpoint/pci-epc-mem.c | 143 +++++++++++++++++++++++++++++++++++ drivers/pci/endpoint/pci-epf-core.c | 351 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mod_devicetable.h | 10 +++ include/linux/pci-ep-cfs.h | 41 ++++++++++ include/linux/pci-epc.h | 144 +++++++++++++++++++++++++++++++++++ include/linux/pci-epf.h | 162 +++++++++++++++++++++++++++++++++++++++ include/linux/pci_ids.h | 2 + include/uapi/linux/Kbuild | 1 + include/uapi/linux/pcitest.h | 19 +++++ tools/pci/pcitest.c | 186 +++++++++++++++++++++++++++++++++++++++++++++ tools/pci/pcitest.sh | 56 ++++++++++++++ 40 files changed, 4869 insertions(+), 40 deletions(-) create mode 100644 Documentation/PCI/endpoint/function/binding/pci-test.txt create mode 100644 Documentation/PCI/endpoint/pci-endpoint-cfs.txt create mode 100644 Documentation/PCI/endpoint/pci-endpoint.txt create mode 100644 Documentation/PCI/endpoint/pci-test-function.txt create mode 100644 Documentation/PCI/endpoint/pci-test-howto.txt create mode 100644 Documentation/misc-devices/pci-endpoint-test.txt create mode 100644 drivers/misc/pci_endpoint_test.c create mode 100644 drivers/pci/dwc/pcie-designware-ep.c create mode 100644 drivers/pci/endpoint/Kconfig create mode 100644 drivers/pci/endpoint/Makefile create mode 100644 drivers/pci/endpoint/functions/Kconfig create mode 100644 drivers/pci/endpoint/functions/Makefile create mode 100644 drivers/pci/endpoint/functions/pci-epf-test.c create mode 100644 drivers/pci/endpoint/pci-ep-cfs.c create mode 100644 drivers/pci/endpoint/pci-epc-core.c create mode 100644 drivers/pci/endpoint/pci-epc-mem.c create mode 100644 drivers/pci/endpoint/pci-epf-core.c create mode 100644 include/linux/pci-ep-cfs.h create mode 100644 include/linux/pci-epc.h create mode 100644 include/linux/pci-epf.h create mode 100644 include/uapi/linux/pcitest.h create mode 100644 tools/pci/pcitest.c create mode 100644 tools/pci/pcitest.sh
PATCH v6 1/23 PCI: endpoint: Add EP core layer to enable EP controller and EP functions
Introduce a new EP core layer in order to support endpoint functions in linux kernel. This comprises the EPC library (Endpoint Controller Library) and EPF library (Endpoint Function Library). EPC library implements functions specific to an endpoint controller and EPF library implements functions specific to an endpoint function.
--- drivers/Makefile | 2 + drivers/pci/Kconfig | 1 + drivers/pci/endpoint/Kconfig | 20 ++ drivers/pci/endpoint/Makefile | 6 + drivers/pci/endpoint/pci-epc-core.c | 575 ++++++++++++++++++++++++++++++++++++ drivers/pci/endpoint/pci-epc-mem.c | 143 +++++++++ drivers/pci/endpoint/pci-epf-core.c | 347 ++++++++++++++++++++++ include/linux/mod_devicetable.h | 10 + include/linux/pci-epc.h | 142 +++++++++ include/linux/pci-epf.h | 160 ++++++++++ 10 files changed, 1406 insertions(+) create mode 100644 drivers/pci/endpoint/Kconfig create mode 100644 drivers/pci/endpoint/Makefile create mode 100644 drivers/pci/endpoint/pci-epc-core.c create mode 100644 drivers/pci/endpoint/pci-epc-mem.c create mode 100644 drivers/pci/endpoint/pci-epf-core.c create mode 100644 include/linux/pci-epc.h create mode 100644 include/linux/pci-epf.h
drivers/Makefile +2 -0
@@ -14,7 +14,9 @@ obj-$(CONFIG_GENERIC_PHY) += phy/ obj-$(CONFIG_PINCTRL) += pinctrl/ obj-$(CONFIG_GPIOLIB) += gpio/ obj-y += pwm/ + obj-$(CONFIG_PCI) += pci/ +obj-$(CONFIG_PCI_ENDPOINT) += pci/endpoint/ # PCI dwc controller drivers obj-y += pci/dwc/
drivers/pci/Kconfig +1 -0
@@ -134,3 +134,4 @@ config PCI_HYPERV source "drivers/pci/hotplug/Kconfig" source "drivers/pci/dwc/Kconfig" source "drivers/pci/host/Kconfig" +source "drivers/pci/endpoint/Kconfig"
drivers/pci/endpoint/Kconfig new file +20 -0
@@ -0,0 +1,20 @@ +# +# PCI Endpoint Support +# + +menu "PCI Endpoint" + +config PCI_ENDPOINT + bool "PCI Endpoint Support" + help + Enable this configuration option to support configurable PCI + endpoint. This should be enabled if the platform has a PCI + controller that can operate in endpoint mode. + + Enabling this option will build the endpoint library, which + includes endpoint controller library and endpoint function + library. + + If in doubt, say "N" to disable Endpoint support. + +endmenu
drivers/pci/endpoint/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# +# Makefile for PCI Endpoint Support +# + +obj-$(CONFIG_PCI_ENDPOINT) += pci-epc-core.o pci-epf-core.o\ + pci-epc-mem.o
drivers/pci/endpoint/pci-epc-core.c new file +575 -0
575 lines not on this page · raw message
drivers/pci/endpoint/pci-epc-mem.c new file +143 -0
143 lines not on this page · raw message
drivers/pci/endpoint/pci-epf-core.c new file +347 -0
347 lines not on this page · raw message
include/linux/mod_devicetable.h +10 -0
@@ -428,6 +428,16 @@ struct i2c_device_id {kernel_ulong_t driver_data;/* Data private to the driver */ }; +/* pci_epf */ + +#define PCI_EPF_NAME_SIZE 20 +#define PCI_EPF_MODULE_PREFIX "pci_epf:" + +struct pci_epf_device_id { +char name[PCI_EPF_NAME_SIZE ]; +kernel_ulong_t driver_data; +}; +/* spi */ #define SPI_NAME_SIZE 32
include/linux/pci-epc.h new file +142 -0
142 lines not on this page · raw message
include/linux/pci-epf.h new file +160 -0
160 lines not on this page · raw message
Signature · 1 line
2.11.0
Re: [PATCH v6 01/23] PCI: endpoint: Add EP core layer to enable EP controller and EP functions
Quoted 12 lines · Kishon Vijay Abraham I
Introduce a new EP core layer in order to support endpoint functions in linux kernel. This comprises the EPC library (Endpoint Controller Library) and EPF library (Endpoint Function Library). EPC library implements functions specific to an endpoint controller and EPF library implements functions specific to an endpoint function.
...drivers/pci/endpoint/pci-epf-core.c new file +5
-0+/** +* pci_epf_linkup() - Notify the function driver that EPC device has +* established a connection with the Root Complex. +* @epf: the EPF device bound to the EPC device which has established +* the connection with the host
drivers/pci/endpoint/pci-epf-core.c line 45
Quoted 10 lines
drivers/pci/endpoint/pci-epf-core.c new file +10
-0+* +* Invoke to notify the function driver that EPC device has established +* a connection with the Root Complex. +*/ +void pci_epf_linkup (struct pci_epf *epf) +{ +if (!epf->driver) +dev_WARN (&epf->dev,"epf device not bound to driver\n" ); + + epf->driver->ops->linkup (epf);
I don't understand what's going on here. We warn if epf->driver is NULL, but the next thing we do is dereference it.
For NULL pointers that are symptoms of Linux defects, I usually prefer not to check at all so that a dereference generates an oops and we can debug the problem. For NULL pointers caused by user error, we would generally return an error that percolates up to the user.
I haven't competely wrapped my head around this endpoint support, but I assume a NULL pointer here would be caused by user error, not necessarily a Linux defect. So why would we dereference a NULL pointer? And what happens when we do? Is this just going to oops an embedded Linux running inside the endpoint? Is that the correct behavior?
Bjorn
Re: [PATCH v6 01/23] PCI: endpoint: Add EP core layer to enable EP controller and EP functions
Hi Bjorn,
Quoted 32 lines · Bjorn Helgaas
Quoted 12 lines · Kishon Vijay Abraham I
Introduce a new EP core layer in order to support endpoint functions in linux kernel. This comprises the EPC library (Endpoint Controller Library) and EPF library (Endpoint Function Library). EPC library implements functions specific to an endpoint controller and EPF library implements functions specific to an endpoint function.
...drivers/pci/endpoint/pci-epf-core.c new file +5
-0+/** +* pci_epf_linkup() - Notify the function driver that EPC device has +* established a connection with the Root Complex. +* @epf: the EPF device bound to the EPC device which has established +* the connection with the host drivers/pci/endpoint/pci-epf-core.c line 45
Quoted 10 lines
drivers/pci/endpoint/pci-epf-core.c new file +10
-0+* +* Invoke to notify the function driver that EPC device has established +* a connection with the Root Complex. +*/ +void pci_epf_linkup (struct pci_epf *epf) +{ +if (!epf->driver) +dev_WARN (&epf->dev,"epf device not bound to driver\n" ); + + epf->driver->ops->linkup (epf);I don't understand what's going on here. We warn if
epf->driveris NULL, but the next thing we do is dereference it.For NULL pointers that are symptoms of Linux defects, I usually prefer not to check at all so that a dereference generates an oops and we can debug the problem. For NULL pointers caused by user error, we would generally return an error that percolates up to the user.
Quoted 6 lines
I haven't competely wrapped my head around this endpoint support, but I assume a NULL pointer here would be caused by user error, not necessarily a Linux defect. So why would we dereference a NULL pointer? And what happens when we do? Is this just going to oops an embedded Linux running inside the endpoint? Is that the correct behavior?
With the new configfs directory structure, this should be a kernel error. However the EPF layer should be independent of how it's API's are used i.e someone can create a new sysfs/configfs structure and the value of epf->driver might be dependent on user actions.
I think I'd prefer not to dereference NULL pointers since we anyways have a dev_WARN for debug. I'll resend this patch with return if epf->driver is NULL.
Thanks
Kishon
PATCH v6 2/23 Documentation: PCI: Guide to use PCI Endpoint Core Layer
In reply to Kishon Vijay Abraham IAdd Documentation to help users use endpoint library to enable endpoint mode in the PCI controller and add new PCI endpoint functions.
--- Documentation/PCI/00-INDEX | 2 + Documentation/PCI/endpoint/pci-endpoint.txt | 215 ++++++++++++++++++++++++++++ 2 files changed, 217 insertions(+) create mode 100644 Documentation/PCI/endpoint/pci-endpoint.txt
Documentation/PCI/00-INDEX +2 -0
@@ -12,3 +12,5 @@ pci.txt - info on the PCI subsystem for device driver authors pcieaer-howto.txt - the PCI Express Advanced Error Reporting Driver Guide HOWTO +endpoint/pci-endpoint.txt + - guide to add endpoint controller driver and endpoint function driver.
Documentation/PCI/endpoint/pci-endpoint.txt new file +215 -0
215 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v6 3/23 PCI: endpoint: Introduce configfs entry for configuring EP functions
In reply to Kishon Vijay Abraham IIntroduce a new configfs entry to configure the EP function (like configuring the standard configuration header entries) and to bind the EP function with EP controller.
--- drivers/pci/endpoint/Kconfig | 9 + drivers/pci/endpoint/Makefile | 1 + drivers/pci/endpoint/pci-ep-cfs.c | 509 ++++++++++++++++++++++++++++++++++++++ include/linux/pci-ep-cfs.h | 41 +++ 4 files changed, 560 insertions(+) create mode 100644 drivers/pci/endpoint/pci-ep-cfs.c create mode 100644 include/linux/pci-ep-cfs.h
drivers/pci/endpoint/Kconfig +9 -0
@@ -17,4 +17,13 @@ config PCI_ENDPOINT If in doubt, say "N" to disable Endpoint support. +config PCI_ENDPOINT_CONFIGFS + bool "PCI Endpoint Configfs Support" + depends on PCI_ENDPOINT + select CONFIGFS_FS + help + This will enable the configfs entry that can be used to + configure the endpoint function and used to bind the + function with a endpoint controller. + endmenu
drivers/pci/endpoint/Makefile +1 -0
@@ -2,5 +2,6 @@ # Makefile for PCI Endpoint Support # +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
drivers/pci/endpoint/pci-ep-cfs.c new file +509 -0
509 lines not on this page · raw message
include/linux/pci-ep-cfs.h new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v6 4/23 Documentation: PCI: Guide to use PCI endpoint configfs
In reply to Kishon Vijay Abraham IAdd Documentation to help users use PCI endpoint to configure PCI endpoint function and to bind the endpoint function with endpoint controller.
--- Documentation/PCI/00-INDEX | 2 + Documentation/PCI/endpoint/pci-endpoint-cfs.txt | 105 ++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 Documentation/PCI/endpoint/pci-endpoint-cfs.txt
Documentation/PCI/00-INDEX +2 -0
@@ -14,3 +14,5 @@ pcieaer-howto.txt - the PCI Express Advanced Error Reporting Driver Guide HOWTO endpoint/pci-endpoint.txt - guide to add endpoint controller driver and endpoint function driver. +endpoint/pci-endpoint-cfs.txt + - guide to use configfs to configure the PCI endpoint function.
Documentation/PCI/endpoint/pci-endpoint-cfs.txt new file +105 -0
105 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v6 5/23 PCI: endpoint: Create configfs entry for EPC device and EPF driver
In reply to Kishon Vijay Abraham IInvoke APIs provided by pci-ep-cfs to create configfs entry for every EPC device and EPF driver to help users in creating EPF device and binding the EPF device to the EPC device.
--- drivers/pci/endpoint/pci-epc-core.c | 4 ++++ drivers/pci/endpoint/pci-epf-core.c | 4 ++++ include/linux/pci-epc.h | 2 ++ include/linux/pci-epf.h | 2 ++ 4 files changed, 12 insertions(+)
drivers/pci/endpoint/pci-epc-core.c +4 -0
@@ -24,6 +24,7 @@#include <linux/pci-epc.h> #include <linux/pci-epf.h> +#include <linux/pci-ep-cfs.h> static struct class *pci_epc_class;
@@ -441,6 +442,7 @@ EXPORT_SYMBOL_GPL(pci_epc_linkup);*/ void pci_epc_destroy (struct pci_epc *epc) { +pci_ep_cfs_remove_epc_group (epc->group);device_unregister (&epc->dev);kfree (epc); }
@@ -507,6 +509,8 @@ __pci_epc_create(struct device *dev, const struct pci_epc_ops *ops,if (ret) goto put_dev; + epc->group =pci_ep_cfs_add_epc_group (dev_name (dev)); +return epc; put_dev:
drivers/pci/endpoint/pci-epf-core.c +4 -0
@@ -24,6 +24,7 @@#include <linux/pci-epc.h> #include <linux/pci-epf.h> +#include <linux/pci-ep-cfs.h> static struct bus_type pci_epf_bus_type;static struct device_type pci_epf_type;
@@ -143,6 +144,7 @@ EXPORT_SYMBOL_GPL(pci_epf_alloc_space);*/ void pci_epf_unregister_driver (struct pci_epf_driver *driver) { +pci_ep_cfs_remove_epf_group (driver->group);driver_unregister (&driver->driver); }EXPORT_SYMBOL_GPL (pci_epf_unregister_driver);
@@ -172,6 +174,8 @@ int __pci_epf_register_driver(struct pci_epf_driver *driver,if (ret)return ret; + driver->group =pci_ep_cfs_add_epf_group (driver->driver.name); +return 0 ; }EXPORT_SYMBOL_GPL (__pci_epf_register_driver);
include/linux/pci-epc.h +2 -0
@@ -77,6 +77,7 @@ struct pci_epc_mem {* @ops: function pointers for performing endpoint operations * @mem: address space of the endpoint controller * @max_functions: max number of functions that can be configured in this EPC +* @group: configfs group representing the PCI EPC device * @lock: spinlock to protect pci_epc ops */ struct pci_epc {
@@ -85,6 +86,7 @@ struct pci_epc {const struct pci_epc_ops *ops;struct pci_epc_mem *mem;u8 max_functions; +struct config_group *group;/* spinlock to protect against concurrent access of EP controller */ spinlock_t lock; };
include/linux/pci-epf.h +2 -0
@@ -82,6 +82,7 @@ struct pci_epf_ops {* @driver: PCI EPF driver * @ops: set of function pointers for performing EPF operations * @owner: the owner of the module that registers the PCI EPF driver +* @group: configfs group corresponding to the PCI EPF driver * @id_table: identifies EPF devices for probing */ struct pci_epf_driver {
@@ -91,6 +92,7 @@ struct pci_epf_driver {struct device_driver driver;struct pci_epf_ops *ops;struct module *owner; +struct config_group *group;const struct pci_epf_device_id *id_table; };
Signature · 1 line
2.11.0
PATCH v6 6/23 Documentation: PCI: Add specification for the *PCI test* function device
In reply to Kishon Vijay Abraham IAdd specification for the *PCI test* virtual function device. The endpoint function driver and the host PCI driver should be created based on this specification.
--- Documentation/PCI/00-INDEX | 2 + Documentation/PCI/endpoint/pci-test-function.txt | 66 ++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 Documentation/PCI/endpoint/pci-test-function.txt
Documentation/PCI/00-INDEX +2 -0
@@ -16,3 +16,5 @@ endpoint/pci-endpoint.txt - guide to add endpoint controller driver and endpoint function driver. endpoint/pci-endpoint-cfs.txt - guide to use configfs to configure the PCI endpoint function. +endpoint/pci-test-function.txt + - specification of *PCI test* function device.
Documentation/PCI/endpoint/pci-test-function.txt new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v6 7/23 PCI: endpoint: functions: Add an EP function to test PCI
In reply to Kishon Vijay Abraham IAdds a new endpoint function driver (to program the virtual test device) making use of the EP-core library.
--- drivers/pci/endpoint/Kconfig | 2 + drivers/pci/endpoint/Makefile | 2 +- drivers/pci/endpoint/functions/Kconfig | 12 + drivers/pci/endpoint/functions/Makefile | 5 + drivers/pci/endpoint/functions/pci-epf-test.c | 510 ++++++++++++++++++++++++++ 5 files changed, 530 insertions(+), 1 deletion(-) create mode 100644 drivers/pci/endpoint/functions/Kconfig create mode 100644 drivers/pci/endpoint/functions/Makefile create mode 100644 drivers/pci/endpoint/functions/pci-epf-test.c
drivers/pci/endpoint/Kconfig +2 -0
@@ -26,4 +26,6 @@ config PCI_ENDPOINT_CONFIGFS configure the endpoint function and used to bind the function with a endpoint controller. +source "drivers/pci/endpoint/functions/Kconfig" + endmenu
drivers/pci/endpoint/Makefile +1 -1
@@ -4,4 +4,4 @@ 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 + pci-epc-mem.o functions/
drivers/pci/endpoint/functions/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +# +# PCI Endpoint Functions +# + +config PCI_EPF_TEST + tristate "PCI Endpoint Test driver" + depends on PCI_ENDPOINT + help + Enable this configuration option to enable the test driver + for PCI Endpoint. + + If in doubt, say "N" to disable Endpoint test driver.
drivers/pci/endpoint/functions/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for PCI Endpoint Functions +# + +obj-$(CONFIG_PCI_EPF_TEST) += pci-epf-test.o
drivers/pci/endpoint/functions/pci-epf-test.c new file +510 -0
510 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v6 8/23 Documentation: PCI: Add binding documentation for pci-test endpoint function
In reply to Kishon Vijay Abraham IAdd binding documentation for pci-test endpoint function that helps in adding and configuring pci-test endpoint function.
--- Documentation/PCI/00-INDEX | 2 ++ .../PCI/endpoint/function/binding/pci-test.txt | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 Documentation/PCI/endpoint/function/binding/pci-test.txt
Documentation/PCI/00-INDEX +2 -0
@@ -18,3 +18,5 @@ endpoint/pci-endpoint-cfs.txt - guide to use configfs to configure the PCI endpoint function. endpoint/pci-test-function.txt - specification of *PCI test* function device. +endpoint/function/binding/ + - binding documentation for PCI endpoint function
Documentation/PCI/endpoint/function/binding/pci-test.txt new file +17 -0
@@ -0,0 +1,17 @@ +PCI TEST ENDPOINT FUNCTION + +name: Should be "pci_epf_test" to bind to the pci_epf_test driver. + +Configurable Fields: +vendorid : should be 0x104c +deviceid : should be 0xb500 for DRA74x and 0xb501 for DRA72x +revid : don't care +progif_code : don't care +subclass_code : don't care +baseclass_code : should be 0xff +cache_line_size : don't care +subsys_vendor_id : don't care +subsys_id : don't care +interrupt_pin : Should be 1 - INTA, 2 - INTB, 3 - INTC, 4 -INTD +msi_interrupts : Should be 1 to 32 depending on the number of MSI interrupts + to test
Signature · 1 line
2.11.0
PATCH v6 9/23 PCI: dwc: designware: Add EP mode support
In reply to Kishon Vijay Abraham IAdd endpoint mode support to designware driver. This uses the EP Core layer introduced recently to add endpoint mode support. *Any* function driver can now use this designware device in order to achieve the EP functionality.
--- drivers/pci/dwc/Kconfig | 5 + drivers/pci/dwc/Makefile | 1 + drivers/pci/dwc/pcie-designware-ep.c | 342 +++++++++++++++++++++++++++++++++++ drivers/pci/dwc/pcie-designware.c | 125 +++++++++++++ drivers/pci/dwc/pcie-designware.h | 105 +++++++++++ 5 files changed, 578 insertions(+) create mode 100644 drivers/pci/dwc/pcie-designware-ep.c
drivers/pci/dwc/Kconfig +5 -0
@@ -9,6 +9,11 @@ config PCIE_DW_HOST depends on PCI_MSI_IRQ_DOMAIN select PCIE_DW +config PCIE_DW_EP + bool + depends on PCI_ENDPOINT + select PCIE_DW + config PCI_DRA7XX bool "TI DRA7xx PCIe controller" depends on PCI
drivers/pci/dwc/Makefile +1 -0
@@ -1,5 +1,6 @@ obj-$(CONFIG_PCIE_DW) += pcie-designware.o obj-$(CONFIG_PCIE_DW_HOST) += pcie-designware-host.o +obj-$(CONFIG_PCIE_DW_EP) += pcie-designware-ep.o obj-$(CONFIG_PCIE_DW_PLAT) += pcie-designware-plat.o obj-$(CONFIG_PCI_DRA7XX) += pci-dra7xx.o obj-$(CONFIG_PCI_EXYNOS) += pci-exynos.o
drivers/pci/dwc/pcie-designware-ep.c new file +342 -0
342 lines not on this page · raw message
drivers/pci/dwc/pcie-designware.c +125 -0
131 lines not on this page · raw message
drivers/pci/dwc/pcie-designware.h +105 -0
164 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v6 10/23 dt-bindings: PCI: Add DT bindings for PCI designware EP mode
In reply to Kishon Vijay Abraham IAdd device tree binding documentation for PCI designware EP mode.
--- .../devicetree/bindings/pci/designware-pcie.txt | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-)
Documentation/devicetree/bindings/pci/designware-pcie.txt +18 -8
@@ -6,30 +6,40 @@ Required properties: - reg-names: Must be "config" for the PCIe configuration space. (The old way of getting the configuration address space from "ranges" is deprecated and should be avoided.) +- num-lanes: number of lanes to use +RC mode: - #address-cells: set to <3> - #size-cells: set to <2> - device_type: set to "pci" - ranges: ranges for the PCI memory and I/O regions - #interrupt-cells: set to <1> -- interrupt-map-mask and interrupt-map: standard PCI properties - to define the mapping of the PCIe interface to interrupt +- interrupt-map-mask and interrupt-map: standard PCI + properties to define the mapping of the PCIe interface to interrupt numbers. -- num-lanes: number of lanes to use +EP mode: +- num-ib-windows: number of inbound address translation + windows +- num-ob-windows: number of outbound address translation + windows Optional properties: -- num-viewport: number of view ports configured in hardware. If a platform - does not specify it, the driver assumes 2. - num-lanes: number of lanes to use (this property should be specified unless the link is brought already up in BIOS) - reset-gpio: gpio pin number of power good signal -- bus-range: PCI bus numbers covered (it is recommended for new devicetrees to - specify this property, to keep backwards compatibility a range of 0x00-0xff - is assumed if not present) - clocks: Must contain an entry for each entry in clock-names. See ../clocks/clock-bindings.txt for details. - clock-names: Must include the following entries: - "pcie" - "pcie_bus" +RC mode: +- num-viewport: number of view ports configured in + hardware. If a platform does not specify it, the driver assumes 2. +- bus-range: PCI bus numbers covered (it is recommended + for new devicetrees to specify this property, to keep backwards + compatibility a range of 0x00-0xff is assumed if not present) +EP mode: +- max-functions: maximum number of functions that can be + configured Example configuration:
Signature · 1 line
2.11.0
PATCH v6 11/23 PCI: dwc: dra7xx: Facilitate wrapper and MSI interrupts to be enabled independently
In reply to Kishon Vijay Abraham INo functional change. Split dra7xx_pcie_enable_interrupts() into dra7xx_pcie_enable_wrapper_interrupts() and dra7xx_pcie_enable_msi_interrupts() so that wrapper interrupts and MSI interrupts can be enabled independently. This is in preparation for adding EP mode support to dra7xx driver since EP mode doesn't have to enable msi_interrupts.
--- drivers/pci/dwc/pci-dra7xx.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/pci/dwc/pci-dra7xx.c +18 -6
@@ -140,18 +140,30 @@ static int dra7xx_pcie_establish_link(struct dra7xx_pcie *dra7xx)return dw_pcie_wait_for_link (pci); } -static void dra7xx_pcie_enable_interrupts (struct dra7xx_pcie *dra7xx) +static void dra7xx_pcie_enable_msi_interrupts (struct dra7xx_pcie *dra7xx) { -dra7xx_pcie_writel (dra7xx,PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN , - ~INTERRUPTS ); -dra7xx_pcie_writel (dra7xx, -PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MAIN ,INTERRUPTS );dra7xx_pcie_writel (dra7xx,PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI , ~LEG_EP_INTERRUPTS & ~MSI ); -dra7xx_pcie_writel (dra7xx,PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MSI , + +dra7xx_pcie_writel (dra7xx, +PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MSI ,MSI |LEG_EP_INTERRUPTS ); } +static void dra7xx_pcie_enable_wrapper_interrupts (struct dra7xx_pcie *dra7xx) +{ +dra7xx_pcie_writel (dra7xx,PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN , + ~INTERRUPTS ); +dra7xx_pcie_writel (dra7xx,PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MAIN , +INTERRUPTS ); +} + +static void dra7xx_pcie_enable_interrupts (struct dra7xx_pcie *dra7xx) +{ +dra7xx_pcie_enable_wrapper_interrupts (dra7xx); +dra7xx_pcie_enable_msi_interrupts (dra7xx); +} +static void dra7xx_pcie_host_init (struct pcie_port *pp) {struct dw_pcie *pci =to_dw_pcie_from_pp (pp);
Signature · 1 line
2.11.0
PATCH v6 12/23 PCI: dwc: dra7xx: Add EP mode support
In reply to Kishon Vijay Abraham IThe PCIe controller integrated in dra7xx SoCs is capable of operating in endpoint mode. Add endpoint mode support to dra7xx driver.
--- drivers/pci/dwc/Kconfig | 31 +++++- drivers/pci/dwc/Makefile | 4 +- drivers/pci/dwc/pci-dra7xx.c | 197 +++++++++++++++++++++++++++++++++++--- drivers/pci/dwc/pcie-designware.h | 7 ++ 4 files changed, 221 insertions(+), 18 deletions(-)
drivers/pci/dwc/Kconfig +27 -4
@@ -16,14 +16,37 @@ config PCIE_DW_EP config PCI_DRA7XX bool "TI DRA7xx PCIe controller" - depends on PCI + depends on (PCI && PCI_MSI_IRQ_DOMAIN) || PCI_ENDPOINT depends on OF && HAS_IOMEM && TI_PIPE3 + help + Enables support for the PCIe controller in the DRA7xx SoC. There + are two instances of PCIe controller in DRA7xx. This controller can + work either as EP or RC. In order to enable host-specific features + PCI_DRA7XX_HOST must be selected and in order to enable device- + specific features PCI_DRA7XX_EP must be selected. This uses + the Designware core. + +if PCI_DRA7XX + +config PCI_DRA7XX_HOST + bool "PCI DRA7xx Host Mode" + depends on PCI depends on PCI_MSI_IRQ_DOMAIN select PCIE_DW_HOST + default y help - Enables support for the PCIe controller in the DRA7xx SoC. There - are two instances of PCIe controller in DRA7xx. This controller can - act both as EP and RC. This reuses the Designware core. + Enables support for the PCIe controller in the DRA7xx SoC to work in + host mode. + +config PCI_DRA7XX_EP + bool "PCI DRA7xx Endpoint Mode" + depends on PCI_ENDPOINT + select PCIE_DW_EP + help + Enables support for the PCIe controller in the DRA7xx SoC to work in + endpoint mode. + +endif config PCIE_DW_PLAT bool "Platform bus based DesignWare PCIe Controller"
drivers/pci/dwc/Makefile +3 -1
@@ -2,7 +2,9 @@ obj-$(CONFIG_PCIE_DW) += pcie-designware.o obj-$(CONFIG_PCIE_DW_HOST) += pcie-designware-host.o obj-$(CONFIG_PCIE_DW_EP) += pcie-designware-ep.o obj-$(CONFIG_PCIE_DW_PLAT) += pcie-designware-plat.o -obj-$(CONFIG_PCI_DRA7XX) += pci-dra7xx.o +ifneq ($(filter y,$(CONFIG_PCI_DRA7XX_HOST) $(CONFIG_PCI_DRA7XX_EP)),) + obj-$(CONFIG_PCI_DRA7XX) += pci-dra7xx.o +endif obj-$(CONFIG_PCI_EXYNOS) += pci-exynos.o obj-$(CONFIG_PCI_IMX6) += pci-imx6.o obj-$(CONFIG_PCIE_SPEAR13XX) += pcie-spear13xx.o
drivers/pci/dwc/pci-dra7xx.c +184 -13
307 lines not on this page · raw message
drivers/pci/dwc/pcie-designware.h +7 -0
@@ -120,6 +120,13 @@ enum dw_pcie_region_type { DW_PCIE_REGION_OUTBOUND, }; +enum dw_pcie_device_mode { +DW_PCIE_UNKNOWN_TYPE , +DW_PCIE_EP_TYPE , +DW_PCIE_LEG_EP_TYPE , +DW_PCIE_RC_TYPE , +}; +struct dw_pcie_host_ops {int (*rd_own_conf)(struct pcie_port *pp,int where,int size,u32 *val);int (*wr_own_conf)(struct pcie_port *pp,int where,int size,u32 val);
Signature · 1 line
2.11.0
PATCH v6 13/23 dt-bindings: PCI: dra7xx: Add DT bindings for PCI dra7xx EP mode
In reply to Kishon Vijay Abraham IAdd device tree binding documentation for PCI dra7xx EP mode.
--- Documentation/devicetree/bindings/pci/ti-pci.txt | 37 +++++++++++++++++++----- 1 file changed, 30 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/pci/ti-pci.txt +30 -7
@@ -1,17 +1,22 @@ TI PCI Controllers PCIe Designware Controller - - compatible: Should be "ti,dra7-pcie"" - - reg : Two register ranges as listed in the reg-names property - - reg-names : The first entry must be "ti-conf" for the TI specific registers - The second entry must be "rc-dbics" for the designware pcie - registers - The third entry must be "config" for the PCIe configuration space + - compatible: Should be "ti,dra7-pcie" for RC + Should be "ti,dra7-pcie-ep" for EP - phys : list of PHY specifiers (used by generic PHY framework) - phy-names : must be "pcie-phy0", "pcie-phy1", "pcie-phyN".. based on the number of PHYs as specified in *phys* property. - ti,hwmods : Name of the hwmod associated to the pcie, "pcie<X>", where <X> is the instance number of the pcie from the HW spec. + - num-lanes as specified in ../designware-pcie.txt + +HOST MODE +========= + - reg : Two register ranges as listed in the reg-names property + - reg-names : The first entry must be "ti-conf" for the TI specific registers + The second entry must be "rc-dbics" for the DesignWare PCIe + registers + The third entry must be "config" for the PCIe configuration space - interrupts : Two interrupt entries must be specified. The first one is for main interrupt line and the second for MSI interrupt line. - #address-cells,
@@ -19,13 +24,31 @@ PCIe Designware Controller #interrupt-cells, device_type, ranges, - num-lanes, interrupt-map-mask, interrupt-map : as specified in ../designware-pcie.txt +DEVICE MODE +=========== + - reg : Four register ranges as listed in the reg-names property + - reg-names : "ti-conf" for the TI specific registers + "ep_dbics" for the standard configuration registers as + they are locally accessed within the DIF CS space + "ep_dbics2" for the standard configuration registers as + they are locally accessed within the DIF CS2 space + "addr_space" used to map remote RC address space + - interrupts : one interrupt entries must be specified for main interrupt. + - num-ib-windows : number of inbound address translation windows + - num-ob-windows : number of outbound address translation windows + Optional Property: - gpios : Should be added if a gpio line is required to drive PERST# line +NOTE: Two DT nodes may be added for each PCI controller; one for host +mode and another for device mode. So in order for PCI to +work in host mode, EP mode DT node should be disabled and in order to PCI to +work in EP mode, host mode DT node should be disabled. Host mode and EP +mode are mutually exclusive. + Example: axi { compatible = "simple-bus";
Signature · 1 line
2.11.0
PATCH v6 14/23 PCI: dwc: dra7xx: Workaround for errata id i870
In reply to Kishon Vijay Abraham IAccording to errata i870, access to the PCIe slave port that are not 32-bit aligned will result in incorrect mapping to TLP Address and Byte enable fields.
Accessing non 32-bit aligned data causes incorrect data in the target buffer if memcpy is used. Implement the workaround for this errata here.
--- drivers/pci/dwc/pci-dra7xx.c | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
drivers/pci/dwc/pci-dra7xx.c +49 -0
@@ -26,6 +26,8 @@#include <linux/pm_runtime.h> #include <linux/resource.h> #include <linux/types.h> +#include <linux/mfd/syscon.h> +#include <linux/regmap.h> #include "pcie-designware.h"
@@ -528,6 +530,48 @@ static const struct of_device_id of_dra7xx_pcie_match[] = { {}, }; +/* +* dra7xx_pcie_ep_unaligned_memaccess: workaround for AM572x/AM571x Errata i870 +* @dra7xx: the dra7xx device where the workaround should be applied +* +* Access to the PCIe slave port that are not 32-bit aligned will result +* in incorrect mapping to TLP Address and Byte enable fields. Therefore, +* byte and half-word accesses are not possible to byte offset 0x1, 0x2, or +* 0x3. +* +* To avoid this issue set PCIE_SS1_AXI2OCP_LEGACY_MODE_ENABLE to 1. +*/ +static int dra7xx_pcie_ep_unaligned_memaccess (struct device *dev) +{ +int ret; +struct device_node *np = dev->of_node; +struct of_phandle_args args; +struct regmap *regmap; + + regmap =syscon_regmap_lookup_by_phandle (np, +"ti,syscon-unaligned-access" ); +if (IS_ERR (regmap)) { +dev_dbg (dev,"can't get ti,syscon-unaligned-access\n" ); +return -EINVAL ; + } + + ret =of_parse_phandle_with_fixed_args (np,"ti,syscon-unaligned-access" , +2 ,0 , &args); +if (ret) { +dev_err (dev,"failed to parse ti,syscon-unaligned-access\n" ); +return ret; + } + + ret =regmap_update_bits (regmap, args.args[0 ], args.args[1 ], + args.args[1 ]); +if (ret) +dev_err (dev,"failed to enable unaligned access\n" ); + +of_node_put (args.np); + +return ret; +} +static int __init dra7xx_pcie_probe (struct platform_device *pdev) {u32 reg;
@@ -644,6 +688,11 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)case DW_PCIE_EP_TYPE :dra7xx_pcie_writel (dra7xx,PCIECTRL_TI_CONF_DEVICE_TYPE ,DEVICE_TYPE_EP ); + + ret =dra7xx_pcie_ep_unaligned_memaccess (dev); +if (ret) + goto err_gpio; + ret =dra7xx_add_pcie_ep (dra7xx, pdev);if (ret <0 ) goto err_gpio;
Signature · 1 line
2.11.0
PATCH v6 15/23 dt-bindings: PCI: dra7xx: Add DT bindings to enable unaligned access
In reply to Kishon Vijay Abraham IUpdate device tree binding documentation of TI's dra7xx PCI controller to include property for enabling unaligned mem access.
--- Documentation/devicetree/bindings/pci/ti-pci.txt | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/pci/ti-pci.txt +5 -0
@@ -39,6 +39,11 @@ DEVICE MODE - interrupts : one interrupt entries must be specified for main interrupt. - num-ib-windows : number of inbound address translation windows - num-ob-windows : number of outbound address translation windows + - ti,syscon-unaligned-access: phandle to the syscon DT node. The 1st argument + should contain the register offset within syscon + and the 2nd argument should contain the bit field + for setting the bit to enable unaligned + access. Optional Property: - gpios : Should be added if a gpio line is required to drive PERST# line
Signature · 1 line
2.11.0
PATCH v6 16/23 PCI: Add device IDs for DRA74x and DRA72x
In reply to Kishon Vijay Abraham IAdd device IDs for DRA74x and DRA72x devices. These devices have configurable PCI endpoint.
--- include/linux/pci_ids.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/pci_ids.h +2 -0
@@ -862,6 +862,8 @@#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_DRA74x 0xb500 +#define PCI_DEVICE_ID_TI_DRA72x 0xb501#define PCI_VENDOR_ID_SONY 0x104d
Signature · 1 line
2.11.0
PATCH v6 17/23 misc: Add host side PCI driver for PCI test function device
In reply to Kishon Vijay Abraham IAdd PCI endpoint test driver that can verify base address register, legacy interrupt/MSI interrupt and read/write/copy buffers between host and device. The corresponding pci-epf-test function driver should be used on the EP side.
--- drivers/misc/Kconfig | 7 + drivers/misc/Makefile | 1 + drivers/misc/pci_endpoint_test.c | 534 +++++++++++++++++++++++++++++++++++++++ include/uapi/linux/Kbuild | 1 + include/uapi/linux/pcitest.h | 19 ++ 5 files changed, 562 insertions(+) create mode 100644 drivers/misc/pci_endpoint_test.c create mode 100644 include/uapi/linux/pcitest.h
drivers/misc/Kconfig +7 -0
@@ -771,6 +771,13 @@ config PANEL_BOOT_MESSAGE endif # PANEL +config PCI_ENDPOINT_TEST + depends on PCI + tristate "PCI Endpoint Test driver" + ---help--- + Enable this configuration option to enable the host side test driver + for PCI Endpoint. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
@@ -54,6 +54,7 @@ obj-$(CONFIG_ECHO) += echo/ obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o obj-$(CONFIG_CXL_BASE) += cxl/ obj-$(CONFIG_PANEL) += panel.o +obj-$(CONFIG_PCI_ENDPOINT_TEST) += pci_endpoint_test.o lkdtm-$(CONFIG_LKDTM) += lkdtm_core.o lkdtm-$(CONFIG_LKDTM) += lkdtm_bugs.o
drivers/misc/pci_endpoint_test.c new file +534 -0
534 lines not on this page · raw message
include/uapi/linux/Kbuild +1 -0
@@ -333,6 +333,7 @@ header-y += parport.h header-y += patchkey.h header-y += pci.h header-y += pci_regs.h +header-y += pcitest.h header-y += perf_event.h header-y += personality.h header-y += pfkeyv2.h
include/uapi/linux/pcitest.h new file +19 -0
@@ -0,0 +1,19 @@ +/** +* pcitest.h - PCI test uapi defines +* +* Copyright (C) 2017 Texas Instruments +* Author: Kishon Vijay Abraham I <[email protected]> +* +*/ + +#ifndef __UAPI_LINUX_PCITEST_H +#define __UAPI_LINUX_PCITEST_H + +#define PCITEST_BAR _IO('P', 0x1) +#define PCITEST_LEGACY_IRQ _IO('P', 0x2) +#define PCITEST_MSI _IOW('P', 0x3, int) +#define PCITEST_WRITE _IOW('P', 0x4, unsigned long) +#define PCITEST_READ _IOW('P', 0x5, unsigned long) +#define PCITEST_COPY _IOW('P', 0x6, unsigned long) + +#endif /* __UAPI_LINUX_PCITEST_H */
Signature · 1 line
2.11.0
PATCH v6 18/23 Documentation: misc-devices: Add Documentation for pci-endpoint-test driver
In reply to Kishon Vijay Abraham IAdd Documentation for pci-endpoint-test driver.
--- Documentation/misc-devices/pci-endpoint-test.txt | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Documentation/misc-devices/pci-endpoint-test.txt
Documentation/misc-devices/pci-endpoint-test.txt new file +35 -0
@@ -0,0 +1,35 @@ +Driver for PCI Endpoint Test Function + +This driver should be used as a host side driver if the root complex is +connected to a configurable PCI endpoint running *pci_epf_test* function +driver configured according to [1]. + +The "pci_endpoint_test" driver can be used to perform the following tests. + +The PCI driver for the test device performs the following tests + *) verifying addresses programmed in BAR + *) raise legacy IRQ + *) raise MSI IRQ + *) read data + *) write data + *) copy data + +This misc driver creates /dev/pci-endpoint-test.<num> for every +*pci_epf_test* function connected to the root complex and "ioctls" +should be used to perform the above tests. + +ioctl +----- + PCITEST_BAR: Tests the BAR. The number of the BAR to be tested + should be passed as argument. + PCITEST_LEGACY_IRQ: Tests legacy IRQ + PCITEST_MSI: Tests message signalled interrupts. The MSI number + to be tested should be passed as argument. + PCITEST_WRITE: Perform write tests. The size of the buffer should be passed + as argument. + PCITEST_READ: Perform read tests. The size of the buffer should be passed + as argument. + PCITEST_COPY: Perform read tests. The size of the buffer should be passed + as argument. + +[1] -> Documentation/PCI/endpoint/function/binding/pci-test.txt
Signature · 1 line
2.11.0
PATCH v6 19/23 tools: PCI: Add a userspace tool to test PCI endpoint
In reply to Kishon Vijay Abraham IAdd a userspace tool to invoke the ioctls exposed by the PCI endpoint test driver to perform various PCI tests.
--- tools/pci/pcitest.c | 186 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 tools/pci/pcitest.c
tools/pci/pcitest.c new file +186 -0
@@ -0,0 +1,186 @@ +/** +* Userspace PCI Endpoint Test Module +* +* Copyright (C) 2017 Texas Instruments +* Author: Kishon Vijay Abraham I <[email protected]> +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 of +* the License as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <errno.h> +#include <fcntl.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/ioctl.h> +#include <time.h> +#include <unistd.h> + +#include <linux/pcitest.h> + +#define BILLION 1E9 + +static char *result[] = {"NOT OKAY" ,"OKAY" }; + +struct pci_test { +char *device; +char barnum; +bool legacyirq; +unsigned int msinum; +bool read; +bool write; +bool copy; +unsigned long size; +}; + +static int run_test (struct pci_test *test) +{ +long ret; +int fd; +struct timespec start, end; +double time; + + fd =open (test->device,O_RDWR ); +if (fd <0 ) { +perror ("can't open PCI Endpoint Test device" ); +return fd; + } + +if (test->barnum >=0 && test->barnum <=5 ) { + ret =ioctl (fd,PCITEST_BAR , test->barnum); +fprintf (stdout,"BAR%d:\t\t" , test->barnum); +if (ret <0 ) +fprintf (stdout,"TEST FAILED\n" ); +else +fprintf (stdout,"%s\n" , result[ret]); + } + +if (test->legacyirq) { + ret =ioctl (fd,PCITEST_LEGACY_IRQ ,0 ); +fprintf (stdout,"LEGACY IRQ:\t" ); +if (ret <0 ) +fprintf (stdout,"TEST FAILED\n" ); +else +fprintf (stdout,"%s\n" , result[ret]); + } + +if (test->msinum >0 && test->msinum <=32 ) { + ret =ioctl (fd,PCITEST_MSI , test->msinum); +fprintf (stdout,"MSI%d:\t\t" , test->msinum); +if (ret <0 ) +fprintf (stdout,"TEST FAILED\n" ); +else +fprintf (stdout,"%s\n" , result[ret]); + } + +if (test->write) { + ret =ioctl (fd,PCITEST_WRITE , test->size); +fprintf (stdout,"WRITE (%7ld bytes):\t\t" , test->size); +if (ret <0 ) +fprintf (stdout,"TEST FAILED\n" ); +else +fprintf (stdout,"%s\n" , result[ret]); + } + +if (test->read) { + ret =ioctl (fd,PCITEST_READ , test->size); +fprintf (stdout,"READ (%7ld bytes):\t\t" , test->size); +if (ret <0 ) +fprintf (stdout,"TEST FAILED\n" ); +else +fprintf (stdout,"%s\n" , result[ret]); + } + +if (test->copy) { + ret =ioctl (fd,PCITEST_COPY , test->size); +fprintf (stdout,"COPY (%7ld bytes):\t\t" , test->size); +if (ret <0 ) +fprintf (stdout,"TEST FAILED\n" ); +else +fprintf (stdout,"%s\n" , result[ret]); + } + +fflush (stdout); +} + +int main (int argc,char **argv) +{ +int c; +struct pci_test *test; + + test =calloc (1 ,sizeof (*test)); +if (!test) { +perror ("Fail to allocate memory for pci_test\n" ); +return -ENOMEM ; + } + +/* since '0' is a valid BAR number, initialize it to -1 */ + test->barnum =-1 ; + +/* set default size as 100KB */ + test->size =0x19000 ; + +/* set default endpoint device */ + test->device ="/dev/pci-endpoint-test.0" ; + +while ((c =getopt (argc, argv,"D:b:m:lrwcs:" )) !=EOF ) +switch (c) { +case 'D' : + test->device = optarg; +continue ; +case 'b' : + test->barnum =atoi (optarg); +if (test->barnum <0 || test->barnum >5 ) + goto usage; +continue ; +case 'l' : + test->legacyirq = true; +continue ; +case 'm' : + test->msinum =atoi (optarg); +if (test->msinum <1 || test->msinum >32 ) + goto usage; +continue ; +case 'r' : + test->read = true; +continue ; +case 'w' : + test->write = true; +continue ; +case 'c' : + test->copy = true; +continue ; +case 's' : + test->size =strtoul (optarg,NULL ,0 ); +continue ; +case '?' : +case 'h' : +default : +usage: +fprintf (stderr, +"usage: %s [options]\n" +"Options:\n" +"\t-D <dev> PCI endpoint test device {default: /dev/pci-endpoint-test.0}\n" +"\t-b <bar num> BAR test (bar number between 0..5)\n" +"\t-m <msi num> MSI test (msi number between 1..32)\n" +"\t-r Read buffer test\n" +"\t-w Write buffer test\n" +"\t-c Copy buffer test\n" +"\t-s <size> Size of buffer {default: 100KB}\n" , + argv[0 ]); +return -EINVAL ; + } + +run_test (test); +return 0 ; +}
Signature · 1 line
2.11.0
PATCH v6 20/23 tools: PCI: Add sample test script to invoke pcitest
In reply to Kishon Vijay Abraham IAdd a simple test script that invokes the pcitest userspace tool to perform all the PCI endpoint tests (BAR tests, interrupt tests, read tests, write tests and copy tests).
--- tools/pci/pcitest.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tools/pci/pcitest.sh
tools/pci/pcitest.sh new file +56 -0
@@ -0,0 +1,56 @@ +#!/bin/sh + +echo "BAR tests" +echo + +bar=0 + +while [ $bar -lt 6 ] +do + pcitest -b $bar + bar=`expr $bar + 1` +done +echo + +echo "Interrupt tests" +echo + +pcitest -l +msi=1 + +while [ $msi -lt 33 ] +do + pcitest -m $msi + msi=`expr $msi + 1` +done +echo + +echo "Read Tests" +echo + +pcitest -r -s 1 +pcitest -r -s 1024 +pcitest -r -s 1025 +pcitest -r -s 1024000 +pcitest -r -s 1024001 +echo + +echo "Write Tests" +echo + +pcitest -w -s 1 +pcitest -w -s 1024 +pcitest -w -s 1025 +pcitest -w -s 1024000 +pcitest -w -s 1024001 +echo + +echo "Copy Tests" +echo + +pcitest -c -s 1 +pcitest -c -s 1024 +pcitest -c -s 1025 +pcitest -c -s 1024000 +pcitest -c -s 1024001 +echo
Signature · 1 line
2.11.0
PATCH v6 21/23 Documentation: PCI: Add userguide for PCI endpoint test function
In reply to Kishon Vijay Abraham IAdd documentation to help users use pci-epf-test function driver and pci_endpoint_test host driver for testing PCI.
--- Documentation/PCI/00-INDEX | 2 + Documentation/PCI/endpoint/pci-test-howto.txt | 179 ++++++++++++++++++++++++++ 2 files changed, 181 insertions(+) create mode 100644 Documentation/PCI/endpoint/pci-test-howto.txt
Documentation/PCI/00-INDEX +2 -0
@@ -18,5 +18,7 @@ endpoint/pci-endpoint-cfs.txt - guide to use configfs to configure the PCI endpoint function. endpoint/pci-test-function.txt - specification of *PCI test* function device. +endpoint/pci-test-howto.txt + - userguide for PCI endpoint test function. endpoint/function/binding/ - binding documentation for PCI endpoint function
Documentation/PCI/endpoint/pci-test-howto.txt new file +179 -0
179 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v6 22/23 MAINTAINERS: Add PCI Endpoint maintainer
In reply to Kishon Vijay Abraham IAdd maintainer for the newly introduced PCI Endpoint framework.
--- MAINTAINERS | 9 +++++++++ 1 file changed, 9 insertions(+)
MAINTAINERS +9 -0
@@ -9581,6 +9581,15 @@ F: include/linux/pci* F: arch/x86/pci/ F: arch/x86/kernel/quirks.c +PCI ENDPOINT SUBSYSTEM +M: Kishon Vijay Abraham I <[email protected]> +L: linux-pci at vger.kernel.org +T: git git://git.kernel.org/pub/scm/linux/kernel/git/kishon/pci-endpoint.git +S: Supported +F: drivers/pci/endpoint/ +F: drivers/misc/pci_endpoint_test.c +F: tools/pci/ + PCI DRIVER FOR ALTERA PCIE IP M: Ley Foon Tan <[email protected]> L: rfi at lists.rocketboards.org (moderated for non-subscribers)
Signature · 1 line
2.11.0
PATCH v6 23/23 ARM: DRA7: clockdomain: Change the CLKTRCTRL of CM_PCIE_CLKSTCTRL to SW_WKUP
In reply to Kishon Vijay Abraham IThe PCIe programming sequence in TRM suggests CLKSTCTRL of PCIe should be set to SW_WKUP. There are no issues when CLKSTCTRL is set to HW_AUTO in RC mode. However in EP mode, the host system is not able to access the MEMSPACE and setting the CLKSTCTRL to SW_WKUP fixes it.
--- arch/arm/mach-omap2/clockdomains7xx_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-omap2/clockdomains7xx_data.c +1 -1
@@ -524,7 +524,7 @@ static struct clockdomain pcie_7xx_clkdm = { .dep_bit = DRA7XX_PCIE_STATDEP_SHIFT, .wkdep_srcs = pcie_wkup_sleep_deps, .sleepdep_srcs = pcie_wkup_sleep_deps, - .flags = CLKDM_CAN_HWSUP_SWSUP, + .flags = CLKDM_CAN_SWSUP, };static struct clockdomain atl_7xx_clkdm = {
Signature · 1 line
2.11.0
PATCH v7 1/23 PCI: endpoint: Add EP core layer to enable EP controller and EP functions
In reply to Kishon Vijay Abraham IIntroduce a new EP core layer in order to support endpoint functions in linux kernel. This comprises the EPC library (Endpoint Controller Library) and EPF library (Endpoint Function Library). EPC library implements functions specific to an endpoint controller and EPF library implements functions specific to an endpoint function.
---
Changes from v6:
*) Avoid NULL pointer dereferencing errors in pci-epf-core.c *) Fixed few cleanups missing in the error handling path
drivers/Makefile | 2 + drivers/pci/Kconfig | 1 + drivers/pci/endpoint/Kconfig | 20 ++ drivers/pci/endpoint/Makefile | 6 + drivers/pci/endpoint/pci-epc-core.c | 576 ++++++++++++++++++++++++++++++++++++ drivers/pci/endpoint/pci-epc-mem.c | 143 +++++++++ drivers/pci/endpoint/pci-epf-core.c | 355 ++++++++++++++++++++++ include/linux/mod_devicetable.h | 10 + include/linux/pci-epc.h | 142 +++++++++ include/linux/pci-epf.h | 160 ++++++++++ 10 files changed, 1415 insertions(+) create mode 100644 drivers/pci/endpoint/Kconfig create mode 100644 drivers/pci/endpoint/Makefile create mode 100644 drivers/pci/endpoint/pci-epc-core.c create mode 100644 drivers/pci/endpoint/pci-epc-mem.c create mode 100644 drivers/pci/endpoint/pci-epf-core.c create mode 100644 include/linux/pci-epc.h create mode 100644 include/linux/pci-epf.h
drivers/Makefile +2 -0
@@ -14,7 +14,9 @@ obj-$(CONFIG_GENERIC_PHY) += phy/ obj-$(CONFIG_PINCTRL) += pinctrl/ obj-$(CONFIG_GPIOLIB) += gpio/ obj-y += pwm/ + obj-$(CONFIG_PCI) += pci/ +obj-$(CONFIG_PCI_ENDPOINT) += pci/endpoint/ # PCI dwc controller drivers obj-y += pci/dwc/
drivers/pci/Kconfig +1 -0
@@ -134,3 +134,4 @@ config PCI_HYPERV source "drivers/pci/hotplug/Kconfig" source "drivers/pci/dwc/Kconfig" source "drivers/pci/host/Kconfig" +source "drivers/pci/endpoint/Kconfig"
drivers/pci/endpoint/Kconfig new file +20 -0
@@ -0,0 +1,20 @@ +# +# PCI Endpoint Support +# + +menu "PCI Endpoint" + +config PCI_ENDPOINT + bool "PCI Endpoint Support" + help + Enable this configuration option to support configurable PCI + endpoint. This should be enabled if the platform has a PCI + controller that can operate in endpoint mode. + + Enabling this option will build the endpoint library, which + includes endpoint controller library and endpoint function + library. + + If in doubt, say "N" to disable Endpoint support. + +endmenu
drivers/pci/endpoint/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# +# Makefile for PCI Endpoint Support +# + +obj-$(CONFIG_PCI_ENDPOINT) += pci-epc-core.o pci-epf-core.o\ + pci-epc-mem.o
drivers/pci/endpoint/pci-epc-core.c new file +576 -0
576 lines not on this page · raw message
drivers/pci/endpoint/pci-epc-mem.c new file +143 -0
143 lines not on this page · raw message
drivers/pci/endpoint/pci-epf-core.c new file +355 -0
355 lines not on this page · raw message
include/linux/mod_devicetable.h +10 -0
@@ -428,6 +428,16 @@ struct i2c_device_id {kernel_ulong_t driver_data;/* Data private to the driver */ }; +/* pci_epf */ + +#define PCI_EPF_NAME_SIZE 20 +#define PCI_EPF_MODULE_PREFIX "pci_epf:" + +struct pci_epf_device_id { +char name[PCI_EPF_NAME_SIZE ]; +kernel_ulong_t driver_data; +}; +/* spi */ #define SPI_NAME_SIZE 32
include/linux/pci-epc.h new file +142 -0
142 lines not on this page · raw message
include/linux/pci-epf.h new file +160 -0
160 lines not on this page · raw message
Signature · 1 line
2.11.0
Re: [PATCH v7 01/23] PCI: endpoint: Add EP core layer to enable EP controller and EP functions
Quoted 20 lines · Kishon Vijay Abraham I
Introduce a new EP core layer in order to support endpoint functions in linux kernel. This comprises the EPC library (Endpoint Controller Library) and EPF library (Endpoint Function Library). EPC library implements functions specific to an endpoint controller and EPF library implements functions specific to an endpoint function.
drivers/pci/endpoint/pci-epf-core.c new file +14
-0+void *pci_epf_alloc_space (struct pci_epf *epf,size_t size,enum pci_barno bar) +{ +void *space; +struct device *dev = &epf->dev; +dma_addr_t phys_addr; + +if (size <128 ) + size =128 ; + size =roundup_pow_of_two (size); + + space =dma_alloc_coherent (dev, size, &phys_addr,GFP_KERNEL ); +if (!space) { +dev_err (dev,"failed to allocate mem space\n" ); +return NULL ;
drivers/pci/endpoint/pci-epf-core.c
Quoted 10 lines
drivers/pci/endpoint/pci-epf-core.c new file +9
-0+} + +epf->bar[bar].phys_addr = phys_addr; +* struct pci_epf_bar - represents the BAR of EPF device +* @phys_addr: physical address that should be mapped to the BAR +* @size: the size of the address space present in BAR +*/ +struct pci_epf_bar { +dma_addr_t phys_addr;
If this "phys_addr" is an address that can appear on the PCI bus, is "phys_addr" a misnomer? Many drivers use dma, dmabuf, bus_addr, etc.
Bjorn
Quoted 4 lines · Kishon Vijay Abraham I
Hi Bjorn,
Please find the pull request for PCI endpoint support below. I've also included all the history here.
Thanks, I applied these (with v7 of the first patch) to pci/host-designware for v4.12.
Quoted 168 lines
Changes from v5:
*) remove #syscon-cells property added in v5 and used
of_parse_phandle_with_fixed_args
*) fix compilation error in make.cross ARCH=blackfin that was because
pci_endpoint_test.cdriver depends onCOMPILE_TEST.Changes from v4:
*) add #syscon-cells property and usedof_parse_phandle_with_args
to perform a configuration in syscon module (as suggested by Rob Herring)
*) Remove unnecessary white space.Changes from v3:
*) fixed a typo and adapted to https://lkml.org/lkml/2017/3/13/562.Changes from v2:
*) changed the configfs structure as suggested by Christoph Hellwig. With
this change the framework creates configfs entry for EP function driver and EP controller. Previously these entries have to be created by the the user. (Haven't changed the epc core or epf core except for invoking configfs APIs to create entries for EP function driver and EP controller. That's mostly because the EP function device can still be created by directly invoking the epf core API without using configfs).
*) Now the user has to use configfs entry 'start' to start the link.
This was previously done by the function driver. However in the case of multi function EP, the function driver shouldn't start the link.Changes from v1:
*) The preparation patches for adding EP support is removed and is sent
separately
*) Added device ID for DRA74x/DRA72x and used it instead of
using "PCI_ANY_ID"
*) Added userguide for PCI endpoint test functionMajor Improvements from RFC:
*) support multi-function devices (hw supported not virtual) *) Access host side buffers
*) Raise MSI interrupts
*) Add user space program to use the host side PCI driver *) Adapt all other users of designware to use the new design (only
compile tested. Since I have only dra7xx boards, the new design has only been tested in dra7xx. I'd require the help of others to test the platforms they have access to).This is based on
git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
pci/host-designwareThanks
KishonThe following changes since commit
7ea64dcf602c21b3e5062ca90111ca4459fab403:
__end__(2017-04-04 15:29:37 -0500)are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kishon/pci-endpoint.gittags/pci-endpoint-for-4.12for you to fetch changes up to
a5c85ba45c9682456077d7277196e91f8ea5fd5c:ARM: DRA7: clockdomain: Change the CLKTRCTRL of
CM_PCIE_CLKSTCTRLtoSW_WKUP(2017-04-05 14:05:28 +0530)----------------------------------------------------------------
pci: endpoint: for 4.12*) Add PCI endpoint core layer
*) Modify designware and dra7xx driver to be configured in EP mode *) Add a PCI endpoint *test* function driver and corresponding host
driverSigned-off-by Kishon Vijay Abraham I <[email protected]>----------------------------------------------------------------
Kishon Vijay Abraham I (23):
PCI: endpoint: Add EP core layer to enable EP controller and EP functions
Documentation: PCI: Guide to use PCI Endpoint Core Layer
PCI: endpoint: Introduce configfs entry for configuring EP functions
Documentation: PCI: Guide to use PCI endpoint configfs
PCI: endpoint: Create configfs entry for EPC device and EPF driver
Documentation: PCI: Add specification for the *PCI test* function device
PCI: endpoint: functions: Add an EP function to test PCI
Documentation: PCI: Add binding documentation for pci-test endpoint function
PCI: dwc: designware: Add EP mode support
dt-bindings: PCI: Add DT bindings for PCI designware EP mode
PCI: dwc: dra7xx: Facilitate wrapper and MSI interrupts to be enabled independently
PCI: dwc: dra7xx: Add EP mode support
dt-bindings: PCI: dra7xx: Add DT bindings for PCI dra7xx EP mode
PCI: dwc: dra7xx: Workaround for errata id i870
dt-bindings: PCI: dra7xx: Add DT bindings to enable unaligned access
PCI: Add device IDs for DRA74x and DRA72x
misc: Add host side PCI driver for PCI test function device
Documentation: misc-devices: Add Documentation for pci-endpoint-test driver
tools: PCI: Add a userspace tool to test PCI endpoint
tools: PCI: Add sample test script to invoke pcitest
Documentation: PCI: Add userguide for PCI endpoint test function
MAINTAINERS: Add PCI Endpoint maintainer
ARM: DRA7: clockdomain: Change the CLKTRCTRL ofCM_PCIE_CLKSTCTRLtoSW_WKUPDocumentation/PCI/00-INDEX | 10 +++ Documentation/PCI/endpoint/function/binding/pci-test.txt | 17 +++++ Documentation/PCI/endpoint/pci-endpoint-cfs.txt | 105 ++++++++++++++++++++++++++ Documentation/PCI/endpoint/pci-endpoint.txt | 215 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Documentation/PCI/endpoint/pci-test-function.txt | 66 ++++++++++++++++ Documentation/PCI/endpoint/pci-test-howto.txt | 179 +++++++++++++++++++++++++++++++++++++++++++ Documentation/devicetree/bindings/pci/designware-pcie.txt | 26 +++++-- Documentation/devicetree/bindings/pci/ti-pci.txt | 42 +++++++++-- Documentation/misc-devices/pci-endpoint-test.txt | 35 +++++++++ MAINTAINERS | 9 +++ arch/arm/mach-omap2/clockdomains7xx_data.c | 2 +- drivers/Makefile | 2 + drivers/misc/Kconfig | 7 ++ drivers/misc/Makefile | 1 + drivers/misc/pci_endpoint_test.c | 534 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/Kconfig | 1 + drivers/pci/dwc/Kconfig | 36 ++++++++- drivers/pci/dwc/Makefile | 5 +- drivers/pci/dwc/pci-dra7xx.c | 270 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- drivers/pci/dwc/pcie-designware-ep.c | 342 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/dwc/pcie-designware.c | 125 ++++++++++++++++++++++++++++++ drivers/pci/dwc/pcie-designware.h | 112 +++++++++++++++++++++++++++ drivers/pci/endpoint/Kconfig | 31 ++++++++ drivers/pci/endpoint/Makefile | 7 ++ drivers/pci/endpoint/functions/Kconfig | 12 +++ drivers/pci/endpoint/functions/Makefile | 5 ++ drivers/pci/endpoint/functions/pci-epf-test.c | 510 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/endpoint/pci-ep-cfs.c | 509 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/endpoint/pci-epc-core.c | 579 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/endpoint/pci-epc-mem.c | 143 +++++++++++++++++++++++++++++++++++ drivers/pci/endpoint/pci-epf-core.c | 351 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mod_devicetable.h | 10 +++ include/linux/pci-ep-cfs.h | 41 ++++++++++ include/linux/pci-epc.h | 144 +++++++++++++++++++++++++++++++++++ include/linux/pci-epf.h | 162 +++++++++++++++++++++++++++++++++++++++ include/linux/pci_ids.h | 2 + include/uapi/linux/Kbuild | 1 + include/uapi/linux/pcitest.h | 19 +++++ tools/pci/pcitest.c | 186 +++++++++++++++++++++++++++++++++++++++++++++ tools/pci/pcitest.sh | 56 ++++++++++++++ 40 files changed, 4869 insertions(+), 40 deletions(-) create mode 100644 Documentation/PCI/endpoint/function/binding/pci-test.txt create mode 100644 Documentation/PCI/endpoint/pci-endpoint-cfs.txt create mode 100644 Documentation/PCI/endpoint/pci-endpoint.txt create mode 100644 Documentation/PCI/endpoint/pci-test-function.txt create mode 100644 Documentation/PCI/endpoint/pci-test-howto.txt create mode 100644 Documentation/misc-devices/pci-endpoint-test.txt create mode 100644 drivers/misc/pci_endpoint_test.c create mode 100644 drivers/pci/dwc/pcie-designware-ep.c create mode 100644 drivers/pci/endpoint/Kconfig create mode 100644 drivers/pci/endpoint/Makefile create mode 100644 drivers/pci/endpoint/functions/Kconfig create mode 100644 drivers/pci/endpoint/functions/Makefile create mode 100644 drivers/pci/endpoint/functions/pci-epf-test.c create mode 100644 drivers/pci/endpoint/pci-ep-cfs.c create mode 100644 drivers/pci/endpoint/pci-epc-core.c create mode 100644 drivers/pci/endpoint/pci-epc-mem.c create mode 100644 drivers/pci/endpoint/pci-epf-core.c create mode 100644 include/linux/pci-ep-cfs.h create mode 100644 include/linux/pci-epc.h create mode 100644 include/linux/pci-epf.h create mode 100644 include/uapi/linux/pcitest.h create mode 100644 tools/pci/pcitest.c create mode 100644 tools/pci/pcitest.sh_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 8 lines · Bjorn Helgaas
Quoted 4 lines · Kishon Vijay Abraham I
Hi Bjorn,
Please find the pull request for PCI endpoint support below. I've also included all the history here.
Thanks, I applied these (with v7 of the first patch) to pci/host-designware for v4.12.
Ok, sorry, I screwed this up. I think my branch actually had v5, not v6. But I *think* I fixed it. Here's the diff from my branch to your git tree. Apparently you haven't pushed the v7 patch there, so I *think* the diff below is the diff between v6 and v7 of that first patch.
$ git diff pci/host-designware a5c85ba45c96
drivers/pci/endpoint/pci-epc-core.c +0 -1
@@ -83,7 +83,6 @@ struct pci_epc *pci_epc_get(const char *epc_name) goto err; } -class_dev_iter_exit (&iter);get_device (&epc->dev);return epc; }
drivers/pci/endpoint/pci-epf-core.c +4 -12
@@ -40,10 +40,8 @@ static struct device_type pci_epf_type;*/ void pci_epf_linkup (struct pci_epf *epf) { -if (!epf->driver) { +if (!epf->driver)dev_WARN (&epf->dev,"epf device not bound to driver\n" ); -return ; - } epf->driver->ops->linkup (epf); }
@@ -59,10 +57,8 @@ EXPORT_SYMBOL_GPL(pci_epf_linkup);*/ void pci_epf_unbind (struct pci_epf *epf) { -if (!epf->driver) { +if (!epf->driver)dev_WARN (&epf->dev,"epf device not bound to driver\n" ); -return ; - } epf->driver->ops->unbind (epf);module_put (epf->driver->owner);
@@ -78,10 +74,8 @@ EXPORT_SYMBOL_GPL(pci_epf_unbind);*/ int pci_epf_bind (struct pci_epf *epf) { -if (!epf->driver) { +if (!epf->driver)dev_WARN (&epf->dev,"epf device not bound to driver\n" ); -return -EINVAL ; - }if (!try_module_get (epf->driver->owner))return -EAGAIN ;
@@ -233,7 +227,7 @@ struct pci_epf *pci_epf_create(const char *name) epf->name =kstrdup (func_name,GFP_KERNEL );if (!epf->name) { ret = -ENOMEM ; - goto free_func_name; + goto free_epf; } dev = &epf->dev;
@@ -255,8 +249,6 @@ struct pci_epf *pci_epf_create(const char *name) put_dev:put_device (dev);kfree (epf->name); - -free_func_name:kfree (func_name); free_epf:
Hi Bjorn,
Quoted 7 lines · Bjorn Helgaas
Quoted 6 lines · Bjorn Helgaas
Quoted 4 lines · Kishon Vijay Abraham I
Hi Bjorn,
Please find the pull request for PCI endpoint support below. I've also included all the history here.
Quoted 8 lines
Quoted 2 lines
Thanks, I applied these (with v7 of the first patch) to pci/host-designware for v4.12.
Ok, sorry, I screwed this up. I think my branch actually had v5, not v6. But I *think* I fixed it. Here's the diff from my branch to your git tree. Apparently you haven't pushed the v7 patch there, so I *think* the diff below is the diff between v6 and v7 of that first patch.
I just checked your pci/host-designware branch and it looks correct. Thanks for sorting this out.
Cheers
Kishon