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

Merge tag 'drm-fixes-2021-06-25' of git://anongit.freedesktop.org/drm/drm

Pull drm fixes from Dave Airlie:
"This is a bit bigger than I'd like at this stage, and I guess last
week was extra quiet, but it's mostly one fix across three drivers to
wait for buffer move pinning to complete.

There was one locking change that got reverted so it's just noise.

Otherwise the amdgpu/nouveau changes are for known regressions, and
otherwise it's just misc changes in kmb/atmel/vc4 drivers.

Summary:

core:
- auth locking change + brown paper bag revert

radeon/nouveau/amdgpu/ttm:
- wait for BO to be pinned after moving it (same fix in three
drivers)

amdgpu:
- Revert GFX9/10 doorbell fixes, we just end up trading one bug for
another
- Potential memory corruption fix in framebuffer handling

nouveau:
- fix regression checking dma addresses

kmb:
- error return fix

atmel-hlcdc:
- fix kernel warnings at boot
- enable async flips

vc4:
- fix CPU hang due to power management"

* tag 'drm-fixes-2021-06-25' of git://anongit.freedesktop.org/drm/drm:
drm/nouveau: fix dma_address check for CPU/GPU sync
drm/kmb: Fix error return code in kmb_hw_init()
drm/amdgpu: wait for moving fence after pinning
drm/radeon: wait for moving fence after pinning
drm/nouveau: wait for moving fence after pinning v2
Revert "drm: add a locked version of drm_is_current_master"
Revert "drm/amdgpu/gfx9: fix the doorbell missing when in CGPG issue."
Revert "drm/amdgpu/gfx10: enlarge CP_MEC_DOORBELL_RANGE_UPPER to cover full doorbell."
drm/amdgpu: Call drm_framebuffer_init last for framebuffer init
drm: add a locked version of drm_is_current_master
drm/atmel-hlcdc: Allow async page flips
drm/panel: ld9040: reference spi_device_id table
drm: atmel_hlcdc: Enable the crtc vblank prior to crtc usage.
drm/vc4: hdmi: Make sure the controller is powered in detect
drm/vc4: hdmi: Move the HSM clock enable to runtime_pm

+99 -38
+7 -5
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
··· 1047 1047 1048 1048 rfb->base.obj[0] = obj; 1049 1049 drm_helper_mode_fill_fb_struct(dev, &rfb->base, mode_cmd); 1050 - ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs); 1050 + 1051 + ret = amdgpu_display_framebuffer_init(dev, rfb, mode_cmd, obj); 1051 1052 if (ret) 1052 1053 goto err; 1053 1054 1054 - ret = amdgpu_display_framebuffer_init(dev, rfb, mode_cmd, obj); 1055 + ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs); 1055 1056 if (ret) 1056 1057 goto err; 1057 1058 ··· 1072 1071 1073 1072 rfb->base.obj[0] = obj; 1074 1073 drm_helper_mode_fill_fb_struct(dev, &rfb->base, mode_cmd); 1075 - ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs); 1076 - if (ret) 1077 - goto err; 1078 1074 /* Verify that the modifier is supported. */ 1079 1075 if (!drm_any_plane_has_format(dev, mode_cmd->pixel_format, 1080 1076 mode_cmd->modifier[0])) { ··· 1087 1089 } 1088 1090 1089 1091 ret = amdgpu_display_framebuffer_init(dev, rfb, mode_cmd, obj); 1092 + if (ret) 1093 + goto err; 1094 + 1095 + ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs); 1090 1096 if (ret) 1091 1097 goto err; 1092 1098
+13 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
··· 214 214 { 215 215 struct drm_gem_object *obj = attach->dmabuf->priv; 216 216 struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj); 217 + int r; 217 218 218 219 /* pin buffer into GTT */ 219 - return amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_GTT); 220 + r = amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_GTT); 221 + if (r) 222 + return r; 223 + 224 + if (bo->tbo.moving) { 225 + r = dma_fence_wait(bo->tbo.moving, true); 226 + if (r) { 227 + amdgpu_bo_unpin(bo); 228 + return r; 229 + } 230 + } 231 + return 0; 220 232 } 221 233 222 234 /**
+1 -5
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
··· 6871 6871 if (ring->use_doorbell) { 6872 6872 WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_LOWER, 6873 6873 (adev->doorbell_index.kiq * 2) << 2); 6874 - /* If GC has entered CGPG, ringing doorbell > first page doesn't 6875 - * wakeup GC. Enlarge CP_MEC_DOORBELL_RANGE_UPPER to workaround 6876 - * this issue. 6877 - */ 6878 6874 WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_UPPER, 6879 - (adev->doorbell.size - 4)); 6875 + (adev->doorbell_index.userqueue_end * 2) << 2); 6880 6876 } 6881 6877 6882 6878 WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL,
+1 -5
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
··· 3673 3673 if (ring->use_doorbell) { 3674 3674 WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_LOWER, 3675 3675 (adev->doorbell_index.kiq * 2) << 2); 3676 - /* If GC has entered CGPG, ringing doorbell > first page doesn't 3677 - * wakeup GC. Enlarge CP_MEC_DOORBELL_RANGE_UPPER to workaround 3678 - * this issue. 3679 - */ 3680 3676 WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_UPPER, 3681 - (adev->doorbell.size - 4)); 3677 + (adev->doorbell_index.userqueue_end * 2) << 2); 3682 3678 } 3683 3679 3684 3680 WREG32_SOC15_RLC(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL,
+10 -7
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
··· 232 232 233 233 pm_runtime_put_sync(dev->dev); 234 234 235 - drm_crtc_vblank_on(c); 236 235 } 237 236 238 237 #define ATMEL_HLCDC_RGB444_OUTPUT BIT(0) ··· 343 344 static void atmel_hlcdc_crtc_atomic_begin(struct drm_crtc *c, 344 345 struct drm_atomic_state *state) 345 346 { 347 + drm_crtc_vblank_on(c); 348 + } 349 + 350 + static void atmel_hlcdc_crtc_atomic_flush(struct drm_crtc *c, 351 + struct drm_atomic_state *state) 352 + { 346 353 struct atmel_hlcdc_crtc *crtc = drm_crtc_to_atmel_hlcdc_crtc(c); 354 + unsigned long flags; 355 + 356 + spin_lock_irqsave(&c->dev->event_lock, flags); 347 357 348 358 if (c->state->event) { 349 359 c->state->event->pipe = drm_crtc_index(c); ··· 362 354 crtc->event = c->state->event; 363 355 c->state->event = NULL; 364 356 } 365 - } 366 - 367 - static void atmel_hlcdc_crtc_atomic_flush(struct drm_crtc *crtc, 368 - struct drm_atomic_state *state) 369 - { 370 - /* TODO: write common plane control register if available */ 357 + spin_unlock_irqrestore(&c->dev->event_lock, flags); 371 358 } 372 359 373 360 static const struct drm_crtc_helper_funcs lcdc_crtc_helper_funcs = {
+1
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
··· 593 593 dev->mode_config.max_width = dc->desc->max_width; 594 594 dev->mode_config.max_height = dc->desc->max_height; 595 595 dev->mode_config.funcs = &mode_config_funcs; 596 + dev->mode_config.async_page_flip = true; 596 597 597 598 return 0; 598 599 }
+1
drivers/gpu/drm/kmb/kmb_drv.c
··· 137 137 /* Allocate LCD interrupt resources */ 138 138 irq_lcd = platform_get_irq(pdev, 0); 139 139 if (irq_lcd < 0) { 140 + ret = irq_lcd; 140 141 drm_err(&kmb->drm, "irq_lcd not found"); 141 142 goto setup_fail; 142 143 }
+2 -2
drivers/gpu/drm/nouveau/nouveau_bo.c
··· 546 546 struct ttm_tt *ttm_dma = (struct ttm_tt *)nvbo->bo.ttm; 547 547 int i, j; 548 548 549 - if (!ttm_dma) 549 + if (!ttm_dma || !ttm_dma->dma_address) 550 550 return; 551 551 if (!ttm_dma->pages) { 552 552 NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma); ··· 582 582 struct ttm_tt *ttm_dma = (struct ttm_tt *)nvbo->bo.ttm; 583 583 int i, j; 584 584 585 - if (!ttm_dma) 585 + if (!ttm_dma || !ttm_dma->dma_address) 586 586 return; 587 587 if (!ttm_dma->pages) { 588 588 NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma);
+16 -1
drivers/gpu/drm/nouveau/nouveau_prime.c
··· 93 93 if (ret) 94 94 return -EINVAL; 95 95 96 - return 0; 96 + ret = ttm_bo_reserve(&nvbo->bo, false, false, NULL); 97 + if (ret) 98 + goto error; 99 + 100 + if (nvbo->bo.moving) 101 + ret = dma_fence_wait(nvbo->bo.moving, true); 102 + 103 + ttm_bo_unreserve(&nvbo->bo); 104 + if (ret) 105 + goto error; 106 + 107 + return ret; 108 + 109 + error: 110 + nouveau_bo_unpin(nvbo); 111 + return ret; 97 112 } 98 113 99 114 void nouveau_gem_prime_unpin(struct drm_gem_object *obj)
+1
drivers/gpu/drm/panel/panel-samsung-ld9040.c
··· 383 383 static struct spi_driver ld9040_driver = { 384 384 .probe = ld9040_probe, 385 385 .remove = ld9040_remove, 386 + .id_table = ld9040_ids, 386 387 .driver = { 387 388 .name = "panel-samsung-ld9040", 388 389 .of_match_table = ld9040_of_match,
+12 -2
drivers/gpu/drm/radeon/radeon_prime.c
··· 77 77 78 78 /* pin buffer into GTT */ 79 79 ret = radeon_bo_pin(bo, RADEON_GEM_DOMAIN_GTT, NULL); 80 - if (likely(ret == 0)) 81 - bo->prime_shared_count++; 80 + if (unlikely(ret)) 81 + goto error; 82 82 83 + if (bo->tbo.moving) { 84 + ret = dma_fence_wait(bo->tbo.moving, false); 85 + if (unlikely(ret)) { 86 + radeon_bo_unpin(bo); 87 + goto error; 88 + } 89 + } 90 + 91 + bo->prime_shared_count++; 92 + error: 83 93 radeon_bo_unreserve(bo); 84 94 return ret; 85 95 }
+34 -10
drivers/gpu/drm/vc4/vc4_hdmi.c
··· 159 159 struct vc4_hdmi *vc4_hdmi = connector_to_vc4_hdmi(connector); 160 160 bool connected = false; 161 161 162 + WARN_ON(pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev)); 163 + 162 164 if (vc4_hdmi->hpd_gpio) { 163 165 if (gpio_get_value_cansleep(vc4_hdmi->hpd_gpio) ^ 164 166 vc4_hdmi->hpd_active_low) ··· 182 180 } 183 181 } 184 182 183 + pm_runtime_put(&vc4_hdmi->pdev->dev); 185 184 return connector_status_connected; 186 185 } 187 186 188 187 cec_phys_addr_invalidate(vc4_hdmi->cec_adap); 188 + pm_runtime_put(&vc4_hdmi->pdev->dev); 189 189 return connector_status_disconnected; 190 190 } 191 191 ··· 477 473 HDMI_READ(HDMI_VID_CTL) & ~VC4_HD_VID_CTL_ENABLE); 478 474 479 475 clk_disable_unprepare(vc4_hdmi->pixel_bvb_clock); 480 - clk_disable_unprepare(vc4_hdmi->hsm_clock); 481 476 clk_disable_unprepare(vc4_hdmi->pixel_clock); 482 477 483 478 ret = pm_runtime_put(&vc4_hdmi->pdev->dev); ··· 787 784 return; 788 785 } 789 786 790 - ret = clk_prepare_enable(vc4_hdmi->hsm_clock); 791 - if (ret) { 792 - DRM_ERROR("Failed to turn on HSM clock: %d\n", ret); 793 - clk_disable_unprepare(vc4_hdmi->pixel_clock); 794 - return; 795 - } 796 - 797 787 vc4_hdmi_cec_update_clk_div(vc4_hdmi); 798 788 799 789 /* ··· 797 801 (hsm_rate > VC4_HSM_MID_CLOCK ? 150000000 : 75000000)); 798 802 if (ret) { 799 803 DRM_ERROR("Failed to set pixel bvb clock rate: %d\n", ret); 800 - clk_disable_unprepare(vc4_hdmi->hsm_clock); 801 804 clk_disable_unprepare(vc4_hdmi->pixel_clock); 802 805 return; 803 806 } ··· 804 809 ret = clk_prepare_enable(vc4_hdmi->pixel_bvb_clock); 805 810 if (ret) { 806 811 DRM_ERROR("Failed to turn on pixel bvb clock: %d\n", ret); 807 - clk_disable_unprepare(vc4_hdmi->hsm_clock); 808 812 clk_disable_unprepare(vc4_hdmi->pixel_clock); 809 813 return; 810 814 } ··· 1923 1929 return 0; 1924 1930 } 1925 1931 1932 + #ifdef CONFIG_PM 1933 + static int vc4_hdmi_runtime_suspend(struct device *dev) 1934 + { 1935 + struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev); 1936 + 1937 + clk_disable_unprepare(vc4_hdmi->hsm_clock); 1938 + 1939 + return 0; 1940 + } 1941 + 1942 + static int vc4_hdmi_runtime_resume(struct device *dev) 1943 + { 1944 + struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev); 1945 + int ret; 1946 + 1947 + ret = clk_prepare_enable(vc4_hdmi->hsm_clock); 1948 + if (ret) 1949 + return ret; 1950 + 1951 + return 0; 1952 + } 1953 + #endif 1954 + 1926 1955 static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) 1927 1956 { 1928 1957 const struct vc4_hdmi_variant *variant = of_device_get_match_data(dev); ··· 2182 2165 {} 2183 2166 }; 2184 2167 2168 + static const struct dev_pm_ops vc4_hdmi_pm_ops = { 2169 + SET_RUNTIME_PM_OPS(vc4_hdmi_runtime_suspend, 2170 + vc4_hdmi_runtime_resume, 2171 + NULL) 2172 + }; 2173 + 2185 2174 struct platform_driver vc4_hdmi_driver = { 2186 2175 .probe = vc4_hdmi_dev_probe, 2187 2176 .remove = vc4_hdmi_dev_remove, 2188 2177 .driver = { 2189 2178 .name = "vc4_hdmi", 2190 2179 .of_match_table = vc4_hdmi_dt_match, 2180 + .pm = &vc4_hdmi_pm_ops, 2191 2181 }, 2192 2182 };