Lines Matching +full:am62 +full:- +full:gpu
1 // SPDX-License-Identifier: GPL-2.0-only OR MIT
46 * * AXE-1-16M (found in Texas Instruments AM62)
50 * pvr_ioctl_create_bo() - IOCTL to create a GEM buffer object.
54 * @file: [IN] DRM file-private data.
60 * * -%EINVAL if the value of &drm_pvr_ioctl_create_bo_args.size is zero
62 * * -%EINVAL if any bits in &drm_pvr_ioctl_create_bo_args.flags that are
64 * * -%EINVAL if any padding fields in &drm_pvr_ioctl_create_bo_args are not
69 * userspace-accessible handle (see pvr_gem_object_into_handle()).
86 return -EIO; in pvr_ioctl_create_bo()
89 if (args->_padding_c != 0) { in pvr_ioctl_create_bo()
90 err = -EINVAL; in pvr_ioctl_create_bo()
95 * On 64-bit platforms (our primary target), size_t is a u64. However, in pvr_ioctl_create_bo()
99 * We also disallow zero-sized allocations, and reserved (kernel-only) in pvr_ioctl_create_bo()
102 if (args->size > SIZE_MAX || args->size == 0 || args->flags & in pvr_ioctl_create_bo()
103 ~DRM_PVR_BO_FLAGS_MASK || args->size & (PVR_DEVICE_PAGE_SIZE - 1)) { in pvr_ioctl_create_bo()
104 err = -EINVAL; in pvr_ioctl_create_bo()
108 sanitized_size = (size_t)args->size; in pvr_ioctl_create_bo()
111 * Create a buffer object and transfer ownership to a userspace- in pvr_ioctl_create_bo()
114 pvr_obj = pvr_gem_object_create(pvr_dev, sanitized_size, args->flags); in pvr_ioctl_create_bo()
120 /* This function will not modify &args->handle unless it succeeds. */ in pvr_ioctl_create_bo()
121 err = pvr_gem_object_into_handle(pvr_obj, pvr_file, &args->handle); in pvr_ioctl_create_bo()
144 * pvr_ioctl_get_bo_mmap_offset() - IOCTL to generate a "fake" offset to be
158 * * -%ENOENT if the handle does not reference a valid GEM buffer object,
159 * * -%EINVAL if any padding fields in &struct
175 return -EIO; in pvr_ioctl_get_bo_mmap_offset()
178 if (args->_padding_4 != 0) { in pvr_ioctl_get_bo_mmap_offset()
179 ret = -EINVAL; in pvr_ioctl_get_bo_mmap_offset()
186 * object cannot be found for the specified handle, return -%ENOENT (No in pvr_ioctl_get_bo_mmap_offset()
189 pvr_obj = pvr_gem_object_from_handle(pvr_file, args->handle); in pvr_ioctl_get_bo_mmap_offset()
191 ret = -ENOENT; in pvr_ioctl_get_bo_mmap_offset()
213 args->offset = drm_vma_node_offset_addr(&gem_obj->vma_node); in pvr_ioctl_get_bo_mmap_offset()
262 alloc_region_size = common_store_size_in_dwords - (256U * 4U) - in rogue_get_common_store_alloc_region_size()
268 return min(common_store_split_point - (256U * 4U), alloc_region_size); in rogue_get_common_store_alloc_region_size()
311 return rogue_get_common_store_alloc_region_size(pvr_dev) + pending_allocation_coeff_regs - in rogue_get_max_coeffs()
324 available_coeffs_in_dwords -= ROGUE_CSRM_LINE_SIZE_IN_DWORDS * 2; in rogue_get_cdm_max_local_mem_size_regs()
349 * * -%E2BIG if the indicated length of the allocation is less than is
351 * * -%EFAULT if local memory could not be copied to userspace.
360 if (!args->pointer) { in pvr_dev_query_gpu_info_get()
361 args->size = sizeof(struct drm_pvr_dev_query_gpu_info); in pvr_dev_query_gpu_info_get()
366 pvr_gpu_id_to_packed_bvnc(&pvr_dev->gpu_id); in pvr_dev_query_gpu_info_get()
369 err = PVR_UOBJ_SET(args->pointer, args->size, gpu_info); in pvr_dev_query_gpu_info_get()
373 if (args->size > sizeof(gpu_info)) in pvr_dev_query_gpu_info_get()
374 args->size = sizeof(gpu_info); in pvr_dev_query_gpu_info_get()
389 * * -%E2BIG if the indicated length of the allocation is less than is
391 * * -%EFAULT if local memory could not be copied to userspace.
400 if (!args->pointer) { in pvr_dev_query_runtime_info_get()
401 args->size = sizeof(struct drm_pvr_dev_query_runtime_info); in pvr_dev_query_runtime_info_get()
417 err = PVR_UOBJ_SET(args->pointer, args->size, runtime_info); in pvr_dev_query_runtime_info_get()
421 if (args->size > sizeof(runtime_info)) in pvr_dev_query_runtime_info_get()
422 args->size = sizeof(runtime_info); in pvr_dev_query_runtime_info_get()
427 * pvr_dev_query_quirks_get() - Unpack array of quirks at the address given
444 * * -%EINVAL if args contained non-zero reserved fields, or
445 * * -%E2BIG if the indicated length of the allocation is less than is
447 * * -%EFAULT if local memory could not be copied to userspace.
454 * @FIXME - hardcoding of numbers here is intended as an in pvr_dev_query_quirks_get()
474 if (!args->pointer) { in pvr_dev_query_quirks_get()
475 args->size = sizeof(struct drm_pvr_dev_query_quirks); in pvr_dev_query_quirks_get()
479 err = PVR_UOBJ_GET(query, args->size, args->pointer); in pvr_dev_query_quirks_get()
484 return -EINVAL; in pvr_dev_query_quirks_get()
501 return -E2BIG; in pvr_dev_query_quirks_get()
505 return -EFAULT; in pvr_dev_query_quirks_get()
512 err = PVR_UOBJ_SET(args->pointer, args->size, query); in pvr_dev_query_quirks_get()
516 args->size = sizeof(query); in pvr_dev_query_quirks_get()
521 * pvr_dev_query_enhancements_get() - Unpack array of enhancements at the
538 * * -%EINVAL if args contained non-zero reserved fields, or
539 * * -%E2BIG if the indicated length of the allocation is less than is
541 * * -%EFAULT if local memory could not be copied to userspace.
548 * @FIXME - hardcoding of numbers here is intended as an in pvr_dev_query_enhancements_get()
562 if (!args->pointer) { in pvr_dev_query_enhancements_get()
563 args->size = sizeof(struct drm_pvr_dev_query_enhancements); in pvr_dev_query_enhancements_get()
567 err = PVR_UOBJ_GET(query, args->size, args->pointer); in pvr_dev_query_enhancements_get()
572 return -EINVAL; in pvr_dev_query_enhancements_get()
574 return -EINVAL; in pvr_dev_query_enhancements_get()
584 return -E2BIG; in pvr_dev_query_enhancements_get()
588 return -EFAULT; in pvr_dev_query_enhancements_get()
593 err = PVR_UOBJ_SET(args->pointer, args->size, query); in pvr_dev_query_enhancements_get()
597 args->size = sizeof(query); in pvr_dev_query_enhancements_get()
602 * pvr_ioctl_dev_query() - IOCTL to copy information about a device
614 * * 0 on success or when fetching the size with args->pointer == NULL, or
615 * * -%E2BIG if the indicated size of the receiving struct is less than is
617 * * -%EINVAL if the indicated struct type is unknown, or
618 * * -%ENOMEM if local memory could not be allocated, or
619 * * -%EFAULT if local memory could not be copied to userspace.
628 int ret = -EINVAL; in pvr_ioctl_dev_query()
631 return -EIO; in pvr_ioctl_dev_query()
633 switch ((enum drm_pvr_dev_query)args->type) { in pvr_ioctl_dev_query()
665 * pvr_ioctl_create_context() - IOCTL to create a context
675 * * -%EINVAL if provided arguments are invalid, or
676 * * -%EFAULT if arguments can't be copied from userspace, or
684 struct pvr_file *pvr_file = file->driver_priv; in pvr_ioctl_create_context()
689 return -EIO; in pvr_ioctl_create_context()
699 * pvr_ioctl_destroy_context() - IOCTL to destroy a context
709 * * -%EINVAL if context not in context list.
716 struct pvr_file *pvr_file = file->driver_priv; in pvr_ioctl_destroy_context()
718 if (args->_padding_4) in pvr_ioctl_destroy_context()
719 return -EINVAL; in pvr_ioctl_destroy_context()
721 return pvr_context_destroy(pvr_file, args->handle); in pvr_ioctl_destroy_context()
725 * pvr_ioctl_create_free_list() - IOCTL to create a free list
748 return -EIO; in pvr_ioctl_create_free_list()
757 err = xa_alloc(&pvr_file->free_list_handles, in pvr_ioctl_create_free_list()
758 &args->handle, in pvr_ioctl_create_free_list()
779 * pvr_ioctl_destroy_free_list() - IOCTL to destroy a free list
789 * * -%EINVAL if free list not in object list.
799 if (args->_padding_4) in pvr_ioctl_destroy_free_list()
800 return -EINVAL; in pvr_ioctl_destroy_free_list()
802 free_list = xa_erase(&pvr_file->free_list_handles, args->handle); in pvr_ioctl_destroy_free_list()
804 return -EINVAL; in pvr_ioctl_destroy_free_list()
811 * pvr_ioctl_create_hwrt_dataset() - IOCTL to create a HWRT dataset
834 return -EIO; in pvr_ioctl_create_hwrt_dataset()
843 err = xa_alloc(&pvr_file->hwrt_handles, in pvr_ioctl_create_hwrt_dataset()
844 &args->handle, in pvr_ioctl_create_hwrt_dataset()
865 * pvr_ioctl_destroy_hwrt_dataset() - IOCTL to destroy a HWRT dataset
875 * * -%EINVAL if HWRT dataset not in object list.
885 if (args->_padding_4) in pvr_ioctl_destroy_hwrt_dataset()
886 return -EINVAL; in pvr_ioctl_destroy_hwrt_dataset()
888 hwrt = xa_erase(&pvr_file->hwrt_handles, args->handle); in pvr_ioctl_destroy_hwrt_dataset()
890 return -EINVAL; in pvr_ioctl_destroy_hwrt_dataset()
897 * pvr_ioctl_create_vm_context() - IOCTL to create a VM context
920 return -EIO; in pvr_ioctl_create_vm_context()
922 if (args->_padding_4) { in pvr_ioctl_create_vm_context()
923 err = -EINVAL; in pvr_ioctl_create_vm_context()
927 vm_ctx = pvr_vm_create_context(pvr_file->pvr_dev, true); in pvr_ioctl_create_vm_context()
934 err = xa_alloc(&pvr_file->vm_ctx_handles, in pvr_ioctl_create_vm_context()
935 &args->handle, in pvr_ioctl_create_vm_context()
956 * pvr_ioctl_destroy_vm_context() - IOCTL to destroy a VM context
966 * * -%EINVAL if object not in object list.
976 if (args->_padding_4) in pvr_ioctl_destroy_vm_context()
977 return -EINVAL; in pvr_ioctl_destroy_vm_context()
979 vm_ctx = xa_erase(&pvr_file->vm_ctx_handles, args->handle); in pvr_ioctl_destroy_vm_context()
981 return -EINVAL; in pvr_ioctl_destroy_vm_context()
988 * pvr_ioctl_vm_map() - IOCTL to map buffer to GPU address space.
998 * * -%EINVAL if &drm_pvr_ioctl_vm_op_map_args.flags is not zero,
999 * * -%EINVAL if the bounds specified by &drm_pvr_ioctl_vm_op_map_args.offset
1003 * * -%EINVAL if the bounds specified by
1005 * &drm_pvr_ioctl_vm_op_map_args.size do not form a valid device-virtual
1007 * * -%ENOENT if &drm_pvr_ioctl_vm_op_map_args.handle does not refer to a
1027 return -EIO; in pvr_ioctl_vm_map()
1030 if (args->_padding_14) { in pvr_ioctl_vm_map()
1031 err = -EINVAL; in pvr_ioctl_vm_map()
1035 if (args->flags != 0 || in pvr_ioctl_vm_map()
1036 check_add_overflow(args->offset, args->size, &offset_plus_size) || in pvr_ioctl_vm_map()
1037 !pvr_find_heap_containing(pvr_dev, args->device_addr, args->size)) { in pvr_ioctl_vm_map()
1038 err = -EINVAL; in pvr_ioctl_vm_map()
1042 vm_ctx = pvr_vm_context_lookup(pvr_file, args->vm_context_handle); in pvr_ioctl_vm_map()
1044 err = -EINVAL; in pvr_ioctl_vm_map()
1048 pvr_obj = pvr_gem_object_from_handle(pvr_file, args->handle); in pvr_ioctl_vm_map()
1050 err = -ENOENT; in pvr_ioctl_vm_map()
1061 if (args->offset >= pvr_obj_size || offset_plus_size > pvr_obj_size) { in pvr_ioctl_vm_map()
1062 err = -EINVAL; in pvr_ioctl_vm_map()
1066 err = pvr_vm_map(vm_ctx, pvr_obj, args->offset, in pvr_ioctl_vm_map()
1067 args->device_addr, args->size); in pvr_ioctl_vm_map()
1090 * pvr_ioctl_vm_unmap() - IOCTL to unmap buffer from GPU address space.
1100 * * -%EINVAL if &drm_pvr_ioctl_vm_op_unmap_args.device_addr is not a valid
1101 * device page-aligned device-virtual address, or
1102 * * -%ENOENT if there is currently no PowerVR buffer object mapped at
1115 if (args->_padding_4) in pvr_ioctl_vm_unmap()
1116 return -EINVAL; in pvr_ioctl_vm_unmap()
1118 vm_ctx = pvr_vm_context_lookup(pvr_file, args->vm_context_handle); in pvr_ioctl_vm_unmap()
1120 return -EINVAL; in pvr_ioctl_vm_unmap()
1122 err = pvr_vm_unmap(vm_ctx, args->device_addr, args->size); in pvr_ioctl_vm_unmap()
1130 * pvr_ioctl_submit_job() - IOCTL to submit a job to the GPU
1140 * * -%EINVAL if arguments are invalid.
1153 return -EIO; in pvr_ioctl_submit_jobs()
1166 return -EINVAL; in pvr_get_uobj()
1175 return -EINVAL; in pvr_set_uobj()
1178 return -EFAULT; in pvr_set_uobj()
1181 clear_user(u64_to_user_ptr(usr_ptr + obj_size), usr_stride - obj_size)) { in pvr_set_uobj()
1182 return -EFAULT; in pvr_set_uobj()
1194 if (in->stride < min_stride) in pvr_get_uobj_array()
1195 return -EINVAL; in pvr_get_uobj_array()
1197 if (!in->count) in pvr_get_uobj_array()
1200 out_alloc = kvmalloc_array(in->count, obj_size, GFP_KERNEL); in pvr_get_uobj_array()
1202 return -ENOMEM; in pvr_get_uobj_array()
1204 if (obj_size == in->stride) { in pvr_get_uobj_array()
1205 if (copy_from_user(out_alloc, u64_to_user_ptr(in->array), in pvr_get_uobj_array()
1206 (unsigned long)obj_size * in->count)) in pvr_get_uobj_array()
1207 ret = -EFAULT; in pvr_get_uobj_array()
1209 void __user *in_ptr = u64_to_user_ptr(in->array); in pvr_get_uobj_array()
1212 for (u32 i = 0; i < in->count; i++) { in pvr_get_uobj_array()
1213 ret = copy_struct_from_user(out_ptr, obj_size, in_ptr, in->stride); in pvr_get_uobj_array()
1218 in_ptr += in->stride; in pvr_get_uobj_array()
1235 if (out->stride < min_stride) in pvr_set_uobj_array()
1236 return -EINVAL; in pvr_set_uobj_array()
1238 if (!out->count) in pvr_set_uobj_array()
1241 if (obj_size == out->stride) { in pvr_set_uobj_array()
1242 if (copy_to_user(u64_to_user_ptr(out->array), in, in pvr_set_uobj_array()
1243 (unsigned long)obj_size * out->count)) in pvr_set_uobj_array()
1244 return -EFAULT; in pvr_set_uobj_array()
1246 u32 cpy_elem_size = min_t(u32, out->stride, obj_size); in pvr_set_uobj_array()
1247 void __user *out_ptr = u64_to_user_ptr(out->array); in pvr_set_uobj_array()
1250 for (u32 i = 0; i < out->count; i++) { in pvr_set_uobj_array()
1252 return -EFAULT; in pvr_set_uobj_array()
1255 in_ptr += out->stride; in pvr_set_uobj_array()
1258 if (out->stride > obj_size && in pvr_set_uobj_array()
1259 clear_user(u64_to_user_ptr(out->array + obj_size), in pvr_set_uobj_array()
1260 out->stride - obj_size)) { in pvr_set_uobj_array()
1261 return -EFAULT; in pvr_set_uobj_array()
1271 /* clang-format off */
1290 /* clang-format on */
1295 * pvr_drm_driver_open() - Driver callback when a new &struct drm_file is opened
1299 * Allocates powervr-specific file private data (&struct pvr_file).
1305 * * -%ENOMEM if the allocation of a &struct ipvr_file fails, or
1316 return -ENOMEM; in pvr_drm_driver_open()
1322 pvr_file->file = file; in pvr_drm_driver_open()
1325 * Store reference to powervr-specific outer device struct in file in pvr_drm_driver_open()
1328 pvr_file->pvr_dev = pvr_dev; in pvr_drm_driver_open()
1330 INIT_LIST_HEAD(&pvr_file->contexts); in pvr_drm_driver_open()
1332 xa_init_flags(&pvr_file->ctx_handles, XA_FLAGS_ALLOC1); in pvr_drm_driver_open()
1333 xa_init_flags(&pvr_file->free_list_handles, XA_FLAGS_ALLOC1); in pvr_drm_driver_open()
1334 xa_init_flags(&pvr_file->hwrt_handles, XA_FLAGS_ALLOC1); in pvr_drm_driver_open()
1335 xa_init_flags(&pvr_file->vm_ctx_handles, XA_FLAGS_ALLOC1); in pvr_drm_driver_open()
1338 * Store reference to powervr-specific file private data in DRM file in pvr_drm_driver_open()
1341 file->driver_priv = pvr_file; in pvr_drm_driver_open()
1347 * pvr_drm_driver_postclose() - One of the driver callbacks when a &struct
1352 * Frees powervr-specific file private data (&struct pvr_file).
1371 file->driver_priv = NULL; in pvr_drm_driver_postclose()
1406 pvr_dev = devm_drm_dev_alloc(&plat_dev->dev, &pvr_drm_driver, in pvr_probe()
1411 drm_dev = &pvr_dev->base; in pvr_probe()
1415 init_rwsem(&pvr_dev->reset_sem); in pvr_probe()
1423 devm_pm_runtime_enable(&plat_dev->dev); in pvr_probe()
1424 pm_runtime_mark_last_busy(&plat_dev->dev); in pvr_probe()
1426 pm_runtime_set_autosuspend_delay(&plat_dev->dev, 50); in pvr_probe()
1427 pm_runtime_use_autosuspend(&plat_dev->dev); in pvr_probe()
1438 xa_init_flags(&pvr_dev->free_list_ids, XA_FLAGS_ALLOC1); in pvr_probe()
1439 xa_init_flags(&pvr_dev->job_ids, XA_FLAGS_ALLOC1); in pvr_probe()
1462 WARN_ON(!xa_empty(&pvr_dev->job_ids)); in pvr_remove()
1463 WARN_ON(!xa_empty(&pvr_dev->free_list_ids)); in pvr_remove()
1465 xa_destroy(&pvr_dev->job_ids); in pvr_remove()
1466 xa_destroy(&pvr_dev->free_list_ids); in pvr_remove()
1468 pm_runtime_suspend(drm_dev->dev); in pvr_remove()
1477 { .compatible = "img,img-axe", .data = NULL },