Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1919239pxf; Sat, 13 Mar 2021 01:45:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzAxvbAezR3B9/VOjFovMM3+hUjIe4djR3h15G8nq7LpvgVKdImMBjkkmJ/MWd6aJf+ZbVz X-Received: by 2002:a17:906:5d12:: with SMTP id g18mr12953263ejt.246.1615628747807; Sat, 13 Mar 2021 01:45:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615628747; cv=none; d=google.com; s=arc-20160816; b=LZA8YU5jB5c1b+7vNZdoxcSQu7AmF9Kqki4dCEqwow/0cQEnKvQI9eSY3jAncku17A a/38riJIXeMzO8VENVqtY/up8KiKR5Da9xPyW0NKChxzZlM6zZ3MwzZ9WUSvqqK7eEWP +vn4Rxxvdjz9oQyKJ24Nn+o3GQ7diIxDAWrO7BwKdiTNKEej4qQx6PQsS2/W5GrXqotB 7LPYnwp7HMKK36zi8HBJ5q9xLTJHHxseqaaTtuOpCEBq55OpMympAqDmIneH7b3qR7mn mpFb6BRbyARuIH5HuwYFHNAYcTHM4+k2LP4eEqbYpVCu+iS1qOtsZeaU/KSKSQQKENb5 eYMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=ywnUIyW9NzO1zW8zYElF9uOF0ERyobJGZo4twh3fYh0=; b=jylOBQCqO4kNfXxqSF4Vl1uyTrKNIER7QMNzsMaiVrFVR3ltY8L73E56N4ncjj8CUK JsM6uCU8NPs2+yJkQs1ZexVlNGAamt8oWjpQzEHxZLDGQfk2ba3LXDaQbRJRtOWUAyga PQGjpOEltc1vrNRQ9osQ+QKgKByy1fJqZmRPmED43NRf9/EKY//LrU6w95L2Tdr6JKOl nrdR6jo/B2K8EehoZCgYNrR6A3T+iW2VMZuXhL8KcbENEiy+FLFWRyT5tuzKhQjoIoDU olsbwdU1JamkMyoWGeS0JfCDl5rdQ/2TZo3jEMnPr1CtM4I5LGYcT1BvdnBWbPDWgH/W bH6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="SpKwZx/i"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z15si6252604ejr.694.2021.03.13.01.45.13; Sat, 13 Mar 2021 01:45:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="SpKwZx/i"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232431AbhCMJoI (ORCPT + 99 others); Sat, 13 Mar 2021 04:44:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:33248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230441AbhCMJnz (ORCPT ); Sat, 13 Mar 2021 04:43:55 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B397164F14; Sat, 13 Mar 2021 09:43:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615628635; bh=ymSvKKXkySAaTw1aQJH2nwYOEfn49ej0hD436KOzGgI=; h=From:To:Cc:Subject:Date:From; b=SpKwZx/ivwzE7HQSnOwj8SeoRatPxhdPr1nx2eUwahvYS4f2DYeKZnO+Ab4W6TLhO vSl7Vufuuj8vFSdi9MVYZosTRUvH7xDO5fsQn3l4wHt55E4QVQ9OUD/JWQ7GyzDkN7 /EH/uYfVJhfpIdmHn+SWWYdKgdBm1kvgZtDk7vI8awzLBFITpts/K1G7ME+psbXPCU BsXxDc1ViTiBas6bdMJ/ZwlF+51ZyxPZ9BhrG06s3jZ50JWbXKuJ0ya/nqsxMGVTWI 6pHnQLpjC7GdQObrJamifYaKhNsmEM1Zw7Z82dVmh+6qiErGIYRuEa2Kk8t0vukNWn YLmbec9AeLltA== From: Chun-Kuang Hu To: Philipp Zabel , David Airlie , Daniel Vetter Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, Chun-Kuang Hu Subject: [PATCH] drm/mediatek: crtc: Make config-updating atomic Date: Sat, 13 Mar 2021 17:43:31 +0800 Message-Id: <20210313094331.26374-1-chunkuang.hu@kernel.org> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index 8b0de90156c6..870f66210848 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -61,6 +61,7 @@ struct mtk_drm_crtc { /* lock for display hardware access */ struct mutex hw_lock; + bool config_updating; }; struct mtk_crtc_state { @@ -97,7 +98,7 @@ static void mtk_drm_crtc_finish_page_flip(struct mtk_drm_crtc *mtk_crtc) static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc) { drm_crtc_handle_vblank(&mtk_crtc->base); - if (mtk_crtc->pending_needs_vblank) { + if (!mtk_crtc->config_updating && mtk_crtc->pending_needs_vblank) { mtk_drm_crtc_finish_page_flip(mtk_crtc); mtk_crtc->pending_needs_vblank = false; } @@ -425,7 +426,8 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc, } } -static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc) +static void mtk_drm_crtc_update_config(struct mtk_drm_crtc *mtk_crtc, + bool needs_vblank) { #if IS_REACHABLE(CONFIG_MTK_CMDQ) struct cmdq_pkt *cmdq_handle; @@ -436,6 +438,10 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc) int i; mutex_lock(&mtk_crtc->hw_lock); + mtk_crtc->config_updating = true; + if (needs_vblank) + mtk_crtc->pending_needs_vblank = true; + for (i = 0; i < mtk_crtc->layer_nr; i++) { struct drm_plane *plane = &mtk_crtc->planes[i]; struct mtk_plane_state *plane_state; @@ -472,6 +478,7 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc) cmdq_pkt_flush_async(cmdq_handle, ddp_cmdq_cb, cmdq_handle); } #endif + mtk_crtc->config_updating = false; mutex_unlock(&mtk_crtc->hw_lock); } @@ -532,7 +539,7 @@ void mtk_drm_crtc_async_update(struct drm_crtc *crtc, struct drm_plane *plane, return; plane_helper_funcs->atomic_update(plane, new_state); - mtk_drm_crtc_hw_config(mtk_crtc); + mtk_drm_crtc_update_config(mtk_crtc, false); } static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc, @@ -582,7 +589,7 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc, } mtk_crtc->pending_planes = true; - mtk_drm_crtc_hw_config(mtk_crtc); + mtk_drm_crtc_update_config(mtk_crtc, false); /* Wait for planes to be disabled */ drm_crtc_wait_one_vblank(crtc); @@ -618,14 +625,12 @@ static void mtk_drm_crtc_atomic_flush(struct drm_crtc *crtc, struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); int i; - if (mtk_crtc->event) - mtk_crtc->pending_needs_vblank = true; if (crtc->state->color_mgmt_changed) for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { mtk_ddp_gamma_set(mtk_crtc->ddp_comp[i], crtc->state); mtk_ddp_ctm_set(mtk_crtc->ddp_comp[i], crtc->state); } - mtk_drm_crtc_hw_config(mtk_crtc); + mtk_drm_crtc_update_config(mtk_crtc, !!mtk_crtc->event); } static const struct drm_crtc_funcs mtk_crtc_funcs = { -- 2.17.1