mei: use sprintf in tx_queue_limit_show sysfs
Subsystems (2)
PATCH 1/6 mei: use sprintf in tx_queue_limit_show sysfs
Using of snprintf is discouraged in sysfs.
For simple u8 it is safe to use sprintf.
--- drivers/misc/mei/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/mei/main.c +1 -1
@@ -1026,7 +1026,7 @@ static ssize_t tx_queue_limit_show(struct device *device, size = dev->tx_queue_limit;mutex_unlock (&dev->device_lock); -return snprintf (buf,PAGE_SIZE ,"%u\n" , size); +return sprintf (buf,"%u\n" , size); } static ssize_t tx_queue_limit_store(struct device *device,
Signature · 1 line
2.26.2
PATCH 2/6 mei: allow clients on bus to communicate in remove callback
From: Alexander Usyskin <[email protected]>
Introduce new intermediate state to allow the clients on the bus to communicate with the firmware from the remove handler. This is to enable to perform a clean shutdown.
--- drivers/misc/mei/bus.c | 6 ++++-- drivers/misc/mei/client.c | 3 ++- drivers/misc/mei/init.c | 5 ++++- drivers/misc/mei/mei_dev.h | 1 + 4 files changed, 11 insertions(+), 4 deletions(-)
drivers/misc/mei/bus.c +4 -2
@@ -44,7 +44,8 @@ ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length, u8 vtag, bus = cl->dev;mutex_lock (&bus->device_lock); -if (bus->dev_state !=MEI_DEV_ENABLED ) { +if (bus->dev_state !=MEI_DEV_ENABLED && + bus->dev_state !=MEI_DEV_POWERING_DOWN ) { rets = -ENODEV ; goto out; }
@@ -128,7 +129,8 @@ ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length, u8 *vtag, bus = cl->dev;mutex_lock (&bus->device_lock); -if (bus->dev_state !=MEI_DEV_ENABLED ) { +if (bus->dev_state !=MEI_DEV_ENABLED && + bus->dev_state !=MEI_DEV_POWERING_DOWN ) { rets = -ENODEV ; goto out; }
drivers/misc/mei/client.c +2 -1
@@ -990,7 +990,8 @@ int mei_cl_disconnect(struct mei_cl *cl)return 0 ; } -if (dev->dev_state ==MEI_DEV_POWER_DOWN ) { +if (dev->dev_state ==MEI_DEV_POWERING_DOWN || + dev->dev_state ==MEI_DEV_POWER_DOWN ) {cl_dbg (dev, cl,"Device is powering down, don't bother with disconnection\n" );mei_cl_set_disconnected (cl);return 0 ;
drivers/misc/mei/init.c +4 -1
@@ -303,9 +303,12 @@ void mei_stop(struct mei_device *dev)dev_dbg (dev->dev,"stopping the device.\n" );mutex_lock (&dev->device_lock); -mei_set_devstate (dev,MEI_DEV_POWER_DOWN ); +mei_set_devstate (dev,MEI_DEV_POWERING_DOWN );mutex_unlock (&dev->device_lock);mei_cl_bus_remove_devices (dev); +mutex_lock (&dev->device_lock); +mei_set_devstate (dev,MEI_DEV_POWER_DOWN ); +mutex_unlock (&dev->device_lock);mei_cancel_work (dev);
drivers/misc/mei/mei_dev.h +1 -0
@@ -57,6 +57,7 @@ enum mei_dev_state {MEI_DEV_ENABLED ,MEI_DEV_RESETTING ,MEI_DEV_DISABLED , +MEI_DEV_POWERING_DOWN ,MEI_DEV_POWER_DOWN , MEI_DEV_POWER_UP };
Signature · 1 line
2.26.2
PATCH 3/6 mei: add support for client dma capability
In reply to Tomas WinklerFrom: Alexander Usyskin <[email protected]>
Client DMA capability indicates whether the firmware supports setting up a direct DMA channel between the host and me client.
The DMA capabilities are supported from firmware HBM version 2.2 and newer.
--- drivers/misc/mei/debugfs.c | 1 + drivers/misc/mei/hbm.c | 13 ++++++++++++- drivers/misc/mei/hw.h | 8 ++++++++ drivers/misc/mei/mei_dev.h | 2 ++ 4 files changed, 23 insertions(+), 1 deletion(-)
drivers/misc/mei/debugfs.c +1 -0
@@ -106,6 +106,7 @@ static int mei_dbgfs_devstate_show(struct seq_file *m, void *unused)seq_printf (m,"\tDR: %01d\n" , dev->hbm_f_dr_supported);seq_printf (m,"\tVT: %01d\n" , dev->hbm_f_vt_supported);seq_printf (m,"\tCAP: %01d\n" , dev->hbm_f_cap_supported); +seq_printf (m,"\tCD: %01d\n" , dev->hbm_f_cd_supported); } seq_printf(m, "pg: %s, %s\n",
drivers/misc/mei/hbm.c +12 -1
@@ -339,7 +339,9 @@ static int mei_hbm_capabilities_req(struct mei_device *dev)memset (&req,0 ,sizeof (req)); req.hbm_cmd =MEI_HBM_CAPABILITIES_REQ_CMD ;if (dev->hbm_f_vt_supported) - req.capability_requested[0 ] =HBM_CAP_VT ; + req.capability_requested[0 ] |=HBM_CAP_VT ; +if (dev->hbm_f_cd_supported) + req.capability_requested[0 ] |=HBM_CAP_CD ; ret =mei_hbm_write_message (dev, &mei_hdr, &req);if (ret) {
@@ -1085,6 +1087,13 @@ static void mei_hbm_config_features(struct mei_device *dev) (dev->version.major_version ==HBM_MAJOR_VERSION_CAP && dev->version.minor_version >= HBM_MINOR_VERSION_CAP)) dev->hbm_f_cap_supported = 1; + +/* Client DMA Support */ + dev->hbm_f_cd_supported =0 ; +if (dev->version.major_version >HBM_MAJOR_VERSION_CD || + (dev->version.major_version ==HBM_MAJOR_VERSION_CD && + dev->version.minor_version >=HBM_MINOR_VERSION_CD )) + dev->hbm_f_cd_supported =1 ; }/**
@@ -1233,6 +1242,8 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr) capability_res = (struct hbm_capability_response *)mei_msg;if (!(capability_res->capability_granted[0 ] &HBM_CAP_VT )) dev->hbm_f_vt_supported =0 ; +if (!(capability_res->capability_granted[0 ] &HBM_CAP_CD )) + dev->hbm_f_cd_supported =0 ;if (dev->hbm_f_dr_supported) {if (mei_dmam_ring_alloc (dev))
drivers/misc/mei/hw.h +8 -0
@@ -88,6 +88,12 @@#define HBM_MINOR_VERSION_CAP 2#define HBM_MAJOR_VERSION_CAP 2 +/* +* MEI version with client DMA support +*/ +#define HBM_MINOR_VERSION_CD 2 +#define HBM_MAJOR_VERSION_CD 2 +/* Host bus message command opcode */ #define MEI_HBM_CMD_OP_MSK 0x7f/* Host bus message command RESPONSE */
@@ -648,6 +654,8 @@ struct hbm_dma_ring_ctrl {/* virtual tag supported */ #define HBM_CAP_VT BIT(0) +/* client dma supported */ +#define HBM_CAP_CD BIT(2)/** * struct hbm_capability_request - capability request from host to fw
drivers/misc/mei/mei_dev.h +2 -0
@@ -451,6 +451,7 @@ struct mei_fw_version {* @hbm_f_dr_supported : hbm feature dma ring supported * @hbm_f_vt_supported : hbm feature vtag supported * @hbm_f_cap_supported : hbm feature capabilities message supported +* @hbm_f_cd_supported : hbm feature client dma supported * * @fw_ver : FW versions *
@@ -538,6 +539,7 @@ struct mei_device { unsigned int hbm_f_dr_supported:1; unsigned int hbm_f_vt_supported:1; unsigned int hbm_f_cap_supported:1; + unsigned int hbm_f_cd_supported:1;struct mei_fw_version fw_ver[MEI_MAX_FW_VER_BLOCKS ];
Signature · 1 line
2.26.2
PATCH 4/6 mei: hbm: add client dma hbm messages
In reply to Tomas WinklerFrom: Alexander Usyskin <[email protected]>
Define structures for client DMA HBM protocol.
The protocol requires passing dma buffer address
and the buffer id.
--- drivers/misc/mei/hw.h | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)
drivers/misc/mei/hw.h +53 -0
@@ -142,6 +142,12 @@#define MEI_HBM_CAPABILITIES_REQ_CMD 0x13#define MEI_HBM_CAPABILITIES_RES_CMD 0x93 +#define MEI_HBM_CLIENT_DMA_MAP_REQ_CMD 0x14 +#define MEI_HBM_CLIENT_DMA_MAP_RES_CMD 0x94 + +#define MEI_HBM_CLIENT_DMA_UNMAP_REQ_CMD 0x15 +#define MEI_HBM_CLIENT_DMA_UNMAP_RES_CMD 0x95 +/* * MEI Stop Reason * used by hbm_host_stop_request.reason
@@ -679,4 +685,51 @@ struct hbm_capability_response { u8 capability_granted[3]; } __packed; +/** +* struct hbm_client_dma_map_request - client dma map request from host to fw +* +* @hbm_cmd: bus message command header +* @client_buffer_id: client buffer id +* @reserved: reserved +* @address_lsb: DMA address LSB +* @address_msb: DMA address MSB +* @size: DMA size +*/ +struct hbm_client_dma_map_request { +u8 hbm_cmd; +u8 client_buffer_id; +u8 reserved[2 ]; +u32 address_lsb; +u32 address_msb; +u32 size; +} __packed; + +/** +* struct hbm_client_dma_unmap_request +* client dma unmap request from the host to the firmware +* +* @hbm_cmd: bus message command header +* @status: unmap status +* @client_buffer_id: client buffer id +* @reserved: reserved +*/ +struct hbm_client_dma_unmap_request { +u8 hbm_cmd; +u8 status; +u8 client_buffer_id; +u8 reserved; +} __packed; + +/** +* struct hbm_client_dma_response +* client dma unmap response from the firmware to the host +* +* @hbm_cmd: bus message command header +* @status: command status +*/ +struct hbm_client_dma_response { +u8 hbm_cmd; +u8 status; +} __packed; +#endif
Signature · 1 line
2.26.2
PATCH 5/6 mei: implement client dma setup.
In reply to Tomas WinklerFrom: Alexander Usyskin <[email protected]>
Implement HBM message protocol to setup and tear down DMA buffer on behalf of an client. On top there DMA buffer allocation and its life time management.
--- drivers/misc/mei/client.c | 286 +++++++++++++++++++++++++++++++++++ drivers/misc/mei/client.h | 8 + drivers/misc/mei/hbm.c | 124 +++++++++++++++ drivers/misc/mei/hbm.h | 4 +- drivers/misc/mei/interrupt.c | 10 ++ drivers/misc/mei/mei_dev.h | 15 ++ 6 files changed, 446 insertions(+), 1 deletion(-)
drivers/misc/mei/client.c +286 -0
@@ -9,6 +9,7 @@#include <linux/delay.h> #include <linux/slab.h> #include <linux/pm_runtime.h> +#include <linux/dma-mapping.h> #include <linux/mei.h>
@@ -2114,6 +2115,8 @@ void mei_cl_complete(struct mei_cl *cl, struct mei_cl_cb *cb)case MEI_FOP_DISCONNECT :case MEI_FOP_NOTIFY_STOP :case MEI_FOP_NOTIFY_START : +case MEI_FOP_DMA_MAP : +case MEI_FOP_DMA_UNMAP :if (waitqueue_active (&cl->wait))wake_up (&cl->wait);
@@ -2140,3 +2143,286 @@ void mei_cl_all_disconnect(struct mei_device *dev)list_for_each_entry (cl, &dev->file_list, link)mei_cl_set_disconnected (cl); } + +static struct mei_cl *mei_cl_dma_map_find (struct mei_device *dev,u8 buffer_id) +{ +struct mei_cl *cl; + +list_for_each_entry (cl, &dev->file_list, link) +if (cl->dma.buffer_id == buffer_id) +return cl; +return NULL ; +} + +/** +* mei_cl_irq_dma_map - send client dma map request in irq_thread context +* +* @cl: client +* @cb: callback block. +* @cmpl_list: complete list. +* +* Return: 0 on such and error otherwise. +*/ +int mei_cl_irq_dma_map (struct mei_cl *cl,struct mei_cl_cb *cb, +struct list_head *cmpl_list) +{ +struct mei_device *dev = cl->dev; +u32 msg_slots; +int slots; +int ret; + + msg_slots =mei_hbm2slots (sizeof (struct hbm_client_dma_map_request )); + slots =mei_hbuf_empty_slots (dev); +if (slots <0 ) +return -EOVERFLOW ; + +if ((u32 )slots < msg_slots) +return -EMSGSIZE ; + + ret =mei_hbm_cl_dma_map_req (dev, cl); +if (ret) { + cl->status = ret; +list_move_tail (&cb->list, cmpl_list); +return ret; + } + +list_move_tail (&cb->list, &dev->ctrl_rd_list); +return 0 ; +} + +/** +* mei_cl_irq_dma_unmap - send client dma unmap request in irq_thread context +* +* @cl: client +* @cb: callback block. +* @cmpl_list: complete list. +* +* Return: 0 on such and error otherwise. +*/ +int mei_cl_irq_dma_unmap (struct mei_cl *cl,struct mei_cl_cb *cb, +struct list_head *cmpl_list) +{ +struct mei_device *dev = cl->dev; +u32 msg_slots; +int slots; +int ret; + + msg_slots =mei_hbm2slots (sizeof (struct hbm_client_dma_unmap_request )); + slots =mei_hbuf_empty_slots (dev); +if (slots <0 ) +return -EOVERFLOW ; + +if ((u32 )slots < msg_slots) +return -EMSGSIZE ; + + ret =mei_hbm_cl_dma_unmap_req (dev, cl); +if (ret) { + cl->status = ret; +list_move_tail (&cb->list, cmpl_list); +return ret; + } + +list_move_tail (&cb->list, &dev->ctrl_rd_list); +return 0 ; +} + +static int mei_cl_dma_alloc (struct mei_cl *cl,u8 buf_id,size_t size) +{ + cl->dma.vaddr =dmam_alloc_coherent (cl->dev->dev, size, + &cl->dma.daddr,GFP_KERNEL ); +if (!cl->dma.vaddr) +return -ENOMEM ; + + cl->dma.buffer_id = buf_id; + cl->dma.size = size; + +return 0 ; +} + +static void mei_cl_dma_free (struct mei_cl *cl) +{ + cl->dma.buffer_id =0 ; +dmam_free_coherent (cl->dev->dev, + cl->dma.size, cl->dma.vaddr, cl->dma.daddr); + cl->dma.size =0 ; + cl->dma.vaddr =NULL ; + cl->dma.daddr =0 ; +} + +/** +* mei_cl_alloc_and_map - send client dma map request +* +* @cl: host client +* @fp: pointer to file structure +* @buffer_id: id of the mapped buffer +* @size: size of the buffer +* +* Locking: called under "dev->device_lock" lock +* +* Return: +* * -ENODEV +* * -EINVAL +* * -EOPNOTSUPP +* * -EPROTO +* * -ENOMEM; +*/ +int mei_cl_dma_alloc_and_map (struct mei_cl *cl,const struct file *fp, +u8 buffer_id,size_t size) +{ +struct mei_device *dev; +struct mei_cl_cb *cb; +int rets; + +if (WARN_ON (!cl || !cl->dev)) +return -ENODEV ; + + dev = cl->dev; + +if (!dev->hbm_f_cd_supported) { +cl_dbg (dev, cl,"client dma is not supported\n" ); +return -EOPNOTSUPP ; + } + +if (buffer_id ==0 ) +return -EINVAL ; + +if (!mei_cl_is_connected (cl)) +return -ENODEV ; + +if (cl->dma_mapped) +return -EPROTO ; + +if (mei_cl_dma_map_find (dev, buffer_id)) { +cl_dbg (dev, cl,"client dma with id %d is already allocated\n" , + cl->dma.buffer_id); +return -EPROTO ; + } + + rets =pm_runtime_get (dev->dev); +if (rets <0 && rets != -EINPROGRESS ) { +pm_runtime_put_noidle (dev->dev); +cl_err (dev, cl,"rpm: get failed %d\n" , rets); +return rets; + } + + rets =mei_cl_dma_alloc (cl, buffer_id, size); +if (rets) { +pm_runtime_put_noidle (dev->dev); +return rets; + } + + cb =mei_cl_enqueue_ctrl_wr_cb (cl,0 ,MEI_FOP_DMA_MAP , fp); +if (!cb) { + rets = -ENOMEM ; + goto out; + } + +if (mei_hbuf_acquire (dev)) { +if (mei_hbm_cl_dma_map_req (dev, cl)) { + rets = -ENODEV ; + goto out; + } +list_move_tail (&cb->list, &dev->ctrl_rd_list); + } + +mutex_unlock (&dev->device_lock); +wait_event_timeout (cl->wait, + cl->dma_mapped || + cl->status || + !mei_cl_is_connected (cl), +mei_secs_to_jiffies (MEI_CL_CONNECT_TIMEOUT )); +mutex_lock (&dev->device_lock); + +if (!cl->dma_mapped && !cl->status) + cl->status = -EFAULT ; + + rets = cl->status; + +out: +if (rets) +mei_cl_dma_free (cl); + +cl_dbg (dev, cl,"rpm: autosuspend\n" ); +pm_runtime_mark_last_busy (dev->dev); +pm_runtime_put_autosuspend (dev->dev); + +mei_io_cb_free (cb); +return rets; +} + +/** +* mei_cl_unmap_and_free - send client dma unmap request +* +* @cl: host client +* @fp: pointer to file structure +* +* Locking: called under "dev->device_lock" lock +* +* Return: 0 on such and error otherwise. +*/ +int mei_cl_dma_unmap (struct mei_cl *cl,const struct file *fp) +{ +struct mei_device *dev; +struct mei_cl_cb *cb; +int rets; + +if (WARN_ON (!cl || !cl->dev)) +return -ENODEV ; + + dev = cl->dev; + +if (!dev->hbm_f_cd_supported) { +cl_dbg (dev, cl,"client dma is not supported\n" ); +return -EOPNOTSUPP ; + } + +if (!mei_cl_is_connected (cl)) +return -ENODEV ; + +if (!cl->dma_mapped) +return -EPROTO ; + + rets =pm_runtime_get (dev->dev); +if (rets <0 && rets != -EINPROGRESS ) { +pm_runtime_put_noidle (dev->dev); +cl_err (dev, cl,"rpm: get failed %d\n" , rets); +return rets; + } + + cb =mei_cl_enqueue_ctrl_wr_cb (cl,0 ,MEI_FOP_DMA_UNMAP , fp); +if (!cb) { + rets = -ENOMEM ; + goto out; + } + +if (mei_hbuf_acquire (dev)) { +if (mei_hbm_cl_dma_unmap_req (dev, cl)) { + rets = -ENODEV ; + goto out; + } +list_move_tail (&cb->list, &dev->ctrl_rd_list); + } + +mutex_unlock (&dev->device_lock); +wait_event_timeout (cl->wait, + !cl->dma_mapped || + cl->status || + !mei_cl_is_connected (cl), +mei_secs_to_jiffies (MEI_CL_CONNECT_TIMEOUT )); +mutex_lock (&dev->device_lock); + +if (cl->dma_mapped && !cl->status) + cl->status = -EFAULT ; + + rets = cl->status; + +if (!rets) +mei_cl_dma_free (cl); +out: +cl_dbg (dev, cl,"rpm: autosuspend\n" ); +pm_runtime_mark_last_busy (dev->dev); +pm_runtime_put_autosuspend (dev->dev); + +mei_io_cb_free (cb); +return rets; +}
drivers/misc/mei/client.h +8 -0
@@ -265,6 +265,14 @@ void mei_cl_notify(struct mei_cl *cl);void mei_cl_all_disconnect (struct mei_device *dev); +int mei_cl_irq_dma_map (struct mei_cl *cl,struct mei_cl_cb *cb, +struct list_head *cmpl_list); +int mei_cl_irq_dma_unmap (struct mei_cl *cl,struct mei_cl_cb *cb, +struct list_head *cmpl_list); +int mei_cl_dma_alloc_and_map (struct mei_cl *cl,const struct file *fp, +u8 buffer_id,size_t size); +int mei_cl_dma_unmap (struct mei_cl *cl,const struct file *fp); +#define MEI_CL_FMT "cl:host=%02d me=%02d "#define MEI_CL_PRM (cl) (cl)->host_client_id, mei_cl_me_id(cl)
drivers/misc/mei/hbm.c +124 -0
142 lines not on this page · raw message
drivers/misc/mei/hbm.h +3 -1
@@ -10,6 +10,7 @@struct mei_device ;struct mei_msg_hdr ;struct mei_cl ; +struct mei_dma_data ;/** * enum mei_hbm_state - host bus message protocol state
@@ -51,6 +52,7 @@ int mei_hbm_pg(struct mei_device *dev, u8 pg_cmd);void mei_hbm_pg_resume (struct mei_device *dev);int mei_hbm_cl_notify_req (struct mei_device *dev,struct mei_cl *cl,u8 request); - +int mei_hbm_cl_dma_map_req (struct mei_device *dev,struct mei_cl *cl); +int mei_hbm_cl_dma_unmap_req (struct mei_device *dev,struct mei_cl *cl);#endif /* _MEI_HBM_H_ */
drivers/misc/mei/interrupt.c +10 -0
@@ -547,6 +547,16 @@ int mei_irq_write_handler(struct mei_device *dev, struct list_head *cmpl_list)if (ret)return ret;break ; +case MEI_FOP_DMA_MAP : + ret =mei_cl_irq_dma_map (cl, cb, cmpl_list); +if (ret) +return ret; +break ; +case MEI_FOP_DMA_UNMAP : + ret =mei_cl_irq_dma_unmap (cl, cb, cmpl_list); +if (ret) +return ret; +break ;default :BUG (); }
drivers/misc/mei/mei_dev.h +15 -0
@@ -79,6 +79,8 @@ enum mei_file_transaction_states {* @MEI_FOP_DISCONNECT_RSP: disconnect response * @MEI_FOP_NOTIFY_START: start notification * @MEI_FOP_NOTIFY_STOP: stop notification +* @MEI_FOP_DMA_MAP: request client dma map +* @MEI_FOP_DMA_UNMAP: request client dma unmap */ enum mei_cb_file_ops {MEI_FOP_READ =0 ,
@@ -88,6 +90,8 @@ enum mei_cb_file_ops {MEI_FOP_DISCONNECT_RSP ,MEI_FOP_NOTIFY_START ,MEI_FOP_NOTIFY_STOP , +MEI_FOP_DMA_MAP , + MEI_FOP_DMA_UNMAP, };/**
@@ -113,6 +117,13 @@ struct mei_msg_data {unsigned char *data; }; +struct mei_dma_data { +u8 buffer_id; +void *vaddr; +dma_addr_t daddr; +size_t size; +}; +/** * struct mei_dma_dscr - dma address descriptor *
@@ -236,6 +247,8 @@ struct mei_cl_vtag {* @rd_pending: pending read credits * @rd_completed_lock: protects rd_completed queue * @rd_completed: completed read +* @dma: dma settings +* @dma_mapped: dma buffer is currently mapped. * * @cldev: device on the mei client bus */
@@ -263,6 +276,8 @@ struct mei_cl {struct list_head rd_pending;spinlock_t rd_completed_lock;/* protects rd_completed queue */ struct list_head rd_completed; +struct mei_dma_data dma; +u8 dma_mapped;struct mei_cl_device *cldev; };
Signature · 1 line
2.26.2
PATCH 6/6 mei: bus: add client dma interface
In reply to Tomas WinklerFrom: Alexander Usyskin <[email protected]>
Expose the client dma mapping via mei client
bus interface.
--- drivers/misc/mei/bus.c | 46 ++++++++++++++++++++++++++++++++++++++ drivers/misc/mei/hw.h | 5 +++++ include/linux/mei_cl_bus.h | 3 +++ 3 files changed, 54 insertions(+)
drivers/misc/mei/bus.c +46 -0
@@ -636,6 +636,52 @@ static void mei_cl_bus_vtag_free(struct mei_cl_device *cldev)kfree (cl_vtag); } +void *mei_cldev_dma_map (struct mei_cl_device *cldev,u8 buffer_id,size_t size) +{ +struct mei_device *bus; +struct mei_cl *cl; +int ret; + +if (!cldev || !buffer_id || !size) +return ERR_PTR (-EINVAL ); + +if (!IS_ALIGNED (size,MEI_FW_PAGE_SIZE )) { +dev_err (&cldev->dev,"Map size should be aligned to %lu\n" , +MEI_FW_PAGE_SIZE ); +return ERR_PTR (-EINVAL ); + } + + cl = cldev->cl; + bus = cldev->bus; + +mutex_lock (&bus->device_lock); + ret =mei_cl_dma_alloc_and_map (cl,NULL , buffer_id, size); +mutex_unlock (&bus->device_lock); +if (ret) +return ERR_PTR (ret); +return cl->dma.vaddr; +} +EXPORT_SYMBOL_GPL (mei_cldev_dma_map); + +int mei_cldev_dma_unmap (struct mei_cl_device *cldev) +{ +struct mei_device *bus; +struct mei_cl *cl; +int ret; + +if (!cldev) +return -EINVAL ; + + cl = cldev->cl; + bus = cldev->bus; + +mutex_lock (&bus->device_lock); + ret =mei_cl_dma_unmap (cl,NULL ); +mutex_unlock (&bus->device_lock); +return ret; +} +EXPORT_SYMBOL_GPL (mei_cldev_dma_unmap); +/** * mei_cldev_enable - enable me client device * create connection with me client
drivers/misc/mei/hw.h +5 -0
@@ -22,6 +22,11 @@#define MEI_D0I3_TIMEOUT 5/* D0i3 set/unset max response time */ #define MEI_HBM_TIMEOUT 1/* 1 second */ +/* +* FW page size for DMA allocations +*/ +#define MEI_FW_PAGE_SIZE 4096UL +/* * MEI Version */
include/linux/mei_cl_bus.h +3 -0
@@ -116,4 +116,7 @@ int mei_cldev_enable(struct mei_cl_device *cldev);int mei_cldev_disable (struct mei_cl_device *cldev);bool mei_cldev_enabled (struct mei_cl_device *cldev); +void *mei_cldev_dma_map (struct mei_cl_device *cldev,u8 buffer_id,size_t size); +int mei_cldev_dma_unmap (struct mei_cl_device *cldev); +#endif /* _LINUX_MEI_CL_BUS_H */
Signature · 1 line
2.26.2
Greg Kroah-Hartman
maintainerRe: [char-misc-next 6/6] mei: bus: add client dma interface
Quoted 37 lines · Tomas Winkler
From: Alexander Usyskin <[email protected]>
Expose the client dma mapping via mei client
bus interface.Signed-off-by Alexander Usyskin <[email protected]>Signed-off-by Tomas Winkler <[email protected]>--- drivers/misc/mei/bus.c | 46 ++++++++++++++++++++++++++++++++++++++ drivers/misc/mei/hw.h | 5 +++++ include/linux/mei_cl_bus.h | 3 +++ 3 files changed, 54 insertions(+)drivers/misc/mei/bus.c +16
-0@@ -636,6 +636,52 @@ static void mei_cl_bus_vtag_free(struct mei_cl_device *cldev)kfree (cl_vtag); } +void *mei_cldev_dma_map (struct mei_cl_device *cldev,u8 buffer_id,size_t size) +{ +struct mei_device *bus; +struct mei_cl *cl; +int ret; + +if (!cldev || !buffer_id || !size) +return ERR_PTR (-EINVAL ); + +if (!IS_ALIGNED (size,MEI_FW_PAGE_SIZE )) { +dev_err (&cldev->dev,"Map size should be aligned to %lu\n" , +MEI_FW_PAGE_SIZE ); +return ERR_PTR (-EINVAL ); + } + + cl = cldev->cl;
drivers/misc/mei/bus.c static void mei_cl_bus_vtag_free(struct mei_cl_device *cldev) · line 664
Quoted 10 lines
drivers/misc/mei/bus.c +10
-0+ bus = cldev->bus; + +mutex_lock (&bus->device_lock); + ret =mei_cl_dma_alloc_and_map (cl,NULL , buffer_id, size); +mutex_unlock (&bus->device_lock); +if (ret) +return ERR_PTR (ret); +return cl->dma.vaddr; +} +EXPORT_SYMBOL_GPL (mei_cldev_dma_map);
Why are you exporting symbols without a user of them?
That's a sure way to get them removed by someone right after this lands in the tree :)
Please only add infrastructure for when you have a real user.
thanks,
greg k-h
RE: [char-misc-next 6/6] mei: bus: add client dma interface
Quoted 52 lines · Tomas Winkler
Quoted 8 lines
From: Alexander Usyskin <[email protected]>
Expose the client dma mapping via mei client bus interface.
Signed-off-by Alexander Usyskin <[email protected]>Signed-off-by Tomas Winkler <[email protected]>--- drivers/misc/mei/bus.c | 46++++++++++++++++++++++++++++++++++++++
drivers/misc/mei/bus.c static void mei_cl_bus_vtag_free(struct
Quoted 9 lines
drivers/misc/mei/hw.h | 5 +++++ include/linux/mei_cl_bus.h | 3 +++ 3 files changed, 54 insertions(+)drivers/misc/mei/bus.c index renamed from drivers/misc/mei/bus.c +0
-0
34fb5e541fe5..d430710a5fe5100644drivers/misc/mei/bus.c +0
-0@@ -636,6 +636,52 @@ static void mei_cl_bus_vtag_free(struct
mei_cl_device*cldev)Quoted 19 lines
drivers/misc/mei/bus.c +16
-0kfree (cl_vtag); } +void *mei_cldev_dma_map (struct mei_cl_device *cldev,u8 buffer_id, +size_t size) { +struct mei_device *bus; +struct mei_cl *cl; +int ret; + +if (!cldev || !buffer_id || !size) +return ERR_PTR (-EINVAL ); + +if (!IS_ALIGNED (size,MEI_FW_PAGE_SIZE )) { +dev_err (&cldev->dev,"Map size should be aligned to %lu\n" , +MEI_FW_PAGE_SIZE ); +return ERR_PTR (-EINVAL ); + } + + cl = cldev->cl;drivers/misc/mei/bus.c static void mei_cl_bus_vtag_free(struct mei_cl_device *cldev) · line 664
Quoted 10 lines
drivers/misc/mei/bus.c +10
-0+ bus = cldev->bus; + +mutex_lock (&bus->device_lock); + ret =mei_cl_dma_alloc_and_map (cl,NULL , buffer_id, size); +mutex_unlock (&bus->device_lock); +if (ret) +return ERR_PTR (ret); +return cl->dma.vaddr; +} +EXPORT_SYMBOL_GPL (mei_cldev_dma_map);Why are you exporting symbols without a user of them?
Quoted 4 lines
That's a sure way to get them removed by someone right after this lands in the tree :)
Please only add infrastructure for when you have a real user.
You are right, the user is coming from wifi tree. We need merge before they do. If you prefer we can merge that all from the wifi tree.
Thanks
Tomas
Greg Kroah-Hartman
maintainerRe: [char-misc-next 6/6] mei: bus: add client dma interface
Quoted 52 lines · Tomas
Quoted 52 lines · Tomas Winkler
Quoted 8 lines
From: Alexander Usyskin <[email protected]>
Expose the client dma mapping via mei client bus interface.
Signed-off-by Alexander Usyskin <[email protected]>Signed-off-by Tomas Winkler <[email protected]>--- drivers/misc/mei/bus.c | 46++++++++++++++++++++++++++++++++++++++
drivers/misc/mei/bus.c static void mei_cl_bus_vtag_free(struct
Quoted 9 lines
drivers/misc/mei/hw.h | 5 +++++ include/linux/mei_cl_bus.h | 3 +++ 3 files changed, 54 insertions(+)drivers/misc/mei/bus.c index renamed from drivers/misc/mei/bus.c +0
-0
34fb5e541fe5..d430710a5fe5100644drivers/misc/mei/bus.c +0
-0@@ -636,6 +636,52 @@ static void mei_cl_bus_vtag_free(struct
mei_cl_device*cldev)Quoted 19 lines
drivers/misc/mei/bus.c +16
-0kfree (cl_vtag); } +void *mei_cldev_dma_map (struct mei_cl_device *cldev,u8 buffer_id, +size_t size) { +struct mei_device *bus; +struct mei_cl *cl; +int ret; + +if (!cldev || !buffer_id || !size) +return ERR_PTR (-EINVAL ); + +if (!IS_ALIGNED (size,MEI_FW_PAGE_SIZE )) { +dev_err (&cldev->dev,"Map size should be aligned to %lu\n" , +MEI_FW_PAGE_SIZE ); +return ERR_PTR (-EINVAL ); + } + + cl = cldev->cl;drivers/misc/mei/bus.c static void mei_cl_bus_vtag_free(struct mei_cl_device *cldev) · line 664
Quoted 10 lines
drivers/misc/mei/bus.c +10
-0+ bus = cldev->bus; + +mutex_lock (&bus->device_lock); + ret =mei_cl_dma_alloc_and_map (cl,NULL , buffer_id, size); +mutex_unlock (&bus->device_lock); +if (ret) +return ERR_PTR (ret); +return cl->dma.vaddr; +} +EXPORT_SYMBOL_GPL (mei_cldev_dma_map);Why are you exporting symbols without a user of them?
Quoted 6 lines
Quoted 4 lines
That's a sure way to get them removed by someone right after this lands in the tree :)
Please only add infrastructure for when you have a real user.
You are right, the user is coming from wifi tree. We need merge before they do. If you prefer we can merge that all from the wifi tree.
That wasn't documented well at all in your changelog comment :(
It can go through whatever tree needs it.
thanks,
greg k-h
RE: [char-misc-next 6/6] mei: bus: add client dma interface
Quoted 57 lines · Tomas
Quoted 55 lines
Quoted 55 lines · Tomas Winkler
Quoted 8 lines
From: Alexander Usyskin <[email protected]>
Expose the client dma mapping via mei client bus interface.
Signed-off-by Alexander Usyskin <[email protected]>Signed-off-by Tomas Winkler <[email protected]>--- drivers/misc/mei/bus.c | 46++++++++++++++++++++++++++++++++++++++
drivers/misc/mei/bus.c static void mei_cl_bus_vtag_free(struct
Quoted 9 lines
drivers/misc/mei/hw.h | 5 +++++ include/linux/mei_cl_bus.h | 3 +++ 3 files changed, 54 insertions(+)drivers/misc/mei/bus.c index renamed from drivers/misc/mei/bus.c +0
-0
34fb5e541fe5..d430710a5fe5100644drivers/misc/mei/bus.c +0
-0@@ -636,6 +636,52 @@ static void mei_cl_bus_vtag_free(struct
mei_cl_device*cldev)Quoted 19 lines
drivers/misc/mei/bus.c +16
-0kfree (cl_vtag); } +void *mei_cldev_dma_map (struct mei_cl_device *cldev,u8 +buffer_id,size_t size) { +struct mei_device *bus; +struct mei_cl *cl; +int ret; + +if (!cldev || !buffer_id || !size) +return ERR_PTR (-EINVAL ); + +if (!IS_ALIGNED (size,MEI_FW_PAGE_SIZE )) { +dev_err (&cldev->dev,"Map size should be aligned to %lu\n" , +MEI_FW_PAGE_SIZE ); +return ERR_PTR (-EINVAL ); + } + + cl = cldev->cl;drivers/misc/mei/bus.c static void mei_cl_bus_vtag_free(struct mei_cl_device *cldev) · line 664
Quoted 10 lines
drivers/misc/mei/bus.c +10
-0+ bus = cldev->bus; + +mutex_lock (&bus->device_lock); + ret =mei_cl_dma_alloc_and_map (cl,NULL , buffer_id, size); +mutex_unlock (&bus->device_lock); +if (ret) +return ERR_PTR (ret); +return cl->dma.vaddr; +} +EXPORT_SYMBOL_GPL (mei_cldev_dma_map);Why are you exporting symbols without a user of them?
That's a sure way to get them removed by someone right after this lands in the tree :)
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Please only add infrastructure for when you have a real user.
You are right, the user is coming from wifi tree. We need merge before
they do.
Quoted 1 line
If you prefer we can merge that all from the wifi tree.
That wasn't documented well at all in your changelog comment :(
Note taken.
Quoted 1 line
It can go through whatever tree needs it.
If possible please merge our changes already here, and let the wifi guys to finish their task in their tree, in their own time. Thanks
Tomas
Greg Kroah-Hartman
maintainerRe: [char-misc-next 6/6] mei: bus: add client dma interface
Quoted 58 lines · Tomas
Quoted 58 lines · Tomas
Quoted 56 lines
Quoted 56 lines · Tomas Winkler
Quoted 8 lines
From: Alexander Usyskin <[email protected]>
Expose the client dma mapping via mei client bus interface.
Signed-off-by Alexander Usyskin <[email protected]>Signed-off-by Tomas Winkler <[email protected]>--- drivers/misc/mei/bus.c | 46++++++++++++++++++++++++++++++++++++++
drivers/misc/mei/bus.c static void mei_cl_bus_vtag_free(struct
Quoted 9 lines
drivers/misc/mei/hw.h | 5 +++++ include/linux/mei_cl_bus.h | 3 +++ 3 files changed, 54 insertions(+)drivers/misc/mei/bus.c index renamed from drivers/misc/mei/bus.c +0
-0
34fb5e541fe5..d430710a5fe5100644drivers/misc/mei/bus.c +0
-0@@ -636,6 +636,52 @@ static void mei_cl_bus_vtag_free(struct
mei_cl_device*cldev)Quoted 19 lines
drivers/misc/mei/bus.c +16
-0kfree (cl_vtag); } +void *mei_cldev_dma_map (struct mei_cl_device *cldev,u8 +buffer_id,size_t size) { +struct mei_device *bus; +struct mei_cl *cl; +int ret; + +if (!cldev || !buffer_id || !size) +return ERR_PTR (-EINVAL ); + +if (!IS_ALIGNED (size,MEI_FW_PAGE_SIZE )) { +dev_err (&cldev->dev,"Map size should be aligned to %lu\n" , +MEI_FW_PAGE_SIZE ); +return ERR_PTR (-EINVAL ); + } + + cl = cldev->cl;drivers/misc/mei/bus.c static void mei_cl_bus_vtag_free(struct mei_cl_device *cldev) · line 664
Quoted 10 lines
drivers/misc/mei/bus.c +10
-0+ bus = cldev->bus; + +mutex_lock (&bus->device_lock); + ret =mei_cl_dma_alloc_and_map (cl,NULL , buffer_id, size); +mutex_unlock (&bus->device_lock); +if (ret) +return ERR_PTR (ret); +return cl->dma.vaddr; +} +EXPORT_SYMBOL_GPL (mei_cldev_dma_map);Why are you exporting symbols without a user of them?
That's a sure way to get them removed by someone right after this lands in the tree :)
Please only add infrastructure for when you have a real user.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
You are right, the user is coming from wifi tree. We need merge before
they do.
Quoted 1 line
If you prefer we can merge that all from the wifi tree.
That wasn't documented well at all in your changelog comment :(
Note taken.
Quoted 1 line
It can go through whatever tree needs it.
If possible please merge our changes already here, and let the wifi guys to finish their task in their tree, in their own time.
I took some of these already, patches 1 and 6 I can't take as-is, sorry.
thanks,
greg k-h
RE: [char-misc-next 6/6] mei: bus: add client dma interface
Hi Greg,
Quoted 66 lines · Tomas
Quoted 26 lines
Quoted 26 lines · Tomas
Quoted 24 lines
Quoted 24 lines · Tomas Winkler
Quoted 8 lines
From: Alexander Usyskin <[email protected]>
Expose the client dma mapping via mei client bus interface.
Signed-off-by Alexander Usyskin <[email protected]>Signed-off-by Tomas Winkler <[email protected]>--- drivers/misc/mei/bus.c | 46++++++++++++++++++++++++++++++++++++++
drivers/misc/mei/bus.c static void mei_cl_bus_vtag_free(struct
Quoted 10 lines
drivers/misc/mei/hw.h | 5 +++++ include/linux/mei_cl_bus.h | 3 +++ 3 files changed, 54 insertions(+)drivers/misc/mei/bus.c +0
-0index
34fb5e541fe5..d430710a5fe5100644drivers/misc/mei/bus.c +0
-0@@ -636,6 +636,52 @@ static void mei_cl_bus_vtag_free(struct
mei_cl_device*cldev)Quoted 3 lines
drivers/misc/mei/bus.c +0
-0kfree (cl_vtag); }Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/misc/mei/bus.c static void mei_cl_bus_vtag_free(struct mei_cl_device *cldev)
Quoted 11 lines
drivers/misc/mei/bus.c +11
-0+void *mei_cldev_dma_map (struct mei_cl_device *cldev,u8 +buffer_id,size_t size) { +struct mei_device *bus; +struct mei_cl *cl; +int ret; + +if (!cldev || !buffer_id || !size) +return ERR_PTR (-EINVAL ); + +if (!IS_ALIGNED (size,MEI_FW_PAGE_SIZE )) { + dev_err(&cldev->dev, "Map size should be aligned to%lu\n",
Quoted 27 lines
Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
Quoted 5 lines
drivers/misc/mei/bus.c +5
-0+ MEI_FW_PAGE_SIZE); +return ERR_PTR (-EINVAL ); + } + + cl = cldev->cl;drivers/misc/mei/bus.c static void mei_cl_bus_vtag_free(struct mei_cl_device *cldev) · line 664
Quoted 10 lines
drivers/misc/mei/bus.c +10
-0+ bus = cldev->bus; + +mutex_lock (&bus->device_lock); + ret =mei_cl_dma_alloc_and_map (cl,NULL , buffer_id, size); +mutex_unlock (&bus->device_lock); +if (ret) +return ERR_PTR (ret); +return cl->dma.vaddr; +} +EXPORT_SYMBOL_GPL (mei_cldev_dma_map);Why are you exporting symbols without a user of them?
Quoted 6 lines
Quoted 4 lines
That's a sure way to get them removed by someone right after this lands in the tree :)
Please only add infrastructure for when you have a real user.
You are right, the user is coming from wifi tree. We need merge before
they do.
Quoted 1 line
If you prefer we can merge that all from the wifi tree.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
That wasn't documented well at all in your changelog comment :(
Note taken.
Quoted 1 line
It can go through whatever tree needs it.
If possible please merge our changes already here, and let the wifi guys to
finish their task in their tree, in their own time.
I took some of these already, patches 1 and 6 I can't take as-is, sorry.
As Tomas said, 6 is needed by iwlwifi. I understand you want it to be routed through iwlwifi-next.git. I added Kalle so that he gets a heads up. 1 is not related to iwlwifi.
Greg Kroah-Hartman
maintainerQuoted 13 lines · Tomas Winkler
Using of snprintf is discouraged in sysfs.
For simple u8 it is safe to use sprintf.Signed-off-by Tomas Winkler <[email protected]>--- drivers/misc/mei/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/misc/mei/main.c +0
-0
drivers/misc/mei/main.c static ssize_t tx_queue_limit_show(struct device *device, · line 1029
Quoted 5 lines
drivers/misc/mei/main.c +1
-1@@ -1026,7 +1026,7 @@ static ssize_t tx_queue_limit_show(struct device *device, size = dev->tx_queue_limit;mutex_unlock (&dev->device_lock); -return snprintf (buf,PAGE_SIZE ,"%u\n" , size); +return sprintf (buf,"%u\n" , size);
If you are going to do this, why not just convert it to use sysfs_emit() instead?
thanks,
greg k-h
Quoted 16 lines · Tomas Winkler
drivers/misc/mei/main.c static ssize_t tx_queue_limit_show(struct device
Quoted 13 lines
Using of snprintf is discouraged in sysfs.
For simple u8 it is safe to use sprintf.Signed-off-by Tomas Winkler <[email protected]>--- drivers/misc/mei/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/misc/mei/main.c index renamed from drivers/misc/mei/main.c +0
-0
9f6682033ed7..24a05f45b639100644drivers/misc/mei/main.c +0
-0@@ -1026,7 +1026,7 @@ static ssize_t tx_queue_limit_show(struct device*device,
Quoted 8 lines
drivers/misc/mei/main.c static ssize_t tx_queue_limit_show(struct device *device, · line 1029
Quoted 5 lines
drivers/misc/mei/main.c +1
-1size = dev->tx_queue_limit;mutex_unlock (&dev->device_lock); -return snprintf (buf,PAGE_SIZE ,"%u\n" , size); +return sprintf (buf,"%u\n" , size);If you are going to do this, why not just convert it to use
sysfs_emit()instead?
I thought it's an overkill, but if you prefer that I will resubmit.
Thanks
Tomas