[Intel-gfx] [PATCH 3/4] drm/i915: treat shmem as a region
Chris Wilson
chris at chris-wilson.co.uk
Thu Oct 17 20:31:23 UTC 2019
Quoting Matthew Auld (2019-10-17 18:45:43)
> @@ -434,9 +439,9 @@ const struct drm_i915_gem_object_ops i915_gem_shmem_ops = {
> .release = shmem_release,
> };
>
> -static int create_shmem(struct drm_i915_private *i915,
> - struct drm_gem_object *obj,
> - size_t size)
> +static int __create_shmem(struct drm_i915_private *i915,
> + struct drm_gem_object *obj,
> + size_t size)
I would feel happier if our interface was consistent, right up until the
moment it met drm, i.e. resource_size_t size.
> {
> unsigned long flags = VM_NORESERVE;
> struct file *filp;
> @@ -455,31 +460,23 @@ static int create_shmem(struct drm_i915_private *i915,
> return 0;
> }
>
> -struct drm_i915_gem_object *
> -i915_gem_object_create_shmem(struct drm_i915_private *i915, u64 size)
> +static struct drm_i915_gem_object *
> +create_shmem(struct intel_memory_region *mem,
> + resource_size_t size,
> + unsigned int flags)
> {
> + struct drm_i915_private *i915 = mem->i915;
> struct drm_i915_gem_object *obj;
> struct address_space *mapping;
> unsigned int cache_level;
> gfp_t mask;
> int ret;
>
> - /* There is a prevalence of the assumption that we fit the object's
> - * page count inside a 32bit _signed_ variable. Let's document this and
> - * catch if we ever need to fix it. In the meantime, if you do spot
> - * such a local variable, please consider fixing!
> - */
> - if (size >> PAGE_SHIFT > INT_MAX)
> - return ERR_PTR(-E2BIG);
> -
> - if (overflows_type(size, obj->base.size))
> - return ERR_PTR(-E2BIG);
> -
> obj = i915_gem_object_alloc();
> if (!obj)
> return ERR_PTR(-ENOMEM);
>
> - ret = create_shmem(i915, &obj->base, size);
> + ret = __create_shmem(i915, &obj->base, size);
> if (ret)
> goto fail;
More information about the Intel-gfx
mailing list