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 * returns -EIO on write failure
376 * -EOPNOTSUPP if the operation is not supported by the protocol
378 int mei_hbm_pg(struct mei_device *dev, u8 pg_cmd)
380 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
381 struct hbm_power_gate *req;
382 const size_t len = sizeof(struct hbm_power_gate);
385 if (!dev->hbm_f_pg_supported)
388 mei_hbm_hdr(mei_hdr, len);
390 req = (struct hbm_power_gate *)dev->wr_msg.data;
392 req->hbm_cmd = pg_cmd;
394 ret = mei_write_message(dev, mei_hdr, dev->wr_msg.data);
396 dev_err(&dev->pdev->dev, "power gate command write failed.\n");
399 EXPORT_SYMBOL_GPL(mei_hbm_pg);
402 * mei_hbm_stop_req - send stop request message
407 * This function returns -EIO on write failure
409 static int mei_hbm_stop_req(struct mei_device *dev)
411 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
412 struct hbm_host_stop_request *req =
413 (struct hbm_host_stop_request *)dev->wr_msg.data;
414 const size_t len = sizeof(struct hbm_host_stop_request);
416 mei_hbm_hdr(mei_hdr, len);
419 req->hbm_cmd = HOST_STOP_REQ_CMD;
420 req->reason = DRIVER_STOP_REQUEST;
422 return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
426 * mei_hbm_cl_flow_control_req - sends flow control request.
428 * @dev: the device structure
431 * This function returns -EIO on write failure
433 int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl)
435 const size_t len = sizeof(struct hbm_flow_control);
436 cl_dbg(dev, cl, "sending flow control\n");
437 return mei_hbm_cl_write(dev, cl, MEI_FLOW_CONTROL_CMD, len);
441 * mei_hbm_add_single_flow_creds - adds single buffer credentials.
443 * @dev: the device structure
444 * @flow: flow control.
446 * return 0 on success, < 0 otherwise
448 static int mei_hbm_add_single_flow_creds(struct mei_device *dev,
449 struct hbm_flow_control *flow)
451 struct mei_me_client *me_cl;
453 me_cl = mei_me_cl_by_id(dev, flow->me_addr);
455 dev_err(&dev->pdev->dev, "no such me client %d\n",
460 if (WARN_ON(me_cl->props.single_recv_buf == 0))
463 me_cl->mei_flow_ctrl_creds++;
464 dev_dbg(&dev->pdev->dev, "recv flow ctrl msg ME %d (single) creds = %d.\n",
465 flow->me_addr, me_cl->mei_flow_ctrl_creds);
471 * mei_hbm_cl_flow_control_res - flow control response from me
473 * @dev: the device structure
474 * @flow_control: flow control response bus message
476 static void mei_hbm_cl_flow_control_res(struct mei_device *dev,
477 struct hbm_flow_control *flow_control)
481 if (!flow_control->host_addr) {
482 /* single receive buffer */
483 mei_hbm_add_single_flow_creds(dev, flow_control);
487 cl = mei_hbm_cl_find_by_cmd(dev, flow_control);
489 cl->mei_flow_ctrl_creds++;
490 cl_dbg(dev, cl, "flow control creds = %d.\n",
491 cl->mei_flow_ctrl_creds);
497 * mei_hbm_cl_disconnect_req - sends disconnect message to fw.
499 * @dev: the device structure
500 * @cl: a client to disconnect from
502 * This function returns -EIO on write failure
504 int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl *cl)
506 const size_t len = sizeof(struct hbm_client_connect_request);
507 return mei_hbm_cl_write(dev, cl, CLIENT_DISCONNECT_REQ_CMD, len);
511 * mei_hbm_cl_disconnect_rsp - sends disconnect respose to the FW
513 * @dev: the device structure
514 * @cl: a client to disconnect from
516 * This function returns -EIO on write failure
518 int mei_hbm_cl_disconnect_rsp(struct mei_device *dev, struct mei_cl *cl)
520 const size_t len = sizeof(struct hbm_client_connect_response);
521 return mei_hbm_cl_write(dev, cl, CLIENT_DISCONNECT_RES_CMD, len);
525 * mei_hbm_cl_disconnect_res - update the client state according
526 * disconnect response
528 * @cl: mei host client
529 * @cmd: disconnect client response host bus message
531 static void mei_hbm_cl_disconnect_res(struct mei_cl *cl,
532 struct mei_hbm_cl_cmd *cmd)
534 struct hbm_client_connect_response *rs =
535 (struct hbm_client_connect_response *)cmd;
537 dev_dbg(&cl->dev->pdev->dev, "hbm: disconnect response cl:host=%02d me=%02d status=%d\n",
538 rs->me_addr, rs->host_addr, rs->status);
540 if (rs->status == MEI_CL_DISCONN_SUCCESS)
541 cl->state = MEI_FILE_DISCONNECTED;
546 * mei_hbm_cl_connect_req - send connection request to specific me client
548 * @dev: the device structure
549 * @cl: a client to connect to
551 * returns -EIO on write failure
553 int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl *cl)
555 const size_t len = sizeof(struct hbm_client_connect_request);
556 return mei_hbm_cl_write(dev, cl, CLIENT_CONNECT_REQ_CMD, len);
560 * mei_hbm_cl_connect_res - update the client state according
561 * connection response
563 * @cl: mei host client
564 * @cmd: connect client response host bus message
566 static void mei_hbm_cl_connect_res(struct mei_cl *cl,
567 struct mei_hbm_cl_cmd *cmd)
569 struct hbm_client_connect_response *rs =
570 (struct hbm_client_connect_response *)cmd;
572 dev_dbg(&cl->dev->pdev->dev, "hbm: connect response cl:host=%02d me=%02d status=%s\n",
573 rs->me_addr, rs->host_addr,
574 mei_cl_conn_status_str(rs->status));
576 if (rs->status == MEI_CL_CONN_SUCCESS)
577 cl->state = MEI_FILE_CONNECTED;
579 cl->state = MEI_FILE_DISCONNECTED;
580 cl->status = mei_cl_conn_status_to_errno(rs->status);
584 * mei_hbm_cl_res - process hbm response received on behalf
587 * @dev: the device structure
588 * @rs: hbm client message
589 * @fop_type: file operation type
591 static void mei_hbm_cl_res(struct mei_device *dev,
592 struct mei_hbm_cl_cmd *rs,
593 enum mei_cb_file_ops fop_type)
596 struct mei_cl_cb *cb, *next;
599 list_for_each_entry_safe(cb, next, &dev->ctrl_rd_list.list, list) {
602 /* this should not happen */
604 list_del_init(&cb->list);
608 if (cb->fop_type != fop_type)
611 if (mei_hbm_cl_addr_equal(cl, rs)) {
621 case MEI_FOP_CONNECT:
622 mei_hbm_cl_connect_res(cl, rs);
624 case MEI_FOP_DISCONNECT:
625 mei_hbm_cl_disconnect_res(cl, rs);
637 * mei_hbm_fw_disconnect_req - disconnect request initiated by ME firmware
638 * host sends disconnect response
640 * @dev: the device structure.
641 * @disconnect_req: disconnect request bus message from the me
643 * returns -ENOMEM on allocation failure
645 static int mei_hbm_fw_disconnect_req(struct mei_device *dev,
646 struct hbm_client_connect_request *disconnect_req)
649 struct mei_cl_cb *cb;
651 cl = mei_hbm_cl_find_by_cmd(dev, disconnect_req);
653 cl_dbg(dev, cl, "disconnect request received\n");
654 cl->state = MEI_FILE_DISCONNECTED;
657 cb = mei_io_cb_init(cl, NULL);
660 cb->fop_type = MEI_FOP_DISCONNECT_RSP;
661 cl_dbg(dev, cl, "add disconnect response as first\n");
662 list_add(&cb->list, &dev->ctrl_wr_list.list);
668 * mei_hbm_config_features: check what hbm features and commands
669 * are supported by the fw
671 * @dev: the device structure
673 static void mei_hbm_config_features(struct mei_device *dev)
675 /* Power Gating Isolation Support */
676 dev->hbm_f_pg_supported = 0;
677 if (dev->version.major_version > HBM_MAJOR_VERSION_PGI)
678 dev->hbm_f_pg_supported = 1;
680 if (dev->version.major_version == HBM_MAJOR_VERSION_PGI &&
681 dev->version.minor_version >= HBM_MINOR_VERSION_PGI)
682 dev->hbm_f_pg_supported = 1;
686 * mei_hbm_version_is_supported - checks whether the driver can
687 * support the hbm version of the device
689 * @dev: the device structure
690 * returns true if driver can support hbm version of the device
692 bool mei_hbm_version_is_supported(struct mei_device *dev)
694 return (dev->version.major_version < HBM_MAJOR_VERSION) ||
695 (dev->version.major_version == HBM_MAJOR_VERSION &&
696 dev->version.minor_version <= HBM_MINOR_VERSION);
700 * mei_hbm_dispatch - bottom half read routine after ISR to
701 * handle the read bus message cmd processing.
703 * @dev: the device structure
704 * @mei_hdr: header of bus message
706 * returns 0 on success and < 0 on failure
708 int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
710 struct mei_bus_message *mei_msg;
711 struct hbm_host_version_response *version_res;
712 struct hbm_props_response *props_res;
713 struct hbm_host_enum_response *enum_res;
715 struct mei_hbm_cl_cmd *cl_cmd;
716 struct hbm_client_connect_request *disconnect_req;
717 struct hbm_flow_control *flow_control;
719 /* read the message to our buffer */
720 BUG_ON(hdr->length >= sizeof(dev->rd_msg_buf));
721 mei_read_slots(dev, dev->rd_msg_buf, hdr->length);
722 mei_msg = (struct mei_bus_message *)dev->rd_msg_buf;
723 cl_cmd = (struct mei_hbm_cl_cmd *)mei_msg;
725 /* ignore spurious message and prevent reset nesting
726 * hbm is put to idle during system reset
728 if (dev->hbm_state == MEI_HBM_IDLE) {
729 dev_dbg(&dev->pdev->dev, "hbm: state is idle ignore spurious messages\n");
733 switch (mei_msg->hbm_cmd) {
734 case HOST_START_RES_CMD:
735 dev_dbg(&dev->pdev->dev, "hbm: start: response message received.\n");
737 dev->init_clients_timer = 0;
739 version_res = (struct hbm_host_version_response *)mei_msg;
741 dev_dbg(&dev->pdev->dev, "HBM VERSION: DRIVER=%02d:%02d DEVICE=%02d:%02d\n",
742 HBM_MAJOR_VERSION, HBM_MINOR_VERSION,
743 version_res->me_max_version.major_version,
744 version_res->me_max_version.minor_version);
746 if (version_res->host_version_supported) {
747 dev->version.major_version = HBM_MAJOR_VERSION;
748 dev->version.minor_version = HBM_MINOR_VERSION;
750 dev->version.major_version =
751 version_res->me_max_version.major_version;
752 dev->version.minor_version =
753 version_res->me_max_version.minor_version;
756 if (!mei_hbm_version_is_supported(dev)) {
757 dev_warn(&dev->pdev->dev, "hbm: start: version mismatch - stopping the driver.\n");
759 dev->hbm_state = MEI_HBM_STOPPED;
760 if (mei_hbm_stop_req(dev)) {
761 dev_err(&dev->pdev->dev, "hbm: start: failed to send stop request\n");
767 mei_hbm_config_features(dev);
769 if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
770 dev->hbm_state != MEI_HBM_STARTING) {
771 dev_err(&dev->pdev->dev, "hbm: start: state mismatch, [%d, %d]\n",
772 dev->dev_state, dev->hbm_state);
776 dev->hbm_state = MEI_HBM_STARTED;
778 if (mei_hbm_enum_clients_req(dev)) {
779 dev_err(&dev->pdev->dev, "hbm: start: failed to send enumeration request\n");
783 wake_up(&dev->wait_hbm_start);
786 case CLIENT_CONNECT_RES_CMD:
787 dev_dbg(&dev->pdev->dev, "hbm: client connect response: message received.\n");
788 mei_hbm_cl_res(dev, cl_cmd, MEI_FOP_CONNECT);
791 case CLIENT_DISCONNECT_RES_CMD:
792 dev_dbg(&dev->pdev->dev, "hbm: client disconnect response: message received.\n");
793 mei_hbm_cl_res(dev, cl_cmd, MEI_FOP_DISCONNECT);
796 case MEI_FLOW_CONTROL_CMD:
797 dev_dbg(&dev->pdev->dev, "hbm: client flow control response: message received.\n");
799 flow_control = (struct hbm_flow_control *) mei_msg;
800 mei_hbm_cl_flow_control_res(dev, flow_control);
803 case MEI_PG_ISOLATION_ENTRY_RES_CMD:
804 dev_dbg(&dev->pdev->dev, "power gate isolation entry response received\n");
805 dev->pg_event = MEI_PG_EVENT_RECEIVED;
806 if (waitqueue_active(&dev->wait_pg))
807 wake_up(&dev->wait_pg);
810 case MEI_PG_ISOLATION_EXIT_REQ_CMD:
811 dev_dbg(&dev->pdev->dev, "power gate isolation exit request received\n");
812 dev->pg_event = MEI_PG_EVENT_RECEIVED;
813 if (waitqueue_active(&dev->wait_pg))
814 wake_up(&dev->wait_pg);
817 * If the driver is not waiting on this then
818 * this is HW initiated exit from PG.
819 * Start runtime pm resume sequence to exit from PG.
821 pm_request_resume(&dev->pdev->dev);
824 case HOST_CLIENT_PROPERTIES_RES_CMD:
825 dev_dbg(&dev->pdev->dev, "hbm: properties response: message received.\n");
827 dev->init_clients_timer = 0;
829 if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
830 dev->hbm_state != MEI_HBM_CLIENT_PROPERTIES) {
831 dev_err(&dev->pdev->dev, "hbm: properties response: state mismatch, [%d, %d]\n",
832 dev->dev_state, dev->hbm_state);
836 props_res = (struct hbm_props_response *)mei_msg;
838 if (props_res->status) {
839 dev_err(&dev->pdev->dev, "hbm: properties response: wrong status = %d %s\n",
841 mei_hbm_status_str(props_res->status));
845 mei_hbm_me_cl_add(dev, props_res);
847 dev->me_client_index++;
848 dev->me_client_presentation_num++;
850 /* request property for the next client */
851 if (mei_hbm_prop_req(dev))
856 case HOST_ENUM_RES_CMD:
857 dev_dbg(&dev->pdev->dev, "hbm: enumeration response: message received\n");
859 dev->init_clients_timer = 0;
861 enum_res = (struct hbm_host_enum_response *) mei_msg;
862 BUILD_BUG_ON(sizeof(dev->me_clients_map)
863 < sizeof(enum_res->valid_addresses));
864 memcpy(dev->me_clients_map, enum_res->valid_addresses,
865 sizeof(enum_res->valid_addresses));
867 if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
868 dev->hbm_state != MEI_HBM_ENUM_CLIENTS) {
869 dev_err(&dev->pdev->dev, "hbm: enumeration response: state mismatch, [%d, %d]\n",
870 dev->dev_state, dev->hbm_state);
874 dev->hbm_state = MEI_HBM_CLIENT_PROPERTIES;
876 /* first property request */
877 if (mei_hbm_prop_req(dev))
882 case HOST_STOP_RES_CMD:
883 dev_dbg(&dev->pdev->dev, "hbm: stop response: message received\n");
885 dev->init_clients_timer = 0;
887 if (dev->hbm_state != MEI_HBM_STOPPED) {
888 dev_err(&dev->pdev->dev, "hbm: stop response: state mismatch, [%d, %d]\n",
889 dev->dev_state, dev->hbm_state);
893 dev->dev_state = MEI_DEV_POWER_DOWN;
894 dev_info(&dev->pdev->dev, "hbm: stop response: resetting.\n");
895 /* force the reset */
899 case CLIENT_DISCONNECT_REQ_CMD:
900 dev_dbg(&dev->pdev->dev, "hbm: disconnect request: message received\n");
902 disconnect_req = (struct hbm_client_connect_request *)mei_msg;
903 mei_hbm_fw_disconnect_req(dev, disconnect_req);
906 case ME_STOP_REQ_CMD:
907 dev_dbg(&dev->pdev->dev, "hbm: stop request: message received\n");
908 dev->hbm_state = MEI_HBM_STOPPED;
909 if (mei_hbm_stop_req(dev)) {
910 dev_err(&dev->pdev->dev, "hbm: stop request: failed to send stop request\n");