Lines Matching refs:qdev

91 	struct qaic_device *qdev = to_qaic_device(dev);  in qaicm_pci_release()  local
93 pci_set_drvdata(qdev->pdev, NULL); in qaicm_pci_release()
108 struct qaic_device *qdev = qddev->qdev; in qaic_open() local
113 rcu_id = srcu_read_lock(&qdev->dev_lock); in qaic_open()
114 if (qdev->dev_state != QAIC_ONLINE) { in qaic_open()
144 srcu_read_unlock(&qdev->dev_lock, rcu_id); in qaic_open()
153 srcu_read_unlock(&qdev->dev_lock, rcu_id); in qaic_open()
161 struct qaic_device *qdev; in qaic_postclose() local
169 qdev = qddev->qdev; in qaic_postclose()
170 qdev_rcu_id = srcu_read_lock(&qdev->dev_lock); in qaic_postclose()
171 if (qdev->dev_state == QAIC_ONLINE) { in qaic_postclose()
172 qaic_release_usr(qdev, usr); in qaic_postclose()
173 for (i = 0; i < qdev->num_dbc; ++i) in qaic_postclose()
174 if (qdev->dbc[i].usr && qdev->dbc[i].usr->handle == usr->handle) in qaic_postclose()
175 release_dbc(qdev, i); in qaic_postclose()
177 srcu_read_unlock(&qdev->dev_lock, qdev_rcu_id); in qaic_postclose()
221 static int qaic_create_drm_device(struct qaic_device *qdev, s32 partition_id) in qaic_create_drm_device() argument
223 struct qaic_drm_device *qddev = qdev->qddev; in qaic_create_drm_device()
235 pci_dbg(qdev->pdev, "drm_dev_register failed %d\n", ret); in qaic_create_drm_device()
244 static void qaic_destroy_drm_device(struct qaic_device *qdev, s32 partition_id) in qaic_destroy_drm_device() argument
246 struct qaic_drm_device *qddev = qdev->qddev; in qaic_destroy_drm_device()
283 struct qaic_device *qdev; in qaic_mhi_probe() local
297 qdev = pci_get_drvdata(to_pci_dev(mhi_dev->mhi_cntrl->cntrl_dev)); in qaic_mhi_probe()
299 dev_set_drvdata(&mhi_dev->dev, qdev); in qaic_mhi_probe()
300 qdev->cntl_ch = mhi_dev; in qaic_mhi_probe()
302 ret = qaic_control_open(qdev); in qaic_mhi_probe()
304 pci_dbg(qdev->pdev, "%s: control_open failed %d\n", __func__, ret); in qaic_mhi_probe()
308 qdev->dev_state = QAIC_BOOT; in qaic_mhi_probe()
309 ret = get_cntl_version(qdev, NULL, &major, &minor); in qaic_mhi_probe()
311 …pci_err(qdev->pdev, "%s: Control protocol version (%d.%d) not supported. Supported version is (%d.… in qaic_mhi_probe()
316 qdev->dev_state = QAIC_ONLINE; in qaic_mhi_probe()
317 kobject_uevent(&(to_accel_kdev(qdev->qddev))->kobj, KOBJ_ONLINE); in qaic_mhi_probe()
322 qaic_control_close(qdev); in qaic_mhi_probe()
331 static void qaic_notify_reset(struct qaic_device *qdev) in qaic_notify_reset() argument
335 kobject_uevent(&(to_accel_kdev(qdev->qddev))->kobj, KOBJ_OFFLINE); in qaic_notify_reset()
336 qdev->dev_state = QAIC_OFFLINE; in qaic_notify_reset()
338 wake_all_cntl(qdev); in qaic_notify_reset()
339 for (i = 0; i < qdev->num_dbc; ++i) in qaic_notify_reset()
340 wakeup_dbc(qdev, i); in qaic_notify_reset()
341 synchronize_srcu(&qdev->dev_lock); in qaic_notify_reset()
344 void qaic_dev_reset_clean_local_state(struct qaic_device *qdev) in qaic_dev_reset_clean_local_state() argument
348 qaic_notify_reset(qdev); in qaic_dev_reset_clean_local_state()
351 for (i = 0; i < qdev->num_dbc; ++i) in qaic_dev_reset_clean_local_state()
352 release_dbc(qdev, i); in qaic_dev_reset_clean_local_state()
359 struct qaic_device *qdev; in create_qdev() local
363 qdev = devm_kzalloc(dev, sizeof(*qdev), GFP_KERNEL); in create_qdev()
364 if (!qdev) in create_qdev()
367 qdev->dev_state = QAIC_OFFLINE; in create_qdev()
369 qdev->num_dbc = 16; in create_qdev()
370 qdev->dbc = devm_kcalloc(dev, qdev->num_dbc, sizeof(*qdev->dbc), GFP_KERNEL); in create_qdev()
371 if (!qdev->dbc) in create_qdev()
380 pci_set_drvdata(pdev, qdev); in create_qdev()
388 ret = drmm_mutex_init(drm, &qdev->cntl_mutex); in create_qdev()
391 ret = drmm_mutex_init(drm, &qdev->bootlog_mutex); in create_qdev()
395 qdev->cntl_wq = qaicm_wq_init(drm, "qaic_cntl"); in create_qdev()
396 if (IS_ERR(qdev->cntl_wq)) in create_qdev()
398 qdev->qts_wq = qaicm_wq_init(drm, "qaic_ts"); in create_qdev()
399 if (IS_ERR(qdev->qts_wq)) in create_qdev()
402 ret = qaicm_srcu_init(drm, &qdev->dev_lock); in create_qdev()
406 qdev->qddev = qddev; in create_qdev()
407 qdev->pdev = pdev; in create_qdev()
408 qddev->qdev = qdev; in create_qdev()
410 INIT_LIST_HEAD(&qdev->cntl_xfer_list); in create_qdev()
411 INIT_LIST_HEAD(&qdev->bootlog); in create_qdev()
414 for (i = 0; i < qdev->num_dbc; ++i) { in create_qdev()
415 spin_lock_init(&qdev->dbc[i].xfer_lock); in create_qdev()
416 qdev->dbc[i].qdev = qdev; in create_qdev()
417 qdev->dbc[i].id = i; in create_qdev()
418 INIT_LIST_HEAD(&qdev->dbc[i].xfer_list); in create_qdev()
419 ret = qaicm_srcu_init(drm, &qdev->dbc[i].ch_lock); in create_qdev()
422 init_waitqueue_head(&qdev->dbc[i].dbc_release); in create_qdev()
423 INIT_LIST_HEAD(&qdev->dbc[i].bo_lists); in create_qdev()
426 return qdev; in create_qdev()
429 static int init_pci(struct qaic_device *qdev, struct pci_dev *pdev) in init_pci() argument
452 qdev->bar_0 = devm_ioremap_resource(&pdev->dev, &pdev->resource[0]); in init_pci()
453 if (IS_ERR(qdev->bar_0)) in init_pci()
454 return PTR_ERR(qdev->bar_0); in init_pci()
456 qdev->bar_2 = devm_ioremap_resource(&pdev->dev, &pdev->resource[2]); in init_pci()
457 if (IS_ERR(qdev->bar_2)) in init_pci()
458 return PTR_ERR(qdev->bar_2); in init_pci()
466 static int init_msi(struct qaic_device *qdev, struct pci_dev *pdev) in init_msi() argument
487 qdev->single_msi = true; in init_msi()
497 for (i = 0; i < qdev->num_dbc; ++i) { in init_msi()
499 pci_irq_vector(pdev, qdev->single_msi ? 0 : i + 1), in init_msi()
501 "qaic_dbc", &qdev->dbc[i]); in init_msi()
506 qdev->dbc[i].irq = pci_irq_vector(pdev, qdev->single_msi ? 0 : i + 1); in init_msi()
507 if (!qdev->single_msi) in init_msi()
508 disable_irq_nosync(qdev->dbc[i].irq); in init_msi()
509 INIT_WORK(&qdev->dbc[i].poll_work, irq_polling_work); in init_msi()
518 struct qaic_device *qdev; in qaic_pci_probe() local
523 qdev = create_qdev(pdev, id); in qaic_pci_probe()
524 if (!qdev) in qaic_pci_probe()
527 ret = init_pci(qdev, pdev); in qaic_pci_probe()
531 for (i = 0; i < qdev->num_dbc; ++i) in qaic_pci_probe()
532 qdev->dbc[i].dbc_base = qdev->bar_2 + QAIC_DBC_OFF(i); in qaic_pci_probe()
534 mhi_irq = init_msi(qdev, pdev); in qaic_pci_probe()
538 ret = qaic_create_drm_device(qdev, QAIC_NO_PARTITION); in qaic_pci_probe()
542 qdev->mhi_cntrl = qaic_mhi_register_controller(pdev, qdev->bar_0, mhi_irq, in qaic_pci_probe()
543 qdev->single_msi); in qaic_pci_probe()
544 if (IS_ERR(qdev->mhi_cntrl)) { in qaic_pci_probe()
545 ret = PTR_ERR(qdev->mhi_cntrl); in qaic_pci_probe()
546 qaic_destroy_drm_device(qdev, QAIC_NO_PARTITION); in qaic_pci_probe()
555 struct qaic_device *qdev = pci_get_drvdata(pdev); in qaic_pci_remove() local
557 if (!qdev) in qaic_pci_remove()
560 qaic_dev_reset_clean_local_state(qdev); in qaic_pci_remove()
561 qaic_mhi_free_controller(qdev->mhi_cntrl, link_up); in qaic_pci_remove()
562 qaic_destroy_drm_device(qdev, QAIC_NO_PARTITION); in qaic_pci_remove()
579 struct qaic_device *qdev = pci_get_drvdata(pdev); in qaic_pci_reset_prepare() local
581 qaic_notify_reset(qdev); in qaic_pci_reset_prepare()
582 qaic_mhi_start_reset(qdev->mhi_cntrl); in qaic_pci_reset_prepare()
583 qaic_dev_reset_clean_local_state(qdev); in qaic_pci_reset_prepare()
588 struct qaic_device *qdev = pci_get_drvdata(pdev); in qaic_pci_reset_done() local
590 qaic_mhi_reset_done(qdev->mhi_cntrl); in qaic_pci_reset_done()