[Intel-gfx] [RFC PATCH 092/162] drm/i915/uapi: introduce drm_i915_gem_create_ext

Chris Wilson chris at chris-wilson.co.uk
Fri Nov 27 19:21:31 UTC 2020


Quoting Matthew Auld (2020-11-27 12:06:08)
> +int
> +i915_gem_create_ioctl(struct drm_device *dev, void *data,
> +                     struct drm_file *file)
> +{
> +       struct drm_i915_private *i915 = to_i915(dev);
> +       struct create_ext ext_data = { .i915 = i915 };
> +       struct drm_i915_gem_create_ext *args = data;
> +       int ret;
> +
> +       i915_gem_flush_free_objects(i915);
> +
> +       ret = i915_user_extensions(u64_to_user_ptr(args->extensions),
> +                                  create_extensions,
> +                                  ARRAY_SIZE(create_extensions),
> +                                  &ext_data);
> +       if (ret)
> +               goto err_free;
> +
> +       if (!ext_data.placements) {
> +               struct intel_memory_region **placements;
> +               enum intel_memory_type mem_type = INTEL_MEMORY_SYSTEM;
> +
> +               placements = kmalloc(sizeof(struct intel_memory_region *),
> +                                    GFP_KERNEL);
> +               if (!placements)
> +                       return -ENOMEM;
> +
> +               placements[0] = intel_memory_region_by_type(i915, mem_type);
> +
> +               ext_data.placements = placements;
> +               ext_data.n_placements = 1;
> +       }
> +
> +       ret = i915_gem_create(file,
> +                             ext_data.placements,
> +                             ext_data.n_placements,
> +                             &args->size, &args->handle);
> +       if (!ret)
> +               return 0;

Applying the extensions has to happen after creating the vanilla object.

It literally is the equivalent of applying the setparam ioctl to a fresh
object.

Look at the PXP series for how badly wrong this goes if you try it this
way around.
-Chris


More information about the Intel-gfx mailing list