Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2828757pxv; Mon, 12 Jul 2021 02:58:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXYi7fcvjMYroLgZzwXeCNorkvS3rGhtuxsPMJ1F4uxmWIDLq1DeBUf1xN4Ou50upjRtOe X-Received: by 2002:a92:c888:: with SMTP id w8mr19753948ilo.140.1626083921571; Mon, 12 Jul 2021 02:58:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626083921; cv=none; d=google.com; s=arc-20160816; b=ZhQ2IzcOMn8Vzf/Zzt0MuqWgdcXFgz7Poya3iJOrmk8qOOM9i86X5zrsjg9L4O8ROl YDQFZCTn22Iwk9A89OcRby5au4ycmgZ1981hc2UBCqY1uDywQi8kStyL+KSCYpMssdbF UTVHgZEzej5TzeJIFBxx68ZRkYnqfPc1WhwBBguNnOIr/cQTbsRhUQV9Aa53NqoehyUm SKqZDi8TOj7xOSnSwXlsG8UZQDVtbXS1Z6HEggAIX0ya8KSdk8AiAEq21EHwEbOel0P/ AhA+uAisGuH78cmQmJgnHnW7s9ZYsUgazHMCJDmlzt8UcpB4z/yg1yigau/mofjPen75 nbCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=TtlFDuiSPLPktWlwQVE+gO11LVfUZTdN/Gu+Wo5D/aI=; b=SHDxHFJgidlwBzqQjqtH/tqZov99YYFVeWR+BQ3fSuG92GlKY1PsNbcyLQaKZo6NzN 9YevwXGSeFXKdjDHba7uALC5Oc3GgNJbRSoZWhemK8RhFRXXYrSIfUxvrEtg0+6izjo7 HuLFSMWk9ICziRuHRRlwWgADhE8FNeSk326xzT0Ofo14xJsFrOPD6aPyZWLTmuGxggDb 7kplHNmfyzHw/T9N63unKOeoPXDi+puVd5oibOduKtOy9pi8/LQmBpJWUPG6n/8t47Lc dNYecKFEiy/umd8DNQK6QOmMFPd/rvBD7RIiH4shX0HAGtY8HxKOnuCuEtmz7geyedh0 bKrw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w13si18392676ilu.98.2021.07.12.02.58.29; Mon, 12 Jul 2021 02:58:41 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239178AbhGLHA6 (ORCPT + 99 others); Mon, 12 Jul 2021 03:00:58 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:37894 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S239176AbhGLGow (ORCPT ); Mon, 12 Jul 2021 02:44:52 -0400 X-UUID: 2bdc28769b9148929ed04cf5bb0e0ca6-20210712 X-UUID: 2bdc28769b9148929ed04cf5bb0e0ca6-20210712 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1331553782; Mon, 12 Jul 2021 14:42:00 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs05n1.mediatek.inc (172.21.101.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 12 Jul 2021 14:41:59 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 12 Jul 2021 14:41:52 +0800 From: Yongqiang Niu To: Chun-Kuang Hu CC: Rob Herring , Matthias Brugger , Philipp Zabel , David Airlie , Daniel Vetter , Jassi Brar , Yongqiang Niu , Fabien Parent , Dennis YC Hsieh , , , , , , , Hsin-Yi Wang , CK Hu Subject: [PATCH v2] drm/mediatek: clear pending flag when cmdq packet is done. Date: Mon, 12 Jul 2021 14:41:49 +0800 Message-ID: <1626072109-2657-2-git-send-email-yongqiang.niu@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1626072109-2657-1-git-send-email-yongqiang.niu@mediatek.com> References: <1626072109-2657-1-git-send-email-yongqiang.niu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In cmdq mode, packet may be flushed before it is executed, so the pending flag should be cleared after cmdq packet is done. Signed-off-by: CK Hu Signed-off-by: Yongqiang Niu --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 92 ++++++++++++++++++++++++++++++--- 1 file changed, 85 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index 40df2c8..8cd107b 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -73,6 +73,13 @@ struct mtk_crtc_state { unsigned int pending_vrefresh; }; +#if IS_REACHABLE(CONFIG_MTK_CMDQ) +struct mtk_cmdq_cb_data { + struct cmdq_pkt *cmdq_handle; + struct mtk_drm_crtc *mtk_crtc; +}; +#endif + static inline struct mtk_drm_crtc *to_mtk_crtc(struct drm_crtc *c) { return container_of(c, struct mtk_drm_crtc, base); @@ -224,7 +231,64 @@ struct mtk_ddp_comp *mtk_drm_ddp_comp_for_plane(struct drm_crtc *crtc, #if IS_REACHABLE(CONFIG_MTK_CMDQ) static void ddp_cmdq_cb(struct cmdq_cb_data data) { - cmdq_pkt_destroy(data.data); + struct mtk_cmdq_cb_data *cb_data = data.data; + struct mtk_drm_crtc *mtk_crtc; + struct mtk_crtc_state *state; + unsigned int i; + + if (!cb_data) { + DRM_ERROR("cmdq callback data is null pointer!\n"); + return; + } + + if (data.sta != 0) { + DRM_WARN("cmdq callback error %d!!\n", data.sta); + goto destroy_pkt; + } + + mtk_crtc = cb_data->mtk_crtc; + if (!mtk_crtc) { + DRM_ERROR("cmdq callback mtk_crtc is null pointer!\n"); + goto destroy_pkt; + } + + state = to_mtk_crtc_state(mtk_crtc->base.state); + + if (state->pending_config) { + state->pending_config = false; + } + + if (mtk_crtc->pending_planes) { + for (i = 0; i < mtk_crtc->layer_nr; i++) { + struct drm_plane *plane = &mtk_crtc->planes[i]; + struct mtk_plane_state *plane_state; + + plane_state = to_mtk_plane_state(plane->state); + + if (plane_state->pending.config) + plane_state->pending.config = false; + } + mtk_crtc->pending_planes = false; + } + + if (mtk_crtc->pending_async_planes) { + for (i = 0; i < mtk_crtc->layer_nr; i++) { + struct drm_plane *plane = &mtk_crtc->planes[i]; + struct mtk_plane_state *plane_state; + + plane_state = to_mtk_plane_state(plane->state); + + if (plane_state->pending.async_config) + plane_state->pending.async_config = false; + } + mtk_crtc->pending_async_planes = false; + } + +destroy_pkt: + if (cb_data->cmdq_handle) + cmdq_pkt_destroy(cb_data->cmdq_handle); + + kfree(cb_data); } #endif @@ -378,7 +442,8 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc, state->pending_vrefresh, 0, cmdq_handle); - state->pending_config = false; + if (!cmdq_handle) + state->pending_config = false; } if (mtk_crtc->pending_planes) { @@ -398,9 +463,12 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc, mtk_ddp_comp_layer_config(comp, local_layer, plane_state, cmdq_handle); - plane_state->pending.config = false; + if (!cmdq_handle) + plane_state->pending.config = false; } - mtk_crtc->pending_planes = false; + + if (!cmdq_handle) + mtk_crtc->pending_planes = false; } if (mtk_crtc->pending_async_planes) { @@ -420,9 +488,13 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc, mtk_ddp_comp_layer_config(comp, local_layer, plane_state, cmdq_handle); - plane_state->pending.async_config = false; + + if (!cmdq_handle) + plane_state->pending.async_config = false; } - mtk_crtc->pending_async_planes = false; + + if (!cmdq_handle) + mtk_crtc->pending_async_planes = false; } } @@ -469,13 +541,19 @@ static void mtk_drm_crtc_update_config(struct mtk_drm_crtc *mtk_crtc, } #if IS_REACHABLE(CONFIG_MTK_CMDQ) if (mtk_crtc->cmdq_client) { + struct mtk_cmdq_cb_data *cb_data; + mbox_flush(mtk_crtc->cmdq_client->chan, 2000); cmdq_handle = cmdq_pkt_create(mtk_crtc->cmdq_client, PAGE_SIZE); cmdq_pkt_clear_event(cmdq_handle, mtk_crtc->cmdq_event); cmdq_pkt_wfe(cmdq_handle, mtk_crtc->cmdq_event, false); mtk_crtc_ddp_config(crtc, cmdq_handle); cmdq_pkt_finalize(cmdq_handle); - cmdq_pkt_flush_async(cmdq_handle, ddp_cmdq_cb, cmdq_handle); + + cb_data = kmalloc(sizeof(*cb_data), GFP_KERNEL); + cb_data->cmdq_handle = cmdq_handle; + cb_data->mtk_crtc = mtk_crtc; + cmdq_pkt_flush_async(cmdq_handle, ddp_cmdq_cb, cb_data); } #endif mtk_crtc->config_updating = false; -- 1.8.1.1.dirty