drm/i915: Introduce the main fb_pin parent interface

Introduce the main part of the new fb_pin parent interface:
- intel_parent_fb_pin_ggtt_(un)pin()
- intel_parent_fb_pin_dpt_(un)pin()
- intel_parent_fb_pin_reuse_vma()

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-14-ville.syrjala@linux.intel.com
This commit is contained in:
Ville Syrjälä
2026-05-08 17:34:23 +03:00
parent 4b17676627
commit f225861a0f
5 changed files with 148 additions and 25 deletions

View File

@@ -53,6 +53,59 @@ void intel_parent_dpt_resume(struct intel_display *display, struct intel_dpt *dp
}
/* fb_pin */
int intel_parent_fb_pin_ggtt_pin(struct intel_display *display,
struct drm_gem_object *obj,
const struct intel_fb_pin_params *pin_params,
struct i915_vma **out_ggtt_vma,
u32 *out_offset,
int *out_fence_id)
{
return display->parent->fb_pin->ggtt_pin(obj, pin_params,
out_ggtt_vma, out_offset, out_fence_id);
}
void intel_parent_fb_pin_ggtt_unpin(struct intel_display *display,
struct i915_vma *ggtt_vma,
int fence_id)
{
return display->parent->fb_pin->ggtt_unpin(ggtt_vma, fence_id);
}
int intel_parent_fb_pin_dpt_pin(struct intel_display *display,
struct drm_gem_object *obj,
struct intel_dpt *dpt,
const struct intel_fb_pin_params *pin_params,
struct i915_vma **out_dpt_vma,
struct i915_vma **out_ggtt_vma,
u32 *out_offset)
{
return display->parent->fb_pin->dpt_pin(obj, dpt, pin_params,
out_dpt_vma, out_ggtt_vma, out_offset);
}
void intel_parent_fb_pin_dpt_unpin(struct intel_display *display,
struct intel_dpt *dpt,
struct i915_vma *dpt_vma,
struct i915_vma *ggtt_vma)
{
return display->parent->fb_pin->dpt_unpin(dpt, dpt_vma, ggtt_vma);
}
struct i915_vma *intel_parent_fb_pin_reuse_vma(struct intel_display *display,
struct i915_vma *old_ggtt_vma,
struct drm_gem_object *old_obj,
const struct i915_gtt_view *old_view,
struct drm_gem_object *new_obj,
const struct i915_gtt_view *new_view,
u32 *out_offset)
{
if (!display->parent->fb_pin->reuse_vma)
return NULL;
return display->parent->fb_pin->reuse_vma(old_ggtt_vma, old_obj, old_view,
new_obj, new_view, out_offset);
}
void intel_parent_fb_pin_get_map(struct intel_display *display,
struct i915_vma *vma, struct iosys_map *map)
{

View File

@@ -11,9 +11,11 @@ struct dma_fence;
struct drm_file;
struct drm_gem_object;
struct drm_scanout_buffer;
struct i915_gtt_view;
struct i915_vma;
struct intel_display;
struct intel_dpt;
struct intel_fb_pin_params;
struct intel_frontbuffer;
struct intel_hdcp_gsc_context;
struct intel_panic;
@@ -28,6 +30,33 @@ void intel_parent_dpt_suspend(struct intel_display *display, struct intel_dpt *d
void intel_parent_dpt_resume(struct intel_display *display, struct intel_dpt *dpt);
/* fb_pin */
int intel_parent_fb_pin_ggtt_pin(struct intel_display *display,
struct drm_gem_object *obj,
const struct intel_fb_pin_params *pin_params,
struct i915_vma **out_ggtt_vma,
u32 *out_offset,
int *out_fence_id);
void intel_parent_fb_pin_ggtt_unpin(struct intel_display *display,
struct i915_vma *ggtt_vma,
int fence_id);
int intel_parent_fb_pin_dpt_pin(struct intel_display *display,
struct drm_gem_object *obj,
struct intel_dpt *dpt,
const struct intel_fb_pin_params *pin_params,
struct i915_vma **out_dpt_vma,
struct i915_vma **out_ggtt_vma,
u32 *out_offset);
void intel_parent_fb_pin_dpt_unpin(struct intel_display *display,
struct intel_dpt *dpt,
struct i915_vma *dpt_vma,
struct i915_vma *ggtt_vma);
struct i915_vma *intel_parent_fb_pin_reuse_vma(struct intel_display *display,
struct i915_vma *old_ggtt_vma,
struct drm_gem_object *old_obj,
const struct i915_gtt_view *old_view,
struct drm_gem_object *new_obj,
const struct i915_gtt_view *new_view,
u32 *out_offset);
void intel_parent_fb_pin_get_map(struct intel_display *display,
struct i915_vma *vma, struct iosys_map *map);

View File

@@ -14,6 +14,7 @@
#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"
@@ -360,9 +361,9 @@ int intel_plane_pin_fb(struct intel_plane_state *plane_state,
.needs_fence = intel_plane_needs_fence(display),
};
ret = i915_fb_pin_ggtt_pin(intel_fb_bo(&fb->base),
&pin_params, &ggtt_vma, &offset,
intel_plane_uses_fence(plane_state) ? &fence_id : NULL);
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 {
@@ -372,9 +373,9 @@ int intel_plane_pin_fb(struct intel_plane_state *plane_state,
.needs_cpu_lmem_access = intel_fb_needs_cpu_access(&fb->base),
};
ret = i915_fb_pin_dpt_pin(intel_fb_bo(&fb->base), fb->dpt,
&pin_params, &dpt_vma,
&ggtt_vma, &offset);
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;
}
@@ -389,19 +390,21 @@ int intel_plane_pin_fb(struct intel_plane_state *plane_state,
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)) {
i915_fb_pin_ggtt_unpin(old_plane_state->ggtt_vma,
old_plane_state->fence_id);
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 {
i915_fb_pin_dpt_unpin(fb->dpt,
old_plane_state->dpt_vma,
old_plane_state->ggtt_vma);
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;
@@ -414,5 +417,9 @@ static void i915_fb_pin_get_map(struct i915_vma *vma, struct iosys_map *map)
}
const struct intel_display_fb_pin_interface i915_display_fb_pin_interface = {
.ggtt_pin = i915_fb_pin_ggtt_pin,
.ggtt_unpin = i915_fb_pin_ggtt_unpin,
.dpt_pin = i915_fb_pin_dpt_pin,
.dpt_unpin = i915_fb_pin_dpt_unpin,
.get_map = i915_fb_pin_get_map,
};

View File

@@ -10,6 +10,7 @@
#include "intel_display_types.h"
#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"
@@ -516,6 +517,7 @@ intel_plane_fb_min_alignment(const struct intel_plane_state *plane_state)
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);
@@ -531,23 +533,25 @@ int intel_plane_pin_fb(struct intel_plane_state *new_plane_state,
u32 offset;
int ret;
ggtt_vma = xe_fb_pin_reuse_vma(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);
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 = xe_fb_pin_ggtt_pin(obj, &pin_params,
&ggtt_vma, &offset, NULL);
ret = intel_parent_fb_pin_ggtt_pin(display, obj, &pin_params,
&ggtt_vma, &offset, NULL);
if (ret)
return ret;
} else {
ret = xe_fb_pin_dpt_pin(obj, fb->dpt, &pin_params,
&dpt_vma, &ggtt_vma, &offset);
ret = intel_parent_fb_pin_dpt_pin(display, obj, fb->dpt,
&pin_params, &dpt_vma,
&ggtt_vma, &offset);
if (ret)
return ret;
}
@@ -563,17 +567,20 @@ int intel_plane_pin_fb(struct intel_plane_state *new_plane_state,
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)) {
xe_fb_pin_ggtt_unpin(old_plane_state->ggtt_vma,
old_plane_state->fence_id);
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 {
xe_fb_pin_dpt_unpin(fb->dpt, old_plane_state->dpt_vma,
old_plane_state->ggtt_vma);
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;
@@ -586,5 +593,10 @@ static void xe_fb_pin_get_map(struct i915_vma *vma, struct iosys_map *map)
}
const struct intel_display_fb_pin_interface xe_display_fb_pin_interface = {
.ggtt_pin = xe_fb_pin_ggtt_pin,
.ggtt_unpin = xe_fb_pin_ggtt_unpin,
.dpt_pin = xe_fb_pin_dpt_pin,
.dpt_unpin = xe_fb_pin_dpt_unpin,
.reuse_vma = xe_fb_pin_reuse_vma,
.get_map = xe_fb_pin_get_map,
};

View File

@@ -83,6 +83,28 @@ struct intel_display_dsb_interface {
};
struct intel_display_fb_pin_interface {
int (*ggtt_pin)(struct drm_gem_object *obj,
const struct intel_fb_pin_params *pin_params,
struct i915_vma **out_ggtt_vma,
u32 *out_offset,
int *out_fence_id);
void (*ggtt_unpin)(struct i915_vma *ggtt_vma,
int fence_id);
int (*dpt_pin)(struct drm_gem_object *obj,
struct intel_dpt *dpt,
const struct intel_fb_pin_params *pin_params,
struct i915_vma **out_dpt_vma,
struct i915_vma **out_ggtt_vma,
u32 *out_offset);
void (*dpt_unpin)(struct intel_dpt *dpt,
struct i915_vma *dpt_vma,
struct i915_vma *ggtt_vma);
struct i915_vma *(*reuse_vma)(struct i915_vma *old_ggtt_vma,
struct drm_gem_object *old_obj,
const struct i915_gtt_view *old_view,
struct drm_gem_object *new_obj,
const struct i915_gtt_view *new_view,
u32 *out_offset);
void (*get_map)(struct i915_vma *vma, struct iosys_map *map);
};