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)