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 * @dev: the device structure
566 * @cl: mei host client
567 * @cmd: disconnect client response host bus message
569 static void mei_hbm_cl_disconnect_res(struct mei_device
*dev
, struct mei_cl
*cl
,
570 struct mei_hbm_cl_cmd
*cmd
)
572 struct hbm_client_connect_response
*rs
=
573 (struct hbm_client_connect_response
*)cmd
;
575 cl_dbg(dev
, cl
, "hbm: disconnect response status=%d\n", 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 * @dev: the device structure
602 * @cl: mei host client
603 * @cmd: connect client response host bus message
605 static void mei_hbm_cl_connect_res(struct mei_device
*dev
, struct mei_cl
*cl
,
606 struct mei_hbm_cl_cmd
*cmd
)
608 struct hbm_client_connect_response
*rs
=
609 (struct hbm_client_connect_response
*)cmd
;
611 cl_dbg(dev
, cl
, "hbm: connect response status=%s\n",
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
) {
641 if (cb
->fop_type
!= fop_type
)
644 if (mei_hbm_cl_addr_equal(cl
, rs
)) {
654 case MEI_FOP_CONNECT
:
655 mei_hbm_cl_connect_res(dev
, cl
, rs
);
657 case MEI_FOP_DISCONNECT
:
658 mei_hbm_cl_disconnect_res(dev
, cl
, rs
);
670 * mei_hbm_fw_disconnect_req - disconnect request initiated by ME firmware
671 * host sends disconnect response
673 * @dev: the device structure.
674 * @disconnect_req: disconnect request bus message from the me
676 * Return: -ENOMEM on allocation failure
678 static int mei_hbm_fw_disconnect_req(struct mei_device
*dev
,
679 struct hbm_client_connect_request
*disconnect_req
)
682 struct mei_cl_cb
*cb
;
684 cl
= mei_hbm_cl_find_by_cmd(dev
, disconnect_req
);
686 cl_dbg(dev
, cl
, "disconnect request received\n");
687 cl
->state
= MEI_FILE_DISCONNECTED
;
690 cb
= mei_io_cb_init(cl
, NULL
);
693 cb
->fop_type
= MEI_FOP_DISCONNECT_RSP
;
694 cl_dbg(dev
, cl
, "add disconnect response as first\n");
695 list_add(&cb
->list
, &dev
->ctrl_wr_list
.list
);
701 * mei_hbm_config_features - check what hbm features and commands
702 * are supported by the fw
704 * @dev: the device structure
706 static void mei_hbm_config_features(struct mei_device
*dev
)
708 /* Power Gating Isolation Support */
709 dev
->hbm_f_pg_supported
= 0;
710 if (dev
->version
.major_version
> HBM_MAJOR_VERSION_PGI
)
711 dev
->hbm_f_pg_supported
= 1;
713 if (dev
->version
.major_version
== HBM_MAJOR_VERSION_PGI
&&
714 dev
->version
.minor_version
>= HBM_MINOR_VERSION_PGI
)
715 dev
->hbm_f_pg_supported
= 1;
719 * mei_hbm_version_is_supported - checks whether the driver can
720 * support the hbm version of the device
722 * @dev: the device structure
723 * Return: true if driver can support hbm version of the device
725 bool mei_hbm_version_is_supported(struct mei_device
*dev
)
727 return (dev
->version
.major_version
< HBM_MAJOR_VERSION
) ||
728 (dev
->version
.major_version
== HBM_MAJOR_VERSION
&&
729 dev
->version
.minor_version
<= HBM_MINOR_VERSION
);
733 * mei_hbm_dispatch - bottom half read routine after ISR to
734 * handle the read bus message cmd processing.
736 * @dev: the device structure
737 * @hdr: header of bus message
739 * Return: 0 on success and < 0 on failure
741 int mei_hbm_dispatch(struct mei_device
*dev
, struct mei_msg_hdr
*hdr
)
743 struct mei_bus_message
*mei_msg
;
744 struct hbm_host_version_response
*version_res
;
745 struct hbm_props_response
*props_res
;
746 struct hbm_host_enum_response
*enum_res
;
748 struct mei_hbm_cl_cmd
*cl_cmd
;
749 struct hbm_client_connect_request
*disconnect_req
;
750 struct hbm_flow_control
*flow_control
;
752 /* read the message to our buffer */
753 BUG_ON(hdr
->length
>= sizeof(dev
->rd_msg_buf
));
754 mei_read_slots(dev
, dev
->rd_msg_buf
, hdr
->length
);
755 mei_msg
= (struct mei_bus_message
*)dev
->rd_msg_buf
;
756 cl_cmd
= (struct mei_hbm_cl_cmd
*)mei_msg
;
758 /* ignore spurious message and prevent reset nesting
759 * hbm is put to idle during system reset
761 if (dev
->hbm_state
== MEI_HBM_IDLE
) {
762 dev_dbg(dev
->dev
, "hbm: state is idle ignore spurious messages\n");
766 switch (mei_msg
->hbm_cmd
) {
767 case HOST_START_RES_CMD
:
768 dev_dbg(dev
->dev
, "hbm: start: response message received.\n");
770 dev
->init_clients_timer
= 0;
772 version_res
= (struct hbm_host_version_response
*)mei_msg
;
774 dev_dbg(dev
->dev
, "HBM VERSION: DRIVER=%02d:%02d DEVICE=%02d:%02d\n",
775 HBM_MAJOR_VERSION
, HBM_MINOR_VERSION
,
776 version_res
->me_max_version
.major_version
,
777 version_res
->me_max_version
.minor_version
);
779 if (version_res
->host_version_supported
) {
780 dev
->version
.major_version
= HBM_MAJOR_VERSION
;
781 dev
->version
.minor_version
= HBM_MINOR_VERSION
;
783 dev
->version
.major_version
=
784 version_res
->me_max_version
.major_version
;
785 dev
->version
.minor_version
=
786 version_res
->me_max_version
.minor_version
;
789 if (!mei_hbm_version_is_supported(dev
)) {
790 dev_warn(dev
->dev
, "hbm: start: version mismatch - stopping the driver.\n");
792 dev
->hbm_state
= MEI_HBM_STOPPED
;
793 if (mei_hbm_stop_req(dev
)) {
794 dev_err(dev
->dev
, "hbm: start: failed to send stop request\n");
800 mei_hbm_config_features(dev
);
802 if (dev
->dev_state
!= MEI_DEV_INIT_CLIENTS
||
803 dev
->hbm_state
!= MEI_HBM_STARTING
) {
804 dev_err(dev
->dev
, "hbm: start: state mismatch, [%d, %d]\n",
805 dev
->dev_state
, dev
->hbm_state
);
809 if (mei_hbm_enum_clients_req(dev
)) {
810 dev_err(dev
->dev
, "hbm: start: failed to send enumeration request\n");
814 wake_up(&dev
->wait_hbm_start
);
817 case CLIENT_CONNECT_RES_CMD
:
818 dev_dbg(dev
->dev
, "hbm: client connect response: message received.\n");
819 mei_hbm_cl_res(dev
, cl_cmd
, MEI_FOP_CONNECT
);
822 case CLIENT_DISCONNECT_RES_CMD
:
823 dev_dbg(dev
->dev
, "hbm: client disconnect response: message received.\n");
824 mei_hbm_cl_res(dev
, cl_cmd
, MEI_FOP_DISCONNECT
);
827 case MEI_FLOW_CONTROL_CMD
:
828 dev_dbg(dev
->dev
, "hbm: client flow control response: message received.\n");
830 flow_control
= (struct hbm_flow_control
*) mei_msg
;
831 mei_hbm_cl_flow_control_res(dev
, flow_control
);
834 case MEI_PG_ISOLATION_ENTRY_RES_CMD
:
835 dev_dbg(dev
->dev
, "power gate isolation entry response received\n");
836 dev
->pg_event
= MEI_PG_EVENT_RECEIVED
;
837 if (waitqueue_active(&dev
->wait_pg
))
838 wake_up(&dev
->wait_pg
);
841 case MEI_PG_ISOLATION_EXIT_REQ_CMD
:
842 dev_dbg(dev
->dev
, "power gate isolation exit request received\n");
843 dev
->pg_event
= MEI_PG_EVENT_RECEIVED
;
844 if (waitqueue_active(&dev
->wait_pg
))
845 wake_up(&dev
->wait_pg
);
848 * If the driver is not waiting on this then
849 * this is HW initiated exit from PG.
850 * Start runtime pm resume sequence to exit from PG.
852 pm_request_resume(dev
->dev
);
855 case HOST_CLIENT_PROPERTIES_RES_CMD
:
856 dev_dbg(dev
->dev
, "hbm: properties response: message received.\n");
858 dev
->init_clients_timer
= 0;
860 if (dev
->dev_state
!= MEI_DEV_INIT_CLIENTS
||
861 dev
->hbm_state
!= MEI_HBM_CLIENT_PROPERTIES
) {
862 dev_err(dev
->dev
, "hbm: properties response: state mismatch, [%d, %d]\n",
863 dev
->dev_state
, dev
->hbm_state
);
867 props_res
= (struct hbm_props_response
*)mei_msg
;
869 if (props_res
->status
) {
870 dev_err(dev
->dev
, "hbm: properties response: wrong status = %d %s\n",
872 mei_hbm_status_str(props_res
->status
));
876 mei_hbm_me_cl_add(dev
, props_res
);
878 dev
->me_client_index
++;
880 /* request property for the next client */
881 if (mei_hbm_prop_req(dev
))
886 case HOST_ENUM_RES_CMD
:
887 dev_dbg(dev
->dev
, "hbm: enumeration response: message received\n");
889 dev
->init_clients_timer
= 0;
891 enum_res
= (struct hbm_host_enum_response
*) mei_msg
;
892 BUILD_BUG_ON(sizeof(dev
->me_clients_map
)
893 < sizeof(enum_res
->valid_addresses
));
894 memcpy(dev
->me_clients_map
, enum_res
->valid_addresses
,
895 sizeof(enum_res
->valid_addresses
));
897 if (dev
->dev_state
!= MEI_DEV_INIT_CLIENTS
||
898 dev
->hbm_state
!= MEI_HBM_ENUM_CLIENTS
) {
899 dev_err(dev
->dev
, "hbm: enumeration response: state mismatch, [%d, %d]\n",
900 dev
->dev_state
, dev
->hbm_state
);
904 dev
->hbm_state
= MEI_HBM_CLIENT_PROPERTIES
;
906 /* first property request */
907 if (mei_hbm_prop_req(dev
))
912 case HOST_STOP_RES_CMD
:
913 dev_dbg(dev
->dev
, "hbm: stop response: message received\n");
915 dev
->init_clients_timer
= 0;
917 if (dev
->hbm_state
!= MEI_HBM_STOPPED
) {
918 dev_err(dev
->dev
, "hbm: stop response: state mismatch, [%d, %d]\n",
919 dev
->dev_state
, dev
->hbm_state
);
923 dev
->dev_state
= MEI_DEV_POWER_DOWN
;
924 dev_info(dev
->dev
, "hbm: stop response: resetting.\n");
925 /* force the reset */
929 case CLIENT_DISCONNECT_REQ_CMD
:
930 dev_dbg(dev
->dev
, "hbm: disconnect request: message received\n");
932 disconnect_req
= (struct hbm_client_connect_request
*)mei_msg
;
933 mei_hbm_fw_disconnect_req(dev
, disconnect_req
);
936 case ME_STOP_REQ_CMD
:
937 dev_dbg(dev
->dev
, "hbm: stop request: message received\n");
938 dev
->hbm_state
= MEI_HBM_STOPPED
;
939 if (mei_hbm_stop_req(dev
)) {
940 dev_err(dev
->dev
, "hbm: stop request: failed to send stop request\n");