Skip to content

Commit b0228a3

Browse files
juhapekkamkahola
authored andcommitted
drm/xe/display: align framebuffers according to hw requirements
Align framebuffers in memory according to hw requirements instead of default page size alignment. Signed-off-by: Juha-Pekka Heikkila <[email protected]> Reviewed-by: Jonathan Cavitt <[email protected]> Signed-off-by: Mika Kahola <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 3ad86ae commit b0228a3

File tree

1 file changed

+35
-22
lines changed

1 file changed

+35
-22
lines changed

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

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ write_dpt_remapped(struct xe_bo *bo, struct iosys_map *map, u32 *dpt_ofs,
7979

8080
static int __xe_pin_fb_vma_dpt(const struct intel_framebuffer *fb,
8181
const struct i915_gtt_view *view,
82-
struct i915_vma *vma)
82+
struct i915_vma *vma,
83+
u64 physical_alignment)
8384
{
8485
struct xe_device *xe = to_xe_device(fb->base.dev);
8586
struct xe_tile *tile0 = xe_device_get_root_tile(xe);
@@ -98,23 +99,29 @@ static int __xe_pin_fb_vma_dpt(const struct intel_framebuffer *fb,
9899
XE_PAGE_SIZE);
99100

100101
if (IS_DGFX(xe))
101-
dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
102-
ttm_bo_type_kernel,
103-
XE_BO_FLAG_VRAM0 |
104-
XE_BO_FLAG_GGTT |
105-
XE_BO_FLAG_PAGETABLE);
102+
dpt = xe_bo_create_pin_map_at_aligned(xe, tile0, NULL,
103+
dpt_size, ~0ull,
104+
ttm_bo_type_kernel,
105+
XE_BO_FLAG_VRAM0 |
106+
XE_BO_FLAG_GGTT |
107+
XE_BO_FLAG_PAGETABLE,
108+
physical_alignment);
106109
else
107-
dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
108-
ttm_bo_type_kernel,
109-
XE_BO_FLAG_STOLEN |
110-
XE_BO_FLAG_GGTT |
111-
XE_BO_FLAG_PAGETABLE);
110+
dpt = xe_bo_create_pin_map_at_aligned(xe, tile0, NULL,
111+
dpt_size, ~0ull,
112+
ttm_bo_type_kernel,
113+
XE_BO_FLAG_STOLEN |
114+
XE_BO_FLAG_GGTT |
115+
XE_BO_FLAG_PAGETABLE,
116+
physical_alignment);
112117
if (IS_ERR(dpt))
113-
dpt = xe_bo_create_pin_map(xe, tile0, NULL, dpt_size,
114-
ttm_bo_type_kernel,
115-
XE_BO_FLAG_SYSTEM |
116-
XE_BO_FLAG_GGTT |
117-
XE_BO_FLAG_PAGETABLE);
118+
dpt = xe_bo_create_pin_map_at_aligned(xe, tile0, NULL,
119+
dpt_size, ~0ull,
120+
ttm_bo_type_kernel,
121+
XE_BO_FLAG_SYSTEM |
122+
XE_BO_FLAG_GGTT |
123+
XE_BO_FLAG_PAGETABLE,
124+
physical_alignment);
118125
if (IS_ERR(dpt))
119126
return PTR_ERR(dpt);
120127

@@ -183,7 +190,8 @@ write_ggtt_rotated(struct xe_bo *bo, struct xe_ggtt *ggtt, u32 *ggtt_ofs, u32 bo
183190

184191
static int __xe_pin_fb_vma_ggtt(const struct intel_framebuffer *fb,
185192
const struct i915_gtt_view *view,
186-
struct i915_vma *vma)
193+
struct i915_vma *vma,
194+
u64 physical_alignment)
187195
{
188196
struct xe_bo *bo = intel_fb_obj(&fb->base);
189197
struct xe_device *xe = to_xe_device(fb->base.dev);
@@ -264,7 +272,8 @@ static int __xe_pin_fb_vma_ggtt(const struct intel_framebuffer *fb,
264272
}
265273

266274
static struct i915_vma *__xe_pin_fb_vma(const struct intel_framebuffer *fb,
267-
const struct i915_gtt_view *view)
275+
const struct i915_gtt_view *view,
276+
u64 physical_alignment)
268277
{
269278
struct drm_device *dev = fb->base.dev;
270279
struct xe_device *xe = to_xe_device(dev);
@@ -312,9 +321,9 @@ static struct i915_vma *__xe_pin_fb_vma(const struct intel_framebuffer *fb,
312321

313322
vma->bo = bo;
314323
if (intel_fb_uses_dpt(&fb->base))
315-
ret = __xe_pin_fb_vma_dpt(fb, view, vma);
324+
ret = __xe_pin_fb_vma_dpt(fb, view, vma, physical_alignment);
316325
else
317-
ret = __xe_pin_fb_vma_ggtt(fb, view, vma);
326+
ret = __xe_pin_fb_vma_ggtt(fb, view, vma, physical_alignment);
318327
if (ret)
319328
goto err_unpin;
320329

@@ -355,7 +364,7 @@ intel_fb_pin_to_ggtt(const struct drm_framebuffer *fb,
355364
{
356365
*out_flags = 0;
357366

358-
return __xe_pin_fb_vma(to_intel_framebuffer(fb), view);
367+
return __xe_pin_fb_vma(to_intel_framebuffer(fb), view, phys_alignment);
359368
}
360369

361370
void intel_fb_unpin_vma(struct i915_vma *vma, unsigned long flags)
@@ -368,11 +377,15 @@ int intel_plane_pin_fb(struct intel_plane_state *plane_state)
368377
struct drm_framebuffer *fb = plane_state->hw.fb;
369378
struct xe_bo *bo = intel_fb_obj(fb);
370379
struct i915_vma *vma;
380+
struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
381+
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
382+
u64 phys_alignment = plane->min_alignment(plane, fb, 0);
371383

372384
/* We reject creating !SCANOUT fb's, so this is weird.. */
373385
drm_WARN_ON(bo->ttm.base.dev, !(bo->flags & XE_BO_FLAG_SCANOUT));
374386

375-
vma = __xe_pin_fb_vma(to_intel_framebuffer(fb), &plane_state->view.gtt);
387+
vma = __xe_pin_fb_vma(intel_fb, &plane_state->view.gtt, phys_alignment);
388+
376389
if (IS_ERR(vma))
377390
return PTR_ERR(vma);
378391

0 commit comments

Comments
 (0)