Lines Matching refs:dev
91 * @dev: mei device
95 static inline int mei_hbm_write_message(struct mei_device *dev,
99 return mei_write_message(dev, hdr, sizeof(*hdr), data, hdr->length);
105 * @dev: the device structure
107 void mei_hbm_idle(struct mei_device *dev)
109 dev->init_clients_timer = 0;
110 dev->hbm_state = MEI_HBM_IDLE;
116 * @dev: the device structure
118 void mei_hbm_reset(struct mei_device *dev)
120 mei_me_cl_rm_all(dev);
122 mei_hbm_idle(dev);
162 * @dev: the device structure
170 static inline int mei_hbm_cl_write(struct mei_device *dev, struct mei_cl *cl,
178 return mei_hbm_write_message(dev, &mei_hdr, buf);
200 * @dev: the device structure
206 struct mei_cl *mei_hbm_cl_find_by_cmd(struct mei_device *dev, void *buf)
211 list_for_each_entry(cl, &dev->file_list, link)
221 * @dev: the device structure
225 int mei_hbm_start_wait(struct mei_device *dev)
229 if (dev->hbm_state > MEI_HBM_STARTING)
232 mutex_unlock(&dev->device_lock);
233 ret = wait_event_timeout(dev->wait_hbm_start,
234 dev->hbm_state != MEI_HBM_STARTING,
236 mutex_lock(&dev->device_lock);
238 if (ret == 0 && (dev->hbm_state <= MEI_HBM_STARTING)) {
239 dev->hbm_state = MEI_HBM_IDLE;
240 dev_err(dev->dev, "waiting for mei start failed\n");
249 * @dev: the device structure
253 int mei_hbm_start_req(struct mei_device *dev)
259 mei_hbm_reset(dev);
269 dev->hbm_state = MEI_HBM_IDLE;
270 ret = mei_hbm_write_message(dev, &mei_hdr, &req);
272 dev_err(dev->dev, "version message write failed: ret = %d\n",
277 dev->hbm_state = MEI_HBM_STARTING;
278 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
279 mei_schedule_stall_timer(dev);
285 * @dev: the device structure
289 static int mei_hbm_dma_setup_req(struct mei_device *dev)
303 paddr = dev->dr_dscr[i].daddr;
306 req.dma_dscr[i].size = dev->dr_dscr[i].size;
309 mei_dma_ring_reset(dev);
311 ret = mei_hbm_write_message(dev, &mei_hdr, &req);
313 dev_err(dev->dev, "dma setup request write failed: ret = %d.\n",
318 dev->hbm_state = MEI_HBM_DR_SETUP;
319 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
320 mei_schedule_stall_timer(dev);
327 * @dev: the device structure
331 static int mei_hbm_capabilities_req(struct mei_device *dev)
341 if (dev->hbm_f_vt_supported)
344 ret = mei_hbm_write_message(dev, &mei_hdr, &req);
346 dev_err(dev->dev,
351 dev->hbm_state = MEI_HBM_CAP_SETUP;
352 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
353 mei_schedule_stall_timer(dev);
360 * @dev: the device structure
364 static int mei_hbm_enum_clients_req(struct mei_device *dev)
375 req.flags |= dev->hbm_f_dc_supported ? MEI_HBM_ENUM_F_ALLOW_ADD : 0;
376 req.flags |= dev->hbm_f_ie_supported ?
379 ret = mei_hbm_write_message(dev, &mei_hdr, &req);
381 dev_err(dev->dev, "enumeration request write failed: ret = %d.\n",
385 dev->hbm_state = MEI_HBM_ENUM_CLIENTS;
386 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
387 mei_schedule_stall_timer(dev);
394 * @dev: the device structure
400 static int mei_hbm_me_cl_add(struct mei_device *dev,
406 mei_me_cl_rm_by_uuid(dev, uuid);
418 mei_me_cl_add(dev, me_cl);
426 * @dev: the device structure
432 static int mei_hbm_add_cl_resp(struct mei_device *dev, u8 addr, u8 status)
438 dev_dbg(dev->dev, "adding client response\n");
447 ret = mei_hbm_write_message(dev, &mei_hdr, &resp);
449 dev_err(dev->dev, "add client response write failed: ret = %d\n",
457 * @dev: the device structure
462 static int mei_hbm_fw_add_cl_req(struct mei_device *dev,
471 ret = mei_hbm_me_cl_add(dev, (struct hbm_props_response *)req);
475 if (dev->dev_state == MEI_DEV_ENABLED)
476 schedule_work(&dev->bus_rescan_work);
478 return mei_hbm_add_cl_resp(dev, req->me_addr, status);
484 * @dev: the device structure
490 int mei_hbm_cl_notify_req(struct mei_device *dev,
503 ret = mei_hbm_write_message(dev, &mei_hdr, &req);
505 dev_err(dev->dev, "notify request failed: ret = %d\n", ret);
530 * @dev: the device structure
534 static void mei_hbm_cl_notify_start_res(struct mei_device *dev,
541 cl_dbg(dev, cl, "hbm: notify start response status=%d\n", rs->status);
556 * @dev: the device structure
560 static void mei_hbm_cl_notify_stop_res(struct mei_device *dev,
567 cl_dbg(dev, cl, "hbm: notify stop response status=%d\n", rs->status);
582 * @dev: the device structure
585 static void mei_hbm_cl_notify(struct mei_device *dev,
590 cl = mei_hbm_cl_find_by_cmd(dev, cmd);
598 * @dev: the device structure
603 static int mei_hbm_prop_req(struct mei_device *dev, unsigned long start_idx)
610 addr = find_next_bit(dev->me_clients_map, MEI_CLIENTS_MAX, start_idx);
614 dev->hbm_state = MEI_HBM_STARTED;
615 mei_host_client_init(dev);
626 ret = mei_hbm_write_message(dev, &mei_hdr, &req);
628 dev_err(dev->dev, "properties request write failed: ret = %d\n",
633 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
634 mei_schedule_stall_timer(dev);
642 * @dev: the device structure
648 int mei_hbm_pg(struct mei_device *dev, u8 pg_cmd)
654 if (!dev->hbm_f_pg_supported)
662 ret = mei_hbm_write_message(dev, &mei_hdr, &req);
664 dev_err(dev->dev, "power gate command write failed.\n");
672 * @dev: mei device
676 static int mei_hbm_stop_req(struct mei_device *dev)
687 return mei_hbm_write_message(dev, &mei_hdr, &req);
693 * @dev: the device structure
698 int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl)
702 cl_dbg(dev, cl, "sending flow control\n");
703 return mei_hbm_cl_write(dev, cl, MEI_FLOW_CONTROL_CMD,
710 * @dev: the device structure
715 static int mei_hbm_add_single_tx_flow_ctrl_creds(struct mei_device *dev,
721 me_cl = mei_me_cl_by_id(dev, fctrl->me_addr);
723 dev_err(dev->dev, "no such me client %d\n", fctrl->me_addr);
733 dev_dbg(dev->dev, "recv flow ctrl msg ME %d (single) creds = %d.\n",
745 * @dev: the device structure
748 static void mei_hbm_cl_tx_flow_ctrl_creds_res(struct mei_device *dev,
755 mei_hbm_add_single_tx_flow_ctrl_creds(dev, fctrl);
759 cl = mei_hbm_cl_find_by_cmd(dev, fctrl);
762 cl_dbg(dev, cl, "flow control creds = %d.\n",
771 * @dev: the device structure
776 int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl *cl)
780 return mei_hbm_cl_write(dev, cl, CLIENT_DISCONNECT_REQ_CMD,
787 * @dev: the device structure
792 int mei_hbm_cl_disconnect_rsp(struct mei_device *dev, struct mei_cl *cl)
796 return mei_hbm_cl_write(dev, cl, CLIENT_DISCONNECT_RES_CMD,
804 * @dev: the device structure
808 static void mei_hbm_cl_disconnect_res(struct mei_device *dev, struct mei_cl *cl,
814 cl_dbg(dev, cl, "hbm: disconnect response status=%d\n", rs->status);
824 * @dev: the device structure
829 int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl *cl)
833 return mei_hbm_cl_write(dev, cl, CLIENT_CONNECT_REQ_CMD,
841 * @dev: the device structure
845 static void mei_hbm_cl_connect_res(struct mei_device *dev, struct mei_cl *cl,
851 cl_dbg(dev, cl, "hbm: connect response status=%s\n",
859 mei_me_cl_del(dev, cl->me_cl);
860 if (dev->dev_state == MEI_DEV_ENABLED)
861 schedule_work(&dev->bus_rescan_work);
871 * @dev: the device structure
875 static void mei_hbm_cl_res(struct mei_device *dev,
883 list_for_each_entry_safe(cb, next, &dev->ctrl_rd_list, list) {
901 mei_hbm_cl_connect_res(dev, cl, rs);
904 mei_hbm_cl_disconnect_res(dev, cl, rs);
907 mei_hbm_cl_notify_start_res(dev, cl, rs);
910 mei_hbm_cl_notify_stop_res(dev, cl, rs);
925 * @dev: the device structure.
930 static int mei_hbm_fw_disconnect_req(struct mei_device *dev,
936 cl = mei_hbm_cl_find_by_cmd(dev, disconnect_req);
938 cl_warn(dev, cl, "fw disconnect request received\n");
953 * @dev: the device structure.
957 static int mei_hbm_pg_enter_res(struct mei_device *dev)
959 if (mei_pg_state(dev) != MEI_PG_OFF ||
960 dev->pg_event != MEI_PG_EVENT_WAIT) {
961 dev_err(dev->dev, "hbm: pg entry response: state mismatch [%s, %d]\n",
962 mei_pg_state_str(mei_pg_state(dev)), dev->pg_event);
966 dev->pg_event = MEI_PG_EVENT_RECEIVED;
967 wake_up(&dev->wait_pg);
975 * @dev: the device structure.
977 void mei_hbm_pg_resume(struct mei_device *dev)
979 pm_request_resume(dev->dev);
986 * @dev: the device structure.
990 static int mei_hbm_pg_exit_res(struct mei_device *dev)
992 if (mei_pg_state(dev) != MEI_PG_ON ||
993 (dev->pg_event != MEI_PG_EVENT_WAIT &&
994 dev->pg_event != MEI_PG_EVENT_IDLE)) {
995 dev_err(dev->dev, "hbm: pg exit response: state mismatch [%s, %d]\n",
996 mei_pg_state_str(mei_pg_state(dev)), dev->pg_event);
1000 switch (dev->pg_event) {
1002 dev->pg_event = MEI_PG_EVENT_RECEIVED;
1003 wake_up(&dev->wait_pg);
1011 dev->pg_event = MEI_PG_EVENT_RECEIVED;
1012 mei_hbm_pg_resume(dev);
1016 dev->pg_event);
1027 * @dev: the device structure
1029 static void mei_hbm_config_features(struct mei_device *dev)
1032 dev->hbm_f_pg_supported = 0;
1033 if (dev->version.major_version > HBM_MAJOR_VERSION_PGI)
1034 dev->hbm_f_pg_supported = 1;
1036 if (dev->version.major_version == HBM_MAJOR_VERSION_PGI &&
1037 dev->version.minor_version >= HBM_MINOR_VERSION_PGI)
1038 dev->hbm_f_pg_supported = 1;
1040 dev->hbm_f_dc_supported = 0;
1041 if (dev->version.major_version >= HBM_MAJOR_VERSION_DC)
1042 dev->hbm_f_dc_supported = 1;
1044 dev->hbm_f_ie_supported = 0;
1045 if (dev->version.major_version >= HBM_MAJOR_VERSION_IE)
1046 dev->hbm_f_ie_supported = 1;
1049 dev->hbm_f_dot_supported = 0;
1050 if (dev->version.major_version >= HBM_MAJOR_VERSION_DOT)
1051 dev->hbm_f_dot_supported = 1;
1054 dev->hbm_f_ev_supported = 0;
1055 if (dev->version.major_version >= HBM_MAJOR_VERSION_EV)
1056 dev->hbm_f_ev_supported = 1;
1059 dev->hbm_f_fa_supported = 0;
1060 if (dev->version.major_version >= HBM_MAJOR_VERSION_FA)
1061 dev->hbm_f_fa_supported = 1;
1064 dev->hbm_f_os_supported = 0;
1065 if (dev->version.major_version >= HBM_MAJOR_VERSION_OS)
1066 dev->hbm_f_os_supported = 1;
1069 dev->hbm_f_dr_supported = 0;
1070 if (dev->version.major_version > HBM_MAJOR_VERSION_DR ||
1071 (dev->version.major_version == HBM_MAJOR_VERSION_DR &&
1072 dev->version.minor_version >= HBM_MINOR_VERSION_DR))
1073 dev->hbm_f_dr_supported = 1;
1076 dev->hbm_f_vt_supported = 0;
1077 if (dev->version.major_version > HBM_MAJOR_VERSION_VT ||
1078 (dev->version.major_version == HBM_MAJOR_VERSION_VT &&
1079 dev->version.minor_version >= HBM_MINOR_VERSION_VT))
1080 dev->hbm_f_vt_supported = 1;
1083 dev->hbm_f_cap_supported = 0;
1084 if (dev->version.major_version > HBM_MAJOR_VERSION_CAP ||
1085 (dev->version.major_version == HBM_MAJOR_VERSION_CAP &&
1086 dev->version.minor_version >= HBM_MINOR_VERSION_CAP))
1087 dev->hbm_f_cap_supported = 1;
1094 * @dev: the device structure
1097 bool mei_hbm_version_is_supported(struct mei_device *dev)
1099 return (dev->version.major_version < HBM_MAJOR_VERSION) ||
1100 (dev->version.major_version == HBM_MAJOR_VERSION &&
1101 dev->version.minor_version <= HBM_MINOR_VERSION);
1108 * @dev: the device structure
1113 int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
1129 BUG_ON(hdr->length >= sizeof(dev->rd_msg_buf));
1130 mei_read_slots(dev, dev->rd_msg_buf, hdr->length);
1131 mei_msg = (struct mei_bus_message *)dev->rd_msg_buf;
1137 if (dev->hbm_state == MEI_HBM_IDLE) {
1138 dev_dbg(dev->dev, "hbm: state is idle ignore spurious messages\n");
1144 dev_dbg(dev->dev, "hbm: start: response message received.\n");
1146 dev->init_clients_timer = 0;
1150 dev_dbg(dev->dev, "HBM VERSION: DRIVER=%02d:%02d DEVICE=%02d:%02d\n",
1156 dev->version.major_version = HBM_MAJOR_VERSION;
1157 dev->version.minor_version = HBM_MINOR_VERSION;
1159 dev->version.major_version =
1161 dev->version.minor_version =
1165 if (!mei_hbm_version_is_supported(dev)) {
1166 dev_warn(dev->dev, "hbm: start: version mismatch - stopping the driver.\n");
1168 dev->hbm_state = MEI_HBM_STOPPED;
1169 if (mei_hbm_stop_req(dev)) {
1170 dev_err(dev->dev, "hbm: start: failed to send stop request\n");
1176 mei_hbm_config_features(dev);
1178 if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
1179 dev->hbm_state != MEI_HBM_STARTING) {
1180 dev_err(dev->dev, "hbm: start: state mismatch, [%d, %d]\n",
1181 dev->dev_state, dev->hbm_state);
1185 if (dev->hbm_f_cap_supported) {
1186 if (mei_hbm_capabilities_req(dev))
1188 wake_up(&dev->wait_hbm_start);
1192 if (dev->hbm_f_dr_supported) {
1193 if (mei_dmam_ring_alloc(dev))
1194 dev_info(dev->dev, "running w/o dma ring\n");
1195 if (mei_dma_ring_is_allocated(dev)) {
1196 if (mei_hbm_dma_setup_req(dev))
1199 wake_up(&dev->wait_hbm_start);
1204 dev->hbm_f_dr_supported = 0;
1205 mei_dmam_ring_free(dev);
1207 if (mei_hbm_enum_clients_req(dev))
1210 wake_up(&dev->wait_hbm_start);
1214 dev_dbg(dev->dev, "hbm: capabilities response: message received.\n");
1216 dev->init_clients_timer = 0;
1218 if (dev->hbm_state != MEI_HBM_CAP_SETUP) {
1219 dev_err(dev->dev, "hbm: capabilities response: state mismatch, [%d, %d]\n",
1220 dev->dev_state, dev->hbm_state);
1226 dev->hbm_f_vt_supported = 0;
1228 if (dev->hbm_f_dr_supported) {
1229 if (mei_dmam_ring_alloc(dev))
1230 dev_info(dev->dev, "running w/o dma ring\n");
1231 if (mei_dma_ring_is_allocated(dev)) {
1232 if (mei_hbm_dma_setup_req(dev))
1238 dev->hbm_f_dr_supported = 0;
1239 mei_dmam_ring_free(dev);
1241 if (mei_hbm_enum_clients_req(dev))
1246 dev_dbg(dev->dev, "hbm: dma setup response: message received.\n");
1248 dev->init_clients_timer = 0;
1250 if (dev->hbm_state != MEI_HBM_DR_SETUP) {
1251 dev_err(dev->dev, "hbm: dma setup response: state mismatch, [%d, %d]\n",
1252 dev->dev_state, dev->hbm_state);
1262 dev_dbg(dev->dev, "hbm: dma setup not allowed\n");
1264 dev_info(dev->dev, "hbm: dma setup response: failure = %d %s\n",
1268 dev->hbm_f_dr_supported = 0;
1269 mei_dmam_ring_free(dev);
1272 if (mei_hbm_enum_clients_req(dev))
1277 dev_dbg(dev->dev, "hbm: client connect response: message received.\n");
1278 mei_hbm_cl_res(dev, cl_cmd, MEI_FOP_CONNECT);
1282 dev_dbg(dev->dev, "hbm: client disconnect response: message received.\n");
1283 mei_hbm_cl_res(dev, cl_cmd, MEI_FOP_DISCONNECT);
1287 dev_dbg(dev->dev, "hbm: client flow control response: message received.\n");
1290 mei_hbm_cl_tx_flow_ctrl_creds_res(dev, fctrl);
1294 dev_dbg(dev->dev, "hbm: power gate isolation entry response received\n");
1295 ret = mei_hbm_pg_enter_res(dev);
1301 dev_dbg(dev->dev, "hbm: power gate isolation exit request received\n");
1302 ret = mei_hbm_pg_exit_res(dev);
1308 dev_dbg(dev->dev, "hbm: properties response: message received.\n");
1310 dev->init_clients_timer = 0;
1312 if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
1313 dev->hbm_state != MEI_HBM_CLIENT_PROPERTIES) {
1314 dev_err(dev->dev, "hbm: properties response: state mismatch, [%d, %d]\n",
1315 dev->dev_state, dev->hbm_state);
1322 dev_dbg(dev->dev, "hbm: properties response: %d CLIENT_NOT_FOUND\n",
1325 dev_err(dev->dev, "hbm: properties response: wrong status = %d %s\n",
1330 mei_hbm_me_cl_add(dev, props_res);
1334 if (mei_hbm_prop_req(dev, props_res->me_addr + 1))
1340 dev_dbg(dev->dev, "hbm: enumeration response: message received\n");
1342 dev->init_clients_timer = 0;
1345 BUILD_BUG_ON(sizeof(dev->me_clients_map)
1347 memcpy(dev->me_clients_map, enum_res->valid_addresses,
1350 if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
1351 dev->hbm_state != MEI_HBM_ENUM_CLIENTS) {
1352 dev_err(dev->dev, "hbm: enumeration response: state mismatch, [%d, %d]\n",
1353 dev->dev_state, dev->hbm_state);
1357 dev->hbm_state = MEI_HBM_CLIENT_PROPERTIES;
1360 if (mei_hbm_prop_req(dev, 0))
1366 dev_dbg(dev->dev, "hbm: stop response: message received\n");
1368 dev->init_clients_timer = 0;
1370 if (dev->hbm_state != MEI_HBM_STOPPED) {
1371 dev_err(dev->dev, "hbm: stop response: state mismatch, [%d, %d]\n",
1372 dev->dev_state, dev->hbm_state);
1376 mei_set_devstate(dev, MEI_DEV_POWER_DOWN);
1377 dev_info(dev->dev, "hbm: stop response: resetting.\n");
1383 dev_dbg(dev->dev, "hbm: disconnect request: message received\n");
1386 mei_hbm_fw_disconnect_req(dev, disconnect_req);
1390 dev_dbg(dev->dev, "hbm: stop request: message received\n");
1391 dev->hbm_state = MEI_HBM_STOPPED;
1392 if (mei_hbm_stop_req(dev)) {
1393 dev_err(dev->dev, "hbm: stop request: failed to send stop request\n");
1399 dev_dbg(dev->dev, "hbm: add client request received\n");
1404 if (dev->hbm_state <= MEI_HBM_ENUM_CLIENTS ||
1405 dev->hbm_state >= MEI_HBM_STOPPED) {
1406 dev_err(dev->dev, "hbm: add client: state mismatch, [%d, %d]\n",
1407 dev->dev_state, dev->hbm_state);
1411 ret = mei_hbm_fw_add_cl_req(dev, add_cl_req);
1413 dev_err(dev->dev, "hbm: add client: failed to send response %d\n",
1417 dev_dbg(dev->dev, "hbm: add client request processed\n");
1421 dev_dbg(dev->dev, "hbm: notify response received\n");
1422 mei_hbm_cl_res(dev, cl_cmd, notify_res_to_fop(cl_cmd));
1426 dev_dbg(dev->dev, "hbm: notification\n");
1427 mei_hbm_cl_notify(dev, cl_cmd);