cdx: add support for bus mastering
Nipun Gupta
maintainerPATCH v3 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.
---
Changes v2->v3
- Changed return value from EOPNOTSUPP to -EOPNOTSUPP in cdx_set_master()
Changes v1->v2:
- Replace bme with bus_master_enable
- Added check for dev_configure API callback
- remove un-necessary error prints
- changed conditional to if-else
- updated commit message to use 72 columns
drivers/cdx/cdx.c | 29 +++++++++++++ drivers/cdx/controller/cdx_controller.c | 4 ++ drivers/cdx/controller/mcdi_functions.c | 58 +++++++++++++++++++++++++ drivers/cdx/controller/mcdi_functions.h | 13 ++++++ include/linux/cdx/cdx_bus.h | 16 +++++++ 5 files changed, 120 insertions(+)
drivers/cdx/cdx.c +29 -0
@@ -182,6 +182,35 @@ 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 = -EOPNOTSUPP ; + + dev_config.type =CDX_DEV_BUS_MASTER_CONF ; + dev_config.bus_master_enable = true; +if (cdx->ops->dev_configure) + ret = cdx->ops->dev_configure (cdx, cdx_dev->bus_num, + cdx_dev->dev_num, &dev_config); + +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; + + dev_config.type =CDX_DEV_BUS_MASTER_CONF ; + dev_config.bus_master_enable = false; +if (cdx->ops->dev_configure) + cdx->ops->dev_configure (cdx, cdx_dev->bus_num, + cdx_dev->dev_num, &dev_config); +} +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
@@ -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->bus_master_enable); +break ;default : ret = -EINVAL ; }
drivers/cdx/controller/mcdi_functions.c +58 -0
61 lines not on this page · raw message
drivers/cdx/controller/mcdi_functions.h +13 -0
@@ -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
@@ -21,11 +21,13 @@struct cdx_controller ;enum { +CDX_DEV_BUS_MASTER_CONF ,CDX_DEV_RESET_CONF , };struct cdx_device_config {u8 type; +bool bus_master_enable; };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
Quoted 7 lines · Nipun Gupta
Introduce
cdx_set_master()andcdx_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.Signed-off-by Nipun Gupta <[email protected]>Reviewed-by Pieter Jansen van Vuuren <[email protected]>---
You are adding apis here that no one is actually using, making it pretty impossible to see if they are being used properly, or if they are even needed at all.
Please submit this as part of a patch series that uses the apis, otherwise there's no need for anyone to accept this patch.
thanks,
greg k-h