Lines Matching +full:powervr +full:- +full:gpu
1 // SPDX-License-Identifier: GPL-2.0-only OR MIT
13 #include <linux/dma-buf.h>
14 #include <linux/dma-direction.h>
15 #include <linux/dma-mapping.h>
18 #include <linux/iosys-map.h>
35 if (!(pvr_obj->flags & DRM_PVR_BO_ALLOW_CPU_USERSPACE_ACCESS)) in pvr_gem_mmap()
36 return -EINVAL; in pvr_gem_mmap()
54 * pvr_gem_object_flags_validate() - Verify that a collection of PowerVR GEM
56 * @flags: PowerVR GEM mapping/creation flags to validate.
58 * This function explicitly allows kernel-only flags. All ioctl entrypoints
70 * Memory flagged as PM/FW-protected cannot be mapped to in pvr_gem_object_flags_validate()
105 * pvr_gem_object_into_handle() - Convert a reference to an object into a
106 * userspace-accessible handle.
107 * @pvr_obj: [IN] Target PowerVR-specific object.
151 * pvr_gem_object_from_handle() - Obtain a reference to an object from a
153 * @pvr_file: PowerVR-specific file to which @handle is associated.
163 * * A pointer to the requested PowerVR-specific object on success, or
180 * pvr_gem_object_vmap() - Map a PowerVR GEM object into CPU virtual address
182 * @pvr_obj: Target PowerVR GEM object.
187 * If @pvr_obj is CPU-cached, dma_sync_sgtable_for_cpu() is called to make
192 * * -%ENOMEM if the mapping fails, or
204 dma_resv_lock(obj->resv, NULL); in pvr_gem_object_vmap()
210 if (pvr_obj->flags & PVR_BO_CPU_CACHED) { in pvr_gem_object_vmap()
211 struct device *dev = shmem_obj->base.dev->dev; in pvr_gem_object_vmap()
213 /* If shmem_obj->sgt is NULL, that means the buffer hasn't been mapped in pvr_gem_object_vmap()
214 * in GPU space yet. in pvr_gem_object_vmap()
216 if (shmem_obj->sgt) in pvr_gem_object_vmap()
217 dma_sync_sgtable_for_cpu(dev, shmem_obj->sgt, DMA_BIDIRECTIONAL); in pvr_gem_object_vmap()
220 dma_resv_unlock(obj->resv); in pvr_gem_object_vmap()
225 dma_resv_unlock(obj->resv); in pvr_gem_object_vmap()
231 * pvr_gem_object_vunmap() - Unmap a PowerVR memory object from CPU virtual
233 * @pvr_obj: Target PowerVR GEM object.
235 * If @pvr_obj is CPU-cached, dma_sync_sgtable_for_device() is called to make
236 * sure the GPU mapping is consistent.
242 struct iosys_map map = IOSYS_MAP_INIT_VADDR(shmem_obj->vaddr); in pvr_gem_object_vunmap()
248 dma_resv_lock(obj->resv, NULL); in pvr_gem_object_vunmap()
250 if (pvr_obj->flags & PVR_BO_CPU_CACHED) { in pvr_gem_object_vunmap()
251 struct device *dev = shmem_obj->base.dev->dev; in pvr_gem_object_vunmap()
253 /* If shmem_obj->sgt is NULL, that means the buffer hasn't been mapped in pvr_gem_object_vunmap()
254 * in GPU space yet. in pvr_gem_object_vunmap()
256 if (shmem_obj->sgt) in pvr_gem_object_vunmap()
257 dma_sync_sgtable_for_device(dev, shmem_obj->sgt, DMA_BIDIRECTIONAL); in pvr_gem_object_vunmap()
262 dma_resv_unlock(obj->resv); in pvr_gem_object_vunmap()
266 * pvr_gem_object_zero() - Zeroes the physical memory behind an object.
267 * @pvr_obj: Target PowerVR GEM object.
285 /* Make sure the zero-ing is done before vumap-ing the object. */ in pvr_gem_object_zero()
294 * pvr_gem_create_object() - Allocate and pre-initializes a pvr_gem_object
299 * * The new pre-initialized GEM object on success,
300 * * -ENOMEM if the allocation failed.
309 return ERR_PTR(-ENOMEM); in pvr_gem_create_object()
312 gem_obj->funcs = &pvr_gem_object_funcs; in pvr_gem_create_object()
318 * pvr_gem_object_create() - Creates a PowerVR-specific buffer object.
319 * @pvr_dev: Target PowerVR device.
331 * * The newly-minted PowerVR-specific buffer object on success,
332 * * -%EINVAL if @size is zero or @flags is not valid,
333 * * -%ENOMEM if sufficient physical memory cannot be allocated, or
346 return ERR_PTR(-EINVAL); in pvr_gem_object_create()
352 shmem_obj->pages_mark_dirty_on_put = true; in pvr_gem_object_create()
353 shmem_obj->map_wc = !(flags & PVR_BO_CPU_CACHED); in pvr_gem_object_create()
355 pvr_obj->flags = flags; in pvr_gem_object_create()
363 dma_sync_sgtable_for_device(shmem_obj->base.dev->dev, sgt, in pvr_gem_object_create()
381 * pvr_gem_get_dma_addr() - Get DMA address for given offset in object
388 * * -%EINVAL if object is not currently backed, or if @offset is out of valid
400 WARN_ON(!shmem_obj->sgt); in pvr_gem_get_dma_addr()
401 for_each_sgtable_dma_sg(shmem_obj->sgt, sgl, sgt_idx) { in pvr_gem_get_dma_addr()
406 (offset - accumulated_offset); in pvr_gem_get_dma_addr()
413 return -EINVAL; in pvr_gem_get_dma_addr()