Skip to contentSkip to conversation

mei: mei_write: revamp function flow

PATCH New Tomas Winkler 1 participant 6 messages Nov 1, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/6 mei: mei_write: revamp function flow

Use goto statement for error handling instead of deeper if constructs and rename label 'unlock_dev' to more appropriate 'err'

---
 drivers/misc/mei/main.c |   88 +++++++++++++++++++++++-----------------------
 1 files changed, 44 insertions(+), 44 deletions(-)
drivers/misc/mei/main.c +44 -44
index ed4943f..7a03d77 100644
@@ -543,24 +543,24 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
 
 	if (dev->dev_state != MEI_DEV_ENABLED) {
 		rets = -ENODEV;
-		goto unlock_dev;
+		goto err;
 	}
 
 	i = mei_me_cl_by_id(dev, cl->me_client_id);
 	if (i < 0) {
 		rets = -ENODEV;
-		goto unlock_dev;
+		goto err;
 	}
 	if (length > dev->me_clients[i].props.max_msg_length || length <= 0) {
 		rets = -EMSGSIZE;
-		goto unlock_dev;
+		goto err;
 	}
 
 	if (cl->state != MEI_FILE_CONNECTED) {
 		rets = -ENODEV;
 		dev_err(&dev->pdev->dev, "host client = %d,  is not connected to ME client = %d",
 			cl->host_client_id, cl->me_client_id);
-		goto unlock_dev;
+		goto err;
 	}
 	if (cl == &dev->iamthif_cl) {
 		write_cb = find_amthi_read_list_entry(dev, file);
@@ -599,17 +599,17 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
 	if (!write_cb) {
 		dev_err(&dev->pdev->dev, "write cb allocation failed\n");
 		rets = -ENOMEM;
-		goto unlock_dev;
+		goto err;
 	}
 	rets = mei_io_cb_alloc_req_buf(write_cb, length);
 	if (rets)
-		goto unlock_dev;
+		goto err;
 
 	dev_dbg(&dev->pdev->dev, "cb request size = %zd\n", length);
 
 	rets = copy_from_user(write_cb->request_buffer.data, ubuf, length);
 	if (rets)
-		goto unlock_dev;
+		goto err;
 
 	cl->sm_state = 0;
 	if (length == 4 &&
@@ -624,7 +624,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
 	if (cl == &dev->iamthif_cl) {
 		rets = mei_io_cb_alloc_resp_buf(write_cb, dev->iamthif_mtu);
 		if (rets)
-			goto unlock_dev;
+			goto err;
 
 		write_cb->major_file_operations = MEI_IOCTL;
 
@@ -641,7 +641,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
 			if (rets) {
 				dev_err(&dev->pdev->dev, "amthi write failed with status = %d\n",
 				    rets);
-				goto unlock_dev;
+				goto err;
 			}
 		}
 		mutex_unlock(&dev->device_lock);
@@ -654,51 +654,51 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
 	    cl->host_client_id, cl->me_client_id);
 	rets = mei_flow_ctrl_creds(dev, cl);
 	if (rets < 0)
-		goto unlock_dev;
+		goto err;
 
-	if (rets && dev->mei_host_buffer_is_empty) {
-		rets = 0;
-		dev->mei_host_buffer_is_empty = false;
-		if (length >  mei_hbuf_max_data(dev)) {
-			mei_hdr.length = mei_hbuf_max_data(dev);
-			mei_hdr.msg_complete = 0;
-		} else {
-			mei_hdr.length = length;
-			mei_hdr.msg_complete = 1;
-		}
-		mei_hdr.host_addr = cl->host_client_id;
-		mei_hdr.me_addr = cl->me_client_id;
-		mei_hdr.reserved = 0;
-		dev_dbg(&dev->pdev->dev, "call mei_write_message header=%08x.\n",
-		    *((u32 *) &mei_hdr));
-		if (mei_write_message(dev, &mei_hdr,
-			(unsigned char *) (write_cb->request_buffer.data),
-			mei_hdr.length)) {
-			rets = -ENODEV;
-			goto unlock_dev;
-		}
+	if (rets == 0 || dev->mei_host_buffer_is_empty == false) {
+		write_cb->buf_idx = 0;
+		mei_hdr.msg_complete = 0;
 		cl->writing_state = MEI_WRITING;
-		write_cb->buf_idx = mei_hdr.length;
-		if (mei_hdr.msg_complete) {
-			if (mei_flow_ctrl_reduce(dev, cl)) {
-				rets = -ENODEV;
-				goto unlock_dev;
-			}
-			list_add_tail(&write_cb->list, &dev->write_waiting_list.list);
-		} else {
-			list_add_tail(&write_cb->list, &dev->write_list.list);
-		}
+		goto out;
+	}
 
+	dev->mei_host_buffer_is_empty = false;
+	if (length >  mei_hbuf_max_data(dev)) {
+		mei_hdr.length = mei_hbuf_max_data(dev);
+		mei_hdr.msg_complete = 0;
 	} else {
+		mei_hdr.length = length;
+		mei_hdr.msg_complete = 1;
+	}
+	mei_hdr.host_addr = cl->host_client_id;
+	mei_hdr.me_addr = cl->me_client_id;
+	mei_hdr.reserved = 0;
+	dev_dbg(&dev->pdev->dev, "call mei_write_message header=%08x.\n",
+	    *((u32 *) &mei_hdr));
+	if (mei_write_message(dev, &mei_hdr,
+		write_cb->request_buffer.data, mei_hdr.length)) {
+		rets = -ENODEV;
+		goto err;
+	}
+	cl->writing_state = MEI_WRITING;
+	write_cb->buf_idx = mei_hdr.length;
 
-		write_cb->buf_idx = 0;
-		cl->writing_state = MEI_WRITING;
+out:
+	if (mei_hdr.msg_complete) {
+		if (mei_flow_ctrl_reduce(dev, cl)) {
+			rets = -ENODEV;
+			goto err;
+		}
+		list_add_tail(&write_cb->list, &dev->write_waiting_list.list);
+	} else {
 		list_add_tail(&write_cb->list, &dev->write_list.list);
 	}
+
 	mutex_unlock(&dev->device_lock);
 	return length;
 
-unlock_dev:
+err:
 	mutex_unlock(&dev->device_lock);
 	mei_io_cb_free(write_cb);
 	return rets;
Signature · 1 line
1.7.4.4
#1 lore raw

PATCH 2/6 mei: normalize timeouts definitions

1. The hardware book defines timeouts in seconds so we stick to this and define the wrapper function mei_secs_to_jiffies around msecs_to_jiffies to use be used instead multiplying by HZ

2. We add name space prefix MEI_ to all timer defines

---
 drivers/misc/mei/hw.h        |   14 +++++++-------
 drivers/misc/mei/init.c      |   18 +++++++++---------
 drivers/misc/mei/interrupt.c |    4 ++--
 drivers/misc/mei/iorw.c      |    8 ++++----
 drivers/misc/mei/main.c      |    2 +-
 drivers/misc/mei/mei_dev.h   |    5 +++++
 drivers/misc/mei/wd.c        |    2 +-
 7 files changed, 29 insertions(+), 24 deletions(-)
drivers/misc/mei/hw.h +7 -7
index 9700532..f21721a 100644
@@ -20,16 +20,16 @@
 #include <linux/uuid.h>
 
 /*
- * Timeouts
+ * Timeouts in Seconds
  */
-#define MEI_INTEROP_TIMEOUT    (HZ * 7)
-#define MEI_CONNECT_TIMEOUT		3	/* at least 2 seconds */
+#define MEI_INTEROP_TIMEOUT         7  /* Timeout on ready message */
+#define MEI_CONNECT_TIMEOUT         3  /* HPS: at least 2 seconds */
 
-#define CONNECT_TIMEOUT        15	/* HPS definition */
-#define INIT_CLIENTS_TIMEOUT   15	/* HPS definition */
+#define MEI_CL_CONNECT_TIMEOUT     15  /* HPS: Client Connect Timeout */
+#define MEI_CLIENTS_INIT_TIMEOUT   15  /* HPS: Clients Enumeration Timeout */
 
-#define IAMTHIF_STALL_TIMER		12	/* seconds */
-#define IAMTHIF_READ_TIMER		10000	/* ms */
+#define MEI_IAMTHIF_STALL_TIMER    12  /* HPS */
+#define MEI_IAMTHIF_READ_TIMER     10  /* HPS */
 
 /*
  * Internal Clients Number
drivers/misc/mei/init.c +9 -9
index 1f13eb9..e6951ec 100644
@@ -184,7 +184,8 @@ int mei_hw_init(struct mei_device *dev)
 	if (!dev->recvd_msg) {
 		mutex_unlock(&dev->device_lock);
 		err = wait_event_interruptible_timeout(dev->wait_recvd_msg,
-			dev->recvd_msg, MEI_INTEROP_TIMEOUT);
+			dev->recvd_msg,
+			mei_secs_to_jiffies(MEI_INTEROP_TIMEOUT));
 		mutex_lock(&dev->device_lock);
 	}
 
@@ -381,7 +382,7 @@ void mei_host_start_message(struct mei_device *dev)
 		mei_reset(dev, 1);
 	}
 	dev->init_clients_state = MEI_START_MESSAGE;
-	dev->init_clients_timer = INIT_CLIENTS_TIMEOUT;
+	dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
 	return ;
 }
 
@@ -414,7 +415,7 @@ void mei_host_enum_clients_message(struct mei_device *dev)
 		mei_reset(dev, 1);
 	}
 	dev->init_clients_state = MEI_ENUM_CLIENTS_MESSAGE;
-	dev->init_clients_timer = INIT_CLIENTS_TIMEOUT;
+	dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
 	return;
 }
 
@@ -502,7 +503,7 @@ int mei_host_client_properties(struct mei_device *dev)
 			return -EIO;
 		}
 
-		dev->init_clients_timer = INIT_CLIENTS_TIMEOUT;
+		dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
 		dev->me_client_index = b;
 		return 1;
 	}
@@ -621,7 +622,7 @@ void mei_host_init_iamthif(struct mei_device *dev)
 		dev->iamthif_cl.state = MEI_FILE_DISCONNECTED;
 		dev->iamthif_cl.host_client_id = 0;
 	} else {
-		dev->iamthif_cl.timer_count = CONNECT_TIMEOUT;
+		dev->iamthif_cl.timer_count = MEI_CONNECT_TIMEOUT;
 	}
 }
 
@@ -658,9 +659,8 @@ struct mei_cl *mei_cl_allocate(struct mei_device *dev)
  */
 int mei_disconnect_host_client(struct mei_device *dev, struct mei_cl *cl)
 {
-	int rets, err;
-	long timeout = 15;	/* 15 seconds */
 	struct mei_cl_cb *cb;
+	int rets, err;
 
 	if (!dev || !cl)
 		return -ENODEV;
@@ -690,8 +690,8 @@ int mei_disconnect_host_client(struct mei_device *dev, struct mei_cl *cl)
 	mutex_unlock(&dev->device_lock);
 
 	err = wait_event_timeout(dev->wait_recvd_msg,
-		 (MEI_FILE_DISCONNECTED == cl->state),
-		 timeout * HZ);
+			MEI_FILE_DISCONNECTED == cl->state,
+			mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT));
 
 	mutex_lock(&dev->device_lock);
 	if (MEI_FILE_DISCONNECTED == cl->state) {
drivers/misc/mei/interrupt.c +2 -2
index 5c65bac..248f581 100644
@@ -269,7 +269,7 @@ static int _mei_irq_thread_iamthif_read(struct mei_device *dev, s32 *slots)
 	dev->iamthif_flow_control_pending = false;
 	dev->iamthif_msg_buf_index = 0;
 	dev->iamthif_msg_buf_size = 0;
-	dev->iamthif_stall_timer = IAMTHIF_STALL_TIMER;
+	dev->iamthif_stall_timer = MEI_IAMTHIF_STALL_TIMER;
 	dev->mei_host_buffer_is_empty = mei_hbuf_is_empty(dev);
 	return 0;
 }
@@ -1379,7 +1379,7 @@ void mei_timer(struct work_struct *work)
 	if (dev->iamthif_timer) {
 
 		timeout = dev->iamthif_timer +
-				msecs_to_jiffies(IAMTHIF_READ_TIMER);
+			mei_secs_to_jiffies(MEI_IAMTHIF_READ_TIMER);
 
 		dev_dbg(&dev->pdev->dev, "dev->iamthif_timer = %ld\n",
 				dev->iamthif_timer);
drivers/misc/mei/iorw.c +4 -4
index 541c157..8026cbf 100644
@@ -173,7 +173,7 @@ int mei_ioctl_connect_client(struct file *file,
 	struct mei_cl *cl;
 	struct mei_cl *cl_pos = NULL;
 	struct mei_cl *cl_next = NULL;
-	long timeout = CONNECT_TIMEOUT;
+	long timeout = mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT);
 	int i;
 	int err;
 	int rets;
@@ -291,8 +291,7 @@ int mei_ioctl_connect_client(struct file *file,
 	mutex_unlock(&dev->device_lock);
 	err = wait_event_timeout(dev->wait_recvd_msg,
 			(MEI_FILE_CONNECTED == cl->state ||
-			 MEI_FILE_DISCONNECTED == cl->state),
-			timeout * HZ);
+			 MEI_FILE_DISCONNECTED == cl->state), timeout);
 
 	mutex_lock(&dev->device_lock);
 	if (MEI_FILE_CONNECTED == cl->state) {
@@ -415,7 +414,8 @@ int amthi_read(struct mei_device *dev, struct file *file,
 	dev->iamthif_timer = 0;
 
 	if (cb) {
-		timeout = cb->read_time + msecs_to_jiffies(IAMTHIF_READ_TIMER);
+		timeout = cb->read_time +
+			mei_secs_to_jiffies(MEI_IAMTHIF_READ_TIMER);
 		dev_dbg(&dev->pdev->dev, "amthi timeout = %lud\n",
 				timeout);
 
drivers/misc/mei/main.c +1 -1
index 7a03d77..659727a 100644
@@ -567,7 +567,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
 
 		if (write_cb) {
 			timeout = write_cb->read_time +
-					msecs_to_jiffies(IAMTHIF_READ_TIMER);
+				mei_secs_to_jiffies(MEI_IAMTHIF_READ_TIMER);
 
 			if (time_after(jiffies, timeout) ||
 			    cl->reading_state == MEI_READ_COMPLETE) {
drivers/misc/mei/mei_dev.h +5 -0
index 6adcb3f..32c951a 100644
@@ -270,6 +270,11 @@ struct mei_device {
 	bool iamthif_canceled;
 };
 
+static inline unsigned long mei_secs_to_jiffies(unsigned long sec)
+{
+	return msecs_to_jiffies(sec * MSEC_PER_SEC);
+}
+
 
 /*
  * mei init function prototypes
drivers/misc/mei/wd.c +1 -1
index d96c537..8edb054 100644
@@ -85,7 +85,7 @@ int mei_wd_host_init(struct mei_device *dev)
 		dev->wd_cl.host_client_id = 0;
 		return -EIO;
 	}
-	dev->wd_cl.timer_count = CONNECT_TIMEOUT;
+	dev->wd_cl.timer_count = MEI_CONNECT_TIMEOUT;
 
 	return 0;
 }
Signature · 1 line
1.7.4.4
#5 lore raw

PATCH 6/6 mei: move amthif specific code from mei_write to mei_amthif_write

In reply to Tomas Winkler

For sake of amthif consolidation move amthif specific code from mei_write to mei_amthif_write

The original mei_amthif_write to mei_amthif_send_cmd as this function deals with sending single command while mei_amthif_write is interface function called from the main driver which in turns calls mei_amthif_send_cmd

---
 drivers/misc/mei/amthif.c |   39 ++++++++++++++++++++++++++++++++++++---
 drivers/misc/mei/main.c   |   25 +++++--------------------
 2 files changed, 41 insertions(+), 23 deletions(-)
drivers/misc/mei/amthif.c +36 -3
index 392203d..96db3ad 100644
@@ -255,14 +255,15 @@ out:
 }
 
 /**
- * mei_amthif_write - write amthif data to amthif client
+ * mei_amthif_send_cmd - send amthif command to the ME
  *
  * @dev: the device structure
  * @cb: mei call back struct
  *
  * returns 0 on success, <0 on failure.
+ *
  */
-int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *cb)
+static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)
 {
 	struct mei_msg_hdr mei_hdr;
 	int ret;
@@ -329,6 +330,38 @@ int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *cb)
 }
 
 /**
+ * mei_amthif_write - write amthif data to amthif client
+ *
+ * @dev: the device structure
+ * @cb: mei call back struct
+ *
+ * returns 0 on success, <0 on failure.
+ *
+ */
+int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *cb)
+{
+	int ret;
+
+	if (!dev || !cb)
+		return -ENODEV;
+
+	ret = mei_io_cb_alloc_resp_buf(cb, dev->iamthif_mtu);
+	if (ret)
+		return ret;
+
+	cb->major_file_operations = MEI_IOCTL;
+
+	if (!list_empty(&dev->amthi_cmd_list.list) ||
+	    dev->iamthif_state != MEI_IAMTHIF_IDLE) {
+		dev_dbg(&dev->pdev->dev,
+			"amthif state = %d\n", dev->iamthif_state);
+		dev_dbg(&dev->pdev->dev, "AMTHIF: add cb to the wait list\n");
+		list_add_tail(&cb->list, &dev->amthi_cmd_list.list);
+		return 0;
+	}
+	return mei_amthif_send_cmd(dev, cb);
+}
+/**
  * mei_amthif_run_next_cmd
  *
  * @dev: the device structure
@@ -360,7 +393,7 @@ void mei_amthif_run_next_cmd(struct mei_device *dev)
 		cl_tmp = (struct mei_cl *)pos->file_private;
 
 		if (cl_tmp && cl_tmp == &dev->iamthif_cl) {
-			status = mei_amthif_write(dev, pos);
+			status = mei_amthif_send_cmd(dev, pos);
 			if (status) {
 				dev_dbg(&dev->pdev->dev,
 					"amthi write failed status = %d\n",
drivers/misc/mei/main.c +5 -20
index d8221a5..ff50cc1 100644
@@ -620,27 +620,12 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
 		cl->sm_state |= MEI_WD_STATE_INDEPENDENCE_MSG_SENT;
 
 	if (cl == &dev->iamthif_cl) {
-		rets = mei_io_cb_alloc_resp_buf(write_cb, dev->iamthif_mtu);
-		if (rets)
-			goto err;
+		rets = mei_amthif_write(dev, write_cb);
 
-		write_cb->major_file_operations = MEI_IOCTL;
-
-		if (!list_empty(&dev->amthi_cmd_list.list) ||
-				dev->iamthif_state != MEI_IAMTHIF_IDLE) {
-			dev_dbg(&dev->pdev->dev, "amthi_state = %d\n",
-					(int) dev->iamthif_state);
-			dev_dbg(&dev->pdev->dev, "add amthi cb to amthi cmd waiting list\n");
-			list_add_tail(&write_cb->list, &dev->amthi_cmd_list.list);
-		} else {
-			dev_dbg(&dev->pdev->dev, "call amthi write\n");
-			rets = mei_amthif_write(dev, write_cb);
-
-			if (rets) {
-				dev_err(&dev->pdev->dev, "amthi write failed with status = %d\n",
-				    rets);
-				goto err;
-			}
+		if (rets) {
+			dev_err(&dev->pdev->dev,
+				"amthi write failed with status = %d\n", rets);
+			goto err;
 		}
 		mutex_unlock(&dev->device_lock);
 		return length;
Signature · 1 line
1.7.4.4
#4 lore raw

PATCH 5/6 mei: use internal watchdog device registration tracking

In reply to Tomas Winkler

remove bool wd_interface_reg as watchdog device already keeps track of its registration

---
 drivers/misc/mei/init.c    |    2 --
 drivers/misc/mei/mei_dev.h |    1 -
 drivers/misc/mei/wd.c      |    5 +----
 3 files changed, 1 insertions(+), 7 deletions(-)
drivers/misc/mei/init.c +0 -2
index 4a8eb92..8c3c268 100644
@@ -111,8 +111,6 @@ struct mei_device *mei_device_init(struct pci_dev *pdev)
 	init_waitqueue_head(&dev->wait_stop_wd);
 	dev->dev_state = MEI_DEV_INITIALIZING;
 	dev->iamthif_state = MEI_IAMTHIF_IDLE;
-	dev->wd_interface_reg = false;
-
 
 	mei_io_list_init(&dev->read_list);
 	mei_io_list_init(&dev->write_list);
drivers/misc/mei/mei_dev.h +0 -1
index 57a5a4e..8b96d99 100644
@@ -249,7 +249,6 @@ struct mei_device {
 
 	struct mei_cl wd_cl;
 	enum mei_wd_states wd_state;
-	bool wd_interface_reg;
 	bool wd_pending;
 	u16 wd_timeout;
 	unsigned char wd_data[MEI_WD_START_MSG_SIZE];
drivers/misc/mei/wd.c +1 -4
index 8edb054..4fc2b3d 100644
@@ -360,23 +360,20 @@ void mei_watchdog_register(struct mei_device *dev)
 	if (watchdog_register_device(&amt_wd_dev)) {
 		dev_err(&dev->pdev->dev,
 			"wd: unable to register watchdog device.\n");
-		dev->wd_interface_reg = false;
 		return;
 	}
 
 	dev_dbg(&dev->pdev->dev,
 		"wd: successfully register watchdog interface.\n");
-	dev->wd_interface_reg = true;
 	watchdog_set_drvdata(&amt_wd_dev, dev);
 }
 
 void mei_watchdog_unregister(struct mei_device *dev)
 {
-	if (!dev->wd_interface_reg)
+	if (test_bit(WDOG_UNREGISTERED, &amt_wd_dev.status))
 		return;
 
 	watchdog_set_drvdata(&amt_wd_dev, NULL);
 	watchdog_unregister_device(&amt_wd_dev);
-	dev->wd_interface_reg = false;
 }
 
Signature · 1 line
1.7.4.4
#3 lore raw

PATCH 4/6 mei: mei_clear_list: kill file_temp

In reply to Tomas Winkler

file_temp is used only once, so there is no any benefit of creating a temporary variable

---
 drivers/misc/mei/main.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/misc/mei/main.c +2 -4
index f69e085..d8221a5 100644
@@ -103,18 +103,16 @@ static DEFINE_MUTEX(mei_mutex);
  * returns true if callback removed from the list, false otherwise
  */
 static bool mei_clear_list(struct mei_device *dev,
-		struct file *file, struct list_head *mei_cb_list)
+		const struct file *file, struct list_head *mei_cb_list)
 {
 	struct mei_cl_cb *cb_pos = NULL;
 	struct mei_cl_cb *cb_next = NULL;
-	struct file *file_temp;
 	bool removed = false;
 
 	/* list all list member */
 	list_for_each_entry_safe(cb_pos, cb_next, mei_cb_list, list) {
-		file_temp = (struct file *)cb_pos->file_object;
 		/* check if list member associated with a file */
-		if (file_temp == file) {
+		if (file == cb_pos->file_object) {
 			/* remove member from the list */
 			list_del(&cb_pos->list);
 			/* check if cb equal to current iamthif cb */
Signature · 1 line
1.7.4.4
#2 lore raw

PATCH 3/6 mei: extract AMTHI functions into the amthif.c file

In reply to Tomas Winkler

Move AMT Host Interface functions into the new amthif.c file. All functions has now common prefix: mei_amthif_

---
 drivers/misc/mei/Makefile    |    1 +
 drivers/misc/mei/amthif.c    |  572 ++++++++++++++++++++++++++++++++++++++++++
 drivers/misc/mei/init.c      |   73 +------
 drivers/misc/mei/interrupt.c |  218 +---------------
 drivers/misc/mei/iorw.c      |  266 --------------------
 drivers/misc/mei/main.c      |   10 +-
 drivers/misc/mei/mei_dev.h   |   29 ++-
 7 files changed, 613 insertions(+), 556 deletions(-)
 create mode 100644 drivers/misc/mei/amthif.c
drivers/misc/mei/Makefile +1 -0
index 57168db..0017842 100644
@@ -8,4 +8,5 @@ mei-objs += interrupt.o
 mei-objs += interface.o
 mei-objs += iorw.o
 mei-objs += main.o
+mei-objs += amthif.o
 mei-objs += wd.o
drivers/misc/mei/amthif.c new file +572 -0

572 lines not on this page · raw message

drivers/misc/mei/init.c +1 -72

97 lines not on this page · raw message

drivers/misc/mei/interrupt.c +10 -208

284 lines not on this page · raw message

drivers/misc/mei/iorw.c +0 -266

275 lines not on this page · raw message

drivers/misc/mei/main.c +5 -5
index 659727a..f69e085 100644
@@ -349,7 +349,7 @@ static int mei_release(struct inode *inode, struct file *file)
 			dev->iamthif_canceled = true;
 			if (dev->iamthif_state == MEI_IAMTHIF_READ_COMPLETE) {
 				dev_dbg(&dev->pdev->dev, "run next amthi iamthif cb\n");
-				mei_run_next_iamthif_cmd(dev);
+				mei_amthif_run_next_cmd(dev);
 			}
 		}
 
@@ -410,7 +410,7 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
 	}
 
 	if (cl == &dev->iamthif_cl) {
-		rets = amthi_read(dev, file, ubuf, length, offset);
+		rets = mei_amthif_read(dev, file, ubuf, length, offset);
 		goto out;
 	}
 
@@ -563,7 +563,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
 		goto err;
 	}
 	if (cl == &dev->iamthif_cl) {
-		write_cb = find_amthi_read_list_entry(dev, file);
+		write_cb = mei_amthif_find_read_list_entry(dev, file);
 
 		if (write_cb) {
 			timeout = write_cb->read_time +
@@ -636,7 +636,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
 			list_add_tail(&write_cb->list, &dev->amthi_cmd_list.list);
 		} else {
 			dev_dbg(&dev->pdev->dev, "call amthi write\n");
-			rets = amthi_write(dev, write_cb);
+			rets = mei_amthif_write(dev, write_cb);
 
 			if (rets) {
 				dev_err(&dev->pdev->dev, "amthi write failed with status = %d\n",
@@ -823,7 +823,7 @@ static unsigned int mei_poll(struct file *file, poll_table *wait)
 			dev->iamthif_file_object == file) {
 			mask |= (POLLIN | POLLRDNORM);
 			dev_dbg(&dev->pdev->dev, "run next amthi cb\n");
-			mei_run_next_iamthif_cmd(dev);
+			mei_amthif_run_next_cmd(dev);
 		}
 		goto out;
 	}
drivers/misc/mei/mei_dev.h +24 -5
index 32c951a..57a5a4e 100644
@@ -286,7 +286,6 @@ int mei_task_initialize_clients(void *data);
 int mei_initialize_clients(struct mei_device *dev);
 int mei_disconnect_host_client(struct mei_device *dev, struct mei_cl *cl);
 void mei_remove_client_from_file_list(struct mei_device *dev, u8 host_client_id);
-void mei_host_init_iamthif(struct mei_device *dev);
 void mei_allocate_me_clients_storage(struct mei_device *dev);
 
 
@@ -362,17 +361,37 @@ int mei_ioctl_connect_client(struct file *file,
 
 int mei_start_read(struct mei_device *dev, struct mei_cl *cl);
 
-int amthi_write(struct mei_device *dev, struct mei_cl_cb *priv_cb);
 
-int amthi_read(struct mei_device *dev, struct file *file,
+/*
+ * AMTHIF - AMT Host Interface Functions
+ */
+void mei_amthif_reset_params(struct mei_device *dev);
+
+void mei_amthif_host_init(struct mei_device *dev);
+
+int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *priv_cb);
+
+int mei_amthif_read(struct mei_device *dev, struct file *file,
 	      char __user *ubuf, size_t length, loff_t *offset);
 
-struct mei_cl_cb *find_amthi_read_list_entry(struct mei_device *dev,
+struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev,
 						struct file *file);
 
-void mei_run_next_iamthif_cmd(struct mei_device *dev);
+void mei_amthif_run_next_cmd(struct mei_device *dev);
+
+
+int mei_amthif_read_message(struct mei_cl_cb *complete_list,
+		struct mei_device *dev, struct mei_msg_hdr *mei_hdr);
 
+int mei_amthif_irq_process_completed(struct mei_device *dev, s32 *slots,
+			struct mei_cl_cb *cb_pos,
+			struct mei_cl *cl,
+			struct mei_cl_cb *cmpl_list);
 
+void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb);
+int mei_amthif_irq_read_message(struct mei_cl_cb *complete_list,
+		struct mei_device *dev, struct mei_msg_hdr *mei_hdr);
+int mei_amthif_irq_read(struct mei_device *dev, s32 *slots);
 
 /*
  * Register Access Function
Signature · 1 line
1.7.4.4