18 #include <linux/pci.h>
41 u32 csr_reg = mei_hcsr_read(dev);
43 if ((csr_reg &
H_IS) != H_IS)
47 mei_reg_write(dev,
H_CSR, csr_reg);
64 if (waitqueue_active(&cl->
tx_wait))
70 if (waitqueue_active(&cl->
rx_wait))
92 dev_dbg(&dev->
pdev->dev,
"amthi read completed.\n");
94 dev_dbg(&dev->
pdev->dev,
"dev->iamthif_timer = %ld\n",
100 dev_dbg(&dev->
pdev->dev,
"completing amthi call back.\n");
115 static int mei_irq_thread_read_amthi_message(
struct mei_io_list *complete_list,
137 "amthi_message_buffer_index =%d\n",
140 dev_dbg(&dev->
pdev->dev,
"completed amthi read.\n ");
156 dev_dbg(&dev->
pdev->dev,
"complete the amthi read cb.\n ");
157 dev_dbg(&dev->
pdev->dev,
"add the amthi read cb to complete.\n ");
159 &complete_list->
mei_cb.cb_list);
172 static int _mei_irq_thread_state_ok(
struct mei_cl *cl,
191 static int mei_irq_thread_read_client_message(
struct mei_io_list *complete_list,
197 unsigned char *buffer =
NULL;
200 if (list_empty(&dev->
read_list.mei_cb.cb_list))
206 if (cl && _mei_irq_thread_state_ok(cl, mei_hdr)) {
224 "completed read H cl = %d, ME cl = %d, length = %lu\n",
229 &complete_list->
mei_cb.cb_list);
241 dev_dbg(&dev->
pdev->dev,
"discarding message, header =%08x.\n",
265 dev_dbg(&dev->
pdev->dev,
"iamthif flow control failed\n");
269 dev_dbg(&dev->
pdev->dev,
"iamthif flow control success\n");
290 static int _mei_irq_thread_close(
struct mei_device *dev,
s32 *slots,
304 list_move_tail(&cb_pos->
cb_list,
305 &cmpl_list->
mei_cb.cb_list);
311 list_move_tail(&cb_pos->
cb_list,
327 static bool is_treat_specially_client(
struct mei_cl *cl,
354 static void mei_client_connect_response(
struct mei_device *dev,
362 "connect_response:\n"
372 if (is_treat_specially_client(&(dev->
wd_cl), rs)) {
373 dev_dbg(&dev->
pdev->dev,
"successfully connected to WD client.\n");
381 if (is_treat_specially_client(&(dev->
iamthif_cl), rs)) {
394 if (is_treat_specially_client(cl, rs)) {
410 static void mei_client_disconnect_response(
struct mei_device *dev,
417 "disconnect_response:\n"
434 dev_dbg(&dev->
pdev->dev,
"list_for_each_entry_safe in ctrl_rd_list.\n");
469 static void add_single_flow_creds(
struct mei_device *dev,
478 if (client->
props.single_recv_buf) {
480 dev_dbg(&dev->
pdev->dev,
"recv flow ctrl msg ME %d (single).\n",
482 dev_dbg(&dev->
pdev->dev,
"flow control credentials =%d.\n",
497 static void mei_client_flow_control_response(
struct mei_device *dev,
505 add_single_flow_creds(dev, flow_control);
510 dev_dbg(&dev->
pdev->dev,
"list_for_each_entry_safe in file_list\n");
512 dev_dbg(&dev->
pdev->dev,
"cl of host client %d ME client %d.\n",
515 dev_dbg(&dev->
pdev->dev,
"flow ctrl msg for host %d ME %d.\n",
518 if (same_flow_addr(cl_pos, flow_control)) {
519 dev_dbg(&dev->
pdev->dev,
"recv ctrl msg for host %d ME %d.\n",
523 dev_dbg(&dev->
pdev->dev,
"flow control credentials = %d.\n",
539 static int same_disconn_addr(
struct mei_cl *cl,
552 static void mei_client_disconnect_request(
struct mei_device *dev,
561 if (same_disconn_addr(cl_pos, disconnect_req)) {
562 dev_dbg(&dev->
pdev->dev,
"disconnect request host client %d ME client %d.\n",
567 if (cl_pos == &dev->
wd_cl)
588 disconnect_res->
status = 0;
603 static void mei_irq_thread_read_bus_message(
struct mei_device *dev,
635 dev_dbg(&dev->
pdev->dev,
"IMEI reset due to received host start response bus message.\n");
658 (
unsigned char *) (host_stop_req),
665 dev_dbg(&dev->
pdev->dev,
"host start response message received.\n");
671 mei_client_connect_response(dev, connect_res);
672 dev_dbg(&dev->
pdev->dev,
"client connect response message received.\n");
679 mei_client_disconnect_response(dev, disconnect_res);
680 dev_dbg(&dev->
pdev->dev,
"client disconnect response message received.\n");
686 mei_client_flow_control_response(dev, flow_control);
687 dev_dbg(&dev->
pdev->dev,
"client flow control response message received.\n");
693 dev_dbg(&dev->
pdev->dev,
"reset due to received host client properties response bus message wrong status.\n");
698 .client_id == props_res->
address) {
712 dev_dbg(&dev->
pdev->dev,
"mei_host_client_properties() failed");
741 dev_dbg(&dev->
pdev->dev,
"reset due to received host client properties response bus message");
746 dev_dbg(&dev->
pdev->dev,
"reset due to received host client properties response bus message for wrong client ID\n");
765 dev_dbg(&dev->
pdev->dev,
"reset due to received host enumeration clients response bus message.\n");
773 dev_dbg(&dev->
pdev->dev,
"resetting because of FW stop response.\n");
781 mei_client_disconnect_request(dev, disconnect_req);
821 static int _mei_irq_thread_read(
struct mei_device *dev,
s32 *slots,
838 list_move_tail(&cb_pos->
cb_list, &cmpl_list->
mei_cb.cb_list);
858 static int _mei_irq_thread_ioctl(
struct mei_device *dev,
s32 *slots,
878 list_move_tail(&cb_pos->
cb_list,
896 static int _mei_irq_thread_cmpl(
struct mei_device *dev,
s32 *slots,
913 dev_dbg(&dev->
pdev->dev,
"cb_pos->request_buffer.size =%d"
914 "mei_hdr->msg_complete = %d\n",
917 dev_dbg(&dev->
pdev->dev,
"cb_pos->information =%lu\n",
921 *slots -= mei_data2slots(mei_hdr->
length);
928 list_move_tail(&cb_pos->
cb_list,
929 &cmpl_list->
mei_cb.cb_list);
936 list_move_tail(&cb_pos->
cb_list,
948 *slots -= mei_data2slots(mei_hdr->
length);
955 list_move_tail(&cb_pos->
cb_list,
956 &cmpl_list->
mei_cb.cb_list);
961 "cb_pos->request_buffer.size =%d"
962 " mei_hdr->msg_complete = %d\n",
965 dev_dbg(&dev->
pdev->dev,
"cb_pos->information =%lu\n",
989 static int _mei_irq_thread_cmpl_iamthif(
struct mei_device *dev,
s32 *slots,
1007 *slots -= mei_data2slots(mei_hdr->
length);
1027 list_move_tail(&cb_pos->
cb_list,
1041 *slots -= mei_data2slots(mei_hdr->
length);
1070 static int mei_irq_thread_read_handler(
struct mei_io_list *cmpl_list,
1081 dev_dbg(&dev->
pdev->dev,
"slots =%08x.\n", *slots);
1083 dev_dbg(&dev->
pdev->dev,
"slots =%08x.\n", *slots);
1089 dev_dbg(&dev->
pdev->dev,
"corrupted message header.\n");
1098 "list_for_each_entry_safe read host"
1099 " client = %d, ME client = %d\n",
1108 dev_dbg(&dev->
pdev->dev,
"corrupted message header\n");
1113 if (((*slots) *
sizeof(
u32)) < mei_hdr->
length) {
1115 "we can't read the message slots =%08x.\n",
1124 dev_dbg(&dev->
pdev->dev,
"call mei_irq_thread_read_bus_message.\n");
1125 mei_irq_thread_read_bus_message(dev, mei_hdr);
1126 dev_dbg(&dev->
pdev->dev,
"end mei_irq_thread_read_bus_message.\n");
1130 dev_dbg(&dev->
pdev->dev,
"call mei_irq_thread_read_iamthif_message.\n");
1133 ret = mei_irq_thread_read_amthi_message(cmpl_list,
1139 dev_dbg(&dev->
pdev->dev,
"call mei_irq_thread_read_client_message.\n");
1140 ret = mei_irq_thread_read_client_message(cmpl_list,
1153 dev_dbg(&dev->
pdev->dev,
"resetting due to slots overflow.\n");
1173 static int mei_irq_thread_write_handler(
struct mei_io_list *cmpl_list,
1184 dev_dbg(&dev->
pdev->dev,
"host buffer is not empty.\n");
1192 dev_dbg(&dev->
pdev->dev,
"complete all waiting for write cb.\n");
1208 &cmpl_list->
mei_cb.cb_list);
1211 dev_dbg(&dev->
pdev->dev,
"check iamthif flow control.\n");
1213 ret = _mei_irq_thread_iamthif_read(dev, slots);
1226 dev_dbg(&dev->
pdev->dev,
"extra_write_index =%d.\n",
1253 dev_dbg(&dev->
pdev->dev,
"complete control write list cb.\n");
1264 ret = _mei_irq_thread_close(dev, slots, pos, cl, cmpl_list);
1271 ret = _mei_irq_thread_read(dev, slots, pos, cl, cmpl_list);
1280 ret = _mei_irq_thread_ioctl(dev, slots, pos, cl, cmpl_list);
1292 dev_dbg(&dev->
pdev->dev,
"complete write list cb.\n");
1302 "No flow control credentials for client %d, not sending.\n",
1306 ret = _mei_irq_thread_cmpl(dev, slots, pos,
1313 dev_dbg(&dev->
pdev->dev,
"complete amthi write cb.\n");
1316 "No flow control credentials for amthi client %d.\n",
1320 ret = _mei_irq_thread_cmpl_iamthif(dev, slots, pos,
1358 dev_dbg(&dev->
pdev->dev,
"IMEI reset due to init clients timeout ,init clients state = %d.\n",
1370 dev_dbg(&dev->
pdev->dev,
"HECI reset due to connect/disconnect timeout.\n");
1379 dev_dbg(&dev->
pdev->dev,
"resetting because of hang to amthi.\n");
1402 dev_dbg(&dev->
pdev->dev,
"dev->iamthif_timer = %ld\n",
1404 dev_dbg(&dev->
pdev->dev,
"timeout = %ld\n", timeout);
1412 dev_dbg(&dev->
pdev->dev,
"freeing AMTHI for other requests\n");
1459 bool bus_message_received;
1462 dev_dbg(&dev->
pdev->dev,
"function called after ISR to handle the interrupt processing.\n");
1470 if (pci_dev_msi_enabled(dev->
pdev))
1488 dev_dbg(&dev->
pdev->dev,
"we need to start the dev.\n");
1492 dev_dbg(&dev->
pdev->dev,
"link is established start sending messages.\n");
1507 dev_dbg(&dev->
pdev->dev,
"slots =%08x extra_write_index =%08x.\n",
1510 dev_dbg(&dev->
pdev->dev,
"slots =%08x extra_write_index =%08x.\n",
1512 dev_dbg(&dev->
pdev->dev,
"call mei_irq_thread_read_handler.\n");
1513 rets = mei_irq_thread_read_handler(&complete_list, dev, &slots);
1517 rets = mei_irq_thread_write_handler(&complete_list, dev, &slots);
1519 dev_dbg(&dev->
pdev->dev,
"end of bottom half function.\n");
1523 bus_message_received =
false;
1525 dev_dbg(&dev->
pdev->dev,
"received waiting bus message\n");
1526 bus_message_received =
true;
1529 if (bus_message_received) {
1530 dev_dbg(&dev->
pdev->dev,
"wake up dev->wait_recvd_msg\n");
1532 bus_message_received =
false;
1534 if (list_empty(&complete_list.
mei_cb.cb_list))
1539 &complete_list.
mei_cb.cb_list, cb_list) {
1544 dev_dbg(&dev->
pdev->dev,
"completing call back.\n");
1545 _mei_cmpl(cl, cb_pos);
1548 _mei_cmpl_iamthif(dev, cb_pos);