return ret;
 }
 
+static void dm_get_oriented_plane_size(struct drm_plane_state *plane_state,
+                                      int *src_w, int *src_h)
+{
+       switch (plane_state->rotation & DRM_MODE_ROTATE_MASK) {
+       case DRM_MODE_ROTATE_90:
+       case DRM_MODE_ROTATE_270:
+               *src_w = plane_state->src_h >> 16;
+               *src_h = plane_state->src_w >> 16;
+               break;
+       case DRM_MODE_ROTATE_0:
+       case DRM_MODE_ROTATE_180:
+       default:
+               *src_w = plane_state->src_w >> 16;
+               *src_h = plane_state->src_h >> 16;
+               break;
+       }
+}
+
 static int dm_check_crtc_cursor(struct drm_atomic_state *state,
                                struct drm_crtc *crtc,
                                struct drm_crtc_state *new_crtc_state)
        struct drm_plane_state *new_cursor_state, *new_underlying_state;
        int i;
        int cursor_scale_w, cursor_scale_h, underlying_scale_w, underlying_scale_h;
+       int cursor_src_w, cursor_src_h;
+       int underlying_src_w, underlying_src_h;
 
        /* On DCE and DCN there is no dedicated hardware cursor plane. We get a
         * cursor per pipe but it's going to inherit the scaling and
                return 0;
        }
 
-       cursor_scale_w = new_cursor_state->crtc_w * 1000 /
-                        (new_cursor_state->src_w >> 16);
-       cursor_scale_h = new_cursor_state->crtc_h * 1000 /
-                        (new_cursor_state->src_h >> 16);
+       dm_get_oriented_plane_size(new_cursor_state, &cursor_src_w, &cursor_src_h);
+       cursor_scale_w = new_cursor_state->crtc_w * 1000 / cursor_src_w;
+       cursor_scale_h = new_cursor_state->crtc_h * 1000 / cursor_src_h;
 
        for_each_new_plane_in_state_reverse(state, underlying, new_underlying_state, i) {
                /* Narrow down to non-cursor planes on the same CRTC as the cursor */
                if (!new_underlying_state->fb)
                        continue;
 
-               underlying_scale_w = new_underlying_state->crtc_w * 1000 /
-                                    (new_underlying_state->src_w >> 16);
-               underlying_scale_h = new_underlying_state->crtc_h * 1000 /
-                                    (new_underlying_state->src_h >> 16);
+               dm_get_oriented_plane_size(new_underlying_state,
+                                          &underlying_src_w, &underlying_src_h);
+               underlying_scale_w = new_underlying_state->crtc_w * 1000 / underlying_src_w;
+               underlying_scale_h = new_underlying_state->crtc_h * 1000 / underlying_src_h;
 
                if (cursor_scale_w != underlying_scale_w ||
                    cursor_scale_h != underlying_scale_h) {