Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4014361ybb; Mon, 23 Mar 2020 11:51:50 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt/dvh7PMr5vYp5XK5Qc1KrOX8ueTJaSvR3TSgQrOrGEt6/OsFzaCFFhewOyaAwL3uwWZy6 X-Received: by 2002:a9d:247:: with SMTP id 65mr19370432otb.364.1584989509867; Mon, 23 Mar 2020 11:51:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584989509; cv=none; d=google.com; s=arc-20160816; b=YiKOSiWsrY5jSnjNWGBpwqUrNu9M/l2wdIQjFIM8pVr6R/4c5DOAhvzQrrAerKBABj yCKvv1t2rAjQuKXMqye58QEnw2EPQVPyv+tgI0dpXck7IGwZZ7Y93uk0p3WkegCUoxUJ GqEyp0iwu6AUUzgwWG8vuTQz/HHzttFhXMXM+GiokzYKwZ4Nhe8/6cdqZKuOo8qnVWRF Mky3TdjuyHrnl40sRrCz/InUWDIwc38dah+bxBZFDePD+Z7wrUdzKUoHPOZgUsAWTSQE QL22uYsMKh/tXXC5riWHBWswYZCJEKXzBpmNStLgoKYB+A/fJFJFXyyF4TQVCXACsi6z 0IXQ== 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=1J62+9HfSlkv3NzIyJlYav7hvhHpbiduAqAYuKWJ56w=; b=fJLxwLHSZIdhMNJ3SmDmINe3/w661VjqC9HSJv2xhCb2zHPiVjaxvDbOaWOI6WXBff r2qvtGSNGjYY+7htnbp+/AbX47FAJ6yqnUfsoHAJGFdLTG9q94IXPesgoxUXnwzOQRXJ FrTbqhayEk4CGTZBTkTdlHRVgkgu3Q83NkY6UZCvmC4EuK5DTphFQ+5uGq/nhSJ8Durg 8I/qe4anicCkVGZH/0Xc4g9N2YVcgMuqIm21oR5Nmd8qWL6afQAUfEPFJKi8D+z6EEd8 fNA3/mK2m/uPHiReOVKAxWY5p+8Y1e1GjsI5rIWYjxu4Uo5rCaUr9cDLYnbMmsoHcuTQ XAgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=SbC7Ih2D; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q2si2503666otg.211.2020.03.23.11.51.37; Mon, 23 Mar 2020 11:51:49 -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=@chromium.org header.s=google header.b=SbC7Ih2D; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727738AbgCWStl (ORCPT + 99 others); Mon, 23 Mar 2020 14:49:41 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:46352 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727720AbgCWStl (ORCPT ); Mon, 23 Mar 2020 14:49:41 -0400 Received: by mail-pl1-f196.google.com with SMTP id r3so6277295pls.13 for ; Mon, 23 Mar 2020 11:49:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=1J62+9HfSlkv3NzIyJlYav7hvhHpbiduAqAYuKWJ56w=; b=SbC7Ih2DUxaxGl2gtNtmOwhFbplBnLc5bk/mh3cXsvp7HOWf+H6thuWp7k6GV4SFWl 2bwkKMHcatMt3EMca3epfVROO0kjMJbZB2a4ZlHPLcwGDPucKlLBUqS/Wler1sMSZxb6 VVVdlakmG4lbqpwioWnimupGTuHz3Rjf+T2TQ= 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=1J62+9HfSlkv3NzIyJlYav7hvhHpbiduAqAYuKWJ56w=; b=HoV0B+fRNjZnfWZ/VHCDLp2xoWk7t9o+++A3FU0QPiFNf5lnwqicV/D0aL1YDyEsbk M6xjuREuay2H5LEQQUKelwhf7bnyWk4fpGjynV+qENV9mdeC/pK1+oC7ONhGxMxl8Jev eUGFXB8l7ynRuwyVFRZU7NIfXEtzf0zlZaliQ/sysId4qQGKaxhwzVkK5varEkfP9Mfu HPvHbsdXpp/LRAHZFfQMY5yBomxfb5IhIzrDpxKZG+BHJSAEe7X6zWJkL7XJyGymaiqn NsgbRk4jC2VXcIKcBno3U12z7Aycnp1NCN/KlJAhrm36Cd4z7BqnWkmOC81i0N54Xtcf h/sQ== X-Gm-Message-State: ANhLgQ32TTmfQjExfmlh2SK1ckCBdtMF17kXurnkobZmiJ3dNHxolOY6 Dz682JGWClI/y9XKxyb4r0Kjsw== X-Received: by 2002:a17:90b:4d04:: with SMTP id mw4mr821413pjb.180.1584989378516; Mon, 23 Mar 2020 11:49:38 -0700 (PDT) Received: from localhost ([2620:15c:202:1:4fff:7a6b:a335:8fde]) by smtp.gmail.com with ESMTPSA id i11sm281182pje.30.2020.03.23.11.49.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Mar 2020 11:49:37 -0700 (PDT) Date: Mon, 23 Mar 2020 11:49:36 -0700 From: Matthias Kaehlcke To: Pradeep P V K Cc: bjorn.andersson@linaro.org, adrian.hunter@intel.com, robh+dt@kernel.org, ulf.hansson@linaro.org, asutoshd@codeaurora.org, stummala@codeaurora.org, sayalil@codeaurora.org, rampraka@codeaurora.org, vbadigan@codeaurora.org, sboyd@kernel.org, georgi.djakov@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, agross@kernel.org, linux-mmc-owner@vger.kernel.org, Subhash Jadavani Subject: Re: [RFC v6 1/2] mmc: sdhci-msm: Add interconnect bus bandwidth scaling support Message-ID: <20200323184936.GC204494@google.com> References: <1584973502-14775-1-git-send-email-ppvk@codeaurora.org> <1584973502-14775-2-git-send-email-ppvk@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1584973502-14775-2-git-send-email-ppvk@codeaurora.org> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Pradeep, On Mon, Mar 23, 2020 at 07:55:01PM +0530, Pradeep P V K wrote: > Add interconnect bandwidths for SDHC driver using OPP framework that > is required by SDHC driver based on the clock frequency and bus width > of the card. Otherwise, the system clocks may run at minimum clock > speed and thus affecting the performance. > > This change is based on > [RFC] mmc: host: sdhci-msm: Use the interconnect API > (https://lkml.org/lkml/2018/10/11/499) and > > [PATCH v6] Introduce Bandwidth OPPs for interconnects > (https://lkml.org/lkml/2019/12/6/740) > > Co-developed-by: Sahitya Tummala > Signed-off-by: Sahitya Tummala > Co-developed-by: Subhash Jadavani > Signed-off-by: Subhash Jadavani > Co-developed-by: Veerabhadrarao Badiganti > Signed-off-by: Veerabhadrarao Badiganti > Co-developed-by: Pradeep P V K > Signed-off-by: Pradeep P V K > --- > > RFC v5 -> v6: > - Added new goto jump tag to put both icc paths. > - Removed bus vote data error check and added is_null check. > - Addressed minor code style comments. > > drivers/mmc/host/sdhci-msm.c | 240 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 236 insertions(+), 4 deletions(-) > > diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c > index 09ff731..469db65 100644 > --- a/drivers/mmc/host/sdhci-msm.c > +++ b/drivers/mmc/host/sdhci-msm.c > > ... > > +/* > + * Helper function to parse the exact OPP node > + * Returns OPP pointer on success else NULL on error > + */ > +static struct dev_pm_opp > + *sdhci_msm_find_opp_for_freq(struct sdhci_msm_host *msm_host, > + unsigned long bw) > +{ > + struct dev_pm_opp *opp; > + struct sdhci_host *host = mmc_priv(msm_host->mmc); > + unsigned int freq = bw; > + struct device *dev = &msm_host->pdev->dev; > + > + delete one empty line > + if (!freq) > + opp = dev_pm_opp_find_peak_bw_floor(dev, &freq); > + else > + opp = dev_pm_opp_find_peak_bw_exact(dev, freq, true); > + > + /* Max bandwidth vote */ > + if (PTR_ERR(opp) == -ERANGE && freq > sdhci_msm_get_max_clock(host)) > + opp = dev_pm_opp_find_peak_bw_ceil(dev, &bw); > + > + if (IS_ERR(opp)) { > + dev_err(dev, "Failed to find OPP for freq:%u err:%ld\n", > + freq, PTR_ERR(opp)); > + return NULL; > + } > + return opp; > +} > > ... > > +/* > + * Helper function to register for OPP and interconnect > + * frameworks. > + */ > +static struct sdhci_msm_bus_vote_data > + *sdhci_msm_bus_register(struct sdhci_msm_host *host, > + struct platform_device *pdev) > +{ > + struct sdhci_msm_bus_vote_data *vote_data; > + struct device *dev = &pdev->dev; > + int i, err; > + struct icc_path *icc_paths[BUS_INTERCONNECT_PATHS]; > + const char *path_names[] = { > + "sdhc-ddr", > + "cpu-sdhc", > + }; > + > + for (i = 0; i < BUS_INTERCONNECT_PATHS; i++) > + icc_paths[i] = of_icc_get(&pdev->dev, path_names[i]); > + > + if (!icc_paths[0] && !icc_paths[1]) { > + dev_info(&pdev->dev, "ICC DT property is missing.Skip vote!!\n"); > + return NULL; > + } > + > + for (i = 0; i < BUS_INTERCONNECT_PATHS; i++) { > + if (!icc_paths[i]) { > + dev_err(&pdev->dev, "interconnect path '%s' is not configured\n", > + path_names[i]); > + err = -EINVAL; > + goto handle_err; > + } > + if (IS_ERR(icc_paths[i])) { > + err = PTR_ERR(icc_paths[i]); > + > + if (err != -EPROBE_DEFER) > + dev_err(&pdev->dev, "interconnect path '%s' is invalid:%d\n", > + path_names[i], err); > + goto handle_err; > + } > + } > + > + err = dev_pm_opp_of_add_table(dev); > + if (err) { > + if (err == -ENODEV || err == -ENODATA) > + dev_err(dev, "OPP dt properties missing:%d\n", err); > + else > + dev_err(dev, "OPP registration failed:%d\n", err); > + goto put_icc; > + } > + > + vote_data = devm_kzalloc(dev, sizeof(*vote_data), GFP_KERNEL); > + if (!vote_data) { > + err = -ENOMEM; > + goto put_icc; > + } > + vote_data->sdhc_to_ddr = icc_paths[0]; > + vote_data->cpu_to_sdhc = icc_paths[1]; > + return vote_data; > + > +handle_err: > + if (err) { the check for 'err' is not needed, this code is only executed when an error is encountered. > + int other = (i == 0) ? 1 : 0; > + > + if (!IS_ERR_OR_NULL(icc_paths[other])) > + icc_put(icc_paths[other]); > + } > + return ERR_PTR(err); > + > +put_icc: > + if (err) { > + for (i = 0; i < BUS_INTERCONNECT_PATHS; i++) > + icc_put(icc_paths[i]); > + } > + return ERR_PTR(err); The two error paths are somewhat redundant and the 'handle_err' isn't super clear, especially since it is disconnected from the code where the error is found. You could have a single handler instead: put_icc: for (i = 0; i < BUS_INTERCONNECT_PATHS; i++) { if (!IS_ERR_OR_NULL(icc_paths[i])) icc_put(icc_paths[i]); } return ERR_PTR(err);