Lines Matching full:dev
81 * @dev: the device structure
83 void mei_cancel_work(struct mei_device *dev) in mei_cancel_work() argument
85 cancel_work_sync(&dev->reset_work); in mei_cancel_work()
86 cancel_work_sync(&dev->bus_rescan_work); in mei_cancel_work()
88 cancel_delayed_work_sync(&dev->timer_work); in mei_cancel_work()
92 static void mei_save_fw_status(struct mei_device *dev) in mei_save_fw_status() argument
97 ret = mei_fw_status(dev, &fw_status); in mei_save_fw_status()
99 dev_err(dev->dev, "failed to read firmware status: %d\n", ret); in mei_save_fw_status()
103 dev->saved_dev_state = dev->dev_state; in mei_save_fw_status()
104 dev->saved_fw_status_flag = true; in mei_save_fw_status()
105 memcpy(&dev->saved_fw_status, &fw_status, sizeof(fw_status)); in mei_save_fw_status()
111 * @dev: the device structure
115 int mei_reset(struct mei_device *dev) in mei_reset() argument
117 enum mei_dev_state state = dev->dev_state; in mei_reset()
127 mei_fw_status_str(dev, fw_sts_str, MEI_FW_STATUS_STR_SZ); in mei_reset()
128 if (kind_is_gsc(dev) || kind_is_gscfi(dev)) { in mei_reset()
129 dev_dbg(dev->dev, "unexpected reset: dev_state = %s fw status = %s\n", in mei_reset()
131 mei_save_fw_status(dev); in mei_reset()
133 dev_warn(dev->dev, "unexpected reset: dev_state = %s fw status = %s\n", in mei_reset()
138 mei_clear_interrupts(dev); in mei_reset()
145 mei_hbm_idle(dev); in mei_reset()
149 mei_set_devstate(dev, MEI_DEV_RESETTING); in mei_reset()
151 dev->reset_count++; in mei_reset()
152 if (dev->reset_count > MEI_MAX_CONSEC_RESET) { in mei_reset()
153 dev_err(dev->dev, "reset: reached maximal consecutive resets: disabling the device\n"); in mei_reset()
154 mei_set_devstate(dev, MEI_DEV_DISABLED); in mei_reset()
158 ret = mei_hw_reset(dev, interrupts_enabled); in mei_reset()
163 mei_cl_all_disconnect(dev); in mei_reset()
165 mei_hbm_reset(dev); in mei_reset()
168 dev->fw_ver_received = 0; in mei_reset()
170 memset(dev->rd_msg_hdr, 0, sizeof(dev->rd_msg_hdr)); in mei_reset()
173 dev_err(dev->dev, "hw_reset failed ret = %d\n", ret); in mei_reset()
178 dev_dbg(dev->dev, "powering down: end of reset\n"); in mei_reset()
179 mei_set_devstate(dev, MEI_DEV_DISABLED); in mei_reset()
183 ret = mei_hw_start(dev); in mei_reset()
187 mei_fw_status_str(dev, fw_sts_str, MEI_FW_STATUS_STR_SZ); in mei_reset()
188 dev_err(dev->dev, "hw_start failed ret = %d fw status = %s\n", ret, fw_sts_str); in mei_reset()
192 if (dev->dev_state != MEI_DEV_RESETTING) { in mei_reset()
193 dev_dbg(dev->dev, "wrong state = %d on link start\n", dev->dev_state); in mei_reset()
197 dev_dbg(dev->dev, "link is established start sending messages.\n"); in mei_reset()
199 mei_set_devstate(dev, MEI_DEV_INIT_CLIENTS); in mei_reset()
200 ret = mei_hbm_start_req(dev); in mei_reset()
202 dev_err(dev->dev, "hbm_start failed ret = %d\n", ret); in mei_reset()
203 mei_set_devstate(dev, MEI_DEV_RESETTING); in mei_reset()
214 * @dev: the device structure
218 int mei_start(struct mei_device *dev) in mei_start() argument
222 mutex_lock(&dev->device_lock); in mei_start()
225 mei_clear_interrupts(dev); in mei_start()
227 ret = mei_hw_config(dev); in mei_start()
231 dev_dbg(dev->dev, "reset in start the mei device.\n"); in mei_start()
233 dev->reset_count = 0; in mei_start()
235 mei_set_devstate(dev, MEI_DEV_INITIALIZING); in mei_start()
236 ret = mei_reset(dev); in mei_start()
238 if (ret == -ENODEV || dev->dev_state == MEI_DEV_DISABLED) { in mei_start()
239 dev_err(dev->dev, "reset failed ret = %d", ret); in mei_start()
244 if (mei_hbm_start_wait(dev)) { in mei_start()
245 dev_err(dev->dev, "HBM haven't started"); in mei_start()
249 if (!mei_hbm_version_is_supported(dev)) { in mei_start()
250 dev_dbg(dev->dev, "MEI start failed.\n"); in mei_start()
254 dev_dbg(dev->dev, "link layer has been established.\n"); in mei_start()
256 mutex_unlock(&dev->device_lock); in mei_start()
259 dev_err(dev->dev, "link layer initialization failed.\n"); in mei_start()
260 mei_set_devstate(dev, MEI_DEV_DISABLED); in mei_start()
261 mutex_unlock(&dev->device_lock); in mei_start()
269 * @dev: the device structure
273 int mei_restart(struct mei_device *dev) in mei_restart() argument
277 mutex_lock(&dev->device_lock); in mei_restart()
279 mei_set_devstate(dev, MEI_DEV_POWER_UP); in mei_restart()
280 dev->reset_count = 0; in mei_restart()
282 err = mei_reset(dev); in mei_restart()
284 mutex_unlock(&dev->device_lock); in mei_restart()
286 if (err == -ENODEV || dev->dev_state == MEI_DEV_DISABLED) { in mei_restart()
287 dev_err(dev->dev, "device disabled = %d\n", err); in mei_restart()
293 schedule_work(&dev->reset_work); in mei_restart()
302 struct mei_device *dev = in mei_reset_work() local
306 mei_clear_interrupts(dev); in mei_reset_work()
307 mei_synchronize_irq(dev); in mei_reset_work()
309 mutex_lock(&dev->device_lock); in mei_reset_work()
311 ret = mei_reset(dev); in mei_reset_work()
313 mutex_unlock(&dev->device_lock); in mei_reset_work()
315 if (dev->dev_state == MEI_DEV_DISABLED) { in mei_reset_work()
316 dev_err(dev->dev, "device disabled = %d\n", ret); in mei_reset_work()
322 schedule_work(&dev->reset_work); in mei_reset_work()
325 void mei_stop(struct mei_device *dev) in mei_stop() argument
327 dev_dbg(dev->dev, "stopping the device.\n"); in mei_stop()
329 mutex_lock(&dev->device_lock); in mei_stop()
330 mei_set_devstate(dev, MEI_DEV_POWERING_DOWN); in mei_stop()
331 mutex_unlock(&dev->device_lock); in mei_stop()
332 mei_cl_bus_remove_devices(dev); in mei_stop()
333 mutex_lock(&dev->device_lock); in mei_stop()
334 mei_set_devstate(dev, MEI_DEV_POWER_DOWN); in mei_stop()
335 mutex_unlock(&dev->device_lock); in mei_stop()
337 mei_cancel_work(dev); in mei_stop()
339 mei_clear_interrupts(dev); in mei_stop()
340 mei_synchronize_irq(dev); in mei_stop()
342 mei_cancel_work(dev); in mei_stop()
344 mutex_lock(&dev->device_lock); in mei_stop()
346 mei_reset(dev); in mei_stop()
348 mei_set_devstate(dev, MEI_DEV_DISABLED); in mei_stop()
350 mutex_unlock(&dev->device_lock); in mei_stop()
357 * @dev: the device structure
361 bool mei_write_is_idle(struct mei_device *dev) in mei_write_is_idle() argument
363 bool idle = (dev->dev_state == MEI_DEV_ENABLED && in mei_write_is_idle()
364 list_empty(&dev->ctrl_wr_list) && in mei_write_is_idle()
365 list_empty(&dev->write_list) && in mei_write_is_idle()
366 list_empty(&dev->write_waiting_list)); in mei_write_is_idle()
368 dev_dbg(dev->dev, "write pg: is idle[%d] state=%s ctrl=%01d write=%01d wwait=%01d\n", in mei_write_is_idle()
370 mei_dev_state_str(dev->dev_state), in mei_write_is_idle()
371 list_empty(&dev->ctrl_wr_list), in mei_write_is_idle()
372 list_empty(&dev->write_list), in mei_write_is_idle()
373 list_empty(&dev->write_waiting_list)); in mei_write_is_idle()
382 * @dev: the mei device
387 void mei_device_init(struct mei_device *dev, in mei_device_init() argument
393 INIT_LIST_HEAD(&dev->file_list); in mei_device_init()
394 INIT_LIST_HEAD(&dev->device_list); in mei_device_init()
395 INIT_LIST_HEAD(&dev->me_clients); in mei_device_init()
396 mutex_init(&dev->device_lock); in mei_device_init()
397 init_rwsem(&dev->me_clients_rwsem); in mei_device_init()
398 mutex_init(&dev->cl_bus_lock); in mei_device_init()
399 init_waitqueue_head(&dev->wait_hw_ready); in mei_device_init()
400 init_waitqueue_head(&dev->wait_pg); in mei_device_init()
401 init_waitqueue_head(&dev->wait_hbm_start); in mei_device_init()
402 dev->dev_state = MEI_DEV_INITIALIZING; in mei_device_init()
403 dev->reset_count = 0; in mei_device_init()
405 INIT_LIST_HEAD(&dev->write_list); in mei_device_init()
406 INIT_LIST_HEAD(&dev->write_waiting_list); in mei_device_init()
407 INIT_LIST_HEAD(&dev->ctrl_wr_list); in mei_device_init()
408 INIT_LIST_HEAD(&dev->ctrl_rd_list); in mei_device_init()
409 dev->tx_queue_limit = MEI_TX_QUEUE_LIMIT_DEFAULT; in mei_device_init()
411 INIT_DELAYED_WORK(&dev->timer_work, mei_timer); in mei_device_init()
412 INIT_WORK(&dev->reset_work, mei_reset_work); in mei_device_init()
413 INIT_WORK(&dev->bus_rescan_work, mei_cl_bus_rescan_work); in mei_device_init()
415 bitmap_zero(dev->host_clients_map, MEI_CLIENTS_MAX); in mei_device_init()
416 dev->open_handle_count = 0; in mei_device_init()
418 dev->pxp_mode = MEI_DEV_PXP_DEFAULT; in mei_device_init()
419 dev->gsc_reset_to_pxp = MEI_DEV_RESET_TO_PXP_DEFAULT; in mei_device_init()
425 bitmap_set(dev->host_clients_map, 0, 1); in mei_device_init()
427 dev->pg_event = MEI_PG_EVENT_IDLE; in mei_device_init()
428 dev->ops = hw_ops; in mei_device_init()
429 dev->dev = device; in mei_device_init()
431 dev->timeouts.hw_ready = mei_secs_to_jiffies(MEI_HW_READY_TIMEOUT); in mei_device_init()
432 dev->timeouts.connect = MEI_CONNECT_TIMEOUT; in mei_device_init()
433 dev->timeouts.client_init = MEI_CLIENTS_INIT_TIMEOUT; in mei_device_init()
434 dev->timeouts.pgi = mei_secs_to_jiffies(MEI_PGI_TIMEOUT); in mei_device_init()
435 dev->timeouts.d0i3 = mei_secs_to_jiffies(MEI_D0I3_TIMEOUT); in mei_device_init()
437 dev->timeouts.cl_connect = mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT_SLOW); in mei_device_init()
438 dev->timeouts.hbm = mei_secs_to_jiffies(MEI_HBM_TIMEOUT_SLOW); in mei_device_init()
439 dev->timeouts.mkhi_recv = msecs_to_jiffies(MKHI_RCV_TIMEOUT_SLOW); in mei_device_init()
441 dev->timeouts.cl_connect = mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT); in mei_device_init()
442 dev->timeouts.hbm = mei_secs_to_jiffies(MEI_HBM_TIMEOUT); in mei_device_init()
443 dev->timeouts.mkhi_recv = msecs_to_jiffies(MKHI_RCV_TIMEOUT); in mei_device_init()