3 * Intel Management Engine Interface (Intel MEI) Linux driver
4 * Copyright (c) 2003-2012, Intel Corporation.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 #include <linux/export.h>
18 #include <linux/pci.h>
19 #include <linux/sched.h>
20 #include <linux/wait.h>
21 #include <linux/mei.h>
22 #include <linux/pm_runtime.h>
28 static const char *mei_hbm_status_str(enum mei_hbm_status status)
30 #define MEI_HBM_STATUS(status) case MEI_HBMS_##status: return #status
32 MEI_HBM_STATUS(SUCCESS);
33 MEI_HBM_STATUS(CLIENT_NOT_FOUND);
34 MEI_HBM_STATUS(ALREADY_EXISTS);
35 MEI_HBM_STATUS(REJECTED);
36 MEI_HBM_STATUS(INVALID_PARAMETER);
37 MEI_HBM_STATUS(NOT_ALLOWED);
38 MEI_HBM_STATUS(ALREADY_STARTED);
39 MEI_HBM_STATUS(NOT_STARTED);
40 default: return "unknown";
45 static const char *mei_cl_conn_status_str(enum mei_cl_connect_status status)
47 #define MEI_CL_CS(status) case MEI_CL_CONN_##status: return #status
51 MEI_CL_CS(ALREADY_STARTED);
52 MEI_CL_CS(OUT_OF_RESOURCES);
53 MEI_CL_CS(MESSAGE_SMALL);
54 default: return "unknown";
60 * mei_cl_conn_status_to_errno - convert client connect response
61 * status to error code
63 * @status: client connect response status
65 * returns corresponding error code
67 static int mei_cl_conn_status_to_errno(enum mei_cl_connect_status status)
70 case MEI_CL_CONN_SUCCESS: return 0;
71 case MEI_CL_CONN_NOT_FOUND: return -ENOTTY;
72 case MEI_CL_CONN_ALREADY_STARTED: return -EBUSY;
73 case MEI_CL_CONN_OUT_OF_RESOURCES: return -EBUSY;
74 case MEI_CL_CONN_MESSAGE_SMALL: return -EINVAL;
75 default: return -EINVAL;
80 * mei_hbm_idle - set hbm to idle state
82 * @dev: the device structure
84 void mei_hbm_idle(struct mei_device *dev)
86 dev->init_clients_timer = 0;
87 dev->hbm_state = MEI_HBM_IDLE;
91 * mei_me_cl_remove_all - remove all me clients
93 * @dev: the device structure
95 static void mei_me_cl_remove_all(struct mei_device *dev)
97 struct mei_me_client *me_cl, *next;
98 list_for_each_entry_safe(me_cl, next, &dev->me_clients, list) {
99 list_del(&me_cl->list);
105 * mei_hbm_reset - reset hbm counters and book keeping data structurs
107 * @dev: the device structure
109 void mei_hbm_reset(struct mei_device *dev)
111 dev->me_client_presentation_num = 0;
112 dev->me_client_index = 0;
114 mei_me_cl_remove_all(dev);
120 * mei_hbm_cl_hdr - construct client hbm header
123 * @hbm_cmd: host bus message command
124 * @buf: buffer for cl header
125 * @len: buffer length
128 void mei_hbm_cl_hdr(struct mei_cl *cl, u8 hbm_cmd, void *buf, size_t len)
130 struct mei_hbm_cl_cmd *cmd = buf;
134 cmd->hbm_cmd = hbm_cmd;
135 cmd->host_addr = cl->host_client_id;
136 cmd->me_addr = cl->me_client_id;
140 * mei_hbm_cl_write - write simple hbm client message
142 * @dev: the device structure
144 * @hbm_cmd: host bus message command
145 * @len: buffer length
148 int mei_hbm_cl_write(struct mei_device *dev,
149 struct mei_cl *cl, u8 hbm_cmd, size_t len)
151 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
153 mei_hbm_hdr(mei_hdr, len);
154 mei_hbm_cl_hdr(cl, hbm_cmd, dev->wr_msg.data, len);
156 return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
160 * mei_hbm_cl_addr_equal - check if the client's and
161 * the message address match
164 * @cmd: hbm client message
166 * returns true if addresses are the same
169 bool mei_hbm_cl_addr_equal(struct mei_cl *cl, struct mei_hbm_cl_cmd *cmd)
171 return cl->host_client_id == cmd->host_addr &&
172 cl->me_client_id == cmd->me_addr;
176 * mei_hbm_cl_find_by_cmd - find recipient client
178 * @dev: the device structure
179 * @buf: a buffer with hbm cl command
181 * returns the recipient client or NULL if not found
184 struct mei_cl *mei_hbm_cl_find_by_cmd(struct mei_device *dev, void *buf)
186 struct mei_hbm_cl_cmd *cmd = (struct mei_hbm_cl_cmd *)buf;
189 list_for_each_entry(cl, &dev->file_list, link)
190 if (mei_hbm_cl_addr_equal(cl, cmd))
197 * mei_hbm_start_wait - wait for start response message.
199 * @dev: the device structure
201 * returns 0 on success and < 0 on failure
203 int mei_hbm_start_wait(struct mei_device *dev)
207 if (dev->hbm_state > MEI_HBM_STARTING)
210 mutex_unlock(&dev->device_lock);
211 ret = wait_event_timeout(dev->wait_hbm_start,
212 dev->hbm_state != MEI_HBM_STARTING,
213 mei_secs_to_jiffies(MEI_HBM_TIMEOUT));
214 mutex_lock(&dev->device_lock);
216 if (ret == 0 && (dev->hbm_state <= MEI_HBM_STARTING)) {
217 dev->hbm_state = MEI_HBM_IDLE;
218 dev_err(&dev->pdev->dev, "waiting for mei start failed\n");
225 * mei_hbm_start_req - sends start request message.
227 * @dev: the device structure
229 * returns 0 on success and < 0 on failure
231 int mei_hbm_start_req(struct mei_device *dev)
233 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
234 struct hbm_host_version_request *start_req;
235 const size_t len = sizeof(struct hbm_host_version_request);
240 mei_hbm_hdr(mei_hdr, len);
242 /* host start message */
243 start_req = (struct hbm_host_version_request *)dev->wr_msg.data;
244 memset(start_req, 0, len);
245 start_req->hbm_cmd = HOST_START_REQ_CMD;
246 start_req->host_version.major_version = HBM_MAJOR_VERSION;
247 start_req->host_version.minor_version = HBM_MINOR_VERSION;
249 dev->hbm_state = MEI_HBM_IDLE;
250 ret = mei_write_message(dev, mei_hdr, dev->wr_msg.data);
252 dev_err(&dev->pdev->dev, "version message write failed: ret = %d\n",
257 dev->hbm_state = MEI_HBM_STARTING;
258 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
263 * mei_hbm_enum_clients_req - sends enumeration client request message.
265 * @dev: the device structure
267 * returns 0 on success and < 0 on failure
269 static int mei_hbm_enum_clients_req(struct mei_device *dev)
271 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
272 struct hbm_host_enum_request *enum_req;
273 const size_t len = sizeof(struct hbm_host_enum_request);
276 /* enumerate clients */
277 mei_hbm_hdr(mei_hdr, len);
279 enum_req = (struct hbm_host_enum_request *)dev->wr_msg.data;
280 memset(enum_req, 0, len);
281 enum_req->hbm_cmd = HOST_ENUM_REQ_CMD;
283 ret = mei_write_message(dev, mei_hdr, dev->wr_msg.data);
285 dev_err(&dev->pdev->dev, "enumeration request write failed: ret = %d.\n",
289 dev->hbm_state = MEI_HBM_ENUM_CLIENTS;
290 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
295 * mei_hbm_me_cl_add - add new me client to the list
297 * @dev: the device structure
298 * @res: hbm property response
300 * returns 0 on success and -ENOMEM on allocation failure
303 static int mei_hbm_me_cl_add(struct mei_device *dev,
304 struct hbm_props_response *res)
306 struct mei_me_client *me_cl;
308 me_cl = kzalloc(sizeof(struct mei_me_client), GFP_KERNEL);
312 me_cl->props = res->client_properties;
313 me_cl->client_id = res->me_addr;
314 me_cl->mei_flow_ctrl_creds = 0;
316 list_add(&me_cl->list, &dev->me_clients);
321 * mei_hbm_prop_req - request property for a single client
323 * @dev: the device structure
325 * returns 0 on success and < 0 on failure
328 static int mei_hbm_prop_req(struct mei_device *dev)
331 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
332 struct hbm_props_request *prop_req;
333 const size_t len = sizeof(struct hbm_props_request);
334 unsigned long next_client_index;
337 next_client_index = find_next_bit(dev->me_clients_map, MEI_CLIENTS_MAX,
338 dev->me_client_index);
340 /* We got all client properties */
341 if (next_client_index == MEI_CLIENTS_MAX) {
342 dev->hbm_state = MEI_HBM_STARTED;
343 schedule_work(&dev->init_work);
348 mei_hbm_hdr(mei_hdr, len);
349 prop_req = (struct hbm_props_request *)dev->wr_msg.data;
351 memset(prop_req, 0, sizeof(struct hbm_props_request));
353 prop_req->hbm_cmd = HOST_CLIENT_PROPERTIES_REQ_CMD;
354 prop_req->me_addr = next_client_index;
356 ret = mei_write_message(dev, mei_hdr, dev->wr_msg.data);
358 dev_err(&dev->pdev->dev, "properties request write failed: ret = %d\n",
363 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
364 dev->me_client_index = next_client_index;
370 * mei_hbm_pg - sends pg command
372 * @dev: the device structure
373 * @pg_cmd: the pg command code
375 * This function returns -EIO on write failure
377 int mei_hbm_pg(struct mei_device *dev, u8 pg_cmd)
379 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
380 struct hbm_power_gate *req;
381 const size_t len = sizeof(struct hbm_power_gate);
384 mei_hbm_hdr(mei_hdr, len);
386 req = (struct hbm_power_gate *)dev->wr_msg.data;
388 req->hbm_cmd = pg_cmd;
390 ret = mei_write_message(dev, mei_hdr, dev->wr_msg.data);
392 dev_err(&dev->pdev->dev, "power gate command write failed.\n");
395 EXPORT_SYMBOL_GPL(mei_hbm_pg);
398 * mei_hbm_stop_req - send stop request message
403 * This function returns -EIO on write failure
405 static int mei_hbm_stop_req(struct mei_device *dev)
407 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
408 struct hbm_host_stop_request *req =
409 (struct hbm_host_stop_request *)dev->wr_msg.data;
410 const size_t len = sizeof(struct hbm_host_stop_request);
412 mei_hbm_hdr(mei_hdr, len);
415 req->hbm_cmd = HOST_STOP_REQ_CMD;
416 req->reason = DRIVER_STOP_REQUEST;
418 return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
422 * mei_hbm_cl_flow_control_req - sends flow control request.
424 * @dev: the device structure
427 * This function returns -EIO on write failure
429 int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl)
431 const size_t len = sizeof(struct hbm_flow_control);
432 cl_dbg(dev, cl, "sending flow control\n");
433 return mei_hbm_cl_write(dev, cl, MEI_FLOW_CONTROL_CMD, len);
437 * mei_hbm_add_single_flow_creds - adds single buffer credentials.
439 * @dev: the device structure
440 * @flow: flow control.
442 * return 0 on success, < 0 otherwise
444 static int mei_hbm_add_single_flow_creds(struct mei_device *dev,
445 struct hbm_flow_control *flow)
447 struct mei_me_client *me_cl;
449 me_cl = mei_me_cl_by_id(dev, flow->me_addr);
451 dev_err(&dev->pdev->dev, "no such me client %d\n",
456 if (WARN_ON(me_cl->props.single_recv_buf == 0))
459 me_cl->mei_flow_ctrl_creds++;
460 dev_dbg(&dev->pdev->dev, "recv flow ctrl msg ME %d (single) creds = %d.\n",
461 flow->me_addr, me_cl->mei_flow_ctrl_creds);
467 * mei_hbm_cl_flow_control_res - flow control response from me
469 * @dev: the device structure
470 * @flow_control: flow control response bus message
472 static void mei_hbm_cl_flow_control_res(struct mei_device *dev,
473 struct hbm_flow_control *flow_control)
477 if (!flow_control->host_addr) {
478 /* single receive buffer */
479 mei_hbm_add_single_flow_creds(dev, flow_control);
483 cl = mei_hbm_cl_find_by_cmd(dev, flow_control);
485 cl->mei_flow_ctrl_creds++;
486 cl_dbg(dev, cl, "flow control creds = %d.\n",
487 cl->mei_flow_ctrl_creds);
493 * mei_hbm_cl_disconnect_req - sends disconnect message to fw.
495 * @dev: the device structure
496 * @cl: a client to disconnect from
498 * This function returns -EIO on write failure
500 int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl *cl)
502 const size_t len = sizeof(struct hbm_client_connect_request);
503 return mei_hbm_cl_write(dev, cl, CLIENT_DISCONNECT_REQ_CMD, len);
507 * mei_hbm_cl_disconnect_rsp - sends disconnect respose to the FW
509 * @dev: the device structure
510 * @cl: a client to disconnect from
512 * This function returns -EIO on write failure
514 int mei_hbm_cl_disconnect_rsp(struct mei_device *dev, struct mei_cl *cl)
516 const size_t len = sizeof(struct hbm_client_connect_response);
517 return mei_hbm_cl_write(dev, cl, CLIENT_DISCONNECT_RES_CMD, len);
521 * mei_hbm_cl_disconnect_res - update the client state according
522 * disconnect response
524 * @cl: mei host client
525 * @cmd: disconnect client response host bus message
527 static void mei_hbm_cl_disconnect_res(struct mei_cl *cl,
528 struct mei_hbm_cl_cmd *cmd)
530 struct hbm_client_connect_response *rs =
531 (struct hbm_client_connect_response *)cmd;
533 dev_dbg(&cl->dev->pdev->dev, "hbm: disconnect response cl:host=%02d me=%02d status=%d\n",
534 rs->me_addr, rs->host_addr, rs->status);
536 if (rs->status == MEI_CL_DISCONN_SUCCESS)
537 cl->state = MEI_FILE_DISCONNECTED;
542 * mei_hbm_cl_connect_req - send connection request to specific me client
544 * @dev: the device structure
545 * @cl: a client to connect to
547 * returns -EIO on write failure
549 int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl *cl)
551 const size_t len = sizeof(struct hbm_client_connect_request);
552 return mei_hbm_cl_write(dev, cl, CLIENT_CONNECT_REQ_CMD, len);
556 * mei_hbm_cl_connect_res - update the client state according
557 * connection response
559 * @cl: mei host client
560 * @cmd: connect client response host bus message
562 static void mei_hbm_cl_connect_res(struct mei_cl *cl,
563 struct mei_hbm_cl_cmd *cmd)
565 struct hbm_client_connect_response *rs =
566 (struct hbm_client_connect_response *)cmd;
568 dev_dbg(&cl->dev->pdev->dev, "hbm: connect response cl:host=%02d me=%02d status=%s\n",
569 rs->me_addr, rs->host_addr,
570 mei_cl_conn_status_str(rs->status));
572 if (rs->status == MEI_CL_CONN_SUCCESS)
573 cl->state = MEI_FILE_CONNECTED;
575 cl->state = MEI_FILE_DISCONNECTED;
576 cl->status = mei_cl_conn_status_to_errno(rs->status);
580 * mei_hbm_cl_res - process hbm response received on behalf
583 * @dev: the device structure
584 * @rs: hbm client message
585 * @fop_type: file operation type
587 static void mei_hbm_cl_res(struct mei_device *dev,
588 struct mei_hbm_cl_cmd *rs,
589 enum mei_cb_file_ops fop_type)
592 struct mei_cl_cb *cb, *next;
595 list_for_each_entry_safe(cb, next, &dev->ctrl_rd_list.list, list) {
598 /* this should not happen */
600 list_del_init(&cb->list);
604 if (cb->fop_type != fop_type)
607 if (mei_hbm_cl_addr_equal(cl, rs)) {
617 case MEI_FOP_CONNECT:
618 mei_hbm_cl_connect_res(cl, rs);
620 case MEI_FOP_DISCONNECT:
621 mei_hbm_cl_disconnect_res(cl, rs);
633 * mei_hbm_fw_disconnect_req - disconnect request initiated by ME firmware
634 * host sends disconnect response
636 * @dev: the device structure.
637 * @disconnect_req: disconnect request bus message from the me
639 * returns -ENOMEM on allocation failure
641 static int mei_hbm_fw_disconnect_req(struct mei_device *dev,
642 struct hbm_client_connect_request *disconnect_req)
645 struct mei_cl_cb *cb;
647 cl = mei_hbm_cl_find_by_cmd(dev, disconnect_req);
649 cl_dbg(dev, cl, "disconnect request received\n");
650 cl->state = MEI_FILE_DISCONNECTED;
653 cb = mei_io_cb_init(cl, NULL);
656 cb->fop_type = MEI_FOP_DISCONNECT_RSP;
657 cl_dbg(dev, cl, "add disconnect response as first\n");
658 list_add(&cb->list, &dev->ctrl_wr_list.list);
665 * mei_hbm_version_is_supported - checks whether the driver can
666 * support the hbm version of the device
668 * @dev: the device structure
669 * returns true if driver can support hbm version of the device
671 bool mei_hbm_version_is_supported(struct mei_device *dev)
673 return (dev->version.major_version < HBM_MAJOR_VERSION) ||
674 (dev->version.major_version == HBM_MAJOR_VERSION &&
675 dev->version.minor_version <= HBM_MINOR_VERSION);
679 * mei_hbm_dispatch - bottom half read routine after ISR to
680 * handle the read bus message cmd processing.
682 * @dev: the device structure
683 * @mei_hdr: header of bus message
685 * returns 0 on success and < 0 on failure
687 int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
689 struct mei_bus_message *mei_msg;
690 struct hbm_host_version_response *version_res;
691 struct hbm_props_response *props_res;
692 struct hbm_host_enum_response *enum_res;
694 struct mei_hbm_cl_cmd *cl_cmd;
695 struct hbm_client_connect_request *disconnect_req;
696 struct hbm_flow_control *flow_control;
698 /* read the message to our buffer */
699 BUG_ON(hdr->length >= sizeof(dev->rd_msg_buf));
700 mei_read_slots(dev, dev->rd_msg_buf, hdr->length);
701 mei_msg = (struct mei_bus_message *)dev->rd_msg_buf;
702 cl_cmd = (struct mei_hbm_cl_cmd *)mei_msg;
704 /* ignore spurious message and prevent reset nesting
705 * hbm is put to idle during system reset
707 if (dev->hbm_state == MEI_HBM_IDLE) {
708 dev_dbg(&dev->pdev->dev, "hbm: state is idle ignore spurious messages\n");
712 switch (mei_msg->hbm_cmd) {
713 case HOST_START_RES_CMD:
714 dev_dbg(&dev->pdev->dev, "hbm: start: response message received.\n");
716 dev->init_clients_timer = 0;
718 version_res = (struct hbm_host_version_response *)mei_msg;
720 dev_dbg(&dev->pdev->dev, "HBM VERSION: DRIVER=%02d:%02d DEVICE=%02d:%02d\n",
721 HBM_MAJOR_VERSION, HBM_MINOR_VERSION,
722 version_res->me_max_version.major_version,
723 version_res->me_max_version.minor_version);
725 if (version_res->host_version_supported) {
726 dev->version.major_version = HBM_MAJOR_VERSION;
727 dev->version.minor_version = HBM_MINOR_VERSION;
729 dev->version.major_version =
730 version_res->me_max_version.major_version;
731 dev->version.minor_version =
732 version_res->me_max_version.minor_version;
735 if (!mei_hbm_version_is_supported(dev)) {
736 dev_warn(&dev->pdev->dev, "hbm: start: version mismatch - stopping the driver.\n");
738 dev->hbm_state = MEI_HBM_STOPPED;
739 if (mei_hbm_stop_req(dev)) {
740 dev_err(&dev->pdev->dev, "hbm: start: failed to send stop request\n");
746 if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
747 dev->hbm_state != MEI_HBM_STARTING) {
748 dev_err(&dev->pdev->dev, "hbm: start: state mismatch, [%d, %d]\n",
749 dev->dev_state, dev->hbm_state);
753 dev->hbm_state = MEI_HBM_STARTED;
755 if (mei_hbm_enum_clients_req(dev)) {
756 dev_err(&dev->pdev->dev, "hbm: start: failed to send enumeration request\n");
760 wake_up(&dev->wait_hbm_start);
763 case CLIENT_CONNECT_RES_CMD:
764 dev_dbg(&dev->pdev->dev, "hbm: client connect response: message received.\n");
765 mei_hbm_cl_res(dev, cl_cmd, MEI_FOP_CONNECT);
768 case CLIENT_DISCONNECT_RES_CMD:
769 dev_dbg(&dev->pdev->dev, "hbm: client disconnect response: message received.\n");
770 mei_hbm_cl_res(dev, cl_cmd, MEI_FOP_DISCONNECT);
773 case MEI_FLOW_CONTROL_CMD:
774 dev_dbg(&dev->pdev->dev, "hbm: client flow control response: message received.\n");
776 flow_control = (struct hbm_flow_control *) mei_msg;
777 mei_hbm_cl_flow_control_res(dev, flow_control);
780 case MEI_PG_ISOLATION_ENTRY_RES_CMD:
781 dev_dbg(&dev->pdev->dev, "power gate isolation entry response received\n");
782 dev->pg_event = MEI_PG_EVENT_RECEIVED;
783 if (waitqueue_active(&dev->wait_pg))
784 wake_up(&dev->wait_pg);
787 case MEI_PG_ISOLATION_EXIT_REQ_CMD:
788 dev_dbg(&dev->pdev->dev, "power gate isolation exit request received\n");
789 dev->pg_event = MEI_PG_EVENT_RECEIVED;
790 if (waitqueue_active(&dev->wait_pg))
791 wake_up(&dev->wait_pg);
794 * If the driver is not waiting on this then
795 * this is HW initiated exit from PG.
796 * Start runtime pm resume sequence to exit from PG.
798 pm_request_resume(&dev->pdev->dev);
801 case HOST_CLIENT_PROPERTIES_RES_CMD:
802 dev_dbg(&dev->pdev->dev, "hbm: properties response: message received.\n");
804 dev->init_clients_timer = 0;
806 if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
807 dev->hbm_state != MEI_HBM_CLIENT_PROPERTIES) {
808 dev_err(&dev->pdev->dev, "hbm: properties response: state mismatch, [%d, %d]\n",
809 dev->dev_state, dev->hbm_state);
813 props_res = (struct hbm_props_response *)mei_msg;
815 if (props_res->status) {
816 dev_err(&dev->pdev->dev, "hbm: properties response: wrong status = %d %s\n",
818 mei_hbm_status_str(props_res->status));
822 mei_hbm_me_cl_add(dev, props_res);
824 dev->me_client_index++;
825 dev->me_client_presentation_num++;
827 /* request property for the next client */
828 if (mei_hbm_prop_req(dev))
833 case HOST_ENUM_RES_CMD:
834 dev_dbg(&dev->pdev->dev, "hbm: enumeration response: message received\n");
836 dev->init_clients_timer = 0;
838 enum_res = (struct hbm_host_enum_response *) mei_msg;
839 BUILD_BUG_ON(sizeof(dev->me_clients_map)
840 < sizeof(enum_res->valid_addresses));
841 memcpy(dev->me_clients_map, enum_res->valid_addresses,
842 sizeof(enum_res->valid_addresses));
844 if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
845 dev->hbm_state != MEI_HBM_ENUM_CLIENTS) {
846 dev_err(&dev->pdev->dev, "hbm: enumeration response: state mismatch, [%d, %d]\n",
847 dev->dev_state, dev->hbm_state);
851 dev->hbm_state = MEI_HBM_CLIENT_PROPERTIES;
853 /* first property request */
854 if (mei_hbm_prop_req(dev))
859 case HOST_STOP_RES_CMD:
860 dev_dbg(&dev->pdev->dev, "hbm: stop response: message received\n");
862 dev->init_clients_timer = 0;
864 if (dev->hbm_state != MEI_HBM_STOPPED) {
865 dev_err(&dev->pdev->dev, "hbm: stop response: state mismatch, [%d, %d]\n",
866 dev->dev_state, dev->hbm_state);
870 dev->dev_state = MEI_DEV_POWER_DOWN;
871 dev_info(&dev->pdev->dev, "hbm: stop response: resetting.\n");
872 /* force the reset */
876 case CLIENT_DISCONNECT_REQ_CMD:
877 dev_dbg(&dev->pdev->dev, "hbm: disconnect request: message received\n");
879 disconnect_req = (struct hbm_client_connect_request *)mei_msg;
880 mei_hbm_fw_disconnect_req(dev, disconnect_req);
883 case ME_STOP_REQ_CMD:
884 dev_dbg(&dev->pdev->dev, "hbm: stop request: message received\n");
885 dev->hbm_state = MEI_HBM_STOPPED;
886 if (mei_hbm_stop_req(dev)) {
887 dev_err(&dev->pdev->dev, "hbm: stop request: failed to send stop request\n");