From patchwork Tue Aug 26 13:12:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 4781721 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5E586C0338 for ; Tue, 26 Aug 2014 13:13:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 40D1B2015E for ; Tue, 26 Aug 2014 13:13:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E399220176 for ; Tue, 26 Aug 2014 13:13:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758105AbaHZNN2 (ORCPT ); Tue, 26 Aug 2014 09:13:28 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:40248 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757970AbaHZNMy (ORCPT ); Tue, 26 Aug 2014 09:12:54 -0400 Received: by mail-wi0-f169.google.com with SMTP id n3so5159839wiv.4 for ; Tue, 26 Aug 2014 06:12:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=hsYHx+aqAdSOkX1SEadT94NzXR94SQ7zKKIZfDQdpWk=; b=mu0f2Fc+DRbJN6XySvObETT9UO8eJA9y3NmK/MB92GFP+VU3n0fRvUCOaiemfz398+ ybvwBbLomCwe1zCZJSw24KNBTVUeg5P4VXoJt0PTwp/UvTDmlN60SgMOnhFe14xU/nAz kAdEB1BZOCrPQvr8co/Ui9rd/wfk5txsIdWwnBiw2d9QP6LU0rE8C+PLulY0lZgKpn9E arRYz1V/d0U0WbSeNFQOsSxOZSk52WrGvkbZ3XqAj9jURyRC8McFYmiwKWJqQxngjmNh 78TBe0PvR8mYPbxfsFwEusKp+dxbh+BT3wZhwz4cpspcWNcBimjBFZgVpxamhlIEzL53 T+CQ== X-Received: by 10.194.92.244 with SMTP id cp20mr1286416wjb.135.1409058772991; Tue, 26 Aug 2014 06:12:52 -0700 (PDT) Received: from cizrna.lan (37-48-39-9.tmcz.cz. [37.48.39.9]) by mx.google.com with ESMTPSA id ga9sm8163291wjb.45.2014.08.26.06.12.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Aug 2014 06:12:52 -0700 (PDT) From: Tomeu Vizoso To: linux-pm@vger.kernel.org Cc: Thierry Reding , =?UTF-8?q?Terje=20Bergstr=C3=B6m?= , Stephen Warren , "Rafael J. Wysocki" , Pavel Machek , Len Brown , linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Martinez Canillas , Mikko Perttunen , Tomeu Vizoso Subject: [PATCH v4 2/3] drm/tegra: Request memory bandwidth for the display controller Date: Tue, 26 Aug 2014 15:12:07 +0200 Message-Id: <1409058728-13347-3-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1409058728-13347-1-git-send-email-tomeu.vizoso@collabora.com> References: <1409058728-13347-1-git-send-email-tomeu.vizoso@collabora.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For now the amount requested is based solely on the current mode's refresh rate. Signed-off-by: Tomeu Vizoso Acked-by: Pavel Machek --- v4: * Use vertical refresh rate when calculating the bandwidth requirement v3: * Fixed the bandwidth calculation, and have the units be mbps --- drivers/gpu/drm/tegra/dc.c | 15 +++++++++++++++ drivers/gpu/drm/tegra/drm.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c index 6553fd2..8a3fee8 100644 --- a/drivers/gpu/drm/tegra/dc.c +++ b/drivers/gpu/drm/tegra/dc.c @@ -9,6 +9,7 @@ #include #include +#include #include #include "dc.h" @@ -753,6 +754,8 @@ static void tegra_crtc_disable(struct drm_crtc *crtc) } drm_vblank_off(drm, dc->pipe); + + pm_qos_update_request(&dc->qos_request, PM_QOS_DEFAULT_VALUE); } static bool tegra_crtc_mode_fixup(struct drm_crtc *crtc, @@ -839,6 +842,7 @@ static int tegra_crtc_mode_set(struct drm_crtc *crtc, struct tegra_dc *dc = to_tegra_dc(crtc); struct tegra_dc_window window; u32 value; + unsigned long bandwidth; int err; drm_vblank_pre_modeset(crtc->dev, dc->pipe); @@ -879,6 +883,12 @@ static int tegra_crtc_mode_set(struct drm_crtc *crtc, if (err < 0) dev_err(dc->dev, "failed to enable root plane\n"); + bandwidth = window.stride[0] * window.dst.h * 8; + bandwidth *= drm_mode_vrefresh(mode); + bandwidth /= 1024 * 1024; + + pm_qos_update_request(&dc->qos_request, bandwidth); + return 0; } @@ -1499,6 +1509,9 @@ static int tegra_dc_probe(struct platform_device *pdev) return err; } + pm_qos_add_request(&dc->qos_request, PM_QOS_MEMORY_BANDWIDTH, + PM_QOS_DEFAULT_VALUE); + platform_set_drvdata(pdev, dc); return 0; @@ -1509,6 +1522,8 @@ static int tegra_dc_remove(struct platform_device *pdev) struct tegra_dc *dc = platform_get_drvdata(pdev); int err; + pm_qos_remove_request(&dc->qos_request); + err = host1x_client_unregister(&dc->client); if (err < 0) { dev_err(&pdev->dev, "failed to unregister host1x client: %d\n", diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h index e89c70f..a99e533d 100644 --- a/drivers/gpu/drm/tegra/drm.h +++ b/drivers/gpu/drm/tegra/drm.h @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -120,6 +121,8 @@ struct tegra_dc { struct drm_pending_vblank_event *event; const struct tegra_dc_soc_info *soc; + + struct pm_qos_request qos_request; }; static inline struct tegra_dc *