Commit 9abd8b31 authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman

mei: amthif: replace amthif_rd_complete_list with rd_completed

Now when we have per client rd_completed list we can remove
the amthif specific amthif_rd_complete_list.
In addition in the function mei_amthif_read do not loop over the
rd_completed list like the original code as the code path is unlocked.
Reviewed-by: default avatarAlexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5cf8b2a9
...@@ -84,26 +84,6 @@ int mei_amthif_host_init(struct mei_device *dev, struct mei_me_client *me_cl) ...@@ -84,26 +84,6 @@ int mei_amthif_host_init(struct mei_device *dev, struct mei_me_client *me_cl)
return ret; return ret;
} }
/**
* mei_amthif_find_read_list_entry - finds a amthilist entry for current file
*
* @dev: the device structure
* @file: pointer to file object
*
* Return: returned a list entry on success, NULL on failure.
*/
struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev,
const struct file *file)
{
struct mei_cl_cb *cb;
list_for_each_entry(cb, &dev->amthif_rd_complete_list.list, list)
if (cb->fp == file)
return cb;
return NULL;
}
/** /**
* mei_amthif_read - read data from AMTHIF client * mei_amthif_read - read data from AMTHIF client
* *
...@@ -123,12 +103,13 @@ struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev, ...@@ -123,12 +103,13 @@ struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev,
int mei_amthif_read(struct mei_device *dev, struct file *file, int mei_amthif_read(struct mei_device *dev, struct file *file,
char __user *ubuf, size_t length, loff_t *offset) char __user *ubuf, size_t length, loff_t *offset)
{ {
struct mei_cl *cl = file->private_data;
struct mei_cl_cb *cb; struct mei_cl_cb *cb;
int rets; int rets;
int wait_ret; int wait_ret;
dev_dbg(dev->dev, "checking amthif data\n"); dev_dbg(dev->dev, "checking amthif data\n");
cb = mei_amthif_find_read_list_entry(dev, file); cb = mei_cl_read_cb(cl, file);
/* Check for if we can block or not*/ /* Check for if we can block or not*/
if (cb == NULL && file->f_flags & O_NONBLOCK) if (cb == NULL && file->f_flags & O_NONBLOCK)
...@@ -141,7 +122,7 @@ int mei_amthif_read(struct mei_device *dev, struct file *file, ...@@ -141,7 +122,7 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,
mutex_unlock(&dev->device_lock); mutex_unlock(&dev->device_lock);
wait_ret = wait_event_interruptible(dev->iamthif_cl.wait, wait_ret = wait_event_interruptible(dev->iamthif_cl.wait,
(cb = mei_amthif_find_read_list_entry(dev, file))); !list_empty(&cl->rd_completed));
/* Locking again the Mutex */ /* Locking again the Mutex */
mutex_lock(&dev->device_lock); mutex_lock(&dev->device_lock);
...@@ -149,7 +130,7 @@ int mei_amthif_read(struct mei_device *dev, struct file *file, ...@@ -149,7 +130,7 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,
if (wait_ret) if (wait_ret)
return -ERESTARTSYS; return -ERESTARTSYS;
dev_dbg(dev->dev, "woke up from sleep\n"); cb = mei_cl_read_cb(cl, file);
} }
if (cb->status) { if (cb->status) {
...@@ -420,11 +401,12 @@ int mei_amthif_irq_read_msg(struct mei_cl *cl, ...@@ -420,11 +401,12 @@ int mei_amthif_irq_read_msg(struct mei_cl *cl,
/** /**
* mei_amthif_complete - complete amthif callback. * mei_amthif_complete - complete amthif callback.
* *
* @dev: the device structure. * @cl: host client
* @cb: callback block. * @cb: callback block.
*/ */
void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb) void mei_amthif_complete(struct mei_cl *cl, struct mei_cl_cb *cb)
{ {
struct mei_device *dev = cl->dev;
if (cb->fop_type == MEI_FOP_WRITE) { if (cb->fop_type == MEI_FOP_WRITE) {
if (!cb->status) { if (!cb->status) {
...@@ -436,7 +418,7 @@ void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb) ...@@ -436,7 +418,7 @@ void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb)
* in case of error enqueue the write cb to complete read list * in case of error enqueue the write cb to complete read list
* so it can be propagated to the reader * so it can be propagated to the reader
*/ */
list_add_tail(&cb->list, &dev->amthif_rd_complete_list.list); list_add_tail(&cb->list, &cl->rd_completed);
wake_up_interruptible(&dev->iamthif_cl.wait); wake_up_interruptible(&dev->iamthif_cl.wait);
return; return;
} }
...@@ -444,7 +426,7 @@ void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb) ...@@ -444,7 +426,7 @@ void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb)
if (!dev->iamthif_canceled) { if (!dev->iamthif_canceled) {
dev->iamthif_state = MEI_IAMTHIF_READ_COMPLETE; dev->iamthif_state = MEI_IAMTHIF_READ_COMPLETE;
dev->iamthif_stall_timer = 0; dev->iamthif_stall_timer = 0;
list_add_tail(&cb->list, &dev->amthif_rd_complete_list.list); list_add_tail(&cb->list, &cl->rd_completed);
dev_dbg(dev->dev, "amthif read completed\n"); dev_dbg(dev->dev, "amthif read completed\n");
} else { } else {
mei_amthif_run_next_cmd(dev); mei_amthif_run_next_cmd(dev);
...@@ -506,10 +488,11 @@ static bool mei_clear_list(struct mei_device *dev, ...@@ -506,10 +488,11 @@ static bool mei_clear_list(struct mei_device *dev,
static bool mei_clear_lists(struct mei_device *dev, const struct file *file) static bool mei_clear_lists(struct mei_device *dev, const struct file *file)
{ {
bool removed = false; bool removed = false;
struct mei_cl *cl = &dev->iamthif_cl;
/* remove callbacks associated with a file */ /* remove callbacks associated with a file */
mei_clear_list(dev, file, &dev->amthif_cmd_list.list); mei_clear_list(dev, file, &dev->amthif_cmd_list.list);
if (mei_clear_list(dev, file, &dev->amthif_rd_complete_list.list)) if (mei_clear_list(dev, file, &cl->rd_completed))
removed = true; removed = true;
mei_clear_list(dev, file, &dev->ctrl_rd_list.list); mei_clear_list(dev, file, &dev->ctrl_rd_list.list);
......
...@@ -536,7 +536,6 @@ int mei_cl_flush_queues(struct mei_cl *cl, const struct file *fp) ...@@ -536,7 +536,6 @@ int mei_cl_flush_queues(struct mei_cl *cl, const struct file *fp)
mei_io_list_flush(&cl->dev->ctrl_wr_list, cl); mei_io_list_flush(&cl->dev->ctrl_wr_list, cl);
mei_io_list_flush(&cl->dev->ctrl_rd_list, cl); mei_io_list_flush(&cl->dev->ctrl_rd_list, cl);
mei_io_list_flush(&cl->dev->amthif_cmd_list, cl); mei_io_list_flush(&cl->dev->amthif_cmd_list, cl);
mei_io_list_flush(&cl->dev->amthif_rd_complete_list, cl);
mei_cl_read_cb_flush(cl, fp); mei_cl_read_cb_flush(cl, fp);
......
...@@ -402,7 +402,6 @@ void mei_device_init(struct mei_device *dev, ...@@ -402,7 +402,6 @@ void mei_device_init(struct mei_device *dev,
INIT_LIST_HEAD(&dev->iamthif_cl.link); INIT_LIST_HEAD(&dev->iamthif_cl.link);
mei_io_list_init(&dev->amthif_cmd_list); mei_io_list_init(&dev->amthif_cmd_list);
mei_io_list_init(&dev->amthif_rd_complete_list);
bitmap_zero(dev->host_clients_map, MEI_CLIENTS_MAX); bitmap_zero(dev->host_clients_map, MEI_CLIENTS_MAX);
dev->open_handle_count = 0; dev->open_handle_count = 0;
......
...@@ -48,7 +48,7 @@ void mei_irq_compl_handler(struct mei_device *dev, struct mei_cl_cb *compl_list) ...@@ -48,7 +48,7 @@ void mei_irq_compl_handler(struct mei_device *dev, struct mei_cl_cb *compl_list)
dev_dbg(dev->dev, "completing call back.\n"); dev_dbg(dev->dev, "completing call back.\n");
if (cl == &dev->iamthif_cl) if (cl == &dev->iamthif_cl)
mei_amthif_complete(dev, cb); mei_amthif_complete(cl, cb);
else else
mei_cl_complete(cl, cb); mei_cl_complete(cl, cb);
} }
......
...@@ -406,7 +406,6 @@ const char *mei_pg_state_str(enum mei_pg_state state); ...@@ -406,7 +406,6 @@ const char *mei_pg_state_str(enum mei_pg_state state);
* @allow_fixed_address: allow user space to connect a fixed client * @allow_fixed_address: allow user space to connect a fixed client
* *
* @amthif_cmd_list : amthif list for cmd waiting * @amthif_cmd_list : amthif list for cmd waiting
* @amthif_rd_complete_list : amthif list for reading completed cmd data
* @iamthif_fp : file for current amthif operation * @iamthif_fp : file for current amthif operation
* @iamthif_cl : amthif host client * @iamthif_cl : amthif host client
* @iamthif_current_cb : amthif current operation callback * @iamthif_current_cb : amthif current operation callback
...@@ -496,7 +495,6 @@ struct mei_device { ...@@ -496,7 +495,6 @@ struct mei_device {
/* amthif list for cmd waiting */ /* amthif list for cmd waiting */
struct mei_cl_cb amthif_cmd_list; struct mei_cl_cb amthif_cmd_list;
/* driver managed amthif list for reading completed amthif cmd data */ /* driver managed amthif list for reading completed amthif cmd data */
struct mei_cl_cb amthif_rd_complete_list;
const struct file *iamthif_fp; const struct file *iamthif_fp;
struct mei_cl iamthif_cl; struct mei_cl iamthif_cl;
struct mei_cl_cb *iamthif_current_cb; struct mei_cl_cb *iamthif_current_cb;
...@@ -589,15 +587,12 @@ unsigned int mei_amthif_poll(struct mei_device *dev, ...@@ -589,15 +587,12 @@ unsigned int mei_amthif_poll(struct mei_device *dev,
int mei_amthif_release(struct mei_device *dev, struct file *file); int mei_amthif_release(struct mei_device *dev, struct file *file);
struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev,
const struct file *file);
int mei_amthif_write(struct mei_cl *cl, struct mei_cl_cb *cb); int mei_amthif_write(struct mei_cl *cl, struct mei_cl_cb *cb);
int mei_amthif_run_next_cmd(struct mei_device *dev); int mei_amthif_run_next_cmd(struct mei_device *dev);
int mei_amthif_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb, int mei_amthif_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
struct mei_cl_cb *cmpl_list); struct mei_cl_cb *cmpl_list);
void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb); void mei_amthif_complete(struct mei_cl *cl, struct mei_cl_cb *cb);
int mei_amthif_irq_read_msg(struct mei_cl *cl, int mei_amthif_irq_read_msg(struct mei_cl *cl,
struct mei_msg_hdr *mei_hdr, struct mei_msg_hdr *mei_hdr,
struct mei_cl_cb *complete_list); struct mei_cl_cb *complete_list);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment