Re: [PATCH 6/9] drm/i915: Constify 'fb' in during pinning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 06 May 2024, Ville Syrjala <ville.syrjala@xxxxxxxxxxxxxxx> wrote:
> From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
>
> 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.

I was half expecting to see further changes switching interfaces to
intel_framebuffer instead of passing &fb->base around. But this is good
regardless.

Reviewed-by: Jani Nikula <jani.nikula@xxxxxxxxx>


>
> Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
> ---
>  drivers/gpu/drm/i915/display/intel_fb_pin.c | 33 ++++++++++-----------
>  drivers/gpu/drm/i915/display/intel_fb_pin.h |  2 +-
>  drivers/gpu/drm/xe/display/xe_fb_pin.c      |  8 ++---
>  3 files changed, 21 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_fb_pin.c b/drivers/gpu/drm/i915/display/intel_fb_pin.c
> index 041f09f76628..7971656982a6 100644
> --- a/drivers/gpu/drm/i915/display/intel_fb_pin.c
> +++ b/drivers/gpu/drm/i915/display/intel_fb_pin.c
> @@ -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);
>  	}
>  }
> diff --git a/drivers/gpu/drm/i915/display/intel_fb_pin.h b/drivers/gpu/drm/i915/display/intel_fb_pin.h
> index de0efaa25905..edcebe75afd7 100644
> --- a/drivers/gpu/drm/i915/display/intel_fb_pin.h
> +++ b/drivers/gpu/drm/i915/display/intel_fb_pin.h
> @@ -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,
> diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> index 3e1ae37c4c8b..8b7ca3268834 100644
> --- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
> +++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> @@ -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,

-- 
Jani Nikula, Intel




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux