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/sched.h>
19 #include <linux/wait.h>
20 #include <linux/pm_runtime.h>
21 #include <linux/slab.h>
23 #include <linux/mei.h>
29 static const char *mei_hbm_status_str(enum mei_hbm_status status)
31 #define MEI_HBM_STATUS(status) case MEI_HBMS_##status: return #status
33 MEI_HBM_STATUS(SUCCESS);
34 MEI_HBM_STATUS(CLIENT_NOT_FOUND);
35 MEI_HBM_STATUS(ALREADY_EXISTS);
36 MEI_HBM_STATUS(REJECTED);
37 MEI_HBM_STATUS(INVALID_PARAMETER);
38 MEI_HBM_STATUS(NOT_ALLOWED);
39 MEI_HBM_STATUS(ALREADY_STARTED);
40 MEI_HBM_STATUS(NOT_STARTED);
41 default: return "unknown";
46 static const char *mei_cl_conn_status_str(enum mei_cl_connect_status status)
48 #define MEI_CL_CS(status) case MEI_CL_CONN_##status: return #status
52 MEI_CL_CS(ALREADY_STARTED);
53 MEI_CL_CS(OUT_OF_RESOURCES);
54 MEI_CL_CS(MESSAGE_SMALL);
55 default: return "unknown";
60 const char *mei_hbm_state_str(enum mei_hbm_state state)
62 #define MEI_HBM_STATE(state) case MEI_HBM_##state: return #state
65 MEI_HBM_STATE(STARTING);
66 MEI_HBM_STATE(STARTED);
67 MEI_HBM_STATE(ENUM_CLIENTS);
68 MEI_HBM_STATE(CLIENT_PROPERTIES);
69 MEI_HBM_STATE(STOPPED);
77 * mei_cl_conn_status_to_errno - convert client connect response
78 * status to error code
80 * @status: client connect response status
82 * Return: corresponding error code
84 static int mei_cl_conn_status_to_errno(enum mei_cl_connect_status status)
87 case MEI_CL_CONN_SUCCESS: return 0;
88 case MEI_CL_CONN_NOT_FOUND: return -ENOTTY;
89 case MEI_CL_CONN_ALREADY_STARTED: return -EBUSY;
90 case MEI_CL_CONN_OUT_OF_RESOURCES: return -EBUSY;
91 case MEI_CL_CONN_MESSAGE_SMALL: return -EINVAL;
92 default: return -EINVAL;
97 * mei_hbm_idle - set hbm to idle state
99 * @dev: the device structure
101 void mei_hbm_idle(struct mei_device *dev)
103 dev->init_clients_timer = 0;
104 dev->hbm_state = MEI_HBM_IDLE;
108 * mei_me_cl_remove_all - remove all me clients
110 * @dev: the device structure
112 static void mei_me_cl_remove_all(struct mei_device *dev)
114 struct mei_me_client *me_cl, *next;
116 list_for_each_entry_safe(me_cl, next, &dev->me_clients, list) {
117 list_del(&me_cl->list);
123 * mei_hbm_reset - reset hbm counters and book keeping data structurs
125 * @dev: the device structure
127 void mei_hbm_reset(struct mei_device *dev)
129 dev->me_client_index = 0;
131 mei_me_cl_remove_all(dev);
137 * mei_hbm_hdr - construct hbm header
140 * @length: payload length
143 static inline void mei_hbm_hdr(struct mei_msg_hdr *hdr, size_t length)
147 hdr->length = length;
148 hdr->msg_complete = 1;
153 * mei_hbm_cl_hdr - construct client hbm header
156 * @hbm_cmd: host bus message command
157 * @buf: buffer for cl header
158 * @len: buffer length
161 void mei_hbm_cl_hdr(struct mei_cl *cl, u8 hbm_cmd, void *buf, size_t len)
163 struct mei_hbm_cl_cmd *cmd = buf;
167 cmd->hbm_cmd = hbm_cmd;
168 cmd->host_addr = cl->host_client_id;
169 cmd->me_addr = cl->me_client_id;
173 * mei_hbm_cl_write - write simple hbm client message
175 * @dev: the device structure
177 * @hbm_cmd: host bus message command
178 * @len: buffer length
180 * Return: 0 on success, <0 on failure.
183 int mei_hbm_cl_write(struct mei_device *dev,
184 struct mei_cl *cl, u8 hbm_cmd, size_t len)
186 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
188 mei_hbm_hdr(mei_hdr, len);
189 mei_hbm_cl_hdr(cl, hbm_cmd, dev->wr_msg.data, len);
191 return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
195 * mei_hbm_cl_addr_equal - check if the client's and
196 * the message address match
199 * @cmd: hbm client message
201 * Return: true if addresses are the same
204 bool mei_hbm_cl_addr_equal(struct mei_cl *cl, struct mei_hbm_cl_cmd *cmd)
206 return cl->host_client_id == cmd->host_addr &&
207 cl->me_client_id == cmd->me_addr;
211 * mei_hbm_cl_find_by_cmd - find recipient client
213 * @dev: the device structure
214 * @buf: a buffer with hbm cl command
216 * Return: the recipient client or NULL if not found
219 struct mei_cl *mei_hbm_cl_find_by_cmd(struct mei_device *dev, void *buf)
221 struct mei_hbm_cl_cmd *cmd = (struct mei_hbm_cl_cmd *)buf;
224 list_for_each_entry(cl, &dev->file_list, link)
225 if (mei_hbm_cl_addr_equal(cl, cmd))
232 * mei_hbm_start_wait - wait for start response message.
234 * @dev: the device structure
236 * Return: 0 on success and < 0 on failure
238 int mei_hbm_start_wait(struct mei_device *dev)
242 if (dev->hbm_state > MEI_HBM_STARTING)
245 mutex_unlock(&dev->device_lock);
246 ret = wait_event_timeout(dev->wait_hbm_start,
247 dev->hbm_state != MEI_HBM_STARTING,
248 mei_secs_to_jiffies(MEI_HBM_TIMEOUT));
249 mutex_lock(&dev->device_lock);
251 if (ret == 0 && (dev->hbm_state <= MEI_HBM_STARTING)) {
252 dev->hbm_state = MEI_HBM_IDLE;
253 dev_err(dev->dev, "waiting for mei start failed\n");
260 * mei_hbm_start_req - sends start request message.
262 * @dev: the device structure
264 * Return: 0 on success and < 0 on failure
266 int mei_hbm_start_req(struct mei_device *dev)
268 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
269 struct hbm_host_version_request *start_req;
270 const size_t len = sizeof(struct hbm_host_version_request);
275 mei_hbm_hdr(mei_hdr, len);
277 /* host start message */
278 start_req = (struct hbm_host_version_request *)dev->wr_msg.data;
279 memset(start_req, 0, len);
280 start_req->hbm_cmd = HOST_START_REQ_CMD;
281 start_req->host_version.major_version = HBM_MAJOR_VERSION;
282 start_req->host_version.minor_version = HBM_MINOR_VERSION;
284 dev->hbm_state = MEI_HBM_IDLE;
285 ret = mei_write_message(dev, mei_hdr, dev->wr_msg.data);
287 dev_err(dev->dev, "version message write failed: ret = %d\n",
292 dev->hbm_state = MEI_HBM_STARTING;
293 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
298 * mei_hbm_enum_clients_req - sends enumeration client request message.
300 * @dev: the device structure
302 * Return: 0 on success and < 0 on failure
304 static int mei_hbm_enum_clients_req(struct mei_device *dev)
306 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
307 struct hbm_host_enum_request *enum_req;
308 const size_t len = sizeof(struct hbm_host_enum_request);
311 /* enumerate clients */
312 mei_hbm_hdr(mei_hdr, len);
314 enum_req = (struct hbm_host_enum_request *)dev->wr_msg.data;
315 memset(enum_req, 0, len);
316 enum_req->hbm_cmd = HOST_ENUM_REQ_CMD;
318 ret = mei_write_message(dev, mei_hdr, dev->wr_msg.data);
320 dev_err(dev->dev, "enumeration request write failed: ret = %d.\n",
324 dev->hbm_state = MEI_HBM_ENUM_CLIENTS;
325 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
330 * mei_hbm_me_cl_add - add new me client to the list
332 * @dev: the device structure
333 * @res: hbm property response
335 * Return: 0 on success and -ENOMEM on allocation failure
338 static int mei_hbm_me_cl_add(struct mei_device *dev,
339 struct hbm_props_response *res)
341 struct mei_me_client *me_cl;
343 me_cl = kzalloc(sizeof(struct mei_me_client), GFP_KERNEL);
347 me_cl->props = res->client_properties;
348 me_cl->client_id = res->me_addr;
349 me_cl->mei_flow_ctrl_creds = 0;
351 list_add(&me_cl->list, &dev->me_clients);
356 * mei_hbm_prop_req - request property for a single client
358 * @dev: the device structure
360 * Return: 0 on success and < 0 on failure
363 static int mei_hbm_prop_req(struct mei_device *dev)
366 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
367 struct hbm_props_request *prop_req;
368 const size_t len = sizeof(struct hbm_props_request);
369 unsigned long next_client_index;
372 next_client_index = find_next_bit(dev->me_clients_map, MEI_CLIENTS_MAX,
373 dev->me_client_index);
375 /* We got all client properties */
376 if (next_client_index == MEI_CLIENTS_MAX) {
377 dev->hbm_state = MEI_HBM_STARTED;
378 schedule_work(&dev->init_work);
383 mei_hbm_hdr(mei_hdr, len);
384 prop_req = (struct hbm_props_request *)dev->wr_msg.data;
386 memset(prop_req, 0, sizeof(struct hbm_props_request));
388 prop_req->hbm_cmd = HOST_CLIENT_PROPERTIES_REQ_CMD;
389 prop_req->me_addr = next_client_index;
391 ret = mei_write_message(dev, mei_hdr, dev->wr_msg.data);
393 dev_err(dev->dev, "properties request write failed: ret = %d\n",
398 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
399 dev->me_client_index = next_client_index;
405 * mei_hbm_pg - sends pg command
407 * @dev: the device structure
408 * @pg_cmd: the pg command code
410 * Return: -EIO on write failure
411 * -EOPNOTSUPP if the operation is not supported by the protocol
413 int mei_hbm_pg(struct mei_device *dev, u8 pg_cmd)
415 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
416 struct hbm_power_gate *req;
417 const size_t len = sizeof(struct hbm_power_gate);
420 if (!dev->hbm_f_pg_supported)
423 mei_hbm_hdr(mei_hdr, len);
425 req = (struct hbm_power_gate *)dev->wr_msg.data;
427 req->hbm_cmd = pg_cmd;
429 ret = mei_write_message(dev, mei_hdr, dev->wr_msg.data);
431 dev_err(dev->dev, "power gate command write failed.\n");
434 EXPORT_SYMBOL_GPL(mei_hbm_pg);
437 * mei_hbm_stop_req - send stop request message
441 * Return: -EIO on write failure
443 static int mei_hbm_stop_req(struct mei_device *dev)
445 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
446 struct hbm_host_stop_request *req =
447 (struct hbm_host_stop_request *)dev->wr_msg.data;
448 const size_t len = sizeof(struct hbm_host_stop_request);
450 mei_hbm_hdr(mei_hdr, len);
453 req->hbm_cmd = HOST_STOP_REQ_CMD;
454 req->reason = DRIVER_STOP_REQUEST;
456 return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
460 * mei_hbm_cl_flow_control_req - sends flow control request.
462 * @dev: the device structure
465 * Return: -EIO on write failure
467 int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl)
469 const size_t len = sizeof(struct hbm_flow_control);
471 cl_dbg(dev, cl, "sending flow control\n");
472 return mei_hbm_cl_write(dev, cl, MEI_FLOW_CONTROL_CMD, len);
476 * mei_hbm_add_single_flow_creds - adds single buffer credentials.
478 * @dev: the device structure
479 * @flow: flow control.
481 * Return: 0 on success, < 0 otherwise
483 static int mei_hbm_add_single_flow_creds(struct mei_device *dev,
484 struct hbm_flow_control *flow)
486 struct mei_me_client *me_cl;
488 me_cl = mei_me_cl_by_id(dev, flow->me_addr);
490 dev_err(dev->dev, "no such me client %d\n",
495 if (WARN_ON(me_cl->props.single_recv_buf == 0))
498 me_cl->mei_flow_ctrl_creds++;
499 dev_dbg(dev->dev, "recv flow ctrl msg ME %d (single) creds = %d.\n",
500 flow->me_addr, me_cl->mei_flow_ctrl_creds);
506 * mei_hbm_cl_flow_control_res - flow control response from me
508 * @dev: the device structure
509 * @flow_control: flow control response bus message
511 static void mei_hbm_cl_flow_control_res(struct mei_device *dev,
512 struct hbm_flow_control *flow_control)
516 if (!flow_control->host_addr) {
517 /* single receive buffer */
518 mei_hbm_add_single_flow_creds(dev, flow_control);
522 cl = mei_hbm_cl_find_by_cmd(dev, flow_control);
524 cl->mei_flow_ctrl_creds++;
525 cl_dbg(dev, cl, "flow control creds = %d.\n",
526 cl->mei_flow_ctrl_creds);
532 * mei_hbm_cl_disconnect_req - sends disconnect message to fw.
534 * @dev: the device structure
535 * @cl: a client to disconnect from
537 * Return: -EIO on write failure
539 int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl *cl)
541 const size_t len = sizeof(struct hbm_client_connect_request);
543 return mei_hbm_cl_write(dev, cl, CLIENT_DISCONNECT_REQ_CMD, len);
547 * mei_hbm_cl_disconnect_rsp - sends disconnect respose to the FW
549 * @dev: the device structure
550 * @cl: a client to disconnect from
552 * Return: -EIO on write failure
554 int mei_hbm_cl_disconnect_rsp(struct mei_device *dev, struct mei_cl *cl)
556 const size_t len = sizeof(struct hbm_client_connect_response);
558 return mei_hbm_cl_write(dev, cl, CLIENT_DISCONNECT_RES_CMD, len);
562 * mei_hbm_cl_disconnect_res - update the client state according
563 * disconnect response
565 * @cl: mei host client
566 * @cmd: disconnect client response host bus message
568 static void mei_hbm_cl_disconnect_res(struct mei_cl *cl,
569 struct mei_hbm_cl_cmd *cmd)
571 struct hbm_client_connect_response *rs =
572 (struct hbm_client_connect_response *)cmd;
574 dev_dbg(cl->dev->dev, "hbm: disconnect response cl:host=%02d me=%02d status=%d\n",
575 rs->me_addr, rs->host_addr, rs->status);
577 if (rs->status == MEI_CL_DISCONN_SUCCESS)
578 cl->state = MEI_FILE_DISCONNECTED;
583 * mei_hbm_cl_connect_req - send connection request to specific me client
585 * @dev: the device structure
586 * @cl: a client to connect to
588 * Return: -EIO on write failure
590 int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl *cl)
592 const size_t len = sizeof(struct hbm_client_connect_request);
594 return mei_hbm_cl_write(dev, cl, CLIENT_CONNECT_REQ_CMD, len);
598 * mei_hbm_cl_connect_res - update the client state according
599 * connection response
601 * @cl: mei host client
602 * @cmd: connect client response host bus message
604 static void mei_hbm_cl_connect_res(struct mei_cl *cl,
605 struct mei_hbm_cl_cmd *cmd)
607 struct hbm_client_connect_response *rs =
608 (struct hbm_client_connect_response *)cmd;
610 dev_dbg(cl->dev->dev, "hbm: connect response cl:host=%02d me=%02d status=%s\n",
611 rs->me_addr, rs->host_addr,
612 mei_cl_conn_status_str(rs->status));
614 if (rs->status == MEI_CL_CONN_SUCCESS)
615 cl->state = MEI_FILE_CONNECTED;
617 cl->state = MEI_FILE_DISCONNECTED;
618 cl->status = mei_cl_conn_status_to_errno(rs->status);
622 * mei_hbm_cl_res - process hbm response received on behalf
625 * @dev: the device structure
626 * @rs: hbm client message
627 * @fop_type: file operation type
629 static void mei_hbm_cl_res(struct mei_device *dev,
630 struct mei_hbm_cl_cmd *rs,
631 enum mei_cb_file_ops fop_type)
634 struct mei_cl_cb *cb, *next;
637 list_for_each_entry_safe(cb, next, &dev->ctrl_rd_list.list, list) {
640 /* this should not happen */
642 list_del_init(&cb->list);
646 if (cb->fop_type != fop_type)
649 if (mei_hbm_cl_addr_equal(cl, rs)) {
659 case MEI_FOP_CONNECT:
660 mei_hbm_cl_connect_res(cl, rs);
662 case MEI_FOP_DISCONNECT:
663 mei_hbm_cl_disconnect_res(cl, rs);
675 * mei_hbm_fw_disconnect_req - disconnect request initiated by ME firmware
676 * host sends disconnect response
678 * @dev: the device structure.
679 * @disconnect_req: disconnect request bus message from the me
681 * Return: -ENOMEM on allocation failure
683 static int mei_hbm_fw_disconnect_req(struct mei_device *dev,
684 struct hbm_client_connect_request *disconnect_req)
687 struct mei_cl_cb *cb;
689 cl = mei_hbm_cl_find_by_cmd(dev, disconnect_req);
691 cl_dbg(dev, cl, "disconnect request received\n");
692 cl->state = MEI_FILE_DISCONNECTED;
695 cb = mei_io_cb_init(cl, NULL);
698 cb->fop_type = MEI_FOP_DISCONNECT_RSP;
699 cl_dbg(dev, cl, "add disconnect response as first\n");
700 list_add(&cb->list, &dev->ctrl_wr_list.list);
706 * mei_hbm_config_features - check what hbm features and commands
707 * are supported by the fw
709 * @dev: the device structure
711 static void mei_hbm_config_features(struct mei_device *dev)
713 /* Power Gating Isolation Support */
714 dev->hbm_f_pg_supported = 0;
715 if (dev->version.major_version > HBM_MAJOR_VERSION_PGI)
716 dev->hbm_f_pg_supported = 1;
718 if (dev->version.major_version == HBM_MAJOR_VERSION_PGI &&
719 dev->version.minor_version >= HBM_MINOR_VERSION_PGI)
720 dev->hbm_f_pg_supported = 1;
724 * mei_hbm_version_is_supported - checks whether the driver can
725 * support the hbm version of the device
727 * @dev: the device structure
728 * Return: true if driver can support hbm version of the device
730 bool mei_hbm_version_is_supported(struct mei_device *dev)
732 return (dev->version.major_version < HBM_MAJOR_VERSION) ||
733 (dev->version.major_version == HBM_MAJOR_VERSION &&
734 dev->version.minor_version <= HBM_MINOR_VERSION);
738 * mei_hbm_dispatch - bottom half read routine after ISR to
739 * handle the read bus message cmd processing.
741 * @dev: the device structure
742 * @hdr: header of bus message
744 * Return: 0 on success and < 0 on failure
746 int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
748 struct mei_bus_message *mei_msg;
749 struct hbm_host_version_response *version_res;
750 struct hbm_props_response *props_res;
751 struct hbm_host_enum_response *enum_res;
753 struct mei_hbm_cl_cmd *cl_cmd;
754 struct hbm_client_connect_request *disconnect_req;
755 struct hbm_flow_control *flow_control;
757 /* read the message to our buffer */
758 BUG_ON(hdr->length >= sizeof(dev->rd_msg_buf));
759 mei_read_slots(dev, dev->rd_msg_buf, hdr->length);
760 mei_msg = (struct mei_bus_message *)dev->rd_msg_buf;
761 cl_cmd = (struct mei_hbm_cl_cmd *)mei_msg;
763 /* ignore spurious message and prevent reset nesting
764 * hbm is put to idle during system reset
766 if (dev->hbm_state == MEI_HBM_IDLE) {
767 dev_dbg(dev->dev, "hbm: state is idle ignore spurious messages\n");
771 switch (mei_msg->hbm_cmd) {
772 case HOST_START_RES_CMD:
773 dev_dbg(dev->dev, "hbm: start: response message received.\n");
775 dev->init_clients_timer = 0;
777 version_res = (struct hbm_host_version_response *)mei_msg;
779 dev_dbg(dev->dev, "HBM VERSION: DRIVER=%02d:%02d DEVICE=%02d:%02d\n",
780 HBM_MAJOR_VERSION, HBM_MINOR_VERSION,
781 version_res->me_max_version.major_version,
782 version_res->me_max_version.minor_version);
784 if (version_res->host_version_supported) {
785 dev->version.major_version = HBM_MAJOR_VERSION;
786 dev->version.minor_version = HBM_MINOR_VERSION;
788 dev->version.major_version =
789 version_res->me_max_version.major_version;
790 dev->version.minor_version =
791 version_res->me_max_version.minor_version;
794 if (!mei_hbm_version_is_supported(dev)) {
795 dev_warn(dev->dev, "hbm: start: version mismatch - stopping the driver.\n");
797 dev->hbm_state = MEI_HBM_STOPPED;
798 if (mei_hbm_stop_req(dev)) {
799 dev_err(dev->dev, "hbm: start: failed to send stop request\n");
805 mei_hbm_config_features(dev);
807 if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
808 dev->hbm_state != MEI_HBM_STARTING) {
809 dev_err(dev->dev, "hbm: start: state mismatch, [%d, %d]\n",
810 dev->dev_state, dev->hbm_state);
814 dev->hbm_state = MEI_HBM_STARTED;
816 if (mei_hbm_enum_clients_req(dev)) {
817 dev_err(dev->dev, "hbm: start: failed to send enumeration request\n");
821 wake_up(&dev->wait_hbm_start);
824 case CLIENT_CONNECT_RES_CMD:
825 dev_dbg(dev->dev, "hbm: client connect response: message received.\n");
826 mei_hbm_cl_res(dev, cl_cmd, MEI_FOP_CONNECT);
829 case CLIENT_DISCONNECT_RES_CMD:
830 dev_dbg(dev->dev, "hbm: client disconnect response: message received.\n");
831 mei_hbm_cl_res(dev, cl_cmd, MEI_FOP_DISCONNECT);
834 case MEI_FLOW_CONTROL_CMD:
835 dev_dbg(dev->dev, "hbm: client flow control response: message received.\n");
837 flow_control = (struct hbm_flow_control *) mei_msg;
838 mei_hbm_cl_flow_control_res(dev, flow_control);
841 case MEI_PG_ISOLATION_ENTRY_RES_CMD:
842 dev_dbg(dev->dev, "power gate isolation entry response received\n");
843 dev->pg_event = MEI_PG_EVENT_RECEIVED;
844 if (waitqueue_active(&dev->wait_pg))
845 wake_up(&dev->wait_pg);
848 case MEI_PG_ISOLATION_EXIT_REQ_CMD:
849 dev_dbg(dev->dev, "power gate isolation exit request received\n");
850 dev->pg_event = MEI_PG_EVENT_RECEIVED;
851 if (waitqueue_active(&dev->wait_pg))
852 wake_up(&dev->wait_pg);
855 * If the driver is not waiting on this then
856 * this is HW initiated exit from PG.
857 * Start runtime pm resume sequence to exit from PG.
859 pm_request_resume(dev->dev);
862 case HOST_CLIENT_PROPERTIES_RES_CMD:
863 dev_dbg(dev->dev, "hbm: properties response: message received.\n");
865 dev->init_clients_timer = 0;
867 if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
868 dev->hbm_state != MEI_HBM_CLIENT_PROPERTIES) {
869 dev_err(dev->dev, "hbm: properties response: state mismatch, [%d, %d]\n",
870 dev->dev_state, dev->hbm_state);
874 props_res = (struct hbm_props_response *)mei_msg;
876 if (props_res->status) {
877 dev_err(dev->dev, "hbm: properties response: wrong status = %d %s\n",
879 mei_hbm_status_str(props_res->status));
883 mei_hbm_me_cl_add(dev, props_res);
885 dev->me_client_index++;
887 /* request property for the next client */
888 if (mei_hbm_prop_req(dev))
893 case HOST_ENUM_RES_CMD:
894 dev_dbg(dev->dev, "hbm: enumeration response: message received\n");
896 dev->init_clients_timer = 0;
898 enum_res = (struct hbm_host_enum_response *) mei_msg;
899 BUILD_BUG_ON(sizeof(dev->me_clients_map)
900 < sizeof(enum_res->valid_addresses));
901 memcpy(dev->me_clients_map, enum_res->valid_addresses,
902 sizeof(enum_res->valid_addresses));
904 if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
905 dev->hbm_state != MEI_HBM_ENUM_CLIENTS) {
906 dev_err(dev->dev, "hbm: enumeration response: state mismatch, [%d, %d]\n",
907 dev->dev_state, dev->hbm_state);
911 dev->hbm_state = MEI_HBM_CLIENT_PROPERTIES;
913 /* first property request */
914 if (mei_hbm_prop_req(dev))
919 case HOST_STOP_RES_CMD:
920 dev_dbg(dev->dev, "hbm: stop response: message received\n");
922 dev->init_clients_timer = 0;
924 if (dev->hbm_state != MEI_HBM_STOPPED) {
925 dev_err(dev->dev, "hbm: stop response: state mismatch, [%d, %d]\n",
926 dev->dev_state, dev->hbm_state);
930 dev->dev_state = MEI_DEV_POWER_DOWN;
931 dev_info(dev->dev, "hbm: stop response: resetting.\n");
932 /* force the reset */
936 case CLIENT_DISCONNECT_REQ_CMD:
937 dev_dbg(dev->dev, "hbm: disconnect request: message received\n");
939 disconnect_req = (struct hbm_client_connect_request *)mei_msg;
940 mei_hbm_fw_disconnect_req(dev, disconnect_req);
943 case ME_STOP_REQ_CMD:
944 dev_dbg(dev->dev, "hbm: stop request: message received\n");
945 dev->hbm_state = MEI_HBM_STOPPED;
946 if (mei_hbm_stop_req(dev)) {
947 dev_err(dev->dev, "hbm: stop request: failed to send stop request\n");