@@ -623,6 +623,14 @@ typedef struct drm_i915_irq_wait {
623
623
#define I915_SCHEDULER_CAP_PREEMPTION (1ul << 2)
624
624
#define I915_SCHEDULER_CAP_SEMAPHORES (1ul << 3)
625
625
#define I915_SCHEDULER_CAP_ENGINE_BUSY_STATS (1ul << 4)
626
+ /*
627
+ * Indicates the 2k user priority levels are statically mapped into 3 buckets as
628
+ * follows:
629
+ *
630
+ * -1k to -1 Low priority
631
+ * 0 Normal priority
632
+ * 1 to 1k Highest priority
633
+ */
626
634
#define I915_SCHEDULER_CAP_STATIC_PRIORITY_MAP (1ul << 5)
627
635
628
636
#define I915_PARAM_HUC_STATUS 42
@@ -2072,6 +2080,61 @@ struct i915_context_engines_parallel_submit {
2072
2080
struct i915_engine_class_instance engines[N__]; \
2073
2081
} __attribute__((packed)) name__
2074
2082
2083
+ /**
2084
+ * DOC: Context Engine Map uAPI
2085
+ *
2086
+ * Context engine map is a new way of addressing engines when submitting batch-
2087
+ * buffers, replacing the existing way of using identifiers like `I915_EXEC_BLT`
2088
+ * inside the flags field of `struct drm_i915_gem_execbuffer2`.
2089
+ *
2090
+ * To use it created GEM contexts need to be configured with a list of engines
2091
+ * the user is intending to submit to. This is accomplished using the
2092
+ * `I915_CONTEXT_PARAM_ENGINES` parameter and `struct
2093
+ * i915_context_param_engines`.
2094
+ *
2095
+ * For such contexts the `I915_EXEC_RING_MASK` field becomes an index into the
2096
+ * configured map.
2097
+ *
2098
+ * Example of creating such context and submitting against it:
2099
+ *
2100
+ * .. code-block:: C
2101
+ *
2102
+ * I915_DEFINE_CONTEXT_PARAM_ENGINES(engines, 2) = {
2103
+ * .engines = { { I915_ENGINE_CLASS_RENDER, 0 },
2104
+ * { I915_ENGINE_CLASS_COPY, 0 } }
2105
+ * };
2106
+ * struct drm_i915_gem_context_create_ext_setparam p_engines = {
2107
+ * .base = {
2108
+ * .name = I915_CONTEXT_CREATE_EXT_SETPARAM,
2109
+ * },
2110
+ * .param = {
2111
+ * .param = I915_CONTEXT_PARAM_ENGINES,
2112
+ * .value = to_user_pointer(&engines),
2113
+ * .size = sizeof(engines),
2114
+ * },
2115
+ * };
2116
+ * struct drm_i915_gem_context_create_ext create = {
2117
+ * .flags = I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS,
2118
+ * .extensions = to_user_pointer(&p_engines);
2119
+ * };
2120
+ *
2121
+ * ctx_id = gem_context_create_ext(drm_fd, &create);
2122
+ *
2123
+ * // We have now created a GEM context with two engines in the map:
2124
+ * // Index 0 points to rcs0 while index 1 points to bcs0. Other engines
2125
+ * // will not be accessible from this context.
2126
+ *
2127
+ * ...
2128
+ * execbuf.rsvd1 = ctx_id;
2129
+ * execbuf.flags = 0; // Submits to index 0, which is rcs0 for this context
2130
+ * gem_execbuf(drm_fd, &execbuf);
2131
+ *
2132
+ * ...
2133
+ * execbuf.rsvd1 = ctx_id;
2134
+ * execbuf.flags = 1; // Submits to index 0, which is bcs0 for this context
2135
+ * gem_execbuf(drm_fd, &execbuf);
2136
+ */
2137
+
2075
2138
struct i915_context_param_engines {
2076
2139
__u64 extensions ; /* linked chain of extension blocks, 0 terminates */
2077
2140
#define I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE 0 /* see i915_context_engines_load_balance */
@@ -2106,8 +2169,6 @@ struct drm_i915_gem_context_destroy {
2106
2169
* The id of new VM (bound to the fd) for use with I915_CONTEXT_PARAM_VM is
2107
2170
* returned in the outparam @id.
2108
2171
*
2109
- * No flags are defined, with all bits reserved and must be zero.
2110
- *
2111
2172
* An extension chain maybe provided, starting with @extensions, and terminated
2112
2173
* by the @next_extension being 0. Currently, mem region extension is defined.
2113
2174
*
@@ -2407,6 +2468,7 @@ struct drm_i915_query_item {
2407
2468
#define DRM_I915_QUERY_TOPOLOGY_INFO 1
2408
2469
#define DRM_I915_QUERY_ENGINE_INFO 2
2409
2470
#define DRM_I915_QUERY_PERF_CONFIG 3
2471
+ #define DRM_I915_QUERY_MEMORY_REGIONS 4
2410
2472
/* Must be kept compact -- no holes and well documented */
2411
2473
2412
2474
/**
@@ -2554,8 +2616,6 @@ struct drm_i915_query_topology_info {
2554
2616
* struct drm_i915_engine_info
2555
2617
*
2556
2618
* Describes one engine and it's capabilities as known to the driver.
2557
- *
2558
- * FIXME: revert to upstream version after UMD switch to PRELIM version
2559
2619
*/
2560
2620
struct drm_i915_engine_info {
2561
2621
/** @engine: Engine class and instance. */
@@ -2649,6 +2709,138 @@ struct drm_i915_query_perf_config {
2649
2709
__u8 data [];
2650
2710
};
2651
2711
2712
+ /**
2713
+ * enum drm_i915_gem_memory_class - Supported memory classes
2714
+ */
2715
+ enum drm_i915_gem_memory_class {
2716
+ /** @I915_MEMORY_CLASS_SYSTEM: System memory */
2717
+ I915_MEMORY_CLASS_SYSTEM = 0 ,
2718
+ /** @I915_MEMORY_CLASS_DEVICE: Device local-memory */
2719
+ I915_MEMORY_CLASS_DEVICE ,
2720
+ };
2721
+
2722
+ /**
2723
+ * struct drm_i915_gem_memory_class_instance - Identify particular memory region
2724
+ */
2725
+ struct drm_i915_gem_memory_class_instance {
2726
+ /** @memory_class: See enum drm_i915_gem_memory_class */
2727
+ __u16 memory_class ;
2728
+
2729
+ /** @memory_instance: Which instance */
2730
+ __u16 memory_instance ;
2731
+ };
2732
+
2733
+ /**
2734
+ * struct drm_i915_memory_region_info - Describes one region as known to the
2735
+ * driver.
2736
+ *
2737
+ * Note that we reserve some stuff here for potential future work. As an example
2738
+ * we might want expose the capabilities for a given region, which could include
2739
+ * things like if the region is CPU mappable/accessible, what are the supported
2740
+ * mapping types etc.
2741
+ *
2742
+ * Note that to extend struct drm_i915_memory_region_info and struct
2743
+ * drm_i915_query_memory_regions in the future the plan is to do the following:
2744
+ *
2745
+ * .. code-block:: C
2746
+ *
2747
+ * struct drm_i915_memory_region_info {
2748
+ * struct drm_i915_gem_memory_class_instance region;
2749
+ * union {
2750
+ * __u32 rsvd0;
2751
+ * __u32 new_thing1;
2752
+ * };
2753
+ * ...
2754
+ * union {
2755
+ * __u64 rsvd1[8];
2756
+ * struct {
2757
+ * __u64 new_thing2;
2758
+ * __u64 new_thing3;
2759
+ * ...
2760
+ * };
2761
+ * };
2762
+ * };
2763
+ *
2764
+ * With this things should remain source compatible between versions for
2765
+ * userspace, even as we add new fields.
2766
+ *
2767
+ * Note this is using both struct drm_i915_query_item and struct drm_i915_query.
2768
+ * For this new query we are adding the new query id DRM_I915_QUERY_MEMORY_REGIONS
2769
+ * at &drm_i915_query_item.query_id.
2770
+ */
2771
+ struct drm_i915_memory_region_info {
2772
+ /** @region: The class:instance pair encoding */
2773
+ struct drm_i915_gem_memory_class_instance region ;
2774
+
2775
+ /** @rsvd0: MBZ */
2776
+ __u32 rsvd0 ;
2777
+
2778
+ /** @probed_size: Memory probed by the driver (-1 = unknown) */
2779
+ __u64 probed_size ;
2780
+
2781
+ /** @unallocated_size: Estimate of memory remaining (-1 = unknown) */
2782
+ __u64 unallocated_size ;
2783
+
2784
+ /** @rsvd1: MBZ */
2785
+ __u64 rsvd1 [8 ];
2786
+ };
2787
+
2788
+ /**
2789
+ * struct drm_i915_query_memory_regions
2790
+ *
2791
+ * The region info query enumerates all regions known to the driver by filling
2792
+ * in an array of struct drm_i915_memory_region_info structures.
2793
+ *
2794
+ * Example for getting the list of supported regions:
2795
+ *
2796
+ * .. code-block:: C
2797
+ *
2798
+ * struct drm_i915_query_memory_regions *info;
2799
+ * struct drm_i915_query_item item = {
2800
+ * .query_id = DRM_I915_QUERY_MEMORY_REGIONS;
2801
+ * };
2802
+ * struct drm_i915_query query = {
2803
+ * .num_items = 1,
2804
+ * .items_ptr = (uintptr_t)&item,
2805
+ * };
2806
+ * int err, i;
2807
+ *
2808
+ * // First query the size of the blob we need, this needs to be large
2809
+ * // enough to hold our array of regions. The kernel will fill out the
2810
+ * // item.length for us, which is the number of bytes we need.
2811
+ * err = ioctl(fd, DRM_IOCTL_I915_QUERY, &query);
2812
+ * if (err) ...
2813
+ *
2814
+ * info = calloc(1, item.length);
2815
+ * // Now that we allocated the required number of bytes, we call the ioctl
2816
+ * // again, this time with the data_ptr pointing to our newly allocated
2817
+ * // blob, which the kernel can then populate with the all the region info.
2818
+ * item.data_ptr = (uintptr_t)&info,
2819
+ *
2820
+ * err = ioctl(fd, DRM_IOCTL_I915_QUERY, &query);
2821
+ * if (err) ...
2822
+ *
2823
+ * // We can now access each region in the array
2824
+ * for (i = 0; i < info->num_regions; i++) {
2825
+ * struct drm_i915_memory_region_info mr = info->regions[i];
2826
+ * u16 class = mr.region.class;
2827
+ * u16 instance = mr.region.instance;
2828
+ *
2829
+ * ....
2830
+ * }
2831
+ *
2832
+ * free(info);
2833
+ */
2834
+ struct drm_i915_query_memory_regions {
2835
+ /** @num_regions: Number of supported regions */
2836
+ __u32 num_regions ;
2837
+
2838
+ /** @rsvd: MBZ */
2839
+ __u32 rsvd [3 ];
2840
+
2841
+ /** @regions: Info about each supported region */
2842
+ struct drm_i915_memory_region_info regions [];
2843
+ };
2652
2844
#include "i915_drm_prelim.h"
2653
2845
2654
2846
/* ID of the protected content session managed by i915 when PXP is active */
0 commit comments