Skip to content

Commit c66f471

Browse files
mlankhorstrodrigovivi
authored andcommitted
drm/xe: Align all VRAM scanout buffers to 64k physical pages when needed.
For CCS formats on affected platforms, CCS can be used freely, but display engine requires a multiple of 64k physical pages. No other changes are needed. At the BO creation time we don't know if the BO will be used for CCS or not. If the scanout flag is set, and the BO is a multiple of 64k, we take the safe route and force the physical alignment of 64k pages. If the BO is not a multiple of 64k, or the scanout flag was not set at BO creation, we reject it for usage as CCS in display. The physical pages are likely not aligned correctly, and this will cause corruption when used as FB. The scanout flag and size being a multiple of 64k are used together to enforce 64k physical placement. VM_BIND is completely unaffected, mappings to a VM can still be aligned to 4k, just like for normal buffers. Signed-off-by: Zbigniew Kempczyński <[email protected]> Signed-off-by: Maarten Lankhorst <[email protected]> Cc: Matthew Auld <[email protected]> Cc: Rodrigo Vivi <[email protected]> Cc: Thomas Hellström <[email protected]> Cc: Maarten Lankhorst <[email protected]> Cc: Juha-Pekka Heikkilä <[email protected]> Reviewed-by: Rodrigo Vivi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 97c6efb commit c66f471

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

drivers/gpu/drm/xe/display/intel_fb_bo.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <drm/ttm/ttm_bo.h>
88

99
#include "intel_display_types.h"
10+
#include "intel_fb.h"
1011
#include "intel_fb_bo.h"
1112
#include "xe_bo.h"
1213

@@ -28,6 +29,14 @@ int intel_fb_bo_framebuffer_init(struct intel_framebuffer *intel_fb,
2829
struct xe_device *xe = to_xe_device(bo->ttm.base.dev);
2930
int ret;
3031

32+
/*
33+
* Some modifiers require physical alignment of 64KiB VRAM pages;
34+
* require that the BO in those cases is created correctly.
35+
*/
36+
if (XE_IOCTL_DBG(xe, intel_fb_needs_64k_phys(mode_cmd->modifier[0]) &&
37+
!(bo->flags & XE_BO_FLAG_NEEDS_64K)))
38+
return -EINVAL;
39+
3140
xe_bo_get(bo);
3241

3342
ret = ttm_bo_reserve(&bo->ttm, true, false, NULL);

drivers/gpu/drm/xe/xe_bo.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,6 +1990,13 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data,
19901990

19911991
bo_flags |= args->placement << (ffs(XE_BO_FLAG_SYSTEM) - 1);
19921992

1993+
/* CCS formats need physical placement at a 64K alignment in VRAM. */
1994+
if ((bo_flags & XE_BO_FLAG_VRAM_MASK) &&
1995+
(bo_flags & XE_BO_FLAG_SCANOUT) &&
1996+
!(xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K) &&
1997+
IS_ALIGNED(args->size, SZ_64K))
1998+
bo_flags |= XE_BO_FLAG_NEEDS_64K;
1999+
19932000
if (args->flags & DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM) {
19942001
if (XE_IOCTL_DBG(xe, !(bo_flags & XE_BO_FLAG_VRAM_MASK)))
19952002
return -EINVAL;

drivers/gpu/drm/xe/xe_vm.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2905,7 +2905,16 @@ static int xe_vm_bind_ioctl_validate_bo(struct xe_device *xe, struct xe_bo *bo,
29052905
return -EINVAL;
29062906
}
29072907

2908-
if (bo->flags & XE_BO_FLAG_INTERNAL_64K) {
2908+
/*
2909+
* Some platforms require 64k VM_BIND alignment,
2910+
* specifically those with XE_VRAM_FLAGS_NEED64K.
2911+
*
2912+
* Other platforms may have BO's set to 64k physical placement,
2913+
* but can be mapped at 4k offsets anyway. This check is only
2914+
* there for the former case.
2915+
*/
2916+
if ((bo->flags & XE_BO_FLAG_INTERNAL_64K) &&
2917+
(xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K)) {
29092918
if (XE_IOCTL_DBG(xe, obj_offset &
29102919
XE_64K_PAGE_MASK) ||
29112920
XE_IOCTL_DBG(xe, addr & XE_64K_PAGE_MASK) ||

0 commit comments

Comments
 (0)