Lines Matching +full:os +full:- +full:initiated
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2003-2022, Intel Corporation. All rights reserved.
68 * mei_cl_conn_status_to_errno - convert client connect response
79 case MEI_CL_CONN_NOT_FOUND: return -ENOTTY; in mei_cl_conn_status_to_errno()
80 case MEI_CL_CONN_ALREADY_STARTED: return -EBUSY; in mei_cl_conn_status_to_errno()
81 case MEI_CL_CONN_OUT_OF_RESOURCES: return -EBUSY; in mei_cl_conn_status_to_errno()
82 case MEI_CL_CONN_MESSAGE_SMALL: return -EINVAL; in mei_cl_conn_status_to_errno()
83 case MEI_CL_CONN_NOT_ALLOWED: return -EBUSY; in mei_cl_conn_status_to_errno()
84 default: return -EINVAL; in mei_cl_conn_status_to_errno()
89 * mei_hbm_write_message - wrapper for sending hbm messages.
99 return mei_write_message(dev, hdr, sizeof(*hdr), data, hdr->length); in mei_hbm_write_message()
103 * mei_hbm_idle - set hbm to idle state
109 dev->init_clients_timer = 0; in mei_hbm_idle()
110 dev->hbm_state = MEI_HBM_IDLE; in mei_hbm_idle()
114 * mei_hbm_reset - reset hbm counters and book keeping data structurs
126 * mei_hbm_hdr - construct hbm header
135 mei_hdr->length = length; in mei_hbm_hdr()
136 mei_hdr->msg_complete = 1; in mei_hbm_hdr()
140 * mei_hbm_cl_hdr - construct client hbm header
154 cmd->hbm_cmd = hbm_cmd; in mei_hbm_cl_hdr()
155 cmd->host_addr = mei_cl_host_addr(cl); in mei_hbm_cl_hdr()
156 cmd->me_addr = mei_cl_me_id(cl); in mei_hbm_cl_hdr()
160 * mei_hbm_cl_write - write simple hbm client message
182 * mei_hbm_cl_addr_equal - check if the client's and
193 return mei_cl_host_addr(cl) == cmd->host_addr && in mei_hbm_cl_addr_equal()
194 mei_cl_me_id(cl) == cmd->me_addr; in mei_hbm_cl_addr_equal()
198 * mei_hbm_cl_find_by_cmd - find recipient client
211 list_for_each_entry(cl, &dev->file_list, link) in mei_hbm_cl_find_by_cmd()
219 * mei_hbm_start_wait - wait for start response message.
229 if (dev->hbm_state > MEI_HBM_STARTING) in mei_hbm_start_wait()
232 mutex_unlock(&dev->device_lock); in mei_hbm_start_wait()
233 ret = wait_event_timeout(dev->wait_hbm_start, in mei_hbm_start_wait()
234 dev->hbm_state != MEI_HBM_STARTING, in mei_hbm_start_wait()
235 dev->timeouts.hbm); in mei_hbm_start_wait()
236 mutex_lock(&dev->device_lock); in mei_hbm_start_wait()
238 if (ret == 0 && (dev->hbm_state <= MEI_HBM_STARTING)) { in mei_hbm_start_wait()
239 dev->hbm_state = MEI_HBM_IDLE; in mei_hbm_start_wait()
240 dev_err(dev->dev, "waiting for mei start failed\n"); in mei_hbm_start_wait()
241 return -ETIME; in mei_hbm_start_wait()
247 * mei_hbm_start_req - sends start request message.
269 dev->hbm_state = MEI_HBM_IDLE; in mei_hbm_start_req()
272 dev_err(dev->dev, "version message write failed: ret = %d\n", in mei_hbm_start_req()
277 dev->hbm_state = MEI_HBM_STARTING; in mei_hbm_start_req()
278 dev->init_clients_timer = dev->timeouts.client_init; in mei_hbm_start_req()
284 * mei_hbm_dma_setup_req() - setup DMA request
303 paddr = dev->dr_dscr[i].daddr; in mei_hbm_dma_setup_req()
306 req.dma_dscr[i].size = dev->dr_dscr[i].size; in mei_hbm_dma_setup_req()
313 dev_err(dev->dev, "dma setup request write failed: ret = %d.\n", in mei_hbm_dma_setup_req()
318 dev->hbm_state = MEI_HBM_DR_SETUP; in mei_hbm_dma_setup_req()
319 dev->init_clients_timer = dev->timeouts.client_init; in mei_hbm_dma_setup_req()
325 * mei_hbm_capabilities_req - request capabilities
341 if (dev->hbm_f_vt_supported) in mei_hbm_capabilities_req()
344 if (dev->hbm_f_cd_supported) in mei_hbm_capabilities_req()
347 if (dev->hbm_f_gsc_supported) in mei_hbm_capabilities_req()
352 dev_err(dev->dev, in mei_hbm_capabilities_req()
357 dev->hbm_state = MEI_HBM_CAP_SETUP; in mei_hbm_capabilities_req()
358 dev->init_clients_timer = dev->timeouts.client_init; in mei_hbm_capabilities_req()
364 * mei_hbm_enum_clients_req - sends enumeration client request message.
381 req.flags |= dev->hbm_f_dc_supported ? MEI_HBM_ENUM_F_ALLOW_ADD : 0; in mei_hbm_enum_clients_req()
382 req.flags |= dev->hbm_f_ie_supported ? in mei_hbm_enum_clients_req()
387 dev_err(dev->dev, "enumeration request write failed: ret = %d.\n", in mei_hbm_enum_clients_req()
391 dev->hbm_state = MEI_HBM_ENUM_CLIENTS; in mei_hbm_enum_clients_req()
392 dev->init_clients_timer = dev->timeouts.client_init; in mei_hbm_enum_clients_req()
398 * mei_hbm_me_cl_add - add new me client to the list
403 * Return: 0 on success and -ENOMEM on allocation failure
410 const uuid_le *uuid = &res->client_properties.protocol_name; in mei_hbm_me_cl_add()
416 return -ENOMEM; in mei_hbm_me_cl_add()
420 me_cl->props = res->client_properties; in mei_hbm_me_cl_add()
421 me_cl->client_id = res->me_addr; in mei_hbm_me_cl_add()
422 me_cl->tx_flow_ctrl_creds = 0; in mei_hbm_me_cl_add()
430 * mei_hbm_add_cl_resp - send response to fw on client add request
444 dev_dbg(dev->dev, "adding client response\n"); in mei_hbm_add_cl_resp()
455 dev_err(dev->dev, "add client response write failed: ret = %d\n", in mei_hbm_add_cl_resp()
461 * mei_hbm_fw_add_cl_req - request from the fw to add a client
481 if (dev->dev_state == MEI_DEV_ENABLED) in mei_hbm_fw_add_cl_req()
482 schedule_work(&dev->bus_rescan_work); in mei_hbm_fw_add_cl_req()
484 return mei_hbm_add_cl_resp(dev, req->me_addr, status); in mei_hbm_fw_add_cl_req()
488 * mei_hbm_cl_notify_req - send notification request
494 * Return: 0 on success and -EIO on write failure
511 dev_err(dev->dev, "notify request failed: ret = %d\n", ret); in mei_hbm_cl_notify_req()
517 * notify_res_to_fop - convert notification response to the proper
529 return mei_cl_notify_req2fop(rs->start); in notify_res_to_fop()
533 * mei_hbm_cl_notify_start_res - update the client state according
547 cl_dbg(dev, cl, "hbm: notify start response status=%d\n", rs->status); in mei_hbm_cl_notify_start_res()
549 if (rs->status == MEI_HBMS_SUCCESS || in mei_hbm_cl_notify_start_res()
550 rs->status == MEI_HBMS_ALREADY_STARTED) { in mei_hbm_cl_notify_start_res()
551 cl->notify_en = true; in mei_hbm_cl_notify_start_res()
552 cl->status = 0; in mei_hbm_cl_notify_start_res()
554 cl->status = -EINVAL; in mei_hbm_cl_notify_start_res()
559 * mei_hbm_cl_notify_stop_res - update the client state according
573 cl_dbg(dev, cl, "hbm: notify stop response status=%d\n", rs->status); in mei_hbm_cl_notify_stop_res()
575 if (rs->status == MEI_HBMS_SUCCESS || in mei_hbm_cl_notify_stop_res()
576 rs->status == MEI_HBMS_NOT_STARTED) { in mei_hbm_cl_notify_stop_res()
577 cl->notify_en = false; in mei_hbm_cl_notify_stop_res()
578 cl->status = 0; in mei_hbm_cl_notify_stop_res()
581 cl->status = -EINVAL; in mei_hbm_cl_notify_stop_res()
586 * mei_hbm_cl_notify - signal notification event
602 * mei_hbm_cl_dma_map_req - send client dma map request
607 * Return: 0 on success and -EIO on write failure
620 req.client_buffer_id = cl->dma.buffer_id; in mei_hbm_cl_dma_map_req()
621 req.address_lsb = lower_32_bits(cl->dma.daddr); in mei_hbm_cl_dma_map_req()
622 req.address_msb = upper_32_bits(cl->dma.daddr); in mei_hbm_cl_dma_map_req()
623 req.size = cl->dma.size; in mei_hbm_cl_dma_map_req()
627 dev_err(dev->dev, "dma map request failed: ret = %d\n", ret); in mei_hbm_cl_dma_map_req()
633 * mei_hbm_cl_dma_unmap_req - send client dma unmap request
638 * Return: 0 on success and -EIO on write failure
651 req.client_buffer_id = cl->dma.buffer_id; in mei_hbm_cl_dma_unmap_req()
655 dev_err(dev->dev, "dma unmap request failed: ret = %d\n", ret); in mei_hbm_cl_dma_unmap_req()
667 list_for_each_entry_safe(cb, next, &dev->ctrl_rd_list, list) { in mei_hbm_cl_dma_map_res()
668 if (cb->fop_type != MEI_FOP_DMA_MAP) in mei_hbm_cl_dma_map_res()
670 if (!cb->cl->dma.buffer_id || cb->cl->dma_mapped) in mei_hbm_cl_dma_map_res()
673 cl = cb->cl; in mei_hbm_cl_dma_map_res()
679 if (res->status) { in mei_hbm_cl_dma_map_res()
680 dev_err(dev->dev, "cl dma map failed %d\n", res->status); in mei_hbm_cl_dma_map_res()
681 cl->status = -EFAULT; in mei_hbm_cl_dma_map_res()
683 dev_dbg(dev->dev, "cl dma map succeeded\n"); in mei_hbm_cl_dma_map_res()
684 cl->dma_mapped = 1; in mei_hbm_cl_dma_map_res()
685 cl->status = 0; in mei_hbm_cl_dma_map_res()
687 wake_up(&cl->wait); in mei_hbm_cl_dma_map_res()
697 list_for_each_entry_safe(cb, next, &dev->ctrl_rd_list, list) { in mei_hbm_cl_dma_unmap_res()
698 if (cb->fop_type != MEI_FOP_DMA_UNMAP) in mei_hbm_cl_dma_unmap_res()
700 if (!cb->cl->dma.buffer_id || !cb->cl->dma_mapped) in mei_hbm_cl_dma_unmap_res()
703 cl = cb->cl; in mei_hbm_cl_dma_unmap_res()
709 if (res->status) { in mei_hbm_cl_dma_unmap_res()
710 dev_err(dev->dev, "cl dma unmap failed %d\n", res->status); in mei_hbm_cl_dma_unmap_res()
711 cl->status = -EFAULT; in mei_hbm_cl_dma_unmap_res()
713 dev_dbg(dev->dev, "cl dma unmap succeeded\n"); in mei_hbm_cl_dma_unmap_res()
714 cl->dma_mapped = 0; in mei_hbm_cl_dma_unmap_res()
715 cl->status = 0; in mei_hbm_cl_dma_unmap_res()
717 wake_up(&cl->wait); in mei_hbm_cl_dma_unmap_res()
721 * mei_hbm_prop_req - request property for a single client
735 addr = find_next_bit(dev->me_clients_map, MEI_CLIENTS_MAX, start_idx); in mei_hbm_prop_req()
739 dev->hbm_state = MEI_HBM_STARTED; in mei_hbm_prop_req()
753 dev_err(dev->dev, "properties request write failed: ret = %d\n", in mei_hbm_prop_req()
758 dev->init_clients_timer = dev->timeouts.client_init; in mei_hbm_prop_req()
765 * mei_hbm_pg - sends pg command
770 * Return: -EIO on write failure
771 * -EOPNOTSUPP if the operation is not supported by the protocol
779 if (!dev->hbm_f_pg_supported) in mei_hbm_pg()
780 return -EOPNOTSUPP; in mei_hbm_pg()
789 dev_err(dev->dev, "power gate command write failed.\n"); in mei_hbm_pg()
795 * mei_hbm_stop_req - send stop request message
799 * Return: -EIO on write failure
816 * mei_hbm_cl_flow_control_req - sends flow control request.
821 * Return: -EIO on write failure
833 * mei_hbm_add_single_tx_flow_ctrl_creds - adds single buffer credentials.
846 me_cl = mei_me_cl_by_id(dev, fctrl->me_addr); in mei_hbm_add_single_tx_flow_ctrl_creds()
848 dev_err(dev->dev, "no such me client %d\n", fctrl->me_addr); in mei_hbm_add_single_tx_flow_ctrl_creds()
849 return -ENOENT; in mei_hbm_add_single_tx_flow_ctrl_creds()
852 if (WARN_ON(me_cl->props.single_recv_buf == 0)) { in mei_hbm_add_single_tx_flow_ctrl_creds()
853 rets = -EINVAL; in mei_hbm_add_single_tx_flow_ctrl_creds()
857 me_cl->tx_flow_ctrl_creds++; in mei_hbm_add_single_tx_flow_ctrl_creds()
858 dev_dbg(dev->dev, "recv flow ctrl msg ME %d (single) creds = %d.\n", in mei_hbm_add_single_tx_flow_ctrl_creds()
859 fctrl->me_addr, me_cl->tx_flow_ctrl_creds); in mei_hbm_add_single_tx_flow_ctrl_creds()
868 * mei_hbm_cl_tx_flow_ctrl_creds_res - flow control response from me
878 if (!fctrl->host_addr) { in mei_hbm_cl_tx_flow_ctrl_creds_res()
886 cl->tx_flow_ctrl_creds++; in mei_hbm_cl_tx_flow_ctrl_creds_res()
888 cl->tx_flow_ctrl_creds); in mei_hbm_cl_tx_flow_ctrl_creds_res()
894 * mei_hbm_cl_disconnect_req - sends disconnect message to fw.
899 * Return: -EIO on write failure
910 * mei_hbm_cl_disconnect_rsp - sends disconnect respose to the FW
915 * Return: -EIO on write failure
926 * mei_hbm_cl_disconnect_res - update the client state according
939 cl_dbg(dev, cl, "hbm: disconnect response status=%d\n", rs->status); in mei_hbm_cl_disconnect_res()
941 if (rs->status == MEI_CL_DISCONN_SUCCESS) in mei_hbm_cl_disconnect_res()
942 cl->state = MEI_FILE_DISCONNECT_REPLY; in mei_hbm_cl_disconnect_res()
943 cl->status = 0; in mei_hbm_cl_disconnect_res()
947 * mei_hbm_cl_connect_req - send connection request to specific me client
952 * Return: -EIO on write failure
963 * mei_hbm_cl_connect_res - update the client state according
977 mei_cl_conn_status_str(rs->status)); in mei_hbm_cl_connect_res()
979 if (rs->status == MEI_CL_CONN_SUCCESS) in mei_hbm_cl_connect_res()
980 cl->state = MEI_FILE_CONNECTED; in mei_hbm_cl_connect_res()
982 cl->state = MEI_FILE_DISCONNECT_REPLY; in mei_hbm_cl_connect_res()
983 if (rs->status == MEI_CL_CONN_NOT_FOUND) { in mei_hbm_cl_connect_res()
984 mei_me_cl_del(dev, cl->me_cl); in mei_hbm_cl_connect_res()
985 if (dev->dev_state == MEI_DEV_ENABLED) in mei_hbm_cl_connect_res()
986 schedule_work(&dev->bus_rescan_work); in mei_hbm_cl_connect_res()
989 cl->status = mei_cl_conn_status_to_errno(rs->status); in mei_hbm_cl_connect_res()
993 * mei_hbm_cl_res - process hbm response received on behalf
1008 list_for_each_entry_safe(cb, next, &dev->ctrl_rd_list, list) { in mei_hbm_cl_res()
1010 cl = cb->cl; in mei_hbm_cl_res()
1012 if (cb->fop_type != fop_type) in mei_hbm_cl_res()
1016 list_del_init(&cb->list); in mei_hbm_cl_res()
1041 cl->timer_count = 0; in mei_hbm_cl_res()
1042 wake_up(&cl->wait); in mei_hbm_cl_res()
1047 * mei_hbm_fw_disconnect_req - disconnect request initiated by ME firmware
1053 * Return: -ENOMEM on allocation failure
1064 cl->state = MEI_FILE_DISCONNECTING; in mei_hbm_fw_disconnect_req()
1065 cl->timer_count = 0; in mei_hbm_fw_disconnect_req()
1070 return -ENOMEM; in mei_hbm_fw_disconnect_req()
1076 * mei_hbm_pg_enter_res - PG enter response received
1080 * Return: 0 on success, -EPROTO on state mismatch
1085 dev->pg_event != MEI_PG_EVENT_WAIT) { in mei_hbm_pg_enter_res()
1086 dev_err(dev->dev, "hbm: pg entry response: state mismatch [%s, %d]\n", in mei_hbm_pg_enter_res()
1087 mei_pg_state_str(mei_pg_state(dev)), dev->pg_event); in mei_hbm_pg_enter_res()
1088 return -EPROTO; in mei_hbm_pg_enter_res()
1091 dev->pg_event = MEI_PG_EVENT_RECEIVED; in mei_hbm_pg_enter_res()
1092 wake_up(&dev->wait_pg); in mei_hbm_pg_enter_res()
1098 * mei_hbm_pg_resume - process with PG resume
1104 pm_request_resume(dev->dev); in mei_hbm_pg_resume()
1109 * mei_hbm_pg_exit_res - PG exit response received
1113 * Return: 0 on success, -EPROTO on state mismatch
1118 (dev->pg_event != MEI_PG_EVENT_WAIT && in mei_hbm_pg_exit_res()
1119 dev->pg_event != MEI_PG_EVENT_IDLE)) { in mei_hbm_pg_exit_res()
1120 dev_err(dev->dev, "hbm: pg exit response: state mismatch [%s, %d]\n", in mei_hbm_pg_exit_res()
1121 mei_pg_state_str(mei_pg_state(dev)), dev->pg_event); in mei_hbm_pg_exit_res()
1122 return -EPROTO; in mei_hbm_pg_exit_res()
1125 switch (dev->pg_event) { in mei_hbm_pg_exit_res()
1127 dev->pg_event = MEI_PG_EVENT_RECEIVED; in mei_hbm_pg_exit_res()
1128 wake_up(&dev->wait_pg); in mei_hbm_pg_exit_res()
1133 * this is HW initiated exit from PG. in mei_hbm_pg_exit_res()
1136 dev->pg_event = MEI_PG_EVENT_RECEIVED; in mei_hbm_pg_exit_res()
1141 dev->pg_event); in mei_hbm_pg_exit_res()
1142 return -EPROTO; in mei_hbm_pg_exit_res()
1149 * mei_hbm_config_features - check what hbm features and commands
1157 dev->hbm_f_pg_supported = 0; in mei_hbm_config_features()
1158 if (dev->version.major_version > HBM_MAJOR_VERSION_PGI) in mei_hbm_config_features()
1159 dev->hbm_f_pg_supported = 1; in mei_hbm_config_features()
1161 if (dev->version.major_version == HBM_MAJOR_VERSION_PGI && in mei_hbm_config_features()
1162 dev->version.minor_version >= HBM_MINOR_VERSION_PGI) in mei_hbm_config_features()
1163 dev->hbm_f_pg_supported = 1; in mei_hbm_config_features()
1165 dev->hbm_f_dc_supported = 0; in mei_hbm_config_features()
1166 if (dev->version.major_version >= HBM_MAJOR_VERSION_DC) in mei_hbm_config_features()
1167 dev->hbm_f_dc_supported = 1; in mei_hbm_config_features()
1169 dev->hbm_f_ie_supported = 0; in mei_hbm_config_features()
1170 if (dev->version.major_version >= HBM_MAJOR_VERSION_IE) in mei_hbm_config_features()
1171 dev->hbm_f_ie_supported = 1; in mei_hbm_config_features()
1174 dev->hbm_f_dot_supported = 0; in mei_hbm_config_features()
1175 if (dev->version.major_version >= HBM_MAJOR_VERSION_DOT) in mei_hbm_config_features()
1176 dev->hbm_f_dot_supported = 1; in mei_hbm_config_features()
1179 dev->hbm_f_ev_supported = 0; in mei_hbm_config_features()
1180 if (dev->version.major_version >= HBM_MAJOR_VERSION_EV) in mei_hbm_config_features()
1181 dev->hbm_f_ev_supported = 1; in mei_hbm_config_features()
1184 dev->hbm_f_fa_supported = 0; in mei_hbm_config_features()
1185 if (dev->version.major_version >= HBM_MAJOR_VERSION_FA) in mei_hbm_config_features()
1186 dev->hbm_f_fa_supported = 1; in mei_hbm_config_features()
1188 /* OS ver message Support */ in mei_hbm_config_features()
1189 dev->hbm_f_os_supported = 0; in mei_hbm_config_features()
1190 if (dev->version.major_version >= HBM_MAJOR_VERSION_OS) in mei_hbm_config_features()
1191 dev->hbm_f_os_supported = 1; in mei_hbm_config_features()
1194 dev->hbm_f_dr_supported = 0; in mei_hbm_config_features()
1195 if (dev->version.major_version > HBM_MAJOR_VERSION_DR || in mei_hbm_config_features()
1196 (dev->version.major_version == HBM_MAJOR_VERSION_DR && in mei_hbm_config_features()
1197 dev->version.minor_version >= HBM_MINOR_VERSION_DR)) in mei_hbm_config_features()
1198 dev->hbm_f_dr_supported = 1; in mei_hbm_config_features()
1201 dev->hbm_f_vt_supported = 0; in mei_hbm_config_features()
1202 if (dev->version.major_version > HBM_MAJOR_VERSION_VT || in mei_hbm_config_features()
1203 (dev->version.major_version == HBM_MAJOR_VERSION_VT && in mei_hbm_config_features()
1204 dev->version.minor_version >= HBM_MINOR_VERSION_VT)) in mei_hbm_config_features()
1205 dev->hbm_f_vt_supported = 1; in mei_hbm_config_features()
1208 if (dev->version.major_version > HBM_MAJOR_VERSION_GSC || in mei_hbm_config_features()
1209 (dev->version.major_version == HBM_MAJOR_VERSION_GSC && in mei_hbm_config_features()
1210 dev->version.minor_version >= HBM_MINOR_VERSION_GSC)) in mei_hbm_config_features()
1211 dev->hbm_f_gsc_supported = 1; in mei_hbm_config_features()
1214 dev->hbm_f_cap_supported = 0; in mei_hbm_config_features()
1215 if (dev->version.major_version > HBM_MAJOR_VERSION_CAP || in mei_hbm_config_features()
1216 (dev->version.major_version == HBM_MAJOR_VERSION_CAP && in mei_hbm_config_features()
1217 dev->version.minor_version >= HBM_MINOR_VERSION_CAP)) in mei_hbm_config_features()
1218 dev->hbm_f_cap_supported = 1; in mei_hbm_config_features()
1221 dev->hbm_f_cd_supported = 0; in mei_hbm_config_features()
1222 if (dev->version.major_version > HBM_MAJOR_VERSION_CD || in mei_hbm_config_features()
1223 (dev->version.major_version == HBM_MAJOR_VERSION_CD && in mei_hbm_config_features()
1224 dev->version.minor_version >= HBM_MINOR_VERSION_CD)) in mei_hbm_config_features()
1225 dev->hbm_f_cd_supported = 1; in mei_hbm_config_features()
1229 * mei_hbm_version_is_supported - checks whether the driver can
1237 return (dev->version.major_version < HBM_MAJOR_VERSION) || in mei_hbm_version_is_supported()
1238 (dev->version.major_version == HBM_MAJOR_VERSION && in mei_hbm_version_is_supported()
1239 dev->version.minor_version <= HBM_MINOR_VERSION); in mei_hbm_version_is_supported()
1243 * mei_hbm_dispatch - bottom half read routine after ISR to
1268 BUG_ON(hdr->length >= sizeof(dev->rd_msg_buf)); in mei_hbm_dispatch()
1269 mei_read_slots(dev, dev->rd_msg_buf, hdr->length); in mei_hbm_dispatch()
1270 mei_msg = (struct mei_bus_message *)dev->rd_msg_buf; in mei_hbm_dispatch()
1276 if (dev->hbm_state == MEI_HBM_IDLE) { in mei_hbm_dispatch()
1277 dev_dbg(dev->dev, "hbm: state is idle ignore spurious messages\n"); in mei_hbm_dispatch()
1281 switch (mei_msg->hbm_cmd) { in mei_hbm_dispatch()
1283 dev_dbg(dev->dev, "hbm: start: response message received.\n"); in mei_hbm_dispatch()
1285 dev->init_clients_timer = 0; in mei_hbm_dispatch()
1289 dev_dbg(dev->dev, "HBM VERSION: DRIVER=%02d:%02d DEVICE=%02d:%02d\n", in mei_hbm_dispatch()
1291 version_res->me_max_version.major_version, in mei_hbm_dispatch()
1292 version_res->me_max_version.minor_version); in mei_hbm_dispatch()
1294 if (version_res->host_version_supported) { in mei_hbm_dispatch()
1295 dev->version.major_version = HBM_MAJOR_VERSION; in mei_hbm_dispatch()
1296 dev->version.minor_version = HBM_MINOR_VERSION; in mei_hbm_dispatch()
1298 dev->version.major_version = in mei_hbm_dispatch()
1299 version_res->me_max_version.major_version; in mei_hbm_dispatch()
1300 dev->version.minor_version = in mei_hbm_dispatch()
1301 version_res->me_max_version.minor_version; in mei_hbm_dispatch()
1305 dev_warn(dev->dev, "hbm: start: version mismatch - stopping the driver.\n"); in mei_hbm_dispatch()
1307 dev->hbm_state = MEI_HBM_STOPPED; in mei_hbm_dispatch()
1309 dev_err(dev->dev, "hbm: start: failed to send stop request\n"); in mei_hbm_dispatch()
1310 return -EIO; in mei_hbm_dispatch()
1317 if (dev->dev_state != MEI_DEV_INIT_CLIENTS || in mei_hbm_dispatch()
1318 dev->hbm_state != MEI_HBM_STARTING) { in mei_hbm_dispatch()
1319 if (dev->dev_state == MEI_DEV_POWER_DOWN || in mei_hbm_dispatch()
1320 dev->dev_state == MEI_DEV_POWERING_DOWN) { in mei_hbm_dispatch()
1321 dev_dbg(dev->dev, "hbm: start: on shutdown, ignoring\n"); in mei_hbm_dispatch()
1324 dev_err(dev->dev, "hbm: start: state mismatch, [%d, %d]\n", in mei_hbm_dispatch()
1325 dev->dev_state, dev->hbm_state); in mei_hbm_dispatch()
1326 return -EPROTO; in mei_hbm_dispatch()
1329 if (dev->hbm_f_cap_supported) { in mei_hbm_dispatch()
1331 return -EIO; in mei_hbm_dispatch()
1332 wake_up(&dev->wait_hbm_start); in mei_hbm_dispatch()
1336 if (dev->hbm_f_dr_supported) { in mei_hbm_dispatch()
1338 dev_info(dev->dev, "running w/o dma ring\n"); in mei_hbm_dispatch()
1341 return -EIO; in mei_hbm_dispatch()
1343 wake_up(&dev->wait_hbm_start); in mei_hbm_dispatch()
1348 dev->hbm_f_dr_supported = 0; in mei_hbm_dispatch()
1352 return -EIO; in mei_hbm_dispatch()
1354 wake_up(&dev->wait_hbm_start); in mei_hbm_dispatch()
1358 dev_dbg(dev->dev, "hbm: capabilities response: message received.\n"); in mei_hbm_dispatch()
1360 dev->init_clients_timer = 0; in mei_hbm_dispatch()
1362 if (dev->dev_state != MEI_DEV_INIT_CLIENTS || in mei_hbm_dispatch()
1363 dev->hbm_state != MEI_HBM_CAP_SETUP) { in mei_hbm_dispatch()
1364 if (dev->dev_state == MEI_DEV_POWER_DOWN || in mei_hbm_dispatch()
1365 dev->dev_state == MEI_DEV_POWERING_DOWN) { in mei_hbm_dispatch()
1366 dev_dbg(dev->dev, "hbm: capabilities response: on shutdown, ignoring\n"); in mei_hbm_dispatch()
1369 dev_err(dev->dev, "hbm: capabilities response: state mismatch, [%d, %d]\n", in mei_hbm_dispatch()
1370 dev->dev_state, dev->hbm_state); in mei_hbm_dispatch()
1371 return -EPROTO; in mei_hbm_dispatch()
1375 if (!(capability_res->capability_granted[0] & HBM_CAP_VT)) in mei_hbm_dispatch()
1376 dev->hbm_f_vt_supported = 0; in mei_hbm_dispatch()
1377 if (!(capability_res->capability_granted[0] & HBM_CAP_CD)) in mei_hbm_dispatch()
1378 dev->hbm_f_cd_supported = 0; in mei_hbm_dispatch()
1380 if (!(capability_res->capability_granted[0] & HBM_CAP_GSC)) in mei_hbm_dispatch()
1381 dev->hbm_f_gsc_supported = 0; in mei_hbm_dispatch()
1383 if (dev->hbm_f_dr_supported) { in mei_hbm_dispatch()
1385 dev_info(dev->dev, "running w/o dma ring\n"); in mei_hbm_dispatch()
1388 return -EIO; in mei_hbm_dispatch()
1393 dev->hbm_f_dr_supported = 0; in mei_hbm_dispatch()
1397 return -EIO; in mei_hbm_dispatch()
1401 dev_dbg(dev->dev, "hbm: dma setup response: message received.\n"); in mei_hbm_dispatch()
1403 dev->init_clients_timer = 0; in mei_hbm_dispatch()
1405 if (dev->dev_state != MEI_DEV_INIT_CLIENTS || in mei_hbm_dispatch()
1406 dev->hbm_state != MEI_HBM_DR_SETUP) { in mei_hbm_dispatch()
1407 if (dev->dev_state == MEI_DEV_POWER_DOWN || in mei_hbm_dispatch()
1408 dev->dev_state == MEI_DEV_POWERING_DOWN) { in mei_hbm_dispatch()
1409 dev_dbg(dev->dev, "hbm: dma setup response: on shutdown, ignoring\n"); in mei_hbm_dispatch()
1412 dev_err(dev->dev, "hbm: dma setup response: state mismatch, [%d, %d]\n", in mei_hbm_dispatch()
1413 dev->dev_state, dev->hbm_state); in mei_hbm_dispatch()
1414 return -EPROTO; in mei_hbm_dispatch()
1419 if (dma_setup_res->status) { in mei_hbm_dispatch()
1420 u8 status = dma_setup_res->status; in mei_hbm_dispatch()
1423 dev_dbg(dev->dev, "hbm: dma setup not allowed\n"); in mei_hbm_dispatch()
1425 dev_info(dev->dev, "hbm: dma setup response: failure = %d %s\n", in mei_hbm_dispatch()
1429 dev->hbm_f_dr_supported = 0; in mei_hbm_dispatch()
1434 return -EIO; in mei_hbm_dispatch()
1438 dev_dbg(dev->dev, "hbm: client connect response: message received.\n"); in mei_hbm_dispatch()
1443 dev_dbg(dev->dev, "hbm: client disconnect response: message received.\n"); in mei_hbm_dispatch()
1448 dev_dbg(dev->dev, "hbm: client flow control response: message received.\n"); in mei_hbm_dispatch()
1455 dev_dbg(dev->dev, "hbm: power gate isolation entry response received\n"); in mei_hbm_dispatch()
1462 dev_dbg(dev->dev, "hbm: power gate isolation exit request received\n"); in mei_hbm_dispatch()
1469 dev_dbg(dev->dev, "hbm: properties response: message received.\n"); in mei_hbm_dispatch()
1471 dev->init_clients_timer = 0; in mei_hbm_dispatch()
1473 if (dev->dev_state != MEI_DEV_INIT_CLIENTS || in mei_hbm_dispatch()
1474 dev->hbm_state != MEI_HBM_CLIENT_PROPERTIES) { in mei_hbm_dispatch()
1475 if (dev->dev_state == MEI_DEV_POWER_DOWN || in mei_hbm_dispatch()
1476 dev->dev_state == MEI_DEV_POWERING_DOWN) { in mei_hbm_dispatch()
1477 dev_dbg(dev->dev, "hbm: properties response: on shutdown, ignoring\n"); in mei_hbm_dispatch()
1480 dev_err(dev->dev, "hbm: properties response: state mismatch, [%d, %d]\n", in mei_hbm_dispatch()
1481 dev->dev_state, dev->hbm_state); in mei_hbm_dispatch()
1482 return -EPROTO; in mei_hbm_dispatch()
1487 if (props_res->status == MEI_HBMS_CLIENT_NOT_FOUND) { in mei_hbm_dispatch()
1488 dev_dbg(dev->dev, "hbm: properties response: %d CLIENT_NOT_FOUND\n", in mei_hbm_dispatch()
1489 props_res->me_addr); in mei_hbm_dispatch()
1490 } else if (props_res->status) { in mei_hbm_dispatch()
1491 dev_err(dev->dev, "hbm: properties response: wrong status = %d %s\n", in mei_hbm_dispatch()
1492 props_res->status, in mei_hbm_dispatch()
1493 mei_hbm_status_str(props_res->status)); in mei_hbm_dispatch()
1494 return -EPROTO; in mei_hbm_dispatch()
1500 if (mei_hbm_prop_req(dev, props_res->me_addr + 1)) in mei_hbm_dispatch()
1501 return -EIO; in mei_hbm_dispatch()
1506 dev_dbg(dev->dev, "hbm: enumeration response: message received\n"); in mei_hbm_dispatch()
1508 dev->init_clients_timer = 0; in mei_hbm_dispatch()
1511 BUILD_BUG_ON(sizeof(dev->me_clients_map) in mei_hbm_dispatch()
1512 < sizeof(enum_res->valid_addresses)); in mei_hbm_dispatch()
1513 memcpy(dev->me_clients_map, enum_res->valid_addresses, in mei_hbm_dispatch()
1514 sizeof(enum_res->valid_addresses)); in mei_hbm_dispatch()
1516 if (dev->dev_state != MEI_DEV_INIT_CLIENTS || in mei_hbm_dispatch()
1517 dev->hbm_state != MEI_HBM_ENUM_CLIENTS) { in mei_hbm_dispatch()
1518 if (dev->dev_state == MEI_DEV_POWER_DOWN || in mei_hbm_dispatch()
1519 dev->dev_state == MEI_DEV_POWERING_DOWN) { in mei_hbm_dispatch()
1520 dev_dbg(dev->dev, "hbm: enumeration response: on shutdown, ignoring\n"); in mei_hbm_dispatch()
1523 dev_err(dev->dev, "hbm: enumeration response: state mismatch, [%d, %d]\n", in mei_hbm_dispatch()
1524 dev->dev_state, dev->hbm_state); in mei_hbm_dispatch()
1525 return -EPROTO; in mei_hbm_dispatch()
1528 dev->hbm_state = MEI_HBM_CLIENT_PROPERTIES; in mei_hbm_dispatch()
1532 return -EIO; in mei_hbm_dispatch()
1537 dev_dbg(dev->dev, "hbm: stop response: message received\n"); in mei_hbm_dispatch()
1539 dev->init_clients_timer = 0; in mei_hbm_dispatch()
1541 if (dev->hbm_state != MEI_HBM_STOPPED) { in mei_hbm_dispatch()
1542 dev_err(dev->dev, "hbm: stop response: state mismatch, [%d, %d]\n", in mei_hbm_dispatch()
1543 dev->dev_state, dev->hbm_state); in mei_hbm_dispatch()
1544 return -EPROTO; in mei_hbm_dispatch()
1548 dev_info(dev->dev, "hbm: stop response: resetting.\n"); in mei_hbm_dispatch()
1550 return -EPROTO; in mei_hbm_dispatch()
1553 dev_dbg(dev->dev, "hbm: disconnect request: message received\n"); in mei_hbm_dispatch()
1560 dev_dbg(dev->dev, "hbm: stop request: message received\n"); in mei_hbm_dispatch()
1561 dev->hbm_state = MEI_HBM_STOPPED; in mei_hbm_dispatch()
1563 dev_err(dev->dev, "hbm: stop request: failed to send stop request\n"); in mei_hbm_dispatch()
1564 return -EIO; in mei_hbm_dispatch()
1569 dev_dbg(dev->dev, "hbm: add client request received\n"); in mei_hbm_dispatch()
1574 if (dev->hbm_state <= MEI_HBM_ENUM_CLIENTS || in mei_hbm_dispatch()
1575 dev->hbm_state >= MEI_HBM_STOPPED) { in mei_hbm_dispatch()
1576 dev_err(dev->dev, "hbm: add client: state mismatch, [%d, %d]\n", in mei_hbm_dispatch()
1577 dev->dev_state, dev->hbm_state); in mei_hbm_dispatch()
1578 return -EPROTO; in mei_hbm_dispatch()
1583 dev_err(dev->dev, "hbm: add client: failed to send response %d\n", in mei_hbm_dispatch()
1585 return -EIO; in mei_hbm_dispatch()
1587 dev_dbg(dev->dev, "hbm: add client request processed\n"); in mei_hbm_dispatch()
1591 dev_dbg(dev->dev, "hbm: notify response received\n"); in mei_hbm_dispatch()
1596 dev_dbg(dev->dev, "hbm: notification\n"); in mei_hbm_dispatch()
1601 dev_dbg(dev->dev, "hbm: client dma map response: message received.\n"); in mei_hbm_dispatch()
1607 dev_dbg(dev->dev, "hbm: client dma unmap response: message received.\n"); in mei_hbm_dispatch()
1613 WARN(1, "hbm: wrong command %d\n", mei_msg->hbm_cmd); in mei_hbm_dispatch()
1614 return -EPROTO; in mei_hbm_dispatch()