From patchwork Fri Mar 10 04:32:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 9614801 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 9FA6F60415 for ; Fri, 10 Mar 2017 04:51:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92271286C0 for ; Fri, 10 Mar 2017 04:51:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86E6E286EF; Fri, 10 Mar 2017 04:51:48 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 1A373286C0 for ; Fri, 10 Mar 2017 04:51:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DEDD86EDCC; Fri, 10 Mar 2017 04:50:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-x231.google.com (mail-qk0-x231.google.com [IPv6:2607:f8b0:400d:c09::231]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7BBB36ED9C for ; Fri, 10 Mar 2017 04:49:25 +0000 (UTC) Received: by mail-qk0-x231.google.com with SMTP id 1so151777955qkl.3 for ; Thu, 09 Mar 2017 20:49:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4q/KL3rH1YoXL78fScfOQI31gy0WL6n9nwB4ig+off8=; b=UJ6JG7rVPSTYKYOeFnozOYx7OIPBqK6rEvoN4Yo7qrjeFqlKqrAZFzUAzqq91HCxk1 kQGGA0bIl42/f4X4O52e5HY5awJbbFKuzGzwV71vuXTAfu1Ogwr5TS8Et2obi8AbBCfE Uw0+gYxAvDoL4ccu22Zg6LalfSOK4QpmoFD40= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4q/KL3rH1YoXL78fScfOQI31gy0WL6n9nwB4ig+off8=; b=gx67tTAJJ880ZXAYAMeaty8zx72un4zkIgKtWNdq2zzCwDIAWnF44CWQXdsi0mVtdN 5BUF7dWgdcfBecHDD+8UxLly/AjeQdNfx9lvpdDutcLMUZd9QmdTEvjJMuJxdEOyi3qN h1nHkFVcyvbocdp3QtjksPi+XDISyvSNCJCgW91mjvQEJ6YTIU57Ys0xnoCgbNeuqOip UsJEuYwxoqpRi+Hb9XXbcVFz4qqD4+yMmcckyiGUMJ1dwJVkwfzC6j3xrii4LFqYqtzi jg5yT60mYG4Q5bFssCp96Oy8lKxHYMjhR8uY4ybCMJyRNTeAuIjKvVUS9puDgFBSFROZ 9VLQ== X-Gm-Message-State: AMke39mRjjvnSP+iXcMEAYqJJgjV0mCR0Ivv25O4Zn6e3MA/aqw0oyfF8bMrKpjPV/b+3/6i X-Received: by 10.200.53.69 with SMTP id z5mr18131557qtb.120.1489120805053; Thu, 09 Mar 2017 20:40:05 -0800 (PST) Received: from boxwood.roam.corp.google.com (cpe-75-189-128-87.nc.res.rr.com. [75.189.128.87]) by smtp.gmail.com with ESMTPSA id n19sm5697731qtn.35.2017.03.09.20.40.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Mar 2017 20:40:04 -0800 (PST) From: Sean Paul To: linux-rockchip@lists.infradead.org, dri-devel@lists.freedesktop.org Subject: [PATCH 27/41] drm/rockchip: Restore psr->state when enable/disable psr failed Date: Thu, 9 Mar 2017 23:32:42 -0500 Message-Id: <20170310043305.17216-28-seanpaul@chromium.org> X-Mailer: git-send-email 2.12.0.246.ga2ecc84866-goog In-Reply-To: <20170310043305.17216-1-seanpaul@chromium.org> References: <20170310043305.17216-1-seanpaul@chromium.org> Cc: zain wang , Tomeu Vizoso , Douglas Anderson , Tomasz Figa , Lin Huang , Yakir Yang , linux-arm-kernel@lists.infradead.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: zain wang If we failed disable psr, it would hang the display until next psr cycle coming. So we should restore psr->state when it failed. Cc: Tomasz Figa Signed-off-by: zain wang Signed-off-by: Douglas Anderson Signed-off-by: Sean Paul --- drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 4 +++- drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 12 ++++++------ drivers/gpu/drm/rockchip/rockchip_drm_psr.c | 20 +++++++++++++------- drivers/gpu/drm/rockchip/rockchip_drm_psr.h | 2 +- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c index dcf39ea0d14b..35ea04ff4078 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c @@ -156,8 +156,10 @@ int analogix_dp_disable_psr(struct device *dev) psr_vsc.DB1 = 0; ret = drm_dp_dpcd_writeb(&dp->aux, DP_SET_POWER, DP_SET_POWER_D0); - if (ret != 1) + if (ret != 1) { dev_err(dp->dev, "Failed to set DP Power0 %d\n", ret); + return ret; + } return analogix_dp_send_psr_spd(dp, &psr_vsc, false); } diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c index b6c6d6d09d7e..0614d32c5435 100644 --- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c @@ -76,7 +76,7 @@ struct rockchip_dp_device { struct analogix_dp_plat_data plat_data; }; -static void analogix_dp_psr_set(struct drm_encoder *encoder, bool enabled) +static int analogix_dp_psr_set(struct drm_encoder *encoder, bool enabled) { struct rockchip_dp_device *dp = to_dp(encoder); struct drm_crtc *crtc = dp->encoder.crtc; @@ -84,12 +84,12 @@ static void analogix_dp_psr_set(struct drm_encoder *encoder, bool enabled) int ret; if (!analogix_dp_psr_enabled(dp->dev)) - return; + return 0; dev_dbg(dp->dev, "%s PSR...\n", enabled ? "enable" : "disable"); if (!crtc) - return; + return -EINVAL; vact_end = crtc->mode.vtotal - crtc->mode.vsync_start + crtc->mode.vdisplay; @@ -97,13 +97,13 @@ static void analogix_dp_psr_set(struct drm_encoder *encoder, bool enabled) PSR_WAIT_LINE_FLAG_TIMEOUT_MS); if (ret) { dev_err(dp->dev, "line flag interrupt did not arrive\n"); - return; + return -ETIMEDOUT; } if (enabled) - analogix_dp_enable_psr(dp->dev); + return analogix_dp_enable_psr(dp->dev); else - analogix_dp_disable_psr(dp->dev); + return analogix_dp_disable_psr(dp->dev); } static int rockchip_dp_pre_init(struct rockchip_dp_device *dp) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_psr.c b/drivers/gpu/drm/rockchip/rockchip_drm_psr.c index b339ca943139..9376f4396b6b 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_psr.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_psr.c @@ -36,7 +36,7 @@ struct psr_drv { struct delayed_work flush_work; - void (*set)(struct drm_encoder *encoder, bool enable); + int (*set)(struct drm_encoder *encoder, bool enable); }; static struct psr_drv *find_psr_by_crtc(struct drm_crtc *crtc) @@ -93,19 +93,25 @@ static void psr_set_state_locked(struct psr_drv *psr, enum psr_state state) return; } - psr->state = state; - /* Actually commit the state change to hardware */ - switch (psr->state) { + switch (state) { case PSR_ENABLE: - psr->set(psr->encoder, true); + if (psr->set(psr->encoder, true)) + return; break; case PSR_DISABLE: case PSR_FLUSH: - psr->set(psr->encoder, false); + if (psr->set(psr->encoder, false)) + return; break; + + default: + pr_err("%s: Unknown state %d\n", __func__, state); + return; } + + psr->state = state; } static void psr_set_state(struct psr_drv *psr, enum psr_state state) @@ -229,7 +235,7 @@ EXPORT_SYMBOL(rockchip_drm_psr_flush_all); * Zero on success, negative errno on failure. */ int rockchip_drm_psr_register(struct drm_encoder *encoder, - void (*psr_set)(struct drm_encoder *, bool enable)) + int (*psr_set)(struct drm_encoder *, bool enable)) { struct rockchip_drm_private *drm_drv = encoder->dev->dev_private; struct psr_drv *psr; diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_psr.h b/drivers/gpu/drm/rockchip/rockchip_drm_psr.h index b1ea0155e57c..06537ee27565 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_psr.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_psr.h @@ -22,7 +22,7 @@ int rockchip_drm_psr_activate(struct drm_encoder *encoder); int rockchip_drm_psr_deactivate(struct drm_encoder *encoder); int rockchip_drm_psr_register(struct drm_encoder *encoder, - void (*psr_set)(struct drm_encoder *, bool enable)); + int (*psr_set)(struct drm_encoder *, bool enable)); void rockchip_drm_psr_unregister(struct drm_encoder *encoder); #endif /* __ROCKCHIP_DRM_PSR__ */