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_cl_conn_status_str(enum mei_cl_connect_status status)
30 #define MEI_CL_CS(status) case MEI_CL_CONN_##status: return #status
34 MEI_CL_CS(ALREADY_STARTED);
35 MEI_CL_CS(OUT_OF_RESOURCES);
36 MEI_CL_CS(MESSAGE_SMALL);
37 default: return "unknown";
43 * mei_cl_conn_status_to_errno - convert client connect response
44 * status to error code
46 * @status: client connect response status
48 * returns corresponding error code
50 static int mei_cl_conn_status_to_errno(enum mei_cl_connect_status status)
53 case MEI_CL_CONN_SUCCESS: return 0;
54 case MEI_CL_CONN_NOT_FOUND: return -ENOTTY;
55 case MEI_CL_CONN_ALREADY_STARTED: return -EBUSY;
56 case MEI_CL_CONN_OUT_OF_RESOURCES: return -EBUSY;
57 case MEI_CL_CONN_MESSAGE_SMALL: return -EINVAL;
58 default: return -EINVAL;
63 * mei_hbm_idle - set hbm to idle state
65 * @dev: the device structure
67 void mei_hbm_idle(struct mei_device *dev)
69 dev->init_clients_timer = 0;
70 dev->hbm_state = MEI_HBM_IDLE;
74 * mei_hbm_reset - reset hbm counters and book keeping data structurs
76 * @dev: the device structure
78 void mei_hbm_reset(struct mei_device *dev)
80 dev->me_clients_num = 0;
81 dev->me_client_presentation_num = 0;
82 dev->me_client_index = 0;
84 kfree(dev->me_clients);
85 dev->me_clients = NULL;
91 * mei_hbm_me_cl_allocate - allocates storage for me clients
93 * @dev: the device structure
95 * returns 0 on success -ENOMEM on allocation failure
97 static int mei_hbm_me_cl_allocate(struct mei_device *dev)
99 struct mei_me_client *clients;
104 /* count how many ME clients we have */
105 for_each_set_bit(b, dev->me_clients_map, MEI_CLIENTS_MAX)
106 dev->me_clients_num++;
108 if (dev->me_clients_num == 0)
111 dev_dbg(&dev->pdev->dev, "memory allocation for ME clients size=%ld.\n",
112 dev->me_clients_num * sizeof(struct mei_me_client));
113 /* allocate storage for ME clients representation */
114 clients = kcalloc(dev->me_clients_num,
115 sizeof(struct mei_me_client), GFP_KERNEL);
117 dev_err(&dev->pdev->dev, "memory allocation for ME clients failed.\n");
120 dev->me_clients = clients;
125 * mei_hbm_cl_hdr - construct client hbm header
128 * @hbm_cmd: host bus message command
129 * @buf: buffer for cl header
130 * @len: buffer length
133 void mei_hbm_cl_hdr(struct mei_cl *cl, u8 hbm_cmd, void *buf, size_t len)
135 struct mei_hbm_cl_cmd *cmd = buf;
139 cmd->hbm_cmd = hbm_cmd;
140 cmd->host_addr = cl->host_client_id;
141 cmd->me_addr = cl->me_client_id;
145 * mei_hbm_cl_write - write simple hbm client message
147 * @dev: the device structure
149 * @hbm_cmd: host bus message command
150 * @len: buffer length
153 int mei_hbm_cl_write(struct mei_device *dev,
154 struct mei_cl *cl, u8 hbm_cmd, size_t len)
156 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
158 mei_hbm_hdr(mei_hdr, len);
159 mei_hbm_cl_hdr(cl, hbm_cmd, dev->wr_msg.data, len);
161 return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
165 * mei_hbm_cl_addr_equal - tells if they have the same address
168 * @buf: buffer with cl header
170 * returns true if addresses are the same
173 bool mei_hbm_cl_addr_equal(struct mei_cl *cl, void *buf)
175 struct mei_hbm_cl_cmd *cmd = buf;
176 return cl->host_client_id == cmd->host_addr &&
177 cl->me_client_id == cmd->me_addr;
181 int mei_hbm_start_wait(struct mei_device *dev)
184 if (dev->hbm_state > MEI_HBM_START)
187 mutex_unlock(&dev->device_lock);
188 ret = wait_event_interruptible_timeout(dev->wait_recvd_msg,
189 dev->hbm_state == MEI_HBM_IDLE ||
190 dev->hbm_state >= MEI_HBM_STARTED,
191 mei_secs_to_jiffies(MEI_HBM_TIMEOUT));
192 mutex_lock(&dev->device_lock);
194 if (ret <= 0 && (dev->hbm_state <= MEI_HBM_START)) {
195 dev->hbm_state = MEI_HBM_IDLE;
196 dev_err(&dev->pdev->dev, "waiting for mei start failed\n");
203 * mei_hbm_start_req - sends start request message.
205 * @dev: the device structure
207 * returns 0 on success and < 0 on failure
209 int mei_hbm_start_req(struct mei_device *dev)
211 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
212 struct hbm_host_version_request *start_req;
213 const size_t len = sizeof(struct hbm_host_version_request);
216 mei_hbm_hdr(mei_hdr, len);
218 /* host start message */
219 start_req = (struct hbm_host_version_request *)dev->wr_msg.data;
220 memset(start_req, 0, len);
221 start_req->hbm_cmd = HOST_START_REQ_CMD;
222 start_req->host_version.major_version = HBM_MAJOR_VERSION;
223 start_req->host_version.minor_version = HBM_MINOR_VERSION;
225 dev->hbm_state = MEI_HBM_IDLE;
226 ret = mei_write_message(dev, mei_hdr, dev->wr_msg.data);
228 dev_err(&dev->pdev->dev, "version message write failed: ret = %d\n",
233 dev->hbm_state = MEI_HBM_START;
234 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
239 * mei_hbm_enum_clients_req - sends enumeration client request message.
241 * @dev: the device structure
243 * returns 0 on success and < 0 on failure
245 static int mei_hbm_enum_clients_req(struct mei_device *dev)
247 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
248 struct hbm_host_enum_request *enum_req;
249 const size_t len = sizeof(struct hbm_host_enum_request);
252 /* enumerate clients */
253 mei_hbm_hdr(mei_hdr, len);
255 enum_req = (struct hbm_host_enum_request *)dev->wr_msg.data;
256 memset(enum_req, 0, len);
257 enum_req->hbm_cmd = HOST_ENUM_REQ_CMD;
259 ret = mei_write_message(dev, mei_hdr, dev->wr_msg.data);
261 dev_err(&dev->pdev->dev, "enumeration request write failed: ret = %d.\n",
265 dev->hbm_state = MEI_HBM_ENUM_CLIENTS;
266 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
271 * mei_hbm_prop_req - request property for a single client
273 * @dev: the device structure
275 * returns 0 on success and < 0 on failure
278 static int mei_hbm_prop_req(struct mei_device *dev)
281 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
282 struct hbm_props_request *prop_req;
283 const size_t len = sizeof(struct hbm_props_request);
284 unsigned long next_client_index;
285 unsigned long client_num;
288 client_num = dev->me_client_presentation_num;
290 next_client_index = find_next_bit(dev->me_clients_map, MEI_CLIENTS_MAX,
291 dev->me_client_index);
293 /* We got all client properties */
294 if (next_client_index == MEI_CLIENTS_MAX) {
295 dev->hbm_state = MEI_HBM_STARTED;
296 schedule_work(&dev->init_work);
301 dev->me_clients[client_num].client_id = next_client_index;
302 dev->me_clients[client_num].mei_flow_ctrl_creds = 0;
304 mei_hbm_hdr(mei_hdr, len);
305 prop_req = (struct hbm_props_request *)dev->wr_msg.data;
307 memset(prop_req, 0, sizeof(struct hbm_props_request));
310 prop_req->hbm_cmd = HOST_CLIENT_PROPERTIES_REQ_CMD;
311 prop_req->me_addr = next_client_index;
313 ret = mei_write_message(dev, mei_hdr, dev->wr_msg.data);
315 dev_err(&dev->pdev->dev, "properties request write failed: ret = %d\n",
320 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
321 dev->me_client_index = next_client_index;
327 * mei_hbm_pg - sends pg command
329 * @dev: the device structure
330 * @pg_cmd: the pg command code
332 * This function returns -EIO on write failure
334 int mei_hbm_pg(struct mei_device *dev, u8 pg_cmd)
336 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
337 struct hbm_power_gate *req;
338 const size_t len = sizeof(struct hbm_power_gate);
341 mei_hbm_hdr(mei_hdr, len);
343 req = (struct hbm_power_gate *)dev->wr_msg.data;
345 req->hbm_cmd = pg_cmd;
347 ret = mei_write_message(dev, mei_hdr, dev->wr_msg.data);
349 dev_err(&dev->pdev->dev, "power gate command write failed.\n");
352 EXPORT_SYMBOL_GPL(mei_hbm_pg);
355 * mei_hbm_stop_req - send stop request message
360 * This function returns -EIO on write failure
362 static int mei_hbm_stop_req(struct mei_device *dev)
364 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
365 struct hbm_host_stop_request *req =
366 (struct hbm_host_stop_request *)dev->wr_msg.data;
367 const size_t len = sizeof(struct hbm_host_stop_request);
369 mei_hbm_hdr(mei_hdr, len);
372 req->hbm_cmd = HOST_STOP_REQ_CMD;
373 req->reason = DRIVER_STOP_REQUEST;
375 return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
379 * mei_hbm_cl_flow_control_req - sends flow control request.
381 * @dev: the device structure
384 * This function returns -EIO on write failure
386 int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl)
388 const size_t len = sizeof(struct hbm_flow_control);
389 cl_dbg(dev, cl, "sending flow control\n");
390 return mei_hbm_cl_write(dev, cl, MEI_FLOW_CONTROL_CMD, len);
394 * mei_hbm_add_single_flow_creds - adds single buffer credentials.
396 * @dev: the device structure
397 * @flow: flow control.
399 * return 0 on success, < 0 otherwise
401 static int mei_hbm_add_single_flow_creds(struct mei_device *dev,
402 struct hbm_flow_control *flow)
404 struct mei_me_client *me_cl;
406 me_cl = mei_me_cl_by_id(dev, flow->me_addr);
408 dev_err(&dev->pdev->dev, "no such me client %d\n",
413 if (WARN_ON(me_cl->props.single_recv_buf == 0))
416 me_cl->mei_flow_ctrl_creds++;
417 dev_dbg(&dev->pdev->dev, "recv flow ctrl msg ME %d (single) creds = %d.\n",
418 flow->me_addr, me_cl->mei_flow_ctrl_creds);
424 * mei_hbm_cl_flow_control_res - flow control response from me
426 * @dev: the device structure
427 * @flow_control: flow control response bus message
429 static void mei_hbm_cl_flow_control_res(struct mei_device *dev,
430 struct hbm_flow_control *flow_control)
434 if (!flow_control->host_addr) {
435 /* single receive buffer */
436 mei_hbm_add_single_flow_creds(dev, flow_control);
440 /* normal connection */
441 list_for_each_entry(cl, &dev->file_list, link) {
442 if (mei_hbm_cl_addr_equal(cl, flow_control)) {
443 cl->mei_flow_ctrl_creds++;
444 dev_dbg(&dev->pdev->dev, "flow ctrl msg for host %d ME %d.\n",
445 flow_control->host_addr, flow_control->me_addr);
446 dev_dbg(&dev->pdev->dev, "flow control credentials = %d.\n",
447 cl->mei_flow_ctrl_creds);
455 * mei_hbm_cl_disconnect_req - sends disconnect message to fw.
457 * @dev: the device structure
458 * @cl: a client to disconnect from
460 * This function returns -EIO on write failure
462 int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl *cl)
464 const size_t len = sizeof(struct hbm_client_connect_request);
465 return mei_hbm_cl_write(dev, cl, CLIENT_DISCONNECT_REQ_CMD, len);
469 * mei_hbm_cl_disconnect_rsp - sends disconnect respose to the FW
471 * @dev: the device structure
472 * @cl: a client to disconnect from
474 * This function returns -EIO on write failure
476 int mei_hbm_cl_disconnect_rsp(struct mei_device *dev, struct mei_cl *cl)
478 const size_t len = sizeof(struct hbm_client_connect_response);
479 return mei_hbm_cl_write(dev, cl, CLIENT_DISCONNECT_RES_CMD, len);
483 * mei_hbm_cl_disconnect_res - disconnect response from ME
485 * @dev: the device structure
486 * @rs: disconnect response bus message
488 static void mei_hbm_cl_disconnect_res(struct mei_device *dev,
489 struct hbm_client_connect_response *rs)
492 struct mei_cl_cb *cb, *next;
494 dev_dbg(&dev->pdev->dev, "hbm: disconnect response cl:host=%02d me=%02d status=%d\n",
495 rs->me_addr, rs->host_addr, rs->status);
497 list_for_each_entry_safe(cb, next, &dev->ctrl_rd_list.list, list) {
500 /* this should not happen */
506 if (mei_hbm_cl_addr_equal(cl, rs)) {
508 if (rs->status == MEI_CL_DISCONN_SUCCESS)
509 cl->state = MEI_FILE_DISCONNECTED;
519 * mei_hbm_cl_connect_req - send connection request to specific me client
521 * @dev: the device structure
522 * @cl: a client to connect to
524 * returns -EIO on write failure
526 int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl *cl)
528 const size_t len = sizeof(struct hbm_client_connect_request);
529 return mei_hbm_cl_write(dev, cl, CLIENT_CONNECT_REQ_CMD, len);
533 * mei_hbm_cl_connect_res - connect response from the ME
535 * @dev: the device structure
536 * @rs: connect response bus message
538 static void mei_hbm_cl_connect_res(struct mei_device *dev,
539 struct hbm_client_connect_response *rs)
543 struct mei_cl_cb *cb, *next;
545 dev_dbg(&dev->pdev->dev, "hbm: connect response cl:host=%02d me=%02d status=%s\n",
546 rs->me_addr, rs->host_addr,
547 mei_cl_conn_status_str(rs->status));
551 list_for_each_entry_safe(cb, next, &dev->ctrl_rd_list.list, list) {
554 /* this should not happen */
556 list_del_init(&cb->list);
560 if (cb->fop_type != MEI_FOP_CONNECT)
563 if (mei_hbm_cl_addr_equal(cl, rs)) {
573 if (rs->status == MEI_CL_CONN_SUCCESS)
574 cl->state = MEI_FILE_CONNECTED;
576 cl->state = MEI_FILE_DISCONNECTED;
577 cl->status = mei_cl_conn_status_to_errno(rs->status);
582 * mei_hbm_fw_disconnect_req - disconnect request initiated by ME firmware
583 * host sends disconnect response
585 * @dev: the device structure.
586 * @disconnect_req: disconnect request bus message from the me
588 * returns -ENOMEM on allocation failure
590 static int mei_hbm_fw_disconnect_req(struct mei_device *dev,
591 struct hbm_client_connect_request *disconnect_req)
594 struct mei_cl_cb *cb;
596 list_for_each_entry(cl, &dev->file_list, link) {
597 if (mei_hbm_cl_addr_equal(cl, disconnect_req)) {
598 dev_dbg(&dev->pdev->dev, "disconnect request host client %d ME client %d.\n",
599 disconnect_req->host_addr,
600 disconnect_req->me_addr);
601 cl->state = MEI_FILE_DISCONNECTED;
604 cb = mei_io_cb_init(cl, NULL);
607 cb->fop_type = MEI_FOP_DISCONNECT_RSP;
608 cl_dbg(dev, cl, "add disconnect response as first\n");
609 list_add(&cb->list, &dev->ctrl_wr_list.list);
619 * mei_hbm_version_is_supported - checks whether the driver can
620 * support the hbm version of the device
622 * @dev: the device structure
623 * returns true if driver can support hbm version of the device
625 bool mei_hbm_version_is_supported(struct mei_device *dev)
627 return (dev->version.major_version < HBM_MAJOR_VERSION) ||
628 (dev->version.major_version == HBM_MAJOR_VERSION &&
629 dev->version.minor_version <= HBM_MINOR_VERSION);
633 * mei_hbm_dispatch - bottom half read routine after ISR to
634 * handle the read bus message cmd processing.
636 * @dev: the device structure
637 * @mei_hdr: header of bus message
639 * returns 0 on success and < 0 on failure
641 int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
643 struct mei_bus_message *mei_msg;
644 struct mei_me_client *me_client;
645 struct hbm_host_version_response *version_res;
646 struct hbm_client_connect_response *connect_res;
647 struct hbm_client_connect_response *disconnect_res;
648 struct hbm_client_connect_request *disconnect_req;
649 struct hbm_flow_control *flow_control;
650 struct hbm_props_response *props_res;
651 struct hbm_host_enum_response *enum_res;
653 /* read the message to our buffer */
654 BUG_ON(hdr->length >= sizeof(dev->rd_msg_buf));
655 mei_read_slots(dev, dev->rd_msg_buf, hdr->length);
656 mei_msg = (struct mei_bus_message *)dev->rd_msg_buf;
658 /* ignore spurious message and prevent reset nesting
659 * hbm is put to idle during system reset
661 if (dev->hbm_state == MEI_HBM_IDLE) {
662 dev_dbg(&dev->pdev->dev, "hbm: state is idle ignore spurious messages\n");
666 switch (mei_msg->hbm_cmd) {
667 case HOST_START_RES_CMD:
668 dev_dbg(&dev->pdev->dev, "hbm: start: response message received.\n");
670 dev->init_clients_timer = 0;
672 version_res = (struct hbm_host_version_response *)mei_msg;
674 dev_dbg(&dev->pdev->dev, "HBM VERSION: DRIVER=%02d:%02d DEVICE=%02d:%02d\n",
675 HBM_MAJOR_VERSION, HBM_MINOR_VERSION,
676 version_res->me_max_version.major_version,
677 version_res->me_max_version.minor_version);
679 if (version_res->host_version_supported) {
680 dev->version.major_version = HBM_MAJOR_VERSION;
681 dev->version.minor_version = HBM_MINOR_VERSION;
683 dev->version.major_version =
684 version_res->me_max_version.major_version;
685 dev->version.minor_version =
686 version_res->me_max_version.minor_version;
689 if (!mei_hbm_version_is_supported(dev)) {
690 dev_warn(&dev->pdev->dev, "hbm: start: version mismatch - stopping the driver.\n");
692 dev->hbm_state = MEI_HBM_STOPPED;
693 if (mei_hbm_stop_req(dev)) {
694 dev_err(&dev->pdev->dev, "hbm: start: failed to send stop request\n");
700 if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
701 dev->hbm_state != MEI_HBM_START) {
702 dev_err(&dev->pdev->dev, "hbm: start: state mismatch, [%d, %d]\n",
703 dev->dev_state, dev->hbm_state);
707 dev->hbm_state = MEI_HBM_STARTED;
709 if (mei_hbm_enum_clients_req(dev)) {
710 dev_err(&dev->pdev->dev, "hbm: start: failed to send enumeration request\n");
714 wake_up_interruptible(&dev->wait_recvd_msg);
717 case CLIENT_CONNECT_RES_CMD:
718 dev_dbg(&dev->pdev->dev, "hbm: client connect response: message received.\n");
720 connect_res = (struct hbm_client_connect_response *) mei_msg;
721 mei_hbm_cl_connect_res(dev, connect_res);
722 wake_up(&dev->wait_recvd_msg);
725 case CLIENT_DISCONNECT_RES_CMD:
726 dev_dbg(&dev->pdev->dev, "hbm: client disconnect response: message received.\n");
728 disconnect_res = (struct hbm_client_connect_response *) mei_msg;
729 mei_hbm_cl_disconnect_res(dev, disconnect_res);
730 wake_up(&dev->wait_recvd_msg);
733 case MEI_FLOW_CONTROL_CMD:
734 dev_dbg(&dev->pdev->dev, "hbm: client flow control response: message received.\n");
736 flow_control = (struct hbm_flow_control *) mei_msg;
737 mei_hbm_cl_flow_control_res(dev, flow_control);
740 case MEI_PG_ISOLATION_ENTRY_RES_CMD:
741 dev_dbg(&dev->pdev->dev, "power gate isolation entry response received\n");
742 dev->pg_event = MEI_PG_EVENT_RECEIVED;
743 if (waitqueue_active(&dev->wait_pg))
744 wake_up(&dev->wait_pg);
747 case MEI_PG_ISOLATION_EXIT_REQ_CMD:
748 dev_dbg(&dev->pdev->dev, "power gate isolation exit request received\n");
749 dev->pg_event = MEI_PG_EVENT_RECEIVED;
750 if (waitqueue_active(&dev->wait_pg))
751 wake_up(&dev->wait_pg);
754 * If the driver is not waiting on this then
755 * this is HW initiated exit from PG.
756 * Start runtime pm resume sequence to exit from PG.
758 pm_request_resume(&dev->pdev->dev);
761 case HOST_CLIENT_PROPERTIES_RES_CMD:
762 dev_dbg(&dev->pdev->dev, "hbm: properties response: message received.\n");
764 dev->init_clients_timer = 0;
766 if (dev->me_clients == NULL) {
767 dev_err(&dev->pdev->dev, "hbm: properties response: mei_clients not allocated\n");
771 props_res = (struct hbm_props_response *)mei_msg;
772 me_client = &dev->me_clients[dev->me_client_presentation_num];
774 if (props_res->status) {
775 dev_err(&dev->pdev->dev, "hbm: properties response: wrong status = %d\n",
780 if (me_client->client_id != props_res->me_addr) {
781 dev_err(&dev->pdev->dev, "hbm: properties response: address mismatch %d ?= %d\n",
782 me_client->client_id, props_res->me_addr);
786 if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
787 dev->hbm_state != MEI_HBM_CLIENT_PROPERTIES) {
788 dev_err(&dev->pdev->dev, "hbm: properties response: state mismatch, [%d, %d]\n",
789 dev->dev_state, dev->hbm_state);
793 me_client->props = props_res->client_properties;
794 dev->me_client_index++;
795 dev->me_client_presentation_num++;
797 /* request property for the next client */
798 if (mei_hbm_prop_req(dev))
803 case HOST_ENUM_RES_CMD:
804 dev_dbg(&dev->pdev->dev, "hbm: enumeration response: message received\n");
806 dev->init_clients_timer = 0;
808 enum_res = (struct hbm_host_enum_response *) mei_msg;
809 BUILD_BUG_ON(sizeof(dev->me_clients_map)
810 < sizeof(enum_res->valid_addresses));
811 memcpy(dev->me_clients_map, enum_res->valid_addresses,
812 sizeof(enum_res->valid_addresses));
814 if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
815 dev->hbm_state != MEI_HBM_ENUM_CLIENTS) {
816 dev_err(&dev->pdev->dev, "hbm: enumeration response: state mismatch, [%d, %d]\n",
817 dev->dev_state, dev->hbm_state);
821 if (mei_hbm_me_cl_allocate(dev)) {
822 dev_err(&dev->pdev->dev, "hbm: enumeration response: cannot allocate clients array\n");
826 dev->hbm_state = MEI_HBM_CLIENT_PROPERTIES;
828 /* first property request */
829 if (mei_hbm_prop_req(dev))
834 case HOST_STOP_RES_CMD:
835 dev_dbg(&dev->pdev->dev, "hbm: stop response: message received\n");
837 dev->init_clients_timer = 0;
839 if (dev->hbm_state != MEI_HBM_STOPPED) {
840 dev_err(&dev->pdev->dev, "hbm: stop response: state mismatch, [%d, %d]\n",
841 dev->dev_state, dev->hbm_state);
845 dev->dev_state = MEI_DEV_POWER_DOWN;
846 dev_info(&dev->pdev->dev, "hbm: stop response: resetting.\n");
847 /* force the reset */
851 case CLIENT_DISCONNECT_REQ_CMD:
852 dev_dbg(&dev->pdev->dev, "hbm: disconnect request: message received\n");
854 disconnect_req = (struct hbm_client_connect_request *)mei_msg;
855 mei_hbm_fw_disconnect_req(dev, disconnect_req);
858 case ME_STOP_REQ_CMD:
859 dev_dbg(&dev->pdev->dev, "hbm: stop request: message received\n");
860 dev->hbm_state = MEI_HBM_STOPPED;
861 if (mei_hbm_stop_req(dev)) {
862 dev_err(&dev->pdev->dev, "hbm: start: failed to send stop request\n");