From: Tomas Winkler <tomas.winkler@intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alexander Usyskin <alexander.usyskin@intel.com>,
linux-kernel@vger.kernel.org,
Tomas Winkler <tomas.winkler@intel.com>
Subject: [char-misc-next 10/27] mei: amthif: replace amthif_rd_complete_list with rd_completed
Date: Sun, 7 Feb 2016 23:35:26 +0200 [thread overview]
Message-ID: <1454880943-12653-11-git-send-email-tomas.winkler@intel.com> (raw)
In-Reply-To: <1454880943-12653-1-git-send-email-tomas.winkler@intel.com>
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: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/misc/mei/amthif.c | 39 +++++++++++----------------------------
drivers/misc/mei/client.c | 1 -
drivers/misc/mei/init.c | 1 -
drivers/misc/mei/interrupt.c | 2 +-
drivers/misc/mei/mei_dev.h | 7 +------
5 files changed, 13 insertions(+), 37 deletions(-)
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index 4383a9ad9208..058dd6917805 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -85,26 +85,6 @@ int mei_amthif_host_init(struct mei_device *dev, struct mei_me_client *me_cl)
}
/**
- * 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
*
* @dev: the device structure
@@ -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,
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_amthif_find_read_list_entry(dev, file);
+ cb = mei_cl_read_cb(cl, file);
/* Check for if we can block or not*/
if (cb == NULL && file->f_flags & O_NONBLOCK)
@@ -141,7 +122,7 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,
mutex_unlock(&dev->device_lock);
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 */
mutex_lock(&dev->device_lock);
@@ -149,7 +130,7 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,
if (wait_ret)
return -ERESTARTSYS;
- dev_dbg(dev->dev, "woke up from sleep\n");
+ cb = mei_cl_read_cb(cl, file);
}
if (cb->status) {
@@ -420,11 +401,12 @@ int mei_amthif_irq_read_msg(struct mei_cl *cl,
/**
* mei_amthif_complete - complete amthif callback.
*
- * @dev: the device structure.
+ * @cl: host client
* @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->status) {
@@ -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
* 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);
return;
}
@@ -444,7 +426,7 @@ void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb)
if (!dev->iamthif_canceled) {
dev->iamthif_state = MEI_IAMTHIF_READ_COMPLETE;
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");
} else {
mei_amthif_run_next_cmd(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)
{
bool removed = false;
+ struct mei_cl *cl = &dev->iamthif_cl;
/* remove callbacks associated with a file */
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;
mei_clear_list(dev, file, &dev->ctrl_rd_list.list);
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index c57ac25ce8db..32991684563b 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -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_rd_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);
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
index 46a4302e5524..a1d978a82806 100644
--- a/drivers/misc/mei/init.c
+++ b/drivers/misc/mei/init.c
@@ -402,7 +402,6 @@ void mei_device_init(struct mei_device *dev,
INIT_LIST_HEAD(&dev->iamthif_cl.link);
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);
dev->open_handle_count = 0;
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 37c8f0e14387..72806ef6efdd 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -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");
if (cl == &dev->iamthif_cl)
- mei_amthif_complete(dev, cb);
+ mei_amthif_complete(cl, cb);
else
mei_cl_complete(cl, cb);
}
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 3acbbb49d08c..81901967911d 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -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
*
* @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_cl : amthif host client
* @iamthif_current_cb : amthif current operation callback
@@ -496,7 +495,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 */
- struct mei_cl_cb amthif_rd_complete_list;
const struct file *iamthif_fp;
struct mei_cl iamthif_cl;
struct mei_cl_cb *iamthif_current_cb;
@@ -589,15 +587,12 @@ unsigned int mei_amthif_poll(struct mei_device *dev,
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_run_next_cmd(struct mei_device *dev);
int mei_amthif_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
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,
struct mei_msg_hdr *mei_hdr,
struct mei_cl_cb *complete_list);
--
2.4.3
next prev parent reply other threads:[~2016-02-07 21:37 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-07 21:35 [char-misc-next 00/27] mei: fixes, improvements, and cleanups Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 01/27] mei: debugfs: adjust active clients print buffer Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 02/27] mei: debugfs: allow hbm features list dump in earlier stages Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 03/27] mei: fix possible integer overflow issue Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 04/27] mei: call stop on failed char device register Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 05/27] mei: amthif: don't copy from an empty buffer Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 06/27] mei: amthif: don't drop read packets on timeout Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 07/27] mei: constify struct file pointer Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 08/27] mei: rename variable names 'file_object' to fp Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 09/27] mei: amthif: allow only one request at a time Tomas Winkler
2016-02-07 21:35 ` Tomas Winkler [this message]
2016-02-07 21:35 ` [char-misc-next 11/27] mei: amthif: drop parameter validation from mei_amthif_write Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 12/27] mei: amthif: use rx_wait queue also for amthif client Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 13/27] mei: amthif: interrupt reader on link reset Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 14/27] mei: bus: fix RX event scheduling Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 15/27] mei: bus: fix notification event delivery Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 16/27] mei: bus: check if the device is enabled before data transfer Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 17/27] mei: drop superfluous closing bracket from write traces Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 18/27] mei: wake blocked write on link reset Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 19/27] mei: clean write queues and wake waiters on disconnect Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 20/27] mei: discard replies from unconnected fixed address clients Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 21/27] mei: fill file pointer in read cb for fixed address client Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 22/27] mei: fixed address clients for the new platforms Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 23/27] mei: hbm: warn about fw-initiated disconnect Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 24/27] mei: drop reserved host client ids Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 25/27] mei: bus: run rescan on me_clients list change Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 26/27] mei: hbm: send immediate reply flag in enum request Tomas Winkler
2016-02-07 21:35 ` [char-misc-next 27/27] mei: split amthif client init from end of clients enumeration Tomas Winkler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1454880943-12653-11-git-send-email-tomas.winkler@intel.com \
--to=tomas.winkler@intel.com \
--cc=alexander.usyskin@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).