aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/mei/interrupt.c
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2012-11-01 15:17:15 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-11-01 15:31:19 -0400
commit19838fb85306905a373b6449c1428791d653fc21 (patch)
tree09c793c5b27f95494c6a4548af7e420666a108bf /drivers/misc/mei/interrupt.c
parent3870c3206b96c900ce29c8068bd5ad46fae71f5b (diff)
mei: extract AMTHI functions into the amthif.c file
Move AMT Host Interface functions into the new amthif.c file. All functions has now common prefix: mei_amthif_ Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/mei/interrupt.c')
-rw-r--r--drivers/misc/mei/interrupt.c218
1 files changed, 10 insertions, 208 deletions
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 248f581bde31..62f8b65fd11a 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -74,92 +74,6 @@ static void _mei_cmpl(struct mei_cl *cl, struct mei_cl_cb *cb_pos)
74} 74}
75 75
76/** 76/**
77 * _mei_cmpl_iamthif - processes completed iamthif operation.
78 *
79 * @dev: the device structure.
80 * @cb_pos: callback block.
81 */
82static void _mei_cmpl_iamthif(struct mei_device *dev, struct mei_cl_cb *cb_pos)
83{
84 if (dev->iamthif_canceled != 1) {
85 dev->iamthif_state = MEI_IAMTHIF_READ_COMPLETE;
86 dev->iamthif_stall_timer = 0;
87 memcpy(cb_pos->response_buffer.data,
88 dev->iamthif_msg_buf,
89 dev->iamthif_msg_buf_index);
90 list_add_tail(&cb_pos->list, &dev->amthi_read_complete_list.list);
91 dev_dbg(&dev->pdev->dev, "amthi read completed\n");
92 dev->iamthif_timer = jiffies;
93 dev_dbg(&dev->pdev->dev, "dev->iamthif_timer = %ld\n",
94 dev->iamthif_timer);
95 } else {
96 mei_run_next_iamthif_cmd(dev);
97 }
98
99 dev_dbg(&dev->pdev->dev, "completing amthi call back.\n");
100 wake_up_interruptible(&dev->iamthif_cl.wait);
101}
102
103
104/**
105 * mei_irq_thread_read_amthi_message - bottom half read routine after ISR to
106 * handle the read amthi message data processing.
107 *
108 * @complete_list: An instance of our list structure
109 * @dev: the device structure
110 * @mei_hdr: header of amthi message
111 *
112 * returns 0 on success, <0 on failure.
113 */
114static int mei_irq_thread_read_amthi_message(struct mei_cl_cb *complete_list,
115 struct mei_device *dev,
116 struct mei_msg_hdr *mei_hdr)
117{
118 struct mei_cl *cl;
119 struct mei_cl_cb *cb;
120 unsigned char *buffer;
121
122 BUG_ON(mei_hdr->me_addr != dev->iamthif_cl.me_client_id);
123 BUG_ON(dev->iamthif_state != MEI_IAMTHIF_READING);
124
125 buffer = dev->iamthif_msg_buf + dev->iamthif_msg_buf_index;
126 BUG_ON(dev->iamthif_mtu < dev->iamthif_msg_buf_index + mei_hdr->length);
127
128 mei_read_slots(dev, buffer, mei_hdr->length);
129
130 dev->iamthif_msg_buf_index += mei_hdr->length;
131
132 if (!mei_hdr->msg_complete)
133 return 0;
134
135 dev_dbg(&dev->pdev->dev,
136 "amthi_message_buffer_index =%d\n",
137 mei_hdr->length);
138
139 dev_dbg(&dev->pdev->dev, "completed amthi read.\n ");
140 if (!dev->iamthif_current_cb)
141 return -ENODEV;
142
143 cb = dev->iamthif_current_cb;
144 dev->iamthif_current_cb = NULL;
145
146 cl = (struct mei_cl *)cb->file_private;
147 if (!cl)
148 return -ENODEV;
149
150 dev->iamthif_stall_timer = 0;
151 cb->buf_idx = dev->iamthif_msg_buf_index;
152 cb->read_time = jiffies;
153 if (dev->iamthif_ioctl && cl == &dev->iamthif_cl) {
154 /* found the iamthif cb */
155 dev_dbg(&dev->pdev->dev, "complete the amthi read cb.\n ");
156 dev_dbg(&dev->pdev->dev, "add the amthi read cb to complete.\n ");
157 list_add_tail(&cb->list, &complete_list->list);
158 }
159 return 0;
160}
161
162/**
163 * _mei_irq_thread_state_ok - checks if mei header matches file private data 77 * _mei_irq_thread_state_ok - checks if mei header matches file private data
164 * 78 *
165 * @cl: private data of the file object 79 * @cl: private data of the file object
@@ -244,37 +158,6 @@ quit:
244} 158}
245 159
246/** 160/**
247 * _mei_irq_thread_iamthif_read - prepares to read iamthif data.
248 *
249 * @dev: the device structure.
250 * @slots: free slots.
251 *
252 * returns 0, OK; otherwise, error.
253 */
254static int _mei_irq_thread_iamthif_read(struct mei_device *dev, s32 *slots)
255{
256
257 if (((*slots) * sizeof(u32)) < (sizeof(struct mei_msg_hdr)
258 + sizeof(struct hbm_flow_control))) {
259 return -EMSGSIZE;
260 }
261 *slots -= mei_data2slots(sizeof(struct hbm_flow_control));
262 if (mei_send_flow_control(dev, &dev->iamthif_cl)) {
263 dev_dbg(&dev->pdev->dev, "iamthif flow control failed\n");
264 return -EIO;
265 }
266
267 dev_dbg(&dev->pdev->dev, "iamthif flow control success\n");
268 dev->iamthif_state = MEI_IAMTHIF_READING;
269 dev->iamthif_flow_control_pending = false;
270 dev->iamthif_msg_buf_index = 0;
271 dev->iamthif_msg_buf_size = 0;
272 dev->iamthif_stall_timer = MEI_IAMTHIF_STALL_TIMER;
273 dev->mei_host_buffer_is_empty = mei_hbuf_is_empty(dev);
274 return 0;
275}
276
277/**
278 * _mei_irq_thread_close - processes close related operation. 161 * _mei_irq_thread_close - processes close related operation.
279 * 162 *
280 * @dev: the device structure. 163 * @dev: the device structure.
@@ -370,7 +253,7 @@ static void mei_client_connect_response(struct mei_device *dev,
370 mei_watchdog_register(dev); 253 mei_watchdog_register(dev);
371 254
372 /* next step in the state maching */ 255 /* next step in the state maching */
373 mei_host_init_iamthif(dev); 256 mei_amthif_host_init(dev);
374 return; 257 return;
375 } 258 }
376 259
@@ -728,7 +611,7 @@ static void mei_irq_thread_read_bus_message(struct mei_device *dev,
728 * will be received 611 * will be received
729 */ 612 */
730 if (mei_wd_host_init(dev)) 613 if (mei_wd_host_init(dev))
731 mei_host_init_iamthif(dev); 614 mei_amthif_host_init(dev);
732 } 615 }
733 616
734 } else { 617 } else {
@@ -964,87 +847,6 @@ static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots,
964} 847}
965 848
966/** 849/**
967 * _mei_irq_thread_cmpl_iamthif - processes completed iamthif operation.
968 *
969 * @dev: the device structure.
970 * @slots: free slots.
971 * @cb_pos: callback block.
972 * @cl: private data of the file object.
973 * @cmpl_list: complete list.
974 *
975 * returns 0, OK; otherwise, error.
976 */
977static int _mei_irq_thread_cmpl_iamthif(struct mei_device *dev, s32 *slots,
978 struct mei_cl_cb *cb_pos,
979 struct mei_cl *cl,
980 struct mei_cl_cb *cmpl_list)
981{
982 struct mei_msg_hdr *mei_hdr;
983
984 if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) +
985 dev->iamthif_msg_buf_size -
986 dev->iamthif_msg_buf_index)) {
987 mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
988 mei_hdr->host_addr = cl->host_client_id;
989 mei_hdr->me_addr = cl->me_client_id;
990 mei_hdr->length = dev->iamthif_msg_buf_size -
991 dev->iamthif_msg_buf_index;
992 mei_hdr->msg_complete = 1;
993 mei_hdr->reserved = 0;
994
995 *slots -= mei_data2slots(mei_hdr->length);
996
997 if (mei_write_message(dev, mei_hdr,
998 (dev->iamthif_msg_buf +
999 dev->iamthif_msg_buf_index),
1000 mei_hdr->length)) {
1001 dev->iamthif_state = MEI_IAMTHIF_IDLE;
1002 cl->status = -ENODEV;
1003 list_del(&cb_pos->list);
1004 return -ENODEV;
1005 } else {
1006 if (mei_flow_ctrl_reduce(dev, cl))
1007 return -ENODEV;
1008 dev->iamthif_msg_buf_index += mei_hdr->length;
1009 cb_pos->buf_idx = dev->iamthif_msg_buf_index;
1010 cl->status = 0;
1011 dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL;
1012 dev->iamthif_flow_control_pending = true;
1013 /* save iamthif cb sent to amthi client */
1014 dev->iamthif_current_cb = cb_pos;
1015 list_move_tail(&cb_pos->list, &dev->write_waiting_list.list);
1016
1017 }
1018 } else if (*slots == dev->hbuf_depth) {
1019 /* buffer is still empty */
1020 mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
1021 mei_hdr->host_addr = cl->host_client_id;
1022 mei_hdr->me_addr = cl->me_client_id;
1023 mei_hdr->length =
1024 (*slots * sizeof(u32)) - sizeof(struct mei_msg_hdr);
1025 mei_hdr->msg_complete = 0;
1026 mei_hdr->reserved = 0;
1027
1028 *slots -= mei_data2slots(mei_hdr->length);
1029
1030 if (mei_write_message(dev, mei_hdr,
1031 (dev->iamthif_msg_buf +
1032 dev->iamthif_msg_buf_index),
1033 mei_hdr->length)) {
1034 cl->status = -ENODEV;
1035 list_del(&cb_pos->list);
1036 } else {
1037 dev->iamthif_msg_buf_index += mei_hdr->length;
1038 }
1039 return -EMSGSIZE;
1040 } else {
1041 return -EBADMSG;
1042 }
1043
1044 return 0;
1045}
1046
1047/**
1048 * mei_irq_thread_read_handler - bottom half read routine after ISR to 850 * mei_irq_thread_read_handler - bottom half read routine after ISR to
1049 * handle the read processing. 851 * handle the read processing.
1050 * 852 *
@@ -1117,8 +919,8 @@ static int mei_irq_thread_read_handler(struct mei_cl_cb *cmpl_list,
1117 dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_iamthif_message.\n"); 919 dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_iamthif_message.\n");
1118 dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n", 920 dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n",
1119 mei_hdr->length); 921 mei_hdr->length);
1120 ret = mei_irq_thread_read_amthi_message(cmpl_list, 922
1121 dev, mei_hdr); 923 ret = mei_amthif_irq_read_message(cmpl_list, dev, mei_hdr);
1122 if (ret) 924 if (ret)
1123 goto end; 925 goto end;
1124 926
@@ -1195,7 +997,7 @@ static int mei_irq_thread_write_handler(struct mei_cl_cb *cmpl_list,
1195 if (cl == &dev->iamthif_cl) { 997 if (cl == &dev->iamthif_cl) {
1196 dev_dbg(&dev->pdev->dev, "check iamthif flow control.\n"); 998 dev_dbg(&dev->pdev->dev, "check iamthif flow control.\n");
1197 if (dev->iamthif_flow_control_pending) { 999 if (dev->iamthif_flow_control_pending) {
1198 ret = _mei_irq_thread_iamthif_read(dev, slots); 1000 ret = mei_amthif_irq_read(dev, slots);
1199 if (ret) 1001 if (ret)
1200 return ret; 1002 return ret;
1201 } 1003 }
@@ -1300,8 +1102,8 @@ static int mei_irq_thread_write_handler(struct mei_cl_cb *cmpl_list,
1300 cl->host_client_id); 1102 cl->host_client_id);
1301 continue; 1103 continue;
1302 } 1104 }
1303 ret = _mei_irq_thread_cmpl_iamthif(dev, slots, pos, 1105 ret = mei_amthif_irq_process_completed(dev, slots, pos,
1304 cl, cmpl_list); 1106 cl, cmpl_list);
1305 if (ret) 1107 if (ret)
1306 return ret; 1108 return ret;
1307 1109
@@ -1372,7 +1174,7 @@ void mei_timer(struct work_struct *work)
1372 dev->iamthif_current_cb = NULL; 1174 dev->iamthif_current_cb = NULL;
1373 1175
1374 dev->iamthif_file_object = NULL; 1176 dev->iamthif_file_object = NULL;
1375 mei_run_next_iamthif_cmd(dev); 1177 mei_amthif_run_next_cmd(dev);
1376 } 1178 }
1377 } 1179 }
1378 1180
@@ -1409,7 +1211,7 @@ void mei_timer(struct work_struct *work)
1409 dev->iamthif_file_object->private_data = NULL; 1211 dev->iamthif_file_object->private_data = NULL;
1410 dev->iamthif_file_object = NULL; 1212 dev->iamthif_file_object = NULL;
1411 dev->iamthif_timer = 0; 1213 dev->iamthif_timer = 0;
1412 mei_run_next_iamthif_cmd(dev); 1214 mei_amthif_run_next_cmd(dev);
1413 1215
1414 } 1216 }
1415 } 1217 }
@@ -1524,7 +1326,7 @@ end:
1524 _mei_cmpl(cl, cb_pos); 1326 _mei_cmpl(cl, cb_pos);
1525 cb_pos = NULL; 1327 cb_pos = NULL;
1526 } else if (cl == &dev->iamthif_cl) { 1328 } else if (cl == &dev->iamthif_cl) {
1527 _mei_cmpl_iamthif(dev, cb_pos); 1329 mei_amthif_complete(dev, cb_pos);
1528 } 1330 }
1529 } 1331 }
1530 } 1332 }