* [char-misc-next 0/7] mei: amthif fixes and cleanups
@ 2016-05-24 20:03 Tomas Winkler
2016-05-24 20:03 ` [char-misc-next 1/7] mei: amthif: drop READ_COMPLETE state Tomas Winkler
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Tomas Winkler @ 2016-05-24 20:03 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Alexander Usyskin, linux-kernel, Tomas Winkler
Amthif client has special treatment in the driver,
this series provides more reuse of the mei generic consturcts
and reducing amount of the special code.
Alexander Usyskin (7):
mei: amthif: drop READ_COMPLETE state
mei: amthif: fix request cancel
mei: amthif: drop iamthif_current_cb
mei: amthif: enable poll for async events
mei: amthif: drop mei_amthif_send_cmd
mei: amthif: use mei_cl_alloc_cb for allocating cbs
mei: drop mei_io_cb_alloc_buf
drivers/misc/mei/amthif.c | 200 +++++++++++++------------------------------
drivers/misc/mei/client.c | 32 ++-----
drivers/misc/mei/client.h | 2 -
drivers/misc/mei/interrupt.c | 5 --
drivers/misc/mei/main.c | 10 +--
drivers/misc/mei/mei_dev.h | 7 +-
6 files changed, 71 insertions(+), 185 deletions(-)
--
2.5.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [char-misc-next 1/7] mei: amthif: drop READ_COMPLETE state
2016-05-24 20:03 [char-misc-next 0/7] mei: amthif fixes and cleanups Tomas Winkler
@ 2016-05-24 20:03 ` Tomas Winkler
2016-05-24 20:03 ` [char-misc-next 2/7] mei: amthif: fix request cancel Tomas Winkler
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Tomas Winkler @ 2016-05-24 20:03 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Alexander Usyskin, linux-kernel, Tomas Winkler
From: Alexander Usyskin <alexander.usyskin@intel.com>
AMTHIF code now uses read completed queue to store replies from the FW.
It is possible to send the next request as soon as a read from the FW is
completed. With these changes we don't need the READ_COMPLETE state.
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/misc/mei/amthif.c | 34 +++++++++++-----------------------
drivers/misc/mei/main.c | 2 +-
drivers/misc/mei/mei_dev.h | 5 +----
3 files changed, 13 insertions(+), 28 deletions(-)
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index a039a5df6f21..13d89043ad76 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -299,8 +299,7 @@ int mei_amthif_write(struct mei_cl *cl, struct mei_cl_cb *cb)
/*
* The previous request is still in processing, queue this one.
*/
- if (dev->iamthif_state > MEI_IAMTHIF_IDLE &&
- dev->iamthif_state < MEI_IAMTHIF_READ_COMPLETE)
+ if (dev->iamthif_state != MEI_IAMTHIF_IDLE)
return 0;
return mei_amthif_run_next_cmd(dev);
@@ -309,7 +308,6 @@ int mei_amthif_write(struct mei_cl *cl, struct mei_cl_cb *cb)
/**
* mei_amthif_poll - the amthif poll function
*
- * @dev: the device structure
* @file: pointer to file structure
* @wait: pointer to poll_table structure
*
@@ -317,26 +315,19 @@ int mei_amthif_write(struct mei_cl *cl, struct mei_cl_cb *cb)
*
* Locking: called under "dev->device_lock" lock
*/
-
-unsigned int mei_amthif_poll(struct mei_device *dev,
- struct file *file, poll_table *wait)
+unsigned int mei_amthif_poll(struct file *file, poll_table *wait)
{
+ struct mei_cl *cl = file->private_data;
+ struct mei_cl_cb *cb = mei_cl_read_cb(cl, file);
unsigned int mask = 0;
- poll_wait(file, &dev->iamthif_cl.rx_wait, wait);
-
- if (dev->iamthif_state == MEI_IAMTHIF_READ_COMPLETE &&
- dev->iamthif_fp == file) {
-
+ poll_wait(file, &cl->rx_wait, wait);
+ if (cb)
mask |= POLLIN | POLLRDNORM;
- mei_amthif_run_next_cmd(dev);
- }
return mask;
}
-
-
/**
* mei_amthif_irq_write - write iamthif command in irq thread context.
*
@@ -393,7 +384,6 @@ int mei_amthif_irq_read_msg(struct mei_cl *cl,
return 0;
dev_dbg(dev->dev, "completed amthif read.\n ");
- dev->iamthif_current_cb = NULL;
dev->iamthif_stall_timer = 0;
return 0;
@@ -425,14 +415,16 @@ void mei_amthif_complete(struct mei_cl *cl, 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, &cl->rd_completed);
dev_dbg(dev->dev, "amthif read completed\n");
} else {
- mei_amthif_run_next_cmd(dev);
+ mei_io_cb_free(cb);
}
+ dev->iamthif_current_cb = NULL;
+ dev->iamthif_stall_timer = 0;
+ mei_amthif_run_next_cmd(dev);
+
dev_dbg(dev->dev, "completing amthif call back.\n");
wake_up_interruptible(&cl->rx_wait);
}
@@ -539,10 +531,6 @@ int mei_amthif_release(struct mei_device *dev, struct file *file)
dev_dbg(dev->dev, "amthif canceled iamthif state %d\n",
dev->iamthif_state);
dev->iamthif_canceled = true;
- if (dev->iamthif_state == MEI_IAMTHIF_READ_COMPLETE) {
- dev_dbg(dev->dev, "run next amthif iamthif cb\n");
- mei_amthif_run_next_cmd(dev);
- }
}
if (mei_clear_lists(dev, file))
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 52635b063873..622ff19864df 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -610,7 +610,7 @@ static unsigned int mei_poll(struct file *file, poll_table *wait)
}
if (cl == &dev->iamthif_cl) {
- mask = mei_amthif_poll(dev, file, wait);
+ mask = mei_amthif_poll(file, wait);
goto out;
}
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index e5e32503d4bc..fa6007707048 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -80,9 +80,7 @@ const char *mei_dev_state_str(int state);
enum iamthif_states {
MEI_IAMTHIF_IDLE,
MEI_IAMTHIF_WRITING,
- MEI_IAMTHIF_FLOW_CONTROL,
MEI_IAMTHIF_READING,
- MEI_IAMTHIF_READ_COMPLETE
};
enum mei_file_transaction_states {
@@ -572,8 +570,7 @@ 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 mei_device *dev,
- struct file *file, poll_table *wait);
+unsigned int mei_amthif_poll(struct file *file, poll_table *wait);
int mei_amthif_release(struct mei_device *dev, struct file *file);
--
2.5.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [char-misc-next 2/7] mei: amthif: fix request cancel
2016-05-24 20:03 [char-misc-next 0/7] mei: amthif fixes and cleanups Tomas Winkler
2016-05-24 20:03 ` [char-misc-next 1/7] mei: amthif: drop READ_COMPLETE state Tomas Winkler
@ 2016-05-24 20:03 ` Tomas Winkler
2016-05-24 20:03 ` [char-misc-next 3/7] mei: amthif: drop iamthif_current_cb Tomas Winkler
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Tomas Winkler @ 2016-05-24 20:03 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Alexander Usyskin, linux-kernel, Tomas Winkler
From: Alexander Usyskin <alexander.usyskin@intel.com>
Currently, all requests cancelled by the user are immediately removed
from the queues. Such removal can cause unexpected behavior in the case
when a request is partially written or a reply is received after the
request is cancelled. To resolve this a request is always fully
processed and the result is discarded in case the request was canceled.
This completes the partial fix in commit:
9d04ee1 ("mei: amthif: discard not read messages")
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/misc/mei/amthif.c | 111 +++++++++++++++----------------------------
drivers/misc/mei/interrupt.c | 2 -
2 files changed, 38 insertions(+), 75 deletions(-)
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index 13d89043ad76..0cded8aa72c0 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -399,34 +399,44 @@ 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) {
+ dev_dbg(dev->dev, "completing amthif call back.\n");
+ switch (cb->fop_type) {
+ case MEI_FOP_WRITE:
if (!cb->status) {
dev->iamthif_stall_timer = MEI_IAMTHIF_STALL_TIMER;
mei_io_cb_free(cb);
return;
}
- /*
- * 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, &cl->rd_completed);
- wake_up_interruptible(&cl->rx_wait);
- return;
- }
+ dev->iamthif_current_cb = NULL;
+ dev->iamthif_state = MEI_IAMTHIF_IDLE;
+ dev->iamthif_fp = NULL;
+ if (!dev->iamthif_canceled) {
+ /*
+ * 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, &cl->rd_completed);
+ wake_up_interruptible(&cl->rx_wait);
+ } else {
+ mei_io_cb_free(cb);
+ }
+ break;
+ case MEI_FOP_READ:
+ if (!dev->iamthif_canceled) {
+ list_add_tail(&cb->list, &cl->rd_completed);
+ dev_dbg(dev->dev, "amthif read completed\n");
+ wake_up_interruptible(&cl->rx_wait);
+ } else {
+ mei_io_cb_free(cb);
+ }
- if (!dev->iamthif_canceled) {
- list_add_tail(&cb->list, &cl->rd_completed);
- dev_dbg(dev->dev, "amthif read completed\n");
- } else {
- mei_io_cb_free(cb);
+ dev->iamthif_current_cb = NULL;
+ dev->iamthif_stall_timer = 0;
+ mei_amthif_run_next_cmd(dev);
+ break;
+ default:
+ WARN_ON(1);
}
-
- dev->iamthif_current_cb = NULL;
- dev->iamthif_stall_timer = 0;
- mei_amthif_run_next_cmd(dev);
-
- dev_dbg(dev->dev, "completing amthif call back.\n");
- wake_up_interruptible(&cl->rx_wait);
}
/**
@@ -439,32 +449,15 @@ void mei_amthif_complete(struct mei_cl *cl, struct mei_cl_cb *cb)
*
* mei_clear_list is called to clear resources associated with file
* when application calls close function or Ctrl-C was pressed
- *
- * Return: true if callback removed from the list, false otherwise
*/
-static bool mei_clear_list(struct mei_device *dev,
+static void mei_clear_list(struct mei_device *dev,
const struct file *file, struct list_head *mei_cb_list)
{
- struct mei_cl *cl = &dev->iamthif_cl;
struct mei_cl_cb *cb, *next;
- bool removed = false;
-
- /* list all list member */
- list_for_each_entry_safe(cb, next, mei_cb_list, list) {
- /* check if list member associated with a file */
- if (file == cb->fp) {
- /* check if cb equal to current iamthif cb */
- if (dev->iamthif_current_cb == cb) {
- dev->iamthif_current_cb = NULL;
- /* send flow control to iamthif client */
- mei_hbm_cl_flow_control_req(dev, cl);
- }
- /* free all allocated buffers */
+
+ list_for_each_entry_safe(cb, next, mei_cb_list, list)
+ if (file == cb->fp)
mei_io_cb_free(cb);
- removed = true;
- }
- }
- return removed;
}
/**
@@ -475,41 +468,14 @@ static bool mei_clear_list(struct mei_device *dev,
*
* mei_clear_lists is called to clear resources associated with file
* when application calls close function or Ctrl-C was pressed
- *
- * Return: true if callback removed from the list, false otherwise
*/
-static bool mei_clear_lists(struct mei_device *dev, const struct file *file)
+static void 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, &cl->rd_completed))
- removed = true;
-
+ mei_clear_list(dev, file, &cl->rd_completed);
mei_clear_list(dev, file, &dev->ctrl_rd_list.list);
-
- if (mei_clear_list(dev, file, &dev->ctrl_wr_list.list))
- removed = true;
-
- if (mei_clear_list(dev, file, &dev->write_waiting_list.list))
- removed = true;
-
- if (mei_clear_list(dev, file, &dev->write_list.list))
- removed = true;
-
- /* check if iamthif_current_cb not NULL */
- if (dev->iamthif_current_cb && !removed) {
- /* check file and iamthif current cb association */
- if (dev->iamthif_current_cb->fp == file) {
- /* remove cb */
- mei_io_cb_free(dev->iamthif_current_cb);
- dev->iamthif_current_cb = NULL;
- removed = true;
- }
- }
- return removed;
}
/**
@@ -533,8 +499,7 @@ int mei_amthif_release(struct mei_device *dev, struct file *file)
dev->iamthif_canceled = true;
}
- if (mei_clear_lists(dev, file))
- dev->iamthif_state = MEI_IAMTHIF_IDLE;
+ mei_clear_lists(dev, file);
return 0;
}
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 3831a7ba2531..38db1c3d4f14 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -514,8 +514,6 @@ void mei_timer(struct work_struct *work)
if (--dev->iamthif_stall_timer == 0) {
dev_err(dev->dev, "timer: amthif hanged.\n");
mei_reset(dev);
- dev->iamthif_canceled = false;
- dev->iamthif_state = MEI_IAMTHIF_IDLE;
mei_io_cb_free(dev->iamthif_current_cb);
dev->iamthif_current_cb = NULL;
--
2.5.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [char-misc-next 3/7] mei: amthif: drop iamthif_current_cb
2016-05-24 20:03 [char-misc-next 0/7] mei: amthif fixes and cleanups Tomas Winkler
2016-05-24 20:03 ` [char-misc-next 1/7] mei: amthif: drop READ_COMPLETE state Tomas Winkler
2016-05-24 20:03 ` [char-misc-next 2/7] mei: amthif: fix request cancel Tomas Winkler
@ 2016-05-24 20:03 ` Tomas Winkler
2016-05-24 20:03 ` [char-misc-next 4/7] mei: amthif: enable poll for async events Tomas Winkler
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Tomas Winkler @ 2016-05-24 20:03 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Alexander Usyskin, linux-kernel, Tomas Winkler
From: Alexander Usyskin <alexander.usyskin@intel.com>
iamthif_current_cb was used in request cancel in amthif code.
Now a canceled request is discarded only at the end of the processing
and the variable lost its purpose and can be safely removed.
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/misc/mei/amthif.c | 5 -----
drivers/misc/mei/interrupt.c | 3 ---
drivers/misc/mei/mei_dev.h | 2 --
3 files changed, 10 deletions(-)
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index 0cded8aa72c0..b602fd3b914c 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -47,7 +47,6 @@ const uuid_le mei_amthif_guid = UUID_LE(0x12f80028, 0xb4b7, 0x4b2d,
void mei_amthif_reset_params(struct mei_device *dev)
{
/* reset iamthif parameters. */
- dev->iamthif_current_cb = NULL;
dev->iamthif_canceled = false;
dev->iamthif_state = MEI_IAMTHIF_IDLE;
dev->iamthif_stall_timer = 0;
@@ -213,7 +212,6 @@ static int mei_amthif_read_start(struct mei_cl *cl, const struct file *file)
dev->iamthif_state = MEI_IAMTHIF_READING;
dev->iamthif_fp = cb->fp;
- dev->iamthif_current_cb = cb;
return 0;
err:
@@ -240,7 +238,6 @@ static int mei_amthif_send_cmd(struct mei_cl *cl, struct mei_cl_cb *cb)
dev = cl->dev;
dev->iamthif_state = MEI_IAMTHIF_WRITING;
- dev->iamthif_current_cb = cb;
dev->iamthif_fp = cb->fp;
dev->iamthif_canceled = false;
@@ -407,7 +404,6 @@ void mei_amthif_complete(struct mei_cl *cl, struct mei_cl_cb *cb)
mei_io_cb_free(cb);
return;
}
- dev->iamthif_current_cb = NULL;
dev->iamthif_state = MEI_IAMTHIF_IDLE;
dev->iamthif_fp = NULL;
if (!dev->iamthif_canceled) {
@@ -430,7 +426,6 @@ void mei_amthif_complete(struct mei_cl *cl, struct mei_cl_cb *cb)
mei_io_cb_free(cb);
}
- dev->iamthif_current_cb = NULL;
dev->iamthif_stall_timer = 0;
mei_amthif_run_next_cmd(dev);
break;
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 38db1c3d4f14..436ecda3935e 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -515,9 +515,6 @@ void mei_timer(struct work_struct *work)
dev_err(dev->dev, "timer: amthif hanged.\n");
mei_reset(dev);
- mei_io_cb_free(dev->iamthif_current_cb);
- dev->iamthif_current_cb = NULL;
-
dev->iamthif_fp = NULL;
mei_amthif_run_next_cmd(dev);
}
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index fa6007707048..d7b68063ace1 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -400,7 +400,6 @@ const char *mei_pg_state_str(enum mei_pg_state state);
* @amthif_cmd_list : amthif list for cmd waiting
* @iamthif_fp : file for current amthif operation
* @iamthif_cl : amthif host client
- * @iamthif_current_cb : amthif current operation callback
* @iamthif_open_count : number of opened amthif connections
* @iamthif_stall_timer : timer to detect amthif hang
* @iamthif_state : amthif processor state
@@ -485,7 +484,6 @@ struct mei_device {
/* driver managed amthif list for reading completed amthif cmd data */
const struct file *iamthif_fp;
struct mei_cl iamthif_cl;
- struct mei_cl_cb *iamthif_current_cb;
long iamthif_open_count;
u32 iamthif_stall_timer;
enum iamthif_states iamthif_state;
--
2.5.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [char-misc-next 4/7] mei: amthif: enable poll for async events
2016-05-24 20:03 [char-misc-next 0/7] mei: amthif fixes and cleanups Tomas Winkler
` (2 preceding siblings ...)
2016-05-24 20:03 ` [char-misc-next 3/7] mei: amthif: drop iamthif_current_cb Tomas Winkler
@ 2016-05-24 20:03 ` Tomas Winkler
2016-05-24 20:03 ` [char-misc-next 5/7] mei: amthif: drop mei_amthif_send_cmd Tomas Winkler
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Tomas Winkler @ 2016-05-24 20:03 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Alexander Usyskin, linux-kernel, Tomas Winkler
From: Alexander Usyskin <alexander.usyskin@intel.com>
Currently the poll function is bailing early for amthif client and
ignores requests for async events notifications.
Move async event processing before amthif to enable async events
notifications on amthif client.
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/misc/mei/main.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 622ff19864df..a8d0471f817f 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -609,17 +609,17 @@ static unsigned int mei_poll(struct file *file, poll_table *wait)
goto out;
}
- if (cl == &dev->iamthif_cl) {
- mask = mei_amthif_poll(file, wait);
- goto out;
- }
-
if (notify_en) {
poll_wait(file, &cl->ev_wait, wait);
if (cl->notify_ev)
mask |= POLLPRI;
}
+ if (cl == &dev->iamthif_cl) {
+ mask |= mei_amthif_poll(file, wait);
+ goto out;
+ }
+
if (req_events & (POLLIN | POLLRDNORM)) {
poll_wait(file, &cl->rx_wait, wait);
--
2.5.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [char-misc-next 5/7] mei: amthif: drop mei_amthif_send_cmd
2016-05-24 20:03 [char-misc-next 0/7] mei: amthif fixes and cleanups Tomas Winkler
` (3 preceding siblings ...)
2016-05-24 20:03 ` [char-misc-next 4/7] mei: amthif: enable poll for async events Tomas Winkler
@ 2016-05-24 20:03 ` Tomas Winkler
2016-05-24 20:03 ` [char-misc-next 6/7] mei: amthif: use mei_cl_alloc_cb for allocating cbs Tomas Winkler
2016-05-24 20:03 ` [char-misc-next 7/7] mei: drop mei_io_cb_alloc_buf Tomas Winkler
6 siblings, 0 replies; 8+ messages in thread
From: Tomas Winkler @ 2016-05-24 20:03 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Alexander Usyskin, linux-kernel, Tomas Winkler
From: Alexander Usyskin <alexander.usyskin@intel.com>
Incorporate the mei_amthif_send_cmd code into its only caller:
mei_amthif_run_next_cmd
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/misc/mei/amthif.c | 52 +++++++++++++++--------------------------------
1 file changed, 16 insertions(+), 36 deletions(-)
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index b602fd3b914c..9885fa40a120 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -220,38 +220,6 @@ err:
}
/**
- * mei_amthif_send_cmd - send amthif command to the ME
- *
- * @cl: the host client
- * @cb: mei call back struct
- *
- * Return: 0 on success, <0 on failure.
- */
-static int mei_amthif_send_cmd(struct mei_cl *cl, struct mei_cl_cb *cb)
-{
- struct mei_device *dev;
- int ret;
-
- if (!cl->dev || !cb)
- return -ENODEV;
-
- dev = cl->dev;
-
- dev->iamthif_state = MEI_IAMTHIF_WRITING;
- dev->iamthif_fp = cb->fp;
- dev->iamthif_canceled = false;
-
- ret = mei_cl_write(cl, cb, false);
- if (ret < 0)
- return ret;
-
- if (cb->completed)
- cb->status = mei_amthif_read_start(cl, cb->fp);
-
- return 0;
-}
-
-/**
* mei_amthif_run_next_cmd - send next amt command from queue
*
* @dev: the device structure
@@ -262,20 +230,32 @@ int mei_amthif_run_next_cmd(struct mei_device *dev)
{
struct mei_cl *cl = &dev->iamthif_cl;
struct mei_cl_cb *cb;
+ int ret;
dev->iamthif_canceled = false;
- dev->iamthif_state = MEI_IAMTHIF_IDLE;
- dev->iamthif_fp = NULL;
dev_dbg(dev->dev, "complete amthif cmd_list cb.\n");
cb = list_first_entry_or_null(&dev->amthif_cmd_list.list,
typeof(*cb), list);
- if (!cb)
+ if (!cb) {
+ dev->iamthif_state = MEI_IAMTHIF_IDLE;
+ dev->iamthif_fp = NULL;
return 0;
+ }
list_del_init(&cb->list);
- return mei_amthif_send_cmd(cl, cb);
+ dev->iamthif_state = MEI_IAMTHIF_WRITING;
+ dev->iamthif_fp = cb->fp;
+
+ ret = mei_cl_write(cl, cb, false);
+ if (ret < 0)
+ return ret;
+
+ if (cb->completed)
+ cb->status = mei_amthif_read_start(cl, cb->fp);
+
+ return 0;
}
/**
--
2.5.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [char-misc-next 6/7] mei: amthif: use mei_cl_alloc_cb for allocating cbs
2016-05-24 20:03 [char-misc-next 0/7] mei: amthif fixes and cleanups Tomas Winkler
` (4 preceding siblings ...)
2016-05-24 20:03 ` [char-misc-next 5/7] mei: amthif: drop mei_amthif_send_cmd Tomas Winkler
@ 2016-05-24 20:03 ` Tomas Winkler
2016-05-24 20:03 ` [char-misc-next 7/7] mei: drop mei_io_cb_alloc_buf Tomas Winkler
6 siblings, 0 replies; 8+ messages in thread
From: Tomas Winkler @ 2016-05-24 20:03 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Alexander Usyskin, linux-kernel, Tomas Winkler
From: Alexander Usyskin <alexander.usyskin@intel.com>
Use mei_cl_alloc_cb wrapper instead of open code steps
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/misc/mei/amthif.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index 9885fa40a120..14b454143c81 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -196,17 +196,10 @@ static int mei_amthif_read_start(struct mei_cl *cl, const struct file *file)
{
struct mei_device *dev = cl->dev;
struct mei_cl_cb *cb;
- int rets;
-
- cb = mei_io_cb_init(cl, MEI_FOP_READ, file);
- if (!cb) {
- rets = -ENOMEM;
- goto err;
- }
- rets = mei_io_cb_alloc_buf(cb, mei_cl_mtu(cl));
- if (rets)
- goto err;
+ cb = mei_cl_alloc_cb(cl, mei_cl_mtu(cl), MEI_FOP_READ, file);
+ if (!cb)
+ return -ENOMEM;
list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
@@ -214,9 +207,6 @@ static int mei_amthif_read_start(struct mei_cl *cl, const struct file *file)
dev->iamthif_fp = cb->fp;
return 0;
-err:
- mei_io_cb_free(cb);
- return rets;
}
/**
--
2.5.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [char-misc-next 7/7] mei: drop mei_io_cb_alloc_buf
2016-05-24 20:03 [char-misc-next 0/7] mei: amthif fixes and cleanups Tomas Winkler
` (5 preceding siblings ...)
2016-05-24 20:03 ` [char-misc-next 6/7] mei: amthif: use mei_cl_alloc_cb for allocating cbs Tomas Winkler
@ 2016-05-24 20:03 ` Tomas Winkler
6 siblings, 0 replies; 8+ messages in thread
From: Tomas Winkler @ 2016-05-24 20:03 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Alexander Usyskin, linux-kernel, Tomas Winkler
From: Alexander Usyskin <alexander.usyskin@intel.com>
mei_io_cb_alloc_buf have a single caller :mei_cl_alloc_cb. After amthif
stopped using it, the code can be integrated into the caller and the
function can be dropped.
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/misc/mei/client.c | 32 ++++++--------------------------
drivers/misc/mei/client.h | 2 --
2 files changed, 6 insertions(+), 28 deletions(-)
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index 641c1a566687..6658917be64f 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -420,31 +420,6 @@ static inline void mei_io_list_free(struct mei_cl_cb *list, struct mei_cl *cl)
}
/**
- * mei_io_cb_alloc_buf - allocate callback buffer
- *
- * @cb: io callback structure
- * @length: size of the buffer
- *
- * Return: 0 on success
- * -EINVAL if cb is NULL
- * -ENOMEM if allocation failed
- */
-int mei_io_cb_alloc_buf(struct mei_cl_cb *cb, size_t length)
-{
- if (!cb)
- return -EINVAL;
-
- if (length == 0)
- return 0;
-
- cb->buf.data = kmalloc(length, GFP_KERNEL);
- if (!cb->buf.data)
- return -ENOMEM;
- cb->buf.size = length;
- return 0;
-}
-
-/**
* mei_cl_alloc_cb - a convenient wrapper for allocating read cb
*
* @cl: host client
@@ -464,10 +439,15 @@ struct mei_cl_cb *mei_cl_alloc_cb(struct mei_cl *cl, size_t length,
if (!cb)
return NULL;
- if (mei_io_cb_alloc_buf(cb, length)) {
+ if (length == 0)
+ return cb;
+
+ cb->buf.data = kmalloc(length, GFP_KERNEL);
+ if (!cb->buf.data) {
mei_io_cb_free(cb);
return NULL;
}
+ cb->buf.size = length;
return cb;
}
diff --git a/drivers/misc/mei/client.h b/drivers/misc/mei/client.h
index 0d7a3a1fef78..16466aa40cbd 100644
--- a/drivers/misc/mei/client.h
+++ b/drivers/misc/mei/client.h
@@ -85,8 +85,6 @@ static inline u8 mei_me_cl_ver(const struct mei_me_client *me_cl)
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);
-int mei_io_cb_alloc_buf(struct mei_cl_cb *cb, size_t length);
-
/**
* mei_io_list_init - Sets up a queue list.
--
2.5.5
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-05-24 13:08 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-24 20:03 [char-misc-next 0/7] mei: amthif fixes and cleanups Tomas Winkler
2016-05-24 20:03 ` [char-misc-next 1/7] mei: amthif: drop READ_COMPLETE state Tomas Winkler
2016-05-24 20:03 ` [char-misc-next 2/7] mei: amthif: fix request cancel Tomas Winkler
2016-05-24 20:03 ` [char-misc-next 3/7] mei: amthif: drop iamthif_current_cb Tomas Winkler
2016-05-24 20:03 ` [char-misc-next 4/7] mei: amthif: enable poll for async events Tomas Winkler
2016-05-24 20:03 ` [char-misc-next 5/7] mei: amthif: drop mei_amthif_send_cmd Tomas Winkler
2016-05-24 20:03 ` [char-misc-next 6/7] mei: amthif: use mei_cl_alloc_cb for allocating cbs Tomas Winkler
2016-05-24 20:03 ` [char-misc-next 7/7] mei: drop mei_io_cb_alloc_buf Tomas Winkler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®