drm/vmwgfx: Add gui_x/y to vmw_connector_state
authorDeepak Rawat <drawat@vmware.com>
Wed, 20 Jun 2018 09:34:26 +0000 (11:34 +0200)
committerThomas Hellstrom <thellstrom@vmware.com>
Tue, 3 Jul 2018 18:39:46 +0000 (20:39 +0200)
As gui_x/y positioning is display unit is protected by
requested_layout_mutex adding vmw_connector_state copy of the same and
modeset commit will refer the state copy to sync with modeset_check
state.

v2: Tested with CONFIG_PROVE_LOCKING enabled.

Signed-off-by: Deepak Rawat <drawat@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c

index a592d10e5c76304644c3f96d1f830c1bfc26b02b..0fb363458ab57c3e36292cd8da52f9d730bfda38 100644 (file)
@@ -1609,26 +1609,43 @@ static int vmw_kms_check_topology(struct drm_device *dev,
        for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state,
                                      new_crtc_state, i) {
                struct vmw_display_unit *du = vmw_crtc_to_du(crtc);
+               struct drm_connector *connector;
+               struct drm_connector_state *conn_state;
+               struct vmw_connector_state *vmw_conn_state;
 
                if (!new_crtc_state->enable && old_crtc_state->enable) {
                        rects[i].x1 = 0;
                        rects[i].y1 = 0;
                        rects[i].x2 = 0;
                        rects[i].y2 = 0;
+                       continue;
                }
 
-               if (new_crtc_state->enable) {
-                       /* If display unit is not active cannot enable CRTC */
-                       if (!du->pref_active) {
-                               ret = -EINVAL;
-                               goto clean;
-                       }
+               if (!du->pref_active) {
+                       ret = -EINVAL;
+                       goto clean;
+               }
 
-                       rects[i].x1 = du->gui_x;
-                       rects[i].y1 = du->gui_y;
-                       rects[i].x2 = du->gui_x + new_crtc_state->mode.hdisplay;
-                       rects[i].y2 = du->gui_y + new_crtc_state->mode.vdisplay;
+               /*
+                * For vmwgfx each crtc has only one connector attached and it
+                * is not changed so don't really need to check the
+                * crtc->connector_mask and iterate over it.
+                */
+               connector = &du->connector;
+               conn_state = drm_atomic_get_connector_state(state, connector);
+               if (IS_ERR(conn_state)) {
+                       ret = PTR_ERR(conn_state);
+                       goto clean;
                }
+
+               vmw_conn_state = vmw_connector_state_to_vcs(conn_state);
+               vmw_conn_state->gui_x = du->gui_x;
+               vmw_conn_state->gui_y = du->gui_y;
+
+               rects[i].x1 = du->gui_x;
+               rects[i].y1 = du->gui_y;
+               rects[i].x2 = du->gui_x + new_crtc_state->mode.hdisplay;
+               rects[i].y2 = du->gui_y + new_crtc_state->mode.vdisplay;
        }
 
        ret = vmw_kms_check_display_memory(dev, dev->mode_config.num_crtc,
index ff1caed38f94e29fd01a6c3da5a29c781f940c59..1f2b01862652e8615e3da1171175c15bb7fa44d7 100644 (file)
@@ -192,6 +192,24 @@ struct vmw_connector_state {
        struct drm_connector_state base;
 
        bool is_implicit;
+
+       /**
+        * @gui_x:
+        *
+        * vmwgfx connector property representing the x position of this display
+        * unit (connector is synonymous to display unit) in overall topology.
+        * This is what the device expect as xRoot while creating screen.
+        */
+       int gui_x;
+
+       /**
+        * @gui_y:
+        *
+        * vmwgfx connector property representing the y position of this display
+        * unit (connector is synonymous to display unit) in overall topology.
+        * This is what the device expect as yRoot while creating screen.
+        */
+       int gui_y;
 };
 
 /**
index 74dfd4621b7e74fcca18d3fcd4d941a13fe59de9..df21d5a6f84aa28040bf094916ae0f70ede12995 100644 (file)
@@ -109,7 +109,7 @@ static void vmw_sou_crtc_destroy(struct drm_crtc *crtc)
  */
 static int vmw_sou_fifo_create(struct vmw_private *dev_priv,
                               struct vmw_screen_object_unit *sou,
-                              uint32_t x, uint32_t y,
+                              int x, int y,
                               struct drm_display_mode *mode)
 {
        size_t fifo_size;
@@ -139,13 +139,8 @@ static int vmw_sou_fifo_create(struct vmw_private *dev_priv,
                (sou->base.unit == 0 ? SVGA_SCREEN_IS_PRIMARY : 0);
        cmd->obj.size.width = mode->hdisplay;
        cmd->obj.size.height = mode->vdisplay;
-       if (sou->base.is_implicit) {
-               cmd->obj.root.x = x;
-               cmd->obj.root.y = y;
-       } else {
-               cmd->obj.root.x = sou->base.gui_x;
-               cmd->obj.root.y = sou->base.gui_y;
-       }
+       cmd->obj.root.x = x;
+       cmd->obj.root.y = y;
        sou->base.set_gui_x = cmd->obj.root.x;
        sou->base.set_gui_y = cmd->obj.root.y;
 
@@ -222,12 +217,11 @@ static void vmw_sou_crtc_mode_set_nofb(struct drm_crtc *crtc)
        struct vmw_plane_state *vps;
        int ret;
 
-
-       sou      = vmw_crtc_to_sou(crtc);
+       sou = vmw_crtc_to_sou(crtc);
        dev_priv = vmw_priv(crtc->dev);
-       ps       = crtc->primary->state;
-       fb       = ps->fb;
-       vps      = vmw_plane_state_to_vps(ps);
+       ps = crtc->primary->state;
+       fb = ps->fb;
+       vps = vmw_plane_state_to_vps(ps);
 
        vfb = (fb) ? vmw_framebuffer_to_vfb(fb) : NULL;
 
@@ -240,11 +234,25 @@ static void vmw_sou_crtc_mode_set_nofb(struct drm_crtc *crtc)
        }
 
        if (vfb) {
+               struct drm_connector_state *conn_state;
+               struct vmw_connector_state *vmw_conn_state;
+               int x, y;
+
                sou->buffer = vps->bo;
                sou->buffer_size = vps->bo_size;
 
-               ret = vmw_sou_fifo_create(dev_priv, sou, crtc->x, crtc->y,
-                                         &crtc->mode);
+               if (sou->base.is_implicit) {
+                       x = crtc->x;
+                       y = crtc->y;
+               } else {
+                       conn_state = sou->base.connector.state;
+                       vmw_conn_state = vmw_connector_state_to_vcs(conn_state);
+
+                       x = vmw_conn_state->gui_x;
+                       y = vmw_conn_state->gui_y;
+               }
+
+               ret = vmw_sou_fifo_create(dev_priv, sou, x, y, &crtc->mode);
                if (ret)
                        DRM_ERROR("Failed to define Screen Object %dx%d\n",
                                  crtc->x, crtc->y);
index 537df9034008bdec4d25bd29b6164b45aa5fe50c..15f2cb2a151b065854803b1f30e01bce7ac158b1 100644 (file)
@@ -178,13 +178,9 @@ static int vmw_stdu_define_st(struct vmw_private *dev_priv,
        cmd->body.height = mode->vdisplay;
        cmd->body.flags  = (0 == cmd->body.stid) ? SVGA_STFLAG_PRIMARY : 0;
        cmd->body.dpi    = 0;
-       if (stdu->base.is_implicit) {
-               cmd->body.xRoot  = crtc_x;
-               cmd->body.yRoot  = crtc_y;
-       } else {
-               cmd->body.xRoot  = stdu->base.gui_x;
-               cmd->body.yRoot  = stdu->base.gui_y;
-       }
+       cmd->body.xRoot  = crtc_x;
+       cmd->body.yRoot  = crtc_y;
+
        stdu->base.set_gui_x = cmd->body.xRoot;
        stdu->base.set_gui_y = cmd->body.yRoot;
 
@@ -374,11 +370,14 @@ static void vmw_stdu_crtc_mode_set_nofb(struct drm_crtc *crtc)
 {
        struct vmw_private *dev_priv;
        struct vmw_screen_target_display_unit *stdu;
-       int ret;
-
+       struct drm_connector_state *conn_state;
+       struct vmw_connector_state *vmw_conn_state;
+       int x, y, ret;
 
-       stdu     = vmw_crtc_to_stdu(crtc);
+       stdu = vmw_crtc_to_stdu(crtc);
        dev_priv = vmw_priv(crtc->dev);
+       conn_state = stdu->base.connector.state;
+       vmw_conn_state = vmw_connector_state_to_vcs(conn_state);
 
        if (stdu->defined) {
                ret = vmw_stdu_bind_st(dev_priv, stdu, NULL);
@@ -397,8 +396,16 @@ static void vmw_stdu_crtc_mode_set_nofb(struct drm_crtc *crtc)
        if (!crtc->state->enable)
                return;
 
+       if (stdu->base.is_implicit) {
+               x = crtc->x;
+               y = crtc->y;
+       } else {
+               x = vmw_conn_state->gui_x;
+               y = vmw_conn_state->gui_y;
+       }
+
        vmw_svga_enable(dev_priv);
-       ret = vmw_stdu_define_st(dev_priv, stdu, &crtc->mode, crtc->x, crtc->y);
+       ret = vmw_stdu_define_st(dev_priv, stdu, &crtc->mode, x, y);
 
        if (ret)
                DRM_ERROR("Failed to define Screen Target of size %dx%d\n",