mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-03 21:45:08 -04:00
drm/i915: Constify 'fb' in during pinning
Make the 'fb' pointers const in the pinning code. We never want to mutate these. Also nuke a few aliasing fb vs. intel_fb cases by just using the more specific type everywhere in the same function. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240506125718.26001-7-ville.syrjala@linux.intel.com Reviewed-by: Jani Nikula <jani.nikula@intel.com> Acked-by: Lucas De Marchi <lucas.demarchi@intel.com>
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
#include "intel_fb_pin.h"
|
||||
|
||||
static struct i915_vma *
|
||||
intel_pin_fb_obj_dpt(struct drm_framebuffer *fb,
|
||||
intel_pin_fb_obj_dpt(const struct drm_framebuffer *fb,
|
||||
const struct i915_gtt_view *view,
|
||||
unsigned int alignment,
|
||||
unsigned long *out_flags,
|
||||
@@ -102,7 +102,7 @@ intel_pin_fb_obj_dpt(struct drm_framebuffer *fb,
|
||||
}
|
||||
|
||||
struct i915_vma *
|
||||
intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
|
||||
intel_pin_and_fence_fb_obj(const struct drm_framebuffer *fb,
|
||||
bool phys_cursor,
|
||||
const struct i915_gtt_view *view,
|
||||
bool uses_fence,
|
||||
@@ -237,11 +237,12 @@ void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags)
|
||||
int intel_plane_pin_fb(struct intel_plane_state *plane_state)
|
||||
{
|
||||
struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
|
||||
struct drm_framebuffer *fb = plane_state->hw.fb;
|
||||
const struct intel_framebuffer *fb =
|
||||
to_intel_framebuffer(plane_state->hw.fb);
|
||||
struct i915_vma *vma;
|
||||
|
||||
if (!intel_fb_uses_dpt(fb)) {
|
||||
vma = intel_pin_and_fence_fb_obj(fb, intel_plane_needs_physical(plane),
|
||||
if (!intel_fb_uses_dpt(&fb->base)) {
|
||||
vma = intel_pin_and_fence_fb_obj(&fb->base, intel_plane_needs_physical(plane),
|
||||
&plane_state->view.gtt,
|
||||
intel_plane_uses_fence(plane_state),
|
||||
&plane_state->flags);
|
||||
@@ -258,22 +259,21 @@ int intel_plane_pin_fb(struct intel_plane_state *plane_state)
|
||||
*/
|
||||
if (intel_plane_needs_physical(plane))
|
||||
plane_state->phys_dma_addr =
|
||||
i915_gem_object_get_dma_address(intel_fb_obj(fb), 0);
|
||||
i915_gem_object_get_dma_address(intel_fb_obj(&fb->base), 0);
|
||||
} else {
|
||||
struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
|
||||
unsigned int alignment = intel_surf_alignment(fb, 0);
|
||||
unsigned int alignment = intel_surf_alignment(&fb->base, 0);
|
||||
|
||||
vma = intel_dpt_pin(intel_fb->dpt_vm, alignment / 512);
|
||||
vma = intel_dpt_pin(fb->dpt_vm, alignment / 512);
|
||||
if (IS_ERR(vma))
|
||||
return PTR_ERR(vma);
|
||||
|
||||
plane_state->ggtt_vma = vma;
|
||||
|
||||
vma = intel_pin_fb_obj_dpt(fb, &plane_state->view.gtt,
|
||||
vma = intel_pin_fb_obj_dpt(&fb->base, &plane_state->view.gtt,
|
||||
alignment, &plane_state->flags,
|
||||
intel_fb->dpt_vm);
|
||||
fb->dpt_vm);
|
||||
if (IS_ERR(vma)) {
|
||||
intel_dpt_unpin(intel_fb->dpt_vm);
|
||||
intel_dpt_unpin(fb->dpt_vm);
|
||||
plane_state->ggtt_vma = NULL;
|
||||
return PTR_ERR(vma);
|
||||
}
|
||||
@@ -288,22 +288,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 drm_framebuffer *fb = old_plane_state->hw.fb;
|
||||
const struct intel_framebuffer *fb =
|
||||
to_intel_framebuffer(old_plane_state->hw.fb);
|
||||
struct i915_vma *vma;
|
||||
|
||||
if (!intel_fb_uses_dpt(fb)) {
|
||||
if (!intel_fb_uses_dpt(&fb->base)) {
|
||||
vma = fetch_and_zero(&old_plane_state->ggtt_vma);
|
||||
if (vma)
|
||||
intel_unpin_fb_vma(vma, old_plane_state->flags);
|
||||
} else {
|
||||
struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
|
||||
|
||||
vma = fetch_and_zero(&old_plane_state->dpt_vma);
|
||||
if (vma)
|
||||
intel_unpin_fb_vma(vma, old_plane_state->flags);
|
||||
|
||||
vma = fetch_and_zero(&old_plane_state->ggtt_vma);
|
||||
if (vma)
|
||||
intel_dpt_unpin(intel_fb->dpt_vm);
|
||||
intel_dpt_unpin(fb->dpt_vm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ struct intel_plane_state;
|
||||
struct i915_gtt_view;
|
||||
|
||||
struct i915_vma *
|
||||
intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
|
||||
intel_pin_and_fence_fb_obj(const struct drm_framebuffer *fb,
|
||||
bool phys_cursor,
|
||||
const struct i915_gtt_view *view,
|
||||
bool uses_fence,
|
||||
|
||||
@@ -77,7 +77,7 @@ write_dpt_remapped(struct xe_bo *bo, struct iosys_map *map, u32 *dpt_ofs,
|
||||
*dpt_ofs = ALIGN(*dpt_ofs, 4096);
|
||||
}
|
||||
|
||||
static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
|
||||
static int __xe_pin_fb_vma_dpt(const struct intel_framebuffer *fb,
|
||||
const struct i915_gtt_view *view,
|
||||
struct i915_vma *vma)
|
||||
{
|
||||
@@ -181,7 +181,7 @@ write_ggtt_rotated(struct xe_bo *bo, struct xe_ggtt *ggtt, u32 *ggtt_ofs, u32 bo
|
||||
}
|
||||
}
|
||||
|
||||
static int __xe_pin_fb_vma_ggtt(struct intel_framebuffer *fb,
|
||||
static int __xe_pin_fb_vma_ggtt(const struct intel_framebuffer *fb,
|
||||
const struct i915_gtt_view *view,
|
||||
struct i915_vma *vma)
|
||||
{
|
||||
@@ -249,7 +249,7 @@ static int __xe_pin_fb_vma_ggtt(struct intel_framebuffer *fb,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct i915_vma *__xe_pin_fb_vma(struct intel_framebuffer *fb,
|
||||
static struct i915_vma *__xe_pin_fb_vma(const struct intel_framebuffer *fb,
|
||||
const struct i915_gtt_view *view)
|
||||
{
|
||||
struct drm_device *dev = fb->base.dev;
|
||||
@@ -333,7 +333,7 @@ static void __xe_unpin_fb_vma(struct i915_vma *vma)
|
||||
}
|
||||
|
||||
struct i915_vma *
|
||||
intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
|
||||
intel_pin_and_fence_fb_obj(const struct drm_framebuffer *fb,
|
||||
bool phys_cursor,
|
||||
const struct i915_gtt_view *view,
|
||||
bool uses_fence,
|
||||
|
||||
Reference in New Issue
Block a user