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_addr_equal - tells if they have the same address
148 * @buf: buffer with cl header
150 * returns true if addresses are the same
153 bool mei_hbm_cl_addr_equal(struct mei_cl *cl, void *buf)
155 struct mei_hbm_cl_cmd *cmd = buf;
156 return cl->host_client_id == cmd->host_addr &&
157 cl->me_client_id == cmd->me_addr;
161 int mei_hbm_start_wait(struct mei_device *dev)
164 if (dev->hbm_state > MEI_HBM_START)
167 mutex_unlock(&dev->device_lock);
168 ret = wait_event_interruptible_timeout(dev->wait_recvd_msg,
169 dev->hbm_state == MEI_HBM_IDLE ||
170 dev->hbm_state >= MEI_HBM_STARTED,
171 mei_secs_to_jiffies(MEI_HBM_TIMEOUT));
172 mutex_lock(&dev->device_lock);
174 if (ret <= 0 && (dev->hbm_state <= MEI_HBM_START)) {
175 dev->hbm_state = MEI_HBM_IDLE;
176 dev_err(&dev->pdev->dev, "waiting for mei start failed\n");
183 * mei_hbm_start_req - sends start request message.
185 * @dev: the device structure
187 * returns 0 on success and < 0 on failure
189 int mei_hbm_start_req(struct mei_device *dev)
191 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
192 struct hbm_host_version_request *start_req;
193 const size_t len = sizeof(struct hbm_host_version_request);
196 mei_hbm_hdr(mei_hdr, len);
198 /* host start message */
199 start_req = (struct hbm_host_version_request *)dev->wr_msg.data;
200 memset(start_req, 0, len);
201 start_req->hbm_cmd = HOST_START_REQ_CMD;
202 start_req->host_version.major_version = HBM_MAJOR_VERSION;
203 start_req->host_version.minor_version = HBM_MINOR_VERSION;
205 dev->hbm_state = MEI_HBM_IDLE;
206 ret = mei_write_message(dev, mei_hdr, dev->wr_msg.data);
208 dev_err(&dev->pdev->dev, "version message write failed: ret = %d\n",
213 dev->hbm_state = MEI_HBM_START;
214 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
219 * mei_hbm_enum_clients_req - sends enumeration client request message.
221 * @dev: the device structure
223 * returns 0 on success and < 0 on failure
225 static int mei_hbm_enum_clients_req(struct mei_device *dev)
227 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
228 struct hbm_host_enum_request *enum_req;
229 const size_t len = sizeof(struct hbm_host_enum_request);
232 /* enumerate clients */
233 mei_hbm_hdr(mei_hdr, len);
235 enum_req = (struct hbm_host_enum_request *)dev->wr_msg.data;
236 memset(enum_req, 0, len);
237 enum_req->hbm_cmd = HOST_ENUM_REQ_CMD;
239 ret = mei_write_message(dev, mei_hdr, dev->wr_msg.data);
241 dev_err(&dev->pdev->dev, "enumeration request write failed: ret = %d.\n",
245 dev->hbm_state = MEI_HBM_ENUM_CLIENTS;
246 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
251 * mei_hbm_prop_req - request property for a single client
253 * @dev: the device structure
255 * returns 0 on success and < 0 on failure
258 static int mei_hbm_prop_req(struct mei_device *dev)
261 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
262 struct hbm_props_request *prop_req;
263 const size_t len = sizeof(struct hbm_props_request);
264 unsigned long next_client_index;
265 unsigned long client_num;
268 client_num = dev->me_client_presentation_num;
270 next_client_index = find_next_bit(dev->me_clients_map, MEI_CLIENTS_MAX,
271 dev->me_client_index);
273 /* We got all client properties */
274 if (next_client_index == MEI_CLIENTS_MAX) {
275 dev->hbm_state = MEI_HBM_STARTED;
276 schedule_work(&dev->init_work);
281 dev->me_clients[client_num].client_id = next_client_index;
282 dev->me_clients[client_num].mei_flow_ctrl_creds = 0;
284 mei_hbm_hdr(mei_hdr, len);
285 prop_req = (struct hbm_props_request *)dev->wr_msg.data;
287 memset(prop_req, 0, sizeof(struct hbm_props_request));
290 prop_req->hbm_cmd = HOST_CLIENT_PROPERTIES_REQ_CMD;
291 prop_req->address = next_client_index;
293 ret = mei_write_message(dev, mei_hdr, dev->wr_msg.data);
295 dev_err(&dev->pdev->dev, "properties request write failed: ret = %d\n",
300 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
301 dev->me_client_index = next_client_index;
307 * mei_hbm_pg - sends pg command
309 * @dev: the device structure
310 * @pg_cmd: the pg command code
312 * This function returns -EIO on write failure
314 int mei_hbm_pg(struct mei_device *dev, u8 pg_cmd)
316 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
317 struct hbm_power_gate *req;
318 const size_t len = sizeof(struct hbm_power_gate);
321 mei_hbm_hdr(mei_hdr, len);
323 req = (struct hbm_power_gate *)dev->wr_msg.data;
325 req->hbm_cmd = pg_cmd;
327 ret = mei_write_message(dev, mei_hdr, dev->wr_msg.data);
329 dev_err(&dev->pdev->dev, "power gate command write failed.\n");
332 EXPORT_SYMBOL_GPL(mei_hbm_pg);
335 * mei_hbm_stop_req - send stop request message
340 * This function returns -EIO on write failure
342 static int mei_hbm_stop_req(struct mei_device *dev)
344 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
345 struct hbm_host_stop_request *req =
346 (struct hbm_host_stop_request *)dev->wr_msg.data;
347 const size_t len = sizeof(struct hbm_host_stop_request);
349 mei_hbm_hdr(mei_hdr, len);
352 req->hbm_cmd = HOST_STOP_REQ_CMD;
353 req->reason = DRIVER_STOP_REQUEST;
355 return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
359 * mei_hbm_cl_flow_control_req - sends flow control request.
361 * @dev: the device structure
364 * This function returns -EIO on write failure
366 int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl)
368 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
369 const size_t len = sizeof(struct hbm_flow_control);
371 mei_hbm_hdr(mei_hdr, len);
372 mei_hbm_cl_hdr(cl, MEI_FLOW_CONTROL_CMD, dev->wr_msg.data, len);
374 cl_dbg(dev, cl, "sending flow control\n");
376 return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
380 * mei_hbm_add_single_flow_creds - adds single buffer credentials.
382 * @dev: the device structure
383 * @flow: flow control.
385 * return 0 on success, < 0 otherwise
387 static int mei_hbm_add_single_flow_creds(struct mei_device *dev,
388 struct hbm_flow_control *flow)
390 struct mei_me_client *me_cl;
393 id = mei_me_cl_by_id(dev, flow->me_addr);
395 dev_err(&dev->pdev->dev, "no such me client %d\n",
400 me_cl = &dev->me_clients[id];
401 if (me_cl->props.single_recv_buf) {
402 me_cl->mei_flow_ctrl_creds++;
403 dev_dbg(&dev->pdev->dev, "recv flow ctrl msg ME %d (single).\n",
405 dev_dbg(&dev->pdev->dev, "flow control credentials =%d.\n",
406 me_cl->mei_flow_ctrl_creds);
408 BUG(); /* error in flow control */
415 * mei_hbm_cl_flow_control_res - flow control response from me
417 * @dev: the device structure
418 * @flow_control: flow control response bus message
420 static void mei_hbm_cl_flow_control_res(struct mei_device *dev,
421 struct hbm_flow_control *flow_control)
425 if (!flow_control->host_addr) {
426 /* single receive buffer */
427 mei_hbm_add_single_flow_creds(dev, flow_control);
431 /* normal connection */
432 list_for_each_entry(cl, &dev->file_list, link) {
433 if (mei_hbm_cl_addr_equal(cl, flow_control)) {
434 cl->mei_flow_ctrl_creds++;
435 dev_dbg(&dev->pdev->dev, "flow ctrl msg for host %d ME %d.\n",
436 flow_control->host_addr, flow_control->me_addr);
437 dev_dbg(&dev->pdev->dev, "flow control credentials = %d.\n",
438 cl->mei_flow_ctrl_creds);
446 * mei_hbm_cl_disconnect_req - sends disconnect message to fw.
448 * @dev: the device structure
449 * @cl: a client to disconnect from
451 * This function returns -EIO on write failure
453 int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl *cl)
455 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
456 const size_t len = sizeof(struct hbm_client_connect_request);
458 mei_hbm_hdr(mei_hdr, len);
459 mei_hbm_cl_hdr(cl, CLIENT_DISCONNECT_REQ_CMD, dev->wr_msg.data, len);
461 return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
465 * mei_hbm_cl_disconnect_rsp - sends disconnect respose to the FW
467 * @dev: the device structure
468 * @cl: a client to disconnect from
470 * This function returns -EIO on write failure
472 int mei_hbm_cl_disconnect_rsp(struct mei_device *dev, struct mei_cl *cl)
474 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
475 const size_t len = sizeof(struct hbm_client_connect_response);
477 mei_hbm_hdr(mei_hdr, len);
478 mei_hbm_cl_hdr(cl, CLIENT_DISCONNECT_RES_CMD, dev->wr_msg.data, len);
480 return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
484 * mei_hbm_cl_disconnect_res - disconnect response from ME
486 * @dev: the device structure
487 * @rs: disconnect response bus message
489 static void mei_hbm_cl_disconnect_res(struct mei_device *dev,
490 struct hbm_client_connect_response *rs)
493 struct mei_cl_cb *cb, *next;
495 dev_dbg(&dev->pdev->dev, "hbm: disconnect response cl:host=%02d me=%02d status=%d\n",
496 rs->me_addr, rs->host_addr, rs->status);
498 list_for_each_entry_safe(cb, next, &dev->ctrl_rd_list.list, list) {
501 /* this should not happen */
507 if (mei_hbm_cl_addr_equal(cl, rs)) {
509 if (rs->status == MEI_CL_DISCONN_SUCCESS)
510 cl->state = MEI_FILE_DISCONNECTED;
520 * mei_hbm_cl_connect_req - send connection request to specific me client
522 * @dev: the device structure
523 * @cl: a client to connect to
525 * returns -EIO on write failure
527 int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl *cl)
529 struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
530 const size_t len = sizeof(struct hbm_client_connect_request);
532 mei_hbm_hdr(mei_hdr, len);
533 mei_hbm_cl_hdr(cl, CLIENT_CONNECT_REQ_CMD, dev->wr_msg.data, len);
535 return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
539 * mei_hbm_cl_connect_res - connect response from the ME
541 * @dev: the device structure
542 * @rs: connect response bus message
544 static void mei_hbm_cl_connect_res(struct mei_device *dev,
545 struct hbm_client_connect_response *rs)
549 struct mei_cl_cb *cb, *next;
551 dev_dbg(&dev->pdev->dev, "hbm: connect response cl:host=%02d me=%02d status=%s\n",
552 rs->me_addr, rs->host_addr,
553 mei_cl_conn_status_str(rs->status));
557 list_for_each_entry_safe(cb, next, &dev->ctrl_rd_list.list, list) {
560 /* this should not happen */
562 list_del_init(&cb->list);
566 if (cb->fop_type != MEI_FOP_CONNECT)
569 if (mei_hbm_cl_addr_equal(cl, rs)) {
579 if (rs->status == MEI_CL_CONN_SUCCESS)
580 cl->state = MEI_FILE_CONNECTED;
582 cl->state = MEI_FILE_DISCONNECTED;
583 cl->status = mei_cl_conn_status_to_errno(rs->status);
588 * mei_hbm_fw_disconnect_req - disconnect request initiated by ME firmware
589 * host sends disconnect response
591 * @dev: the device structure.
592 * @disconnect_req: disconnect request bus message from the me
594 * returns -ENOMEM on allocation failure
596 static int mei_hbm_fw_disconnect_req(struct mei_device *dev,
597 struct hbm_client_connect_request *disconnect_req)
600 struct mei_cl_cb *cb;
602 list_for_each_entry(cl, &dev->file_list, link) {
603 if (mei_hbm_cl_addr_equal(cl, disconnect_req)) {
604 dev_dbg(&dev->pdev->dev, "disconnect request host client %d ME client %d.\n",
605 disconnect_req->host_addr,
606 disconnect_req->me_addr);
607 cl->state = MEI_FILE_DISCONNECTED;
610 cb = mei_io_cb_init(cl, NULL);
613 cb->fop_type = MEI_FOP_DISCONNECT_RSP;
614 cl_dbg(dev, cl, "add disconnect response as first\n");
615 list_add(&cb->list, &dev->ctrl_wr_list.list);
625 * mei_hbm_version_is_supported - checks whether the driver can
626 * support the hbm version of the device
628 * @dev: the device structure
629 * returns true if driver can support hbm version of the device
631 bool mei_hbm_version_is_supported(struct mei_device *dev)
633 return (dev->version.major_version < HBM_MAJOR_VERSION) ||
634 (dev->version.major_version == HBM_MAJOR_VERSION &&
635 dev->version.minor_version <= HBM_MINOR_VERSION);
639 * mei_hbm_dispatch - bottom half read routine after ISR to
640 * handle the read bus message cmd processing.
642 * @dev: the device structure
643 * @mei_hdr: header of bus message
645 * returns 0 on success and < 0 on failure
647 int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
649 struct mei_bus_message *mei_msg;
650 struct mei_me_client *me_client;
651 struct hbm_host_version_response *version_res;
652 struct hbm_client_connect_response *connect_res;
653 struct hbm_client_connect_response *disconnect_res;
654 struct hbm_client_connect_request *disconnect_req;
655 struct hbm_flow_control *flow_control;
656 struct hbm_props_response *props_res;
657 struct hbm_host_enum_response *enum_res;
659 /* read the message to our buffer */
660 BUG_ON(hdr->length >= sizeof(dev->rd_msg_buf));
661 mei_read_slots(dev, dev->rd_msg_buf, hdr->length);
662 mei_msg = (struct mei_bus_message *)dev->rd_msg_buf;
664 /* ignore spurious message and prevent reset nesting
665 * hbm is put to idle during system reset
667 if (dev->hbm_state == MEI_HBM_IDLE) {
668 dev_dbg(&dev->pdev->dev, "hbm: state is idle ignore spurious messages\n");
672 switch (mei_msg->hbm_cmd) {
673 case HOST_START_RES_CMD:
674 dev_dbg(&dev->pdev->dev, "hbm: start: response message received.\n");
676 dev->init_clients_timer = 0;
678 version_res = (struct hbm_host_version_response *)mei_msg;
680 dev_dbg(&dev->pdev->dev, "HBM VERSION: DRIVER=%02d:%02d DEVICE=%02d:%02d\n",
681 HBM_MAJOR_VERSION, HBM_MINOR_VERSION,
682 version_res->me_max_version.major_version,
683 version_res->me_max_version.minor_version);
685 if (version_res->host_version_supported) {
686 dev->version.major_version = HBM_MAJOR_VERSION;
687 dev->version.minor_version = HBM_MINOR_VERSION;
689 dev->version.major_version =
690 version_res->me_max_version.major_version;
691 dev->version.minor_version =
692 version_res->me_max_version.minor_version;
695 if (!mei_hbm_version_is_supported(dev)) {
696 dev_warn(&dev->pdev->dev, "hbm: start: version mismatch - stopping the driver.\n");
698 dev->hbm_state = MEI_HBM_STOPPED;
699 if (mei_hbm_stop_req(dev)) {
700 dev_err(&dev->pdev->dev, "hbm: start: failed to send stop request\n");
706 if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
707 dev->hbm_state != MEI_HBM_START) {
708 dev_err(&dev->pdev->dev, "hbm: start: state mismatch, [%d, %d]\n",
709 dev->dev_state, dev->hbm_state);
713 dev->hbm_state = MEI_HBM_STARTED;
715 if (mei_hbm_enum_clients_req(dev)) {
716 dev_err(&dev->pdev->dev, "hbm: start: failed to send enumeration request\n");
720 wake_up_interruptible(&dev->wait_recvd_msg);
723 case CLIENT_CONNECT_RES_CMD:
724 dev_dbg(&dev->pdev->dev, "hbm: client connect response: message received.\n");
726 connect_res = (struct hbm_client_connect_response *) mei_msg;
727 mei_hbm_cl_connect_res(dev, connect_res);
728 wake_up(&dev->wait_recvd_msg);
731 case CLIENT_DISCONNECT_RES_CMD:
732 dev_dbg(&dev->pdev->dev, "hbm: client disconnect response: message received.\n");
734 disconnect_res = (struct hbm_client_connect_response *) mei_msg;
735 mei_hbm_cl_disconnect_res(dev, disconnect_res);
736 wake_up(&dev->wait_recvd_msg);
739 case MEI_FLOW_CONTROL_CMD:
740 dev_dbg(&dev->pdev->dev, "hbm: client flow control response: message received.\n");
742 flow_control = (struct hbm_flow_control *) mei_msg;
743 mei_hbm_cl_flow_control_res(dev, flow_control);
746 case MEI_PG_ISOLATION_ENTRY_RES_CMD:
747 dev_dbg(&dev->pdev->dev, "power gate isolation entry response received\n");
748 dev->pg_event = MEI_PG_EVENT_RECEIVED;
749 if (waitqueue_active(&dev->wait_pg))
750 wake_up(&dev->wait_pg);
753 case MEI_PG_ISOLATION_EXIT_REQ_CMD:
754 dev_dbg(&dev->pdev->dev, "power gate isolation exit request received\n");
755 dev->pg_event = MEI_PG_EVENT_RECEIVED;
756 if (waitqueue_active(&dev->wait_pg))
757 wake_up(&dev->wait_pg);
760 * If the driver is not waiting on this then
761 * this is HW initiated exit from PG.
762 * Start runtime pm resume sequence to exit from PG.
764 pm_request_resume(&dev->pdev->dev);
767 case HOST_CLIENT_PROPERTIES_RES_CMD:
768 dev_dbg(&dev->pdev->dev, "hbm: properties response: message received.\n");
770 dev->init_clients_timer = 0;
772 if (dev->me_clients == NULL) {
773 dev_err(&dev->pdev->dev, "hbm: properties response: mei_clients not allocated\n");
777 props_res = (struct hbm_props_response *)mei_msg;
778 me_client = &dev->me_clients[dev->me_client_presentation_num];
780 if (props_res->status) {
781 dev_err(&dev->pdev->dev, "hbm: properties response: wrong status = %d\n",
786 if (me_client->client_id != props_res->address) {
787 dev_err(&dev->pdev->dev, "hbm: properties response: address mismatch %d ?= %d\n",
788 me_client->client_id, props_res->address);
792 if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
793 dev->hbm_state != MEI_HBM_CLIENT_PROPERTIES) {
794 dev_err(&dev->pdev->dev, "hbm: properties response: state mismatch, [%d, %d]\n",
795 dev->dev_state, dev->hbm_state);
799 me_client->props = props_res->client_properties;
800 dev->me_client_index++;
801 dev->me_client_presentation_num++;
803 /* request property for the next client */
804 if (mei_hbm_prop_req(dev))
809 case HOST_ENUM_RES_CMD:
810 dev_dbg(&dev->pdev->dev, "hbm: enumeration response: message received\n");
812 dev->init_clients_timer = 0;
814 enum_res = (struct hbm_host_enum_response *) mei_msg;
815 BUILD_BUG_ON(sizeof(dev->me_clients_map)
816 < sizeof(enum_res->valid_addresses));
817 memcpy(dev->me_clients_map, enum_res->valid_addresses,
818 sizeof(enum_res->valid_addresses));
820 if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
821 dev->hbm_state != MEI_HBM_ENUM_CLIENTS) {
822 dev_err(&dev->pdev->dev, "hbm: enumeration response: state mismatch, [%d, %d]\n",
823 dev->dev_state, dev->hbm_state);
827 if (mei_hbm_me_cl_allocate(dev)) {
828 dev_err(&dev->pdev->dev, "hbm: enumeration response: cannot allocate clients array\n");
832 dev->hbm_state = MEI_HBM_CLIENT_PROPERTIES;
834 /* first property request */
835 if (mei_hbm_prop_req(dev))
840 case HOST_STOP_RES_CMD:
841 dev_dbg(&dev->pdev->dev, "hbm: stop response: message received\n");
843 dev->init_clients_timer = 0;
845 if (dev->hbm_state != MEI_HBM_STOPPED) {
846 dev_err(&dev->pdev->dev, "hbm: stop response: state mismatch, [%d, %d]\n",
847 dev->dev_state, dev->hbm_state);
851 dev->dev_state = MEI_DEV_POWER_DOWN;
852 dev_info(&dev->pdev->dev, "hbm: stop response: resetting.\n");
853 /* force the reset */
857 case CLIENT_DISCONNECT_REQ_CMD:
858 dev_dbg(&dev->pdev->dev, "hbm: disconnect request: message received\n");
860 disconnect_req = (struct hbm_client_connect_request *)mei_msg;
861 mei_hbm_fw_disconnect_req(dev, disconnect_req);
864 case ME_STOP_REQ_CMD:
865 dev_dbg(&dev->pdev->dev, "hbm: stop request: message received\n");
866 dev->hbm_state = MEI_HBM_STOPPED;
867 if (mei_hbm_stop_req(dev)) {
868 dev_err(&dev->pdev->dev, "hbm: start: failed to send stop request\n");