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(struct pvr_vm_context *vm_ctx, u64 device_addr, u64 size); 42 43 dma_addr_t pvr_vm_get_page_table_root_addr(struct pvr_vm_context *vm_ctx); 44 struct dma_resv *pvr_vm_get_dma_resv(struct pvr_vm_context *vm_ctx); 45 46 int pvr_static_data_areas_get(const struct pvr_device *pvr_dev, 47 struct drm_pvr_ioctl_dev_query_args *args); 48 int pvr_heap_info_get(const struct pvr_device *pvr_dev, 49 struct drm_pvr_ioctl_dev_query_args *args); 50 const struct drm_pvr_heap *pvr_find_heap_containing(struct pvr_device *pvr_dev, 51 u64 addr, u64 size); 52 53 struct pvr_gem_object *pvr_vm_find_gem_object(struct pvr_vm_context *vm_ctx, 54 u64 device_addr, 55 u64 *mapped_offset_out, 56 u64 *mapped_size_out); 57 58 struct pvr_fw_object * 59 pvr_vm_get_fw_mem_context(struct pvr_vm_context *vm_ctx); 60 61 struct pvr_vm_context *pvr_vm_context_lookup(struct pvr_file *pvr_file, u32 handle); 62 struct pvr_vm_context *pvr_vm_context_get(struct pvr_vm_context *vm_ctx); 63 bool pvr_vm_context_put(struct pvr_vm_context *vm_ctx); 64 void pvr_destroy_vm_contexts_for_file(struct pvr_file *pvr_file); 65 66 #endif /* PVR_VM_H */ 67