[Intel-gfx] [PATCH 03/22] drm/i915: introduce intel_memory_region

Chris Wilson chris at chris-wilson.co.uk
Fri Sep 27 18:08:58 UTC 2019


Quoting Matthew Auld (2019-09-27 18:33:50)
> +struct drm_i915_gem_object *
> +i915_gem_object_create_region(struct intel_memory_region *mem,
> +                             resource_size_t size,
> +                             unsigned int flags)
> +{
> +       struct drm_i915_gem_object *obj;
> +
> +       if (!mem)
> +               return ERR_PTR(-ENODEV);
> +
> +       size = round_up(size, mem->min_page_size);
> +
> +       GEM_BUG_ON(!size);
> +       GEM_BUG_ON(!IS_ALIGNED(size, I915_GTT_MIN_ALIGNMENT));
> +
> +       if (size >> PAGE_SHIFT > INT_MAX)
> +               return ERR_PTR(-E2BIG);

It's probably past time we fixed up the remaining int num_pages.

Hmm, I know gcc has warned for constants > type. Can we get it to warn
for unguarded type restrictions, i.e.

	int num_pages = resource_size_t >> PAGE_SIZE;

Or maybe we go on a rampage and just ban obj->base.size and force
ourselves to use a wrapper in order to catch any offenders.
-Chris


More information about the Intel-gfx mailing list