From patchwork Wed Nov 27 01:17:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongqiang Niu X-Patchwork-Id: 11263545 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E325513A4 for ; Wed, 27 Nov 2019 08:09:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C9E432070B for ; Wed, 27 Nov 2019 08:09:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9E432070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A0B36E4C1; Wed, 27 Nov 2019 08:09:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by gabe.freedesktop.org (Postfix) with ESMTP id 22A096E1E2 for ; Wed, 27 Nov 2019 01:18:06 +0000 (UTC) X-UUID: b1d2e2b438744ddd84fe632dc4d218cf-20191127 X-UUID: b1d2e2b438744ddd84fe632dc4d218cf-20191127 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 450978565; Wed, 27 Nov 2019 09:18:03 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs05n2.mediatek.inc (172.21.101.140) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 27 Nov 2019 09:17:49 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 27 Nov 2019 09:17:10 +0800 From: To: CK Hu , Philipp Zabel , Rob Herring , Matthias Brugger Subject: [PATCH v1, 1/2] drm/mediatek: Fixup external display black screen issue Date: Wed, 27 Nov 2019 09:17:54 +0800 Message-ID: <1574817475-22378-2-git-send-email-yongqiang.niu@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1574817475-22378-1-git-send-email-yongqiang.niu@mediatek.com> References: <1574817475-22378-1-git-send-email-yongqiang.niu@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Mailman-Approved-At: Wed, 27 Nov 2019 08:09:16 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=ukDKw46dJ6kUKB8fK1XW/KSDkxflYgyotMjPJ393R3U=; b=grzPbgtOoaYuYOJcAIbOpqz1hVI4MKTPAvxuH57zO63yI/7B33G/kWWwgPTRKaJ860f+kFp6kEWJvM+2wxeSzPwgZuSl6V2Lt6BxV0sWUsHdF/HMTj15L4HMD9E3FYsGkZ4Ygwvu9wOYWFWKar8+H52dmls1CanI5jwjN3ghRoc=; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Yongqiang Niu , David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Yongqiang Niu Problem: overlay hangup when external display hotplut test Fix: disable overlay when crtc disable Signed-off-by: Yongqiang Niu --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 39 +++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index 4fb346c..7eca02f 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -369,6 +369,20 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc) mtk_disp_mutex_add_comp(mtk_crtc->mutex, mtk_crtc->ddp_comp[i]->id); mtk_disp_mutex_enable(mtk_crtc->mutex); + /* Initially configure all planes */ + for (i = 0; i < mtk_crtc->layer_nr; i++) { + struct drm_plane *plane = &mtk_crtc->planes[i]; + struct mtk_plane_state *plane_state; + struct mtk_ddp_comp *comp; + unsigned int local_layer; + + plane_state = to_mtk_plane_state(plane->state); + comp = mtk_drm_ddp_comp_for_plane(crtc, plane, &local_layer); + if (comp) + mtk_ddp_comp_layer_config(comp, local_layer, + plane_state, NULL); + } + for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[i]; enum mtk_ddp_comp_id prev; @@ -385,20 +399,6 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc) mtk_ddp_comp_start(comp); } - /* Initially configure all planes */ - for (i = 0; i < mtk_crtc->layer_nr; i++) { - struct drm_plane *plane = &mtk_crtc->planes[i]; - struct mtk_plane_state *plane_state; - struct mtk_ddp_comp *comp; - unsigned int local_layer; - - plane_state = to_mtk_plane_state(plane->state); - comp = mtk_drm_ddp_comp_for_plane(crtc, plane, &local_layer); - if (comp) - mtk_ddp_comp_layer_config(comp, local_layer, - plane_state, NULL); - } - return 0; err_mutex_unprepare: @@ -607,10 +607,21 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc, for (i = 0; i < mtk_crtc->layer_nr; i++) { struct drm_plane *plane = &mtk_crtc->planes[i]; struct mtk_plane_state *plane_state; + struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; + unsigned int comp_layer_nr = mtk_ddp_comp_layer_nr(comp); + unsigned int local_layer; plane_state = to_mtk_plane_state(plane->state); plane_state->pending.enable = false; plane_state->pending.config = true; + + if (i >= comp_layer_nr) { + comp = mtk_crtc->ddp_comp[1]; + local_layer = i - comp_layer_nr; + } else + local_layer = i; + mtk_ddp_comp_layer_config(comp, local_layer, + plane_state, NULL); } mtk_crtc->pending_planes = true; From patchwork Wed Nov 27 01:17:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongqiang Niu X-Patchwork-Id: 11263543 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3EC536C1 for ; Wed, 27 Nov 2019 08:09:44 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 254CF20678 for ; Wed, 27 Nov 2019 08:09:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 254CF20678 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9D7B36E270; Wed, 27 Nov 2019 08:09:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailgw01.mediatek.com (unknown [210.61.82.183]) by gabe.freedesktop.org (Postfix) with ESMTP id 440B96E1E2 for ; Wed, 27 Nov 2019 01:18:08 +0000 (UTC) X-UUID: 7e349144f6d543ddb7a2494a9147c433-20191127 X-UUID: 7e349144f6d543ddb7a2494a9147c433-20191127 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 129762766; Wed, 27 Nov 2019 09:18:04 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs05n1.mediatek.inc (172.21.101.15) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 27 Nov 2019 09:17:53 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 27 Nov 2019 09:17:11 +0800 From: To: CK Hu , Philipp Zabel , Rob Herring , Matthias Brugger Subject: [PATCH v1, 2/2] drm/mediatek: Fix external display vblank timeout issue Date: Wed, 27 Nov 2019 09:17:55 +0800 Message-ID: <1574817475-22378-3-git-send-email-yongqiang.niu@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1574817475-22378-1-git-send-email-yongqiang.niu@mediatek.com> References: <1574817475-22378-1-git-send-email-yongqiang.niu@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Mailman-Approved-At: Wed, 27 Nov 2019 08:09:16 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=Lvh1fcnFFRtO4+2c6Jho2uXYD1k+u4DIOsjea3Dk4/4=; b=nPlRS5jqIpH0rOcUo3hQUanJda7fP53DBXru4GFV5CjsmJb4hO+aVZK9IuxbofxdGgNT4wKOxV2TQA42Wg/KD10ClIvY3DmV9s/q5L9dYOC6DskVsdYfrI+4YeW/V4IgTUK6psIpleTeHfmlewxzxYWvD6Zo309wK6vnCJd6o7M=; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Yongqiang Niu , David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Yongqiang Niu Fix external display vblank timeout issue Signed-off-by: Yongqiang Niu --- drivers/gpu/drm/mediatek/mtk_dpi.c | 14 +++++++++----- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 6 ++++++ drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index be6d95c..38cabbe 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -387,8 +387,12 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi) { int ret; - if (++dpi->refcount != 1) + if (++dpi->refcount != 1) { + dev_warn(dpi->dev, "%s refcount: %d\n", __func__, dpi->refcount); return 0; + } + + DRM_DEBUG_DRIVER("%s refcount %d\n", __func__, dpi->refcount); ret = clk_prepare_enable(dpi->engine_clk); if (ret) { @@ -563,14 +567,14 @@ static int mtk_dpi_atomic_check(struct drm_encoder *encoder, .atomic_check = mtk_dpi_atomic_check, }; -static void mtk_dpi_start(struct mtk_ddp_comp *comp) +static void mtk_dpi_prepare(struct mtk_ddp_comp *comp) { struct mtk_dpi *dpi = container_of(comp, struct mtk_dpi, ddp_comp); mtk_dpi_power_on(dpi); } -static void mtk_dpi_stop(struct mtk_ddp_comp *comp) +static void mtk_dpi_unprepare(struct mtk_ddp_comp *comp) { struct mtk_dpi *dpi = container_of(comp, struct mtk_dpi, ddp_comp); @@ -578,8 +582,8 @@ static void mtk_dpi_stop(struct mtk_ddp_comp *comp) } static const struct mtk_ddp_comp_funcs mtk_dpi_funcs = { - .start = mtk_dpi_start, - .stop = mtk_dpi_stop, + .prepare = mtk_dpi_prepare, + .unprepare = mtk_dpi_unprepare, }; static int mtk_dpi_bind(struct device *dev, struct device *master, void *data) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index 7eca02f..a6d3d97 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -345,6 +345,9 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc) return ret; } + for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) + mtk_ddp_comp_prepare(mtk_crtc->ddp_comp[i]); + ret = mtk_disp_mutex_prepare(mtk_crtc->mutex); if (ret < 0) { DRM_ERROR("Failed to enable mutex clock: %d\n", ret); @@ -434,6 +437,9 @@ static void mtk_crtc_ddp_hw_fini(struct mtk_drm_crtc *mtk_crtc) mtk_crtc_ddp_clk_disable(mtk_crtc); mtk_disp_mutex_unprepare(mtk_crtc->mutex); + for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) + mtk_ddp_comp_unprepare(mtk_crtc->ddp_comp[i]); + pm_runtime_put(drm->dev); if (crtc->state->event && !crtc->state->active) { diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h index 5b0a3d4..097b90d 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h @@ -78,6 +78,8 @@ struct mtk_ddp_comp_funcs { void (*stop)(struct mtk_ddp_comp *comp); void (*enable_vblank)(struct mtk_ddp_comp *comp, struct drm_crtc *crtc); void (*disable_vblank)(struct mtk_ddp_comp *comp); + void (*prepare)(struct mtk_ddp_comp *comp); + void (*unprepare)(struct mtk_ddp_comp *comp); unsigned int (*supported_rotations)(struct mtk_ddp_comp *comp); unsigned int (*layer_nr)(struct mtk_ddp_comp *comp); void (*layer_on)(struct mtk_ddp_comp *comp, unsigned int idx, @@ -117,6 +119,18 @@ static inline void mtk_ddp_comp_config(struct mtk_ddp_comp *comp, comp->funcs->config(comp, w, h, vrefresh, bpc, cmdq_pkt); } +static inline void mtk_ddp_comp_prepare(struct mtk_ddp_comp *comp) +{ + if (comp->funcs && comp->funcs->prepare) + comp->funcs->prepare(comp); +} + +static inline void mtk_ddp_comp_unprepare(struct mtk_ddp_comp *comp) +{ + if (comp->funcs && comp->funcs->unprepare) + comp->funcs->unprepare(comp); +} + static inline void mtk_ddp_comp_start(struct mtk_ddp_comp *comp) { if (comp->funcs && comp->funcs->start)