When the bo is used to set mode, the bo need to be pinned.

Signed-off-by: Emily Deng <emily.d...@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 54 ++++++++++++++++++++++++--------
 1 file changed, 41 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c 
b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
index 2d68181..77752e3 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
@@ -211,19 +211,6 @@ static void dce_virtual_crtc_disable(struct drm_crtc *crtc)
        amdgpu_crtc->connector = NULL;
 }
 
-static int dce_virtual_crtc_mode_set(struct drm_crtc *crtc,
-                                 struct drm_display_mode *mode,
-                                 struct drm_display_mode *adjusted_mode,
-                                 int x, int y, struct drm_framebuffer *old_fb)
-{
-       struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-
-       /* update the hw version fpr dpm */
-       amdgpu_crtc->hw_mode = *adjusted_mode;
-
-       return 0;
-}
-
 static bool dce_virtual_crtc_mode_fixup(struct drm_crtc *crtc,
                                     const struct drm_display_mode *mode,
                                     struct drm_display_mode *adjusted_mode)
@@ -235,6 +222,47 @@ static bool dce_virtual_crtc_mode_fixup(struct drm_crtc 
*crtc,
 static int dce_virtual_crtc_set_base(struct drm_crtc *crtc, int x, int y,
                                  struct drm_framebuffer *old_fb)
 {
+       struct drm_framebuffer *target_fb;
+       struct drm_gem_object *obj;
+       struct amdgpu_bo *abo;
+       int r;
+
+       /* no fb bound */
+       if (!crtc->primary->fb) {
+               DRM_DEBUG_KMS("No FB bound\n");
+               return 0;
+       }
+
+       target_fb = crtc->primary->fb;
+
+       obj = kcl_drm_fb_get_gem_obj(target_fb, 0);
+       abo = gem_to_amdgpu_bo(obj);
+       r = amdgpu_bo_reserve(abo, false);
+       if (unlikely(r != 0))
+               return r;
+
+       r = amdgpu_bo_pin(abo, AMDGPU_GEM_DOMAIN_VRAM);
+       if (unlikely(r != 0)) {
+               amdgpu_bo_unreserve(abo);
+               return -EINVAL;
+       }
+
+       amdgpu_bo_unreserve(abo);
+       return 0;
+}
+
+static int dce_virtual_crtc_mode_set(struct drm_crtc *crtc,
+                                 struct drm_display_mode *mode,
+                                 struct drm_display_mode *adjusted_mode,
+                                 int x, int y, struct drm_framebuffer *old_fb)
+{
+       struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
+
+       dce_virtual_crtc_set_base(crtc, x, y, old_fb);
+
+       /* update the hw version fpr dpm */
+       amdgpu_crtc->hw_mode = *adjusted_mode;
+
        return 0;
 }
 
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to