Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp320387imu; Tue, 22 Jan 2019 19:45:58 -0800 (PST) X-Google-Smtp-Source: ALg8bN59UrmxMJjiOsY46sbj+NOvSW2YwL+n7Zu+83tZMCdgqd0z70yLqLPo8zmr+YMAtWJI61C9 X-Received: by 2002:a62:ae04:: with SMTP id q4mr637442pff.126.1548215158588; Tue, 22 Jan 2019 19:45:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548215158; cv=none; d=google.com; s=arc-20160816; b=Sda0/4gNDMdcIC4KEh4yrVpYC4jv+wt7r/yjuDiNH272R5DOiv7pqsNMzLpi/ryg0l 5fcEdrFBjI6efUpUlnRp0Iis4v+0NFgwSACmiilBoLku27tk68d0ESFNETqtc5O6RYFH uu5vfg8vs8b9ggf2dmTjyOxjsfKNm87lX6QVNg5u2OKEHQIAcQ6WUOcDFj/bz1gKWidZ 6MSie+WHl1Hw6GrV45NMjkMGiCWpMhHyarO7du9XBqCfYfCDEmLg6fjTJpPjZOzPTjkS mK6yulcp9Opb0MSszfd8DnCoCkfseBcAutlgZ/SqWRY31jENsHa6xwQGbGRdBzfxsN0u ZaPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature:dkim-signature; bh=1b5pUC0HJN5BC8Xk9WqiWs2Smu1MxfMh3L79hrPR63A=; b=NGFxw7tA+tOrcpMBvi5FueITprO7xXQgozhyz/WDLER4otsNMMqGpnYIoaSO0mu1bj VndcgKGBf02D4TkizwuxYkGGjv8p3KmTqcp2EH4zarMKOmRqQEvkJeqwGgYOsdAG69fN 3NIPdllAxkj6kPclhKx9j2OLcZK84Rp397SfMrynrczZUzQ7aeSmRU8iEVBPrKlFvKqE v8uxYPNmVvD3s5hWcc/U6gwln0xStGUpxIwoPYJLBjhiTEqDm84xMHKvgG28/s0lotdW bdaQRu5r8lQSVUTDaQ0Msve8PXrF7PaJccnAxcGtkG3a4jJH+MFZTTUBRMf5UyJx3mIL M8tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=GxqqT8EX; dkim=pass header.i=@codeaurora.org header.s=default header.b="K/MjS8zV"; 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 i2si18246551pgl.153.2019.01.22.19.45.43; Tue, 22 Jan 2019 19:45:58 -0800 (PST) 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=GxqqT8EX; dkim=pass header.i=@codeaurora.org header.s=default header.b="K/MjS8zV"; 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 S1727111AbfAWDnC (ORCPT + 99 others); Tue, 22 Jan 2019 22:43:02 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:40114 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726908AbfAWDnC (ORCPT ); Tue, 22 Jan 2019 22:43:02 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C3A00608FF; Wed, 23 Jan 2019 03:43:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1548214980; bh=ZrP/Y7lBLhkjsadzCULKT03Ig7VjHn9+uilYIUUhdeY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GxqqT8EXT0KBvss3UDkJ1rJHyKG8gfw443zsdDoJwk6FeZqHulstCbJds5EIpp9dV Qv5zYrR8qCnTWNdiwSCeHS6ItetFpmLx/bg13kteNECrssx8+w6ziy80SOhZweL123 9YrPVZMnGeFeugueLOnR5Am6hMIC9eUs6Vo+aZX4= 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.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.0 Received: from jshekhar-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jshekhar@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id E27686079C; Wed, 23 Jan 2019 03:42:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1548214979; bh=ZrP/Y7lBLhkjsadzCULKT03Ig7VjHn9+uilYIUUhdeY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K/MjS8zVE9H1dTsCUl72UsWuh9bZ08qenDkIL2WFk7uRSchZJBXV5960bTA+zmMWH 166LG/weXvyyNC8lhAlUYSZfaFjdcQGxsFaN6TTvbM9Sw8sUw8x7EmBvxQEjw4e+yg YjB2RBBkBHs4Rr3CXVKRIj+wxkjUMhRyCVHP410E= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E27686079C 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=jshekhar@codeaurora.org From: Jayant Shekhar To: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, devicetree@vger.kernel.org Cc: Jayant Shekhar , linux-kernel@vger.kernel.org, robdclark@gmail.com, seanpaul@chromium.org, hoegsberg@chromium.org, abhinavk@codeaurora.org, jsanka@codeaurora.org, chandanu@codeaurora.org, nganji@codeaurora.org, Sravanthi Kollukuduru1 Subject: [v6 2/3] drm/msm/dpu: Integrate interconnect API in MDSS Date: Wed, 23 Jan 2019 09:12:34 +0530 Message-Id: <1548214955-19692-3-git-send-email-jshekhar@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1548214955-19692-1-git-send-email-jshekhar@codeaurora.org> References: <1548214955-19692-1-git-send-email-jshekhar@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The interconnect framework is designed to provide a standard kernel interface to control the settings of the interconnects on a SoC. The interconnect API uses a consumer/provider-based model, where the providers are the interconnect buses and the consumers could be various drivers. MDSS is one of the interconnect consumers which uses the interconnect APIs to get the path between endpoints and set its bandwidth requirement for the given interconnected path. Changes in v2: - Remove error log and unnecessary check (Jordan Crouse) Changes in v3: - Code clean involving variable name change, removal of extra paranthesis and variables (Matthias Kaehlcke) Changes in v4: - Add comments, spacings, tabs, proper port name and icc macro (Georgi Djakov) Changes in v5: - Commit text and parenthesis alignment (Georgi Djakov) Changes in v6: - Change to new icc_set API's (Doug Anderson) Signed-off-by: Sravanthi Kollukuduru1 Signed-off-by: Jayant Shekhar --- drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c | 49 +++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c index 38576f8..38daf8a 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c @@ -4,11 +4,15 @@ */ #include "dpu_kms.h" +#include #define to_dpu_mdss(x) container_of(x, struct dpu_mdss, base) #define HW_INTR_STATUS 0x0010 +/* Max BW defined in KBps */ +#define MAX_BW 6800000 + struct dpu_mdss { struct msm_mdss base; void __iomem *mmio; @@ -16,8 +20,30 @@ struct dpu_mdss { u32 hwversion; struct dss_module_power mp; struct dpu_irq_controller irq_controller; + struct icc_path *path[2]; + u32 num_paths; }; +static int dpu_mdss_parse_data_bus_icc_path(struct drm_device *dev, + struct dpu_mdss *dpu_mdss) +{ + struct icc_path *path0 = of_icc_get(dev->dev, "mdp0-mem"); + struct icc_path *path1 = of_icc_get(dev->dev, "mdp1-mem"); + + if (IS_ERR(path0)) + return PTR_ERR(path0); + + dpu_mdss->path[0] = path0; + dpu_mdss->num_paths = 1; + + if (!IS_ERR(path1)) { + dpu_mdss->path[1] = path1; + dpu_mdss->num_paths++; + } + + return 0; +} + static irqreturn_t dpu_mdss_irq(int irq, void *arg) { struct dpu_mdss *dpu_mdss = arg; @@ -127,7 +153,11 @@ static int dpu_mdss_enable(struct msm_mdss *mdss) { struct dpu_mdss *dpu_mdss = to_dpu_mdss(mdss); struct dss_module_power *mp = &dpu_mdss->mp; - int ret; + int ret, i; + u64 avg_bw = dpu_mdss->num_paths ? MAX_BW / dpu_mdss->num_paths : 0; + + for (i = 0; i < dpu_mdss->num_paths; i++) + icc_set_bw(dpu_mdss->path[i], avg_bw, kBps_to_icc(MAX_BW)); ret = msm_dss_enable_clk(mp->clk_config, mp->num_clk, true); if (ret) @@ -140,12 +170,15 @@ static int dpu_mdss_disable(struct msm_mdss *mdss) { struct dpu_mdss *dpu_mdss = to_dpu_mdss(mdss); struct dss_module_power *mp = &dpu_mdss->mp; - int ret; + int ret, i; ret = msm_dss_enable_clk(mp->clk_config, mp->num_clk, false); if (ret) DPU_ERROR("clock disable failed, ret:%d\n", ret); + for (i = 0; i < dpu_mdss->num_paths; i++) + icc_set_bw(dpu_mdss->path[i], 0, 0); + return ret; } @@ -155,6 +188,7 @@ static void dpu_mdss_destroy(struct drm_device *dev) struct msm_drm_private *priv = dev->dev_private; struct dpu_mdss *dpu_mdss = to_dpu_mdss(priv->mdss); struct dss_module_power *mp = &dpu_mdss->mp; + int i; pm_runtime_disable(dev->dev); _dpu_mdss_irq_domain_fini(dpu_mdss); @@ -162,6 +196,9 @@ static void dpu_mdss_destroy(struct drm_device *dev) msm_dss_put_clk(mp->clk_config, mp->num_clk); devm_kfree(&pdev->dev, mp->clk_config); + for (i = 0; i < dpu_mdss->num_paths; i++) + icc_put(dpu_mdss->path[i]); + if (dpu_mdss->mmio) devm_iounmap(&pdev->dev, dpu_mdss->mmio); dpu_mdss->mmio = NULL; @@ -200,6 +237,10 @@ int dpu_mdss_init(struct drm_device *dev) } dpu_mdss->mmio_len = resource_size(res); + ret = dpu_mdss_parse_data_bus_icc_path(dev, dpu_mdss); + if (ret) + return ret; + mp = &dpu_mdss->mp; ret = msm_dss_parse_clock(pdev, mp); if (ret) { @@ -221,14 +262,14 @@ int dpu_mdss_init(struct drm_device *dev) goto irq_error; } + priv->mdss = &dpu_mdss->base; + pm_runtime_enable(dev->dev); pm_runtime_get_sync(dev->dev); dpu_mdss->hwversion = readl_relaxed(dpu_mdss->mmio); pm_runtime_put_sync(dev->dev); - priv->mdss = &dpu_mdss->base; - return ret; irq_error: -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project