mei: rx enhancements
Subsystems (2)
cover mei: rx enhancements
This patch series contains mostly fixes and enhancements of the rx path:
1. Better handling of fixed address clients
2. Support for consecutive reads
3. Further amthif client diet
Alexander Usyskin (10):
mei: move read cb to complete queue if not connected
mei: add file pointer to the host client structure
mei: add read callback on demand for fixed_address clients
mei: amthif: drop mei_clear_lists function
mei: drop redundant krealloc and checks in irq read
mei: prepare read cb for fixed address clients on the receive path
only.
mei: rx flow control counter
mei: enqueue consecutive reads
mei: amthif: drop mei_amthif_read
mei: drop unused file transaction states
Tomas Winkler (2):
mei: use consistent naming for TX control flow credits
mei: add wrapper for queuing control commands.
drivers/misc/mei/amthif.c | 148 ++++--------------------------------- drivers/misc/mei/bus.c | 2 +- drivers/misc/mei/client.c | 170 +++++++++++++++++++++---------------------- drivers/misc/mei/client.h | 5 +- drivers/misc/mei/hbm.c | 45 ++++++------ drivers/misc/mei/interrupt.c | 47 ++++++------ drivers/misc/mei/main.c | 47 ++++++------ drivers/misc/mei/mei_dev.h | 23 ++---- 8 files changed, 176 insertions(+), 311 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/12 mei: move read cb to complete queue if not connected
From: Alexander Usyskin <[email protected]>
Move read cb to the completion queue if a read finds out that client is not connected. This expedite user space reader wake on error condition.
--- drivers/misc/mei/interrupt.c | 1 + 1 file changed, 1 insertion(+)
drivers/misc/mei/interrupt.c +1 -0
@@ -113,6 +113,7 @@ int mei_cl_irq_read_msg(struct mei_cl *cl,if (!mei_cl_is_connected (cl)) {cl_dbg (dev, cl,"not connected\n" ); +list_move_tail (&cb->list, &complete_list->list); cb->status = -ENODEV ; goto out; }
Signature · 1 line
2.7.4
PATCH 2/12 mei: add file pointer to the host client structure
In reply to Tomas WinklerFrom: Alexander Usyskin <[email protected]>
Store the file associated with a client in the host client structure, this enables dropping the special amthif client file pointer from struct mei_device, and this is also a preparation for changing the way rx packet allocation for fixed_address clients
--- drivers/misc/mei/amthif.c | 13 +++++++------ drivers/misc/mei/interrupt.c | 1 - drivers/misc/mei/main.c | 1 + drivers/misc/mei/mei_dev.h | 5 ++--- 4 files changed, 10 insertions(+), 10 deletions(-)
drivers/misc/mei/amthif.c +7 -6
@@ -204,7 +204,7 @@ static int mei_amthif_read_start(struct mei_cl *cl, const struct file *file)list_add_tail (&cb->list, &dev->ctrl_wr_list.list); dev->iamthif_state =MEI_IAMTHIF_READING ; - dev->iamthif_fp = cb->fp; + cl->fp = cb->fp;return 0 ; }
@@ -230,13 +230,13 @@ int mei_amthif_run_next_cmd(struct mei_device *dev) typeof(*cb), list);if (!cb) { dev->iamthif_state =MEI_IAMTHIF_IDLE ; - dev->iamthif_fp =NULL ; + cl->fp =NULL ;return 0 ; }list_del_init (&cb->list); dev->iamthif_state =MEI_IAMTHIF_WRITING ; - dev->iamthif_fp = cb->fp; + cl->fp = cb->fp; ret =mei_cl_write (cl, cb, false);if (ret <0 )
@@ -375,7 +375,7 @@ void mei_amthif_complete(struct mei_cl *cl, struct mei_cl_cb *cb)return ; } dev->iamthif_state =MEI_IAMTHIF_IDLE ; - dev->iamthif_fp =NULL ; + cl->fp =NULL ;if (!dev->iamthif_canceled) {/* * in case of error enqueue the write cb to complete
@@ -453,11 +453,12 @@ static void mei_clear_lists(struct mei_device *dev, const struct file *file)*/ int mei_amthif_release (struct mei_device *dev,struct file *file) { +struct mei_cl *cl = file->private_data; +if (dev->iamthif_open_count >0 ) dev->iamthif_open_count--; -if (dev->iamthif_fp == file && - dev->iamthif_state !=MEI_IAMTHIF_IDLE ) { +if (cl->fp == file && dev->iamthif_state !=MEI_IAMTHIF_IDLE ) {dev_dbg (dev->dev,"amthif canceled iamthif state %d\n" , dev->iamthif_state);
drivers/misc/mei/interrupt.c +0 -1
@@ -516,7 +516,6 @@ void mei_timer(struct work_struct *work)dev_err (dev->dev,"timer: amthif hanged.\n" );mei_reset (dev); - dev->iamthif_fp =NULL ;mei_amthif_run_next_cmd (dev); } }
drivers/misc/mei/main.c +1 -0
@@ -71,6 +71,7 @@ static int mei_open(struct inode *inode, struct file *file) goto err_unlock; } + cl->fp = file; file->private_data = cl;mutex_unlock (&dev->device_lock);
drivers/misc/mei/mei_dev.h +2 -3
@@ -200,6 +200,7 @@ struct mei_cl_cb {* @ev_async: event async notification * @status: connection status * @me_cl: fw client connected +* @fp: file associated with client * @host_client_id: host id * @mei_flow_ctrl_creds: transmit flow credentials * @timer_count: watchdog timer for operation completion
@@ -223,6 +224,7 @@ struct mei_cl {struct fasync_struct *ev_async;int status;struct mei_me_client *me_cl; +const struct file *fp;u8 host_client_id;u8 mei_flow_ctrl_creds;u8 timer_count;
@@ -398,7 +400,6 @@ const char *mei_pg_state_str(enum mei_pg_state state);* @override_fixed_address: force allow fixed address behavior * * @amthif_cmd_list : amthif list for cmd waiting -* @iamthif_fp : file for current amthif operation * @iamthif_cl : amthif host client * @iamthif_open_count : number of opened amthif connections * @iamthif_stall_timer : timer to detect amthif hang
@@ -481,8 +482,6 @@ struct mei_device {/* amthif list for cmd waiting */ struct mei_cl_cb amthif_cmd_list; -/* driver managed amthif list for reading completed amthif cmd data */ -const struct file *iamthif_fp;struct mei_cl iamthif_cl;long iamthif_open_count;u32 iamthif_stall_timer;
Signature · 1 line
2.7.4
PATCH 3/12 mei: add read callback on demand for fixed_address clients
In reply to Tomas WinklerFrom: Alexander Usyskin <[email protected]>
The Fixed address clients do not work with the flow control, and the packet RX callback was allocated upon TX with anticipation of a following RX. This won't work if the clients with unsolicited Rx. Rather than preparing read callback upon a write we allocate one directly on the reciev path if one doesn't exists.
--- drivers/misc/mei/client.c | 15 ++++----------- drivers/misc/mei/interrupt.c | 10 ++++++++-- 2 files changed, 12 insertions(+), 13 deletions(-)
drivers/misc/mei/client.c +4 -11
@@ -1145,26 +1145,19 @@ err:* mei_cl_flow_ctrl_creds - checks flow_control credits for cl. * * @cl: host client -* @fp: the file pointer associated with the pointer * * Return: 1 if mei_flow_ctrl_creds >0, 0 - otherwise. */ -static int mei_cl_flow_ctrl_creds (struct mei_cl *cl,const struct file *fp) +static int mei_cl_flow_ctrl_creds (struct mei_cl *cl) { -int rets; -if (WARN_ON (!cl || !cl->me_cl))return -EINVAL ;if (cl->mei_flow_ctrl_creds >0 )return 1 ; -if (mei_cl_is_fixed_address (cl)) { - rets =mei_cl_read_start (cl,mei_cl_mtu (cl), fp); -if (rets && rets != -EBUSY ) -return rets; +if (mei_cl_is_fixed_address (cl))return 1 ; - }if (mei_cl_is_single_recv_buf (cl)) {if (cl->me_cl->mei_flow_ctrl_creds >0 )
@@ -1537,7 +1530,7 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb, first_chunk = cb->buf_idx ==0 ; - rets = first_chunk ?mei_cl_flow_ctrl_creds (cl, cb->fp) :1 ; + rets = first_chunk ?mei_cl_flow_ctrl_creds (cl) :1 ;if (rets <0 )return rets;
@@ -1643,7 +1636,7 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking) mei_hdr.msg_complete =0 ; mei_hdr.internal = cb->internal; - rets =mei_cl_flow_ctrl_creds (cl, cb->fp); + rets =mei_cl_flow_ctrl_creds (cl);if (rets <0 ) goto err;
drivers/misc/mei/interrupt.c +8 -2
@@ -107,8 +107,14 @@ int mei_cl_irq_read_msg(struct mei_cl *cl, cb = list_first_entry_or_null(&cl->rd_pending, struct mei_cl_cb, list);if (!cb) { -cl_err (dev, cl,"pending read cb not found\n" ); - goto out; +if (!mei_cl_is_fixed_address (cl)) { +cl_err (dev, cl,"pending read cb not found\n" ); + goto out; + } + cb =mei_cl_alloc_cb (cl,mei_cl_mtu (cl),MEI_FOP_READ , cl->fp); +if (!cb) + goto out; +list_add_tail (&cb->list, &cl->rd_pending); }if (!mei_cl_is_connected (cl)) {
Signature · 1 line
2.7.4
PATCH 5/12 mei: drop redundant krealloc and checks in irq read
In reply to Tomas WinklerFrom: Alexander Usyskin <[email protected]>
The read callback is always prepared with MTU-sized buffer and the FW can't send more than the MTU in one message.
Checking for buffer existence and krealloc to increase receive buffer size are redundant and may be safely discarded.
--- drivers/misc/mei/interrupt.c | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-)
drivers/misc/mei/interrupt.c +11 -25
@@ -102,18 +102,17 @@ int mei_cl_irq_read_msg(struct mei_cl *cl, {struct mei_device *dev = cl->dev;struct mei_cl_cb *cb; -unsigned char *buffer =NULL ;size_t buf_sz; cb = list_first_entry_or_null(&cl->rd_pending, struct mei_cl_cb, list);if (!cb) {if (!mei_cl_is_fixed_address (cl)) {cl_err (dev, cl,"pending read cb not found\n" ); - goto out; + goto discard; } cb =mei_cl_alloc_cb (cl,mei_cl_mtu (cl),MEI_FOP_READ , cl->fp);if (!cb) - goto out; + goto discard;list_add_tail (&cb->list, &cl->rd_pending); }
@@ -121,14 +120,7 @@ int mei_cl_irq_read_msg(struct mei_cl *cl,cl_dbg (dev, cl,"not connected\n" );list_move_tail (&cb->list, &complete_list->list); cb->status = -ENODEV ; - goto out; - } - -if (cb->buf.size ==0 || cb->buf.data ==NULL ) { -cl_err (dev, cl,"response buffer is not allocated.\n" ); -list_move_tail (&cb->list, &complete_list->list); - cb->status = -ENOMEM ; - goto out; + goto discard; } buf_sz = mei_hdr->length + cb->buf_idx;
@@ -139,25 +131,19 @@ int mei_cl_irq_read_msg(struct mei_cl *cl,list_move_tail (&cb->list, &complete_list->list); cb->status = -EMSGSIZE ; - goto out; + goto discard; }if (cb->buf.size < buf_sz) {cl_dbg (dev, cl,"message overflow. size %zu len %d idx %zu\n" , cb->buf.size, mei_hdr->length, cb->buf_idx); - buffer =krealloc (cb->buf.data, buf_sz,GFP_KERNEL ); -if (!buffer) { - cb->status = -ENOMEM ; -list_move_tail (&cb->list, &complete_list->list); - goto out; - } - cb->buf.data = buffer; - cb->buf.size = buf_sz; +list_move_tail (&cb->list, &complete_list->list); + cb->status = -EMSGSIZE ; + goto discard; } - buffer = cb->buf.data + cb->buf_idx; -mei_read_slots (dev, buffer, mei_hdr->length); +mei_read_slots (dev, cb->buf.data + cb->buf_idx, mei_hdr->length); cb->buf_idx += mei_hdr->length;
@@ -169,10 +155,10 @@ int mei_cl_irq_read_msg(struct mei_cl *cl,pm_request_autosuspend (dev->dev); } -out: -if (!buffer) -mei_irq_discard_msg (dev, mei_hdr); +return 0 ; +discard: +mei_irq_discard_msg (dev, mei_hdr);return 0 ; }
Signature · 1 line
2.7.4
PATCH 4/12 mei: amthif: drop mei_clear_lists function
In reply to Tomas WinklerFrom: Alexander Usyskin <[email protected]>
Open code mei_clear_lists into its only caller mei_amthif_releas and drop unused parameter 'dev' form from mei_clear_list function.
--- drivers/misc/mei/amthif.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-)
drivers/misc/mei/amthif.c +5 -22
@@ -408,15 +408,14 @@ void mei_amthif_complete(struct mei_cl *cl, struct mei_cl_cb *cb)* mei_clear_list - removes all callbacks associated with file * from mei_cb_list * -* @dev: device structure. * @file: file structure * @mei_cb_list: callbacks list * * mei_clear_list is called to clear resources associated with file * when application calls close function or Ctrl-C was pressed */ -static void mei_clear_list (struct mei_device *dev, -const struct file *file,struct list_head *mei_cb_list) +static void mei_clear_list (const struct file *file, +struct list_head *mei_cb_list) {struct mei_cl_cb *cb, *next;
@@ -426,24 +425,6 @@ static void mei_clear_list(struct mei_device *dev, }/** -* mei_clear_lists - removes all callbacks associated with file -* -* @dev: device structure -* @file: file structure -* -* mei_clear_lists is called to clear resources associated with file -* when application calls close function or Ctrl-C was pressed -*/ -static void mei_clear_lists (struct mei_device *dev,const struct file *file) -{ -struct mei_cl *cl = &dev->iamthif_cl; - -mei_clear_list (dev, file, &dev->amthif_cmd_list.list); -mei_clear_list (dev, file, &cl->rd_completed); -mei_clear_list (dev, file, &dev->ctrl_rd_list.list); -} - -/** * mei_amthif_release - the release function * * @dev: device structure
@@ -465,7 +446,9 @@ int mei_amthif_release(struct mei_device *dev, struct file *file) dev->iamthif_canceled = true; } -mei_clear_lists (dev, file); +mei_clear_list (file, &dev->amthif_cmd_list.list); +mei_clear_list (file, &cl->rd_completed); +mei_clear_list (file, &dev->ctrl_rd_list.list);return 0 ; }
Signature · 1 line
2.7.4
PATCH 10/12 mei: enqueue consecutive reads
In reply to Tomas WinklerFrom: Alexander Usyskin <[email protected]>
The FW supports only one pending read per host client, in order to support issuing of consecutive reads the driver queues read requests internally and send them to the firmware after pending one has completed.
--- drivers/misc/mei/interrupt.c | 3 +++ drivers/misc/mei/main.c | 39 +++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 20 deletions(-)
drivers/misc/mei/interrupt.c +3 -0
@@ -209,6 +209,9 @@ static int mei_cl_irq_read(struct mei_cl *cl, struct mei_cl_cb *cb,int slots;int ret; +if (!list_empty (&cl->rd_pending)) +return 0 ; + msg_slots =mei_data2slots (sizeof (struct hbm_flow_control )); slots =mei_hbuf_empty_slots (dev);
drivers/misc/mei/main.c +19 -20
@@ -139,9 +139,8 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,struct mei_cl *cl = file->private_data;struct mei_device *dev;struct mei_cl_cb *cb =NULL ; +bool nonblock = !!(file->f_flags &O_NONBLOCK );int rets; -int err; -if (WARN_ON (!cl || !cl->dev))return -ENODEV ;
@@ -177,25 +176,29 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,if (*offset >0 ) *offset =0 ; - err =mei_cl_read_start (cl, length, file); -if (err && err != -EBUSY ) { -cl_dbg (dev, cl,"mei start read failure status = %d\n" , err); - rets = err; + rets =mei_cl_read_start (cl, length, file); +if (rets && rets != -EBUSY ) { +cl_dbg (dev, cl,"mei start read failure status = %d\n" , rets); goto out; } -/* synchronized under device mutex */ -if (!waitqueue_active (&cl->rx_wait)) { -if (file->f_flags &O_NONBLOCK ) { - rets = -EAGAIN ; - goto out; - } +if (nonblock) { + rets = -EAGAIN ; + goto out; + } + +if (rets == -EBUSY && + !mei_cl_enqueue_ctrl_wr_cb (cl, length,MEI_FOP_READ , file)) { + rets = -ENOMEM ; + goto out; + } + do { mutex_unlock(&dev->device_lock); if (wait_event_interruptible(cl->rx_wait, - (!list_empty (&cl->rd_completed)) || - (!mei_cl_is_connected (cl)))) { + (!list_empty(&cl->rd_completed)) || + (!mei_cl_is_connected(cl)))) { if (signal_pending(current)) return -EINTR;
@@ -207,13 +210,9 @@ static ssize_t mei_read(struct file *file, char __user *ubuf, rets = -ENODEV ; goto out; } - } - cb =mei_cl_read_cb (cl, file); -if (!cb) { - rets =0 ; - goto out; - } + cb =mei_cl_read_cb (cl, file); + }while (!cb); copy_buffer:/* now copy the data to user space */
Signature · 1 line
2.7.4
PATCH 12/12 mei: drop unused file transaction states
In reply to Tomas WinklerFrom: Alexander Usyskin <[email protected]>
--- drivers/misc/mei/mei_dev.h | 3 --- 1 file changed, 3 deletions(-)
drivers/misc/mei/mei_dev.h +0 -3
@@ -87,9 +87,6 @@ enum mei_file_transaction_states {MEI_IDLE ,MEI_WRITING , MEI_WRITE_COMPLETE, -MEI_FLOW_CONTROL , -MEI_READING , - MEI_READ_COMPLETE };/**
Signature · 1 line
2.7.4
PATCH 11/12 mei: amthif: drop mei_amthif_read
In reply to Tomas WinklerFrom: Alexander Usyskin <[email protected]>
mei_amthif_read have only one difference from mei_read, it is not calling mei_read_start().
Make mei_read_start return immediately for amthif client and drop the special mei_amthif_read function.
--- drivers/misc/mei/amthif.c | 100 --------------------------------------------- drivers/misc/mei/client.c | 2 +- drivers/misc/mei/main.c | 5 --- drivers/misc/mei/mei_dev.h | 3 -- 4 files changed, 1 insertion(+), 109 deletions(-)
drivers/misc/mei/amthif.c +0 -100
@@ -85,106 +85,6 @@ int mei_amthif_host_init(struct mei_device *dev, struct mei_me_client *me_cl) }/** -* mei_amthif_read - read data from AMTHIF client -* -* @dev: the device structure -* @file: pointer to file object -* @ubuf: pointer to user data in user space -* @length: data length to read -* @offset: data read offset -* -* Locking: called under "dev->device_lock" lock -* -* Return: -* returned data length on success, -* zero if no data to read, -* negative on failure. -*/ -int mei_amthif_read (struct mei_device *dev,struct file *file, -char __user *ubuf,size_t length,loff_t *offset) -{ -struct mei_cl *cl = file->private_data; -struct mei_cl_cb *cb; -int rets; -int wait_ret; - -dev_dbg (dev->dev,"checking amthif data\n" ); - cb =mei_cl_read_cb (cl, file); - -/* Check for if we can block or not*/ -if (cb ==NULL && file->f_flags &O_NONBLOCK ) -return -EAGAIN ; - - -dev_dbg (dev->dev,"waiting for amthif data\n" ); -while (cb ==NULL ) { -/* unlock the Mutex */ -mutex_unlock (&dev->device_lock); - - wait_ret =wait_event_interruptible (cl->rx_wait, - !list_empty (&cl->rd_completed) || - !mei_cl_is_connected (cl)); - -/* Locking again the Mutex */ -mutex_lock (&dev->device_lock); - -if (wait_ret) -return -ERESTARTSYS ; - -if (!mei_cl_is_connected (cl)) { - rets = -ENODEV ; - goto out; - } - - cb =mei_cl_read_cb (cl, file); - } - -if (cb->status) { - rets = cb->status; -dev_dbg (dev->dev,"read operation failed %d\n" , rets); - goto free; - } - -dev_dbg (dev->dev,"Got amthif data\n" ); -/* if the whole message will fit remove it from the list */ -if (cb->buf_idx >= *offset && length >= (cb->buf_idx - *offset)) -list_del_init (&cb->list); -else if (cb->buf_idx <= *offset) { -/* end of the message has been reached */ -list_del_init (&cb->list); - rets =0 ; - goto free; - } -/* else means that not full buffer will be read and do not -* remove message from deletion list -*/ - -dev_dbg (dev->dev,"amthif cb->buf.size - %zu cb->buf_idx - %zu\n" , - cb->buf.size, cb->buf_idx); - -/* length is being truncated to PAGE_SIZE, however, -* the buf_idx may point beyond */ - length =min_t (size_t, length, (cb->buf_idx - *offset)); - -if (copy_to_user (ubuf, cb->buf.data + *offset, length)) { -dev_dbg (dev->dev,"failed to copy data to userland\n" ); - rets = -EFAULT ; - }else { - rets = length; -if ((*offset + length) < cb->buf_idx) { - *offset += length; - goto out; - } - } -free: -dev_dbg (dev->dev,"free amthif cb memory.\n" ); - *offset =0 ; -mei_io_cb_free (cb); -out: -return rets; -} - -/** * mei_amthif_read_start - queue message for sending read credential * * @cl: host client
drivers/misc/mei/client.c +1 -1
@@ -1462,7 +1462,7 @@ int mei_cl_read_start(struct mei_cl *cl, size_t length, const struct file *fp)return -ENOTTY ; } -if (mei_cl_is_fixed_address (cl)) +if (mei_cl_is_fixed_address (cl) || cl == &dev->iamthif_cl)return 0 ;/* HW currently supports only one pending read */
drivers/misc/mei/main.c +0 -5
@@ -164,11 +164,6 @@ static ssize_t mei_read(struct file *file, char __user *ubuf, goto out; } -if (cl == &dev->iamthif_cl) { - rets =mei_amthif_read (dev, file, ubuf, length, offset); - goto out; - } - cb =mei_cl_read_cb (cl, file);if (cb) goto copy_buffer;
drivers/misc/mei/mei_dev.h +0 -3
@@ -564,9 +564,6 @@ void mei_amthif_reset_params(struct mei_device *dev);int mei_amthif_host_init (struct mei_device *dev,struct mei_me_client *me_cl); -int mei_amthif_read (struct mei_device *dev,struct file *file, -char __user *ubuf,size_t length,loff_t *offset); -unsigned int mei_amthif_poll (struct file *file,poll_table *wait);int mei_amthif_release (struct mei_device *dev,struct file *file);
Signature · 1 line
2.7.4
PATCH 9/12 mei: add wrapper for queuing control commands.
In reply to Tomas WinklerEnclose the boiler plate code of allocating a control/hbm command cb and enqueueing it onto ctrl_wr.list in a convenient wrapper mei_cl_enqueue_ctrl_wr_cb().
This is a preparatory patch for enabling consecutive reads.
--- drivers/misc/mei/amthif.c | 7 ++--- drivers/misc/mei/bus.c | 2 +- drivers/misc/mei/client.c | 78 ++++++++++++++++++++++++++++++----------------- drivers/misc/mei/client.h | 5 +-- drivers/misc/mei/hbm.c | 4 +-- drivers/misc/mei/main.c | 2 +- 6 files changed, 60 insertions(+), 38 deletions(-)
drivers/misc/mei/amthif.c +3 -4
@@ -188,20 +188,19 @@ out:* mei_amthif_read_start - queue message for sending read credential * * @cl: host client -* @file: file pointer of message recipient +* @fp: file pointer of message recipient * * Return: 0 on success, <0 on failure. */ -static int mei_amthif_read_start (struct mei_cl *cl,const struct file *file) +static int mei_amthif_read_start (struct mei_cl *cl,const struct file *fp) {struct mei_device *dev = cl->dev;struct mei_cl_cb *cb; - cb =mei_cl_alloc_cb (cl,mei_cl_mtu (cl),MEI_FOP_READ , file); + cb =mei_cl_enqueue_ctrl_wr_cb (cl,mei_cl_mtu (cl),MEI_FOP_READ , fp);if (!cb)return -ENOMEM ; -list_add_tail (&cb->list, &dev->ctrl_wr_list.list); cl->rx_flow_ctrl_creds++; dev->iamthif_state =MEI_IAMTHIF_READING ;
drivers/misc/mei/bus.c +1 -1
@@ -235,7 +235,7 @@ static void mei_cl_bus_event_work(struct work_struct *work)/* Prepare for the next read */ if (cldev->events_mask &BIT (MEI_CL_EVENT_RX )) {mutex_lock (&bus->device_lock); -mei_cl_read_start (cldev->cl,0 ,NULL ); +mei_cl_read_start (cldev->cl,mei_cl_mtu (cldev->cl),NULL );mutex_unlock (&bus->device_lock); } }
drivers/misc/mei/client.c +50 -28
159 lines not on this page · raw message
drivers/misc/mei/client.h +3 -2
@@ -82,8 +82,6 @@ static inline u8 mei_me_cl_ver(const struct mei_me_client *me_cl)/* * MEI IO Functions */ -struct mei_cl_cb *mei_io_cb_init (struct mei_cl *cl,enum mei_cb_file_ops type, -const struct file *fp);void mei_io_cb_free (struct mei_cl_cb *priv_cb);/**
@@ -116,6 +114,9 @@ void mei_cl_read_cb_flush(const struct mei_cl *cl, const struct file *fp);struct mei_cl_cb *mei_cl_alloc_cb (struct mei_cl *cl,size_t length,enum mei_cb_file_ops type,const struct file *fp); +struct mei_cl_cb *mei_cl_enqueue_ctrl_wr_cb (struct mei_cl *cl,size_t length, +enum mei_cb_file_ops type, +const struct file *fp);int mei_cl_flush_queues (struct mei_cl *cl,const struct file *fp);/*
drivers/misc/mei/hbm.c +2 -2
@@ -871,10 +871,10 @@ static int mei_hbm_fw_disconnect_req(struct mei_device *dev, cl->state =MEI_FILE_DISCONNECTING ; cl->timer_count =0 ; - cb =mei_io_cb_init (cl,MEI_FOP_DISCONNECT_RSP ,NULL ); + cb =mei_cl_enqueue_ctrl_wr_cb (cl,0 ,MEI_FOP_DISCONNECT_RSP , +NULL );if (!cb)return -ENOMEM ; -list_add_tail (&cb->list, &dev->ctrl_wr_list.list); }return 0 ; }
drivers/misc/mei/main.c +1 -1
@@ -628,7 +628,7 @@ static unsigned int mei_poll(struct file *file, poll_table *wait)if (!list_empty (&cl->rd_completed)) mask |=POLLIN |POLLRDNORM ;else -mei_cl_read_start (cl,0 , file); +mei_cl_read_start (cl,mei_cl_mtu (cl), file); } out:
Signature · 1 line
2.7.4
PATCH 8/12 mei: use consistent naming for TX control flow credits
In reply to Tomas WinklerWith the introduction of the receive control flow credits prefixed with rx_ we add tx_ prefix to the variables and function used for tracking the transmit control flow credits.
--- drivers/misc/mei/client.c | 39 +++++++++++++++++++-------------------- drivers/misc/mei/hbm.c | 41 ++++++++++++++++++++--------------------- drivers/misc/mei/mei_dev.h | 8 ++++---- 3 files changed, 43 insertions(+), 45 deletions(-)
drivers/misc/mei/client.c +19 -20
@@ -734,8 +734,8 @@ void mei_cl_set_disconnected(struct mei_cl *cl)mei_io_list_flush (&dev->ctrl_rd_list, cl);mei_io_list_flush (&dev->ctrl_wr_list, cl);mei_cl_wake_all (cl); - cl->mei_flow_ctrl_creds =0 ; cl->rx_flow_ctrl_creds =0 ; + cl->tx_flow_ctrl_creds =0 ; cl->timer_count =0 ;if (!cl->me_cl)
@@ -745,7 +745,7 @@ void mei_cl_set_disconnected(struct mei_cl *cl) cl->me_cl->connect_count--;if (cl->me_cl->connect_count ==0 ) - cl->me_cl->mei_flow_ctrl_creds =0 ; + cl->me_cl->tx_flow_ctrl_creds =0 ;mei_me_cl_put (cl->me_cl); cl->me_cl =NULL ;
@@ -1140,43 +1140,42 @@ err:return ERR_PTR (ret); } - -/** -* mei_cl_flow_ctrl_creds - checks flow_control credits for cl. +* mei_cl_tx_flow_ctrl_creds - checks flow_control credits for cl. * * @cl: host client * -* Return: 1 if mei_flow_ctrl_creds >0, 0 - otherwise. +* Return: 1 if tx_flow_ctrl_creds >0, 0 - otherwise. */ -static int mei_cl_flow_ctrl_creds (struct mei_cl *cl) +static int mei_cl_tx_flow_ctrl_creds (struct mei_cl *cl) {if (WARN_ON (!cl || !cl->me_cl))return -EINVAL ; -if (cl->mei_flow_ctrl_creds >0 ) +if (cl->tx_flow_ctrl_creds >0 )return 1 ;if (mei_cl_is_fixed_address (cl))return 1 ;if (mei_cl_is_single_recv_buf (cl)) { -if (cl->me_cl->mei_flow_ctrl_creds >0 ) +if (cl->me_cl->tx_flow_ctrl_creds >0 )return 1 ; }return 0 ; }/** -* mei_cl_flow_ctrl_reduce - reduces flow_control. +* mei_cl_tx_flow_ctrl_creds_reduce - reduces transmit flow control credits +* for a client * -* @cl: private data of the file object +* @cl: host client * * Return: * 0 on success * -EINVAL when ctrl credits are <= 0 */ -static int mei_cl_flow_ctrl_reduce (struct mei_cl *cl) +static int mei_cl_tx_flow_ctrl_creds_reduce (struct mei_cl *cl) {if (WARN_ON (!cl || !cl->me_cl))return -EINVAL ;
@@ -1185,13 +1184,13 @@ static int mei_cl_flow_ctrl_reduce(struct mei_cl *cl)return 0 ;if (mei_cl_is_single_recv_buf (cl)) { -if (WARN_ON (cl->me_cl->mei_flow_ctrl_creds <=0 )) +if (WARN_ON (cl->me_cl->tx_flow_ctrl_creds <=0 ))return -EINVAL ; - cl->me_cl->mei_flow_ctrl_creds--; + cl->me_cl->tx_flow_ctrl_creds--; }else { -if (WARN_ON (cl->mei_flow_ctrl_creds <=0 )) +if (WARN_ON (cl->tx_flow_ctrl_creds <=0 ))return -EINVAL ; - cl->mei_flow_ctrl_creds--; + cl->tx_flow_ctrl_creds--; }return 0 ; }
@@ -1511,7 +1510,7 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb, first_chunk = cb->buf_idx ==0 ; - rets = first_chunk ?mei_cl_flow_ctrl_creds (cl) :1 ; + rets = first_chunk ?mei_cl_tx_flow_ctrl_creds (cl) :1 ;if (rets <0 )return rets;
@@ -1559,7 +1558,7 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb, cb->completed = mei_hdr.msg_complete ==1 ;if (first_chunk) { -if (mei_cl_flow_ctrl_reduce (cl)) +if (mei_cl_tx_flow_ctrl_creds_reduce (cl))return -EIO ; }
@@ -1617,7 +1616,7 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking) mei_hdr.msg_complete =0 ; mei_hdr.internal = cb->internal; - rets =mei_cl_flow_ctrl_creds (cl); + rets =mei_cl_tx_flow_ctrl_creds (cl);if (rets <0 ) goto err;
@@ -1645,7 +1644,7 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking)if (rets) goto err; - rets =mei_cl_flow_ctrl_reduce (cl); + rets =mei_cl_tx_flow_ctrl_creds_reduce (cl);if (rets) goto err;
drivers/misc/mei/hbm.c +20 -21
98 lines not on this page · raw message
drivers/misc/mei/mei_dev.h +4 -4
@@ -144,7 +144,7 @@ struct mei_fw_status {* @refcnt: struct reference count * @props: client properties * @client_id: me client id -* @mei_flow_ctrl_creds: flow control credits +* @tx_flow_ctrl_creds: flow control credits * @connect_count: number connections to this client * @bus_added: added to bus */
@@ -153,7 +153,7 @@ struct mei_me_client {struct kref refcnt;struct mei_client_properties props;u8 client_id; -u8 mei_flow_ctrl_creds; +u8 tx_flow_ctrl_creds;u8 connect_count;u8 bus_added; };
@@ -202,7 +202,7 @@ struct mei_cl_cb {* @me_cl: fw client connected * @fp: file associated with client * @host_client_id: host id -* @mei_flow_ctrl_creds: transmit flow credentials +* @tx_flow_ctrl_creds: transmit flow credentials * @rx_flow_ctrl_creds: receive flow credentials * @timer_count: watchdog timer for operation completion * @notify_en: notification - enabled/disabled
@@ -226,7 +226,7 @@ struct mei_cl {struct mei_me_client *me_cl;const struct file *fp;u8 host_client_id; -u8 mei_flow_ctrl_creds; +u8 tx_flow_ctrl_creds;u8 rx_flow_ctrl_creds;u8 timer_count;u8 notify_en;
Signature · 1 line
2.7.4
PATCH 7/12 mei: rx flow control counter
In reply to Tomas WinklerFrom: Alexander Usyskin <[email protected]>
Use RX flow control counter in the host client structure to track the number of simultaneous outstanding reads. This eliminates search in queues and makes ground for enabling for parallel read.
--- drivers/misc/mei/amthif.c | 1 + drivers/misc/mei/client.c | 40 +++++++++++++--------------------------- drivers/misc/mei/mei_dev.h | 4 ++-- 3 files changed, 16 insertions(+), 29 deletions(-)
drivers/misc/mei/amthif.c +1 -0
@@ -202,6 +202,7 @@ static int mei_amthif_read_start(struct mei_cl *cl, const struct file *file)return -ENOMEM ;list_add_tail (&cb->list, &dev->ctrl_wr_list.list); + cl->rx_flow_ctrl_creds++; dev->iamthif_state =MEI_IAMTHIF_READING ; cl->fp = cb->fp;
drivers/misc/mei/client.c +13 -27
@@ -735,6 +735,7 @@ void mei_cl_set_disconnected(struct mei_cl *cl)mei_io_list_flush (&dev->ctrl_wr_list, cl);mei_cl_wake_all (cl); cl->mei_flow_ctrl_creds =0 ; + cl->rx_flow_ctrl_creds =0 ; cl->timer_count =0 ;if (!cl->me_cl)
@@ -1409,25 +1410,6 @@ out: }/** -* mei_cl_is_read_fc_cb - check if read cb is waiting for flow control -* for given host client -* -* @cl: host client -* -* Return: true, if found at least one cb. -*/ -static bool mei_cl_is_read_fc_cb (struct mei_cl *cl) -{ -struct mei_device *dev = cl->dev; -struct mei_cl_cb *cb; - -list_for_each_entry (cb, &dev->ctrl_wr_list.list, list) -if (cb->fop_type ==MEI_FOP_READ && cb->cl == cl) -return true; -return false; -} - -/** * mei_cl_read_start - the start read client message function. * * @cl: host client
@@ -1450,10 +1432,6 @@ int mei_cl_read_start(struct mei_cl *cl, size_t length, const struct file *fp)if (!mei_cl_is_connected (cl))return -ENODEV ; -/* HW currently supports only one pending read */ -if (!list_empty (&cl->rd_pending) ||mei_cl_is_read_fc_cb (cl)) -return -EBUSY ; -if (!mei_me_cl_is_active (cl->me_cl)) {cl_err (dev, cl,"no such me client\n" );return -ENOTTY ;
@@ -1462,12 +1440,18 @@ int mei_cl_read_start(struct mei_cl *cl, size_t length, const struct file *fp)if (mei_cl_is_fixed_address (cl))return 0 ; +/* HW currently supports only one pending read */ +if (cl->rx_flow_ctrl_creds) +return -EBUSY ; +/* always allocate at least client max message */ length =max_t (size_t, length,mei_cl_mtu (cl)); cb =mei_cl_alloc_cb (cl, length,MEI_FOP_READ , fp);if (!cb)return -ENOMEM ; +list_add_tail (&cb->list, &dev->ctrl_wr_list.list); + rets =pm_runtime_get (dev->dev);if (rets <0 && rets != -EINPROGRESS ) {pm_runtime_put_noidle (dev->dev);
@@ -1475,16 +1459,15 @@ int mei_cl_read_start(struct mei_cl *cl, size_t length, const struct file *fp) goto nortpm; } + rets =0 ;if (mei_hbuf_acquire (dev)) { rets =mei_hbm_cl_flow_control_req (dev, cl);if (rets <0 ) goto out; -list_add_tail (&cb->list, &cl->rd_pending); - }else { - rets =0 ; -list_add_tail (&cb->list, &dev->ctrl_wr_list.list); +list_move_tail (&cb->list, &cl->rd_pending); } + cl->rx_flow_ctrl_creds++; out:cl_dbg (dev, cl,"rpm: autosuspend\n" );
@@ -1732,6 +1715,9 @@ void mei_cl_complete(struct mei_cl *cl, struct mei_cl_cb *cb)case MEI_FOP_READ :list_add_tail (&cb->list, &cl->rd_completed); +if (!mei_cl_is_fixed_address (cl) && + !WARN_ON (!cl->rx_flow_ctrl_creds)) + cl->rx_flow_ctrl_creds--;if (!mei_cl_bus_rx_event (cl))wake_up_interruptible (&cl->rx_wait);break ;
drivers/misc/mei/mei_dev.h +2 -2
@@ -203,8 +203,8 @@ struct mei_cl_cb {* @fp: file associated with client * @host_client_id: host id * @mei_flow_ctrl_creds: transmit flow credentials +* @rx_flow_ctrl_creds: receive flow credentials * @timer_count: watchdog timer for operation completion -* @reserved: reserved for alignment * @notify_en: notification - enabled/disabled * @notify_ev: pending notification event * @writing_state: state of the tx
@@ -227,8 +227,8 @@ struct mei_cl {const struct file *fp;u8 host_client_id;u8 mei_flow_ctrl_creds; +u8 rx_flow_ctrl_creds;u8 timer_count; -u8 reserved;u8 notify_en;u8 notify_ev;enum mei_file_transaction_states writing_state;
Signature · 1 line
2.7.4
PATCH 6/12 mei: prepare read cb for fixed address clients on the receive path only.
In reply to Tomas WinklerFrom: Alexander Usyskin <[email protected]>
The read callbacks for the fixed address clients, that don't have flow control are built now on the receive path. In order to have a single allocation place we remove the allocation from the read request.
--- drivers/misc/mei/client.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/misc/mei/client.c +3 -5
@@ -1459,17 +1459,15 @@ int mei_cl_read_start(struct mei_cl *cl, size_t length, const struct file *fp)return -ENOTTY ; } +if (mei_cl_is_fixed_address (cl)) +return 0 ; +/* always allocate at least client max message */ length =max_t (size_t, length,mei_cl_mtu (cl)); cb =mei_cl_alloc_cb (cl, length,MEI_FOP_READ , fp);if (!cb)return -ENOMEM ; -if (mei_cl_is_fixed_address (cl)) { -list_add_tail (&cb->list, &cl->rd_pending); -return 0 ; - } - rets =pm_runtime_get (dev->dev);if (rets <0 && rets != -EINPROGRESS ) {pm_runtime_put_noidle (dev->dev);
Signature · 1 line
2.7.4
Quoted 6 lines
This patch series contains mostly fixes and enhancements of the rx path:
1. Better handling of fixed address clients 2. Support for consecutive reads 3. Further amthif client diet
Hi Greg, looks like the first 4 patches I've resent by mistake from the previous patchset , not sure if to resend it or you'll manage. Second, we have two other series of patches sitting in your mailbox over a month, hope you can get time to review them and squeeze them to rc2.
Thanks
Tomas
Greg Kroah-Hartman
maintainerQuoted 9 lines · Tomas
Quoted 6 lines
This patch series contains mostly fixes and enhancements of the rx path:
1. Better handling of fixed address clients 2. Support for consecutive reads 3. Further amthif client dietHi Greg, looks like the first 4 patches I've resent by mistake from the previous patchset , not sure if to resend it or you'll manage. Second, we have two other series of patches sitting in your mailbox over a month, hope you can get time to review them and squeeze them to rc2.
Yes, I will work to catch up on my backlog by rc2, sorry for that, I've been on vacation and traveling.
greg k-h
Quoted 10 lines · Tomas
Quoted 3 lines
Quoted 3 lines
This patch series contains mostly fixes and enhancements of the rx path:
1. Better handling of fixed address clients 2. Support for consecutivereads 3.
Quoted 3 lines
Quoted 3 lines
Further amthif client diet
Quoted 8 lines
Quoted 1 line
Hi Greg, looks like the first 4 patches I've resent by mistake from the
previous patchset , not sure if to resend it or you'll manage.
Quoted 1 line
Second, we have two other series of patches sitting in your mailbox over a
month, hope you can get time to review them and squeeze them to rc2.
Quoted 1 line
Yes, I will work to catch up on my backlog by rc2, sorry for that, I've been on vacation and traveling.
Thanks, understood.
I will resend this particular series as we found two issues that need to be addressed. Tomas
Quoted 20 lines
Quoted 5 lines · Tomas
Quoted 2 lines
Quoted 2 lines
This patch series contains mostly fixes and enhancements of the rx
path:
Quoted 14 lines
Quoted 2 lines
Quoted 2 lines
1. Better handling of fixed address clients 2. Support for consecutive
reads 3.
Quoted 5 lines
Quoted 3 lines
Further amthif client diet
Hi Greg, looks like the first 4 patches I've resent by mistake from the
previous patchset , not sure if to resend it or you'll manage.
Quoted 2 lines
Second, we have two other series of patches sitting in your mailbox over a
month, hope you can get time to review them and squeeze them to rc2.
Quoted 1 line
Quoted 8 lines
Quoted 2 lines
Yes, I will work to catch up on my backlog by rc2, sorry for that, I've been on vacation and traveling.
Thanks, understood.
I will resend this particular series as we found two issues that need to be addressed.
Tomas
Hi Greg
Any chance you will review our patches?
It will perhaps be smoother for you if we move to pull request mode?
Thanks
Tomas
'Greg Kroah-Hartman'
maintainerQuoted 25 lines · Tomas
Quoted 25 lines
Quoted 5 lines · Tomas
Quoted 2 lines
Quoted 2 lines
This patch series contains mostly fixes and enhancements of the rx
path:
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
1. Better handling of fixed address clients 2. Support for consecutive
reads 3.
Quoted 5 lines
Quoted 3 lines
Further amthif client diet
Hi Greg, looks like the first 4 patches I've resent by mistake from the
Quoted 8 lines
previous patchset , not sure if to resend it or you'll manage.
Quoted 2 lines
Second, we have two other series of patches sitting in your mailbox over a
month, hope you can get time to review them and squeeze them to rc2.
Quoted 1 line
Yes, I will work to catch up on my backlog by rc2, sorry for that, I've been on vacation and traveling.
Thanks, understood.
Quoted 7 lines
Quoted 3 lines
I will resend this particular series as we found two issues that need to be addressed.
TomasHi Greg
Any chance you will review our patches?
It will perhaps be smoother for you if we move to pull request mode?
Yeah, they are in my queue, sorry about this, been distracted with other email threads :(
greg k-h