add support for CDX bus
Subsystems (4)
Nipun Gupta
maintainerv6 cover add support for CDX bus
Introduces AMD CDX bus, which provides a mechanism to discover/rescan CDX devices. The CDX devices are memory mapped on system bus for embedded CPUs.
CDX controller interacts with the firmware to query different CDX devices present in the Fabric and expose them to the Linux host on CDX bus.
This patch series:
- Introduces the CDX bus and CDX devices.
- Device tree binding for CDX controller
- Support for CDX bus in arm-smmu-v3 driver
- Add MCDI (Management CPU Driver Interface) as a protocol for communication with RPU Firmware
- Support RPMSg channel for Firmware communication
After RFC v4 we sent out v1 (non-RFC) which was meant to be v5. This non-RFC patch is at:
https://lore.kernel.org/lkml/[email protected]/T/
Sending this series as a v6 now.
Changes v5 -> v6
- updated compatible name in the CDX dt-binding
- updated reset CDX device and removed redundant function
- moved from drivers/bus/cdx to drivers/cdx
- used xarray instead of controller list and ID
- updated sysfs documentation with more details
Changes RFC v4 -> v5
- Fixed device tree documentation
- Add MCDI as a protocol and RPMsg as transport for communication with RPU Firmware instead of using MCDI stubs.
- MSI patches for CDX are not added in this series as it's support is being revisited as per patch series:
https://lore.kernel.org/all/[email protected]/
It will be added as separate patches.
Changes RFC v3 -> RFC v4:
- Separate CDX bus and CDX controller driver (Greg K-H)
- Added MSI interfacing to Firmware for writing MSI message to firmware so it can be provided to the device.
- Fix MSI review comments - multiple cleanups (Mark Zynger)
- Fix the device tree yaml compilation (Rob Herring, Krzysztof)
- removed vfio-cdx from this series. It will be added after bus support is complete (Jason)
Changes RFC v2 -> RFC v3:
- Move CDX bus as a new bus type in kernel rather than using the platform devices (Greg K-H, Marc Zynger)
- Correspondingly update ARM SMMU v3
- Add support for vfio-cdx driver
- Updated device tree yaml with correct binding information (Krzysztof Kozlowski)
- remove 'compatible' sysfs platform patch which was required for CDX devices exposed as platform devices
Changes RFC v1 -> RFC v2:
- introduce CDX bus infrastructure
- fixed code for making compatible visible for devices having the 'compatible' property only (Greg K-H)
- moved CDX-MSI domain as part of CDX bus infrastructure. previously it was part of irqchip (Marc Zynger).
- fixed few prints (Greg K-H)
- support rescan and reset of CDX bus
- add VFIO reset module for CDX bus based devices
Abhijit Gangurde (1):
cdx: add rpmsg communication channel for CDX
Nipun Gupta (6):
cdx: add the cdx bus driver
iommu/arm-smmu-v3: support ops registration for CDX bus
dt-bindings: bus: add CDX bus controller for versal net
cdx: add MCDI protocol interface for firmware interaction
cdx: add cdx controller
cdx: add device attributes
Documentation/ABI/testing/sysfs-bus-cdx | 79 ++ .../bindings/bus/xlnx,versal-net-cdx.yaml | 68 ++ MAINTAINERS | 8 + drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/cdx/Kconfig | 18 + drivers/cdx/Makefile | 8 + drivers/cdx/cdx.c | 553 +++++++++++ drivers/cdx/cdx.h | 62 ++ drivers/cdx/controller/Kconfig | 30 + drivers/cdx/controller/Makefile | 9 + drivers/cdx/controller/bitfield.h | 88 ++ drivers/cdx/controller/cdx_controller.c | 229 +++++ drivers/cdx/controller/cdx_controller.h | 30 + drivers/cdx/controller/cdx_rpmsg.c | 202 ++++ drivers/cdx/controller/mc_cdx_pcol.h | 590 +++++++++++ drivers/cdx/controller/mcdi.c | 913 ++++++++++++++++++ drivers/cdx/controller/mcdi.h | 247 +++++ drivers/cdx/controller/mcdi_functions.c | 139 +++ drivers/cdx/controller/mcdi_functions.h | 61 ++ drivers/iommu/iommu.c | 4 + include/linux/cdx/cdx_bus.h | 174 ++++ include/linux/mod_devicetable.h | 15 + scripts/mod/devicetable-offsets.c | 4 + scripts/mod/file2alias.c | 12 + 25 files changed, 3546 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-cdx create mode 100644 Documentation/devicetree/bindings/bus/xlnx,versal-net-cdx.yaml create mode 100644 drivers/cdx/Kconfig create mode 100644 drivers/cdx/Makefile create mode 100644 drivers/cdx/cdx.c create mode 100644 drivers/cdx/cdx.h create mode 100644 drivers/cdx/controller/Kconfig create mode 100644 drivers/cdx/controller/Makefile create mode 100644 drivers/cdx/controller/bitfield.h create mode 100644 drivers/cdx/controller/cdx_controller.c create mode 100644 drivers/cdx/controller/cdx_controller.h create mode 100644 drivers/cdx/controller/cdx_rpmsg.c create mode 100644 drivers/cdx/controller/mc_cdx_pcol.h create mode 100644 drivers/cdx/controller/mcdi.c create mode 100644 drivers/cdx/controller/mcdi.h create mode 100644 drivers/cdx/controller/mcdi_functions.c create mode 100644 drivers/cdx/controller/mcdi_functions.h create mode 100644 include/linux/cdx/cdx_bus.h
Signature · 1 line
2.17.1
Nipun Gupta
maintainerPATCH v6 1/7 cdx: add the cdx bus driver
Introduce AMD CDX bus, which provides a mechanism for scanning and probing CDX devices. These devices are memory mapped on system bus for Application Processors(APUs).
CDX devices can be changed dynamically in the Fabric and CDX bus interacts with CDX controller to rescan the bus and rediscover the devices.
---
CDX bus module is kept as bool and not as a tristate as IOMMU does not support buses with module compilation. Buses are provided to IOMMU at compile time only.
Documentation/ABI/testing/sysfs-bus-cdx | 12 + MAINTAINERS | 7 + drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/cdx/Kconfig | 16 + drivers/cdx/Makefile | 8 + drivers/cdx/cdx.c | 408 ++++++++++++++++++++++++ drivers/cdx/cdx.h | 62 ++++ include/linux/cdx/cdx_bus.h | 147 +++++++++ include/linux/mod_devicetable.h | 15 + scripts/mod/devicetable-offsets.c | 4 + scripts/mod/file2alias.c | 12 + 12 files changed, 694 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-cdx create mode 100644 drivers/cdx/Kconfig create mode 100644 drivers/cdx/Makefile create mode 100644 drivers/cdx/cdx.c create mode 100644 drivers/cdx/cdx.h create mode 100644 include/linux/cdx/cdx_bus.h
Documentation/ABI/testing/sysfs-bus-cdx new file +12 -0
@@ -0,0 +1,12 @@ +What: /sys/bus/cdx/rescan +Date: January 2023 +Contact: [email protected] +Description: + Writing a non-zero value to this file would cause rescan + of the bus and devices on the CDX bus. Any new devices would + be scanned and added to the list of linux devices and any + devices removed are also deleted from linux. + + For example:: + + # echo 1 > /sys/bus/cdx/rescan
MAINTAINERS +7 -0
@@ -964,6 +964,13 @@ Q: https://patchwork.kernel.org/project/linux-rdma/list/ F: drivers/infiniband/hw/efa/ F: include/uapi/rdma/efa-abi.h +AMD CDX BUS DRIVER +M: Nipun Gupta <[email protected]> +M: Nikhil Agarwal <[email protected]> +S: Maintained +F: drivers/cdx/* +F: include/linux/cdx/* + AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER M: Tom Lendacky <[email protected]> M: John Allen <[email protected]>
drivers/Kconfig +2 -0
@@ -241,4 +241,6 @@ source "drivers/peci/Kconfig" source "drivers/hte/Kconfig" +source "drivers/cdx/Kconfig" + endmenu
drivers/Makefile +1 -0
@@ -190,3 +190,4 @@ obj-$(CONFIG_MOST) += most/ obj-$(CONFIG_PECI) += peci/ obj-$(CONFIG_HTE) += hte/ obj-$(CONFIG_DRM_ACCEL) += accel/ +obj-$(CONFIG_CDX_BUS) += cdx/
drivers/cdx/Kconfig new file +16 -0
@@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# CDX bus configuration +# +# Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +# + +config CDX_BUS + bool "CDX Bus driver" + help + Driver to enable Composable DMA Transfer(CDX) Bus. CDX bus + exposes Fabric devices which uses composable DMA IP to the + APU. CDX bus provides a mechanism for scanning and probing + of CDX devices. CDX devices are memory mapped on system bus + for embedded CPUs. CDX bus uses CDX controller and firmware + to scan these CDX devices.
drivers/cdx/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for CDX +# +# Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +# + +obj-$(CONFIG_CDX_BUS) += cdx.o
drivers/cdx/cdx.c new file +408 -0
408 lines not on this page · raw message
drivers/cdx/cdx.h new file +62 -0
62 lines not on this page · raw message
include/linux/cdx/cdx_bus.h new file +147 -0
147 lines not on this page · raw message
include/linux/mod_devicetable.h +15 -0
@@ -911,4 +911,19 @@ struct ishtp_device_id { kernel_ulong_t driver_data; }; +/** +* struct cdx_device_id - CDX device identifier +* @vendor: Vendor ID +* @device: Device ID +* @override_only: Match only when dev->driver_override is this driver. +* +* Type of entries in the "device Id" table for CDX devices supported by +* a CDX device driver. +*/ +struct cdx_device_id { +__u16 vendor; +__u16 device; +__u32 override_only; +}; +#endif /* LINUX_MOD_DEVICETABLE_H */
scripts/mod/devicetable-offsets.c +4 -0
@@ -262,5 +262,9 @@ int main(void)DEVID (ishtp_device_id);DEVID_FIELD (ishtp_device_id, guid); +DEVID (cdx_device_id); +DEVID_FIELD (cdx_device_id, vendor); +DEVID_FIELD (cdx_device_id, device); +return 0 ; }
scripts/mod/file2alias.c +12 -0
@@ -1452,6 +1452,17 @@ static int do_dfl_entry(const char *filename, void *symval, char *alias)return 1 ; } +/* Looks like: cdx:vNdN */ +static int do_cdx_entry (const char *filename,void *symval, +char *alias) +{ +DEF_FIELD (symval, cdx_device_id, vendor); +DEF_FIELD (symval, cdx_device_id, device); + +sprintf (alias,"cdx:v%08Xd%08Xd" , vendor, device); +return 1 ; +} +/* Does namelen bytes of name exactly match the symbol? */ static bool sym_is (const char *name,unsigned namelen,const char *symbol) {
@@ -1531,6 +1542,7 @@ static const struct devtable devtable[] = { {"ssam", SIZE_ssam_device_id, do_ssam_entry}, {"dfl", SIZE_dfl_device_id, do_dfl_entry}, {"ishtp", SIZE_ishtp_device_id, do_ishtp_entry}, + {"cdx", SIZE_cdx_device_id, do_cdx_entry}, };/* Create MODULE_ALIAS() statements.
Signature · 1 line
2.17.1
Re: [PATCH v6 1/7] cdx: add the cdx bus driver
Better as:
Documentation/ABI/testing/sysfs-bus-cdx line 4
Quoted 10 lines · Nipun Gupta
Documentation/ABI/testing/sysfs-bus-cdx new file +4
-0@@ -0,0 +1,12 @@ +What: /sys/bus/cdx/rescan +Date: January 2023 +Contact: [email protected] +Description:
(also capitalize Linux)
Writing a non-zero value to this file causes rescan of the bus and devices on the CDX bus. Any new devices are scanned and added to the list of Linux devices and any devices removed are also deleted from Linux.
Quoted 4 lines
Documentation/ABI/testing/sysfs-bus-cdx new file +4
-0+ + For example:: + + # echo 1 > /sys/bus/cdx/rescan
Signature · 1 line
~Randy
Nipun Gupta
maintainerPATCH v6 2/7 iommu/arm-smmu-v3: support ops registration for CDX bus
In reply to Nipun GuptaWith new CDX bus supported for AMD FPGA devices on ARM platform, the bus requires registration for the SMMU v3 driver.
--- drivers/iommu/iommu.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/iommu/iommu.c +4 -0
@@ -28,6 +28,7 @@#include <linux/fsl/mc.h> #include <linux/module.h> #include <linux/cc_platform.h> +#include <linux/cdx/cdx_bus.h> #include <trace/events/iommu.h> #include <linux/sched/mm.h> #include <linux/msi.h>
@@ -129,6 +130,9 @@ static struct bus_type * const iommu_buses[] = {#ifdef CONFIG_TEGRA_HOST1X_CONTEXT_BUS &host1x_context_device_bus_type,#endif +#ifdef CONFIG_CDX_BUS + &cdx_bus_type, +#endif };/*
Signature · 1 line
2.17.1
Nipun Gupta
maintainerPATCH v6 3/7 dt-bindings: bus: add CDX bus controller for versal net
In reply to Nipun GuptaAdd CDX bus controller device tree bindings for versal-net devices.
--- .../bindings/bus/xlnx,versal-net-cdx.yaml | 68 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/bus/xlnx,versal-net-cdx.yaml
Documentation/devicetree/bindings/bus/xlnx,versal-net-cdx.yaml new file +68 -0
@@ -0,0 +1,68 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/bus/xlnx,versal-net-cdx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: AMD CDX bus controller + +description: | + CDX bus controller for AMD devices is implemented to dynamically + detect CDX bus and devices on these bus using the firmware. + The CDX bus manages multiple FPGA based hardware devices, which + can support network, crypto or any other specialized type of + devices. These FPGA based devices can be added/modified dynamically + on run-time. + + All devices on the CDX bus will have a unique streamid (for IOMMU) + and a unique device ID (for MSI) corresponding to a requestor ID + (one to one associated with the device). The streamid and deviceid + are used to configure SMMU and GIC-ITS respectively. + + iommu-map property is used to define the set of stream ids + corresponding to each device and the associated IOMMU. + + The MSI writes are accompanied by sideband data (Device ID). + The msi-map property is used to associate the devices with the + device ID as well as the associated ITS controller. + + rproc property (xlnx,rproc) is used to identify the remote processor + with which APU (Application Processor Unit) interacts to find out + the bus and device configuration. + +maintainers: + - Nipun Gupta <[email protected]> + - Nikhil Agarwal <[email protected]> + +properties: + compatible: + const: xlnx,versal-net-cdx + + iommu-map: true + + msi-map: true + + xlnx,rproc: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle to the remoteproc_r5 rproc node using which APU interacts + with remote processor. + +required: + - compatible + - iommu-map + - msi-map + - xlnx,rproc + +additionalProperties: false + +examples: + - | + cdx { + compatible = "xlnx,versal-net-cdx"; + /* define map for RIDs 250-259 */ + iommu-map = <250 &smmu 250 10>; + /* define msi map for RIDs 250-259 */ + msi-map = <250 &its 250 10>; + xlnx,rproc = <&remoteproc_r5>; + };
MAINTAINERS +1 -0
@@ -968,6 +968,7 @@ AMD CDX BUS DRIVER M: Nipun Gupta <[email protected]> M: Nikhil Agarwal <[email protected]> S: Maintained +F: Documentation/devicetree/bindings/bus/xlnx,versal-net-cdx.yaml F: drivers/cdx/* F: include/linux/cdx/*
Signature · 1 line
2.17.1
Nipun Gupta
maintainerPATCH v6 4/7 cdx: add MCDI protocol interface for firmware interaction
In reply to Nipun GuptaThe MCDI (Management CPU Driver Interface) is used as a protocol to communicate with the RPU firmware. It has pre-defined set of messages for different message exchanges between APU and RPU.
--- drivers/cdx/Kconfig | 2 + drivers/cdx/Makefile | 2 +- drivers/cdx/controller/Kconfig | 20 + drivers/cdx/controller/Makefile | 9 + drivers/cdx/controller/bitfield.h | 88 +++ drivers/cdx/controller/mc_cdx_pcol.h | 590 +++++++++++++++++ drivers/cdx/controller/mcdi.c | 913 +++++++++++++++++++++++++++ drivers/cdx/controller/mcdi.h | 238 +++++++ 8 files changed, 1861 insertions(+), 1 deletion(-) create mode 100644 drivers/cdx/controller/Kconfig create mode 100644 drivers/cdx/controller/Makefile create mode 100644 drivers/cdx/controller/bitfield.h create mode 100644 drivers/cdx/controller/mc_cdx_pcol.h create mode 100644 drivers/cdx/controller/mcdi.c create mode 100644 drivers/cdx/controller/mcdi.h
drivers/cdx/Kconfig +2 -0
@@ -14,3 +14,5 @@ config CDX_BUS of CDX devices. CDX devices are memory mapped on system bus for embedded CPUs. CDX bus uses CDX controller and firmware to scan these CDX devices. + +source "drivers/cdx/controller/Kconfig"
drivers/cdx/Makefile +1 -1
@@ -5,4 +5,4 @@ # Copyright (C) 2022-2023, Advanced Micro Devices, Inc. # -obj-$(CONFIG_CDX_BUS) += cdx.o +obj-$(CONFIG_CDX_BUS) += cdx.o controller/
drivers/cdx/controller/Kconfig new file +20 -0
@@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# CDX controller configuration +# +# Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +# + +if CDX_BUS + +config MCDI_LOGGING + bool "MCDI Logging for the CDX controller" + depends on CDX_CONTROLLER + help + Enable MCDI Logging for + the CDX Controller for debug + purpose. + + If unsure, say N. + +endif
drivers/cdx/controller/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Makefile for CDX controller drivers +# +# Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +# + +obj-$(CONFIG_CDX_CONTROLLER) += cdx-controller.o +cdx-controller-objs := mcdi.o
drivers/cdx/controller/bitfield.h new file +88 -0
88 lines not on this page · raw message
drivers/cdx/controller/mc_cdx_pcol.h new file +590 -0
590 lines not on this page · raw message
drivers/cdx/controller/mcdi.c new file +913 -0
913 lines not on this page · raw message
drivers/cdx/controller/mcdi.h new file +238 -0
238 lines not on this page · raw message
Signature · 1 line
2.17.1
kernel test robot
build botRe: [PATCH v6 4/7] cdx: add MCDI protocol interface for firmware interaction
I love your patch! Perhaps something to improve:
Hi Nipun,
I love your patch! Perhaps something to improve:
[auto build test WARNING on next-20230127]
[cannot apply to masahiroy-kbuild/for-next masahiroy-kbuild/fixes robh/for-next joro-iommu/next linus/master v6.2-rc5 v6.2-rc4 v6.2-rc3 v6.2-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Nipun-Gupta/cdx-add-the-cdx-bus-driver/20230128-161622 patch link: https://lore.kernel.org/r/20230126104630.15493-5-nipun.gupta%40amd.com patch subject: [PATCH v6 4/7] cdx: add MCDI protocol interface for firmware interaction
reproduce:
make versioncheck
If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <[email protected]>
versioncheck warnings: (new ones prefixed by >>)
INFO PATH=/opt/cross/clang/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
/usr/bin/timeout -k 100 3h /usr/bin/make W=1 --keep-going HOSTCC=gcc-11 CC=gcc-11 -j32 ARCH=x86_64 versioncheck find ./* \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -o \
-name '*.[hcS]' -type f -print | sort \
| xargs perl -w ./scripts/checkversion.pl
./drivers/accessibility/speakup/genmap.c: 13 linux/version.h not needed. ./drivers/accessibility/speakup/makemapdata.c: 13 linux/version.h not needed.
>> ./drivers/cdx/controller/mcdi.c: 20 linux/version.h not needed.
./drivers/net/ethernet/qlogic/qede/qede.h: 10 linux/version.h not needed. ./drivers/net/ethernet/qlogic/qede/qede_ethtool.c: 7 linux/version.h not needed. ./drivers/scsi/cxgbi/libcxgbi.h: 27 linux/version.h not needed. ./drivers/scsi/mpi3mr/mpi3mr.h: 32 linux/version.h not needed. ./drivers/scsi/qedi/qedi_dbg.h: 14 linux/version.h not needed. ./drivers/soc/tegra/cbb/tegra-cbb.c: 19 linux/version.h not needed. ./drivers/soc/tegra/cbb/tegra194-cbb.c: 26 linux/version.h not needed. ./drivers/soc/tegra/cbb/tegra234-cbb.c: 27 linux/version.h not needed. ./drivers/staging/media/atomisp/include/linux/atomisp.h: 23 linux/version.h not needed. ./samples/trace_events/trace_custom_sched.c: 11 linux/version.h not needed. ./sound/soc/codecs/cs42l42.c: 14 linux/version.h not needed. ./tools/lib/bpf/bpf_helpers.h: 289: need linux/version.h ./tools/perf/tests/bpf-script-example.c: 60: need linux/version.h ./tools/perf/tests/bpf-script-test-kbuild.c: 21: need linux/version.h ./tools/perf/tests/bpf-script-test-prologue.c: 49: need linux/version.h ./tools/perf/tests/bpf-script-test-relocation.c: 51: need linux/version.h ./tools/testing/selftests/bpf/progs/dev_cgroup.c: 9 linux/version.h not needed. ./tools/testing/selftests/bpf/progs/netcnt_prog.c: 3 linux/version.h not needed. ./tools/testing/selftests/bpf/progs/test_map_lock.c: 4 linux/version.h not needed. ./tools/testing/selftests/bpf/progs/test_send_signal_kern.c: 4 linux/version.h not needed. ./tools/testing/selftests/bpf/progs/test_spin_lock.c: 4 linux/version.h not needed. ./tools/testing/selftests/bpf/progs/test_tcp_estats.c: 37 linux/version.h not needed. ./tools/testing/selftests/wireguard/qemu/init.c: 27 linux/version.h not needed.
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Nipun Gupta
maintainerPATCH v6 5/7 cdx: add cdx controller
In reply to Nipun GuptaCDX controller uses MCDI interface as a protocol to communicate with the RPU firmware and registers the detected CDX devices on the CDX bus. It also uses RPMsg as the communication channel with the Firmware.
--- drivers/cdx/controller/Kconfig | 9 ++ drivers/cdx/controller/Makefile | 2 +- drivers/cdx/controller/cdx_controller.c | 187 ++++++++++++++++++++++++ drivers/cdx/controller/mcdi_functions.c | 125 ++++++++++++++++ drivers/cdx/controller/mcdi_functions.h | 50 +++++++ 5 files changed, 372 insertions(+), 1 deletion(-) create mode 100644 drivers/cdx/controller/cdx_controller.c create mode 100644 drivers/cdx/controller/mcdi_functions.c create mode 100644 drivers/cdx/controller/mcdi_functions.h
drivers/cdx/controller/Kconfig +9 -0
@@ -7,6 +7,15 @@ if CDX_BUS +config CDX_CONTROLLER + tristate "CDX bus controller" + help + CDX controller drives the CDX bus. It interacts with + firmware to get the hardware devices and registers with + the CDX bus. Say Y to enable the CDX hardware driver. + + If unsure, say N. + config MCDI_LOGGING bool "MCDI Logging for the CDX controller" depends on CDX_CONTROLLER
drivers/cdx/controller/Makefile +1 -1
@@ -6,4 +6,4 @@ # obj-$(CONFIG_CDX_CONTROLLER) += cdx-controller.o -cdx-controller-objs := mcdi.o +cdx-controller-objs := cdx_controller.o mcdi.o mcdi_functions.o
drivers/cdx/controller/cdx_controller.c new file +187 -0
187 lines not on this page · raw message
drivers/cdx/controller/mcdi_functions.c new file +125 -0
125 lines not on this page · raw message
drivers/cdx/controller/mcdi_functions.h new file +50 -0
50 lines not on this page · raw message
Signature · 1 line
2.17.1
kernel test robot
build botRe: [PATCH v6 5/7] cdx: add cdx controller
I love your patch! Yet something to improve:
Hi Nipun,
I love your patch! Yet something to improve:
[auto build test ERROR on next-20230127]
[cannot apply to masahiroy-kbuild/for-next masahiroy-kbuild/fixes robh/for-next joro-iommu/next linus/master v6.2-rc5 v6.2-rc4 v6.2-rc3 v6.2-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Nipun-Gupta/cdx-add-the-cdx-bus-driver/20230128-161622 patch link: https://lore.kernel.org/r/20230126104630.15493-6-nipun.gupta%40amd.com patch subject: [PATCH v6 5/7] cdx: add cdx controller config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20230128/[email protected]/config) compiler: sh4-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/f412d73800370b8e51d1be454e651d3c4ff796a8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Nipun-Gupta/cdx-add-the-cdx-bus-driver/20230128-161622
git checkout f412d73800370b8e51d1be454e651d3c4ff796a8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh SHELL=/bin/bash drivers/cdx/controller/
If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <[email protected]>
All error/warnings (new ones prefixed by >>):
drivers/cdx/controller/cdx_controller.c: In function 'xlnx_cdx_probe':
>> drivers/cdx/controller/cdx_controller.c:102:20: error: implicit declaration of function 'kzalloc' [-Werror=implicit-function-declaration]
102 | cdx_mcdi = kzalloc(sizeof(*cdx_mcdi), GFP_KERNEL);
| ^~~~~~~
>> drivers/cdx/controller/cdx_controller.c:102:18: warning: assignment to 'struct cdx_mcdi *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
102 | cdx_mcdi = kzalloc(sizeof(*cdx_mcdi), GFP_KERNEL);
| ^
>> drivers/cdx/controller/cdx_controller.c:115:13: warning: assignment to 'struct cdx_controller *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
115 | cdx = kzalloc(sizeof(*cdx), GFP_KERNEL);
| ^
>> drivers/cdx/controller/cdx_controller.c:131:9: error: implicit declaration of function 'kfree'; did you mean 'kvfree'? [-Werror=implicit-function-declaration]
131 | kfree(cdx_mcdi);
| ^~~~~
| kvfreecc1: some warnings being treated as errors
vim +/kzalloc +102 drivers/cdx/controller/cdx_controller.c
95
96 static int xlnx_cdx_probe(struct platform_device *pdev)
97 {
98 struct cdx_controller *cdx;
99 struct cdx_mcdi *cdx_mcdi;
100 int ret;
101
> 102 cdx_mcdi = kzalloc(sizeof(*cdx_mcdi), GFP_KERNEL);
103 if (!cdx_mcdi)
104 return -ENOMEM;
105
106 /* Store the MCDI ops */
107 cdx_mcdi->mcdi_ops = &mcdi_ops;
108 /* MCDI FW: Initialize the FW path */
109 ret = cdx_mcdi_init(cdx_mcdi);
110 if (ret) {
111 dev_err_probe(&pdev->dev, ret, "MCDI Initialization failed\n");
112 goto mcdi_init_fail;
113 }
114
> 115 cdx = kzalloc(sizeof(*cdx), GFP_KERNEL);
116 if (!cdx) {
117 ret = -ENOMEM;
118 goto cdx_alloc_fail;
119 }
120 platform_set_drvdata(pdev, cdx);
121
122 cdx->dev = &pdev->dev;
123 cdx->priv = cdx_mcdi;
124 cdx->ops = &cdx_ops;
125
126 return 0;
127
128 cdx_alloc_fail:
129 cdx_mcdi_finish(cdx_mcdi);
130 mcdi_init_fail:
> 131 kfree(cdx_mcdi); 132
133 return ret;
134 }
135
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
kernel test robot
build botRe: [PATCH v6 5/7] cdx: add cdx controller
In reply to Nipun GuptaI love your patch! Yet something to improve:
Hi Nipun,
I love your patch! Yet something to improve:
[auto build test ERROR on next-20230127]
[cannot apply to masahiroy-kbuild/for-next masahiroy-kbuild/fixes robh/for-next joro-iommu/next linus/master v6.2-rc5 v6.2-rc4 v6.2-rc3 v6.2-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Nipun-Gupta/cdx-add-the-cdx-bus-driver/20230128-161622 patch link: https://lore.kernel.org/r/20230126104630.15493-6-nipun.gupta%40amd.com patch subject: [PATCH v6 5/7] cdx: add cdx controller config: powerpc-buildonly-randconfig-r004-20230129 (https://download.01.org/0day-ci/archive/20230129/[email protected]/config) compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 4196ca3278f78c6e19246e54ab0ecb364e37d66a)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install powerpc cross compiling tool for clang build
# apt-get install binutils-powerpc-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/f412d73800370b8e51d1be454e651d3c4ff796a8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Nipun-Gupta/cdx-add-the-cdx-bus-driver/20230128-161622
git checkout f412d73800370b8e51d1be454e651d3c4ff796a8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/cdx/controller/
If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <[email protected]>
All errors (new ones prefixed by >>):
>> drivers/cdx/controller/cdx_controller.c:102:13: error: call to undeclared function 'kzalloc'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
cdx_mcdi = kzalloc(sizeof(*cdx_mcdi), GFP_KERNEL);
^
>> drivers/cdx/controller/cdx_controller.c:102:11: error: incompatible integer to pointer conversion assigning to 'struct cdx_mcdi *' from 'int' [-Wint-conversion]
cdx_mcdi = kzalloc(sizeof(*cdx_mcdi), GFP_KERNEL);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/cdx/controller/cdx_controller.c:115:6: error: incompatible integer to pointer conversion assigning to 'struct cdx_controller *' from 'int' [-Wint-conversion]
cdx = kzalloc(sizeof(*cdx), GFP_KERNEL);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/cdx/controller/cdx_controller.c:131:2: error: call to undeclared function 'kfree'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
kfree(cdx_mcdi);
^
drivers/cdx/controller/cdx_controller.c:141:2: error: call to undeclared function 'kfree'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
kfree(cdx);
^
5 errors generated.
--
>> drivers/cdx/controller/mcdi.c:272:2: error: call to undeclared function 'FIELD_PREP'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
CDX_POPULATE_DWORD_7(hdr[0],
^
drivers/cdx/controller/bitfield.h:72:30: note: expanded from macro 'CDX_POPULATE_DWORD_7'
#define CDX_POPULATE_DWORD_7 CDX_POPULATE_DWORD
^
drivers/cdx/controller/bitfield.h:69:32: note: expanded from macro 'CDX_POPULATE_DWORD'
(dword).cdx_u32 = cpu_to_le32(CDX_INSERT_FIELDS(__VA_ARGS__))
^
drivers/cdx/controller/bitfield.h:60:3: note: expanded from macro 'CDX_INSERT_FIELDS'
(CDX_INSERT_FIELD(field1, (value1)) | \
^
drivers/cdx/controller/bitfield.h:46:3: note: expanded from macro 'CDX_INSERT_FIELD'
(FIELD_PREP(GENMASK(CDX_HIGH_BIT(field), \
^
>> drivers/cdx/controller/mcdi.c:635:12: error: call to undeclared function 'FIELD_GET'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
respseq = CDX_DWORD_FIELD(outbuf[0], MCDI_HEADER_SEQ);
^
drivers/cdx/controller/bitfield.h:38:3: note: expanded from macro 'CDX_DWORD_FIELD'
(FIELD_GET(GENMASK(CDX_HIGH_BIT(field), CDX_LOW_BIT(field)), \
^
drivers/cdx/controller/mcdi.c:692:12: error: call to undeclared function 'FIELD_GET'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
respcmd = CDX_DWORD_FIELD(outbuf[0], MCDI_HEADER_CODE);
^
drivers/cdx/controller/bitfield.h:38:3: note: expanded from macro 'CDX_DWORD_FIELD'
(FIELD_GET(GENMASK(CDX_HIGH_BIT(field), CDX_LOW_BIT(field)), \
^
3 errors generated.
--
>> drivers/cdx/controller/mcdi_functions.c:25:9: error: call to undeclared function 'FIELD_GET'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
return MCDI_DWORD(outbuf, CDX_BUS_ENUM_BUSES_OUT_BUS_COUNT);
^
drivers/cdx/controller/mcdi.h:223:2: note: expanded from macro 'MCDI_DWORD'
CDX_DWORD_FIELD(*_MCDI_DWORD(_buf, _field), CDX_DWORD)
^
drivers/cdx/controller/bitfield.h:38:3: note: expanded from macro 'CDX_DWORD_FIELD'
(FIELD_GET(GENMASK(CDX_HIGH_BIT(field), CDX_LOW_BIT(field)), \
^
>> drivers/cdx/controller/mcdi_functions.c:35:2: error: call to undeclared function 'FIELD_PREP'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
MCDI_SET_DWORD(inbuf, CDX_BUS_ENUM_DEVICES_IN_BUS, bus_num);
^
drivers/cdx/controller/mcdi.h:221:2: note: expanded from macro 'MCDI_SET_DWORD'
CDX_POPULATE_DWORD_1(*_MCDI_DWORD(_buf, _field), CDX_DWORD, _value)
^
drivers/cdx/controller/bitfield.h:84:2: note: expanded from macro 'CDX_POPULATE_DWORD_1'
CDX_POPULATE_DWORD_2(dword, CDX_DWORD, 0, __VA_ARGS__)
^
drivers/cdx/controller/bitfield.h:82:2: note: expanded from macro 'CDX_POPULATE_DWORD_2'
CDX_POPULATE_DWORD_3(dword, CDX_DWORD, 0, __VA_ARGS__)
^
note: (skipping 5 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
drivers/cdx/controller/bitfield.h:69:32: note: expanded from macro 'CDX_POPULATE_DWORD'
(dword).cdx_u32 = cpu_to_le32(CDX_INSERT_FIELDS(__VA_ARGS__))
^
drivers/cdx/controller/bitfield.h:60:3: note: expanded from macro 'CDX_INSERT_FIELDS'
(CDX_INSERT_FIELD(field1, (value1)) | \
^
drivers/cdx/controller/bitfield.h:46:3: note: expanded from macro 'CDX_INSERT_FIELD'
(FIELD_PREP(GENMASK(CDX_HIGH_BIT(field), \
^
drivers/cdx/controller/mcdi_functions.c:45:9: error: call to undeclared function 'FIELD_GET'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
return MCDI_DWORD(outbuf, CDX_BUS_ENUM_DEVICES_OUT_DEVICE_COUNT);
^
drivers/cdx/controller/mcdi.h:223:2: note: expanded from macro 'MCDI_DWORD'
CDX_DWORD_FIELD(*_MCDI_DWORD(_buf, _field), CDX_DWORD)
^
drivers/cdx/controller/bitfield.h:38:3: note: expanded from macro 'CDX_DWORD_FIELD'
(FIELD_GET(GENMASK(CDX_HIGH_BIT(field), CDX_LOW_BIT(field)), \
^
drivers/cdx/controller/mcdi_functions.c:59:2: error: call to undeclared function 'FIELD_PREP'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
MCDI_SET_DWORD(inbuf, CDX_BUS_GET_DEVICE_CONFIG_IN_BUS, bus_num);
^
drivers/cdx/controller/mcdi.h:221:2: note: expanded from macro 'MCDI_SET_DWORD'
CDX_POPULATE_DWORD_1(*_MCDI_DWORD(_buf, _field), CDX_DWORD, _value)
^
drivers/cdx/controller/bitfield.h:84:2: note: expanded from macro 'CDX_POPULATE_DWORD_1'
CDX_POPULATE_DWORD_2(dword, CDX_DWORD, 0, __VA_ARGS__)
^
drivers/cdx/controller/bitfield.h:82:2: note: expanded from macro 'CDX_POPULATE_DWORD_2'
CDX_POPULATE_DWORD_3(dword, CDX_DWORD, 0, __VA_ARGS__)
^
note: (skipping 5 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
drivers/cdx/controller/bitfield.h:69:32: note: expanded from macro 'CDX_POPULATE_DWORD'
(dword).cdx_u32 = cpu_to_le32(CDX_INSERT_FIELDS(__VA_ARGS__))
^
drivers/cdx/controller/bitfield.h:60:3: note: expanded from macro 'CDX_INSERT_FIELDS'
(CDX_INSERT_FIELD(field1, (value1)) | \
^
drivers/cdx/controller/bitfield.h:46:3: note: expanded from macro 'CDX_INSERT_FIELD'
(FIELD_PREP(GENMASK(CDX_HIGH_BIT(field), \
^
drivers/cdx/controller/mcdi_functions.c:73:11: error: call to undeclared function 'FIELD_GET'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
req_id = MCDI_DWORD(outbuf, CDX_BUS_GET_DEVICE_CONFIG_OUT_REQUESTER_ID);
^
drivers/cdx/controller/mcdi.h:223:2: note: expanded from macro 'MCDI_DWORD'
CDX_DWORD_FIELD(*_MCDI_DWORD(_buf, _field), CDX_DWORD)
^
drivers/cdx/controller/bitfield.h:38:3: note: expanded from macro 'CDX_DWORD_FIELD'
(FIELD_GET(GENMASK(CDX_HIGH_BIT(field), CDX_LOW_BIT(field)), \
^5 errors generated.
vim +/kzalloc +102 drivers/cdx/controller/cdx_controller.c
95
96 static int xlnx_cdx_probe(struct platform_device *pdev)
97 {
98 struct cdx_controller *cdx;
99 struct cdx_mcdi *cdx_mcdi;
100 int ret;
101
> 102 cdx_mcdi = kzalloc(sizeof(*cdx_mcdi), GFP_KERNEL);
103 if (!cdx_mcdi)
104 return -ENOMEM;
105
106 /* Store the MCDI ops */
107 cdx_mcdi->mcdi_ops = &mcdi_ops;
108 /* MCDI FW: Initialize the FW path */
109 ret = cdx_mcdi_init(cdx_mcdi);
110 if (ret) {
111 dev_err_probe(&pdev->dev, ret, "MCDI Initialization failed\n");
112 goto mcdi_init_fail;
113 }
114
> 115 cdx = kzalloc(sizeof(*cdx), GFP_KERNEL);
116 if (!cdx) {
117 ret = -ENOMEM;
118 goto cdx_alloc_fail;
119 }
120 platform_set_drvdata(pdev, cdx);
121
122 cdx->dev = &pdev->dev;
123 cdx->priv = cdx_mcdi;
124 cdx->ops = &cdx_ops;
125
126 return 0;
127
128 cdx_alloc_fail:
129 cdx_mcdi_finish(cdx_mcdi);
130 mcdi_init_fail:
> 131 kfree(cdx_mcdi); 132
133 return ret;
134 }
135
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Nipun Gupta
maintainerPATCH v6 6/7 cdx: add rpmsg communication channel for CDX
In reply to Nipun GuptaFrom: Abhijit Gangurde <[email protected]>
RPMsg is used as a transport communication channel. This change introduces RPMsg driver and integrates it with the CDX controller.
--- drivers/cdx/controller/Kconfig | 1 + drivers/cdx/controller/Makefile | 2 +- drivers/cdx/controller/cdx_controller.c | 31 +++- drivers/cdx/controller/cdx_controller.h | 30 ++++ drivers/cdx/controller/cdx_rpmsg.c | 202 ++++++++++++++++++++++++ drivers/cdx/controller/mcdi.h | 9 ++ 6 files changed, 270 insertions(+), 5 deletions(-) create mode 100644 drivers/cdx/controller/cdx_controller.h create mode 100644 drivers/cdx/controller/cdx_rpmsg.c
drivers/cdx/controller/Kconfig +1 -0
@@ -9,6 +9,7 @@ if CDX_BUS config CDX_CONTROLLER tristate "CDX bus controller" + select RPMSG help CDX controller drives the CDX bus. It interacts with firmware to get the hardware devices and registers with
drivers/cdx/controller/Makefile +1 -1
@@ -6,4 +6,4 @@ # obj-$(CONFIG_CDX_CONTROLLER) += cdx-controller.o -cdx-controller-objs := cdx_controller.o mcdi.o mcdi_functions.o +cdx-controller-objs := cdx_controller.o cdx_rpmsg.o mcdi.o mcdi_functions.o
drivers/cdx/controller/cdx_controller.c +27 -4
@@ -8,6 +8,7 @@#include <linux/of_platform.h> #include <linux/cdx/cdx_bus.h> +#include "cdx_controller.h" #include "../cdx.h" #include "mcdi_functions.h" #include "mcdi.h"
@@ -21,10 +22,7 @@ static void cdx_mcdi_request(struct cdx_mcdi *cdx, const struct cdx_dword *hdr, size_t hdr_len, const struct cdx_dword *sdu, size_t sdu_len) { -/* -* This will get updated by rpmsg APIs, with RPMSG introduction -* in CDX controller as a transport layer. -*/ +cdx_rpmsg_send (cdx ,hdr ,hdr_len ,sdu ,sdu_len ); } static const struct cdx_mcdi_ops mcdi_ops = {
@@ -32,6 +30,19 @@ static const struct cdx_mcdi_ops mcdi_ops = { .mcdi_request = cdx_mcdi_request, }; +void cdx_rpmsg_post_probe (struct cdx_controller *cdx) +{ +/* Register CDX controller with CDX bus driver */ +if (cdx_register_controller (cdx)) +dev_err (cdx->dev,"Failed to register CDX controller\n" ); +} + +void cdx_rpmsg_pre_remove (struct cdx_controller *cdx) +{ +cdx_unregister_controller (cdx); +cdx_mcdi_wait_for_quiescence (cdx->priv,MCDI_RPC_TIMEOUT ); +} +static int cdx_scan_devices (struct cdx_controller *cdx) {struct cdx_mcdi *cdx_mcdi = cdx->priv;
@@ -123,8 +134,18 @@ static int xlnx_cdx_probe(struct platform_device *pdev) cdx->priv = cdx_mcdi; cdx->ops = &cdx_ops; + ret =cdx_setup_rpmsg (pdev); +if (ret) { +if (ret != -EPROBE_DEFER ) +dev_err (&pdev->dev,"Failed to register CDX RPMsg transport\n" ); + goto cdx_rpmsg_fail; + } + +dev_info (&pdev->dev,"Successfully registered CDX controller with RPMsg as transport\n" );return 0 ; +cdx_rpmsg_fail: +kfree (cdx); cdx_alloc_fail:cdx_mcdi_finish (cdx_mcdi); mcdi_init_fail:
@@ -138,6 +159,8 @@ static int xlnx_cdx_remove(struct platform_device *pdev)struct cdx_controller *cdx =platform_get_drvdata (pdev);struct cdx_mcdi *cdx_mcdi = cdx->priv; +cdx_destroy_rpmsg (pdev); +kfree (cdx);cdx_mcdi_finish (cdx_mcdi);
drivers/cdx/controller/cdx_controller.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Header file for the CDX Controller +* +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +#ifndef _CDX_CONTROLLER_H_ +#define _CDX_CONTROLLER_H_ + +#include <linux/cdx/cdx_bus.h> +#include "mcdi_functions.h" + +void cdx_rpmsg_post_probe (struct cdx_controller *cdx); + +void cdx_rpmsg_pre_remove (struct cdx_controller *cdx); + +int cdx_rpmsg_send (struct cdx_mcdi *cdx_mcdi, +const struct cdx_dword *hdr,size_t hdr_len, +const struct cdx_dword *sdu,size_t sdu_len); + +void cdx_rpmsg_read_resp (struct cdx_mcdi *cdx_mcdi, +struct cdx_dword *outbuf,size_t offset, +size_t outlen); + +int cdx_setup_rpmsg (struct platform_device *pdev); + +void cdx_destroy_rpmsg (struct platform_device *pdev); + +#endif /* _CDX_CONT_PRIV_H_ */
drivers/cdx/controller/cdx_rpmsg.c new file +202 -0
202 lines not on this page · raw message
drivers/cdx/controller/mcdi.h +9 -0
@@ -62,11 +62,20 @@ enum cdx_mcdi_cmd_state {* with CDX controller. * @mcdi: MCDI interface * @mcdi_ops: MCDI operations +* @r5_rproc : R5 Remoteproc device handle +* @rpdev: RPMsg device +* @ept: RPMsg endpoint +* @work: Post probe work */ struct cdx_mcdi {/* MCDI interface */ struct cdx_mcdi_data *mcdi;const struct cdx_mcdi_ops *mcdi_ops; + +struct rproc *r5_rproc; +struct rpmsg_device *rpdev; +struct rpmsg_endpoint *ept; +struct work_struct work; };struct cdx_mcdi_ops {
Signature · 1 line
2.17.1
Nipun Gupta
maintainerPATCH v6 7/7 cdx: add device attributes
In reply to Nipun GuptaCreate sysfs entry for CDX devices.
Sysfs entries provided in each of the CDX device detected by the CDX controller
- vendor id
- device id
- remove
- reset of the device.
- driver override
--- Documentation/ABI/testing/sysfs-bus-cdx | 44 +++++++ drivers/cdx/cdx.c | 145 ++++++++++++++++++++++++ drivers/cdx/controller/cdx_controller.c | 19 ++++ drivers/cdx/controller/mcdi_functions.c | 14 +++ drivers/cdx/controller/mcdi_functions.h | 11 ++ include/linux/cdx/cdx_bus.h | 27 +++++ 6 files changed, 260 insertions(+)
Documentation/ABI/testing/sysfs-bus-cdx +44 -0
@@ -10,3 +10,47 @@ Description: For example:: # echo 1 > /sys/bus/cdx/rescan + +What: /sys/bus/cdx/devices/.../vendor +Date: January 2023 +Contact: [email protected] +Description: + Vendor ID for this CDX device. Vendor ID is 16 bit + identifier which is specific to the device manufacturer. + Combination of Vendor ID and Device ID identifies a device. + +What: /sys/bus/cdx/devices/.../device +Date: January 2023 +Contact: [email protected] +Description: + Device ID for this CDX device. Device ID is a 16 bit + identifier to identify a device type within the range + of a device manufacturer. + Combination of Vendor ID and Device ID identifies a device. + +What: /sys/bus/cdx/devices/.../reset +Date: January 2023 +Contact: [email protected] +Description: + Writing a non-zero value to this file would reset the CDX + device. On resetting the device, the corresponding driver + would be notified twice, once before the device is being + reset, and again after the reset has been complete. + + For example:: + + # echo 1 > /sys/bus/cdx/.../reset + +What: /sys/bus/cdx/devices/.../remove +Date: January 2023 +Contact: [email protected] +Description: + Writing a non-zero value to this file would remove the + corrosponding device from the CDX bus. If the device is + to be reconfigured in the Hardware, the device can be + removed, so that the device driver does not access the + device while it is being reconfigured. + + For example:: + + # echo 1 > /sys/bus/cdx/devices/.../remove
drivers/cdx/cdx.c +145 -0
163 lines not on this page · raw message
drivers/cdx/controller/cdx_controller.c +19 -0
@@ -43,6 +43,24 @@ void cdx_rpmsg_pre_remove(struct cdx_controller *cdx)cdx_mcdi_wait_for_quiescence (cdx->priv,MCDI_RPC_TIMEOUT ); } +static int cdx_configure_device (struct cdx_controller *cdx, +u8 bus_num,u8 dev_num, +struct cdx_device_config *dev_config) +{ +int ret =0 ; + +switch (dev_config->type) { +case CDX_DEV_RESET_CONF : + ret =cdx_mcdi_reset_device (cdx->priv, bus_num, dev_num); +break ; +default : +dev_err (cdx->dev,"Invalid device configuration flag\n" ); + ret = -EINVAL ; + } + +return ret; +} +static int cdx_scan_devices (struct cdx_controller *cdx) {struct cdx_mcdi *cdx_mcdi = cdx->priv;
@@ -102,6 +120,7 @@ static int cdx_scan_devices(struct cdx_controller *cdx)static struct cdx_ops cdx_ops = { .scan = cdx_scan_devices, + .dev_configure = cdx_configure_device, };static int xlnx_cdx_probe (struct platform_device *pdev)
drivers/cdx/controller/mcdi_functions.c +14 -0
@@ -123,3 +123,17 @@ int cdx_mcdi_get_dev_config(struct cdx_mcdi *cdx,return 0 ; } + +int cdx_mcdi_reset_device (struct cdx_mcdi *cdx,u8 bus_num,u8 dev_num) +{ +MCDI_DECLARE_BUF (inbuf,MC_CMD_CDX_DEVICE_RESET_IN_LEN ); +int rc; + +MCDI_SET_DWORD (inbuf,CDX_DEVICE_RESET_IN_BUS , bus_num); +MCDI_SET_DWORD (inbuf,CDX_DEVICE_RESET_IN_DEVICE , dev_num); + + rc =cdx_mcdi_rpc (cdx,MC_CMD_CDX_DEVICE_RESET , inbuf,sizeof (inbuf), +NULL ,0 ,NULL ); + +return rc; +}
drivers/cdx/controller/mcdi_functions.h +11 -0
@@ -47,4 +47,15 @@ int cdx_mcdi_get_dev_config(struct cdx_mcdi *cdx, u8 bus_num, u8 dev_num, struct cdx_dev_params *dev_params); +/** +* cdx_mcdi_reset_device - Reset cdx device represented by bus_num:dev_num +* @cdx: pointer to MCDI interface. +* @bus_num: Bus number. +* @dev_num: Device number. +* +* Return: 0 on success, <0 on failure +*/ +int cdx_mcdi_reset_device (struct cdx_mcdi *cdx, +u8 bus_num,u8 dev_num); +#endif /* CDX_MCDI_FUNCTIONS_H */
include/linux/cdx/cdx_bus.h +27 -0
@@ -21,8 +21,20 @@/* Forward declaration for CDX controller */ struct cdx_controller ; +enum { +CDX_DEV_RESET_CONF , +}; + +struct cdx_device_config { +u8 type; +}; +typedef int (*cdx_scan_cb )(struct cdx_controller *cdx); +typedef int (*cdx_dev_configure_cb )(struct cdx_controller *cdx, +u8 bus_num,u8 dev_num, +struct cdx_device_config *dev_config); +/** * CDX_DEVICE_DRIVER_OVERRIDE - macro used to describe a CDX device with * override_only flags.
@@ -39,9 +51,12 @@ typedef int (*cdx_scan_cb)(struct cdx_controller *cdx);/** * struct cdx_ops - Callbacks supported by CDX controller. * @scan: scan the devices on the controller +* @dev_configure: configuration like reset, master_enable, +* msi_config etc for a CDX device */ struct cdx_ops {cdx_scan_cb scan; +cdx_dev_configure_cb dev_configure; };/**
@@ -101,6 +116,8 @@ struct cdx_device {* @probe: Function called when a device is added * @remove: Function called when a device is removed * @shutdown: Function called at shutdown time to quiesce the device +* @reset_prepare: Function called before is reset to notify driver +* @reset_done: Function called after reset is complete to notify driver * @driver_managed_dma: Device driver doesn't use kernel DMA API for DMA. * For most device drivers, no need to care about this flag * as long as all DMAs are handled through the kernel DMA API.
@@ -115,6 +132,8 @@ struct cdx_driver {int (*probe)(struct cdx_device *dev);int (*remove)(struct cdx_device *dev);void (*shutdown)(struct cdx_device *dev); +void (*reset_prepare)(struct cdx_device *dev); +void (*reset_done)(struct cdx_device *dev);bool driver_managed_dma; };
@@ -144,4 +163,12 @@ void cdx_driver_unregister(struct cdx_driver *cdx_driver);extern struct bus_type cdx_bus_type; +/** +* cdx_dev_reset - Reset CDX device +* @dev: device pointer +* +* Return: 0 for success, -errno on failure +*/ +int cdx_dev_reset (struct device *dev); +#endif /* _CDX_BUS_H_ */
Signature · 1 line
2.17.1
Re: [PATCH v6 7/7] cdx: add device attributes
Hi--
Quoted 20 lines · Nipun Gupta
Documentation/ABI/testing/sysfs-bus-cdx +12
-0@@ -10,3 +10,47 @@ Description: For example:: # echo 1 > /sys/bus/cdx/rescan + +What: /sys/bus/cdx/devices/.../vendor +Date: January 2023 +Contact: [email protected] +Description: + Vendor ID for this CDX device. Vendor ID is 16 bit + identifier which is specific to the device manufacturer. + Combination of Vendor ID and Device ID identifies a device. + +What: /sys/bus/cdx/devices/.../device +Date: January 2023 +Contact: [email protected]
Documentation/ABI/testing/sysfs-bus-cdx Description: · line 34
Quoted 10 lines
Documentation/ABI/testing/sysfs-bus-cdx +10
-0+Description: + Device ID for this CDX device. Device ID is a 16 bit + identifier to identify a device type within the range + of a device manufacturer. + Combination of Vendor ID and Device ID identifies a device. + +What: /sys/bus/cdx/devices/.../reset +Date: January 2023 +Contact: [email protected] +Description:
Reads better without "would":
Documentation/ABI/testing/sysfs-bus-cdx Description: · line 38
Quoted 3 lines
Documentation/ABI/testing/sysfs-bus-cdx +3
-0+ Writing a non-zero value to this file would reset the CDX> + device. On resetting the device, the corresponding driver + would be notified twice, once before the device is being + reset, and again after the reset has been complete.
Writing a non-zero value to this file resets the CDX device. On resetting the device, the corresponding driver is notified twice, once before the device is being reset, and again after the reset has been complete.
Quoted 4 lines
Documentation/ABI/testing/sysfs-bus-cdx +4
-0+ + For example:: + + # echo 1 > /sys/bus/cdx/.../reset
Documentation/ABI/testing/sysfs-bus-cdx Description: · line 52
Quoted 10 lines
Documentation/ABI/testing/sysfs-bus-cdx +10
-0+ +What: /sys/bus/cdx/devices/.../remove +Date: January 2023 +Contact: [email protected] +Description: + Writing a non-zero value to this file would remove the + corrosponding device from the CDX bus. If the device is + to be reconfigured in the Hardware, the device can be + removed, so that the device driver does not access the + device while it is being reconfigured.
and: (also fix typo of corresponding)
Writing a non-zero value to this file removes the corresponding device from the CDX bus. If the device is to be reconfigured in the Hardware, the device can be removed, so that the device driver does not access the device while it is being reconfigured.
Quoted 4 lines
Documentation/ABI/testing/sysfs-bus-cdx +4
-0+ + For example:: + + # echo 1 > /sys/bus/cdx/devices/.../remove
Signature · 1 line
~Randy
Nipun Gupta
maintainerRe: [PATCH v6 7/7] cdx: add device attributes
Quoted 46 lines · Randy Dunlap
Hi--
Quoted 20 lines · Nipun Gupta
Documentation/ABI/testing/sysfs-bus-cdx +12
-0@@ -10,3 +10,47 @@ Description: For example:: # echo 1 > /sys/bus/cdx/rescan + +What: /sys/bus/cdx/devices/.../vendor +Date: January 2023 +Contact: [email protected] +Description: + Vendor ID for this CDX device. Vendor ID is 16 bit + identifier which is specific to the device manufacturer. + Combination of Vendor ID and Device ID identifies a device. + +What: /sys/bus/cdx/devices/.../device +Date: January 2023 +Contact: [email protected]Documentation/ABI/testing/sysfs-bus-cdx Description: · line 34
Quoted 10 lines
Documentation/ABI/testing/sysfs-bus-cdx +10
-0+Description: + Device ID for this CDX device. Device ID is a 16 bit + identifier to identify a device type within the range + of a device manufacturer. + Combination of Vendor ID and Device ID identifies a device. + +What: /sys/bus/cdx/devices/.../reset +Date: January 2023 +Contact: [email protected] +Description:Reads better without "would":
Documentation/ABI/testing/sysfs-bus-cdx Description: · line 38
Quoted 3 lines
Documentation/ABI/testing/sysfs-bus-cdx +3
-0+ Writing a non-zero value to this file would reset the CDX> + device. On resetting the device, the corresponding driver + would be notified twice, once before the device is being + reset, and again after the reset has been complete.Writing a non-zero value to this file resets the CDX device. On resetting the device, the corresponding driver is notified twice, once before the device is being reset, and again after the reset has been complete.
Quoted 16 lines
Quoted 4 lines
Documentation/ABI/testing/sysfs-bus-cdx +4
-0+ + For example:: + + # echo 1 > /sys/bus/cdx/.../resetDocumentation/ABI/testing/sysfs-bus-cdx Description: · line 52
Quoted 10 lines
Documentation/ABI/testing/sysfs-bus-cdx +10
-0+ +What: /sys/bus/cdx/devices/.../remove +Date: January 2023 +Contact: [email protected] +Description: + Writing a non-zero value to this file would remove the + corrosponding device from the CDX bus. If the device is + to be reconfigured in the Hardware, the device can be + removed, so that the device driver does not access the + device while it is being reconfigured.and: (also fix typo of corresponding)
Thanks for the review. Will fix and update these.
Regards
Nipun
Quoted 7 lines
Writing a non-zero value to this file removes the corresponding device from the CDX bus. If the device is to be reconfigured in the Hardware, the device can be removed, so that the device driver does not access the device while it is being reconfigured.
Quoted 7 lines
Documentation/ABI/testing/sysfs-bus-cdx Description: · line 56
Quoted 4 lines
Documentation/ABI/testing/sysfs-bus-cdx +4
-0+ + For example:: + + # echo 1 > /sys/bus/cdx/devices/.../remove--
~Randy
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel