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

Merge tag 'drm-misc-fixes-2024-06-07' of https://gitlab.freedesktop.org/drm/misc/kernel into drm-fixes

drm-misc-fixes for v6.10-rc3:
- Robustness fixes for vmwgfx.
- Error check for of_drm_get_panel_orientation failing in
sitronix-st7789v.

Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/d5645d00-a8cf-47d9-a2a0-4ff55842fc7d@linux.intel.com

+74 -44
+3 -1
drivers/gpu/drm/panel/panel-sitronix-st7789v.c
··· 643 643 if (ret) 644 644 return dev_err_probe(dev, ret, "Failed to get backlight\n"); 645 645 646 - of_drm_get_panel_orientation(spi->dev.of_node, &ctx->orientation); 646 + ret = of_drm_get_panel_orientation(spi->dev.of_node, &ctx->orientation); 647 + if (ret) 648 + return dev_err_probe(&spi->dev, ret, "Failed to get orientation\n"); 647 649 648 650 drm_panel_add(&ctx->panel); 649 651
+6 -13
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
··· 746 746 dev->vram_size = pci_resource_len(pdev, 2); 747 747 748 748 drm_info(&dev->drm, 749 - "Register MMIO at 0x%pa size is %llu kiB\n", 749 + "Register MMIO at 0x%pa size is %llu KiB\n", 750 750 &rmmio_start, (uint64_t)rmmio_size / 1024); 751 751 dev->rmmio = devm_ioremap(dev->drm.dev, 752 752 rmmio_start, ··· 765 765 fifo_size = pci_resource_len(pdev, 2); 766 766 767 767 drm_info(&dev->drm, 768 - "FIFO at %pa size is %llu kiB\n", 768 + "FIFO at %pa size is %llu KiB\n", 769 769 &fifo_start, (uint64_t)fifo_size / 1024); 770 770 dev->fifo_mem = devm_memremap(dev->drm.dev, 771 771 fifo_start, ··· 790 790 * SVGA_REG_VRAM_SIZE. 791 791 */ 792 792 drm_info(&dev->drm, 793 - "VRAM at %pa size is %llu kiB\n", 793 + "VRAM at %pa size is %llu KiB\n", 794 794 &dev->vram_start, (uint64_t)dev->vram_size / 1024); 795 795 796 796 return 0; ··· 960 960 vmw_read(dev_priv, 961 961 SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB); 962 962 963 - /* 964 - * Workaround for low memory 2D VMs to compensate for the 965 - * allocation taken by fbdev 966 - */ 967 - if (!(dev_priv->capabilities & SVGA_CAP_3D)) 968 - mem_size *= 3; 969 - 970 963 dev_priv->max_mob_pages = mem_size * 1024 / PAGE_SIZE; 971 964 dev_priv->max_primary_mem = 972 965 vmw_read(dev_priv, SVGA_REG_MAX_PRIMARY_MEM); ··· 984 991 dev_priv->max_primary_mem = dev_priv->vram_size; 985 992 } 986 993 drm_info(&dev_priv->drm, 987 - "Legacy memory limits: VRAM = %llu kB, FIFO = %llu kB, surface = %u kB\n", 994 + "Legacy memory limits: VRAM = %llu KiB, FIFO = %llu KiB, surface = %u KiB\n", 988 995 (u64)dev_priv->vram_size / 1024, 989 996 (u64)dev_priv->fifo_mem_size / 1024, 990 997 dev_priv->memory_size / 1024); 991 998 992 999 drm_info(&dev_priv->drm, 993 - "MOB limits: max mob size = %u kB, max mob pages = %u\n", 1000 + "MOB limits: max mob size = %u KiB, max mob pages = %u\n", 994 1001 dev_priv->max_mob_size / 1024, dev_priv->max_mob_pages); 995 1002 996 1003 ret = vmw_dma_masks(dev_priv); ··· 1008 1015 (unsigned)dev_priv->max_gmr_pages); 1009 1016 } 1010 1017 drm_info(&dev_priv->drm, 1011 - "Maximum display memory size is %llu kiB\n", 1018 + "Maximum display memory size is %llu KiB\n", 1012 1019 (uint64_t)dev_priv->max_primary_mem / 1024); 1013 1020 1014 1021 /* Need mmio memory to check for fifo pitchlock cap. */
-3
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
··· 1043 1043 int vmw_kms_write_svga(struct vmw_private *vmw_priv, 1044 1044 unsigned width, unsigned height, unsigned pitch, 1045 1045 unsigned bpp, unsigned depth); 1046 - bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv, 1047 - uint32_t pitch, 1048 - uint32_t height); 1049 1046 int vmw_kms_present(struct vmw_private *dev_priv, 1050 1047 struct drm_file *file_priv, 1051 1048 struct vmw_framebuffer *vfb,
+2 -2
drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
··· 94 94 } else 95 95 new_max_pages = gman->max_gmr_pages * 2; 96 96 if (new_max_pages > gman->max_gmr_pages && new_max_pages >= gman->used_gmr_pages) { 97 - DRM_WARN("vmwgfx: increasing guest mob limits to %u kB.\n", 97 + DRM_WARN("vmwgfx: increasing guest mob limits to %u KiB.\n", 98 98 ((new_max_pages) << (PAGE_SHIFT - 10))); 99 99 100 100 gman->max_gmr_pages = new_max_pages; 101 101 } else { 102 102 char buf[256]; 103 103 snprintf(buf, sizeof(buf), 104 - "vmwgfx, error: guest graphics is out of memory (mob limit at: %ukB).\n", 104 + "vmwgfx, error: guest graphics is out of memory (mob limit at: %u KiB).\n", 105 105 ((gman->max_gmr_pages) << (PAGE_SHIFT - 10))); 106 106 vmw_host_printf(buf); 107 107 DRM_WARN("%s", buf);
+10 -18
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
··· 224 224 new_image = vmw_du_cursor_plane_acquire_image(new_vps); 225 225 226 226 changed = false; 227 - if (old_image && new_image) 227 + if (old_image && new_image && old_image != new_image) 228 228 changed = memcmp(old_image, new_image, size) != 0; 229 229 230 230 return changed; ··· 2171 2171 return 0; 2172 2172 } 2173 2173 2174 + static 2174 2175 bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv, 2175 - uint32_t pitch, 2176 - uint32_t height) 2176 + u64 pitch, 2177 + u64 height) 2177 2178 { 2178 - return ((u64) pitch * (u64) height) < (u64) 2179 - ((dev_priv->active_display_unit == vmw_du_screen_target) ? 2180 - dev_priv->max_primary_mem : dev_priv->vram_size); 2179 + return (pitch * height) < (u64)dev_priv->vram_size; 2181 2180 } 2182 2181 2183 2182 /** ··· 2872 2873 enum drm_mode_status vmw_connector_mode_valid(struct drm_connector *connector, 2873 2874 struct drm_display_mode *mode) 2874 2875 { 2876 + enum drm_mode_status ret; 2875 2877 struct drm_device *dev = connector->dev; 2876 2878 struct vmw_private *dev_priv = vmw_priv(dev); 2877 - u32 max_width = dev_priv->texture_max_width; 2878 - u32 max_height = dev_priv->texture_max_height; 2879 2879 u32 assumed_cpp = 4; 2880 2880 2881 2881 if (dev_priv->assume_16bpp) 2882 2882 assumed_cpp = 2; 2883 2883 2884 - if (dev_priv->active_display_unit == vmw_du_screen_target) { 2885 - max_width = min(dev_priv->stdu_max_width, max_width); 2886 - max_height = min(dev_priv->stdu_max_height, max_height); 2887 - } 2888 - 2889 - if (max_width < mode->hdisplay) 2890 - return MODE_BAD_HVALUE; 2891 - 2892 - if (max_height < mode->vdisplay) 2893 - return MODE_BAD_VVALUE; 2884 + ret = drm_mode_validate_size(mode, dev_priv->texture_max_width, 2885 + dev_priv->texture_max_height); 2886 + if (ret != MODE_OK) 2887 + return ret; 2894 2888 2895 2889 if (!vmw_kms_validate_mode_vram(dev_priv, 2896 2890 mode->hdisplay * assumed_cpp,
+53 -7
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
··· 43 43 #define vmw_connector_to_stdu(x) \ 44 44 container_of(x, struct vmw_screen_target_display_unit, base.connector) 45 45 46 - 46 + /* 47 + * Some renderers such as llvmpipe will align the width and height of their 48 + * buffers to match their tile size. We need to keep this in mind when exposing 49 + * modes to userspace so that this possible over-allocation will not exceed 50 + * graphics memory. 64x64 pixels seems to be a reasonable upper bound for the 51 + * tile size of current renderers. 52 + */ 53 + #define GPU_TILE_SIZE 64 47 54 48 55 enum stdu_content_type { 49 56 SAME_AS_DISPLAY = 0, ··· 90 83 struct vmw_stdu_update { 91 84 SVGA3dCmdHeader header; 92 85 SVGA3dCmdUpdateGBScreenTarget body; 93 - }; 94 - 95 - struct vmw_stdu_dma { 96 - SVGA3dCmdHeader header; 97 - SVGA3dCmdSurfaceDMA body; 98 86 }; 99 87 100 88 struct vmw_stdu_surface_copy { ··· 416 414 { 417 415 struct vmw_private *dev_priv; 418 416 struct vmw_screen_target_display_unit *stdu; 417 + struct drm_crtc_state *new_crtc_state; 419 418 int ret; 420 419 421 420 if (!crtc) { ··· 426 423 427 424 stdu = vmw_crtc_to_stdu(crtc); 428 425 dev_priv = vmw_priv(crtc->dev); 426 + new_crtc_state = drm_atomic_get_new_crtc_state(state, crtc); 429 427 430 428 if (dev_priv->vkms_enabled) 431 429 drm_crtc_vblank_off(crtc); ··· 437 433 DRM_ERROR("Failed to blank CRTC\n"); 438 434 439 435 (void) vmw_stdu_update_st(dev_priv, stdu); 436 + 437 + /* Don't destroy the Screen Target if we are only setting the 438 + * display as inactive 439 + */ 440 + if (new_crtc_state->enable && 441 + !new_crtc_state->active && 442 + !new_crtc_state->mode_changed) 443 + return; 440 444 441 445 ret = vmw_stdu_destroy_st(dev_priv, stdu); 442 446 if (ret) ··· 841 829 vmw_stdu_destroy(vmw_connector_to_stdu(connector)); 842 830 } 843 831 832 + static enum drm_mode_status 833 + vmw_stdu_connector_mode_valid(struct drm_connector *connector, 834 + struct drm_display_mode *mode) 835 + { 836 + enum drm_mode_status ret; 837 + struct drm_device *dev = connector->dev; 838 + struct vmw_private *dev_priv = vmw_priv(dev); 839 + u64 assumed_cpp = dev_priv->assume_16bpp ? 2 : 4; 840 + /* Align width and height to account for GPU tile over-alignment */ 841 + u64 required_mem = ALIGN(mode->hdisplay, GPU_TILE_SIZE) * 842 + ALIGN(mode->vdisplay, GPU_TILE_SIZE) * 843 + assumed_cpp; 844 + required_mem = ALIGN(required_mem, PAGE_SIZE); 844 845 846 + ret = drm_mode_validate_size(mode, dev_priv->stdu_max_width, 847 + dev_priv->stdu_max_height); 848 + if (ret != MODE_OK) 849 + return ret; 850 + 851 + ret = drm_mode_validate_size(mode, dev_priv->texture_max_width, 852 + dev_priv->texture_max_height); 853 + if (ret != MODE_OK) 854 + return ret; 855 + 856 + if (required_mem > dev_priv->max_primary_mem) 857 + return MODE_MEM; 858 + 859 + if (required_mem > dev_priv->max_mob_pages * PAGE_SIZE) 860 + return MODE_MEM; 861 + 862 + if (required_mem > dev_priv->max_mob_size) 863 + return MODE_MEM; 864 + 865 + return MODE_OK; 866 + } 845 867 846 868 static const struct drm_connector_funcs vmw_stdu_connector_funcs = { 847 869 .dpms = vmw_du_connector_dpms, ··· 891 845 static const struct 892 846 drm_connector_helper_funcs vmw_stdu_connector_helper_funcs = { 893 847 .get_modes = vmw_connector_get_modes, 894 - .mode_valid = vmw_connector_mode_valid 848 + .mode_valid = vmw_stdu_connector_mode_valid 895 849 }; 896 850 897 851