Skip to contentSkip to conversation

cdx: add support for bus mastering

PATCH Superseded Nipun Gupta 2 participants 4 messages Jul 18, 2023 – Jul 19, 2023 AMD cdx bus driver

v1 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Nipun Gupta

author maintainer
#0 lore raw

PATCH 1/1 cdx: add support for bus mastering

Introduce cdx_set_master() and cdx_clear_master() APIs to support enable and disable of bus mastering. Drivers need to use these APIs to enable/disable DMAs from the CDX devices.

---
 drivers/cdx/cdx.c                       | 32 ++++++++++++++
 drivers/cdx/controller/cdx_controller.c |  4 ++
 drivers/cdx/controller/mcdi_functions.c | 57 +++++++++++++++++++++++++
 drivers/cdx/controller/mcdi_functions.h | 13 ++++++
 include/linux/cdx/cdx_bus.h             | 16 +++++++
 5 files changed, 122 insertions(+)
drivers/cdx/cdx.c +32 -0
index d2cad4c670a0..efb24672b7d9 100644
@@ -182,6 +182,38 @@ cdx_match_id(const struct cdx_device_id *ids, struct cdx_device *dev)
 	return NULL;
 }
 
+int cdx_set_master(struct cdx_device *cdx_dev)
+{
+	struct cdx_controller *cdx = cdx_dev->cdx;
+	struct cdx_device_config dev_config;
+	int ret;
+
+	dev_config.type = CDX_DEV_BUS_MASTER_CONF;
+	dev_config.bme = true;
+	ret = cdx->ops->dev_configure(cdx, cdx_dev->bus_num,
+				      cdx_dev->dev_num, &dev_config);
+	if (ret)
+		dev_err(&cdx_dev->dev, "device master enable failed\n");
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(cdx_set_master);
+
+void cdx_clear_master(struct cdx_device *cdx_dev)
+{
+	struct cdx_controller *cdx = cdx_dev->cdx;
+	struct cdx_device_config dev_config;
+	int ret;
+
+	dev_config.type = CDX_DEV_BUS_MASTER_CONF;
+	dev_config.bme = false;
+	ret = cdx->ops->dev_configure(cdx, cdx_dev->bus_num,
+				      cdx_dev->dev_num, &dev_config);
+	if (ret)
+		dev_err(&cdx_dev->dev, "device master disable failed\n");
+}
+EXPORT_SYMBOL_GPL(cdx_clear_master);
+
 /**
  * cdx_bus_match - device to driver matching callback
  * @dev: the cdx device to match against
drivers/cdx/controller/cdx_controller.c +4 -0
index dc52f95f8978..ba670f0427d3 100644
@@ -55,6 +55,10 @@ static int cdx_configure_device(struct cdx_controller *cdx,
 	case CDX_DEV_RESET_CONF:
 		ret = cdx_mcdi_reset_device(cdx->priv, bus_num, dev_num);
 		break;
+	case CDX_DEV_BUS_MASTER_CONF:
+		ret = cdx_mcdi_bus_master_enable(cdx->priv, bus_num, dev_num,
+						 dev_config->bme);
+		break;
 	default:
 		ret = -EINVAL;
 	}
drivers/cdx/controller/mcdi_functions.c +57 -0

60 lines not on this page · raw message

drivers/cdx/controller/mcdi_functions.h +13 -0
index 7440ace5539a..a448d6581eb4 100644
@@ -58,4 +58,17 @@ int cdx_mcdi_get_dev_config(struct cdx_mcdi *cdx,
 int cdx_mcdi_reset_device(struct cdx_mcdi *cdx,
 			  u8 bus_num, u8 dev_num);
 
+/**
+ * cdx_mcdi_bus_master_enable - Set/Reset bus mastering for cdx device
+ *				represented by bus_num:dev_num
+ * @cdx: pointer to MCDI interface.
+ * @bus_num: Bus number.
+ * @dev_num: Device number.
+ * @enable: Enable bus mastering if set, disable otherwise.
+ *
+ * Return: 0 on success, <0 on failure
+ */
+int cdx_mcdi_bus_master_enable(struct cdx_mcdi *cdx, u8 bus_num,
+			       u8 dev_num, bool enable);
+
 #endif /* CDX_MCDI_FUNCTIONS_H */
include/linux/cdx/cdx_bus.h +16 -0
index bead71b7bc73..acb4e40bd20e 100644
@@ -21,11 +21,13 @@
 struct cdx_controller;
 
 enum {
+	CDX_DEV_BUS_MASTER_CONF,
 	CDX_DEV_RESET_CONF,
 };
 
 struct cdx_device_config {
 	u8 type;
+	bool bme;
 };
 
 typedef int (*cdx_scan_cb)(struct cdx_controller *cdx);
@@ -170,4 +172,18 @@ extern struct bus_type cdx_bus_type;
  */
 int cdx_dev_reset(struct device *dev);
 
+/**
+ * cdx_set_master - enables bus-mastering for CDX device
+ * @cdx_dev: the CDX device to enable
+ *
+ * Return: 0 for success, -errno on failure
+ */
+int cdx_set_master(struct cdx_device *cdx_dev);
+
+/**
+ * cdx_clear_master - disables bus-mastering for CDX device
+ * @cdx_dev: the CDX device to disable
+ */
+void cdx_clear_master(struct cdx_device *cdx_dev);
+
 #endif /* _CDX_BUS_H_ */
Signature · 1 line
2.17.1
#1 lore raw
Quoted 4 lines · Nipun Gupta

Introduce cdx_set_master() and cdx_clear_master() APIs to support enable and disable of bus mastering. Drivers need to use these APIs to enable/disable DMAs from the CDX devices.

You do have a full 72 columns, why not use that?

Quoted 16 lines
---
 drivers/cdx/cdx.c                       | 32 ++++++++++++++
 drivers/cdx/controller/cdx_controller.c |  4 ++
 drivers/cdx/controller/mcdi_functions.c | 57 +++++++++++++++++++++++++
 drivers/cdx/controller/mcdi_functions.h | 13 ++++++
 include/linux/cdx/cdx_bus.h             | 16 +++++++
 5 files changed, 122 insertions(+)
drivers/cdx/cdx.c +0 -0
index d2cad4c670a0..efb24672b7d9 100644
@@ -182,6 +182,38 @@ cdx_match_id(const struct cdx_device_id *ids, struct cdx_device *dev)
 	return NULL;

drivers/cdx/cdx.c cdx_match_id(const struct cdx_device_id *ids, struct cdx_device *dev) · line 192

Quoted 10 lines
drivers/cdx/cdx.c +8 -0
 }
 
+int cdx_set_master(struct cdx_device *cdx_dev)
+{
+	struct cdx_controller *cdx = cdx_dev->cdx;
+	struct cdx_device_config dev_config;
+	int ret;
+
+	dev_config.type = CDX_DEV_BUS_MASTER_CONF;
+	dev_config.bme = true;

What is "bme"?

And are you sure that the config can be on the stack?

drivers/cdx/cdx.c cdx_match_id(const struct cdx_device_id *ids, struct cdx_device *dev) · line 194

Quoted 2 lines
drivers/cdx/cdx.c +2 -0
+	ret = cdx->ops->dev_configure(cdx, cdx_dev->bus_num,
+				      cdx_dev->dev_num, &dev_config);

Will dev_configure always be there?

drivers/cdx/cdx.c cdx_match_id(const struct cdx_device_id *ids, struct cdx_device *dev) · line 196

Quoted 2 lines
drivers/cdx/cdx.c +2 -0
+	if (ret)
+		dev_err(&cdx_dev->dev, "device master enable failed\n");

Why error out here, shouldn't the call have printed something if it wanted to?

Quoted 7 lines
drivers/cdx/cdx.c +7 -0
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(cdx_set_master);
+
+void cdx_clear_master(struct cdx_device *cdx_dev)
+{

drivers/cdx/cdx.c cdx_match_id(const struct cdx_device_id *ids, struct cdx_device *dev) · line 213

Quoted 10 lines
drivers/cdx/cdx.c +10 -0
+	struct cdx_controller *cdx = cdx_dev->cdx;
+	struct cdx_device_config dev_config;
+	int ret;
+
+	dev_config.type = CDX_DEV_BUS_MASTER_CONF;
+	dev_config.bme = false;
+	ret = cdx->ops->dev_configure(cdx, cdx_dev->bus_num,
+				      cdx_dev->dev_num, &dev_config);
+	if (ret)
+		dev_err(&cdx_dev->dev, "device master disable failed\n");

Same question as above.

Quoted 26 lines
drivers/cdx/cdx.c +3 -0
+}
+EXPORT_SYMBOL_GPL(cdx_clear_master);
+
 /**
  * cdx_bus_match - device to driver matching callback
  * @dev: the cdx device to match against
drivers/cdx/controller/cdx_controller.c +4 -0
index dc52f95f8978..ba670f0427d3 100644
@@ -55,6 +55,10 @@ static int cdx_configure_device(struct cdx_controller *cdx,
 	case CDX_DEV_RESET_CONF:
 		ret = cdx_mcdi_reset_device(cdx->priv, bus_num, dev_num);
 		break;
+	case CDX_DEV_BUS_MASTER_CONF:
+		ret = cdx_mcdi_bus_master_enable(cdx->priv, bus_num, dev_num,
+						 dev_config->bme);
+		break;
 	default:
 		ret = -EINVAL;
 	}
drivers/cdx/controller/mcdi_functions.c +0 -0
index 0158f26533dd..c4c00f376006 100644

drivers/cdx/controller/mcdi_functions.c int cdx_mcdi_reset_device(struct cdx_mcdi *cdx, u8 bus_num, u8 dev_num) · line 145

Quoted 9 lines
drivers/cdx/controller/mcdi_functions.c +6 -0
@@ -137,3 +137,60 @@ int cdx_mcdi_reset_device(struct cdx_mcdi *cdx, u8 bus_num, u8 dev_num)
 
 	return ret;
 }
+
+static int cdx_mcdi_ctrl_flag_get(struct cdx_mcdi *cdx, u8 bus_num,
+				  u8 dev_num, u32 *flags)
+{
+	MCDI_DECLARE_BUF(inbuf, MC_CMD_CDX_DEVICE_CONTROL_GET_IN_LEN);
+	MCDI_DECLARE_BUF(outbuf, MC_CMD_CDX_DEVICE_CONTROL_GET_OUT_LEN);

How big are these buffers?

Quoted 24 lines
drivers/cdx/controller/mcdi_functions.c +24 -0
+	size_t outlen;
+	int ret;
+
+	MCDI_SET_DWORD(inbuf, CDX_DEVICE_CONTROL_GET_IN_BUS, bus_num);
+	MCDI_SET_DWORD(inbuf, CDX_DEVICE_CONTROL_GET_IN_DEVICE, dev_num);
+	ret = cdx_mcdi_rpc(cdx, MC_CMD_CDX_DEVICE_CONTROL_GET, inbuf,
+			   sizeof(inbuf), outbuf, sizeof(outbuf), &outlen);
+	if (ret)
+		return ret;
+
+	if (outlen != MC_CMD_CDX_DEVICE_CONTROL_GET_OUT_LEN)
+		return -EIO;
+
+	*flags = MCDI_DWORD(outbuf, CDX_DEVICE_CONTROL_GET_OUT_FLAGS);
+
+	return 0;
+}
+
+static int cdx_mcdi_ctrl_flag_set(struct cdx_mcdi *cdx, u8 bus_num,
+				  u8 dev_num, bool enable, int lbn)
+{
+	MCDI_DECLARE_BUF(inbuf, MC_CMD_CDX_DEVICE_CONTROL_SET_IN_LEN);
+	int ret, en;
+	u32 flags;

drivers/cdx/controller/mcdi_functions.c int cdx_mcdi_reset_device(struct cdx_mcdi *cdx, u8 bus_num, u8 dev_num) · line 179

Quoted 10 lines
drivers/cdx/controller/mcdi_functions.c +10 -0
+
+	/*
+	 * Get flags and then set/reset BUS_MASTER_BIT according to
+	 * the input params.
+	 */
+	ret = cdx_mcdi_ctrl_flag_get(cdx, bus_num, dev_num, &flags);
+	if (ret)
+		return ret;
+
+	en = enable ? 1 : 0;

if/then/else?

Quoted 44 lines
drivers/cdx/controller/mcdi_functions.c +17 -0
+	flags = (flags & (u32)(~(BIT(lbn)))) | (en << lbn);
+
+	MCDI_SET_DWORD(inbuf, CDX_DEVICE_CONTROL_SET_IN_BUS, bus_num);
+	MCDI_SET_DWORD(inbuf, CDX_DEVICE_CONTROL_SET_IN_DEVICE, dev_num);
+	MCDI_SET_DWORD(inbuf, CDX_DEVICE_CONTROL_SET_IN_FLAGS, flags);
+	ret = cdx_mcdi_rpc(cdx, MC_CMD_CDX_DEVICE_CONTROL_SET, inbuf,
+			   sizeof(inbuf), NULL, 0, NULL);
+
+	return ret;
+}
+
+int cdx_mcdi_bus_master_enable(struct cdx_mcdi *cdx, u8 bus_num,
+			       u8 dev_num, bool enable)
+{
+	return cdx_mcdi_ctrl_flag_set(cdx, bus_num, dev_num, enable,
+			MC_CMD_CDX_DEVICE_CONTROL_SET_IN_BUS_MASTER_ENABLE_LBN);
+}
drivers/cdx/controller/mcdi_functions.h +13 -0
index 7440ace5539a..a448d6581eb4 100644
@@ -58,4 +58,17 @@ int cdx_mcdi_get_dev_config(struct cdx_mcdi *cdx,
 int cdx_mcdi_reset_device(struct cdx_mcdi *cdx,
 			  u8 bus_num, u8 dev_num);
 
+/**
+ * cdx_mcdi_bus_master_enable - Set/Reset bus mastering for cdx device
+ *				represented by bus_num:dev_num
+ * @cdx: pointer to MCDI interface.
+ * @bus_num: Bus number.
+ * @dev_num: Device number.
+ * @enable: Enable bus mastering if set, disable otherwise.
+ *
+ * Return: 0 on success, <0 on failure
+ */
+int cdx_mcdi_bus_master_enable(struct cdx_mcdi *cdx, u8 bus_num,
+			       u8 dev_num, bool enable);
+
 #endif /* CDX_MCDI_FUNCTIONS_H */
include/linux/cdx/cdx_bus.h +0 -0
index bead71b7bc73..acb4e40bd20e 100644

include/linux/cdx/cdx_bus.h line 30

Quoted 10 lines
include/linux/cdx/cdx_bus.h +2 -0
@@ -21,11 +21,13 @@
 struct cdx_controller;
 
 enum {
+	CDX_DEV_BUS_MASTER_CONF,
 	CDX_DEV_RESET_CONF,
 };
 
 struct cdx_device_config {
 	u8 type;
+	bool bme;

What does "bme" mean?

thanks,

greg k-h

author maintainer
#2 lore raw
Quoted 7 lines · Greg KH
Quoted 4 lines · Nipun Gupta

Introduce cdx_set_master() and cdx_clear_master() APIs to support enable and disable of bus mastering. Drivers need to use these APIs to enable/disable DMAs from the CDX devices.

You do have a full 72 columns, why not use that?

sure, will update accordingly.

Quoted 19 lines
Quoted 19 lines
---
  drivers/cdx/cdx.c                       | 32 ++++++++++++++
  drivers/cdx/controller/cdx_controller.c |  4 ++
  drivers/cdx/controller/mcdi_functions.c | 57 +++++++++++++++++++++++++
  drivers/cdx/controller/mcdi_functions.h | 13 ++++++
  include/linux/cdx/cdx_bus.h             | 16 +++++++
  5 files changed, 122 insertions(+)
drivers/cdx/cdx.c +0 -0
index d2cad4c670a0..efb24672b7d9 100644
@@ -182,6 +182,38 @@ cdx_match_id(const struct cdx_device_id *ids, struct cdx_device *dev)
  	return NULL;
  }
 
Quoted 10 lines

drivers/cdx/cdx.c cdx_match_id(const struct cdx_device_id *ids, struct cdx_device *dev) · line 192

Quoted 8 lines
drivers/cdx/cdx.c +8 -0
+int cdx_set_master(struct cdx_device *cdx_dev)
+{
+	struct cdx_controller *cdx = cdx_dev->cdx;
+	struct cdx_device_config dev_config;
+	int ret;
+
+	dev_config.type = CDX_DEV_BUS_MASTER_CONF;
+	dev_config.bme = true;

What is "bme"?

This is bus master enable. I will add a comment on the structure definition.

Quoted 2 lines

And are you sure that the config can be on the stack?

Yes, as this information is used by the controller and a new created command is sent to the Firmware/Hardware.

Quoted 5 lines

drivers/cdx/cdx.c cdx_match_id(const struct cdx_device_id *ids, struct cdx_device *dev) · line 194

Quoted 3 lines
drivers/cdx/cdx.c +2 -0
+	ret = cdx->ops->dev_configure(cdx, cdx_dev->bus_num,
+				      cdx_dev->dev_num, &dev_config);

Will dev_configure always be there?

This is expected to be there, but will add a check for further assurance.

Quoted 6 lines

drivers/cdx/cdx.c cdx_match_id(const struct cdx_device_id *ids, struct cdx_device *dev) · line 196

Quoted 3 lines
drivers/cdx/cdx.c +2 -0
+	if (ret)
+		dev_err(&cdx_dev->dev, "device master enable failed\n");

Why error out here, shouldn't the call have printed something if it wanted to?

Agree, will remove

Quoted 12 lines
Quoted 12 lines
drivers/cdx/cdx.c +11 -0
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(cdx_set_master);
+
+void cdx_clear_master(struct cdx_device *cdx_dev)
+{
+	struct cdx_controller *cdx = cdx_dev->cdx;
+	struct cdx_device_config dev_config;
+	int ret;
+
Quoted 8 lines

drivers/cdx/cdx.c cdx_match_id(const struct cdx_device_id *ids, struct cdx_device *dev) · line 213

Quoted 6 lines
drivers/cdx/cdx.c +6 -0
+	dev_config.type = CDX_DEV_BUS_MASTER_CONF;
+	dev_config.bme = false;
+	ret = cdx->ops->dev_configure(cdx, cdx_dev->bus_num,
+				      cdx_dev->dev_num, &dev_config);
+	if (ret)
+		dev_err(&cdx_dev->dev, "device master disable failed\n");

Same question as above.

sure will remove

Quoted 28 lines
Quoted 28 lines
drivers/cdx/cdx.c +3 -0
+}
+EXPORT_SYMBOL_GPL(cdx_clear_master);
+
  /**
   * cdx_bus_match - device to driver matching callback
   * @dev: the cdx device to match against
drivers/cdx/controller/cdx_controller.c +4 -0
index dc52f95f8978..ba670f0427d3 100644
@@ -55,6 +55,10 @@ static int cdx_configure_device(struct cdx_controller *cdx,
  	case CDX_DEV_RESET_CONF:
  		ret = cdx_mcdi_reset_device(cdx->priv, bus_num, dev_num);
  		break;
+	case CDX_DEV_BUS_MASTER_CONF:
+		ret = cdx_mcdi_bus_master_enable(cdx->priv, bus_num, dev_num,
+						 dev_config->bme);
+		break;
  	default:
  		ret = -EINVAL;
  	}
drivers/cdx/controller/mcdi_functions.c +0 -0
index 0158f26533dd..c4c00f376006 100644
@@ -137,3 +137,60 @@ int cdx_mcdi_reset_device(struct cdx_mcdi *cdx, u8 bus_num, u8 dev_num)
 
Quoted 10 lines

drivers/cdx/controller/mcdi_functions.c int cdx_mcdi_reset_device(struct cdx_mcdi *cdx, u8 bus_num, u8 dev_num) · line 145

Quoted 8 lines
drivers/cdx/controller/mcdi_functions.c +6 -0
  	return ret;
  }
+
+static int cdx_mcdi_ctrl_flag_get(struct cdx_mcdi *cdx, u8 bus_num,
+				  u8 dev_num, u32 *flags)
+{
+	MCDI_DECLARE_BUF(inbuf, MC_CMD_CDX_DEVICE_CONTROL_GET_IN_LEN);
+	MCDI_DECLARE_BUF(outbuf, MC_CMD_CDX_DEVICE_CONTROL_GET_OUT_LEN);

How big are these buffers?

The defines are as follows in mc_cdx_pcol.h:
#define MC_CMD_CDX_DEVICE_CONTROL_GET_IN_LEN 8
#define MC_CMD_CDX_DEVICE_CONTROL_GET_OUT_LEN 4

where MCDI_DECLARE_BUF leads to creation of a variable of data structure:
/* A doubleword (i.e. 4 byte) datatype - little-endian in HW */

struct cdx_dword {
        __le32 cdx_u32;
};

so inbuf is of 32 bytes (8 * 4) and outbuf is 16 bytes (4 * 4).

Quoted 29 lines
Quoted 29 lines
drivers/cdx/controller/mcdi_functions.c +28 -0
+	size_t outlen;
+	int ret;
+
+	MCDI_SET_DWORD(inbuf, CDX_DEVICE_CONTROL_GET_IN_BUS, bus_num);
+	MCDI_SET_DWORD(inbuf, CDX_DEVICE_CONTROL_GET_IN_DEVICE, dev_num);
+	ret = cdx_mcdi_rpc(cdx, MC_CMD_CDX_DEVICE_CONTROL_GET, inbuf,
+			   sizeof(inbuf), outbuf, sizeof(outbuf), &outlen);
+	if (ret)
+		return ret;
+
+	if (outlen != MC_CMD_CDX_DEVICE_CONTROL_GET_OUT_LEN)
+		return -EIO;
+
+	*flags = MCDI_DWORD(outbuf, CDX_DEVICE_CONTROL_GET_OUT_FLAGS);
+
+	return 0;
+}
+
+static int cdx_mcdi_ctrl_flag_set(struct cdx_mcdi *cdx, u8 bus_num,
+				  u8 dev_num, bool enable, int lbn)
+{
+	MCDI_DECLARE_BUF(inbuf, MC_CMD_CDX_DEVICE_CONTROL_SET_IN_LEN);
+	int ret, en;
+	u32 flags;
+
+	/*
+	 * Get flags and then set/reset BUS_MASTER_BIT according to
+	 * the input params.
Quoted 8 lines

drivers/cdx/controller/mcdi_functions.c int cdx_mcdi_reset_device(struct cdx_mcdi *cdx, u8 bus_num, u8 dev_num) · line 179

Quoted 6 lines
drivers/cdx/controller/mcdi_functions.c +6 -0
+	 */
+	ret = cdx_mcdi_ctrl_flag_get(cdx, bus_num, dev_num, &flags);
+	if (ret)
+		return ret;
+
+	en = enable ? 1 : 0;

if/then/else?

okay. will update

Quoted 53 lines
Quoted 53 lines
drivers/cdx/controller/mcdi_functions.c +17 -0
+	flags = (flags & (u32)(~(BIT(lbn)))) | (en << lbn);
+
+	MCDI_SET_DWORD(inbuf, CDX_DEVICE_CONTROL_SET_IN_BUS, bus_num);
+	MCDI_SET_DWORD(inbuf, CDX_DEVICE_CONTROL_SET_IN_DEVICE, dev_num);
+	MCDI_SET_DWORD(inbuf, CDX_DEVICE_CONTROL_SET_IN_FLAGS, flags);
+	ret = cdx_mcdi_rpc(cdx, MC_CMD_CDX_DEVICE_CONTROL_SET, inbuf,
+			   sizeof(inbuf), NULL, 0, NULL);
+
+	return ret;
+}
+
+int cdx_mcdi_bus_master_enable(struct cdx_mcdi *cdx, u8 bus_num,
+			       u8 dev_num, bool enable)
+{
+	return cdx_mcdi_ctrl_flag_set(cdx, bus_num, dev_num, enable,
+			MC_CMD_CDX_DEVICE_CONTROL_SET_IN_BUS_MASTER_ENABLE_LBN);
+}
drivers/cdx/controller/mcdi_functions.h +13 -0
index 7440ace5539a..a448d6581eb4 100644
@@ -58,4 +58,17 @@ int cdx_mcdi_get_dev_config(struct cdx_mcdi *cdx,
  int cdx_mcdi_reset_device(struct cdx_mcdi *cdx,
  			  u8 bus_num, u8 dev_num);
 
+/**
+ * cdx_mcdi_bus_master_enable - Set/Reset bus mastering for cdx device
+ *				represented by bus_num:dev_num
+ * @cdx: pointer to MCDI interface.
+ * @bus_num: Bus number.
+ * @dev_num: Device number.
+ * @enable: Enable bus mastering if set, disable otherwise.
+ *
+ * Return: 0 on success, <0 on failure
+ */
+int cdx_mcdi_bus_master_enable(struct cdx_mcdi *cdx, u8 bus_num,
+			       u8 dev_num, bool enable);
+
  #endif /* CDX_MCDI_FUNCTIONS_H */
include/linux/cdx/cdx_bus.h +1 -0
index bead71b7bc73..acb4e40bd20e 100644
@@ -21,11 +21,13 @@
  struct cdx_controller;
 
  enum {
+	CDX_DEV_BUS_MASTER_CONF,
  	CDX_DEV_RESET_CONF,
  };
 
Quoted 5 lines

include/linux/cdx/cdx_bus.h line 30

Quoted 3 lines
include/linux/cdx/cdx_bus.h +1 -0
  struct cdx_device_config {
  	u8 type;
+	bool bme;

What does "bme" mean?

This is bus master enable bit. Will add comment.

Thanks,
Nipun

Quoted 4 lines

thanks,

greg k-h

#3 lore raw
Quoted 42 lines · Nipun
Quoted 7 lines · Greg KH
Quoted 4 lines · Nipun Gupta

Introduce cdx_set_master() and cdx_clear_master() APIs to support enable and disable of bus mastering. Drivers need to use these APIs to enable/disable DMAs from the CDX devices.

You do have a full 72 columns, why not use that?

sure, will update accordingly.

Quoted 20 lines
Quoted 20 lines
---
  drivers/cdx/cdx.c                       | 32 ++++++++++++++
  drivers/cdx/controller/cdx_controller.c |  4 ++
  drivers/cdx/controller/mcdi_functions.c | 57 +++++++++++++++++++++++++
  drivers/cdx/controller/mcdi_functions.h | 13 ++++++
  include/linux/cdx/cdx_bus.h             | 16 +++++++
  5 files changed, 122 insertions(+)
drivers/cdx/cdx.c +2 -0
index d2cad4c670a0..efb24672b7d9 100644
@@ -182,6 +182,38 @@ cdx_match_id(const struct cdx_device_id *ids, struct cdx_device *dev)
  	return NULL;
  }
+int cdx_set_master(struct cdx_device *cdx_dev)
+{
Quoted 8 lines

drivers/cdx/cdx.c cdx_match_id(const struct cdx_device_id *ids, struct cdx_device *dev) · line 192

Quoted 6 lines
drivers/cdx/cdx.c +6 -0
+	struct cdx_controller *cdx = cdx_dev->cdx;
+	struct cdx_device_config dev_config;
+	int ret;
+
+	dev_config.type = CDX_DEV_BUS_MASTER_CONF;
+	dev_config.bme = true;

What is "bme"?

Quoted 1 line

This is bus master enable. I will add a comment on the structure definition.

Better yet, spell it out "bus_master_enable" so no one has to look up the comment, no need to try to make cryptic variable names :)

thanks,

greg k-h