mei: Add DMA ring
Subsystems (2)
cover mei: Add DMA ring
This series adds an alternative method for transferring data between the mei driver and the device via a DMA ring. The DMA ring allows transferring data in bigger chunks, up to 128K, than the HW ring 512B. The actual sizes depend on particular MEI generations. The HW ring is faster for packets that fits
into the HW ring while a packet that would require fragmentation is faster to send via the DMA ring.
Alexander Usyskin (3):
mei: define dma ring buffer sizes for PCH12 HW and newer
mei: bump hbm version to 2.1
mei: me: mark CNP devices as having dma support
Tomas Winkler (9):
mei: add support for variable length mei headers.
mei: hbm: define dma ring setup protocol
mei: hbm: introduce dma bit in the message header
mei: restrict dma ring support to hbm version 2.1
mei: dma ring buffers allocation
mei: hbm: setup dma ring
mei: hw: add dma ring control block
mei: dma ring: implement rx circular buffer logic
mei: dma ring: implement transmit flow
drivers/misc/mei/Makefile | 1 + drivers/misc/mei/client.c | 84 +++++++++---- drivers/misc/mei/debugfs.c | 2 + drivers/misc/mei/dma-ring.c | 278 +++++++++++++++++++++++++++++++++++++++++++ drivers/misc/mei/hbm.c | 126 ++++++++++++++++++-- drivers/misc/mei/hbm.h | 2 + drivers/misc/mei/hw-me.c | 53 ++++++--- drivers/misc/mei/hw-me.h | 4 + drivers/misc/mei/hw-txe.c | 42 +++---- drivers/misc/mei/hw.h | 98 ++++++++++++++- drivers/misc/mei/init.c | 2 +- drivers/misc/mei/interrupt.c | 45 ++++--- drivers/misc/mei/mei_dev.h | 57 +++++++-- drivers/misc/mei/pci-me.c | 4 +- 14 files changed, 700 insertions(+), 98 deletions(-) create mode 100644 drivers/misc/mei/dma-ring.c
Signature · 1 line
2.14.4
PATCH 1/12 mei: add support for variable length mei headers.
Remove header size knowledge from me and txe hw layers, this requires to change the write handler to accept header and its length as well as data and its length.
HBM messages are fixed to use basic header, hence we add mei_hbm2slots() that converts HBM message length and mei message header, while mei_data2slots() converts data length directly to the slots.
--- drivers/misc/mei/client.c | 31 ++++++++++++++++++------------- drivers/misc/mei/hbm.c | 30 ++++++++++++++++++++++-------- drivers/misc/mei/hw-me.c | 34 ++++++++++++++++++++-------------- drivers/misc/mei/hw-txe.c | 42 +++++++++++++++++++++--------------------- drivers/misc/mei/interrupt.c | 4 ++-- drivers/misc/mei/mei_dev.h | 25 +++++++++++++++++++------ 6 files changed, 102 insertions(+), 64 deletions(-)
drivers/misc/mei/client.c +18 -13
@@ -863,7 +863,7 @@ int mei_cl_irq_disconnect(struct mei_cl *cl, struct mei_cl_cb *cb,int slots;int ret; - msg_slots =mei_data2slots (sizeof (struct hbm_client_connect_request )); + msg_slots =mei_hbm2slots (sizeof (struct hbm_client_connect_request )); slots =mei_hbuf_empty_slots (dev);if (slots <0 )return -EOVERFLOW ;
@@ -1055,11 +1055,10 @@ int mei_cl_irq_connect(struct mei_cl *cl, struct mei_cl_cb *cb,int slots;int rets; - msg_slots =mei_data2slots (sizeof (struct hbm_client_connect_request )); -if (mei_cl_is_other_connecting (cl))return 0 ; + msg_slots =mei_hbm2slots (sizeof (struct hbm_client_connect_request )); slots =mei_hbuf_empty_slots (dev);if (slots <0 )return -EOVERFLOW ;
@@ -1299,7 +1298,7 @@ int mei_cl_irq_notify(struct mei_cl *cl, struct mei_cl_cb *cb,int ret;bool request; - msg_slots =mei_data2slots (sizeof (struct hbm_client_connect_request )); + msg_slots =mei_hbm2slots (sizeof (struct hbm_client_connect_request )); slots =mei_hbuf_empty_slots (dev);if (slots <0 )return -EOVERFLOW ;
@@ -1571,6 +1570,7 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,struct mei_device *dev;struct mei_msg_data *buf;struct mei_msg_hdr mei_hdr; +size_t hdr_len =sizeof (mei_hdr);size_t len;size_t hbuf_len;int hbuf_slots;
@@ -1601,7 +1601,8 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb, rets = -EOVERFLOW ; goto err; } - hbuf_len =mei_slots2data (hbuf_slots) -sizeof (struct mei_msg_hdr ); + + hbuf_len =mei_slots2data (hbuf_slots);mei_msg_hdr_init (&mei_hdr, cb);
@@ -1609,11 +1610,11 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,* Split the message only if we can write the whole host buffer * otherwise wait for next time the host buffer is empty. */ -if (hbuf_len >= len) { +if (len + hdr_len <= hbuf_len) { mei_hdr.length = len; mei_hdr.msg_complete =1 ; }else if ((u32 )hbuf_slots ==mei_hbuf_depth (dev)) { - mei_hdr.length = hbuf_len; + mei_hdr.length = hbuf_len - hdr_len; }else {return 0 ; }
@@ -1621,7 +1622,8 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,cl_dbg (dev, cl,"buf: size = %zu idx = %zu\n" , cb->buf.size, cb->buf_idx); - rets =mei_write_message (dev, &mei_hdr, buf->data + cb->buf_idx); + rets =mei_write_message (dev, &mei_hdr, hdr_len, + buf->data + cb->buf_idx, mei_hdr.length);if (rets) goto err;
@@ -1661,6 +1663,7 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb)struct mei_device *dev;struct mei_msg_data *buf;struct mei_msg_hdr mei_hdr; +size_t hdr_len =sizeof (mei_hdr);size_t len;size_t hbuf_len;int hbuf_slots;
@@ -1716,15 +1719,17 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb) goto out; } - hbuf_len =mei_slots2data (hbuf_slots) -sizeof (struct mei_msg_hdr ); -if (hbuf_len >= len) { + hbuf_len =mei_slots2data (hbuf_slots); + +if (len + hdr_len <= hbuf_len) { mei_hdr.length = len; mei_hdr.msg_complete =1 ; }else { - mei_hdr.length = hbuf_len; + mei_hdr.length = hbuf_len - hdr_len; } - rets =mei_write_message (dev, &mei_hdr, buf->data); + rets =mei_write_message (dev, &mei_hdr, hdr_len, + buf->data, mei_hdr.length);if (rets) goto err;
@@ -1761,7 +1766,7 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb) } } - rets = len; + rets = buf->size; err:cl_dbg (dev, cl,"rpm: autosuspend\n" );pm_runtime_mark_last_busy (dev->dev);
drivers/misc/mei/hbm.c +22 -8
@@ -95,6 +95,20 @@ static int mei_cl_conn_status_to_errno(enum mei_cl_connect_status status) } } +/** +* mei_hbm_write_message - wrapper for sending hbm messages. +* +* @dev: mei device +* @hdr: mei header +* @data: payload +*/ +static inline int mei_hbm_write_message (struct mei_device *dev, +struct mei_msg_hdr *hdr, +const void *data) +{ +return mei_write_message (dev, hdr,sizeof (*hdr), data, hdr->length); +} +/** * mei_hbm_idle - set hbm to idle state *
@@ -174,7 +188,7 @@ static inline int mei_hbm_cl_write(struct mei_device *dev, struct mei_cl *cl,mei_hbm_hdr (&mei_hdr, len);mei_hbm_cl_hdr (cl, hbm_cmd, buf, len); -return mei_write_message (dev, &mei_hdr, buf); +return mei_hbm_write_message (dev, &mei_hdr, buf); }/**
@@ -267,7 +281,7 @@ int mei_hbm_start_req(struct mei_device *dev) start_req.host_version.minor_version =HBM_MINOR_VERSION ; dev->hbm_state =MEI_HBM_IDLE ; - ret =mei_write_message (dev, &mei_hdr, &start_req); + ret =mei_hbm_write_message (dev, &mei_hdr, &start_req);if (ret) {dev_err (dev->dev,"version message write failed: ret = %d\n" , ret);
@@ -304,7 +318,7 @@ static int mei_hbm_enum_clients_req(struct mei_device *dev) enum_req.flags |= dev->hbm_f_ie_supported ?MEI_HBM_ENUM_F_IMMEDIATE_ENUM :0 ; - ret =mei_write_message (dev, &mei_hdr, &enum_req); + ret =mei_hbm_write_message (dev, &mei_hdr, &enum_req);if (ret) {dev_err (dev->dev,"enumeration request write failed: ret = %d.\n" , ret);
@@ -373,7 +387,7 @@ static int mei_hbm_add_cl_resp(struct mei_device *dev, u8 addr, u8 status) resp.me_addr = addr; resp.status = status; - ret =mei_write_message (dev, &mei_hdr, &resp); + ret =mei_hbm_write_message (dev, &mei_hdr, &resp);if (ret)dev_err (dev->dev,"add client response write failed: ret = %d\n" , ret);
@@ -430,7 +444,7 @@ int mei_hbm_cl_notify_req(struct mei_device *dev, req.start = start; - ret =mei_write_message (dev, &mei_hdr, &req); + ret =mei_hbm_write_message (dev, &mei_hdr, &req);if (ret)dev_err (dev->dev,"notify request failed: ret = %d\n" , ret);
@@ -555,7 +569,7 @@ static int mei_hbm_prop_req(struct mei_device *dev, unsigned long start_idx) prop_req.hbm_cmd =HOST_CLIENT_PROPERTIES_REQ_CMD ; prop_req.me_addr = addr; - ret =mei_write_message (dev, &mei_hdr, &prop_req); + ret =mei_hbm_write_message (dev, &mei_hdr, &prop_req);if (ret) {dev_err (dev->dev,"properties request write failed: ret = %d\n" , ret);
@@ -592,7 +606,7 @@ int mei_hbm_pg(struct mei_device *dev, u8 pg_cmd)memset (&req,0 , len); req.hbm_cmd = pg_cmd; - ret =mei_write_message (dev, &mei_hdr, &req); + ret =mei_hbm_write_message (dev, &mei_hdr, &req);if (ret)dev_err (dev->dev,"power gate command write failed.\n" );return ret;
@@ -618,7 +632,7 @@ static int mei_hbm_stop_req(struct mei_device *dev) req.hbm_cmd =HOST_STOP_REQ_CMD ; req.reason =DRIVER_STOP_REQUEST ; -return mei_write_message (dev, &mei_hdr, &req); +return mei_hbm_write_message (dev, &mei_hdr, &req); }/**
drivers/misc/mei/hw-me.c +20 -14
@@ -517,28 +517,31 @@ static u32 mei_me_hbuf_depth(const struct mei_device *dev)return hw->hbuf_depth; } -/** * mei_me_hbuf_write - writes a message to host hw buffer. * * @dev: the device structure -* @header: mei HECI header of message -* @buf: message payload will be written +* @hdr: header of message +* @hdr_len: header length in bytes: must be multiplication of a slot (4bytes) +* @data: payload +* @data_len: payload length in bytes * -* Return: -EIO if write has failed +* Return: 0 if success, < 0 - otherwise. */ static int mei_me_hbuf_write (struct mei_device *dev, -struct mei_msg_hdr *header, -const unsigned char *buf) +const void *hdr,size_t hdr_len, +const void *data,size_t data_len) {unsigned long rem; -unsigned long length = header->length;unsigned long i; -u32 *reg_buf = (u32 *)buf; +const u32 *reg_buf;u32 dw_cnt;int empty_slots; -dev_dbg (dev->dev,MEI_HDR_FMT ,MEI_HDR_PRM (header)); +if (WARN_ON (!hdr || !data || hdr_len &0x3 )) +return -EINVAL ; + +dev_dbg (dev->dev,MEI_HDR_FMT ,MEI_HDR_PRM ((struct mei_msg_hdr *)hdr)); empty_slots =mei_hbuf_empty_slots (dev);dev_dbg (dev->dev,"empty slots = %hu.\n" , empty_slots);
@@ -546,20 +549,23 @@ static int mei_me_hbuf_write(struct mei_device *dev,if (empty_slots <0 )return -EOVERFLOW ; - dw_cnt =mei_data2slots (length); + dw_cnt =mei_data2slots (hdr_len + data_len);if (dw_cnt > (u32 )empty_slots)return -EMSGSIZE ; -mei_me_hcbww_write (dev, *((u32 *) header)); + reg_buf = hdr; +for (i =0 ; i < hdr_len /MEI_SLOT_SIZE ; i++) +mei_me_hcbww_write (dev, reg_buf[i]); -for (i =0 ; i < length /MEI_SLOT_SIZE ; i++) + reg_buf = data; +for (i =0 ; i < data_len /MEI_SLOT_SIZE ; i++)mei_me_hcbww_write (dev, reg_buf[i]); - rem = length &0x3 ; + rem = data_len &0x3 ;if (rem >0 ) {u32 reg =0 ; -memcpy (®, &buf[length - rem], rem); +memcpy (®, (const u8 *)data + data_len - rem, rem);mei_me_hcbww_write (dev, reg); }
drivers/misc/mei/hw-txe.c +21 -21
75 lines not on this page · raw message
drivers/misc/mei/interrupt.c +2 -2
@@ -173,7 +173,7 @@ static int mei_cl_irq_disconnect_rsp(struct mei_cl *cl, struct mei_cl_cb *cb,int slots;int ret; - msg_slots =mei_data2slots (sizeof (struct hbm_client_connect_response )); + msg_slots =mei_hbm2slots (sizeof (struct hbm_client_connect_response )); slots =mei_hbuf_empty_slots (dev);if (slots <0 )return -EOVERFLOW ;
@@ -208,7 +208,7 @@ static int mei_cl_irq_read(struct mei_cl *cl, struct mei_cl_cb *cb,if (!list_empty (&cl->rd_pending))return 0 ; - msg_slots =mei_data2slots (sizeof (struct hbm_flow_control )); + msg_slots =mei_hbm2slots (sizeof (struct hbm_flow_control )); slots =mei_hbuf_empty_slots (dev);if (slots <0 )return -EOVERFLOW ;
drivers/misc/mei/mei_dev.h +19 -6
@@ -300,8 +300,8 @@ struct mei_hw_ops {bool (*hbuf_is_ready)(struct mei_device *dev);u32 (*hbuf_depth)(const struct mei_device *dev);int (*write)(struct mei_device *dev, -struct mei_msg_hdr *hdr, -const unsigned char *buf); +const void *hdr,size_t hdr_len, +const void *data,size_t data_len);int (*rdbuf_full_slots)(struct mei_device *dev);
@@ -528,14 +528,26 @@ static inline unsigned long mei_secs_to_jiffies(unsigned long sec) }/** -* mei_data2slots - get slots - number of (dwords) from a message length -* + size of the mei header +* mei_data2slots - get slots number from a message length * * @length: size of the messages in bytes * * Return: number of slots */ static inline u32 mei_data2slots (size_t length) +{ +return DIV_ROUND_UP (length,MEI_SLOT_SIZE ); +} + +/** +* mei_hbm2slots - get slots number from a hbm message length +* length + size of the mei message header +* +* @length: size of the messages in bytes +* +* Return: number of slots +*/ +static inline u32 mei_hbm2slots (size_t length) {return DIV_ROUND_UP (sizeof (struct mei_msg_hdr ) + length,MEI_SLOT_SIZE ); }
@@ -656,9 +668,10 @@ static inline u32 mei_hbuf_depth(const struct mei_device *dev) }static inline int mei_write_message (struct mei_device *dev, -struct mei_msg_hdr *hdr,const void *buf) +const void *hdr,size_t hdr_len, +const void *data,size_t data_len) { -return dev->ops->write (dev, hdr, buf); +return dev->ops->write (dev, hdr, hdr_len, data, data_len); }static inline u32 mei_read_hdr (const struct mei_device *dev)
Signature · 1 line
2.14.4
PATCH 2/12 mei: hbm: define dma ring setup protocol
In reply to Tomas WinklerThe protocol defines how to setup an I/O ring on top of host memory to utilize the device DMA engine for faster transport.
Three memory buffers are allocated.
A Host circular buffer for from the Host to Device communication. A Device circular buffer for from Device to the Host communication. And finally a Control block where the pointers for the both circular buffers are managed.
--- drivers/misc/mei/hw.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
drivers/misc/mei/hw.h +49 -0
@@ -122,6 +122,9 @@#define MEI_HBM_NOTIFY_RES_CMD 0x90#define MEI_HBM_NOTIFICATION_CMD 0x11 +#define MEI_HBM_DMA_SETUP_REQ_CMD 0x12 +#define MEI_HBM_DMA_SETUP_RES_CMD 0x92 +/* * MEI Stop Reason * used by hbm_host_stop_request.reason
@@ -449,4 +452,50 @@ struct hbm_notification { u8 reserved[1]; } __packed; +/** +* struct hbm_dma_mem_dscr - dma ring +* +* @addr_hi: the high 32bits of 64 bit address +* @addr_lo: the low 32bits of 64 bit address +* @size : size in bytes (must be power of 2) +*/ +struct hbm_dma_mem_dscr { +u32 addr_hi; +u32 addr_lo; +u32 size; +} __packed; + +enum { +DMA_DSCR_HOST =0 , +DMA_DSCR_DEVICE =1 , +DMA_DSCR_CTRL =2 , +DMA_DSCR_NUM , +}; + +/** +* struct hbm_dma_setup_request - dma setup request +* +* @hbm_cmd: bus message command header +* @reserved: reserved for alignment +* @dma_dscr: dma descriptor for HOST, DEVICE, and CTRL +*/ +struct hbm_dma_setup_request { +u8 hbm_cmd; +u8 reserved[3 ]; +struct hbm_dma_mem_dscr dma_dscr[DMA_DSCR_NUM ]; +} __packed; + +/** +* struct hbm_dma_setup_response - dma setup response +* +* @hbm_cmd: bus message command header +* @status: 0 on success; otherwise DMA setup failed. +* @reserved: reserved for alignment +*/ +struct hbm_dma_setup_response { +u8 hbm_cmd; +u8 status; +u8 reserved[2 ]; +} __packed; +#endif
Signature · 1 line
2.14.4
PATCH 3/12 mei: hbm: introduce dma bit in the message header
In reply to Tomas WinklerAdd dma_ring bit in the mei message header for conveying that the message data itself are on the dma ring.
--- drivers/misc/mei/client.c | 1 + drivers/misc/mei/hbm.c | 1 + drivers/misc/mei/hw.h | 16 ++++++++++++---- drivers/misc/mei/mei_dev.h | 4 ++-- 4 files changed, 16 insertions(+), 6 deletions(-)
drivers/misc/mei/client.c +1 -0
@@ -1551,6 +1551,7 @@ static void mei_msg_hdr_init(struct mei_msg_hdr *mei_hdr, struct mei_cl_cb *cb) mei_hdr->length =0 ; mei_hdr->reserved =0 ; mei_hdr->msg_complete =0 ; + mei_hdr->dma_ring =0 ; mei_hdr->internal = cb->internal; }
drivers/misc/mei/hbm.c +1 -0
@@ -145,6 +145,7 @@ static inline void mei_hbm_hdr(struct mei_msg_hdr *hdr, size_t length) hdr->me_addr =0 ; hdr->length = length; hdr->msg_complete =1 ; + hdr->dma_ring =0 ; hdr->reserved =0 ; hdr->internal =0 ; }
drivers/misc/mei/hw.h +12 -4
@@ -190,19 +190,27 @@ enum mei_cl_disconnect_status {MEI_CL_DISCONN_SUCCESS =MEI_HBMS_SUCCESS }; -/* -* MEI BUS Interface Section +/** +* struct mei_msg_hdr - MEI BUS Interface Section +* +* @me_addr: device address +* @host_addr: host address +* @length: message length +* @reserved: reserved +* @dma_ring: message is on dma ring +* @internal: message is internal +* @msg_complete: last packet of the message */ struct mei_msg_hdr {u32 me_addr:8 ;u32 host_addr:8 ;u32 length:9 ; -u32 reserved:5 ; +u32 reserved:4 ; +u32 dma_ring:1 ;u32 internal:1 ;u32 msg_complete:1 ; } __packed; -struct mei_bus_message {u8 hbm_cmd;u8 data[0 ];
drivers/misc/mei/mei_dev.h +2 -2
@@ -714,10 +714,10 @@ static inline void mei_dbgfs_deregister(struct mei_device *dev) {}int mei_register (struct mei_device *dev,struct device *parent);void mei_deregister (struct mei_device *dev); -#define MEI_HDR_FMT "hdr:host=%02d me=%02d len=%d internal=%1d comp=%1d" +#define MEI_HDR_FMT "hdr:host=%02d me=%02d len=%d dma=%1d internal=%1d comp=%1d"#define MEI_HDR_PRM (hdr) \ (hdr)->host_addr, (hdr)->me_addr, \ - (hdr)->length, (hdr)->internal, (hdr)->msg_complete + (hdr)->length, (hdr)->dma_ring, (hdr)->internal, (hdr)->msg_completessize_t mei_fw_status2str (struct mei_fw_status *fw_sts,char *buf,size_t len);/**
Signature · 1 line
2.14.4
PATCH 4/12 mei: restrict dma ring support to hbm version 2.1
In reply to Tomas WinklerOnly a firmware with version 2.1 and above supports dma ring feature.
--- drivers/misc/mei/debugfs.c | 2 ++ drivers/misc/mei/hbm.c | 6 ++++++ drivers/misc/mei/hw.h | 6 ++++++ drivers/misc/mei/mei_dev.h | 2 ++ 4 files changed, 16 insertions(+)
drivers/misc/mei/debugfs.c +2 -0
@@ -183,6 +183,8 @@ static ssize_t mei_dbgfs_read_devstate(struct file *fp, char __user *ubuf, dev->hbm_f_fa_supported); pos +=scnprintf (buf + pos, bufsz - pos,"\tOS: %01d\n" , dev->hbm_f_os_supported); + pos +=scnprintf (buf + pos, bufsz - pos,"\tDR: %01d\n" , + dev->hbm_f_dr_supported); } pos += scnprintf(buf + pos, bufsz - pos, "pg: %s, %s\n",
drivers/misc/mei/hbm.c +6 -0
@@ -1007,6 +1007,12 @@ static void mei_hbm_config_features(struct mei_device *dev)/* OS ver message Support */ if (dev->version.major_version >=HBM_MAJOR_VERSION_OS ) dev->hbm_f_os_supported =1 ; + +/* DMA Ring Support */ +if (dev->version.major_version >HBM_MAJOR_VERSION_DR || + (dev->version.major_version ==HBM_MAJOR_VERSION_DR && + dev->version.minor_version >=HBM_MINOR_VERSION_DR )) + dev->hbm_f_dr_supported =1 ; }/**
drivers/misc/mei/hw.h +6 -0
@@ -80,6 +80,12 @@#define HBM_MINOR_VERSION_OS 0#define HBM_MAJOR_VERSION_OS 2 +/* +* MEI version with dma ring support +*/ +#define HBM_MINOR_VERSION_DR 1 +#define HBM_MAJOR_VERSION_DR 2 +/* Host bus message command opcode */ #define MEI_HBM_CMD_OP_MSK 0x7f/* Host bus message command RESPONSE */
drivers/misc/mei/mei_dev.h +2 -0
@@ -418,6 +418,7 @@ struct mei_fw_version {* @hbm_f_fa_supported : hbm feature fixed address client * @hbm_f_ie_supported : hbm feature immediate reply to enum request * @hbm_f_os_supported : hbm feature support OS ver message +* @hbm_f_dr_supported : hbm feature dma ring supported * * @fw_ver : FW versions *
@@ -495,6 +496,7 @@ struct mei_device { unsigned int hbm_f_fa_supported:1; unsigned int hbm_f_ie_supported:1; unsigned int hbm_f_os_supported:1; + unsigned int hbm_f_dr_supported:1;struct mei_fw_version fw_ver[MEI_MAX_FW_VER_BLOCKS ];
Signature · 1 line
2.14.4
PATCH 5/12 mei: define dma ring buffer sizes for PCH12 HW and newer
In reply to Tomas WinklerFrom: Alexander Usyskin <[email protected]>
Define dma ring buffer sizes for PCH12 (CLN HW and newer)
--- drivers/misc/mei/hw-me.c | 13 +++++++++++++ drivers/misc/mei/hw-me.h | 4 ++++ 2 files changed, 17 insertions(+)
drivers/misc/mei/hw-me.c +13 -0
@@ -19,6 +19,7 @@#include <linux/kthread.h> #include <linux/interrupt.h> #include <linux/pm_runtime.h> +#include <linux/sizes.h> #include "mei_dev.h" #include "hbm.h"
@@ -1389,6 +1390,11 @@ static bool mei_me_fw_type_sps(struct pci_dev *pdev) .fw_status.status[4] = PCI_CFG_HFS_5, \ .fw_status.status[5] = PCI_CFG_HFS_6 +#define MEI_CFG_DMA_128 \ + .dma_size[DMA_DSCR_HOST] = SZ_128K, \ + .dma_size[DMA_DSCR_DEVICE] = SZ_128K, \ + .dma_size[DMA_DSCR_CTRL] = PAGE_SIZE +/* ICH Legacy devices */ static const struct mei_cfg mei_me_ich_cfg = {MEI_CFG_ICH_HFS ,
@@ -1421,6 +1427,12 @@ static const struct mei_cfg mei_me_pch8_sps_cfg = { MEI_CFG_FW_SPS, }; +/* Cannon Lake and newer devices */ +static const struct mei_cfg mei_me_pch12_cfg = { +MEI_CFG_PCH8_HFS , +MEI_CFG_DMA_128 , +}; +/* * mei_cfg_list - A list of platform platform specific configurations. * Note: has to be synchronized with enum mei_cfg_idx.
@@ -1433,6 +1445,7 @@ static const struct mei_cfg *const mei_cfg_list[] = { [MEI_ME_PCH_CPT_PBG_CFG] = &mei_me_pch_cpt_pbg_cfg, [MEI_ME_PCH8_CFG] = &mei_me_pch8_cfg, [MEI_ME_PCH8_SPS_CFG] = &mei_me_pch8_sps_cfg, + [MEI_ME_PCH12_CFG] = &mei_me_pch12_cfg, };const struct mei_cfg *mei_me_get_cfg (kernel_ulong_t idx)
drivers/misc/mei/hw-me.h +4 -0
@@ -31,10 +31,12 @@* * @fw_status: FW status * @quirk_probe: device exclusion quirk +* @dma_size: device DMA buffers size */ struct mei_cfg {const struct mei_fw_status fw_status;bool (*quirk_probe)(struct pci_dev *pdev); +size_t dma_size[DMA_DSCR_NUM ]; };
@@ -80,6 +82,7 @@ struct mei_me_hw {* @MEI_ME_PCH8_SPS_CFG: Platform Controller Hub Gen8 and newer * servers platforms with quirk for * SPS firmware exclusion. +* @MEI_ME_PCH12_CFG: Platform Controller Hub Gen12 and newer * @MEI_ME_NUM_CFG: Upper Sentinel. */ enum mei_cfg_idx {
@@ -90,6 +93,7 @@ enum mei_cfg_idx {MEI_ME_PCH_CPT_PBG_CFG ,MEI_ME_PCH8_CFG ,MEI_ME_PCH8_SPS_CFG , +MEI_ME_PCH12_CFG , MEI_ME_NUM_CFG, };
Signature · 1 line
2.14.4
PATCH 6/12 mei: dma ring buffers allocation
In reply to Tomas WinklerAllocate DMA ring buffers from managed coherent memory.
--- drivers/misc/mei/Makefile | 1 + drivers/misc/mei/dma-ring.c | 103 ++++++++++++++++++++++++++++++++++++++++++++ drivers/misc/mei/hw-me.c | 6 +++ drivers/misc/mei/mei_dev.h | 20 +++++++++ 4 files changed, 130 insertions(+) create mode 100644 drivers/misc/mei/dma-ring.c
drivers/misc/mei/Makefile +1 -0
@@ -9,6 +9,7 @@ mei-objs += hbm.o mei-objs += interrupt.o mei-objs += client.o mei-objs += main.o +mei-objs += dma-ring.o mei-objs += bus.o mei-objs += bus-fixup.o mei-$(CONFIG_DEBUG_FS) += debugfs.o
drivers/misc/mei/dma-ring.c new file +103 -0
103 lines not on this page · raw message
drivers/misc/mei/hw-me.c +6 -0
@@ -1471,15 +1471,21 @@ struct mei_device *mei_me_dev_init(struct pci_dev *pdev, {struct mei_device *dev;struct mei_me_hw *hw; +int i; dev =devm_kzalloc (&pdev->dev,sizeof (struct mei_device ) +sizeof (struct mei_me_hw ),GFP_KERNEL );if (!dev)return NULL ; + hw =to_me_hw (dev); +for (i =0 ; i <DMA_DSCR_NUM ; i++) + dev->dr_dscr[i].size = cfg->dma_size[i]; +mei_device_init (dev, &pdev->dev, &mei_me_hw_ops); hw->cfg = cfg; +return dev; }
drivers/misc/mei/mei_dev.h +20 -0
@@ -122,6 +122,19 @@ struct mei_msg_data {unsigned char *data; }; +/** +* struct mei_dma_dscr - dma address descriptor +* +* @vaddr: dma buffer virtual address +* @daddr: dma buffer physical address +* @size : dma buffer size +*/ +struct mei_dma_dscr { +void *vaddr; +dma_addr_t daddr; +size_t size; +}; +/* Maximum number of processed FW status registers */ #define MEI_FW_STATUS_MAX 6/* Minimal buffer for FW status string (8 bytes in dw + space or '\0') */
@@ -409,6 +422,7 @@ struct mei_fw_version {* @rd_msg_hdr : read message header storage * * @hbuf_is_ready : query if the host host/write buffer is ready +* @dr_dscr: DMA ring descriptors: TX, RX, and CTRL * * @version : HBM protocol version in use * @hbm_f_pg_supported : hbm feature pgi protocol
@@ -488,6 +502,8 @@ struct mei_device {/* write buffer */ bool hbuf_is_ready; +struct mei_dma_dscr dr_dscr[DMA_DSCR_NUM ]; +struct hbm_version version; unsigned int hbm_f_pg_supported:1; unsigned int hbm_f_dc_supported:1;
@@ -578,6 +594,10 @@ int mei_restart(struct mei_device *dev);void mei_stop (struct mei_device *dev);void mei_cancel_work (struct mei_device *dev); +int mei_dmam_ring_alloc (struct mei_device *dev); +void mei_dmam_ring_free (struct mei_device *dev); +bool mei_dma_ring_is_allocated (struct mei_device *dev); +/* * MEI interrupt functions prototype */
Signature · 1 line
2.14.4
Greg Kroah-Hartman
maintainerRe: [char-misc-next 06/12] mei: dma ring buffers allocation
drivers/misc/mei/dma-ring.c line 1
Quoted 4 lines · Tomas Winkler
drivers/misc/mei/dma-ring.c new file +1
-0@@ -0,0 +1,103 @@ +// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
I thought Intel was not doing this type of crazy nonsense anymore and just properly creating new files that were GPL-2.0.
Are you _sure_ you want to do this?
drivers/misc/mei/dma-ring.c line 3
Quoted 2 lines
drivers/misc/mei/dma-ring.c new file +2
-0+/* +* Copyright(c) 2016 - 2018 Intel Corporation. All rights reserved.
How is a new file copyright 2016? You have had this file laying around for 2 years?
thanks,
greg k-h
RE: [char-misc-next 06/12] mei: dma ring buffers allocation
Quoted 10 lines · Tomas Winkler
drivers/misc/mei/dma-ring.c line 1
Quoted 4 lines
drivers/misc/mei/dma-ring.c new file +1
-0@@ -0,0 +1,103 @@ +// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 I thought Intel was not doing this type of crazy nonsense anymore and just properly creating new files that were GPL-2.0.
Quoted 7 lines
Are you _sure_ you want to do this?
drivers/misc/mei/dma-ring.c line 3
Quoted 2 lines
drivers/misc/mei/dma-ring.c new file +2
-0+/* +* Copyright(c) 2016 - 2018 Intel Corporation. All rights reserved. How is a new file copyright 2016? You have had this file laying around for 2 years?
Yes, it takes time till a HW is released to public.. Tomas
RE: [char-misc-next 06/12] mei: dma ring buffers allocation
In reply to Greg Kroah-HartmanQuoted 14 lines
Subject: RE: [char-misc-next 06/12] mei: dma ring buffers allocation
Quoted 10 lines · Tomas Winkler
drivers/misc/mei/dma-ring.c line 1
Quoted 4 lines
drivers/misc/mei/dma-ring.c new file +1
-0@@ -0,0 +1,103 @@ +// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 I thought Intel was not doing this type of crazy nonsense anymore and just properly creating new files that were GPL-2.0.
Are you _sure_ you want to do this?
I would prefer to keep it that way actually, hoping eventually relicense most of the files in the driver under the dual license, currently it's really kind of mix.
I'm not sure where this was discussed before, so you've surprised me with this comment.
There is no hidden agenda behind this move, just let the BSD and virtualization world look at the code more freely we have quite a gap there.
Thanks
Tomas
Greg Kroah-Hartman
maintainerRe: [char-misc-next 06/12] mei: dma ring buffers allocation
Quoted 13 lines · Tomas
Quoted 13 lines
Subject: RE: [char-misc-next 06/12] mei: dma ring buffers allocation
Quoted 9 lines · Tomas Winkler
drivers/misc/mei/dma-ring.c line 1
Quoted 4 lines
drivers/misc/mei/dma-ring.c new file +1
-0@@ -0,0 +1,103 @@ +// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 I thought Intel was not doing this type of crazy nonsense anymore and just properly creating new files that were GPL-2.0.
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Are you _sure_ you want to do this?
I would prefer to keep it that way actually, hoping eventually
relicense most of the files in the driver under the dual license, currently it's really kind of mix.
I'm not sure where this was discussed before, so you've surprised me with this comment.
Please go talk to the open source legal team at Intel, this has been discussed with them a number of times now. Look at the IB drivers for one example of how this has changed.
thanks,
greg k-h
PATCH 7/12 mei: hbm: setup dma ring
In reply to Tomas WinklerDMA ring is allocated upon HBM handshake and the ring parameters are set via dedicated HBM_DMA_SETUP request command. The firmware will perform its setup and respond with a status. On failure the DMA buffers are released.
--- drivers/misc/mei/hbm.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++-- drivers/misc/mei/hbm.h | 2 ++ 2 files changed, 86 insertions(+), 3 deletions(-)
drivers/misc/mei/hbm.c +84 -3
@@ -65,6 +65,7 @@ const char *mei_hbm_state_str(enum mei_hbm_state state)MEI_HBM_STATE (IDLE );MEI_HBM_STATE (STARTING );MEI_HBM_STATE (STARTED ); +MEI_HBM_STATE (DR_SETUP );MEI_HBM_STATE (ENUM_CLIENTS );MEI_HBM_STATE (CLIENT_PROPERTIES );MEI_HBM_STATE (STOPPED );
@@ -295,6 +296,47 @@ int mei_hbm_start_req(struct mei_device *dev)return 0 ; } +/** +* mei_hbm_dma_setup_req - setup DMA request +* +* @dev: the device structure +* +* Return: 0 on success and < 0 on failure +*/ +static int mei_hbm_dma_setup_req (struct mei_device *dev) +{ +struct mei_msg_hdr mei_hdr; +struct hbm_dma_setup_request req; +const size_t len =sizeof (struct hbm_dma_setup_request ); +unsigned int i; +int ret; + +mei_hbm_hdr (&mei_hdr, len); + +memset (&req,0 , len); + req.hbm_cmd =MEI_HBM_DMA_SETUP_REQ_CMD ; +for (i =0 ; i <DMA_DSCR_NUM ; i++) { +phys_addr_t paddr; + + paddr = dev->dr_dscr[i].daddr; + req.dma_dscr[i].addr_hi =upper_32_bits (paddr); + req.dma_dscr[i].addr_lo =lower_32_bits (paddr); + req.dma_dscr[i].size = dev->dr_dscr[i].size; + } + + ret =mei_hbm_write_message (dev, &mei_hdr, &req); +if (ret) { +dev_err (dev->dev,"dma setup request write failed: ret = %d.\n" , + ret); +return ret; + } + + dev->hbm_state =MEI_HBM_DR_SETUP ; + dev->init_clients_timer =MEI_CLIENTS_INIT_TIMEOUT ; +mei_schedule_stall_timer (dev); +return 0 ; +} +/** * mei_hbm_enum_clients_req - sends enumeration client request message. *
@@ -1044,6 +1086,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)struct hbm_host_version_response *version_res;struct hbm_props_response *props_res;struct hbm_host_enum_response *enum_res; +struct hbm_dma_setup_response *dma_setup_res;struct hbm_add_client_request *add_cl_req;int ret;
@@ -1108,14 +1151,52 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)return -EPROTO ; } -if (mei_hbm_enum_clients_req (dev)) { -dev_err (dev->dev,"hbm: start: failed to send enumeration request\n" ); -return -EIO ; +if (dev->hbm_f_dr_supported) { +if (mei_dmam_ring_alloc (dev)) +dev_info (dev->dev,"running w/o dma ring\n" ); +if (mei_dma_ring_is_allocated (dev)) { +if (mei_hbm_dma_setup_req (dev)) +return -EIO ; + +wake_up (&dev->wait_hbm_start); +break ; + } } + dev->hbm_f_dr_supported =0 ; +mei_dmam_ring_free (dev); + +if (mei_hbm_enum_clients_req (dev)) +return -EIO ; +wake_up (&dev->wait_hbm_start);break ; +case MEI_HBM_DMA_SETUP_RES_CMD : +dev_dbg (dev->dev,"hbm: dma setup response: message received.\n" ); + + dev->init_clients_timer =0 ; + +if (dev->hbm_state !=MEI_HBM_DR_SETUP ) { +dev_err (dev->dev,"hbm: dma setup response: state mismatch, [%d, %d]\n" , + dev->dev_state, dev->hbm_state); +return -EPROTO ; + } + + dma_setup_res = (struct hbm_dma_setup_response *)mei_msg; + +if (dma_setup_res->status) { +dev_info (dev->dev,"hbm: dma setup response: failure = %d %s\n" , + dma_setup_res->status, +mei_hbm_status_str (dma_setup_res->status)); + dev->hbm_f_dr_supported =0 ; +mei_dmam_ring_free (dev); + } + +if (mei_hbm_enum_clients_req (dev)) +return -EIO ; +break ; +case CLIENT_CONNECT_RES_CMD :dev_dbg (dev->dev,"hbm: client connect response: message received.\n" );mei_hbm_cl_res (dev, cl_cmd,MEI_FOP_CONNECT );
drivers/misc/mei/hbm.h +2 -0
@@ -26,6 +26,7 @@ struct mei_cl;* * @MEI_HBM_IDLE : protocol not started * @MEI_HBM_STARTING : start request message was sent +* @MEI_HBM_DR_SETUP : dma ring setup request message was sent * @MEI_HBM_ENUM_CLIENTS : enumeration request was sent * @MEI_HBM_CLIENT_PROPERTIES : acquiring clients properties * @MEI_HBM_STARTED : enumeration was completed
@@ -34,6 +35,7 @@ struct mei_cl;enum mei_hbm_state {MEI_HBM_IDLE =0 ,MEI_HBM_STARTING , +MEI_HBM_DR_SETUP ,MEI_HBM_ENUM_CLIENTS ,MEI_HBM_CLIENT_PROPERTIES ,MEI_HBM_STARTED ,
Signature · 1 line
2.14.4
PATCH 8/12 mei: hw: add dma ring control block
In reply to Tomas WinklerThe DMA ring control block contains write and read indices for host and device circular buffers.
--- drivers/misc/mei/dma-ring.c | 21 +++++++++++++++++++++ drivers/misc/mei/hbm.c | 2 ++ drivers/misc/mei/hw.h | 23 +++++++++++++++++++++++ drivers/misc/mei/mei_dev.h | 1 + 4 files changed, 47 insertions(+)
drivers/misc/mei/dma-ring.c +21 -0
@@ -101,3 +101,24 @@ bool mei_dma_ring_is_allocated(struct mei_device *dev) {return !!dev->dr_dscr[DMA_DSCR_HOST ].vaddr; } + +static inline +struct hbm_dma_ring_ctrl *mei_dma_ring_ctrl (struct mei_device *dev) +{ +return (struct hbm_dma_ring_ctrl *)dev->dr_dscr[DMA_DSCR_CTRL ].vaddr; +} + +/** +* mei_dma_ring_reset - reset the dma control block +* +* @dev: mei device +*/ +void mei_dma_ring_reset (struct mei_device *dev) +{ +struct hbm_dma_ring_ctrl *ctrl =mei_dma_ring_ctrl (dev); + +if (!ctrl) +return ; + +memset (ctrl,0 ,sizeof (*ctrl)); +}
drivers/misc/mei/hbm.c +2 -0
@@ -324,6 +324,8 @@ static int mei_hbm_dma_setup_req(struct mei_device *dev) req.dma_dscr[i].size = dev->dr_dscr[i].size; } +mei_dma_ring_reset (dev); + ret =mei_hbm_write_message (dev, &mei_hdr, &req);if (ret) { dev_err(dev->dev, "dma setup request write failed: ret = %d.\n",
drivers/misc/mei/hw.h +23 -0
@@ -512,4 +512,27 @@ struct hbm_dma_setup_response { u8 reserved[2]; } __packed; +/** +* struct mei_dma_ring_ctrl - dma ring control block +* +* @hbuf_wr_idx: host circular buffer write index in slots +* @reserved1: reserved for alignment +* @hbuf_rd_idx: host circular buffer read index in slots +* @reserved2: reserved for alignment +* @dbuf_wr_idx: device circular buffer write index in slots +* @reserved3: reserved for alignment +* @dbuf_rd_idx: device circular buffer read index in slots +* @reserved4: reserved for alignment +*/ +struct hbm_dma_ring_ctrl { +u32 hbuf_wr_idx; +u32 reserved1; +u32 hbuf_rd_idx; +u32 reserved2; +u32 dbuf_wr_idx; +u32 reserved3; +u32 dbuf_rd_idx; +u32 reserved4; +} __packed; +#endif
drivers/misc/mei/mei_dev.h +1 -0
@@ -597,6 +597,7 @@ void mei_cancel_work(struct mei_device *dev);int mei_dmam_ring_alloc (struct mei_device *dev);void mei_dmam_ring_free (struct mei_device *dev);bool mei_dma_ring_is_allocated (struct mei_device *dev); +void mei_dma_ring_reset (struct mei_device *dev);/* * MEI interrupt functions prototype
Signature · 1 line
2.14.4
PATCH 9/12 mei: dma ring: implement rx circular buffer logic
In reply to Tomas WinklerImplement circular buffer protocol over receive dma buffer. Add extension to the mei message header that holds length of the buffer on the dma buffer.
--- drivers/misc/mei/client.c | 2 +- drivers/misc/mei/dma-ring.c | 63 ++++++++++++++++++++++++++++++++++++++++++++ drivers/misc/mei/hw.h | 4 +++ drivers/misc/mei/init.c | 2 +- drivers/misc/mei/interrupt.c | 41 +++++++++++++++++++--------- drivers/misc/mei/mei_dev.h | 3 ++- 6 files changed, 100 insertions(+), 15 deletions(-)
drivers/misc/mei/client.c +1 -1
@@ -478,7 +478,7 @@ struct mei_cl_cb *mei_cl_alloc_cb(struct mei_cl *cl, size_t length,if (length ==0 )return cb; - cb->buf.data =kmalloc (length,GFP_KERNEL ); + cb->buf.data =kmalloc (roundup (length,MEI_SLOT_SIZE ),GFP_KERNEL );if (!cb->buf.data) {mei_io_cb_free (cb);return NULL ;
drivers/misc/mei/dma-ring.c +63 -0
66 lines not on this page · raw message
drivers/misc/mei/hw.h +4 -0
@@ -206,6 +206,7 @@ enum mei_cl_disconnect_status {* @dma_ring: message is on dma ring * @internal: message is internal * @msg_complete: last packet of the message +* @extension: extension of the header */ struct mei_msg_hdr {u32 me_addr:8 ;
@@ -215,8 +216,11 @@ struct mei_msg_hdr { u32 dma_ring:1; u32 internal:1; u32 msg_complete:1; +u32 extension[0 ]; } __packed; +#define MEI_MSG_HDR_MAX 2 +struct mei_bus_message {u8 hbm_cmd;u8 data[0 ];
drivers/misc/mei/init.c +1 -1
@@ -151,7 +151,7 @@ int mei_reset(struct mei_device *dev)mei_hbm_reset (dev); - dev->rd_msg_hdr =0 ; +memset (dev->rd_msg_hdr,0 ,sizeof (dev->rd_msg_hdr));if (ret) {dev_err (dev->dev,"hw_reset failed ret = %d\n" , ret);
drivers/misc/mei/interrupt.c +29 -12
114 lines not on this page · raw message
drivers/misc/mei/mei_dev.h +2 -1
@@ -497,7 +497,7 @@ struct mei_device {#endif /* CONFIG_PM */ unsigned char rd_msg_buf[MEI_RD_MSG_BUF_SIZE ]; -u32 rd_msg_hdr; +u32 rd_msg_hdr[MEI_MSG_HDR_MAX ];/* write buffer */ bool hbuf_is_ready;
@@ -598,6 +598,7 @@ int mei_dmam_ring_alloc(struct mei_device *dev);void mei_dmam_ring_free (struct mei_device *dev);bool mei_dma_ring_is_allocated (struct mei_device *dev);void mei_dma_ring_reset (struct mei_device *dev); +void mei_dma_ring_read (struct mei_device *dev,unsigned char *buf,u32 len);/* * MEI interrupt functions prototype
Signature · 1 line
2.14.4
PATCH 10/12 mei: dma ring: implement transmit flow
In reply to Tomas WinklerImplement a circular buffer on allocated system memory. Read and write indices are stored on the control block which is also shared between the device and the host.
Two new functions are exported from the DMA module: mei_dma_ring_write, and mei_dma_ring_empty_slots. The former simply copy a packet on the TX DMA circular buffer and later, returns the number of empty slots on the TX DMA circular buffer.
--- drivers/misc/mei/client.c | 56 ++++++++++++++++++++++------ drivers/misc/mei/dma-ring.c | 91 +++++++++++++++++++++++++++++++++++++++++++++ drivers/misc/mei/mei_dev.h | 2 + 3 files changed, 138 insertions(+), 11 deletions(-)
drivers/misc/mei/client.c +45 -11
@@ -1573,10 +1573,13 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,struct mei_msg_hdr mei_hdr;size_t hdr_len =sizeof (mei_hdr);size_t len; -size_t hbuf_len; +size_t hbuf_len, dr_len;int hbuf_slots; +u32 dr_slots; +u32 dma_len;int rets;bool first_chunk; +const void *data;if (WARN_ON (!cl || !cl->dev))return -ENODEV ;
@@ -1597,6 +1600,7 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb, } len = buf->size - cb->buf_idx; + data = buf->data + cb->buf_idx; hbuf_slots =mei_hbuf_empty_slots (dev);if (hbuf_slots <0 ) { rets = -EOVERFLOW ;
@@ -1604,6 +1608,8 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb, } hbuf_len =mei_slots2data (hbuf_slots); + dr_slots =mei_dma_ring_empty_slots (dev); + dr_len =mei_slots2data (dr_slots);mei_msg_hdr_init (&mei_hdr, cb);
@@ -1614,23 +1620,32 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,if (len + hdr_len <= hbuf_len) { mei_hdr.length = len; mei_hdr.msg_complete =1 ; + }else if (dr_slots && hbuf_len >= hdr_len +sizeof (dma_len)) { + mei_hdr.dma_ring =1 ; +if (len > dr_len) + len = dr_len; +else + mei_hdr.msg_complete =1 ; + + mei_hdr.length =sizeof (dma_len); + dma_len = len; + data = &dma_len; }else if ((u32 )hbuf_slots ==mei_hbuf_depth (dev)) { mei_hdr.length = hbuf_len - hdr_len; }else {return 0 ; } -cl_dbg (dev, cl,"buf: size = %zu idx = %zu\n" , - cb->buf.size, cb->buf_idx); +if (mei_hdr.dma_ring) +mei_dma_ring_write (dev, buf->data + cb->buf_idx, len); - rets =mei_write_message (dev, &mei_hdr, hdr_len, - buf->data + cb->buf_idx, mei_hdr.length); + rets =mei_write_message (dev, &mei_hdr, hdr_len, data, mei_hdr.length);if (rets) goto err; cl->status =0 ; cl->writing_state =MEI_WRITING ; - cb->buf_idx += mei_hdr.length; + cb->buf_idx += len;if (first_chunk) {if (mei_cl_tx_flow_ctrl_creds_reduce (cl)) {
@@ -1665,11 +1680,13 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb)struct mei_msg_data *buf;struct mei_msg_hdr mei_hdr;size_t hdr_len =sizeof (mei_hdr); -size_t len; -size_t hbuf_len; +size_t len, hbuf_len, dr_len;int hbuf_slots; +u32 dr_slots; +u32 dma_len;ssize_t rets;bool blocking; +const void *data;if (WARN_ON (!cl || !cl->dev))return -ENODEV ;
@@ -1681,10 +1698,12 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb) buf = &cb->buf; len = buf->size; - blocking = cb->blocking;cl_dbg (dev, cl,"len=%zd\n" , len); + blocking = cb->blocking; + data = buf->data; + rets =pm_runtime_get (dev->dev);if (rets <0 && rets != -EINPROGRESS ) {pm_runtime_put_noidle (dev->dev);
@@ -1721,16 +1740,31 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb) } hbuf_len =mei_slots2data (hbuf_slots); + dr_slots =mei_dma_ring_empty_slots (dev); + dr_len =mei_slots2data (dr_slots);if (len + hdr_len <= hbuf_len) { mei_hdr.length = len; mei_hdr.msg_complete =1 ; + }else if (dr_slots && hbuf_len >= hdr_len +sizeof (dma_len)) { + mei_hdr.dma_ring =1 ; +if (len > dr_len) + len = dr_len; +else + mei_hdr.msg_complete =1 ; + + mei_hdr.length =sizeof (dma_len); + dma_len = len; + data = &dma_len; }else { mei_hdr.length = hbuf_len - hdr_len; } +if (mei_hdr.dma_ring) +mei_dma_ring_write (dev, buf->data, len); + rets =mei_write_message (dev, &mei_hdr, hdr_len, - buf->data, mei_hdr.length); + data, mei_hdr.length);if (rets) goto err;
@@ -1739,7 +1773,7 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb) goto err; cl->writing_state =MEI_WRITING ; - cb->buf_idx = mei_hdr.length; + cb->buf_idx = len; out:if (mei_hdr.msg_complete)
drivers/misc/mei/dma-ring.c +91 -0
100 lines not on this page · raw message
drivers/misc/mei/mei_dev.h +2 -0
@@ -599,6 +599,8 @@ void mei_dmam_ring_free(struct mei_device *dev);bool mei_dma_ring_is_allocated (struct mei_device *dev);void mei_dma_ring_reset (struct mei_device *dev);void mei_dma_ring_read (struct mei_device *dev,unsigned char *buf,u32 len); +void mei_dma_ring_write (struct mei_device *dev,unsigned char *buf,u32 len); +u32 mei_dma_ring_empty_slots (struct mei_device *dev);/* * MEI interrupt functions prototype
Signature · 1 line
2.14.4
PATCH 11/12 mei: bump hbm version to 2.1
In reply to Tomas WinklerFrom: Alexander Usyskin <[email protected]>
Bump HBM version to 2.1 to indicate DMA transfer support.
--- drivers/misc/mei/hw.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/mei/hw.h +1 -1
@@ -35,7 +35,7 @@/* * MEI Version */ -#define HBM_MINOR_VERSION 0 +#define HBM_MINOR_VERSION 1#define HBM_MAJOR_VERSION 2/*
Signature · 1 line
2.14.4
PATCH 12/12 mei: me: mark CNP devices as having dma support
In reply to Tomas WinklerFrom: Alexander Usyskin <[email protected]>
--- drivers/misc/mei/pci-me.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/misc/mei/pci-me.c +2 -2
@@ -98,9 +98,9 @@ static const struct pci_device_id mei_me_pci_tbl[] = { {MEI_PCI_DEVICE(MEI_DEV_ID_KBP, MEI_ME_PCH8_CFG)}, {MEI_PCI_DEVICE(MEI_DEV_ID_KBP_2, MEI_ME_PCH8_CFG)}, - {MEI_PCI_DEVICE(MEI_DEV_ID_CNP_LP, MEI_ME_PCH8_CFG)}, + {MEI_PCI_DEVICE(MEI_DEV_ID_CNP_LP, MEI_ME_PCH12_CFG)}, {MEI_PCI_DEVICE(MEI_DEV_ID_CNP_LP_4, MEI_ME_PCH8_CFG)}, - {MEI_PCI_DEVICE(MEI_DEV_ID_CNP_H, MEI_ME_PCH8_CFG)}, + {MEI_PCI_DEVICE(MEI_DEV_ID_CNP_H, MEI_ME_PCH12_CFG)}, {MEI_PCI_DEVICE(MEI_DEV_ID_CNP_H_4, MEI_ME_PCH8_CFG)},/* required last entry */
Signature · 1 line
2.14.4
Greg Kroah-Hartman
maintainerQuoted 8 lines · Tomas Winkler
This series adds an alternative method for transferring data between the mei driver and the device via a DMA ring. The DMA ring allows transferring data in bigger chunks, up to 128K, than the HW ring 512B. The actual sizes depend on particular MEI generations. The HW ring is faster for packets that fits
into the HW ring while a packet that would require fragmentation is faster to send via the DMA ring.
I've applied the first 5 patches now. Please fix up and resend the rest.
thanks,
greg k-h
Quoted 10 lines · Tomas Winkler
Quoted 7 lines
This series adds an alternative method for transferring data between the mei driver and the device via a DMA ring. The DMA ring allows transferring data in bigger chunks, up to 128K, than the HW ring 512B. The actual sizes depend on particular MEI generations.
The HW ring is faster for packets that fits into the HW ring while a packet that would require fragmentation is faster to send via the DMA ring.I've applied the first 5 patches now. Please fix up and resend the rest.
Greg, as I wrote, we wish to stay with the dual license in that file, please can you apply the patches as they are?
Thanks
Tomas
Quoted 11 lines
Quoted 11 lines · Tomas Winkler
Quoted 7 lines
This series adds an alternative method for transferring data between the mei driver and the device via a DMA ring. The DMA ring allows transferring data in bigger chunks, up to 128K, than the HW ring 512B. The actual sizes depend on particular MEI generations.
The HW ring is faster for packets that fits into the HW ring while a packet that would require fragmentation is faster to send via the DMA ring.
Quoted 4 lines
Quoted 1 line
I've applied the first 5 patches now. Please fix up and resend the rest.
Greg, as I wrote, we wish to stay with the dual license in that file, please can you apply the patches as they are?
Hi Greg, can you please respond, we have half of the series merged only, it should be completed. Thanks
Tomas
'Greg Kroah-Hartman'
maintainerQuoted 11 lines · Tomas
Quoted 11 lines
Quoted 11 lines · Tomas Winkler
Quoted 7 lines
This series adds an alternative method for transferring data between the mei driver and the device via a DMA ring. The DMA ring allows transferring data in bigger chunks, up to 128K, than the HW ring 512B. The actual sizes depend on particular MEI generations.
The HW ring is faster for packets that fits into the HW ring while a packet that would require fragmentation is faster to send via the DMA ring.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
I've applied the first 5 patches now. Please fix up and resend the rest.
Greg, as I wrote, we wish to stay with the dual license in that file, please can you apply the patches as they are?
Hi Greg, can you please respond, we have half of the series merged only, it should be completed.
It's the middle of the merge window, with major security things happening at the same time, my ability to be persistant and annoyed at minor things like this is very low...
Anyway, the patch series is long gone from my queue, you will have to resend them please. But first, I want to see an Intel lawyer's signed-off-by on them when you do resend them as the last time I talked to them, they said they were not going to be doing dual-licensed kernel code anymore for a whole bunch of reasons I don't want to get into on a public mailing list.
So go verify this please, and get their approval before resending.
thanks,
greg k-h
Greg Kroah-Hartman
maintainerQuoted 9 lines · Tomas
Quoted 9 lines · Tomas Winkler
Quoted 7 lines
This series adds an alternative method for transferring data between the mei driver and the device via a DMA ring. The DMA ring allows transferring data in bigger chunks, up to 128K, than the HW ring 512B. The actual sizes depend on particular MEI generations.
The HW ring is faster for packets that fits into the HW ring while a packet that would require fragmentation is faster to send via the DMA ring.
Quoted 4 lines
Quoted 1 line
I've applied the first 5 patches now. Please fix up and resend the rest.
Greg, as I wrote, we wish to stay with the dual license in that file, please can you apply the patches as they are?
I don't have these anymore in my queue, can you rebase and resend?
thanks,
greg k-h