Received: by 10.213.65.68 with SMTP id h4csp785473imn; Tue, 13 Mar 2018 23:09:30 -0700 (PDT) X-Google-Smtp-Source: AG47ELu55r6WEtlsj0aylJ1Vq1AbEwamXddtqbAVZwgKlh1zK+gC/llSHH6Cp03JJyP3A+hVucWt X-Received: by 10.98.200.131 with SMTP id i3mr3202981pfk.40.1521007770563; Tue, 13 Mar 2018 23:09:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521007770; cv=none; d=google.com; s=arc-20160816; b=SFVFDlZYypHQrhJwP3iQeSENRB6RnYlD9zuKVVvBq7zTLRFhw/k7dvl0ynxSRweN6p fLcmkprNp2MXJhS0gNmwFz3zA6Aqr1s1JOS9XO7RL9nnOmgfBC0B4BbcMpInz9HG3wVc Jf4xvjJSUzmoBjkHfrFF5k6Vxm75q891Dfi+uspH5jmDx2N5ldXBcfuY5A2vjnIbY8un hg4+ydhrhbfW0fzKziZUErh5040wAxB5uN7pgnsKj4oOd9JvIKhT2E9j6NTr0LJPY5FY mlozz/Hqk7fcsEMMrHdiORtwUug+pXgzghKriLpZOC/1zv7jn+dWV6TU/+BYIKS+aUau 1w5A== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=d/pS44k9+CRvN0mxXg8rYJc/E6xlUQ71l2/Bicex/oc=; b=Oim8qS4kDnhGIIl+KW7Xx3tbDzkXRlNuRAadip6BQMvdanqWpN5eUYIkgLHYBpsK8b dpFE429/mZmMHPc6uAGKiuoiszGAcw8db0gqGdSsVNI2mR9Fwm1cEbztjVN/JF+/+o8U T1ZbG6sBBGsKca0ZYfWxCJ1OLDm9vFt6d7ldxcOzNG4sHacGcYeRGKrnGOIHJu7ehrvG jtt4vJq/Mfyha3e144MZ/QRn7TBnuVOWvBs8YMpdNG+7trfemFuut3ImC9jRk2+7p6VV isLiX2Tjy4tatNhaejBdUu7SE9dZ0qBwQMd333ZwderogdtOD8oTGXEooEc4oAkquyVk tYQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Qa82zv8o; dkim=pass header.i=@codeaurora.org header.s=default header.b=AKgbFJ0z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u10si1355534pgr.247.2018.03.13.23.09.15; Tue, 13 Mar 2018 23:09:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Qa82zv8o; dkim=pass header.i=@codeaurora.org header.s=default header.b=AKgbFJ0z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753388AbeCNGID (ORCPT + 99 others); Wed, 14 Mar 2018 02:08:03 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:57958 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753320AbeCNGH7 (ORCPT ); Wed, 14 Mar 2018 02:07:59 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 10E2760854; Wed, 14 Mar 2018 06:07:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521007679; bh=gD7jWa/TV6mrUV9BR/mjq0ZygJxQiWT9BeYRTmQSpi0=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=Qa82zv8oE6Xv9zaz4sDy9eSQlau50uhN9aZvJzfRpwhFJ7OAsdhpMqHVhQdOlMZY1 UqsBAMgiyVOegHs3PHg3LrfDyJJPZBJ6miE+Xz4Gezecd0Z+ZKDkUP24wI6PjfFzPM kgR9UvNcjMBiRdVB8FkxeKqjOELJlmvcJMQGHeJo= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [192.168.1.84] (unknown [182.71.117.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: architt@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3968A60590; Wed, 14 Mar 2018 06:07:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521007674; bh=gD7jWa/TV6mrUV9BR/mjq0ZygJxQiWT9BeYRTmQSpi0=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=AKgbFJ0zGfQ28FnCZuXyrGIvSyERPrjR2rHebgyuJBeIXgY8X/WPOyJ7VcYvDiJEZ DJLVYPtNNQ8t8dYrL4kncpuLa/+EfG+90vAbYYKapvLaTQc8YisPddw1ZXs00f9piV fnr/bNJ9gqh5q5kneOlUjOIDdCChLsuWoPG/TUas= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3968A60590 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=architt@codeaurora.org Subject: Re: [PATCH v5 10/36] drm/bridge: analogix_dp: Retry bridge enable when it failed To: Enric Balletbo i Serra , inki.dae@samsung.com, thierry.reding@gmail.com, hjc@rock-chips.com, seanpaul@chromium.org, airlied@linux.ie, tfiga@chromium.org, heiko@sntech.de Cc: dri-devel@lists.freedesktop.org, dianders@chromium.org, a.hajda@samsung.com, ykk@rock-chips.com, kernel@collabora.com, m.szyprowski@samsung.com, linux-samsung-soc@vger.kernel.org, jy0922.shim@samsung.com, rydberg@bitmath.org, krzk@kernel.org, linux-rockchip@lists.infradead.org, kgene@kernel.org, linux-input@vger.kernel.org, orjan.eide@arm.com, wxt@rock-chips.com, jeffy.chen@rock-chips.com, linux-arm-kernel@lists.infradead.org, mark.yao@rock-chips.com, wzz@rock-chips.com, hl@rock-chips.com, jingoohan1@gmail.com, sw0312.kim@samsung.com, linux-kernel@vger.kernel.org, kyungmin.park@samsung.com, Laurent.pinchart@ideasonboard.com, kuankuan.y@gmail.com, hshi@chromium.org, =?UTF-8?Q?St=c3=a9phane_Marchesin?= References: <20180309222327.18689-1-enric.balletbo@collabora.com> <20180309222327.18689-11-enric.balletbo@collabora.com> From: Archit Taneja Message-ID: <1c2ca228-4f3b-d582-6258-8608c7f731f1@codeaurora.org> Date: Wed, 14 Mar 2018 11:37:36 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180309222327.18689-11-enric.balletbo@collabora.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Saturday 10 March 2018 03:53 AM, Enric Balletbo i Serra wrote: > From: zain wang > > When we enable bridge failed, we have to retry it, otherwise we would get > the abnormal display. > Reviewed-by: Archit Taneja Thanks, Archit > Cc: Stéphane Marchesin > Signed-off-by: zain wang > Signed-off-by: Sean Paul > Signed-off-by: Thierry Escande > Reviewed-by: Andrzej Hajda > Signed-off-by: Enric Balletbo i Serra > Tested-by: Marek Szyprowski > --- > > drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 65 +++++++++++++++++----- > drivers/gpu/drm/bridge/analogix/analogix_dp_core.h | 3 +- > drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c | 5 +- > 3 files changed, 56 insertions(+), 17 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > index ea7a80a989c6..c81733b8185e 100644 > --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > @@ -43,8 +43,10 @@ struct bridge_init { > struct device_node *node; > }; > > -static void analogix_dp_init_dp(struct analogix_dp_device *dp) > +static int analogix_dp_init_dp(struct analogix_dp_device *dp) > { > + int ret; > + > analogix_dp_reset(dp); > > analogix_dp_swreset(dp); > @@ -56,10 +58,13 @@ static void analogix_dp_init_dp(struct analogix_dp_device *dp) > analogix_dp_enable_sw_function(dp); > > analogix_dp_config_interrupt(dp); > - analogix_dp_init_analog_func(dp); > + ret = analogix_dp_init_analog_func(dp); > + if (ret) > + return ret; > > analogix_dp_init_hpd(dp); > analogix_dp_init_aux(dp); > + return 0; > } > > static int analogix_dp_detect_hpd(struct analogix_dp_device *dp) > @@ -918,7 +923,7 @@ static irqreturn_t analogix_dp_irq_thread(int irq, void *arg) > return IRQ_HANDLED; > } > > -static void analogix_dp_commit(struct analogix_dp_device *dp) > +static int analogix_dp_commit(struct analogix_dp_device *dp) > { > int ret; > > @@ -928,11 +933,10 @@ static void analogix_dp_commit(struct analogix_dp_device *dp) > DRM_ERROR("failed to disable the panel\n"); > } > > - ret = readx_poll_timeout(analogix_dp_train_link, dp, ret, !ret, 100, > - DP_TIMEOUT_TRAINING_US * 5); > + ret = analogix_dp_train_link(dp); > if (ret) { > dev_err(dp->dev, "unable to do link train, ret=%d\n", ret); > - return; > + return ret; > } > > analogix_dp_enable_scramble(dp, 1); > @@ -953,6 +957,7 @@ static void analogix_dp_commit(struct analogix_dp_device *dp) > dp->psr_enable = analogix_dp_detect_sink_psr(dp); > if (dp->psr_enable) > analogix_dp_enable_sink_psr(dp); > + return 0; > } > > /* > @@ -1149,12 +1154,9 @@ static void analogix_dp_bridge_pre_enable(struct drm_bridge *bridge) > DRM_ERROR("failed to setup the panel ret = %d\n", ret); > } > > -static void analogix_dp_bridge_enable(struct drm_bridge *bridge) > +static int analogix_dp_set_bridge(struct analogix_dp_device *dp) > { > - struct analogix_dp_device *dp = bridge->driver_private; > - > - if (dp->dpms_mode == DRM_MODE_DPMS_ON) > - return; > + int ret; > > pm_runtime_get_sync(dp->dev); > > @@ -1162,11 +1164,46 @@ static void analogix_dp_bridge_enable(struct drm_bridge *bridge) > dp->plat_data->power_on(dp->plat_data); > > phy_power_on(dp->phy); > - analogix_dp_init_dp(dp); > + > + ret = analogix_dp_init_dp(dp); > + if (ret) > + goto out_dp_init; > + > + ret = analogix_dp_commit(dp); > + if (ret) > + goto out_dp_init; > + > enable_irq(dp->irq); > - analogix_dp_commit(dp); > + return 0; > > - dp->dpms_mode = DRM_MODE_DPMS_ON; > +out_dp_init: > + phy_power_off(dp->phy); > + if (dp->plat_data->power_off) > + dp->plat_data->power_off(dp->plat_data); > + pm_runtime_put_sync(dp->dev); > + > + return ret; > +} > + > +static void analogix_dp_bridge_enable(struct drm_bridge *bridge) > +{ > + struct analogix_dp_device *dp = bridge->driver_private; > + int timeout_loop = 0; > + > + if (dp->dpms_mode == DRM_MODE_DPMS_ON) > + return; > + > + while (timeout_loop < MAX_PLL_LOCK_LOOP) { > + if (analogix_dp_set_bridge(dp) == 0) { > + dp->dpms_mode = DRM_MODE_DPMS_ON; > + return; > + } > + dev_err(dp->dev, "failed to set bridge, retry: %d\n", > + timeout_loop); > + timeout_loop++; > + usleep_range(10, 11); > + } > + dev_err(dp->dev, "too many times retry set bridge, give it up\n"); > } > > static void analogix_dp_bridge_disable(struct drm_bridge *bridge) > diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h > index 403ff853464b..769255dc6e99 100644 > --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h > +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h > @@ -19,6 +19,7 @@ > #define DP_TIMEOUT_LOOP_COUNT 100 > #define MAX_CR_LOOP 5 > #define MAX_EQ_LOOP 5 > +#define MAX_PLL_LOCK_LOOP 5 > > /* Training takes 22ms if AUX channel comm fails. Use this as retry interval */ > #define DP_TIMEOUT_TRAINING_US 22000 > @@ -197,7 +198,7 @@ void analogix_dp_set_pll_power_down(struct analogix_dp_device *dp, bool enable); > void analogix_dp_set_analog_power_down(struct analogix_dp_device *dp, > enum analog_power_block block, > bool enable); > -void analogix_dp_init_analog_func(struct analogix_dp_device *dp); > +int analogix_dp_init_analog_func(struct analogix_dp_device *dp); > void analogix_dp_init_hpd(struct analogix_dp_device *dp); > void analogix_dp_force_hpd(struct analogix_dp_device *dp); > enum dp_irq_type analogix_dp_get_irq_type(struct analogix_dp_device *dp); > diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c > index e78c861b9e06..b47c5af43560 100644 > --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c > +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c > @@ -333,7 +333,7 @@ void analogix_dp_set_analog_power_down(struct analogix_dp_device *dp, > } > } > > -void analogix_dp_init_analog_func(struct analogix_dp_device *dp) > +int analogix_dp_init_analog_func(struct analogix_dp_device *dp) > { > u32 reg; > int timeout_loop = 0; > @@ -355,7 +355,7 @@ void analogix_dp_init_analog_func(struct analogix_dp_device *dp) > timeout_loop++; > if (DP_TIMEOUT_LOOP_COUNT < timeout_loop) { > dev_err(dp->dev, "failed to get pll lock status\n"); > - return; > + return -ETIMEDOUT; > } > usleep_range(10, 20); > } > @@ -366,6 +366,7 @@ void analogix_dp_init_analog_func(struct analogix_dp_device *dp) > reg &= ~(SERDES_FIFO_FUNC_EN_N | LS_CLK_DOMAIN_FUNC_EN_N > | AUX_FUNC_EN_N); > writel(reg, dp->reg_base + ANALOGIX_DP_FUNC_EN_2); > + return 0; > } > > void analogix_dp_clear_hotplug_interrupts(struct analogix_dp_device *dp) >