Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/vmwgfx: Remove explicit and broken vblank handling

The explicit vblank handling was never finished. The driver never had
the full implementation of vblank and what was there is emulated
by DRM when the driver doesn't pretend to be implementing it itself.

Let DRM handle the vblank emulation and stop pretending the driver is
doing anything special with vblank. In the future it would make sense
to implement helpers for full vblank handling because vkms and
amdgpu_vkms already have that code. Exporting it to common helpers and
having all three drivers share it would make sense (that would be largely
just to allow more of igt to run).

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Maaz Mombasawala <mombasawalam@vmware.com>
Reviewed-by: Martin Krastev <krastevm@vmware.com>
Reviewed-by: Michael Banack <banackm@vmware.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221022040236.616490-15-zack@kde.org

+1 -101
-3
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
··· 1208 1208 bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv, 1209 1209 uint32_t pitch, 1210 1210 uint32_t height); 1211 - u32 vmw_get_vblank_counter(struct drm_crtc *crtc); 1212 - int vmw_enable_vblank(struct drm_crtc *crtc); 1213 - void vmw_disable_vblank(struct drm_crtc *crtc); 1214 1211 int vmw_kms_present(struct vmw_private *dev_priv, 1215 1212 struct drm_file *file_priv, 1216 1213 struct vmw_framebuffer *vfb,
-34
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
··· 31 31 #include <drm/drm_fourcc.h> 32 32 #include <drm/drm_rect.h> 33 33 #include <drm/drm_sysfs.h> 34 - #include <drm/drm_vblank.h> 35 34 36 35 #include "vmwgfx_kms.h" 37 36 ··· 980 981 void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc, 981 982 struct drm_atomic_state *state) 982 983 { 983 - struct drm_pending_vblank_event *event = crtc->state->event; 984 - 985 - if (event) { 986 - crtc->state->event = NULL; 987 - 988 - spin_lock_irq(&crtc->dev->event_lock); 989 - drm_crtc_send_vblank_event(crtc, event); 990 - spin_unlock_irq(&crtc->dev->event_lock); 991 - } 992 984 } 993 985 994 986 ··· 2295 2305 return ((u64) pitch * (u64) height) < (u64) 2296 2306 ((dev_priv->active_display_unit == vmw_du_screen_target) ? 2297 2307 dev_priv->max_primary_mem : dev_priv->vram_size); 2298 - } 2299 - 2300 - 2301 - /* 2302 - * Function called by DRM code called with vbl_lock held. 2303 - */ 2304 - u32 vmw_get_vblank_counter(struct drm_crtc *crtc) 2305 - { 2306 - return 0; 2307 - } 2308 - 2309 - /* 2310 - * Function called by DRM code called with vbl_lock held. 2311 - */ 2312 - int vmw_enable_vblank(struct drm_crtc *crtc) 2313 - { 2314 - return -EINVAL; 2315 - } 2316 - 2317 - /* 2318 - * Function called by DRM code called with vbl_lock held. 2319 - */ 2320 - void vmw_disable_vblank(struct drm_crtc *crtc) 2321 - { 2322 2308 } 2323 2309 2324 2310 /**
-8
drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
··· 28 28 #include <drm/drm_atomic.h> 29 29 #include <drm/drm_atomic_helper.h> 30 30 #include <drm/drm_fourcc.h> 31 - #include <drm/drm_vblank.h> 32 31 33 32 #include "vmwgfx_kms.h" 34 33 ··· 234 235 .atomic_duplicate_state = vmw_du_crtc_duplicate_state, 235 236 .atomic_destroy_state = vmw_du_crtc_destroy_state, 236 237 .set_config = drm_atomic_helper_set_config, 237 - .get_vblank_counter = vmw_get_vblank_counter, 238 - .enable_vblank = vmw_enable_vblank, 239 - .disable_vblank = vmw_disable_vblank, 240 238 }; 241 239 242 240 ··· 502 506 dev_priv->ldu_priv->num_active = 0; 503 507 dev_priv->ldu_priv->last_num_active = 0; 504 508 dev_priv->ldu_priv->fb = NULL; 505 - 506 - ret = drm_vblank_init(dev, num_display_units); 507 - if (ret != 0) 508 - goto err_free; 509 509 510 510 vmw_kms_create_implicit_placement_property(dev_priv); 511 511
+1 -30
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
··· 29 29 #include <drm/drm_atomic_helper.h> 30 30 #include <drm/drm_damage_helper.h> 31 31 #include <drm/drm_fourcc.h> 32 - #include <drm/drm_vblank.h> 33 32 34 33 #include "vmwgfx_kms.h" 35 34 ··· 319 320 .atomic_destroy_state = vmw_du_crtc_destroy_state, 320 321 .set_config = drm_atomic_helper_set_config, 321 322 .page_flip = drm_atomic_helper_page_flip, 322 - .get_vblank_counter = vmw_get_vblank_counter, 323 - .enable_vblank = vmw_enable_vblank, 324 - .disable_vblank = vmw_disable_vblank, 325 323 }; 326 324 327 325 /* ··· 726 730 struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, plane); 727 731 struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane); 728 732 struct drm_crtc *crtc = new_state->crtc; 729 - struct drm_pending_vblank_event *event = NULL; 730 733 struct vmw_fence_obj *fence = NULL; 731 734 int ret; 732 735 ··· 747 752 } else { 748 753 /* Do nothing when fb and crtc is NULL (blank crtc) */ 749 754 return; 750 - } 751 - 752 - /* For error case vblank event is send from vmw_du_crtc_atomic_flush */ 753 - event = crtc->state->event; 754 - if (event && fence) { 755 - struct drm_file *file_priv = event->base.file_priv; 756 - 757 - ret = vmw_event_fence_action_queue(file_priv, 758 - fence, 759 - &event->base, 760 - &event->event.vbl.tv_sec, 761 - &event->event.vbl.tv_usec, 762 - true); 763 - 764 - if (unlikely(ret != 0)) 765 - DRM_ERROR("Failed to queue event on fence.\n"); 766 - else 767 - crtc->state->event = NULL; 768 755 } 769 756 770 757 if (fence) ··· 924 947 int vmw_kms_sou_init_display(struct vmw_private *dev_priv) 925 948 { 926 949 struct drm_device *dev = &dev_priv->drm; 927 - int i, ret; 950 + int i; 928 951 929 952 if (!(dev_priv->capabilities & SVGA_CAP_SCREEN_OBJECT_2)) { 930 953 return -ENOSYS; 931 954 } 932 - 933 - ret = -ENOMEM; 934 - 935 - ret = drm_vblank_init(dev, VMWGFX_NUM_DISPLAY_UNITS); 936 - if (unlikely(ret != 0)) 937 - return ret; 938 955 939 956 for (i = 0; i < VMWGFX_NUM_DISPLAY_UNITS; ++i) 940 957 vmw_sou_init(dev_priv, i);
-26
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
··· 29 29 #include <drm/drm_atomic_helper.h> 30 30 #include <drm/drm_damage_helper.h> 31 31 #include <drm/drm_fourcc.h> 32 - #include <drm/drm_vblank.h> 33 32 34 33 #include "vmwgfx_kms.h" 35 34 #include "vmw_surface_cache.h" ··· 924 925 .atomic_destroy_state = vmw_du_crtc_destroy_state, 925 926 .set_config = drm_atomic_helper_set_config, 926 927 .page_flip = drm_atomic_helper_page_flip, 927 - .get_vblank_counter = vmw_get_vblank_counter, 928 - .enable_vblank = vmw_enable_vblank, 929 - .disable_vblank = vmw_disable_vblank, 930 928 }; 931 929 932 930 ··· 1587 1591 struct vmw_plane_state *vps = vmw_plane_state_to_vps(new_state); 1588 1592 struct drm_crtc *crtc = new_state->crtc; 1589 1593 struct vmw_screen_target_display_unit *stdu; 1590 - struct drm_pending_vblank_event *event; 1591 1594 struct vmw_fence_obj *fence = NULL; 1592 1595 struct vmw_private *dev_priv; 1593 1596 int ret; ··· 1633 1638 DRM_ERROR("Failed to update STDU.\n"); 1634 1639 1635 1640 return; 1636 - } 1637 - 1638 - /* In case of error, vblank event is send in vmw_du_crtc_atomic_flush */ 1639 - event = crtc->state->event; 1640 - if (event && fence) { 1641 - struct drm_file *file_priv = event->base.file_priv; 1642 - 1643 - ret = vmw_event_fence_action_queue(file_priv, 1644 - fence, 1645 - &event->base, 1646 - &event->event.vbl.tv_sec, 1647 - &event->event.vbl.tv_usec, 1648 - true); 1649 - if (ret) 1650 - DRM_ERROR("Failed to queue event on fence.\n"); 1651 - else 1652 - crtc->state->event = NULL; 1653 1641 } 1654 1642 1655 1643 if (fence) ··· 1860 1882 1861 1883 if (!(dev_priv->capabilities & SVGA_CAP_GBOBJECTS)) 1862 1884 return -ENOSYS; 1863 - 1864 - ret = drm_vblank_init(dev, VMWGFX_NUM_DISPLAY_UNITS); 1865 - if (unlikely(ret != 0)) 1866 - return ret; 1867 1885 1868 1886 dev_priv->active_display_unit = vmw_du_screen_target; 1869 1887