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

drm/mediatek: crtc: Make config-updating atomic

While updating config, the irq would occur and get the partial
config, so use variable config_updating to make updating atomic.

Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>

+12 -7
+12 -7
drivers/gpu/drm/mediatek/mtk_drm_crtc.c
··· 61 61 62 62 /* lock for display hardware access */ 63 63 struct mutex hw_lock; 64 + bool config_updating; 64 65 }; 65 66 66 67 struct mtk_crtc_state { ··· 98 97 static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc) 99 98 { 100 99 drm_crtc_handle_vblank(&mtk_crtc->base); 101 - if (mtk_crtc->pending_needs_vblank) { 100 + if (!mtk_crtc->config_updating && mtk_crtc->pending_needs_vblank) { 102 101 mtk_drm_crtc_finish_page_flip(mtk_crtc); 103 102 mtk_crtc->pending_needs_vblank = false; 104 103 } ··· 426 425 } 427 426 } 428 427 429 - static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc) 428 + static void mtk_drm_crtc_update_config(struct mtk_drm_crtc *mtk_crtc, 429 + bool needs_vblank) 430 430 { 431 431 #if IS_REACHABLE(CONFIG_MTK_CMDQ) 432 432 struct cmdq_pkt *cmdq_handle; ··· 438 436 int i; 439 437 440 438 mutex_lock(&mtk_crtc->hw_lock); 439 + mtk_crtc->config_updating = true; 440 + if (needs_vblank) 441 + mtk_crtc->pending_needs_vblank = true; 442 + 441 443 for (i = 0; i < mtk_crtc->layer_nr; i++) { 442 444 struct drm_plane *plane = &mtk_crtc->planes[i]; 443 445 struct mtk_plane_state *plane_state; ··· 478 472 cmdq_pkt_flush_async(cmdq_handle, ddp_cmdq_cb, cmdq_handle); 479 473 } 480 474 #endif 475 + mtk_crtc->config_updating = false; 481 476 mutex_unlock(&mtk_crtc->hw_lock); 482 477 } 483 478 ··· 539 532 return; 540 533 541 534 plane_helper_funcs->atomic_update(plane, new_state); 542 - mtk_drm_crtc_hw_config(mtk_crtc); 535 + mtk_drm_crtc_update_config(mtk_crtc, false); 543 536 } 544 537 545 538 static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc, ··· 589 582 } 590 583 mtk_crtc->pending_planes = true; 591 584 592 - mtk_drm_crtc_hw_config(mtk_crtc); 585 + mtk_drm_crtc_update_config(mtk_crtc, false); 593 586 /* Wait for planes to be disabled */ 594 587 drm_crtc_wait_one_vblank(crtc); 595 588 ··· 625 618 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); 626 619 int i; 627 620 628 - if (mtk_crtc->event) 629 - mtk_crtc->pending_needs_vblank = true; 630 621 if (crtc->state->color_mgmt_changed) 631 622 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { 632 623 mtk_ddp_gamma_set(mtk_crtc->ddp_comp[i], crtc->state); 633 624 mtk_ddp_ctm_set(mtk_crtc->ddp_comp[i], crtc->state); 634 625 } 635 - mtk_drm_crtc_hw_config(mtk_crtc); 626 + mtk_drm_crtc_update_config(mtk_crtc, !!mtk_crtc->event); 636 627 } 637 628 638 629 static const struct drm_crtc_funcs mtk_crtc_funcs = {