| 1 | /* SPDX-License-Identifier: GPL-2.0-only OR MIT */ |
| 2 | /* Copyright (c) 2023 Imagination Technologies Ltd. */ |
| 3 | |
| 4 | #ifndef PVR_VM_H |
| 5 | #define PVR_VM_H |
| 6 | |
| 7 | #include "pvr_rogue_mmu_defs.h" |
| 8 | |
| 9 | #include <uapi/drm/pvr_drm.h> |
| 10 | |
| 11 | #include <linux/types.h> |
| 12 | |
| 13 | /* Forward declaration from "pvr_device.h" */ |
| 14 | struct pvr_device; |
| 15 | struct pvr_file; |
| 16 | |
| 17 | /* Forward declaration from "pvr_gem.h" */ |
| 18 | struct pvr_gem_object; |
| 19 | |
| 20 | /* Forward declaration from "pvr_vm.c" */ |
| 21 | struct pvr_vm_context; |
| 22 | |
| 23 | /* Forward declaration from <uapi/drm/pvr_drm.h> */ |
| 24 | struct drm_pvr_ioctl_get_heap_info_args; |
| 25 | |
| 26 | /* Forward declaration from <drm/drm_exec.h> */ |
| 27 | struct drm_exec; |
| 28 | |
| 29 | /* Functions defined in pvr_vm.c */ |
| 30 | |
| 31 | bool pvr_device_addr_is_valid(u64 device_addr); |
| 32 | bool pvr_device_addr_and_size_are_valid(struct pvr_vm_context *vm_ctx, |
| 33 | u64 device_addr, u64 size); |
| 34 | |
| 35 | struct pvr_vm_context *pvr_vm_create_context(struct pvr_device *pvr_dev, |
| 36 | bool is_userspace_context); |
| 37 | |
| 38 | int pvr_vm_map(struct pvr_vm_context *vm_ctx, |
| 39 | struct pvr_gem_object *pvr_obj, u64 pvr_obj_offset, |
| 40 | u64 device_addr, u64 size); |
| 41 | int pvr_vm_unmap_obj(struct pvr_vm_context *vm_ctx, |
| 42 | struct pvr_gem_object *pvr_obj, |
| 43 | u64 device_addr, u64 size); |
| 44 | int pvr_vm_unmap(struct pvr_vm_context *vm_ctx, u64 device_addr, u64 size); |
| 45 | void pvr_vm_unmap_all(struct pvr_vm_context *vm_ctx); |
| 46 | |
| 47 | dma_addr_t pvr_vm_get_page_table_root_addr(struct pvr_vm_context *vm_ctx); |
| 48 | struct dma_resv *pvr_vm_get_dma_resv(struct pvr_vm_context *vm_ctx); |
| 49 | |
| 50 | int pvr_static_data_areas_get(const struct pvr_device *pvr_dev, |
| 51 | struct drm_pvr_ioctl_dev_query_args *args); |
| 52 | int pvr_heap_info_get(const struct pvr_device *pvr_dev, |
| 53 | struct drm_pvr_ioctl_dev_query_args *args); |
| 54 | const struct drm_pvr_heap *pvr_find_heap_containing(struct pvr_device *pvr_dev, |
| 55 | u64 addr, u64 size); |
| 56 | |
| 57 | struct pvr_gem_object *pvr_vm_find_gem_object(struct pvr_vm_context *vm_ctx, |
| 58 | u64 device_addr, |
| 59 | u64 *mapped_offset_out, |
| 60 | u64 *mapped_size_out); |
| 61 | |
| 62 | struct pvr_fw_object * |
| 63 | pvr_vm_get_fw_mem_context(struct pvr_vm_context *vm_ctx); |
| 64 | |
| 65 | struct pvr_vm_context *pvr_vm_context_lookup(struct pvr_file *pvr_file, u32 handle); |
| 66 | struct pvr_vm_context *pvr_vm_context_get(struct pvr_vm_context *vm_ctx); |
| 67 | bool pvr_vm_context_put(struct pvr_vm_context *vm_ctx); |
| 68 | void pvr_destroy_vm_contexts_for_file(struct pvr_file *pvr_file); |
| 69 | |
| 70 | #endif /* PVR_VM_H */ |
| 71 | |