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

drm/xe/display: Xe stolen memory handling for fbc support

Add Xe stolen memory handling for fbc.

v3:
- v2: Add parenthesis around parameter in i915_gem_stolen_node_allocated
v2:
- define i915_gem_stolen_area_address/size as !WARN_ON(1)
- squash common type addition into this patch

Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

authored by

Jouni Högander and committed by
Rodrigo Vivi
c5a2eadd c3744ceb

+80
+1
drivers/gpu/drm/xe/compat-i915-headers/i915_drv.h
··· 19 19 #include "xe_bo.h" 20 20 #include "xe_pm.h" 21 21 #include "xe_step.h" 22 + #include "i915_gem_stolen.h" 22 23 #include "i915_gpu_error.h" 23 24 #include "i915_reg_defs.h" 24 25 #include "i915_utils.h"
+79
drivers/gpu/drm/xe/compat-i915-headers/i915_gem_stolen.h
··· 1 + #ifndef _I915_GEM_STOLEN_H_ 2 + #define _I915_GEM_STOLEN_H_ 3 + 4 + #include "xe_ttm_stolen_mgr.h" 5 + #include "xe_res_cursor.h" 6 + 7 + struct xe_bo; 8 + 9 + struct i915_stolen_fb { 10 + struct xe_bo *bo; 11 + }; 12 + 13 + static inline int i915_gem_stolen_insert_node_in_range(struct xe_device *xe, 14 + struct i915_stolen_fb *fb, 15 + u32 size, u32 align, 16 + u32 start, u32 end) 17 + { 18 + struct xe_bo *bo; 19 + int err; 20 + u32 flags = XE_BO_CREATE_PINNED_BIT | XE_BO_CREATE_STOLEN_BIT; 21 + 22 + bo = xe_bo_create_locked_range(xe, xe_device_get_root_tile(xe), 23 + NULL, size, start, end, 24 + ttm_bo_type_kernel, flags); 25 + if (IS_ERR(bo)) { 26 + err = PTR_ERR(bo); 27 + bo = NULL; 28 + return err; 29 + } 30 + err = xe_bo_pin(bo); 31 + xe_bo_unlock_vm_held(bo); 32 + 33 + if (err) { 34 + xe_bo_put(fb->bo); 35 + bo = NULL; 36 + } 37 + 38 + fb->bo = bo; 39 + 40 + return err; 41 + } 42 + 43 + static inline int i915_gem_stolen_insert_node(struct xe_device *xe, 44 + struct i915_stolen_fb *fb, 45 + u32 size, u32 align) 46 + { 47 + /* Not used on xe */ 48 + BUG_ON(1); 49 + return -ENODEV; 50 + } 51 + 52 + static inline void i915_gem_stolen_remove_node(struct xe_device *xe, 53 + struct i915_stolen_fb *fb) 54 + { 55 + xe_bo_unpin_map_no_vm(fb->bo); 56 + fb->bo = NULL; 57 + } 58 + 59 + #define i915_gem_stolen_initialized(xe) (!!ttm_manager_type(&(xe)->ttm, XE_PL_STOLEN)) 60 + #define i915_gem_stolen_node_allocated(fb) (!!((fb)->bo)) 61 + 62 + static inline u32 i915_gem_stolen_node_offset(struct i915_stolen_fb *fb) 63 + { 64 + struct xe_res_cursor res; 65 + 66 + xe_res_first(fb->bo->ttm.resource, 0, 4096, &res); 67 + return res.start; 68 + } 69 + 70 + /* Used for < gen4. These are not supported by Xe */ 71 + #define i915_gem_stolen_area_address(xe) (!WARN_ON(1)) 72 + /* Used for gen9 specific WA. Gen9 is not supported by Xe */ 73 + #define i915_gem_stolen_area_size(xe) (!WARN_ON(1)) 74 + 75 + #define i915_gem_stolen_node_address(xe, fb) (xe_ttm_stolen_gpu_offset(xe) + \ 76 + i915_gem_stolen_node_offset(fb)) 77 + #define i915_gem_stolen_node_size(fb) ((u64)((fb)->bo->ttm.base.size)) 78 + 79 + #endif