[7/8] drm/bochs: use drm_gem_vram_offset to get bo offset v2
diff mbox series

Message ID 20200219135322.56463-8-nirmoy.das@amd.com
State New
Headers show
Series
  • do not store GPU address in TTM
Related show

Commit Message

Nirmoy Das Feb. 19, 2020, 1:53 p.m. UTC
Switch over to GEM VRAM's implementation to retrieve bo->offset

Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
---
 drivers/gpu/drm/bochs/bochs_kms.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

--
2.25.0

Comments

Daniel Vetter Feb. 20, 2020, 6:11 p.m. UTC | #1
On Wed, Feb 19, 2020 at 02:53:21PM +0100, Nirmoy Das wrote:
> Switch over to GEM VRAM's implementation to retrieve bo->offset
> 
> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
> ---
>  drivers/gpu/drm/bochs/bochs_kms.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
> index 8066d7d370d5..18d2ec34534d 100644
> --- a/drivers/gpu/drm/bochs/bochs_kms.c
> +++ b/drivers/gpu/drm/bochs/bochs_kms.c
> @@ -29,16 +29,21 @@ static void bochs_plane_update(struct bochs_device *bochs,
>  			       struct drm_plane_state *state)
>  {
>  	struct drm_gem_vram_object *gbo;
> +	s64 gpu_addr;
> 
>  	if (!state->fb || !bochs->stride)
>  		return;
> 
>  	gbo = drm_gem_vram_of_gem(state->fb->obj[0]);
> +	gpu_addr = drm_gem_vram_offset(gbo);
> +	if (WARN_ON_ONCE(gpu_addr < 0))
> +		return; /* Bug: we didn't pin the BO to VRAM in prepare_fb. */

That negative errno in gpu_addr from vram helpers is kinda wild.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> +
>  	bochs_hw_setbase(bochs,
>  			 state->crtc_x,
>  			 state->crtc_y,
>  			 state->fb->pitches[0],
> -			 state->fb->offsets[0] + gbo->bo.offset);
> +			 state->fb->offsets[0] + gpu_addr);
>  	bochs_hw_setformat(bochs, state->fb->format);
>  }
> 
> --
> 2.25.0
>

Patch
diff mbox series

diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
index 8066d7d370d5..18d2ec34534d 100644
--- a/drivers/gpu/drm/bochs/bochs_kms.c
+++ b/drivers/gpu/drm/bochs/bochs_kms.c
@@ -29,16 +29,21 @@  static void bochs_plane_update(struct bochs_device *bochs,
 			       struct drm_plane_state *state)
 {
 	struct drm_gem_vram_object *gbo;
+	s64 gpu_addr;

 	if (!state->fb || !bochs->stride)
 		return;

 	gbo = drm_gem_vram_of_gem(state->fb->obj[0]);
+	gpu_addr = drm_gem_vram_offset(gbo);
+	if (WARN_ON_ONCE(gpu_addr < 0))
+		return; /* Bug: we didn't pin the BO to VRAM in prepare_fb. */
+
 	bochs_hw_setbase(bochs,
 			 state->crtc_x,
 			 state->crtc_y,
 			 state->fb->pitches[0],
-			 state->fb->offsets[0] + gbo->bo.offset);
+			 state->fb->offsets[0] + gpu_addr);
 	bochs_hw_setformat(bochs, state->fb->format);
 }