From patchwork Fri Sep 8 13:48:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Srinivas, Vidya" X-Patchwork-Id: 9944249 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2E59860224 for ; Fri, 8 Sep 2017 13:40:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20BC128739 for ; Fri, 8 Sep 2017 13:40:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 154B02873C; Fri, 8 Sep 2017 13:40:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EE90728727 for ; Fri, 8 Sep 2017 13:39:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 852A96EBA9; Fri, 8 Sep 2017 13:39:59 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2481C6EBA9 for ; Fri, 8 Sep 2017 13:39:58 +0000 (UTC) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Sep 2017 06:39:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.42,361,1500966000"; d="scan'208"; a="1216338583" Received: from vsrini4-ubuntu-intel.iind.intel.com ([10.223.25.59]) by fmsmga002.fm.intel.com with ESMTP; 08 Sep 2017 06:39:49 -0700 From: Vidya Srinivas To: intel-gfx@lists.freedesktop.org Date: Fri, 8 Sep 2017 19:18:55 +0530 Message-Id: <1504878535-28667-1-git-send-email-vidya.srinivas@intel.com> X-Mailer: git-send-email 1.9.1 Cc: Vidya Srinivas Subject: [Intel-gfx] [PATCH] drm/i915: Enable scanline read for gen9 dsi X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Uma Shankar For gen9 platforms, dsi timings are driven from port instead of pipe (unlike ddi). Thus, we can't rely on pipe registers to get the timing information. Even scanline register read will not be functional. This is causing vblank evasion logic to fail since it relies on scanline, causing atomic update failure warnings. This patch uses pipe framestamp and current timestamp registers to calculate scanline. This is an indirect way to get the scanline. It helps resolve atomic update failure for gen9 dsi platforms. Signed-off-by: Uma Shankar Signed-off-by: Chandra Konduru Signed-off-by: Vidya Srinivas --- drivers/gpu/drm/i915/i915_drv.h | 2 ++ drivers/gpu/drm/i915/i915_irq.c | 5 +++++ drivers/gpu/drm/i915/i915_reg.h | 3 +++ drivers/gpu/drm/i915/intel_dsi.c | 46 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index d07d110..4213b54 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -4077,6 +4077,8 @@ void intel_sbi_write(struct drm_i915_private *dev_priv, u16 reg, u32 value, u32 vlv_flisdsi_read(struct drm_i915_private *dev_priv, u32 reg); void vlv_flisdsi_write(struct drm_i915_private *dev_priv, u32 reg, u32 val); +u32 bxt_dsi_get_scanline(struct intel_crtc *crtc); + /* intel_dpio_phy.c */ void bxt_port_to_phy_channel(struct drm_i915_private *dev_priv, enum port port, enum dpio_phy *phy, enum dpio_channel *ch); diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index 5d391e6..31aa7f0 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c @@ -781,6 +781,7 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc) struct drm_vblank_crtc *vblank; enum pipe pipe = crtc->pipe; int position, vtotal; + enum transcoder cpu_transcoder; if (!crtc->active) return -1; @@ -792,6 +793,10 @@ static int __intel_get_crtc_scanline(struct intel_crtc *crtc) if (mode->flags & DRM_MODE_FLAG_INTERLACE) vtotal /= 2; + cpu_transcoder = crtc->config->cpu_transcoder; + if (IS_BROXTON(dev_priv) && transcoder_is_dsi(cpu_transcoder)) + return bxt_dsi_get_scanline(crtc); + if (IS_GEN2(dev_priv)) position = I915_READ_FW(PIPEDSL(pipe)) & DSL_LINEMASK_GEN2; else diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 9a73ea0..54582de 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -8802,6 +8802,9 @@ enum skl_power_gate { #define MIPIO_TXESC_CLK_DIV2 _MMIO(0x160008) #define GLK_TX_ESC_CLK_DIV2_MASK 0x3FF +#define BXT_TIMESTAMP_CTR _MMIO(0x44070) +#define BXT_PIPE_FRMTMSTMP_A _MMIO(0x70048) + /* BXT MIPI clock controls */ #define BXT_MAX_VAR_OUTPUT_KHZ 39500 diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c index 2a0f5d3..d145ba4 100644 --- a/drivers/gpu/drm/i915/intel_dsi.c +++ b/drivers/gpu/drm/i915/intel_dsi.c @@ -1621,6 +1621,52 @@ static int intel_dsi_get_modes(struct drm_connector *connector) return 1; } +/* + * For Gen9 DSI, pipe scanline register will not + * work to get the scanline since the timings + * are driven from the PORT (unlike DDI encoders). + * This function will use Framestamp and current + * timestamp registers to calculate the scanline. + */ +u32 bxt_dsi_get_scanline(struct intel_crtc *crtc) +{ + struct drm_device *dev = crtc->base.dev; + struct drm_i915_private *dev_priv = to_i915(dev); + u32 vrefresh = crtc->base.mode.vrefresh; + u32 ulPrevTime, ulCurrTime, vtotal, ulScanlineNo2 = 0; + uint_fixed_16_16_t ulScanlineTime; + + /* + * This field provides read back of the display + * pipe frame time stamp. The time stamp value + * is sampled at every start of vertical blank. + */ + ulPrevTime = I915_READ_FW(BXT_PIPE_FRMTMSTMP_A); + + /* + * The TIMESTAMP_CTR register has the current + * time stamp value. + */ + ulCurrTime = I915_READ_FW(BXT_TIMESTAMP_CTR); + + /* The PORT for DSI will always be 0 since + * isolated PORTC cannot be enabled for Gen9 + * DSI. Hence using PORT_A i.e 0 to extract + * the VTOTAL value. + */ + vtotal = I915_READ_FW(BXT_MIPI_TRANS_VTOTAL(0)); + WARN_ON(!vtotal); + if (!vtotal) + return ulScanlineNo2; + + ulScanlineTime = div_fixed16(1000000, vtotal * vrefresh); + ulScanlineNo2 = div_round_up_u32_fixed16((ulCurrTime - ulPrevTime), + ulScanlineTime); + ulScanlineNo2 = (ulScanlineNo2 + vtotal) % vtotal; + + return ulScanlineNo2; +} + static void intel_dsi_connector_destroy(struct drm_connector *connector) { struct intel_connector *intel_connector = to_intel_connector(connector);