amdgpu: amdgpu_drm.h for new GPUVM fault ioctl
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 24 Feb 2023 09:03:36 +0000 (10:03 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 10 Oct 2023 08:25:07 +0000 (10:25 +0200)
Based on agd5f/drm-next.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
include/drm/amdgpu_drm.h

index c0a0ad1..ad21c61 100644 (file)
@@ -94,6 +94,9 @@ extern "C" {
  *
  * %AMDGPU_GEM_DOMAIN_OA       Ordered append, used by 3D or Compute engines
  * for appending data.
+ *
+ * %AMDGPU_GEM_DOMAIN_DOORBELL Doorbell. It is an MMIO region for
+ * signalling user mode queues.
  */
 #define AMDGPU_GEM_DOMAIN_CPU          0x1
 #define AMDGPU_GEM_DOMAIN_GTT          0x2
@@ -101,12 +104,14 @@ extern "C" {
 #define AMDGPU_GEM_DOMAIN_GDS          0x8
 #define AMDGPU_GEM_DOMAIN_GWS          0x10
 #define AMDGPU_GEM_DOMAIN_OA           0x20
+#define AMDGPU_GEM_DOMAIN_DOORBELL     0x40
 #define AMDGPU_GEM_DOMAIN_MASK         (AMDGPU_GEM_DOMAIN_CPU | \
                                         AMDGPU_GEM_DOMAIN_GTT | \
                                         AMDGPU_GEM_DOMAIN_VRAM | \
                                         AMDGPU_GEM_DOMAIN_GDS | \
                                         AMDGPU_GEM_DOMAIN_GWS | \
-                                        AMDGPU_GEM_DOMAIN_OA)
+                                        AMDGPU_GEM_DOMAIN_OA | \
+                                        AMDGPU_GEM_DOMAIN_DOORBELL)
 
 /* Flag that CPU access will be required for the case of VRAM domain */
 #define AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED  (1 << 0)
@@ -140,6 +145,32 @@ extern "C" {
  * not require GTT memory accounting
  */
 #define AMDGPU_GEM_CREATE_PREEMPTIBLE          (1 << 11)
+/* Flag that BO can be discarded under memory pressure without keeping the
+ * content.
+ */
+#define AMDGPU_GEM_CREATE_DISCARDABLE          (1 << 12)
+/* Flag that BO is shared coherently between multiple devices or CPU threads.
+ * May depend on GPU instructions to flush caches to system scope explicitly.
+ *
+ * This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and
+ * may override the MTYPE selected in AMDGPU_VA_OP_MAP.
+ */
+#define AMDGPU_GEM_CREATE_COHERENT             (1 << 13)
+/* Flag that BO should not be cached by GPU. Coherent without having to flush
+ * GPU caches explicitly
+ *
+ * This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and
+ * may override the MTYPE selected in AMDGPU_VA_OP_MAP.
+ */
+#define AMDGPU_GEM_CREATE_UNCACHED             (1 << 14)
+/* Flag that BO should be coherent across devices when using device-level
+ * atomics. May depend on GPU instructions to flush caches to device scope
+ * explicitly, promoting them to system scope automatically.
+ *
+ * This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and
+ * may override the MTYPE selected in AMDGPU_VA_OP_MAP.
+ */
+#define AMDGPU_GEM_CREATE_EXT_COHERENT         (1 << 15)
 
 struct drm_amdgpu_gem_create_in  {
        /** the requested memory size */
@@ -218,15 +249,17 @@ union drm_amdgpu_bo_list {
 /* unknown cause */
 #define AMDGPU_CTX_UNKNOWN_RESET       3
 
-/* indicate gpu reset occured after ctx created */
+/* indicate gpu reset occurred after ctx created */
 #define AMDGPU_CTX_QUERY2_FLAGS_RESET    (1<<0)
-/* indicate vram lost occured after ctx created */
+/* indicate vram lost occurred after ctx created */
 #define AMDGPU_CTX_QUERY2_FLAGS_VRAMLOST (1<<1)
 /* indicate some job from this context once cause gpu hang */
 #define AMDGPU_CTX_QUERY2_FLAGS_GUILTY   (1<<2)
 /* indicate some errors are detected by RAS */
 #define AMDGPU_CTX_QUERY2_FLAGS_RAS_CE   (1<<3)
 #define AMDGPU_CTX_QUERY2_FLAGS_RAS_UE   (1<<4)
+/* indicate that the reset hasn't completed yet */
+#define AMDGPU_CTX_QUERY2_FLAGS_RESET_IN_PROGRESS (1<<5)
 
 /* Context priority level */
 #define AMDGPU_CTX_PRIORITY_UNSET       -2048
@@ -529,6 +562,8 @@ struct drm_amdgpu_gem_op {
 #define AMDGPU_VM_MTYPE_UC             (4 << 5)
 /* Use Read Write MTYPE instead of default MTYPE */
 #define AMDGPU_VM_MTYPE_RW             (5 << 5)
+/* don't allocate MALL */
+#define AMDGPU_VM_PAGE_NOALLOC         (1 << 9)
 
 struct drm_amdgpu_gem_va {
        /** GEM object handle */
@@ -559,7 +594,8 @@ struct drm_amdgpu_gem_va {
  */
 #define AMDGPU_HW_IP_VCN_ENC      7
 #define AMDGPU_HW_IP_VCN_JPEG     8
-#define AMDGPU_HW_IP_NUM          9
+#define AMDGPU_HW_IP_VPE          9
+#define AMDGPU_HW_IP_NUM          10
 
 #define AMDGPU_HW_IP_INSTANCE_MAX_COUNT 1
 
@@ -572,6 +608,7 @@ struct drm_amdgpu_gem_va {
 #define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
 #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT    0x08
 #define AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL  0x09
+#define AMDGPU_CHUNK_ID_CP_GFX_SHADOW   0x0a
 
 struct drm_amdgpu_cs_chunk {
        __u32           chunk_id;
@@ -688,6 +725,15 @@ struct drm_amdgpu_cs_chunk_data {
        };
 };
 
+#define AMDGPU_CS_CHUNK_CP_GFX_SHADOW_FLAGS_INIT_SHADOW         0x1
+
+struct drm_amdgpu_cs_chunk_cp_gfx_shadow {
+       __u64 shadow_va;
+       __u64 csa_va;
+       __u64 gds_va;
+       __u64 flags;
+};
+
 /*
  *  Query h/w info: Flag that this is integrated (a.h.a. fusion) GPU
  *
@@ -695,6 +741,7 @@ struct drm_amdgpu_cs_chunk_data {
 #define AMDGPU_IDS_FLAGS_FUSION         0x1
 #define AMDGPU_IDS_FLAGS_PREEMPTION     0x2
 #define AMDGPU_IDS_FLAGS_TMZ            0x4
+#define AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD 0x8
 
 /* indicate if acceleration can be working */
 #define AMDGPU_INFO_ACCEL_WORKING              0x00
@@ -747,6 +794,20 @@ struct drm_amdgpu_cs_chunk_data {
        #define AMDGPU_INFO_FW_DMCUB            0x14
        /* Subquery id: Query TOC firmware version */
        #define AMDGPU_INFO_FW_TOC              0x15
+       /* Subquery id: Query CAP firmware version */
+       #define AMDGPU_INFO_FW_CAP              0x16
+       /* Subquery id: Query GFX RLCP firmware version */
+       #define AMDGPU_INFO_FW_GFX_RLCP         0x17
+       /* Subquery id: Query GFX RLCV firmware version */
+       #define AMDGPU_INFO_FW_GFX_RLCV         0x18
+       /* Subquery id: Query MES_KIQ firmware version */
+       #define AMDGPU_INFO_FW_MES_KIQ          0x19
+       /* Subquery id: Query MES firmware version */
+       #define AMDGPU_INFO_FW_MES              0x1a
+       /* Subquery id: Query IMU firmware version */
+       #define AMDGPU_INFO_FW_IMU              0x1b
+       /* Subquery id: Query VPE firmware version */
+       #define AMDGPU_INFO_FW_VPE              0x1c
 
 /* number of bytes moved for TTM migration */
 #define AMDGPU_INFO_NUM_BYTES_MOVED            0x0f
@@ -800,6 +861,10 @@ struct drm_amdgpu_cs_chunk_data {
        #define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_SCLK               0x8
        /* Subquery id: Query GPU stable pstate memory clock */
        #define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_MCLK               0x9
+       /* Subquery id: Query GPU peak pstate shader clock */
+       #define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_SCLK                 0xa
+       /* Subquery id: Query GPU peak pstate memory clock */
+       #define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_MCLK                 0xb
 /* Number of VRAM page faults on CPU access. */
 #define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS   0x1E
 #define AMDGPU_INFO_VRAM_LOST_COUNTER          0x1F
@@ -839,6 +904,10 @@ struct drm_amdgpu_cs_chunk_data {
        #define AMDGPU_INFO_VIDEO_CAPS_DECODE           0
        /* Subquery id: Encode */
        #define AMDGPU_INFO_VIDEO_CAPS_ENCODE           1
+/* Query the max number of IBs per gang per submission */
+#define AMDGPU_INFO_MAX_IBS                    0x22
+/* query last page fault info */
+#define AMDGPU_INFO_GPUVM_FAULT                        0x23
 
 #define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0
 #define AMDGPU_INFO_MMR_SE_INDEX_MASK  0xff
@@ -990,6 +1059,8 @@ struct drm_amdgpu_info_vbios {
 #define AMDGPU_VRAM_TYPE_DDR4  8
 #define AMDGPU_VRAM_TYPE_GDDR6 9
 #define AMDGPU_VRAM_TYPE_DDR5  10
+#define AMDGPU_VRAM_TYPE_LPDDR4 11
+#define AMDGPU_VRAM_TYPE_LPDDR5 12
 
 struct drm_amdgpu_info_device {
        /** PCI Device ID */
@@ -1015,7 +1086,8 @@ struct drm_amdgpu_info_device {
        __u32 enabled_rb_pipes_mask;
        __u32 num_rb_pipes;
        __u32 num_hw_gfx_contexts;
-       __u32 _pad;
+       /* PCIe version (the smaller of the GPU and the CPU/motherboard) */
+       __u32 pcie_gen;
        __u64 ids_flags;
        /** Starting virtual address for UMDs. */
        __u64 virtual_address_offset;
@@ -1062,7 +1134,8 @@ struct drm_amdgpu_info_device {
        __u32 gs_prim_buffer_depth;
        /* max gs wavefront per vgt*/
        __u32 max_gs_waves_per_vgt;
-       __u32 _pad1;
+       /* PCIe number of lanes (the smaller of the GPU and the CPU/motherboard) */
+       __u32 pcie_num_lanes;
        /* always on cu bitmap */
        __u32 cu_ao_bitmap[4][4];
        /** Starting high virtual address for UMDs. */
@@ -1073,6 +1146,26 @@ struct drm_amdgpu_info_device {
        __u32 pa_sc_tile_steering_override;
        /* disabled TCCs */
        __u64 tcc_disabled_mask;
+       __u64 min_engine_clock;
+       __u64 min_memory_clock;
+       /* The following fields are only set on gfx11+, older chips set 0. */
+       __u32 tcp_cache_size;       /* AKA GL0, VMEM cache */
+       __u32 num_sqc_per_wgp;
+       __u32 sqc_data_cache_size;  /* AKA SMEM cache */
+       __u32 sqc_inst_cache_size;
+       __u32 gl1c_cache_size;
+       __u32 gl2c_cache_size;
+       __u64 mall_size;            /* AKA infinity cache */
+       /* high 32 bits of the rb pipes mask */
+       __u32 enabled_rb_pipes_mask_hi;
+       /* shadow area size for gfx11 */
+       __u32 shadow_size;
+       /* shadow area base virtual alignment for gfx11 */
+       __u32 shadow_alignment;
+       /* context save area size for gfx11 */
+       __u32 csa_size;
+       /* context save area base virtual alignment for gfx11 */
+       __u32 csa_alignment;
 };
 
 struct drm_amdgpu_info_hw_ip {
@@ -1087,7 +1180,8 @@ struct drm_amdgpu_info_hw_ip {
        __u32  ib_size_alignment;
        /** Bitmask of available rings. Bit 0 means ring 0, etc. */
        __u32  available_rings;
-       __u32  _pad;
+       /** version info: bits 23:16 major, 15:8 minor, 7:0 revision */
+       __u32  ip_discovery_version;
 };
 
 struct drm_amdgpu_info_num_handles {
@@ -1139,6 +1233,20 @@ struct drm_amdgpu_info_video_caps {
        struct drm_amdgpu_info_video_codec_info codec_info[AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT];
 };
 
+#define AMDGPU_VMHUB_TYPE_MASK                 0xff
+#define AMDGPU_VMHUB_TYPE_SHIFT                        0
+#define AMDGPU_VMHUB_TYPE_GFX                  0
+#define AMDGPU_VMHUB_TYPE_MM0                  1
+#define AMDGPU_VMHUB_TYPE_MM1                  2
+#define AMDGPU_VMHUB_IDX_MASK                  0xff00
+#define AMDGPU_VMHUB_IDX_SHIFT                 8
+
+struct drm_amdgpu_info_gpuvm_fault {
+       __u64 addr;
+       __u32 status;
+       __u32 vmhub;
+};
+
 /*
  * Supported GPU families
  */
@@ -1152,7 +1260,12 @@ struct drm_amdgpu_info_video_caps {
 #define AMDGPU_FAMILY_RV                       142 /* Raven */
 #define AMDGPU_FAMILY_NV                       143 /* Navi10 */
 #define AMDGPU_FAMILY_VGH                      144 /* Van Gogh */
+#define AMDGPU_FAMILY_GC_11_0_0                        145 /* GC 11.0.0 */
 #define AMDGPU_FAMILY_YC                       146 /* Yellow Carp */
+#define AMDGPU_FAMILY_GC_11_0_1                        148 /* GC 11.0.1 */
+#define AMDGPU_FAMILY_GC_10_3_6                        149 /* GC 10.3.6 */
+#define AMDGPU_FAMILY_GC_10_3_7                        151 /* GC 10.3.7 */
+#define AMDGPU_FAMILY_GC_11_5_0                        150 /* GC 11.5.0 */
 
 #if defined(__cplusplus)
 }