Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915: split out i915_gtt_view_types.h from i915_vma_types.h

In the interest of limiting the display dependencies on i915 core
headers, split out i915_gtt_view_types.h from i915_vma_types.h, and only
include the new header from intel_display_types.h.

Reuse the new header from xe compat code too, failing build if partial
view is used in display code.

Side note: Why would we ever have set enum i915_gtt_view_type values to
size of each type?! What an insane hack.

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/bb31885c32dbddad76d634c6fdb98a73b546b42e.1740412806.git.jani.nikula@intel.com

+69 -125
+1 -1
drivers/gpu/drm/i915/display/intel_display_types.h
··· 42 42 #include <drm/intel/i915_hdcp_interface.h> 43 43 #include <uapi/drm/i915_drm.h> 44 44 45 - #include "i915_vma_types.h" 45 + #include "i915_gtt_view_types.h" 46 46 #include "intel_bios.h" 47 47 #include "intel_display.h" 48 48 #include "intel_display_conversion.h"
+59
drivers/gpu/drm/i915/i915_gtt_view_types.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* Copyright © 2025 Intel Corporation */ 3 + 4 + #ifndef __I915_GTT_VIEW_TYPES_H__ 5 + #define __I915_GTT_VIEW_TYPES_H__ 6 + 7 + #include <linux/types.h> 8 + 9 + struct intel_remapped_plane_info { 10 + /* in gtt pages */ 11 + u32 offset:31; 12 + u32 linear:1; 13 + union { 14 + /* in gtt pages for !linear */ 15 + struct { 16 + u16 width; 17 + u16 height; 18 + u16 src_stride; 19 + u16 dst_stride; 20 + }; 21 + 22 + /* in gtt pages for linear */ 23 + u32 size; 24 + }; 25 + } __packed; 26 + 27 + struct intel_rotation_info { 28 + struct intel_remapped_plane_info plane[2]; 29 + } __packed; 30 + 31 + struct intel_partial_info { 32 + u64 offset; 33 + unsigned int size; 34 + } __packed; 35 + 36 + struct intel_remapped_info { 37 + struct intel_remapped_plane_info plane[4]; 38 + /* in gtt pages */ 39 + u32 plane_alignment; 40 + } __packed; 41 + 42 + enum i915_gtt_view_type { 43 + I915_GTT_VIEW_NORMAL = 0, 44 + I915_GTT_VIEW_ROTATED = sizeof(struct intel_rotation_info), 45 + I915_GTT_VIEW_PARTIAL = sizeof(struct intel_partial_info), 46 + I915_GTT_VIEW_REMAPPED = sizeof(struct intel_remapped_info), 47 + }; 48 + 49 + struct i915_gtt_view { 50 + enum i915_gtt_view_type type; 51 + union { 52 + /* Members need to contain no holes/padding */ 53 + struct intel_partial_info partial; 54 + struct intel_rotation_info rotated; 55 + struct intel_remapped_info remapped; 56 + }; 57 + }; 58 + 59 + #endif /* __I915_GTT_VIEW_TYPES_H__ */
+2 -50
drivers/gpu/drm/i915/i915_vma_types.h
··· 32 32 33 33 #include "gem/i915_gem_object_types.h" 34 34 35 + #include "i915_gtt_view_types.h" 36 + 35 37 /** 36 38 * DOC: Global GTT views 37 39 * ··· 97 95 98 96 struct i915_vma_resource; 99 97 100 - struct intel_remapped_plane_info { 101 - /* in gtt pages */ 102 - u32 offset:31; 103 - u32 linear:1; 104 - union { 105 - /* in gtt pages for !linear */ 106 - struct { 107 - u16 width; 108 - u16 height; 109 - u16 src_stride; 110 - u16 dst_stride; 111 - }; 112 - 113 - /* in gtt pages for linear */ 114 - u32 size; 115 - }; 116 - } __packed; 117 - 118 - struct intel_remapped_info { 119 - struct intel_remapped_plane_info plane[4]; 120 - /* in gtt pages */ 121 - u32 plane_alignment; 122 - } __packed; 123 - 124 - struct intel_rotation_info { 125 - struct intel_remapped_plane_info plane[2]; 126 - } __packed; 127 - 128 - struct intel_partial_info { 129 - u64 offset; 130 - unsigned int size; 131 - } __packed; 132 - 133 - enum i915_gtt_view_type { 134 - I915_GTT_VIEW_NORMAL = 0, 135 - I915_GTT_VIEW_ROTATED = sizeof(struct intel_rotation_info), 136 - I915_GTT_VIEW_PARTIAL = sizeof(struct intel_partial_info), 137 - I915_GTT_VIEW_REMAPPED = sizeof(struct intel_remapped_info), 138 - }; 139 - 140 98 static inline void assert_i915_gem_gtt_types(void) 141 99 { 142 100 BUILD_BUG_ON(sizeof(struct intel_rotation_info) != 2 * sizeof(u32) + 8 * sizeof(u16)); ··· 121 159 break; 122 160 } 123 161 } 124 - 125 - struct i915_gtt_view { 126 - enum i915_gtt_view_type type; 127 - union { 128 - /* Members need to contain no holes/padding */ 129 - struct intel_partial_info partial; 130 - struct intel_rotation_info rotated; 131 - struct intel_remapped_info remapped; 132 - }; 133 - }; 134 162 135 163 /** 136 164 * DOC: Virtual Memory Address
+7
drivers/gpu/drm/xe/compat-i915-headers/i915_gtt_view_types.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* Copyright © 2025 Intel Corporation */ 3 + 4 + #include "../../i915/i915_gtt_view_types.h" 5 + 6 + /* Partial view not supported in xe, fail build if used. */ 7 + #define I915_GTT_VIEW_PARTIAL
-74
drivers/gpu/drm/xe/compat-i915-headers/i915_vma_types.h
··· 1 - /* SPDX-License-Identifier: MIT */ 2 - /* 3 - * Copyright © 2023 Intel Corporation 4 - */ 5 - 6 - #include <linux/types.h> 7 - #include <linux/build_bug.h> 8 - 9 - /* XX: Figure out how to handle this vma mapping in xe */ 10 - struct intel_remapped_plane_info { 11 - /* in gtt pages */ 12 - u32 offset:31; 13 - u32 linear:1; 14 - union { 15 - /* in gtt pages for !linear */ 16 - struct { 17 - u16 width; 18 - u16 height; 19 - u16 src_stride; 20 - u16 dst_stride; 21 - }; 22 - 23 - /* in gtt pages for linear */ 24 - u32 size; 25 - }; 26 - } __packed; 27 - 28 - struct intel_remapped_info { 29 - struct intel_remapped_plane_info plane[4]; 30 - /* in gtt pages */ 31 - u32 plane_alignment; 32 - } __packed; 33 - 34 - struct intel_rotation_info { 35 - struct intel_remapped_plane_info plane[2]; 36 - } __packed; 37 - 38 - enum i915_gtt_view_type { 39 - I915_GTT_VIEW_NORMAL = 0, 40 - I915_GTT_VIEW_ROTATED = sizeof(struct intel_rotation_info), 41 - I915_GTT_VIEW_REMAPPED = sizeof(struct intel_remapped_info), 42 - }; 43 - 44 - static inline void assert_i915_gem_gtt_types(void) 45 - { 46 - BUILD_BUG_ON(sizeof(struct intel_rotation_info) != 2 * sizeof(u32) + 8 * sizeof(u16)); 47 - BUILD_BUG_ON(sizeof(struct intel_remapped_info) != 5 * sizeof(u32) + 16 * sizeof(u16)); 48 - 49 - /* Check that rotation/remapped shares offsets for simplicity */ 50 - BUILD_BUG_ON(offsetof(struct intel_remapped_info, plane[0]) != 51 - offsetof(struct intel_rotation_info, plane[0])); 52 - BUILD_BUG_ON(offsetofend(struct intel_remapped_info, plane[1]) != 53 - offsetofend(struct intel_rotation_info, plane[1])); 54 - 55 - /* As we encode the size of each branch inside the union into its type, 56 - * we have to be careful that each branch has a unique size. 57 - */ 58 - switch ((enum i915_gtt_view_type)0) { 59 - case I915_GTT_VIEW_NORMAL: 60 - case I915_GTT_VIEW_ROTATED: 61 - case I915_GTT_VIEW_REMAPPED: 62 - /* gcc complains if these are identical cases */ 63 - break; 64 - } 65 - } 66 - 67 - struct i915_gtt_view { 68 - enum i915_gtt_view_type type; 69 - union { 70 - /* Members need to contain no holes/padding */ 71 - struct intel_rotation_info rotated; 72 - struct intel_remapped_info remapped; 73 - }; 74 - };