From patchwork Fri Mar 10 04:32:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 9615061 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 E498660415 for ; Fri, 10 Mar 2017 05:25:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6470286E3 for ; Fri, 10 Mar 2017 05:25:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB001286F1; Fri, 10 Mar 2017 05:25:32 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4BB4E286E3 for ; Fri, 10 Mar 2017 05:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=/ZLeB4muXmUUvFrmsLTb3uWYVZPavZoIK6ZACsw2U/Y=; b=Va/LRJqE6NkgMwK4XRKDA5Zi0F yXs5xYZPPSP0sdH6JZWAUQLYG/dMe4j78qIBni31R2maSD7tEGPNHB8dIdcdsEp3ykmCRc+iuTZlG 4MPoQgm4c9rZZULMwoqp9UBUKCsHswwyGg3yRkcf2hynta+bEjso1DLwXCOfWQMVuGbdMdeVinN93 MPHxbb59GAsOPZ4w9NeTSoKvHR7xp6K43XSIUByBX/zkX3gMITz0Uwad+1Qf2UWYAnl4vf8/hRgwY QOmTEt7ehXFg2Ab19YUzzBqnDUgO0wGGtDxVEtX3tibeqX3F9KIc0IDY2UQ2E5An1Pp+ixZT9nMGJ D9zje/6w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cmD3R-0000yK-Cg; Fri, 10 Mar 2017 05:25:29 +0000 Received: from mail-qk0-x22b.google.com ([2607:f8b0:400d:c09::22b]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cmCN8-0004c7-1X for linux-arm-kernel@lists.infradead.org; Fri, 10 Mar 2017 04:41:49 +0000 Received: by mail-qk0-x22b.google.com with SMTP id y76so152260903qkb.0 for ; Thu, 09 Mar 2017 20:41: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=+Ps/V/8lQxUgA4M8H10UKEp+Xi8f9OejsKFMnnZtZ7M=; b=iFlotXa4KZSH8Y7SaR5HDz5jwBvB7LY7g/9XYZGgohjDAM+GkAvSrWQmFAhnbBtaS9 /BP0GEy+XPQF/6THGHeF+SharchG4AwDWvOcZB85it5qgAFgvPyn5t5y8vyjn4vvfhGL gQAExtgMEOINfeH/Ye2l/pJzt1/518cOxuLE8= 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=+Ps/V/8lQxUgA4M8H10UKEp+Xi8f9OejsKFMnnZtZ7M=; b=qiJJR3JfS4sROAIjdaBrNw936u9ygScuDl/Zn3hBU5BwAISotwPQaf1WrkVEzLy4bk BU8DG5ew6MKMVliAv0ZevpI5os+rfPVipf4dSzHIKcPhxazZI7qrNA5erczhbVOBwGvO GyFLWXZyiYmGUv9Fjb03/Oa5G2cZw9FdtzFThK0dDf5mz1H09h0x3Ml1Jy5R57BOPgSy /LjbsAj9NuS9quwPtQ7eqpfx7sDnRPha8uxT3wMCQRwJAkuzEfa1irV80rCqKnnfW/lE r0LMyZHCjaE1ru41smpn1gABftpwrgDNzmTN6qzAEu4gAvONBJUVI+55SQAkpizpvCTN /bnA== X-Gm-Message-State: AMke39nv3STjvh21a5Cf10A+1+8TW6nI5lkRo/dvLjQt7UxFQfDrvZR0ZDK+OIzvV9zhW0i9 X-Received: by 10.55.46.198 with SMTP id u189mr17036610qkh.88.1489120884970; Thu, 09 Mar 2017 20:41:24 -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.41.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Mar 2017 20:41:24 -0800 (PST) From: Sean Paul To: linux-rockchip@lists.infradead.org, dri-devel@lists.freedesktop.org Subject: [PATCH 33/41] drm/rockchip: Disable VOP windows when PSR is active Date: Thu, 9 Mar 2017 23:32:48 -0500 Message-Id: <20170310043305.17216-34-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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170309_204146_268624_E067E362 X-CRM114-Status: GOOD ( 16.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: zain wang , Heiko Stuebner , David Airlie , Douglas Anderson , Tomasz Figa , Sean Paul , "Kristian H . Kristensen" , linux-arm-kernel@lists.infradead.org, Mark Yao MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: zain wang We do not have to drive the display when it is in PSR mode, so we can save some power by disabling active VOP windows, until a next PSR flush turns them back on. Cc: Kristian H. Kristensen Signed-off-by: zain wang Signed-off-by: Tomasz Figa Signed-off-by: Douglas Anderson Signed-off-by: Sean Paul --- drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 34 +++++++++++++++++-------- drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 1 + drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 31 ++++++++++++++++++++++ 3 files changed, 55 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c index 0614d32c5435..de23cc6fd05d 100644 --- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c @@ -91,19 +91,31 @@ static int analogix_dp_psr_set(struct drm_encoder *encoder, bool enabled) if (!crtc) return -EINVAL; - vact_end = crtc->mode.vtotal - crtc->mode.vsync_start + crtc->mode.vdisplay; + if (enabled) { + vact_end = crtc->mode.vtotal - crtc->mode.vsync_start + + crtc->mode.vdisplay; + ret = rockchip_drm_wait_line_flag(dp->encoder.crtc, vact_end, + PSR_WAIT_LINE_FLAG_TIMEOUT_MS); + if (ret) { + dev_err(dp->dev, "line flag interrupt did not arrive\n"); + return -ETIMEDOUT; + } - ret = rockchip_drm_wait_line_flag(dp->encoder.crtc, vact_end, - PSR_WAIT_LINE_FLAG_TIMEOUT_MS); - if (ret) { - dev_err(dp->dev, "line flag interrupt did not arrive\n"); - return -ETIMEDOUT; + ret = analogix_dp_enable_psr(dp->dev); + if (ret) { + dev_err(dp->dev, "failed to enable psr %d\n", ret); + return ret; + } + rockchip_drm_set_win_enabled(crtc, false); + } else { + rockchip_drm_set_win_enabled(crtc, true); + ret = analogix_dp_disable_psr(dp->dev); + if (ret) { + dev_err(dp->dev, "failed to disable psr %d\n", ret); + return ret; + } } - - if (enabled) - return analogix_dp_enable_psr(dp->dev); - else - return analogix_dp_disable_psr(dp->dev); + return 0; } static int rockchip_dp_pre_init(struct rockchip_dp_device *dp) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h index a966d1d37378..be4ad9b670cf 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h @@ -65,5 +65,6 @@ void rockchip_drm_dma_detach_device(struct drm_device *drm_dev, struct device *dev); int rockchip_drm_wait_line_flag(struct drm_crtc *crtc, unsigned int line_num, unsigned int mstimeout); +void rockchip_drm_set_win_enabled(struct drm_crtc *ctrc, bool enabled); #endif /* _ROCKCHIP_DRM_DRV_H_ */ diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index 879efc3a6c67..e90a32ee5a36 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -89,6 +89,9 @@ #define VOP_WIN_GET_YRGBADDR(vop, win) \ vop_readl(vop, win->base + win->phy->yrgb_mst.offset) +#define VOP_WIN_TO_INDEX(vop_win) \ + ((vop_win) - (vop_win)->vop->win) + #define to_vop(x) container_of(x, struct vop, crtc) #define to_vop_win(x) container_of(x, struct vop_win, base) @@ -108,6 +111,8 @@ struct vop { struct drm_device *drm_dev; bool is_enabled; + unsigned int win_enabled; + struct completion dsp_hold_completion; /* protected by dev->event_lock */ @@ -562,6 +567,27 @@ static int vop_enable(struct drm_crtc *crtc) return ret; } +void rockchip_drm_set_win_enabled(struct drm_crtc *crtc, bool enabled) +{ + struct vop *vop = to_vop(crtc); + int i; + + spin_lock(&vop->reg_lock); + + for (i = 0; i < vop->data->win_size; i++) { + struct vop_win *vop_win = &vop->win[i]; + const struct vop_win_data *win = vop_win->data; + + VOP_WIN_SET(vop, win, enable, + enabled && (vop->win_enabled & BIT(i))); + } + + vop_cfg_done(vop); + + spin_unlock(&vop->reg_lock); +} +EXPORT_SYMBOL(rockchip_drm_set_win_enabled); + static void vop_crtc_disable(struct drm_crtc *crtc) { struct vop *vop = to_vop(crtc); @@ -581,6 +607,7 @@ static void vop_crtc_disable(struct drm_crtc *crtc) spin_lock(&vop->reg_lock); VOP_WIN_SET(vop, win, enable, 0); + vop->win_enabled &= ~BIT(i); spin_unlock(&vop->reg_lock); } @@ -700,6 +727,7 @@ static void vop_plane_atomic_disable(struct drm_plane *plane, spin_lock(&vop->reg_lock); VOP_WIN_SET(vop, win, enable, 0); + vop->win_enabled &= ~BIT(VOP_WIN_TO_INDEX(vop_win)); spin_unlock(&vop->reg_lock); } @@ -807,6 +835,8 @@ static void vop_plane_atomic_update(struct drm_plane *plane, } VOP_WIN_SET(vop, win, enable, 1); + vop->win_enabled |= BIT(VOP_WIN_TO_INDEX(vop_win)); + spin_unlock(&vop->reg_lock); } @@ -1443,6 +1473,7 @@ static int vop_initial(struct vop *vop) const struct vop_win_data *win = &vop_data->win[i]; VOP_WIN_SET(vop, win, enable, 0); + vop->win_enabled &= ~BIT(i); } vop_cfg_done(vop);