History

drm/i915/uapi: implement object placement extension

Add new extension to support setting an immutable-priority-list of potential placements, at creation time. If we use the normal gem_create or gem_create_ext without the extensions/placements then we still get the old behaviour with only placing the object in system memory. v2(Daniel & Jason): - Add a bunch of kernel-doc - Simplify design for placements extension

Matthew Auld committed 5 years ago

Commit 2459e561 parent ebcb4027 files · +318 −17Browse files

Showing the changes to include/uapi/drm (1 of 7 files). Show all

Unified · Split

include/uapi/drm/i915_drm.h+62−0
@@ -2616,6 +2616,11 @@ struct drm_i915_gem_create_ext { · 2615 unmodified lines
26162616 *
26172617 * The (page-aligned) allocated size for the object will be returned.
26182618 *
2619+ * Note that for some devices we have might have further minimum
2620+ * page-size restrictions(larger than 4K), like for device local-memory.
2621+ * However in general the final size here should always reflect any
2622+ * rounding up, if for example using the I915_GEM_CREATE_EXT_MEMORY_REGIONS
2623+ * extension to place the object in device local-memory.
26192624 */
26202625 __u64 size;
26212626 /**
@@ -2636,10 +2641,67 @@ struct drm_i915_gem_create_ext { · 14 unmodified lines
26362641 * If we don't supply any extensions then we get the same old gem_create
26372642 * behaviour.
26382643 *
2644+ * For I915_GEM_CREATE_EXT_MEMORY_REGIONS usage see
2645+ * struct drm_i915_gem_create_ext_memory_regions.
26392646 */
2647+#define I915_GEM_CREATE_EXT_MEMORY_REGIONS 0
26402648 __u64 extensions;
26412649 };
26422650
2651+/**
2652+ * struct drm_i915_gem_create_ext_memory_regions - The
2653+ * I915_GEM_CREATE_EXT_MEMORY_REGIONS extension.
2654+ *
2655+ * Set the object with the desired set of placements/regions in priority
2656+ * order. Each entry must be unique and supported by the device.
2657+ *
2658+ * This is provided as an array of struct drm_i915_gem_memory_class_instance, or
2659+ * an equivalent layout of class:instance pair encodings. See struct
2660+ * drm_i915_query_memory_regions and DRM_I915_QUERY_MEMORY_REGIONS for how to
2661+ * query the supported regions for a device.
2662+ *
2663+ * As an example, on discrete devices, if we wish to set the placement as
2664+ * device local-memory we can do something like:
2665+ *
2666+ * .. code-block:: C
2667+ *
2668+ * struct drm_i915_gem_memory_class_instance region_lmem = {
2669+ * .memory_class = I915_MEMORY_CLASS_DEVICE,
2670+ * .memory_instance = 0,
2671+ * };
2672+ * struct drm_i915_gem_create_ext_memory_regions regions = {
2673+ * .base = { .name = I915_GEM_CREATE_EXT_MEMORY_REGIONS },
2674+ * .regions = (uintptr_t)&region_lmem,
2675+ * .num_regions = 1,
2676+ * };
2677+ * struct drm_i915_gem_create_ext create_ext = {
2678+ * .size = 16 * PAGE_SIZE,
2679+ * .extensions = (uintptr_t)&regions,
2680+ * };
2681+ *
2682+ * int err = ioctl(fd, DRM_IOCTL_I915_GEM_CREATE_EXT, &create_ext);
2683+ * if (err) ...
2684+ *
2685+ * At which point we get the object handle in &drm_i915_gem_create_ext.handle,
2686+ * along with the final object size in &drm_i915_gem_create_ext.size, which
2687+ * should account for any rounding up, if required.
2688+ */
2689+struct drm_i915_gem_create_ext_memory_regions {
2690+ /** @base: Extension link. See struct i915_user_extension. */
2691+ struct i915_user_extension base;
2692+
2693+ /** @pad: MBZ */
2694+ __u32 pad;
2695+ /** @num_regions: Number of elements in the @regions array. */
2696+ __u32 num_regions;
2697+ /**
2698+ * @regions: The regions/placements array.
2699+ *
2700+ * An array of struct drm_i915_gem_memory_class_instance.
2701+ */
2702+ __u64 regions;
2703+};
2704+
26432705 #if defined(__cplusplus)
26442706 }
26452707 #endif