Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5342744yba; Mon, 13 May 2019 09:15:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzEWGsWLtMJ4JgQAGN10z2yFMB71UNJBi/QIWHyK84zLn6VEPJhdyyO/cS7wj/KlwUQRb9+ X-Received: by 2002:a17:902:8ec6:: with SMTP id x6mr31033725plo.123.1557764108804; Mon, 13 May 2019 09:15:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557764108; cv=none; d=google.com; s=arc-20160816; b=vVaDvDp1iKABhtoQw1SiyjgHbuJgznlID5ZJcB7ErGTcWHyelJ+s0muVKrv+2LYPOs 5QMozNrUGf9zxMrcLlQdqkib0UT20rrEwNRiKuWa1kTLtfqZhBr41RibNLiVMx3U0jLw rKCDWzNgKV4wCXRGVk59CeS8NEVGCuo7ejhxcZXw1DHgfH7pfHMMAy5dJ9qb8oEGoITO 97bu3XaD4MloCNxUayI5sbel2xAcwc/2odaNJh+ercnmaaWz2YYX2fU7xGkyf9H/i7tR xfCo1G/awNuuwVGt1oT7cjSr20G5yzlRXvvmko4OvCnAXjsdnEweRFLIQD4lyHXfJ+nY LCCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=z7VBKyem/uSAaxPxkBQdn6zwT3GuO3CSomgcGPmQg0w=; b=wTgQ6eOmpxtDfOiO7hdHQALGVbfRQpn4IPHhvsxT+WrXEdFLi7MekrzLArm1o3iKVS u0ElsH4SHFwJ2WyPWs+xcb/C/Y+ZSgkYZMdSRHH3FvgSzVsflrkP8bFe0ZYJ1amAGUlQ v/4qsbzmBgixgiMRwE5eWbi9NwjpYyg1XVuEqG4JAfkZ8e3dZhBeqatGWt+H+YOAEpIE EoHhttFlvf9WJ/PTpNVExN30RMw/kuM1mSWXeLpWUio5hfYLBIGUzfgjvD3sUQj73kKl KxPv/IiHrWrcfCGw60GxfViVOGR2MRQmuUOk6KL/cHfb/c/5zIuH5n1Hda93etF/ZptX pSrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@poorly.run header.s=google header.b=MUHLKhpG; 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 61si1544986plb.80.2019.05.13.09.14.52; Mon, 13 May 2019 09:15:08 -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=@poorly.run header.s=google header.b=MUHLKhpG; 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 S1730850AbfEMOrZ (ORCPT + 99 others); Mon, 13 May 2019 10:47:25 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:44006 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729308AbfEMOrY (ORCPT ); Mon, 13 May 2019 10:47:24 -0400 Received: by mail-qk1-f196.google.com with SMTP id z6so7302763qkl.10 for ; Mon, 13 May 2019 07:47:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=z7VBKyem/uSAaxPxkBQdn6zwT3GuO3CSomgcGPmQg0w=; b=MUHLKhpGkekM6pDH/oO6xNv4KfE8YOxtxR+E3TJSMvW7RgITDPa4f8RH0qR2GKCRVA QVKjrk8kct3oRAtv2HaVGpt0SOvm0cqqG43sPHK8vZAR+8yRaux7EBKy0pErU/Es8VG3 ujs70I0x04BU9xfCahT4akeHjdvTdlhQq2wZbCGeR+TB1yS3cPv6FgY83divtaKR47+8 tGtcrVc8wjB9yetqXXX8T3gofGSyLLne3rwsiQgVy1uy08lxnejO11GPYgoPgKzf5jEg 5ABodOHZIeSAnKQlFc7z4WGjJDTS7CdfBQaBHzl0B0iRW0HOE/TeSWrDYW+Gki6T+xDz 576Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=z7VBKyem/uSAaxPxkBQdn6zwT3GuO3CSomgcGPmQg0w=; b=i3swV3muEteZsap4JBQrNCzbeaK9wt5exKq14I4ynwD/k8MHNhwDct0dj/weoHC++6 tVKHEUBtiiIQPmQnUsFFyS26xtnv/SaQ+tKkD+DqhTn7Kqz7UxHpwhjHnBTxdkZfrv26 i0kZCQsuOYXxjmWgRYk6ZGAIV9WOoSMH3xdZwcwNVB322mZxaHHllB1rb3+gQg5TTxZN tDQ5DEL/DNZY18pkCqMsTK9iEV2KNAXnSN3by3AnZTTJp9CwWgom4WiaeDoRYTwfY8NW h+cSsc9DzKDyoIfKASM2bue8s/NnAjRaVjwvPFOhEvXP4hFfxMRXvblYMZNVYpPfO3IT V8fA== X-Gm-Message-State: APjAAAUAVr5kBTTiCEUbfSZ8B/+7MIJHGwaO0QhYjzjIHiwX6txmGITZ 8LKvP+qQfyZ6/sFqZBXgym5J4Q== X-Received: by 2002:a37:9fcf:: with SMTP id i198mr22654938qke.49.1557758843565; Mon, 13 May 2019 07:47:23 -0700 (PDT) Received: from localhost ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id l16sm6610039qtj.60.2019.05.13.07.47.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 May 2019 07:47:23 -0700 (PDT) Date: Mon, 13 May 2019 10:47:22 -0400 From: Sean Paul To: Rob Clark Cc: dri-devel@lists.freedesktop.org, Jayant Shekhar , Sravanthi Kollukuduru , Rob Clark , Sean Paul , David Airlie , Daniel Vetter , Jordan Crouse , Abhinav Kumar , Stephen Boyd , Jeykumar Sankaran , linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/5] drm/msm/dpu: Integrate interconnect API in MDSS Message-ID: <20190513144722.GO17077@art_vandelay> References: <20190508204219.31687-1-robdclark@gmail.com> <20190508204219.31687-3-robdclark@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190508204219.31687-3-robdclark@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 08, 2019 at 01:42:12PM -0700, Rob Clark wrote: > From: Jayant Shekhar > > 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) > > Changes in v7: > - Fixed a typo > > Signed-off-by: Sravanthi Kollukuduru > Signed-off-by: Jayant Shekhar > Signed-off-by: Rob Clark > --- > 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 7316b4ab1b85..e3c56ccd7357 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_irq_controller { > unsigned long enabled_mask; > struct irq_domain *domain; > @@ -21,8 +25,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)) of_icc_get can also return NULL, it looks like we also want to guard against this case and keep num_paths == 0. > + 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 void dpu_mdss_irq(struct irq_desc *desc) > { > struct dpu_mdss *dpu_mdss = irq_desc_get_handler_data(desc); > @@ -134,7 +160,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) > @@ -147,12 +177,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; > } > > @@ -163,6 +196,7 @@ static void dpu_mdss_destroy(struct drm_device *dev) > struct dpu_mdss *dpu_mdss = to_dpu_mdss(priv->mdss); > struct dss_module_power *mp = &dpu_mdss->mp; > int irq; > + int i; > > pm_runtime_suspend(dev->dev); > pm_runtime_disable(dev->dev); > @@ -172,6 +206,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; > @@ -211,6 +248,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) { > @@ -232,14 +273,14 @@ int dpu_mdss_init(struct drm_device *dev) > irq_set_chained_handler_and_data(irq, dpu_mdss_irq, > dpu_mdss); > > + 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: > -- > 2.20.1 > -- Sean Paul, Software Engineer, Google / Chromium OS