mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
drm/i915: Consolidate the intel_plane_(un)pin_fb() implementations
Currently i915 and xe each implement their own versions of intel_plane_(un)pin(). Now that we have the fb_pin parent interface we can consolidate this to a single implementation. The result is a mixture of the i915 and xe implementations. The reuse_vma() hack comes from xe (and i915 doesn't implement that part of the parent interface, and the pin_params are taken from i915 since the platforms supported by i915 need more things. Reviewed-by: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patch.msgid.link/20260508143426.26504-17-ville.syrjala@linux.intel.com
This commit is contained in:
parent
37744ae79b
commit
24c100b8ed
|
|
@ -21,7 +21,6 @@
|
|||
#include "intel_display_utils.h"
|
||||
#include "intel_display_wa.h"
|
||||
#include "intel_fb.h"
|
||||
#include "intel_fb_pin.h"
|
||||
#include "intel_frontbuffer.h"
|
||||
#include "intel_plane.h"
|
||||
#include "intel_psr.h"
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
/* SPDX-License-Identifier: MIT */
|
||||
/*
|
||||
* Copyright © 2021 Intel Corporation
|
||||
*/
|
||||
|
||||
#ifndef __INTEL_FB_PIN_H__
|
||||
#define __INTEL_FB_PIN_H__
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
struct drm_gem_object;
|
||||
struct i915_vma;
|
||||
struct intel_fb_pin_params;
|
||||
struct intel_plane_state;
|
||||
struct i915_gtt_view;
|
||||
struct iosys_map;
|
||||
|
||||
struct i915_vma *
|
||||
intel_fb_pin_to_ggtt(struct drm_gem_object *obj,
|
||||
const struct intel_fb_pin_params *pin_params,
|
||||
int *out_fence_id);
|
||||
|
||||
int intel_plane_pin_fb(struct intel_plane_state *new_plane_state,
|
||||
const struct intel_plane_state *old_plane_state);
|
||||
void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state);
|
||||
|
||||
#endif
|
||||
|
|
@ -44,6 +44,7 @@
|
|||
#include <drm/drm_gem_atomic_helper.h>
|
||||
#include <drm/drm_panic.h>
|
||||
#include <drm/drm_print.h>
|
||||
#include <drm/intel/display_parent_interface.h>
|
||||
|
||||
#include "i9xx_plane_regs.h"
|
||||
#include "intel_cdclk.h"
|
||||
|
|
@ -53,7 +54,6 @@
|
|||
#include "intel_display_trace.h"
|
||||
#include "intel_display_types.h"
|
||||
#include "intel_fb.h"
|
||||
#include "intel_fb_pin.h"
|
||||
#include "intel_fbdev.h"
|
||||
#include "intel_parent.h"
|
||||
#include "intel_plane.h"
|
||||
|
|
@ -1191,6 +1191,122 @@ int intel_plane_check_src_coordinates(struct intel_plane_state *plane_state)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
intel_plane_fb_min_alignment(const struct intel_plane_state *plane_state)
|
||||
{
|
||||
const struct intel_framebuffer *fb = to_intel_framebuffer(plane_state->hw.fb);
|
||||
|
||||
return fb->min_alignment;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
intel_plane_fb_min_phys_alignment(const struct intel_plane_state *plane_state)
|
||||
{
|
||||
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
|
||||
const struct drm_framebuffer *fb = plane_state->hw.fb;
|
||||
|
||||
if (!intel_plane_needs_physical(plane))
|
||||
return 0;
|
||||
|
||||
return plane->min_alignment(plane, fb, 0);
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
intel_plane_fb_vtd_guard(const struct intel_plane_state *plane_state)
|
||||
{
|
||||
return intel_fb_view_vtd_guard(plane_state->hw.fb,
|
||||
&plane_state->view,
|
||||
plane_state->hw.rotation);
|
||||
}
|
||||
|
||||
int intel_plane_pin_fb(struct intel_plane_state *plane_state,
|
||||
const struct intel_plane_state *old_plane_state)
|
||||
{
|
||||
struct intel_display *display = to_intel_display(plane_state);
|
||||
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
|
||||
const struct intel_framebuffer *fb =
|
||||
to_intel_framebuffer(plane_state->hw.fb);
|
||||
const struct intel_framebuffer *old_fb =
|
||||
to_intel_framebuffer(old_plane_state->hw.fb);
|
||||
struct i915_vma *ggtt_vma = NULL;
|
||||
struct i915_vma *dpt_vma = NULL;
|
||||
int fence_id = -1;
|
||||
u32 offset = 0;
|
||||
int ret;
|
||||
|
||||
/* hack for xe since it can't keep track of vmas properly */
|
||||
ggtt_vma = intel_parent_fb_pin_reuse_vma(display,
|
||||
old_plane_state->ggtt_vma,
|
||||
intel_fb_bo(&old_fb->base),
|
||||
&old_plane_state->view.gtt,
|
||||
intel_fb_bo(&fb->base),
|
||||
&plane_state->view.gtt,
|
||||
&offset);
|
||||
if (ggtt_vma)
|
||||
goto got_vma;
|
||||
|
||||
if (!intel_fb_uses_dpt(&fb->base)) {
|
||||
struct intel_fb_pin_params pin_params = {
|
||||
.view = &plane_state->view.gtt,
|
||||
.alignment = intel_plane_fb_min_alignment(plane_state),
|
||||
.phys_alignment = intel_plane_fb_min_phys_alignment(plane_state),
|
||||
.vtd_guard = intel_plane_fb_vtd_guard(plane_state),
|
||||
.needs_cpu_lmem_access = intel_fb_needs_cpu_access(&fb->base),
|
||||
.needs_low_address = intel_plane_needs_low_address(display),
|
||||
.needs_physical = intel_plane_needs_physical(plane),
|
||||
.needs_fence = intel_plane_needs_fence(display),
|
||||
};
|
||||
|
||||
ret = intel_parent_fb_pin_ggtt_pin(display, intel_fb_bo(&fb->base),
|
||||
&pin_params, &ggtt_vma, &offset,
|
||||
intel_plane_uses_fence(plane_state) ? &fence_id : NULL);
|
||||
} else {
|
||||
struct intel_fb_pin_params pin_params = {
|
||||
.view = &plane_state->view.gtt,
|
||||
.alignment = intel_plane_fb_min_alignment(plane_state),
|
||||
.needs_cpu_lmem_access = intel_fb_needs_cpu_access(&fb->base),
|
||||
};
|
||||
|
||||
ret = intel_parent_fb_pin_dpt_pin(display, intel_fb_bo(&fb->base),
|
||||
fb->dpt, &pin_params,
|
||||
&dpt_vma, &ggtt_vma, &offset);
|
||||
}
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
got_vma:
|
||||
plane_state->dpt_vma = dpt_vma;
|
||||
plane_state->ggtt_vma = ggtt_vma;
|
||||
plane_state->fence_id = fence_id;
|
||||
|
||||
plane_state->surf = offset + plane->surf_offset(plane_state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state)
|
||||
{
|
||||
struct intel_display *display = to_intel_display(old_plane_state);
|
||||
const struct intel_framebuffer *fb =
|
||||
to_intel_framebuffer(old_plane_state->hw.fb);
|
||||
|
||||
if (!intel_fb_uses_dpt(&fb->base)) {
|
||||
intel_parent_fb_pin_ggtt_unpin(display,
|
||||
old_plane_state->ggtt_vma,
|
||||
old_plane_state->fence_id);
|
||||
|
||||
old_plane_state->ggtt_vma = NULL;
|
||||
old_plane_state->fence_id = -1;
|
||||
} else {
|
||||
intel_parent_fb_pin_dpt_unpin(display, fb->dpt,
|
||||
old_plane_state->dpt_vma,
|
||||
old_plane_state->ggtt_vma);
|
||||
|
||||
old_plane_state->dpt_vma = NULL;
|
||||
old_plane_state->ggtt_vma = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int add_dma_resv_fences(struct dma_resv *resv,
|
||||
struct drm_plane_state *new_plane_state)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -92,5 +92,8 @@ int intel_plane_atomic_check(struct intel_atomic_state *state);
|
|||
bool intel_plane_format_mod_supported_async(struct drm_plane *plane,
|
||||
u32 format,
|
||||
u64 modifier);
|
||||
int intel_plane_pin_fb(struct intel_plane_state *new_plane_state,
|
||||
const struct intel_plane_state *old_plane_state);
|
||||
void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state);
|
||||
|
||||
#endif /* __INTEL_PLANE_H__ */
|
||||
|
|
|
|||
|
|
@ -3,20 +3,9 @@
|
|||
* Copyright © 2021 Intel Corporation
|
||||
*/
|
||||
|
||||
/**
|
||||
* DOC: display pinning helpers
|
||||
*/
|
||||
|
||||
#include <drm/drm_print.h>
|
||||
#include <drm/intel/display_parent_interface.h>
|
||||
|
||||
#include "display/intel_display_core.h"
|
||||
#include "display/intel_display_types.h"
|
||||
#include "display/intel_fb.h"
|
||||
#include "display/intel_fb_pin.h"
|
||||
#include "display/intel_parent.h"
|
||||
#include "display/intel_plane.h"
|
||||
|
||||
#include "gem/i915_gem_domain.h"
|
||||
#include "gem/i915_gem_object.h"
|
||||
|
||||
|
|
@ -114,7 +103,7 @@ intel_fb_pin_to_dpt(struct drm_gem_object *_obj, struct intel_dpt *dpt,
|
|||
return vma;
|
||||
}
|
||||
|
||||
struct i915_vma *
|
||||
static struct i915_vma *
|
||||
intel_fb_pin_to_ggtt(struct drm_gem_object *_obj,
|
||||
const struct intel_fb_pin_params *pin_params,
|
||||
int *out_fence_id)
|
||||
|
|
@ -230,34 +219,6 @@ static void intel_fb_unpin_vma(struct i915_vma *vma, int fence_id)
|
|||
i915_vma_put(vma);
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
intel_plane_fb_min_alignment(const struct intel_plane_state *plane_state)
|
||||
{
|
||||
const struct intel_framebuffer *fb = to_intel_framebuffer(plane_state->hw.fb);
|
||||
|
||||
return fb->min_alignment;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
intel_plane_fb_min_phys_alignment(const struct intel_plane_state *plane_state)
|
||||
{
|
||||
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
|
||||
const struct drm_framebuffer *fb = plane_state->hw.fb;
|
||||
|
||||
if (!intel_plane_needs_physical(plane))
|
||||
return 0;
|
||||
|
||||
return plane->min_alignment(plane, fb, 0);
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
intel_plane_fb_vtd_guard(const struct intel_plane_state *plane_state)
|
||||
{
|
||||
return intel_fb_view_vtd_guard(plane_state->hw.fb,
|
||||
&plane_state->view,
|
||||
plane_state->hw.rotation);
|
||||
}
|
||||
|
||||
static int i915_fb_pin_ggtt_pin(struct drm_gem_object *obj,
|
||||
const struct intel_fb_pin_params *pin_params,
|
||||
struct i915_vma **out_ggtt_vma,
|
||||
|
|
@ -336,81 +297,6 @@ static void i915_fb_pin_dpt_unpin(struct intel_dpt *dpt,
|
|||
i915_dpt_unpin_from_ggtt(dpt);
|
||||
}
|
||||
|
||||
int intel_plane_pin_fb(struct intel_plane_state *plane_state,
|
||||
const struct intel_plane_state *old_plane_state)
|
||||
{
|
||||
struct intel_display *display = to_intel_display(plane_state);
|
||||
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
|
||||
const struct intel_framebuffer *fb =
|
||||
to_intel_framebuffer(plane_state->hw.fb);
|
||||
struct i915_vma *ggtt_vma = NULL;
|
||||
struct i915_vma *dpt_vma = NULL;
|
||||
int fence_id = -1;
|
||||
u32 offset;
|
||||
int ret;
|
||||
|
||||
if (!intel_fb_uses_dpt(&fb->base)) {
|
||||
struct intel_fb_pin_params pin_params = {
|
||||
.view = &plane_state->view.gtt,
|
||||
.alignment = intel_plane_fb_min_alignment(plane_state),
|
||||
.phys_alignment = intel_plane_fb_min_phys_alignment(plane_state),
|
||||
.vtd_guard = intel_plane_fb_vtd_guard(plane_state),
|
||||
.needs_cpu_lmem_access = intel_fb_needs_cpu_access(&fb->base),
|
||||
.needs_low_address = intel_plane_needs_low_address(display),
|
||||
.needs_physical = intel_plane_needs_physical(plane),
|
||||
.needs_fence = intel_plane_needs_fence(display),
|
||||
};
|
||||
|
||||
ret = intel_parent_fb_pin_ggtt_pin(display, intel_fb_bo(&fb->base),
|
||||
&pin_params, &ggtt_vma, &offset,
|
||||
intel_plane_uses_fence(plane_state) ? &fence_id : NULL);
|
||||
if (ret)
|
||||
return ret;
|
||||
} else {
|
||||
struct intel_fb_pin_params pin_params = {
|
||||
.view = &plane_state->view.gtt,
|
||||
.alignment = intel_plane_fb_min_alignment(plane_state),
|
||||
.needs_cpu_lmem_access = intel_fb_needs_cpu_access(&fb->base),
|
||||
};
|
||||
|
||||
ret = intel_parent_fb_pin_dpt_pin(display, intel_fb_bo(&fb->base),
|
||||
fb->dpt, &pin_params,
|
||||
&dpt_vma, &ggtt_vma, &offset);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
plane_state->dpt_vma = dpt_vma;
|
||||
plane_state->ggtt_vma = ggtt_vma;
|
||||
plane_state->fence_id = fence_id;
|
||||
plane_state->surf = offset + plane->surf_offset(plane_state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state)
|
||||
{
|
||||
struct intel_display *display = to_intel_display(old_plane_state);
|
||||
const struct intel_framebuffer *fb =
|
||||
to_intel_framebuffer(old_plane_state->hw.fb);
|
||||
|
||||
if (!intel_fb_uses_dpt(&fb->base)) {
|
||||
intel_parent_fb_pin_ggtt_unpin(display,
|
||||
old_plane_state->ggtt_vma,
|
||||
old_plane_state->fence_id);
|
||||
|
||||
old_plane_state->ggtt_vma = NULL;
|
||||
old_plane_state->fence_id = -1;
|
||||
} else {
|
||||
intel_parent_fb_pin_dpt_unpin(display, fb->dpt,
|
||||
old_plane_state->dpt_vma,
|
||||
old_plane_state->ggtt_vma);
|
||||
|
||||
old_plane_state->dpt_vma = NULL;
|
||||
old_plane_state->ggtt_vma = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void i915_fb_pin_get_map(struct i915_vma *vma, struct iosys_map *map)
|
||||
{
|
||||
iosys_map_set_vaddr_iomem(map, i915_vma_get_iomap(vma));
|
||||
|
|
|
|||
|
|
@ -6,11 +6,12 @@
|
|||
#include <drm/intel/display_parent_interface.h>
|
||||
#include <drm/ttm/ttm_bo.h>
|
||||
|
||||
#include "intel_display_core.h"
|
||||
#include "intel_display_types.h"
|
||||
/* FIXME move the types to parent interface? */
|
||||
#include "i915_gtt_view_types.h"
|
||||
|
||||
/* FIXME move intel_remapped_info_size() & co. to parent interface? */
|
||||
#include "intel_fb.h"
|
||||
#include "intel_fb_pin.h"
|
||||
#include "intel_parent.h"
|
||||
|
||||
#include "xe_bo.h"
|
||||
#include "xe_device.h"
|
||||
#include "xe_display_vma.h"
|
||||
|
|
@ -490,87 +491,6 @@ xe_fb_pin_reuse_vma(struct i915_vma *old_ggtt_vma,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
intel_plane_fb_min_alignment(const struct intel_plane_state *plane_state)
|
||||
{
|
||||
const struct intel_framebuffer *fb = to_intel_framebuffer(plane_state->hw.fb);
|
||||
|
||||
return fb->min_alignment;
|
||||
}
|
||||
|
||||
int intel_plane_pin_fb(struct intel_plane_state *new_plane_state,
|
||||
const struct intel_plane_state *old_plane_state)
|
||||
{
|
||||
struct intel_display *display = to_intel_display(new_plane_state);
|
||||
const struct intel_framebuffer *fb = to_intel_framebuffer(new_plane_state->hw.fb);
|
||||
const struct intel_framebuffer *old_fb = to_intel_framebuffer(old_plane_state->hw.fb);
|
||||
struct drm_gem_object *obj = intel_fb_bo(&fb->base);
|
||||
struct intel_plane *plane = to_intel_plane(new_plane_state->uapi.plane);
|
||||
struct intel_fb_pin_params pin_params = {
|
||||
.view = &new_plane_state->view.gtt,
|
||||
.alignment = intel_plane_fb_min_alignment(new_plane_state),
|
||||
.needs_cpu_lmem_access = intel_fb_needs_cpu_access(&fb->base),
|
||||
};
|
||||
struct i915_vma *ggtt_vma = NULL;
|
||||
struct i915_vma *dpt_vma = NULL;
|
||||
int fence_id = -1;
|
||||
u32 offset;
|
||||
int ret;
|
||||
|
||||
ggtt_vma = intel_parent_fb_pin_reuse_vma(display,
|
||||
old_plane_state->ggtt_vma,
|
||||
intel_fb_bo(&old_fb->base),
|
||||
&old_plane_state->view.gtt,
|
||||
intel_fb_bo(&fb->base),
|
||||
&new_plane_state->view.gtt,
|
||||
&offset);
|
||||
if (ggtt_vma)
|
||||
goto got_vma;
|
||||
|
||||
if (!intel_fb_uses_dpt(&fb->base)) {
|
||||
ret = intel_parent_fb_pin_ggtt_pin(display, obj, &pin_params,
|
||||
&ggtt_vma, &offset, NULL);
|
||||
if (ret)
|
||||
return ret;
|
||||
} else {
|
||||
ret = intel_parent_fb_pin_dpt_pin(display, obj, fb->dpt,
|
||||
&pin_params, &dpt_vma,
|
||||
&ggtt_vma, &offset);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
got_vma:
|
||||
new_plane_state->dpt_vma = dpt_vma;
|
||||
new_plane_state->ggtt_vma = ggtt_vma;
|
||||
new_plane_state->fence_id = fence_id;
|
||||
new_plane_state->surf = offset + plane->surf_offset(new_plane_state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state)
|
||||
{
|
||||
struct intel_display *display = to_intel_display(old_plane_state);
|
||||
const struct intel_framebuffer *fb = to_intel_framebuffer(old_plane_state->hw.fb);
|
||||
|
||||
if (!intel_fb_uses_dpt(&fb->base)) {
|
||||
intel_parent_fb_pin_ggtt_unpin(display,
|
||||
old_plane_state->ggtt_vma,
|
||||
old_plane_state->fence_id);
|
||||
|
||||
old_plane_state->ggtt_vma = NULL;
|
||||
old_plane_state->fence_id = -1;
|
||||
} else {
|
||||
intel_parent_fb_pin_dpt_unpin(display, fb->dpt,
|
||||
old_plane_state->dpt_vma,
|
||||
old_plane_state->ggtt_vma);
|
||||
|
||||
old_plane_state->dpt_vma = NULL;
|
||||
old_plane_state->ggtt_vma = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void xe_fb_pin_get_map(struct i915_vma *vma, struct iosys_map *map)
|
||||
{
|
||||
*map = vma->bo->vmap;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user