Skip to contentSkip to conversation

cdx: provide sysfs interface for cdx device resources

PATCH Superseded Abhijit Gangurde 2 participants 17 messages Jul 11, 2023 – Jul 13, 2023

Subsystems (2)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

cover cdx: provide sysfs interface for cdx device resources

This patch series provides sysfs interface to
- enable and disable of cdx bus
- reset_all for all the devices on cdx bus
- resource files for cdx device
- subsystem, class and revision for cdx device

Abhijit Gangurde (4):
cdx: add support for bus enable and disable
cdx: add sysfs for reset_all
cdx: create sysfs resource files
cdx: add sysfs for subsystem, class and revision

 Documentation/ABI/testing/sysfs-bus-cdx |  82 +++++++++
 drivers/cdx/cdx.c                       | 223 +++++++++++++++++++++++-
 drivers/cdx/cdx.h                       |   8 +
 drivers/cdx/controller/cdx_controller.c |  27 +++
 drivers/cdx/controller/mc_cdx_pcol.h    |  54 ++++++
 drivers/cdx/controller/mcdi_functions.c |  31 ++++
 drivers/cdx/controller/mcdi_functions.h |  16 ++
 include/linux/cdx/cdx_bus.h             |  43 ++++-
 include/linux/mod_devicetable.h         |  10 ++
 scripts/mod/devicetable-offsets.c       |   4 +
 scripts/mod/file2alias.c                |   8 +
 11 files changed, 502 insertions(+), 4 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/4 cdx: add support for bus enable and disable

CDX bus needs to be disabled before updating/writing devices in the FPGA. Once the devices are written, the bus shall be enabled. This change provides sysfs entry to enable/disable the CDX bus.

---
 Documentation/ABI/testing/sysfs-bus-cdx | 11 +++++
 drivers/cdx/cdx.c                       | 26 ++++++++++++
 drivers/cdx/controller/cdx_controller.c | 27 +++++++++++++
 drivers/cdx/controller/mc_cdx_pcol.h    | 54 +++++++++++++++++++++++++
 drivers/cdx/controller/mcdi_functions.c | 24 +++++++++++
 drivers/cdx/controller/mcdi_functions.h | 16 ++++++++
 include/linux/cdx/cdx_bus.h             |  6 +++
 7 files changed, 164 insertions(+)
Documentation/ABI/testing/sysfs-bus-cdx +11 -0
index 7af477f49998..0afa85b3c63b 100644
@@ -11,6 +11,17 @@ Description:
 
 		  # echo 1 > /sys/bus/cdx/rescan
 
+What:		/sys/bus/cdx/enable
+Date:		July 2023
+Contact:	[email protected]
+Description:
+		Writing y/1/on to this file enables the CDX bus and
+		writing n/0/off disables the bus.
+
+		For example to disable CDX bus::
+
+		  # echo 0 > /sys/bus/cdx/enable
+
 What:		/sys/bus/cdx/devices/.../vendor
 Date:		March 2023
 Contact:	[email protected]
drivers/cdx/cdx.c +26 -0
index d2cad4c670a0..48c493a43491 100644
@@ -380,6 +380,30 @@ static struct attribute *cdx_dev_attrs[] = {
 };
 ATTRIBUTE_GROUPS(cdx_dev);
 
+static ssize_t enable_store(const struct bus_type *bus,
+			    const char *buf, size_t count)
+{
+	struct cdx_controller *cdx;
+	unsigned long index;
+	bool enable;
+	int ret;
+
+	if (kstrtobool(buf, &enable) < 0)
+		return -EINVAL;
+
+	xa_for_each(&cdx_controllers, index, cdx) {
+		if (cdx->enabled == enable)
+			continue;
+
+		ret = cdx->ops->enable(cdx, enable);
+		if (ret)
+			dev_err(cdx->dev, "cdx bus enable/disable failed\n");
+	}
+
+	return count;
+}
+static BUS_ATTR_WO(enable);
+
 static ssize_t rescan_store(const struct bus_type *bus,
 			    const char *buf, size_t count)
 {
@@ -410,6 +434,7 @@ static ssize_t rescan_store(const struct bus_type *bus,
 static BUS_ATTR_WO(rescan);
 
 static struct attribute *cdx_bus_attrs[] = {
+	&bus_attr_enable.attr,
 	&bus_attr_rescan.attr,
 	NULL,
 };
@@ -541,6 +566,7 @@ void cdx_unregister_controller(struct cdx_controller *cdx)
 	if (cdx->id >= MAX_CDX_CONTROLLERS)
 		return;
 
+	cdx->ops->enable(cdx, false);
 	device_for_each_child(cdx->dev, NULL, cdx_unregister_device);
 	xa_erase(&cdx_controllers, cdx->id);
 }
drivers/cdx/controller/cdx_controller.c +27 -0
index dc52f95f8978..ac8081f23cbe 100644
@@ -45,6 +45,21 @@ void cdx_rpmsg_pre_remove(struct cdx_controller *cdx)
 	cdx_mcdi_wait_for_quiescence(cdx->priv, MCDI_RPC_TIMEOUT);
 }
 
+static int cdx_bus_enable(struct cdx_controller *cdx, bool enable)
+{
+	int ret;
+
+	if (enable)
+		ret = cdx_mcdi_bus_enable(cdx->priv);
+	else
+		ret = cdx_mcdi_bus_disable(cdx->priv);
+
+	if (!ret)
+		cdx->enabled = enable;
+
+	return ret;
+}
+
 static int cdx_configure_device(struct cdx_controller *cdx,
 				u8 bus_num, u8 dev_num,
 				struct cdx_device_config *dev_config)
@@ -80,11 +95,22 @@ static int cdx_scan_devices(struct cdx_controller *cdx)
 	for (bus_num = 0; bus_num < num_cdx_bus; bus_num++) {
 		u8 num_cdx_dev;
 
+		ret = cdx_mcdi_bus_enable(cdx_mcdi);
+		if (ret && ret != -EALREADY) {
+			dev_err(cdx->dev,
+				"CDX bus %d enable failed: %d\n", bus_num, ret);
+			continue;
+		}
+
 		/* MCDI FW Read: Fetch the number of devices present */
 		ret = cdx_mcdi_get_num_devs(cdx_mcdi, bus_num);
 		if (ret < 0) {
 			dev_err(cdx->dev,
 				"Get devices on CDX bus %d failed: %d\n", bus_num, ret);
+			ret = cdx_mcdi_bus_disable(cdx_mcdi);
+			if (ret)
+				dev_err(cdx->dev,
+					"CDX bus %d disable failed: %d\n", bus_num, ret);
 			continue;
 		}
 		num_cdx_dev = (u8)ret;
@@ -120,6 +146,7 @@ static int cdx_scan_devices(struct cdx_controller *cdx)
 }
 
 static struct cdx_ops cdx_ops = {
+	.enable		= cdx_bus_enable,
 	.scan		= cdx_scan_devices,
 	.dev_configure	= cdx_configure_device,
 };
drivers/cdx/controller/mc_cdx_pcol.h +54 -0

60 lines not on this page · raw message

drivers/cdx/controller/mcdi_functions.c +24 -0
index 0158f26533dd..400fdc771104 100644
@@ -124,6 +124,30 @@ int cdx_mcdi_get_dev_config(struct cdx_mcdi *cdx,
 	return 0;
 }
 
+int cdx_mcdi_bus_enable(struct cdx_mcdi *cdx)
+{
+	MCDI_DECLARE_BUF(inbuf, MC_CMD_CDX_BUS_UP_IN_LEN);
+	int ret;
+
+	MCDI_SET_DWORD(inbuf, CDX_BUS_UP_IN_BUS, 0);
+	ret = cdx_mcdi_rpc(cdx, MC_CMD_CDX_BUS_UP, inbuf, sizeof(inbuf),
+			   NULL, 0, NULL);
+
+	return ret;
+}
+
+int cdx_mcdi_bus_disable(struct cdx_mcdi *cdx)
+{
+	MCDI_DECLARE_BUF(inbuf, MC_CMD_CDX_BUS_DOWN_IN_LEN);
+	int ret;
+
+	MCDI_SET_DWORD(inbuf, CDX_BUS_DOWN_IN_BUS, 0);
+	ret = cdx_mcdi_rpc(cdx, MC_CMD_CDX_BUS_DOWN, inbuf, sizeof(inbuf),
+			   NULL, 0, NULL);
+
+	return ret;
+}
+
 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);
drivers/cdx/controller/mcdi_functions.h +16 -0
index 7440ace5539a..6d26b7cdc07c 100644
@@ -47,6 +47,22 @@ int cdx_mcdi_get_dev_config(struct cdx_mcdi *cdx,
 			    u8 bus_num, u8 dev_num,
 			    struct cdx_dev_params *dev_params);
 
+/**
+ * cdx_mcdi_bus_enable - Enable CDX bus represented by bus_num
+ * @cdx: pointer to MCDI interface.
+ *
+ * Return: 0 on success, <0 on failure
+ */
+int cdx_mcdi_bus_enable(struct cdx_mcdi *cdx);
+
+/**
+ * cdx_mcdi_bus_disable - Disable CDX bus represented by bus_num
+ * @cdx: pointer to MCDI interface.
+ *
+ * Return: 0 on success, <0 on failure
+ */
+int cdx_mcdi_bus_disable(struct cdx_mcdi *cdx);
+
 /**
  * cdx_mcdi_reset_device - Reset cdx device represented by bus_num:dev_num
  * @cdx: pointer to MCDI interface.
include/linux/cdx/cdx_bus.h +6 -0
index bead71b7bc73..5da0634ae4ee 100644
@@ -28,6 +28,8 @@ struct cdx_device_config {
 	u8 type;
 };
 
+typedef int (*cdx_bus_enable_cb)(struct cdx_controller *cdx, bool enable);
+
 typedef int (*cdx_scan_cb)(struct cdx_controller *cdx);
 
 typedef int (*cdx_dev_configure_cb)(struct cdx_controller *cdx,
@@ -49,11 +51,13 @@ typedef int (*cdx_dev_configure_cb)(struct cdx_controller *cdx,
 
 /**
  * struct cdx_ops - Callbacks supported by CDX controller.
+ * @enable: enable or disable bus on the 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_bus_enable_cb enable;
 	cdx_scan_cb scan;
 	cdx_dev_configure_cb dev_configure;
 };
@@ -63,12 +67,14 @@ struct cdx_ops {
  * @dev: Linux device associated with the CDX controller.
  * @priv: private data
  * @id: Controller ID
+ * @enabled: state enabled/disabled
  * @ops: CDX controller ops
  */
 struct cdx_controller {
 	struct device *dev;
 	void *priv;
 	u32 id;
+	bool enabled;
 	struct cdx_ops *ops;
 };
 
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 1/4] cdx: add support for bus enable and disable

Quoted 28 lines · Abhijit Gangurde

CDX bus needs to be disabled before updating/writing devices in the FPGA. Once the devices are written, the bus shall be enabled. This change provides sysfs entry to enable/disable the CDX bus.

---
 Documentation/ABI/testing/sysfs-bus-cdx | 11 +++++
 drivers/cdx/cdx.c                       | 26 ++++++++++++
 drivers/cdx/controller/cdx_controller.c | 27 +++++++++++++
 drivers/cdx/controller/mc_cdx_pcol.h    | 54 +++++++++++++++++++++++++
 drivers/cdx/controller/mcdi_functions.c | 24 +++++++++++
 drivers/cdx/controller/mcdi_functions.h | 16 ++++++++
 include/linux/cdx/cdx_bus.h             |  6 +++
 7 files changed, 164 insertions(+)
Documentation/ABI/testing/sysfs-bus-cdx +0 -0
index 7af477f49998..0afa85b3c63b 100644
@@ -11,6 +11,17 @@ Description:
 
 		  # echo 1 > /sys/bus/cdx/rescan
 

Documentation/ABI/testing/sysfs-bus-cdx Description: · line 23

Quoted 10 lines
Documentation/ABI/testing/sysfs-bus-cdx +10 -0
+What:		/sys/bus/cdx/enable
+Date:		July 2023
+Contact:	[email protected]
+Description:
+		Writing y/1/on to this file enables the CDX bus and
+		writing n/0/off disables the bus.
+
+		For example to disable CDX bus::
+
+		  # echo 0 > /sys/bus/cdx/enable

What could go wrong! :)

You don't say why disabling / enabling the bus is needed, this feels like a very huge stick, why is this for all busses, and not just an individual CDX bus?

Quoted 20 lines
Documentation/ABI/testing/sysfs-bus-cdx +1 -0
+
 What:		/sys/bus/cdx/devices/.../vendor
 Date:		March 2023
 Contact:	[email protected]
drivers/cdx/cdx.c +8 -0
index d2cad4c670a0..48c493a43491 100644
@@ -380,6 +380,30 @@ static struct attribute *cdx_dev_attrs[] = {
 };
 ATTRIBUTE_GROUPS(cdx_dev);
 
+static ssize_t enable_store(const struct bus_type *bus,
+			    const char *buf, size_t count)
+{
+	struct cdx_controller *cdx;
+	unsigned long index;
+	bool enable;
+	int ret;
+

drivers/cdx/cdx.c static struct attribute *cdx_dev_attrs[] = { · line 400

Quoted 10 lines
drivers/cdx/cdx.c +10 -0
+	if (kstrtobool(buf, &enable) < 0)
+		return -EINVAL;
+
+	xa_for_each(&cdx_controllers, index, cdx) {
+		if (cdx->enabled == enable)
+			continue;
+
+		ret = cdx->ops->enable(cdx, enable);
+		if (ret)
+			dev_err(cdx->dev, "cdx bus enable/disable failed\n");

You can say if this was enabled or disabled to help figure things out.

drivers/cdx/cdx.c static struct attribute *cdx_dev_attrs[] = { · line 401

Quoted 1 line
drivers/cdx/cdx.c +1 -0
+	}

No locking needed at all? What happens if controllers are added or removed?

Quoted 29 lines
drivers/cdx/cdx.c +7 -0
+
+	return count;
+}
+static BUS_ATTR_WO(enable);
+
 static ssize_t rescan_store(const struct bus_type *bus,
 			    const char *buf, size_t count)
 {
@@ -410,6 +434,7 @@ static ssize_t rescan_store(const struct bus_type *bus,
 static BUS_ATTR_WO(rescan);
 
 static struct attribute *cdx_bus_attrs[] = {
+	&bus_attr_enable.attr,
 	&bus_attr_rescan.attr,
 	NULL,
 };
@@ -541,6 +566,7 @@ void cdx_unregister_controller(struct cdx_controller *cdx)
 	if (cdx->id >= MAX_CDX_CONTROLLERS)
 		return;
 
+	cdx->ops->enable(cdx, false);
 	device_for_each_child(cdx->dev, NULL, cdx_unregister_device);
 	xa_erase(&cdx_controllers, cdx->id);
 }
drivers/cdx/controller/cdx_controller.c +0 -0
index dc52f95f8978..ac8081f23cbe 100644

drivers/cdx/controller/cdx_controller.c void cdx_rpmsg_pre_remove(struct cdx_controller *cdx) · line 48

Quoted 4 lines
drivers/cdx/controller/cdx_controller.c +1 -0
@@ -45,6 +45,21 @@ void cdx_rpmsg_pre_remove(struct cdx_controller *cdx)
 	cdx_mcdi_wait_for_quiescence(cdx->priv, MCDI_RPC_TIMEOUT);
 }
 
+static int cdx_bus_enable(struct cdx_controller *cdx, bool enable)

Why not just a disable and enable callback instead of being forced to always rembmer that "foo_enable(foo, false)" really is "foo_disable(foo)"?

This is messy, please be explicit.

thanks,

greg k-h

#3 lore raw

RE: [PATCH 1/4] cdx: add support for bus enable and disable

[AMD Official Use Only - General]

Quoted 44 lines
Quoted 9 lines

CDX bus needs to be disabled before updating/writing devices in the FPGA. Once the devices are written, the bus shall be enabled. This change provides sysfs entry to enable/disable the CDX bus.

Reviewed-by Pieter Jansen van Vuuren <pieter.jansen-van-

[email protected]>

Quoted 6 lines
---
 Documentation/ABI/testing/sysfs-bus-cdx | 11 +++++
 drivers/cdx/cdx.c                       | 26 ++++++++++++
 drivers/cdx/controller/cdx_controller.c | 27 +++++++++++++
 drivers/cdx/controller/mc_cdx_pcol.h    | 54

+++++++++++++++++++++++++

Review

Quoted 6 lines
 drivers/cdx/controller/mcdi_functions.c | 24 +++++++++++
 drivers/cdx/controller/mcdi_functions.h | 16 ++++++++
 include/linux/cdx/cdx_bus.h             |  6 +++
 7 files changed, 164 insertions(+)
(quoted diff) +0 -0

b/Documentation/ABI/testing/sysfs-bus-cdx

Quoted 7 lines

index 7af477f49998..0afa85b3c63b 100644

Documentation/ABI/testing/sysfs-bus-cdx +0 -0
@@ -11,6 +11,17 @@ Description:
 
              # echo 1 > /sys/bus/cdx/rescan
 

Documentation/ABI/testing/sysfs-bus-cdx Description: · line 23

Quoted 10 lines
Documentation/ABI/testing/sysfs-bus-cdx +10 -0
+What:              /sys/bus/cdx/enable
+Date:              July 2023
+Contact:   [email protected]
+Description:
+           Writing y/1/on to this file enables the CDX bus and
+           writing n/0/off disables the bus.
+
+           For example to disable CDX bus::
+
+             # echo 0 > /sys/bus/cdx/enable

What could go wrong! :)

Quoted 4 lines

You don't say why disabling / enabling the bus is needed, this feels like a very huge stick, why is this for all busses, and not just an individual CDX bus?

As said in the description of the patch, disabling/enabling is needed when FPGA is being reprogrammed. We would enhance this interface for handling multiple buses in v2.

Quoted 24 lines
Quoted 24 lines
Documentation/ABI/testing/sysfs-bus-cdx +1 -0
+
 What:              /sys/bus/cdx/devices/.../vendor
 Date:              March 2023
 Contact:   [email protected]
drivers/cdx/cdx.c +12 -0
index d2cad4c670a0..48c493a43491 100644
@@ -380,6 +380,30 @@ static struct attribute *cdx_dev_attrs[] = {
 };
 ATTRIBUTE_GROUPS(cdx_dev);
 
+static ssize_t enable_store(const struct bus_type *bus,
+                       const char *buf, size_t count)
+{
+   struct cdx_controller *cdx;
+   unsigned long index;
+   bool enable;
+   int ret;
+
+   if (kstrtobool(buf, &enable) < 0)
+           return -EINVAL;
+
+   xa_for_each(&cdx_controllers, index, cdx) {
Quoted 9 lines

drivers/cdx/cdx.c static struct attribute *cdx_dev_attrs[] = { · line 400

Quoted 6 lines
drivers/cdx/cdx.c +6 -0
+           if (cdx->enabled == enable)
+                   continue;
+
+           ret = cdx->ops->enable(cdx, enable);
+           if (ret)
+                   dev_err(cdx->dev, "cdx bus enable/disable failed\n");

You can say if this was enabled or disabled to help figure things out.

Will correct in v2.

Quoted 4 lines

drivers/cdx/cdx.c static struct attribute *cdx_dev_attrs[] = { · line 401

Quoted 1 line
drivers/cdx/cdx.c +1 -0
+   }

No locking needed at all? What happens if controllers are added or removed?

As of now we had only the controller but you are correct. We would add a lock to protect the controller list.

Quoted 37 lines

drivers/cdx/cdx.c static ssize_t rescan_store(const struct bus_type

Quoted 10 lines
drivers/cdx/cdx.c +5 -0
+
+   return count;
+}
+static BUS_ATTR_WO(enable);
+
 static ssize_t rescan_store(const struct bus_type *bus,
                        const char *buf, size_t count)
 {
@@ -410,6 +434,7 @@ static ssize_t rescan_store(const struct bus_type

*bus,

drivers/cdx/cdx.c void cdx_unregister_controller(struct cdx_controller

Quoted 8 lines
drivers/cdx/cdx.c +1 -0
 static BUS_ATTR_WO(rescan);
 
 static struct attribute *cdx_bus_attrs[] = {
+   &bus_attr_enable.attr,
    &bus_attr_rescan.attr,
    NULL,
 };
@@ -541,6 +566,7 @@ void cdx_unregister_controller(struct cdx_controller

*cdx)

Review

Quoted 8 lines
drivers/cdx/cdx.c +1 -0
    if (cdx->id >= MAX_CDX_CONTROLLERS)
            return;
 
+   cdx->ops->enable(cdx, false);
    device_for_each_child(cdx->dev, NULL, cdx_unregister_device);
    xa_erase(&cdx_controllers, cdx->id);
 }
(quoted diff) +0 -0

b/drivers/cdx/controller/cdx_controller.c

drivers/cdx/controller/cdx_controller.c void cdx_rpmsg_pre_remove(struct cdx_controller

Quoted 4 lines

index dc52f95f8978..ac8081f23cbe 100644

drivers/cdx/controller/cdx_controller.c +0 -0
@@ -45,6 +45,21 @@ void cdx_rpmsg_pre_remove(struct cdx_controller

*cdx)

Quoted 3 lines
drivers/cdx/controller/cdx_controller.c +0 -0
    cdx_mcdi_wait_for_quiescence(cdx->priv, MCDI_RPC_TIMEOUT);
 }
 
Quoted 6 lines

drivers/cdx/controller/cdx_controller.c void cdx_rpmsg_pre_remove(struct cdx_controller *cdx) · line 48

Quoted 1 line
drivers/cdx/controller/cdx_controller.c +1 -0
+static int cdx_bus_enable(struct cdx_controller *cdx, bool enable)

Why not just a disable and enable callback instead of being forced to always rembmer that "foo_enable(foo, false)" really is "foo_disable(foo)"?

This is messy, please be explicit.

Will update in v2.

Thanks,
Abhijit

#4 lore raw

Re: [PATCH 1/4] cdx: add support for bus enable and disable

Quoted 46 lines · Abhijit

[AMD Official Use Only - General]

Quoted 44 lines
Quoted 9 lines

CDX bus needs to be disabled before updating/writing devices in the FPGA. Once the devices are written, the bus shall be enabled. This change provides sysfs entry to enable/disable the CDX bus.

Reviewed-by Pieter Jansen van Vuuren <pieter.jansen-van-

[email protected]>

Quoted 6 lines
---
 Documentation/ABI/testing/sysfs-bus-cdx | 11 +++++
 drivers/cdx/cdx.c                       | 26 ++++++++++++
 drivers/cdx/controller/cdx_controller.c | 27 +++++++++++++
 drivers/cdx/controller/mc_cdx_pcol.h    | 54

+++++++++++++++++++++++++

Review

Quoted 6 lines
 drivers/cdx/controller/mcdi_functions.c | 24 +++++++++++
 drivers/cdx/controller/mcdi_functions.h | 16 ++++++++
 include/linux/cdx/cdx_bus.h             |  6 +++
 7 files changed, 164 insertions(+)
(quoted diff) +0 -0

b/Documentation/ABI/testing/sysfs-bus-cdx

Quoted 7 lines

index 7af477f49998..0afa85b3c63b 100644

Documentation/ABI/testing/sysfs-bus-cdx +0 -0
@@ -11,6 +11,17 @@ Description:
 
              # echo 1 > /sys/bus/cdx/rescan
 

Documentation/ABI/testing/sysfs-bus-cdx Description: · line 23

Quoted 10 lines
Documentation/ABI/testing/sysfs-bus-cdx +10 -0
+What:              /sys/bus/cdx/enable
+Date:              July 2023
+Contact:   [email protected]
+Description:
+           Writing y/1/on to this file enables the CDX bus and
+           writing n/0/off disables the bus.
+
+           For example to disable CDX bus::
+
+             # echo 0 > /sys/bus/cdx/enable

What could go wrong! :)

Quoted 6 lines
Quoted 4 lines

You don't say why disabling / enabling the bus is needed, this feels like a very huge stick, why is this for all busses, and not just an individual CDX bus?

As said in the description of the patch, disabling/enabling is needed when FPGA is being reprogrammed.

Ok, why would this not also be in the description for when you need to look up what this file does? You will not be able to track it back to the commit log very easily.

thanks,

greg k-h

#5 lore raw

PATCH 2/4 cdx: add sysfs for reset_all

In reply to Abhijit Gangurde

Add sysfs for reset_all entry which resets all the devices on the CDX bus.

---
 Documentation/ABI/testing/sysfs-bus-cdx | 11 ++++++++++
 drivers/cdx/cdx.c                       | 29 +++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
Documentation/ABI/testing/sysfs-bus-cdx +11 -0
index 0afa85b3c63b..d9e00058471d 100644
@@ -22,6 +22,17 @@ Description:
 
 		  # echo 0 > /sys/bus/cdx/enable
 
+What:		/sys/bus/cdx/reset_all
+Date:		July 2023
+Contact:	[email protected]
+Description:
+		Writing y/1/on to this file resets all the devices
+		present on the CDX bus
+
+		For example::
+
+		  # echo 1 > /sys/bus/cdx/reset_all
+
 What:		/sys/bus/cdx/devices/.../vendor
 Date:		March 2023
 Contact:	[email protected]
drivers/cdx/cdx.c +29 -0
index 48c493a43491..4d20047b55bb 100644
@@ -106,6 +106,11 @@ int cdx_dev_reset(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(cdx_dev_reset);
 
+static int reset_cdx_device(struct device *dev, void *data)
+{
+	return cdx_dev_reset(dev);
+}
+
 /**
  * cdx_unregister_device - Unregister a CDX device
  * @dev: CDX device
@@ -433,9 +438,33 @@ static ssize_t rescan_store(const struct bus_type *bus,
 }
 static BUS_ATTR_WO(rescan);
 
+static ssize_t reset_all_store(const struct bus_type *bus,
+			       const char *buf, size_t count)
+{
+	bool val;
+	int ret;
+
+	if (kstrtobool(buf, &val) < 0)
+		return -EINVAL;
+
+	if (!val)
+		return -EINVAL;
+
+	/* Reset all the devices attached to cdx bus */
+	ret = bus_for_each_dev(bus, NULL, NULL, reset_cdx_device);
+	if (ret) {
+		pr_err("error in CDX bus reset\n");
+		return 0;
+	}
+
+	return count;
+}
+static BUS_ATTR_WO(reset_all);
+
 static struct attribute *cdx_bus_attrs[] = {
 	&bus_attr_enable.attr,
 	&bus_attr_rescan.attr,
+	&bus_attr_reset_all.attr,
 	NULL,
 };
 ATTRIBUTE_GROUPS(cdx_bus);
Signature · 1 line
2.25.1
#6 lore raw

Re: [PATCH 2/4] cdx: add sysfs for reset_all

Quoted 2 lines · Abhijit Gangurde

Add sysfs for reset_all entry which resets all the devices on the CDX bus.

On all CDX busses, right? Why all? Why not per-bus?

Quoted 21 lines
---
 Documentation/ABI/testing/sysfs-bus-cdx | 11 ++++++++++
 drivers/cdx/cdx.c                       | 29 +++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
Documentation/ABI/testing/sysfs-bus-cdx +0 -0
index 0afa85b3c63b..d9e00058471d 100644
@@ -22,6 +22,17 @@ Description:
 
 		  # echo 0 > /sys/bus/cdx/enable
 

Documentation/ABI/testing/sysfs-bus-cdx Description: · line 34

Quoted 10 lines
Documentation/ABI/testing/sysfs-bus-cdx +10 -0
+What:		/sys/bus/cdx/reset_all
+Date:		July 2023
+Contact:	[email protected]
+Description:
+		Writing y/1/on to this file resets all the devices
+		present on the CDX bus
+
+		For example::
+
+		  # echo 1 > /sys/bus/cdx/reset_all

What does resetting a device mean will happen?

Quoted 28 lines
Documentation/ABI/testing/sysfs-bus-cdx +1 -0
+
 What:		/sys/bus/cdx/devices/.../vendor
 Date:		March 2023
 Contact:	[email protected]
drivers/cdx/cdx.c +9 -0
index 48c493a43491..4d20047b55bb 100644
@@ -106,6 +106,11 @@ int cdx_dev_reset(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(cdx_dev_reset);
 
+static int reset_cdx_device(struct device *dev, void *data)
+{
+	return cdx_dev_reset(dev);
+}
+
 /**
  * cdx_unregister_device - Unregister a CDX device
  * @dev: CDX device
@@ -433,9 +438,33 @@ static ssize_t rescan_store(const struct bus_type *bus,
 }
 static BUS_ATTR_WO(rescan);
 
+static ssize_t reset_all_store(const struct bus_type *bus,
+			       const char *buf, size_t count)
+{
+	bool val;

drivers/cdx/cdx.c static ssize_t rescan_store(const struct bus_type *bus, · line 454

Quoted 10 lines
drivers/cdx/cdx.c +10 -0
+	int ret;
+
+	if (kstrtobool(buf, &val) < 0)
+		return -EINVAL;
+
+	if (!val)
+		return -EINVAL;
+
+	/* Reset all the devices attached to cdx bus */
+	ret = bus_for_each_dev(bus, NULL, NULL, reset_cdx_device);

No locking needed?

drivers/cdx/cdx.c static ssize_t rescan_store(const struct bus_type *bus, · line 456

Quoted 2 lines
drivers/cdx/cdx.c +2 -0
+	if (ret) {
+		pr_err("error in CDX bus reset\n");

What error? For what device? Put the error message in the reset callback, not here, as you have no idea what device failed.

thanks,

greg k-h

#7 lore raw

RE: [PATCH 2/4] cdx: add sysfs for reset_all

[AMD Official Use Only - General]

Quoted 5 lines
Quoted 2 lines

Add sysfs for reset_all entry which resets all the devices on the CDX bus.

On all CDX busses, right? Why all? Why not per-bus?

This was on similar line to bus enable/disable. Would extend this to support per bus in v2.

Quoted 24 lines
Quoted 8 lines
Reviewed-by Pieter Jansen van Vuuren <pieter.jansen-van-

[email protected]>

Review

Quoted 7 lines
---
 Documentation/ABI/testing/sysfs-bus-cdx | 11 ++++++++++
 drivers/cdx/cdx.c                       | 29 +++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
(quoted diff) +0 -0

b/Documentation/ABI/testing/sysfs-bus-cdx

Quoted 7 lines

index 0afa85b3c63b..d9e00058471d 100644

Documentation/ABI/testing/sysfs-bus-cdx +0 -0
@@ -22,6 +22,17 @@ Description:
 
              # echo 0 > /sys/bus/cdx/enable
 
Quoted 12 lines

Documentation/ABI/testing/sysfs-bus-cdx Description: · line 34

Quoted 10 lines
Documentation/ABI/testing/sysfs-bus-cdx +10 -0
+What:              /sys/bus/cdx/reset_all
+Date:              July 2023
+Contact:   [email protected]
+Description:
+           Writing y/1/on to this file resets all the devices
+           present on the CDX bus
+
+           For example::
+
+             # echo 1 > /sys/bus/cdx/reset_all

What does resetting a device mean will happen?

It would be same of pcie flr to the device. Would add more description in v2.

Quoted 26 lines

drivers/cdx/cdx.c static ssize_t rescan_store(const struct bus_type

Quoted 22 lines
Documentation/ABI/testing/sysfs-bus-cdx +1 -0
+
 What:              /sys/bus/cdx/devices/.../vendor
 Date:              March 2023
 Contact:   [email protected]
drivers/cdx/cdx.c +5 -0
index 48c493a43491..4d20047b55bb 100644
@@ -106,6 +106,11 @@ int cdx_dev_reset(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(cdx_dev_reset);
 
+static int reset_cdx_device(struct device *dev, void *data)
+{
+   return cdx_dev_reset(dev);
+}
+
 /**
  * cdx_unregister_device - Unregister a CDX device
  * @dev: CDX device
@@ -433,9 +438,33 @@ static ssize_t rescan_store(const struct bus_type

*bus,

Quoted 3 lines
drivers/cdx/cdx.c +0 -0
 }
 static BUS_ATTR_WO(rescan);
 
Quoted 16 lines
Quoted 4 lines
drivers/cdx/cdx.c +4 -0
+static ssize_t reset_all_store(const struct bus_type *bus,
+                          const char *buf, size_t count)
+{
+   bool val;

drivers/cdx/cdx.c static ssize_t rescan_store(const struct bus_type *bus, · line 454

Quoted 10 lines
drivers/cdx/cdx.c +10 -0
+   int ret;
+
+   if (kstrtobool(buf, &val) < 0)
+           return -EINVAL;
+
+   if (!val)
+           return -EINVAL;
+
+   /* Reset all the devices attached to cdx bus */
+   ret = bus_for_each_dev(bus, NULL, NULL, reset_cdx_device);

No locking needed?

Would protect this with a lock.

Quoted 6 lines

drivers/cdx/cdx.c static ssize_t rescan_store(const struct bus_type *bus, · line 456

Quoted 3 lines
drivers/cdx/cdx.c +2 -0
+   if (ret) {
+           pr_err("error in CDX bus reset\n");

What error? For what device? Put the error message in the reset callback, not here, as you have no idea what device failed.

Would correct in v2.

Thanks,
Abhijit

#8 lore raw

PATCH 3/4 cdx: create sysfs resource files

In reply to Abhijit Gangurde

Resource files provides the basic MMIO regions info to the user-space. Also, resources<x> devices can be used to mmap the MMIO regions in the user-space.

---
 Documentation/ABI/testing/sysfs-bus-cdx |  15 +++
 drivers/cdx/cdx.c                       | 139 +++++++++++++++++++++++-
 include/linux/cdx/cdx_bus.h             |  10 ++
 3 files changed, 163 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-bus-cdx +15 -0
index d9e00058471d..6ca47b6442ce 100644
@@ -76,3 +76,18 @@ Description:
 		For example::
 
 		  # echo 1 > /sys/bus/cdx/devices/.../remove
+
+What:		/sys/bus/cdx/devices/.../resource
+Date:		July 2023
+Contact:	[email protected]
+Description:
+		The resource file contains host addresses of CDX device
+		resources. Each line of the resource file describes a region
+		with start, end, and flag fields.
+
+What:		/sys/bus/cdx/devices/.../resource<N>
+Date:		July 2023
+Contact:	[email protected]
+Description:
+		The resource binary file contains the content of the memory
+		regions. These files can be m'maped from userspace.
drivers/cdx/cdx.c +138 -1

181 lines not on this page · raw message

include/linux/cdx/cdx_bus.h +10 -0
index 5da0634ae4ee..e93f1cd8ae33 100644
@@ -104,6 +104,7 @@ struct cdx_device {
 	u8 bus_num;
 	u8 dev_num;
 	struct resource res[MAX_CDX_DEV_RESOURCES];
+	struct bin_attribute *res_attr[MAX_CDX_DEV_RESOURCES];
 	u8 res_count;
 	u64 dma_mask;
 	u16 flags;
@@ -114,6 +115,15 @@ struct cdx_device {
 #define to_cdx_device(_dev) \
 	container_of(_dev, struct cdx_device, dev)
 
+#define cdx_resource_start(dev, num)	((dev)->res[(num)].start)
+#define cdx_resource_end(dev, num)	((dev)->res[(num)].end)
+#define cdx_resource_flags(dev, num)	((dev)->res[(num)].flags)
+#define cdx_resource_len(dev, num) \
+	((cdx_resource_start((dev), (num)) == 0 &&	\
+	  cdx_resource_end((dev), (num)) ==		\
+	  cdx_resource_start((dev), (num))) ? 0 :	\
+	 (cdx_resource_end((dev), (num)) -		\
+	  cdx_resource_start((dev), (num)) + 1))
 /**
  * struct cdx_driver - CDX device driver
  * @driver: Generic device driver
Signature · 1 line
2.25.1
#9 lore raw

Re: [PATCH 3/4] cdx: create sysfs resource files

Quoted 23 lines · Abhijit Gangurde

Resource files provides the basic MMIO regions info to the user-space. Also, resources<x> devices can be used to mmap the MMIO regions in the user-space.

---
 Documentation/ABI/testing/sysfs-bus-cdx |  15 +++
 drivers/cdx/cdx.c                       | 139 +++++++++++++++++++++++-
 include/linux/cdx/cdx_bus.h             |  10 ++
 3 files changed, 163 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-bus-cdx +0 -0
index d9e00058471d..6ca47b6442ce 100644
@@ -76,3 +76,18 @@ Description:
 		For example::

Documentation/ABI/testing/sysfs-bus-cdx Description: · line 86

Quoted 10 lines
Documentation/ABI/testing/sysfs-bus-cdx +8 -0
 
 		  # echo 1 > /sys/bus/cdx/devices/.../remove
+
+What:		/sys/bus/cdx/devices/.../resource
+Date:		July 2023
+Contact:	[email protected]
+Description:
+		The resource file contains host addresses of CDX device
+		resources. Each line of the resource file describes a region
+		with start, end, and flag fields.

If you documented what this file looked like here, it would be obvious that this is not an acceptable sysfs file in any sense of the word.

Please do so, and then fix the patch to not do that at all.

thanks,

greg k-h

#10 lore raw

RE: [PATCH 3/4] cdx: create sysfs resource files

[AMD Official Use Only - General]

Quoted 39 lines
Quoted 10 lines

Resource files provides the basic MMIO regions info to the user-space. Also, resources<x> devices can be used to mmap the MMIO regions in the user-space.

Reviewed-by Pieter Jansen van Vuuren <pieter.jansen-van-

[email protected]>

Review

Quoted 8 lines
---
 Documentation/ABI/testing/sysfs-bus-cdx |  15 +++
 drivers/cdx/cdx.c                       | 139 +++++++++++++++++++++++-
 include/linux/cdx/cdx_bus.h             |  10 ++
 3 files changed, 163 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/Documentation/ABI/testing/sysfs-bus-cdx

Quoted 5 lines

index d9e00058471d..6ca47b6442ce 100644

Documentation/ABI/testing/sysfs-bus-cdx +0 -0
@@ -76,3 +76,18 @@ Description:
            For example::

Documentation/ABI/testing/sysfs-bus-cdx Description: · line 86

Quoted 10 lines
Documentation/ABI/testing/sysfs-bus-cdx +8 -0
 
              # echo 1 > /sys/bus/cdx/devices/.../remove
+
+What:              /sys/bus/cdx/devices/.../resource
+Date:              July 2023
+Contact:   [email protected]
+Description:
+           The resource file contains host addresses of CDX device
+           resources. Each line of the resource file describes a region
+           with start, end, and flag fields.

If you documented what this file looked like here, it would be obvious that this is not an acceptable sysfs file in any sense of the word.

Quoted 1 line

Please do so, and then fix the patch to not do that at all.

Similar interface exist for pci and we intended to keep it same way. Could you please elaborate on this.

# cat /sys/bus/pci/devices/0000\:01\:00.0/resource
0x0000000092100000 0x00000000921fffff 0x000000000014220c
0x0000000000000000 0x0000000000000000 0x0000000000000000

Thanks,
Abhijit

#11 lore raw

Re: [PATCH 3/4] cdx: create sysfs resource files

Quoted 41 lines · Abhijit

[AMD Official Use Only - General]

Quoted 39 lines
Quoted 10 lines

Resource files provides the basic MMIO regions info to the user-space. Also, resources<x> devices can be used to mmap the MMIO regions in the user-space.

Reviewed-by Pieter Jansen van Vuuren <pieter.jansen-van-

[email protected]>

Review

Quoted 8 lines
---
 Documentation/ABI/testing/sysfs-bus-cdx |  15 +++
 drivers/cdx/cdx.c                       | 139 +++++++++++++++++++++++-
 include/linux/cdx/cdx_bus.h             |  10 ++
 3 files changed, 163 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/Documentation/ABI/testing/sysfs-bus-cdx

Quoted 5 lines

index d9e00058471d..6ca47b6442ce 100644

Documentation/ABI/testing/sysfs-bus-cdx +0 -0
@@ -76,3 +76,18 @@ Description:
            For example::

Documentation/ABI/testing/sysfs-bus-cdx Description: · line 86

Quoted 10 lines
Documentation/ABI/testing/sysfs-bus-cdx +8 -0
 
              # echo 1 > /sys/bus/cdx/devices/.../remove
+
+What:              /sys/bus/cdx/devices/.../resource
+Date:              July 2023
+Contact:   [email protected]
+Description:
+           The resource file contains host addresses of CDX device
+           resources. Each line of the resource file describes a region
+           with start, end, and flag fields.

If you documented what this file looked like here, it would be obvious that this is not an acceptable sysfs file in any sense of the word.

Quoted 7 lines
Quoted 1 line

Please do so, and then fix the patch to not do that at all.

Similar interface exist for pci and we intended to keep it same way. Could you please elaborate on this.

# cat /sys/bus/pci/devices/0000\:01\:00.0/resource
0x0000000092100000 0x00000000921fffff 0x000000000014220c
0x0000000000000000 0x0000000000000000 0x0000000000000000

Please don't propagate incorrect decisions in the past.

Why do you need all of these "resources" in userspace? What tool is going to read and parse them and do something with them?

This really violates the "one value per file" sysfs rule, you are going to have to have a huge reason why this is not applicable here, AND you are going to have to document it very very well and get everyone to agree with it.

thanks,

greg k-h

#12 lore raw

RE: [PATCH 3/4] cdx: create sysfs resource files

[AMD Official Use Only - General]

Quoted 50 lines
Quoted 39 lines
Quoted 39 lines
Quoted 10 lines

Resource files provides the basic MMIO regions info to the user-space. Also, resources<x> devices can be used to mmap the MMIO regions in the user-space.

Reviewed-by Pieter Jansen van Vuuren <pieter.jansen-van-

[email protected]>

Review

Quoted 8 lines
---
 Documentation/ABI/testing/sysfs-bus-cdx |  15 +++
 drivers/cdx/cdx.c                       | 139 +++++++++++++++++++++++-
 include/linux/cdx/cdx_bus.h             |  10 ++
 3 files changed, 163 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/Documentation/ABI/testing/sysfs-bus-cdx

Quoted 5 lines

index d9e00058471d..6ca47b6442ce 100644

Documentation/ABI/testing/sysfs-bus-cdx +0 -0
@@ -76,3 +76,18 @@ Description:
            For example::

Documentation/ABI/testing/sysfs-bus-cdx Description: · line 86

Quoted 10 lines
Documentation/ABI/testing/sysfs-bus-cdx +8 -0
 
              # echo 1 > /sys/bus/cdx/devices/.../remove
+
+What:              /sys/bus/cdx/devices/.../resource
+Date:              July 2023
+Contact:   [email protected]
+Description:
+           The resource file contains host addresses of CDX device
+           resources. Each line of the resource file describes a region
+           with start, end, and flag fields.

If you documented what this file looked like here, it would be obvious that this is not an acceptable sysfs file in any sense of the word.

Quoted 3 lines
Quoted 1 line

Please do so, and then fix the patch to not do that at all.

Similar interface exist for pci and we intended to keep it same way. Could you

please elaborate on this.

Quoted 4 lines
# cat /sys/bus/pci/devices/0000\:01\:00.0/resource
0x0000000092100000 0x00000000921fffff 0x000000000014220c
0x0000000000000000 0x0000000000000000 0x0000000000000000

Please don't propagate incorrect decisions in the past.

Quoted 7 lines

Why do you need all of these "resources" in userspace? What tool is going to read and parse them and do something with them?

This really violates the "one value per file" sysfs rule, you are going to have to have a huge reason why this is not applicable here, AND you are going to have to document it very very well and get everyone to agree with it.

We don't have any strong reason apart from that this is being used by some test and debug applications. Will drop this one now and revisit later by complying to the specifications.

Thanks,
Abhijit

#13 lore raw

Re: [PATCH 3/4] cdx: create sysfs resource files

Quoted 55 lines · Abhijit

[AMD Official Use Only - General]

Quoted 53 lines
Quoted 39 lines
Quoted 39 lines
Quoted 10 lines

Resource files provides the basic MMIO regions info to the user-space. Also, resources<x> devices can be used to mmap the MMIO regions in the user-space.

Reviewed-by Pieter Jansen van Vuuren <pieter.jansen-van-

[email protected]>

Review

Quoted 8 lines
---
 Documentation/ABI/testing/sysfs-bus-cdx |  15 +++
 drivers/cdx/cdx.c                       | 139 +++++++++++++++++++++++-
 include/linux/cdx/cdx_bus.h             |  10 ++
 3 files changed, 163 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/Documentation/ABI/testing/sysfs-bus-cdx

Quoted 5 lines

index d9e00058471d..6ca47b6442ce 100644

Documentation/ABI/testing/sysfs-bus-cdx +0 -0
@@ -76,3 +76,18 @@ Description:
            For example::

Documentation/ABI/testing/sysfs-bus-cdx Description: · line 86

Quoted 10 lines
Documentation/ABI/testing/sysfs-bus-cdx +8 -0
 
              # echo 1 > /sys/bus/cdx/devices/.../remove
+
+What:              /sys/bus/cdx/devices/.../resource
+Date:              July 2023
+Contact:   [email protected]
+Description:
+           The resource file contains host addresses of CDX device
+           resources. Each line of the resource file describes a region
+           with start, end, and flag fields.

If you documented what this file looked like here, it would be obvious that this is not an acceptable sysfs file in any sense of the word.

Quoted 3 lines
Quoted 1 line

Please do so, and then fix the patch to not do that at all.

Similar interface exist for pci and we intended to keep it same way. Could you

please elaborate on this.

Quoted 4 lines
# cat /sys/bus/pci/devices/0000\:01\:00.0/resource
0x0000000092100000 0x00000000921fffff 0x000000000014220c
0x0000000000000000 0x0000000000000000 0x0000000000000000

Please don't propagate incorrect decisions in the past.

Why do you need all of these "resources" in userspace? What tool is going to read and parse them and do something with them?

Quoted 8 lines
Quoted 4 lines

This really violates the "one value per file" sysfs rule, you are going to have to have a huge reason why this is not applicable here, AND you are going to have to document it very very well and get everyone to agree with it.

We don't have any strong reason apart from that this is being used by some test and debug applications. Will drop this one now and revisit later by complying to the specifications.

If it's only for debug stuff, then use debugfs, that's what it is there for.

thanks,

greg k-h

#14 lore raw

PATCH 4/4 cdx: add sysfs for subsystem, class and revision

In reply to Abhijit Gangurde

RPU provides subsystem_vendor, subsystem_device, class and revision info of the device. Use the Subsystem vendor id, device id and class to match the cdx device. Subsystem vendor and device combination can be used to identify the card. This identification would be useful for cdx device driver for card specific operations.

---
 Documentation/ABI/testing/sysfs-bus-cdx | 45 +++++++++++++++++++++++++
 drivers/cdx/cdx.c                       | 29 +++++++++++++++-
 drivers/cdx/cdx.h                       |  8 +++++
 drivers/cdx/controller/mcdi_functions.c |  7 ++++
 include/linux/cdx/cdx_bus.h             | 27 +++++++++++++--
 include/linux/mod_devicetable.h         | 10 ++++++
 scripts/mod/devicetable-offsets.c       |  4 +++
 scripts/mod/file2alias.c                |  8 +++++
 8 files changed, 135 insertions(+), 3 deletions(-)
Documentation/ABI/testing/sysfs-bus-cdx +45 -0
index 6ca47b6442ce..da6459ac8fb2 100644
@@ -50,6 +50,36 @@ Description:
 		of a device manufacturer.
 		Combination of Vendor ID and Device ID identifies a device.
 
+What:		/sys/bus/cdx/devices/.../subsystem_vendor
+Date:		July 2023
+Contact:	[email protected]
+Description:
+		Subsystem Vendor ID for this CDX device, in hexadecimal.
+		Subsystem Vendor ID is 16 bit identifier specific to the
+		card manufacturer.
+
+What:		/sys/bus/cdx/devices/.../subsystem_device
+Date:		July 2023
+Contact:	[email protected]
+Description:
+		Subsystem Device ID for this CDX device, in hexadecimal
+		Subsystem Device ID is 16 bit identifier specific to the
+		card manufacturer.
+
+What:		/sys/bus/cdx/devices/.../class
+Date:		July 2023
+Contact:	[email protected]
+Description:
+		This file contains the class of the CDX device, in hexadecimal.
+		Class is 24 bit identifier specifies the functionality of the device.
+
+What:		/sys/bus/cdx/devices/.../revision
+Date:		July 2023
+Contact:	[email protected]
+Description:
+		This file contains the revision field of the CDX device, in hexadecimal.
+		Revision is 8 bit revision identifier of the device.
+
 What:		/sys/bus/cdx/devices/.../reset
 Date:		March 2023
 Contact:	[email protected]
@@ -91,3 +121,18 @@ Contact:	[email protected]
 Description:
 		The resource binary file contains the content of the memory
 		regions. These files can be m'maped from userspace.
+
+What:		/sys/bus/cdx/devices/.../modalias
+Date:		July 2023
+Contact:	[email protected]
+Description:
+		This attribute indicates the CDX ID of the device.
+		That is in the format:
+		cdx:vXXXXdXXXXsvXXXXsdXXXXcXXXXXX,
+		where:
+
+		    - vXXXX contains the vendor ID;
+		    - dXXXX contains the device ID;
+		    - svXXXX contains the subsystem vendor ID;
+		    - sdXXXX contains the subsystem device ID;
+		    - cXXXXXX contains the device class.
drivers/cdx/cdx.c +28 -1
index 9d568df8e566..e9055baf14bb 100644
@@ -162,7 +162,10 @@ cdx_match_one_device(const struct cdx_device_id *id,
 {
 	/* Use vendor ID and device ID for matching */
 	if ((id->vendor == CDX_ANY_ID || id->vendor == dev->vendor) &&
-	    (id->device == CDX_ANY_ID || id->device == dev->device))
+	    (id->device == CDX_ANY_ID || id->device == dev->device) &&
+	    (id->subvendor == CDX_ANY_ID || id->subvendor == dev->subsystem_vendor) &&
+	    (id->subdevice == CDX_ANY_ID || id->subdevice == dev->subsystem_device) &&
+	    !((id->class ^ dev->class) & id->class_mask))
 		return id;
 	return NULL;
 }
@@ -308,6 +311,10 @@ static DEVICE_ATTR_RO(field)
 
 cdx_config_attr(vendor, "0x%04x\n");
 cdx_config_attr(device, "0x%04x\n");
+cdx_config_attr(subsystem_vendor, "0x%04x\n");
+cdx_config_attr(subsystem_device, "0x%04x\n");
+cdx_config_attr(revision, "0x%02x\n");
+cdx_config_attr(class, "0x%06x\n");
 
 static ssize_t remove_store(struct device *dev,
 			    struct device_attribute *attr,
@@ -353,6 +360,17 @@ static ssize_t reset_store(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_WO(reset);
 
+static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
+			     char *buf)
+{
+	struct cdx_device *cdx_dev = to_cdx_device(dev);
+
+	return sprintf(buf, "cdx:v%04Xd%04Xsv%04Xsd%04Xc%06X\n", cdx_dev->vendor,
+			cdx_dev->device, cdx_dev->subsystem_vendor, cdx_dev->subsystem_device,
+			cdx_dev->class);
+}
+static DEVICE_ATTR_RO(modalias);
+
 static ssize_t driver_override_store(struct device *dev,
 				     struct device_attribute *attr,
 				     const char *buf, size_t count)
@@ -403,6 +421,11 @@ static struct attribute *cdx_dev_attrs[] = {
 	&dev_attr_reset.attr,
 	&dev_attr_vendor.attr,
 	&dev_attr_device.attr,
+	&dev_attr_subsystem_vendor.attr,
+	&dev_attr_subsystem_device.attr,
+	&dev_attr_class.attr,
+	&dev_attr_revision.attr,
+	&dev_attr_modalias.attr,
 	&dev_attr_driver_override.attr,
 	&dev_attr_resource.attr,
 	NULL,
@@ -652,6 +675,10 @@ int cdx_device_add(struct cdx_dev_params *dev_params)
 	cdx_dev->req_id = dev_params->req_id;
 	cdx_dev->vendor = dev_params->vendor;
 	cdx_dev->device = dev_params->device;
+	cdx_dev->subsystem_vendor = dev_params->subsys_vendor;
+	cdx_dev->subsystem_device = dev_params->subsys_device;
+	cdx_dev->class = dev_params->class;
+	cdx_dev->revision = dev_params->revision;
 	cdx_dev->bus_num = dev_params->bus_num;
 	cdx_dev->dev_num = dev_params->dev_num;
 	cdx_dev->cdx = dev_params->cdx;
drivers/cdx/cdx.h +8 -0
index c436ac7ac86f..d17b5a501e8d 100644
@@ -16,21 +16,29 @@
  * @parent: Associated CDX controller
  * @vendor: Vendor ID for CDX device
  * @device: Device ID for CDX device
+ * @subsys_vendor: Sub vendor ID for CDX device
+ * @subsys_device: Sub device ID for CDX device
  * @bus_num: Bus number for this CDX device
  * @dev_num: Device number for this device
  * @res: array of MMIO region entries
  * @res_count: number of valid MMIO regions
  * @req_id: Requestor ID associated with CDX device
+ * @class: Class of the CDX Device
+ * @revision: Revision of the CDX device
  */
 struct cdx_dev_params {
 	struct cdx_controller *cdx;
 	u16 vendor;
 	u16 device;
+	u16 subsys_vendor;
+	u16 subsys_device;
 	u8 bus_num;
 	u8 dev_num;
 	struct resource res[MAX_CDX_DEV_RESOURCES];
 	u8 res_count;
 	u32 req_id;
+	u32 class;
+	u8 revision;
 };
 
 /**
drivers/cdx/controller/mcdi_functions.c +7 -0
index 400fdc771104..a227922a03ca 100644
@@ -120,6 +120,13 @@ int cdx_mcdi_get_dev_config(struct cdx_mcdi *cdx,
 
 	dev_params->vendor = MCDI_WORD(outbuf, CDX_BUS_GET_DEVICE_CONFIG_OUT_VENDOR_ID);
 	dev_params->device = MCDI_WORD(outbuf, CDX_BUS_GET_DEVICE_CONFIG_OUT_DEVICE_ID);
+	dev_params->subsys_vendor = MCDI_WORD(outbuf,
+					      CDX_BUS_GET_DEVICE_CONFIG_OUT_SUBSYS_VENDOR_ID);
+	dev_params->subsys_device = MCDI_WORD(outbuf,
+					      CDX_BUS_GET_DEVICE_CONFIG_OUT_SUBSYS_DEVICE_ID);
+	dev_params->class = MCDI_DWORD(outbuf,
+				       CDX_BUS_GET_DEVICE_CONFIG_OUT_DEVICE_CLASS) & 0xFFFFFF;
+	dev_params->revision = MCDI_BYTE(outbuf, CDX_BUS_GET_DEVICE_CONFIG_OUT_DEVICE_REVISION);
 
 	return 0;
 }
include/linux/cdx/cdx_bus.h +25 -2
index e93f1cd8ae33..2fa727770d6d 100644
@@ -36,6 +36,19 @@ typedef int (*cdx_dev_configure_cb)(struct cdx_controller *cdx,
 				    u8 bus_num, u8 dev_num,
 				    struct cdx_device_config *dev_config);
 
+/**
+ * CDX_DEVICE - macro used to describe a specific CDX device
+ * @vend: the 16 bit CDX Vendor ID
+ * @dev: the 16 bit CDX Device ID
+ *
+ * This macro is used to create a struct cdx_device_id that matches a
+ * specific device. The subvendor and subdevice fields will be set to
+ * CDX_ANY_ID.
+ */
+#define CDX_DEVICE(vend, dev) \
+	.vendor = (vend), .device = (dev), \
+	.subvendor = CDX_ANY_ID, .subdevice = CDX_ANY_ID
+
 /**
  * CDX_DEVICE_DRIVER_OVERRIDE - macro used to describe a CDX device with
  *                              override_only flags.
@@ -44,10 +57,12 @@ typedef int (*cdx_dev_configure_cb)(struct cdx_controller *cdx,
  * @driver_override: the 32 bit CDX Device override_only
  *
  * This macro is used to create a struct cdx_device_id that matches only a
- * driver_override device.
+ * driver_override device. The subvendor and subdevice fields will be set to
+ * CDX_ANY_ID.
  */
 #define CDX_DEVICE_DRIVER_OVERRIDE(vend, dev, driver_override) \
-	.vendor = (vend), .device = (dev), .override_only = (driver_override)
+	.vendor = (vend), .device = (dev), .subvendor = CDX_ANY_ID,\
+	.subdevice = CDX_ANY_ID, .override_only = (driver_override)
 
 /**
  * struct cdx_ops - Callbacks supported by CDX controller.
@@ -84,6 +99,10 @@ struct cdx_controller {
  * @cdx: CDX controller associated with the device
  * @vendor: Vendor ID for CDX device
  * @device: Device ID for CDX device
+ * @subsystem_vendor: Subsystem Vendor ID for CDX device
+ * @subsystem_device: Subsystem Device ID for CDX device
+ * @class: Class for the CDX device
+ * @revision: Revision of the CDX device
  * @bus_num: Bus number for this CDX device
  * @dev_num: Device number for this device
  * @res: array of MMIO region entries
@@ -101,6 +120,10 @@ struct cdx_device {
 	struct cdx_controller *cdx;
 	u16 vendor;
 	u16 device;
+	u16 subsystem_vendor;
+	u16 subsystem_device;
+	u32 class;
+	u8 revision;
 	u8 bus_num;
 	u8 dev_num;
 	struct resource res[MAX_CDX_DEV_RESOURCES];
include/linux/mod_devicetable.h +10 -0
index b0678b093cb2..aa3c28781248 100644
@@ -935,6 +935,12 @@ enum {
  * struct cdx_device_id - CDX device identifier
  * @vendor: Vendor ID
  * @device: Device ID
+ * @subvendor: Subsystem vendor ID (or CDX_ANY_ID)
+ * @subdevice: Subsystem device ID (or CDX_ANY_ID)
+ * @class: Device class
+ *         Most drivers do not need to specify class/class_mask
+ *         as vendor/device is normally sufficient.
+ * @class_mask: Limit which sub-fields of the class field are compared.
  * @override_only: Match only when dev->driver_override is this driver.
  *
  * Type of entries in the "device Id" table for CDX devices supported by
@@ -943,6 +949,10 @@ enum {
 struct cdx_device_id {
 	__u16 vendor;
 	__u16 device;
+	__u16 subvendor;
+	__u16 subdevice;
+	__u32 class;
+	__u32 class_mask;
 	__u32 override_only;
 };
 
scripts/mod/devicetable-offsets.c +4 -0
index abe65f8968dd..7a659aa3114a 100644
@@ -265,6 +265,10 @@ int main(void)
 	DEVID(cdx_device_id);
 	DEVID_FIELD(cdx_device_id, vendor);
 	DEVID_FIELD(cdx_device_id, device);
+	DEVID_FIELD(cdx_device_id, subvendor);
+	DEVID_FIELD(cdx_device_id, subdevice);
+	DEVID_FIELD(cdx_device_id, class);
+	DEVID_FIELD(cdx_device_id, class_mask);
 	DEVID_FIELD(cdx_device_id, override_only);
 
 	return 0;
scripts/mod/file2alias.c +8 -0
index 38120f932b0d..abc4781d5db7 100644
@@ -1458,6 +1458,10 @@ static int do_cdx_entry(const char *filename, void *symval,
 {
 	DEF_FIELD(symval, cdx_device_id, vendor);
 	DEF_FIELD(symval, cdx_device_id, device);
+	DEF_FIELD(symval, cdx_device_id, subvendor);
+	DEF_FIELD(symval, cdx_device_id, subdevice);
+	DEF_FIELD(symval, cdx_device_id, class);
+	DEF_FIELD(symval, cdx_device_id, class_mask);
 	DEF_FIELD(symval, cdx_device_id, override_only);
 
 	switch (override_only) {
@@ -1475,6 +1479,10 @@ static int do_cdx_entry(const char *filename, void *symval,
 
 	ADD(alias, "v", vendor != CDX_ANY_ID, vendor);
 	ADD(alias, "d", device != CDX_ANY_ID, device);
+	ADD(alias, "sv", subvendor != CDX_ANY_ID, subvendor);
+	ADD(alias, "sd", subdevice != CDX_ANY_ID, subdevice);
+	ADD(alias, "c", class_mask == 0xFFFFFF, class);
+
 	return 1;
 }
 
Signature · 1 line
2.25.1
#15 lore raw

Re: [PATCH 4/4] cdx: add sysfs for subsystem, class and revision

Quoted 2 lines · Abhijit Gangurde

RPU provides subsystem_vendor, subsystem_device, class and revision info of the device.

What is "RPU"?

Quoted 4 lines

Use the Subsystem vendor id, device id and class
to match the cdx device. Subsystem vendor and device combination can be used to identify the card. This identification would be useful for cdx device driver for card specific operations.

Why aren't you binding devices to drivers based on this like all other bus types do?

Quoted 250 lines
---
 Documentation/ABI/testing/sysfs-bus-cdx | 45 +++++++++++++++++++++++++
 drivers/cdx/cdx.c                       | 29 +++++++++++++++-
 drivers/cdx/cdx.h                       |  8 +++++
 drivers/cdx/controller/mcdi_functions.c |  7 ++++
 include/linux/cdx/cdx_bus.h             | 27 +++++++++++++--
 include/linux/mod_devicetable.h         | 10 ++++++
 scripts/mod/devicetable-offsets.c       |  4 +++
 scripts/mod/file2alias.c                |  8 +++++
 8 files changed, 135 insertions(+), 3 deletions(-)
Documentation/ABI/testing/sysfs-bus-cdx +45 -0
index 6ca47b6442ce..da6459ac8fb2 100644
@@ -50,6 +50,36 @@ Description:
 		of a device manufacturer.
 		Combination of Vendor ID and Device ID identifies a device.
 
+What:		/sys/bus/cdx/devices/.../subsystem_vendor
+Date:		July 2023
+Contact:	[email protected]
+Description:
+		Subsystem Vendor ID for this CDX device, in hexadecimal.
+		Subsystem Vendor ID is 16 bit identifier specific to the
+		card manufacturer.
+
+What:		/sys/bus/cdx/devices/.../subsystem_device
+Date:		July 2023
+Contact:	[email protected]
+Description:
+		Subsystem Device ID for this CDX device, in hexadecimal
+		Subsystem Device ID is 16 bit identifier specific to the
+		card manufacturer.
+
+What:		/sys/bus/cdx/devices/.../class
+Date:		July 2023
+Contact:	[email protected]
+Description:
+		This file contains the class of the CDX device, in hexadecimal.
+		Class is 24 bit identifier specifies the functionality of the device.
+
+What:		/sys/bus/cdx/devices/.../revision
+Date:		July 2023
+Contact:	[email protected]
+Description:
+		This file contains the revision field of the CDX device, in hexadecimal.
+		Revision is 8 bit revision identifier of the device.
+
 What:		/sys/bus/cdx/devices/.../reset
 Date:		March 2023
 Contact:	[email protected]
@@ -91,3 +121,18 @@ Contact:	[email protected]
 Description:
 		The resource binary file contains the content of the memory
 		regions. These files can be m'maped from userspace.
+
+What:		/sys/bus/cdx/devices/.../modalias
+Date:		July 2023
+Contact:	[email protected]
+Description:
+		This attribute indicates the CDX ID of the device.
+		That is in the format:
+		cdx:vXXXXdXXXXsvXXXXsdXXXXcXXXXXX,
+		where:
+
+		    - vXXXX contains the vendor ID;
+		    - dXXXX contains the device ID;
+		    - svXXXX contains the subsystem vendor ID;
+		    - sdXXXX contains the subsystem device ID;
+		    - cXXXXXX contains the device class.
drivers/cdx/cdx.c +28 -1
index 9d568df8e566..e9055baf14bb 100644
@@ -162,7 +162,10 @@ cdx_match_one_device(const struct cdx_device_id *id,
 {
 	/* Use vendor ID and device ID for matching */
 	if ((id->vendor == CDX_ANY_ID || id->vendor == dev->vendor) &&
-	    (id->device == CDX_ANY_ID || id->device == dev->device))
+	    (id->device == CDX_ANY_ID || id->device == dev->device) &&
+	    (id->subvendor == CDX_ANY_ID || id->subvendor == dev->subsystem_vendor) &&
+	    (id->subdevice == CDX_ANY_ID || id->subdevice == dev->subsystem_device) &&
+	    !((id->class ^ dev->class) & id->class_mask))
 		return id;
 	return NULL;
 }
@@ -308,6 +311,10 @@ static DEVICE_ATTR_RO(field)
 
 cdx_config_attr(vendor, "0x%04x\n");
 cdx_config_attr(device, "0x%04x\n");
+cdx_config_attr(subsystem_vendor, "0x%04x\n");
+cdx_config_attr(subsystem_device, "0x%04x\n");
+cdx_config_attr(revision, "0x%02x\n");
+cdx_config_attr(class, "0x%06x\n");
 
 static ssize_t remove_store(struct device *dev,
 			    struct device_attribute *attr,
@@ -353,6 +360,17 @@ static ssize_t reset_store(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_WO(reset);
 
+static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
+			     char *buf)
+{
+	struct cdx_device *cdx_dev = to_cdx_device(dev);
+
+	return sprintf(buf, "cdx:v%04Xd%04Xsv%04Xsd%04Xc%06X\n", cdx_dev->vendor,
+			cdx_dev->device, cdx_dev->subsystem_vendor, cdx_dev->subsystem_device,
+			cdx_dev->class);
+}
+static DEVICE_ATTR_RO(modalias);
+
 static ssize_t driver_override_store(struct device *dev,
 				     struct device_attribute *attr,
 				     const char *buf, size_t count)
@@ -403,6 +421,11 @@ static struct attribute *cdx_dev_attrs[] = {
 	&dev_attr_reset.attr,
 	&dev_attr_vendor.attr,
 	&dev_attr_device.attr,
+	&dev_attr_subsystem_vendor.attr,
+	&dev_attr_subsystem_device.attr,
+	&dev_attr_class.attr,
+	&dev_attr_revision.attr,
+	&dev_attr_modalias.attr,
 	&dev_attr_driver_override.attr,
 	&dev_attr_resource.attr,
 	NULL,
@@ -652,6 +675,10 @@ int cdx_device_add(struct cdx_dev_params *dev_params)
 	cdx_dev->req_id = dev_params->req_id;
 	cdx_dev->vendor = dev_params->vendor;
 	cdx_dev->device = dev_params->device;
+	cdx_dev->subsystem_vendor = dev_params->subsys_vendor;
+	cdx_dev->subsystem_device = dev_params->subsys_device;
+	cdx_dev->class = dev_params->class;
+	cdx_dev->revision = dev_params->revision;
 	cdx_dev->bus_num = dev_params->bus_num;
 	cdx_dev->dev_num = dev_params->dev_num;
 	cdx_dev->cdx = dev_params->cdx;
drivers/cdx/cdx.h +8 -0
index c436ac7ac86f..d17b5a501e8d 100644
@@ -16,21 +16,29 @@
  * @parent: Associated CDX controller
  * @vendor: Vendor ID for CDX device
  * @device: Device ID for CDX device
+ * @subsys_vendor: Sub vendor ID for CDX device
+ * @subsys_device: Sub device ID for CDX device
  * @bus_num: Bus number for this CDX device
  * @dev_num: Device number for this device
  * @res: array of MMIO region entries
  * @res_count: number of valid MMIO regions
  * @req_id: Requestor ID associated with CDX device
+ * @class: Class of the CDX Device
+ * @revision: Revision of the CDX device
  */
 struct cdx_dev_params {
 	struct cdx_controller *cdx;
 	u16 vendor;
 	u16 device;
+	u16 subsys_vendor;
+	u16 subsys_device;
 	u8 bus_num;
 	u8 dev_num;
 	struct resource res[MAX_CDX_DEV_RESOURCES];
 	u8 res_count;
 	u32 req_id;
+	u32 class;
+	u8 revision;
 };
 
 /**
drivers/cdx/controller/mcdi_functions.c +7 -0
index 400fdc771104..a227922a03ca 100644
@@ -120,6 +120,13 @@ int cdx_mcdi_get_dev_config(struct cdx_mcdi *cdx,
 
 	dev_params->vendor = MCDI_WORD(outbuf, CDX_BUS_GET_DEVICE_CONFIG_OUT_VENDOR_ID);
 	dev_params->device = MCDI_WORD(outbuf, CDX_BUS_GET_DEVICE_CONFIG_OUT_DEVICE_ID);
+	dev_params->subsys_vendor = MCDI_WORD(outbuf,
+					      CDX_BUS_GET_DEVICE_CONFIG_OUT_SUBSYS_VENDOR_ID);
+	dev_params->subsys_device = MCDI_WORD(outbuf,
+					      CDX_BUS_GET_DEVICE_CONFIG_OUT_SUBSYS_DEVICE_ID);
+	dev_params->class = MCDI_DWORD(outbuf,
+				       CDX_BUS_GET_DEVICE_CONFIG_OUT_DEVICE_CLASS) & 0xFFFFFF;
+	dev_params->revision = MCDI_BYTE(outbuf, CDX_BUS_GET_DEVICE_CONFIG_OUT_DEVICE_REVISION);
 
 	return 0;
 }
include/linux/cdx/cdx_bus.h +21 -2
index e93f1cd8ae33..2fa727770d6d 100644
@@ -36,6 +36,19 @@ typedef int (*cdx_dev_configure_cb)(struct cdx_controller *cdx,
 				    u8 bus_num, u8 dev_num,
 				    struct cdx_device_config *dev_config);
 
+/**
+ * CDX_DEVICE - macro used to describe a specific CDX device
+ * @vend: the 16 bit CDX Vendor ID
+ * @dev: the 16 bit CDX Device ID
+ *
+ * This macro is used to create a struct cdx_device_id that matches a
+ * specific device. The subvendor and subdevice fields will be set to
+ * CDX_ANY_ID.
+ */
+#define CDX_DEVICE(vend, dev) \
+	.vendor = (vend), .device = (dev), \
+	.subvendor = CDX_ANY_ID, .subdevice = CDX_ANY_ID
+
 /**
  * CDX_DEVICE_DRIVER_OVERRIDE - macro used to describe a CDX device with
  *                              override_only flags.
@@ -44,10 +57,12 @@ typedef int (*cdx_dev_configure_cb)(struct cdx_controller *cdx,
  * @driver_override: the 32 bit CDX Device override_only
  *
  * This macro is used to create a struct cdx_device_id that matches only a
- * driver_override device.
+ * driver_override device. The subvendor and subdevice fields will be set to
+ * CDX_ANY_ID.
  */
 #define CDX_DEVICE_DRIVER_OVERRIDE(vend, dev, driver_override) \
-	.vendor = (vend), .device = (dev), .override_only = (driver_override)
+	.vendor = (vend), .device = (dev), .subvendor = CDX_ANY_ID,\
+	.subdevice = CDX_ANY_ID, .override_only = (driver_override)
 
 /**
  * struct cdx_ops - Callbacks supported by CDX controller.
@@ -84,6 +99,10 @@ struct cdx_controller {
  * @cdx: CDX controller associated with the device
  * @vendor: Vendor ID for CDX device
  * @device: Device ID for CDX device
+ * @subsystem_vendor: Subsystem Vendor ID for CDX device
+ * @subsystem_device: Subsystem Device ID for CDX device
+ * @class: Class for the CDX device
+ * @revision: Revision of the CDX device
  * @bus_num: Bus number for this CDX device
  * @dev_num: Device number for this device
  * @res: array of MMIO region entries

include/linux/cdx/cdx_bus.h struct cdx_device { · line 125

Quoted 6 lines
include/linux/cdx/cdx_bus.h +3 -0
@@ -101,6 +120,10 @@ struct cdx_device {
 	struct cdx_controller *cdx;
 	u16 vendor;
 	u16 device;
+	u16 subsystem_vendor;
+	u16 subsystem_device;
+	u32 class;

What endian are these attributes? Please be specific for all of them (also for vendor and device, right?)

thanks,

greg k-h

#16 lore raw

RE: [PATCH 4/4] cdx: add sysfs for subsystem, class and revision

[AMD Official Use Only - General]

Quoted 4 lines
Quoted 2 lines

RPU provides subsystem_vendor, subsystem_device, class and revision info of the device.

What is "RPU"?

RPU is the remote processor on which firmware runs(controller). Will update the patch description in v2.

Quoted 8 lines
Quoted 5 lines

Use the Subsystem vendor id, device id and class
to match the cdx device. Subsystem vendor and device combination can be used to identify the card. This identification would be useful for cdx device driver for card specific operations.

Why aren't you binding devices to drivers based on this like all other bus types do?

We are using similar binding to match the device to driver. Would update the patch description in v2.

<snip>

Quoted 15 lines
Quoted 15 lines

/**
* struct cdx_ops - Callbacks supported by CDX controller.

include/linux/cdx/cdx_bus.h +4 -0
@@ -84,6 +99,10 @@ struct cdx_controller {
  * @cdx: CDX controller associated with the device
  * @vendor: Vendor ID for CDX device
  * @device: Device ID for CDX device
+ * @subsystem_vendor: Subsystem Vendor ID for CDX device
+ * @subsystem_device: Subsystem Device ID for CDX device
+ * @class: Class for the CDX device
+ * @revision: Revision of the CDX device
  * @bus_num: Bus number for this CDX device
  * @dev_num: Device number for this device
  * @res: array of MMIO region entries
@@ -101,6 +120,10 @@ struct cdx_device {
    struct cdx_controller *cdx;
Quoted 9 lines

include/linux/cdx/cdx_bus.h struct cdx_device { · line 125

Quoted 5 lines
include/linux/cdx/cdx_bus.h +3 -0
    u16 vendor;
    u16 device;
+   u16 subsystem_vendor;
+   u16 subsystem_device;
+   u32 class;

What endian are these attributes? Please be specific for all of them (also for vendor and device, right?)

Will update this in v2.

Thanks,
Abhijit