Lines Matching refs:uacce

30 	if (q->uacce->ops->start_queue) {  in uacce_start_queue()
31 ret = q->uacce->ops->start_queue(q); in uacce_start_queue()
42 struct uacce_device *uacce = q->uacce; in uacce_put_queue() local
44 if ((q->state == UACCE_Q_STARTED) && uacce->ops->stop_queue) in uacce_put_queue()
45 uacce->ops->stop_queue(q); in uacce_put_queue()
48 uacce->ops->put_queue) in uacce_put_queue()
49 uacce->ops->put_queue(q); in uacce_put_queue()
60 struct uacce_device *uacce = q->uacce; in uacce_fops_unl_ioctl() local
71 mutex_lock(&uacce->mutex); in uacce_fops_unl_ioctl()
83 if (uacce->ops->ioctl) in uacce_fops_unl_ioctl()
84 ret = uacce->ops->ioctl(q, cmd, arg); in uacce_fops_unl_ioctl()
89 mutex_unlock(&uacce->mutex); in uacce_fops_unl_ioctl()
103 static int uacce_bind_queue(struct uacce_device *uacce, struct uacce_queue *q) in uacce_bind_queue() argument
108 if (!(uacce->flags & UACCE_DEV_SVA)) in uacce_bind_queue()
111 handle = iommu_sva_bind_device(uacce->parent, current->mm, NULL); in uacce_bind_queue()
136 struct uacce_device *uacce; in uacce_fops_open() local
140 uacce = xa_load(&uacce_xa, iminor(inode)); in uacce_fops_open()
141 if (!uacce) in uacce_fops_open()
148 mutex_lock(&uacce->mutex); in uacce_fops_open()
150 if (!uacce->parent) { in uacce_fops_open()
155 ret = uacce_bind_queue(uacce, q); in uacce_fops_open()
159 q->uacce = uacce; in uacce_fops_open()
161 if (uacce->ops->get_queue) { in uacce_fops_open()
162 ret = uacce->ops->get_queue(uacce, q->pasid, q); in uacce_fops_open()
169 uacce->inode = inode; in uacce_fops_open()
172 list_add(&q->list, &uacce->queues); in uacce_fops_open()
173 mutex_unlock(&uacce->mutex); in uacce_fops_open()
181 mutex_unlock(&uacce->mutex); in uacce_fops_open()
188 struct uacce_device *uacce = q->uacce; in uacce_fops_release() local
190 mutex_lock(&uacce->mutex); in uacce_fops_release()
194 mutex_unlock(&uacce->mutex); in uacce_fops_release()
218 struct uacce_device *uacce = q->uacce; in uacce_fops_mmap() local
251 if (!uacce->ops->mmap) { in uacce_fops_mmap()
256 ret = uacce->ops->mmap(q, vma, qfr); in uacce_fops_mmap()
280 struct uacce_device *uacce = q->uacce; in uacce_fops_poll() local
289 if (uacce->ops->is_q_updated && uacce->ops->is_q_updated(q)) in uacce_fops_poll()
314 struct uacce_device *uacce = to_uacce_device(dev); in api_show() local
316 return sysfs_emit(buf, "%s\n", uacce->api_ver); in api_show()
322 struct uacce_device *uacce = to_uacce_device(dev); in flags_show() local
324 return sysfs_emit(buf, "%u\n", uacce->flags); in flags_show()
331 struct uacce_device *uacce = to_uacce_device(dev); in available_instances_show() local
333 if (!uacce->ops->get_available_instances) in available_instances_show()
337 uacce->ops->get_available_instances(uacce)); in available_instances_show()
343 struct uacce_device *uacce = to_uacce_device(dev); in algorithms_show() local
345 return sysfs_emit(buf, "%s\n", uacce->algs); in algorithms_show()
351 struct uacce_device *uacce = to_uacce_device(dev); in region_mmio_size_show() local
354 uacce->qf_pg_num[UACCE_QFRT_MMIO] << PAGE_SHIFT); in region_mmio_size_show()
360 struct uacce_device *uacce = to_uacce_device(dev); in region_dus_size_show() local
363 uacce->qf_pg_num[UACCE_QFRT_DUS] << PAGE_SHIFT); in region_dus_size_show()
387 struct uacce_device *uacce = to_uacce_device(dev); in uacce_dev_is_visible() local
390 (!uacce->qf_pg_num[UACCE_QFRT_MMIO])) || in uacce_dev_is_visible()
392 (!uacce->qf_pg_num[UACCE_QFRT_DUS]))) in uacce_dev_is_visible()
407 struct uacce_device *uacce = to_uacce_device(dev); in uacce_release() local
409 kfree(uacce); in uacce_release()
437 static void uacce_disable_sva(struct uacce_device *uacce) in uacce_disable_sva() argument
439 if (!(uacce->flags & UACCE_DEV_SVA)) in uacce_disable_sva()
442 iommu_dev_disable_feature(uacce->parent, IOMMU_DEV_FEAT_SVA); in uacce_disable_sva()
443 iommu_dev_disable_feature(uacce->parent, IOMMU_DEV_FEAT_IOPF); in uacce_disable_sva()
458 struct uacce_device *uacce; in uacce_alloc() local
461 uacce = kzalloc(sizeof(struct uacce_device), GFP_KERNEL); in uacce_alloc()
462 if (!uacce) in uacce_alloc()
467 uacce->parent = parent; in uacce_alloc()
468 uacce->flags = flags; in uacce_alloc()
469 uacce->ops = interface->ops; in uacce_alloc()
471 ret = xa_alloc(&uacce_xa, &uacce->dev_id, uacce, xa_limit_32b, in uacce_alloc()
476 INIT_LIST_HEAD(&uacce->queues); in uacce_alloc()
477 mutex_init(&uacce->mutex); in uacce_alloc()
478 device_initialize(&uacce->dev); in uacce_alloc()
479 uacce->dev.devt = MKDEV(MAJOR(uacce_devt), uacce->dev_id); in uacce_alloc()
480 uacce->dev.class = uacce_class; in uacce_alloc()
481 uacce->dev.groups = uacce_dev_groups; in uacce_alloc()
482 uacce->dev.parent = uacce->parent; in uacce_alloc()
483 uacce->dev.release = uacce_release; in uacce_alloc()
484 dev_set_name(&uacce->dev, "%s-%d", interface->name, uacce->dev_id); in uacce_alloc()
486 return uacce; in uacce_alloc()
489 uacce_disable_sva(uacce); in uacce_alloc()
490 kfree(uacce); in uacce_alloc()
501 int uacce_register(struct uacce_device *uacce) in uacce_register() argument
503 if (!uacce) in uacce_register()
506 uacce->cdev = cdev_alloc(); in uacce_register()
507 if (!uacce->cdev) in uacce_register()
510 uacce->cdev->ops = &uacce_fops; in uacce_register()
511 uacce->cdev->owner = THIS_MODULE; in uacce_register()
513 return cdev_device_add(uacce->cdev, &uacce->dev); in uacce_register()
521 void uacce_remove(struct uacce_device *uacce) in uacce_remove() argument
525 if (!uacce) in uacce_remove()
531 if (uacce->inode) in uacce_remove()
532 unmap_mapping_range(uacce->inode->i_mapping, 0, 0, 1); in uacce_remove()
539 mutex_lock(&uacce->mutex); in uacce_remove()
541 list_for_each_entry_safe(q, next_q, &uacce->queues, list) { in uacce_remove()
553 uacce_disable_sva(uacce); in uacce_remove()
555 if (uacce->cdev) in uacce_remove()
556 cdev_device_del(uacce->cdev, &uacce->dev); in uacce_remove()
557 xa_erase(&uacce_xa, uacce->dev_id); in uacce_remove()
562 uacce->ops = NULL; in uacce_remove()
563 uacce->parent = NULL; in uacce_remove()
564 mutex_unlock(&uacce->mutex); in uacce_remove()
565 put_device(&uacce->dev); in uacce_remove()