Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp403394pxa; Wed, 19 Aug 2020 04:52:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZmOE8KO0vT2MX47d/1KAW3+FZ23LqjJQtA45jdmsmg+o5ERZ/444exauTQ0D/LfXzF6YV X-Received: by 2002:a17:907:104a:: with SMTP id oy10mr24703940ejb.267.1597837968038; Wed, 19 Aug 2020 04:52:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597837968; cv=none; d=google.com; s=arc-20160816; b=mBRwfrgEPx/+V7agjM4hOCOapit9kPtw/wrenjbyXvH60W3451llT21xAmXdTg7yzP 8/gZCrgmi3IYhtfNaRZqZiPtLUvqZMzPDj6ncNXsX8TmRlGgApQ3IH8nS9d69avDqfTe F7AcwBzKxXLu/p8bfgKfT3F5wyHVJkT2ynizG3rS4bkEHBbVsAlZCdHZKc47OD3/TNb8 yCDCY228JgYLCbWP8DYGu+pzzRhhLBtkoYTs4wnaKBTXw8aU/F8ZEuqNewqATry7ISR+ 7eHrjjp5NHu4LSpp3tHxQCsD7h5Lv45JUvbWUY4/TbZTBHP/+PNGkIr7XcQ1G0GWXJXn sYwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sJKxWWE7tXKdzlSlEfF6rcyORbN/ldKtiQQKs2BZT2U=; b=NxmjjKH7S9Q8D+NrIXikkjAqJvU7xczE26lLRo3cS5R3vQEhH0J5aFIj3vT2VD7z64 BCTaYoD8nxj7iZf/Mu5oi+jVUM3ep2MFyOtjgFAQ9zOmyM5WT28tF63kDsNGx99V6UB0 vSBWTGJJ1ZceDERxms66g8k42/vqEU22887KLNyRZIyo3UguGrHKx4N3q3LNgnUDl42S ADnFXSKZ3FS8O1MzUxb5apCR6HtjX+iyD4/G5oidMlThhmLcsblZF0mhEGDQ1N05ygqe G2lT8BL0fYCF7LjlunbwfrQOHLeI1pYoUS7fH9f3QWu+A4ZBPGCtv9Lj9Qzr3BgzOFri BIdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LDFKXpid; 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 g17si21491289edj.109.2020.08.19.04.52.24; Wed, 19 Aug 2020 04:52:48 -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; dkim=pass header.i=@kernel.org header.s=default header.b=LDFKXpid; 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 S1728384AbgHSLuk (ORCPT + 99 others); Wed, 19 Aug 2020 07:50:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:44716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727987AbgHSLqW (ORCPT ); Wed, 19 Aug 2020 07:46:22 -0400 Received: from mail.kernel.org (ip5f5ad5a3.dynamic.kabel-deutschland.de [95.90.213.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 28ACF2078D; Wed, 19 Aug 2020 11:46:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597837581; bh=NPewrDTOQbIKmWxXXrLEDvEG+pl4mWNIoi6RAjja1/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LDFKXpid8S8rDjXPJRzuawn0UghvyY07/CGHDrTode5w1EVMLyvEjEpzs6jkIVr9k XNUCIfwBP1mN6tMdvxgmRsgNBZmcphF0jTjLp9tky3DAG2EVTPWXOT2GvQ7boI384/ z6Cj/20fL/GBvI/6vMKYxlaCTCoeoU0Rgc0o9+1I= Received: from mchehab by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1k8MXr-00Eua2-6K; Wed, 19 Aug 2020 13:46:19 +0200 From: Mauro Carvalho Chehab To: Greg Kroah-Hartman Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Liwei Cai , Mauro Carvalho Chehab , John Stultz , Manivannan Sadhasivam , Daniel Vetter , dri-devel , Xiubin Zhang , Wanchun Zheng , Chen Feng , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/49] staging: hikey9xx/gpu: solve tearing issue of display Date: Wed, 19 Aug 2020 13:45:31 +0200 Message-Id: <5a1a1acbf05e0d9aa44795e668c16f972006e40f.1597833138.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Liwei Cai The use of synchronization mechanisms to deal with the display of buffer, to solve the problem of display tearing. Signed-off-by: Wanchun Zheng Signed-off-by: Liwei Cai Signed-off-by: John Stultz Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/hikey9xx/gpu/dw_drm_dsi.c | 3 +- drivers/staging/hikey9xx/gpu/kirin_drm_dss.c | 4 +- .../hikey9xx/gpu/kirin_drm_overlay_utils.c | 90 ++++++++----------- 3 files changed, 41 insertions(+), 56 deletions(-) diff --git a/drivers/staging/hikey9xx/gpu/dw_drm_dsi.c b/drivers/staging/hikey9xx/gpu/dw_drm_dsi.c index 9871b375416b..db408beb33ec 100644 --- a/drivers/staging/hikey9xx/gpu/dw_drm_dsi.c +++ b/drivers/staging/hikey9xx/gpu/dw_drm_dsi.c @@ -35,7 +35,6 @@ #define DTS_COMP_DSI_NAME "hisilicon,hi3660-dsi" -#define MAX_TX_ESC_CLK 10 #define ROUND(x, y) ((x) / (y) + \ ((x) % (y) * 10 / (y) >= 5 ? 1 : 0)) #define ROUND1(x, y) ((x) / (y) + ((x) % (y) ? 1 : 0)) @@ -1237,7 +1236,7 @@ static int dsi_host_init(struct device *dev, struct dw_dsi *dsi) host->dev = dev; host->ops = &dsi_host_ops; - mipi->max_tx_esc_clk = 10; + mipi->max_tx_esc_clk = 10 * 1000000UL; mipi->vc = 0; mipi->color_mode = DSI_24BITS_1; mipi->clk_post_adjust = 120; diff --git a/drivers/staging/hikey9xx/gpu/kirin_drm_dss.c b/drivers/staging/hikey9xx/gpu/kirin_drm_dss.c index c47d860f4697..62ac1a0648cc 100644 --- a/drivers/staging/hikey9xx/gpu/kirin_drm_dss.c +++ b/drivers/staging/hikey9xx/gpu/kirin_drm_dss.c @@ -167,8 +167,8 @@ static int dss_power_up(struct dss_crtc *acrtc) dss_inner_clk_common_enable(acrtc); dpe_interrupt_mask(acrtc); dpe_interrupt_clear(acrtc); - dpe_irq_enable(acrtc); - dpe_interrupt_unmask(acrtc); + //dpe_irq_enable(acrtc); + //dpe_interrupt_unmask(acrtc); ctx->power_on = true; return 0; diff --git a/drivers/staging/hikey9xx/gpu/kirin_drm_overlay_utils.c b/drivers/staging/hikey9xx/gpu/kirin_drm_overlay_utils.c index 095335eba16d..917e1a7d7bdf 100644 --- a/drivers/staging/hikey9xx/gpu/kirin_drm_overlay_utils.c +++ b/drivers/staging/hikey9xx/gpu/kirin_drm_overlay_utils.c @@ -30,6 +30,7 @@ #define DSS_CHN_MAX_DEFINE (DSS_COPYBIT_MAX) +#define TIME_OUT (16) static int mid_array[DSS_CHN_MAX_DEFINE] = {0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x2, 0x1, 0x3, 0x0}; @@ -1064,6 +1065,38 @@ void hisi_dss_unflow_handler(struct dss_hw_ctx *ctx, bool unmask) outp32(dss_base + DSS_LDI0_OFFSET + LDI_CPU_ITF_INT_MSK, tmp); } +void hisi_dss_wait_for_complete(struct dss_hw_ctx *ctx, bool need_clear) +{ + void __iomem *dss_base; + u32 tmp = 0; + u32 isr_s2 = 0; + + if (!ctx) { + DRM_ERROR("ctx is NULL!\n"); + return; + } + + dss_base = ctx->base; + + do { + isr_s2 = inp32(dss_base + DSS_LDI0_OFFSET + LDI_CPU_ITF_INTS); + if (isr_s2 & BIT_VACTIVE0_END) { + DRM_DEBUG("hisi_dss_wait_for_complete exit! temp = %d\n", tmp); + if (need_clear) + outp32(dss_base + DSS_LDI0_OFFSET + LDI_CPU_ITF_INTS, BIT_VACTIVE0_END); + break; + } else { + msleep(1); + tmp++; + } + } while (tmp < TIME_OUT); + + if (tmp == TIME_OUT) { + isr_s2 = inp32(dss_base + DSS_LDI0_OFFSET + LDI_CPU_ITF_INTS); + DRM_INFO("wait vactive0_end timeout: isr_s2 = 0x%x\n", isr_s2); + } +} +#if 0 static int hisi_vactive0_start_config(struct dss_hw_ctx *ctx) { int ret = 0; @@ -1094,6 +1127,7 @@ static int hisi_vactive0_start_config(struct dss_hw_ctx *ctx) return ret; } +#endif void hisi_fb_pan_display(struct drm_plane *plane) { @@ -1109,9 +1143,6 @@ void hisi_fb_pan_display(struct drm_plane *plane) struct kirin_drm_private *priv = plane->dev->dev_private; struct kirin_fbdev *fbdev = to_kirin_fbdev(priv->fbdev); - ktime_t prepare_timestamp; - u64 vsync_timediff; - bool afbcd = false; bool mmu_enable = true; dss_rect_ltrb_t rect; @@ -1164,26 +1195,7 @@ void hisi_fb_pan_display(struct drm_plane *plane) vbp = mode->vtotal - mode->vsync_end; vsw = mode->vsync_end - mode->vsync_start; - vsync_timediff = (uint64_t)(mode->hdisplay + hbp + hfp + hsw) * - (mode->vdisplay + vbp + vfp + vsw) * - 1000000000UL / (adj_mode->clock * 1000); - - prepare_timestamp = ktime_get(); - - if ((ktime_to_ns(prepare_timestamp) > ktime_to_ns(ctx->vsync_timestamp)) && - (ktime_to_ns(prepare_timestamp) - ktime_to_ns(ctx->vsync_timestamp) < (vsync_timediff - 2000000)) && - (ktime_to_ns(ctx->vsync_timestamp_prev) != ktime_to_ns(ctx->vsync_timestamp))) { - DRM_DEBUG("vsync_timediff=%llu, timestamp_diff=%llu!\n", - vsync_timediff, ktime_to_ns(prepare_timestamp) - ktime_to_ns(ctx->vsync_timestamp)); - } else { - DRM_DEBUG("vsync_timediff=%llu.\n", vsync_timediff); - - if (hisi_vactive0_start_config(ctx) != 0) { - DRM_ERROR("hisi_vactive0_start_config failed!\n"); - return; - } - } - ctx->vsync_timestamp_prev = ctx->vsync_timestamp; + hisi_dss_wait_for_complete(ctx, true); hisi_dss_mctl_mutex_lock(ctx); hisi_dss_aif_ch_config(ctx, chn_idx); @@ -1198,9 +1210,8 @@ void hisi_fb_pan_display(struct drm_plane *plane) hisi_dss_mctl_sys_config(ctx, chn_idx); hisi_dss_mctl_mutex_unlock(ctx); - hisi_dss_unflow_handler(ctx, true); - enable_ldi(acrtc); + hisi_dss_wait_for_complete(ctx, false); } void hisi_dss_online_play(struct drm_plane *plane, drm_dss_layer_t *layer) @@ -1213,9 +1224,6 @@ void hisi_dss_online_play(struct drm_plane *plane, drm_dss_layer_t *layer) struct dss_crtc *acrtc = aplane->acrtc; struct dss_hw_ctx *ctx = acrtc->ctx; - ktime_t prepare_timestamp; - u64 vsync_timediff; - bool afbcd = false; bool mmu_enable = true; dss_rect_ltrb_t rect; @@ -1249,28 +1257,7 @@ void hisi_dss_online_play(struct drm_plane *plane, drm_dss_layer_t *layer) vfp = mode->vsync_start - mode->vdisplay; vbp = mode->vtotal - mode->vsync_end; vsw = mode->vsync_end - mode->vsync_start; - - vsync_timediff = (uint64_t)(mode->hdisplay + hbp + hfp + hsw) * - (mode->vdisplay + vbp + vfp + vsw) * - 1000000000UL / (adj_mode->clock * 1000); - - prepare_timestamp = ktime_get(); - - if ((ktime_to_ns(prepare_timestamp) > ktime_to_ns(ctx->vsync_timestamp)) && - (ktime_to_ns(prepare_timestamp) - ktime_to_ns(ctx->vsync_timestamp) < (vsync_timediff - 2000000)) && - (ktime_to_ns(ctx->vsync_timestamp_prev) != ktime_to_ns(ctx->vsync_timestamp))) { - DRM_DEBUG("vsync_timediff=%llu, timestamp_diff=%llu!\n", - vsync_timediff, ktime_to_ns(prepare_timestamp) - ktime_to_ns(ctx->vsync_timestamp)); - } else { - DRM_DEBUG("vsync_timediff=%llu.\n", vsync_timediff); - - if (hisi_vactive0_start_config(ctx) != 0) { - DRM_ERROR("hisi_vactive0_start_config failed!\n"); - return; - } - } - - ctx->vsync_timestamp_prev = ctx->vsync_timestamp; + hisi_dss_wait_for_complete(ctx, true); hisi_dss_mctl_mutex_lock(ctx); hisi_dss_aif_ch_config(ctx, chn_idx); @@ -1285,7 +1272,6 @@ void hisi_dss_online_play(struct drm_plane *plane, drm_dss_layer_t *layer) hisi_dss_mctl_sys_config(ctx, chn_idx); hisi_dss_mctl_mutex_unlock(ctx); - hisi_dss_unflow_handler(ctx, true); - enable_ldi(acrtc); + hisi_dss_wait_for_complete(ctx, false); } -- 2.26.2