/** * DOC: V3D GEM BO management support * * Compared to VC4 (V3D 2.x), V3D 3.3 introduces an MMU between the * GPU and the bus, allowing us to use shmem objects for our storage * instead of CMA. * * Physically contiguous objects may still be imported to V3D, but the * driver doesn't allocate physically contiguous objects on its own. * Display engines requiring physically contiguous allocations should * look into Mesa's "renderonly" support (as used by the Mesa pl111 * driver) for an example of how to integrate with V3D.
*/
if (bo->base.pages)
res |= DRM_GEM_OBJECT_RESIDENT;
return res;
}
/* Called DRM core on the last userspace/kernel unreference of the * BO.
*/ void v3d_free_object(struct drm_gem_object *obj)
{ struct v3d_dev *v3d = to_v3d_dev(obj->dev); struct v3d_bo *bo = to_v3d_bo(obj);
/* gem_create_object function for allocating a BO struct and doing * early setup.
*/ struct drm_gem_object *v3d_create_object(struct drm_device *dev, size_t size)
{ struct v3d_bo *bo; struct drm_gem_object *obj;
if (size == 0) return ERR_PTR(-EINVAL);
bo = kzalloc(sizeof(*bo), GFP_KERNEL); if (!bo) return ERR_PTR(-ENOMEM);
obj = &bo->base.base;
/* So far we pin the BO in the MMU for its lifetime, so use * shmem's helper for getting a lifetime sgt.
*/
sgt = drm_gem_shmem_get_pages_sgt(&bo->base); if (IS_ERR(sgt)) return PTR_ERR(sgt);
spin_lock(&v3d->mm_lock); /* Allocate the object's space in the GPU's page tables. * Inserting PTEs will happen later, but the offset is for the * lifetime of the BO.
*/
ret = drm_mm_insert_node_generic(&v3d->mm, &bo->node,
obj->size >> V3D_MMU_PAGE_SHIFT,
align >> V3D_MMU_PAGE_SHIFT, 0, 0);
spin_unlock(&v3d->mm_lock); if (ret) return ret;
gem_obj = drm_gem_object_lookup(file_priv, args->handle); if (!gem_obj) {
DRM_DEBUG("Failed to look up GEM BO %d\n", args->handle); return -ENOENT;
}
bo = to_v3d_bo(gem_obj);
ret = drm_gem_dma_resv_wait(file_priv, args->handle, true, timeout_jiffies);
/* Decrement the user's timeout, in case we got interrupted * such that the ioctl will be restarted.
*/
delta_ns = ktime_to_ns(ktime_sub(ktime_get(), start)); if (delta_ns < args->timeout_ns)
args->timeout_ns -= delta_ns; else
args->timeout_ns = 0;
/* Asked to wait beyond the jiffy/scheduler precision? */ if (ret == -ETIME && args->timeout_ns)
ret = -EAGAIN;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.