Lines Matching refs:dev

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()
99 int mei_reset(struct mei_device *dev) in mei_reset() argument
101 enum mei_dev_state state = dev->dev_state; in mei_reset()
111 mei_fw_status_str(dev, fw_sts_str, MEI_FW_STATUS_STR_SZ); in mei_reset()
112 dev_warn(dev->dev, "unexpected reset: dev_state = %s fw status = %s\n", in mei_reset()
116 mei_clear_interrupts(dev); in mei_reset()
123 mei_hbm_idle(dev); in mei_reset()
127 mei_set_devstate(dev, MEI_DEV_RESETTING); in mei_reset()
129 dev->reset_count++; in mei_reset()
130 if (dev->reset_count > MEI_MAX_CONSEC_RESET) { in mei_reset()
131 dev_err(dev->dev, "reset: reached maximal consecutive resets: disabling the device\n"); in mei_reset()
132 mei_set_devstate(dev, MEI_DEV_DISABLED); in mei_reset()
136 ret = mei_hw_reset(dev, interrupts_enabled); in mei_reset()
141 mei_cl_all_disconnect(dev); in mei_reset()
143 mei_hbm_reset(dev); in mei_reset()
145 memset(dev->rd_msg_hdr, 0, sizeof(dev->rd_msg_hdr)); in mei_reset()
148 dev_err(dev->dev, "hw_reset failed ret = %d\n", ret); in mei_reset()
153 dev_dbg(dev->dev, "powering down: end of reset\n"); in mei_reset()
154 mei_set_devstate(dev, MEI_DEV_DISABLED); in mei_reset()
158 ret = mei_hw_start(dev); in mei_reset()
160 dev_err(dev->dev, "hw_start failed ret = %d\n", ret); in mei_reset()
164 if (dev->dev_state != MEI_DEV_RESETTING) { in mei_reset()
165 dev_dbg(dev->dev, "wrong state = %d on link start\n", dev->dev_state); in mei_reset()
169 dev_dbg(dev->dev, "link is established start sending messages.\n"); in mei_reset()
171 mei_set_devstate(dev, MEI_DEV_INIT_CLIENTS); in mei_reset()
172 ret = mei_hbm_start_req(dev); in mei_reset()
174 dev_err(dev->dev, "hbm_start failed ret = %d\n", ret); in mei_reset()
175 mei_set_devstate(dev, MEI_DEV_RESETTING); in mei_reset()
190 int mei_start(struct mei_device *dev) in mei_start() argument
194 mutex_lock(&dev->device_lock); in mei_start()
197 mei_clear_interrupts(dev); in mei_start()
199 ret = mei_hw_config(dev); in mei_start()
203 dev_dbg(dev->dev, "reset in start the mei device.\n"); in mei_start()
205 dev->reset_count = 0; in mei_start()
207 mei_set_devstate(dev, MEI_DEV_INITIALIZING); in mei_start()
208 ret = mei_reset(dev); in mei_start()
210 if (ret == -ENODEV || dev->dev_state == MEI_DEV_DISABLED) { in mei_start()
211 dev_err(dev->dev, "reset failed ret = %d", ret); in mei_start()
216 if (mei_hbm_start_wait(dev)) { in mei_start()
217 dev_err(dev->dev, "HBM haven't started"); in mei_start()
221 if (!mei_hbm_version_is_supported(dev)) { in mei_start()
222 dev_dbg(dev->dev, "MEI start failed.\n"); in mei_start()
226 dev_dbg(dev->dev, "link layer has been established.\n"); in mei_start()
228 mutex_unlock(&dev->device_lock); in mei_start()
231 dev_err(dev->dev, "link layer initialization failed.\n"); in mei_start()
232 mei_set_devstate(dev, MEI_DEV_DISABLED); in mei_start()
233 mutex_unlock(&dev->device_lock); in mei_start()
245 int mei_restart(struct mei_device *dev) in mei_restart() argument
249 mutex_lock(&dev->device_lock); in mei_restart()
251 mei_set_devstate(dev, MEI_DEV_POWER_UP); in mei_restart()
252 dev->reset_count = 0; in mei_restart()
254 err = mei_reset(dev); in mei_restart()
256 mutex_unlock(&dev->device_lock); in mei_restart()
258 if (err == -ENODEV || dev->dev_state == MEI_DEV_DISABLED) { in mei_restart()
259 dev_err(dev->dev, "device disabled = %d\n", err); in mei_restart()
265 schedule_work(&dev->reset_work); in mei_restart()
274 struct mei_device *dev = in mei_reset_work() local
278 mei_clear_interrupts(dev); in mei_reset_work()
279 mei_synchronize_irq(dev); in mei_reset_work()
281 mutex_lock(&dev->device_lock); in mei_reset_work()
283 ret = mei_reset(dev); in mei_reset_work()
285 mutex_unlock(&dev->device_lock); in mei_reset_work()
287 if (dev->dev_state == MEI_DEV_DISABLED) { in mei_reset_work()
288 dev_err(dev->dev, "device disabled = %d\n", ret); in mei_reset_work()
294 schedule_work(&dev->reset_work); in mei_reset_work()
297 void mei_stop(struct mei_device *dev) in mei_stop() argument
299 dev_dbg(dev->dev, "stopping the device.\n"); in mei_stop()
301 mutex_lock(&dev->device_lock); in mei_stop()
302 mei_set_devstate(dev, MEI_DEV_POWERING_DOWN); in mei_stop()
303 mutex_unlock(&dev->device_lock); in mei_stop()
304 mei_cl_bus_remove_devices(dev); in mei_stop()
305 mutex_lock(&dev->device_lock); in mei_stop()
306 mei_set_devstate(dev, MEI_DEV_POWER_DOWN); in mei_stop()
307 mutex_unlock(&dev->device_lock); in mei_stop()
309 mei_cancel_work(dev); in mei_stop()
311 mei_clear_interrupts(dev); in mei_stop()
312 mei_synchronize_irq(dev); in mei_stop()
314 mei_cancel_work(dev); in mei_stop()
316 mutex_lock(&dev->device_lock); in mei_stop()
318 mei_reset(dev); in mei_stop()
320 mei_set_devstate(dev, MEI_DEV_DISABLED); in mei_stop()
322 mutex_unlock(&dev->device_lock); in mei_stop()
333 bool mei_write_is_idle(struct mei_device *dev) in mei_write_is_idle() argument
335 bool idle = (dev->dev_state == MEI_DEV_ENABLED && in mei_write_is_idle()
336 list_empty(&dev->ctrl_wr_list) && in mei_write_is_idle()
337 list_empty(&dev->write_list) && in mei_write_is_idle()
338 list_empty(&dev->write_waiting_list)); in mei_write_is_idle()
340 dev_dbg(dev->dev, "write pg: is idle[%d] state=%s ctrl=%01d write=%01d wwait=%01d\n", in mei_write_is_idle()
342 mei_dev_state_str(dev->dev_state), in mei_write_is_idle()
343 list_empty(&dev->ctrl_wr_list), in mei_write_is_idle()
344 list_empty(&dev->write_list), in mei_write_is_idle()
345 list_empty(&dev->write_waiting_list)); in mei_write_is_idle()
359 void mei_device_init(struct mei_device *dev, in mei_device_init() argument
365 INIT_LIST_HEAD(&dev->file_list); in mei_device_init()
366 INIT_LIST_HEAD(&dev->device_list); in mei_device_init()
367 INIT_LIST_HEAD(&dev->me_clients); in mei_device_init()
368 mutex_init(&dev->device_lock); in mei_device_init()
369 init_rwsem(&dev->me_clients_rwsem); in mei_device_init()
370 mutex_init(&dev->cl_bus_lock); in mei_device_init()
371 init_waitqueue_head(&dev->wait_hw_ready); in mei_device_init()
372 init_waitqueue_head(&dev->wait_pg); in mei_device_init()
373 init_waitqueue_head(&dev->wait_hbm_start); in mei_device_init()
374 dev->dev_state = MEI_DEV_INITIALIZING; in mei_device_init()
375 dev->reset_count = 0; in mei_device_init()
377 INIT_LIST_HEAD(&dev->write_list); in mei_device_init()
378 INIT_LIST_HEAD(&dev->write_waiting_list); in mei_device_init()
379 INIT_LIST_HEAD(&dev->ctrl_wr_list); in mei_device_init()
380 INIT_LIST_HEAD(&dev->ctrl_rd_list); in mei_device_init()
381 dev->tx_queue_limit = MEI_TX_QUEUE_LIMIT_DEFAULT; in mei_device_init()
383 INIT_DELAYED_WORK(&dev->timer_work, mei_timer); in mei_device_init()
384 INIT_WORK(&dev->reset_work, mei_reset_work); in mei_device_init()
385 INIT_WORK(&dev->bus_rescan_work, mei_cl_bus_rescan_work); in mei_device_init()
387 bitmap_zero(dev->host_clients_map, MEI_CLIENTS_MAX); in mei_device_init()
388 dev->open_handle_count = 0; in mei_device_init()
390 dev->pxp_mode = MEI_DEV_PXP_DEFAULT; in mei_device_init()
396 bitmap_set(dev->host_clients_map, 0, 1); in mei_device_init()
398 dev->pg_event = MEI_PG_EVENT_IDLE; in mei_device_init()
399 dev->ops = hw_ops; in mei_device_init()
400 dev->dev = device; in mei_device_init()
402 dev->timeouts.hw_ready = mei_secs_to_jiffies(MEI_HW_READY_TIMEOUT); in mei_device_init()
403 dev->timeouts.connect = MEI_CONNECT_TIMEOUT; in mei_device_init()
404 dev->timeouts.client_init = MEI_CLIENTS_INIT_TIMEOUT; in mei_device_init()
405 dev->timeouts.pgi = mei_secs_to_jiffies(MEI_PGI_TIMEOUT); in mei_device_init()
406 dev->timeouts.d0i3 = mei_secs_to_jiffies(MEI_D0I3_TIMEOUT); in mei_device_init()
408 dev->timeouts.cl_connect = mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT_SLOW); in mei_device_init()
409 dev->timeouts.hbm = mei_secs_to_jiffies(MEI_HBM_TIMEOUT_SLOW); in mei_device_init()
410 dev->timeouts.mkhi_recv = msecs_to_jiffies(MKHI_RCV_TIMEOUT_SLOW); in mei_device_init()
412 dev->timeouts.cl_connect = mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT); in mei_device_init()
413 dev->timeouts.hbm = mei_secs_to_jiffies(MEI_HBM_TIMEOUT); in mei_device_init()
414 dev->timeouts.mkhi_recv = msecs_to_jiffies(MKHI_RCV_TIMEOUT); in mei_device_init()