[Intel-gfx] [PATCH 2/4] drm/i915: Support for creating Stolen memory backed objects
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Wed Jul 1 09:20:27 PDT 2015
On 07/01/2015 10:25 AM, ankitprasad.r.sharma at intel.com wrote:
> From: Ankitprasad Sharma <ankitprasad.r.sharma at intel.com>
>
> Extend the drm_i915_gem_create structure to add support for
> creating Stolen memory backed objects. Added a new flag through
> which user can specify the preference to allocate the object from
> stolen memory, which if set, an attempt will be made to allocate
> the object from stolen memory subject to the availability of
> free space in the stolen region.
>
> v2: Rebased to the latest drm-intel-nightly (Ankit)
>
> testcase: igt/gem_stolen
>
> Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma at intel.com>
> ---
> drivers/gpu/drm/i915/i915_dma.c | 3 +++
> drivers/gpu/drm/i915/i915_gem.c | 31 +++++++++++++++++++++++++++----
> include/uapi/drm/i915_drm.h | 15 +++++++++++++++
> 3 files changed, 45 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> index c5349fa..6045749 100644
> --- a/drivers/gpu/drm/i915/i915_dma.c
> +++ b/drivers/gpu/drm/i915/i915_dma.c
> @@ -167,6 +167,9 @@ static int i915_getparam(struct drm_device *dev, void *data,
> value = i915.enable_hangcheck &&
> intel_has_gpu_reset(dev);
> break;
> + case I915_PARAM_CREATE_VERSION:
> + value = 1;
> + break;
> default:
> DRM_DEBUG("Unknown parameter %d\n", param->param);
> return -EINVAL;
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index a2a4a27..4acf331 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -391,7 +391,8 @@ static int
> i915_gem_create(struct drm_file *file,
> struct drm_device *dev,
> uint64_t size,
> - uint32_t *handle_p)
> + uint32_t *handle_p,
> + uint32_t flags)
> {
> struct drm_i915_gem_object *obj;
> int ret;
> @@ -401,8 +402,29 @@ i915_gem_create(struct drm_file *file,
> if (size == 0)
> return -EINVAL;
>
> + if (flags & ~(I915_CREATE_PLACEMENT_STOLEN))
> + return -EINVAL;
> +
> /* Allocate the new object */
> - obj = i915_gem_alloc_object(dev, size);
> + if (flags & I915_CREATE_PLACEMENT_STOLEN) {
> + mutex_lock(&dev->struct_mutex);
> + obj = i915_gem_object_create_stolen(dev, size);
One more thing here, size is u64 in this function but
i915_gem_object_create_stolen takes u32. Is compiler not noticing this?
(And i915_gem_alloc_object is size_t for a complete win!) :D
Regards,
Tvrtko
More information about the Intel-gfx
mailing list