From: Matthias Kaehlcke <mka@chromium.org>
To: Pradeep P V K <ppvk@codeaurora.org>
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 <subhashj@codeaurora.org>
Subject: Re: [RFC v6 1/2] mmc: sdhci-msm: Add interconnect bus bandwidth scaling support
Date: Mon, 23 Mar 2020 11:49:36 -0700 [thread overview]
Message-ID: <20200323184936.GC204494@google.com> (raw)
In-Reply-To: <1584973502-14775-2-git-send-email-ppvk@codeaurora.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 <stummala@codeaurora.org>
> Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
> Co-developed-by: Subhash Jadavani <subhashj@codeaurora.org>
> Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
> Co-developed-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>
> Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>
> Co-developed-by: Pradeep P V K <ppvk@codeaurora.org>
> Signed-off-by: Pradeep P V K <ppvk@codeaurora.org>
> ---
>
> 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);
next prev parent reply other threads:[~2020-03-23 18:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-23 14:25 [RFC v6 0/2] Add SDHC interconnect bandwidth scaling Pradeep P V K
2020-03-23 14:25 ` [RFC v6 1/2] mmc: sdhci-msm: Add interconnect bus bandwidth scaling support Pradeep P V K
2020-03-23 18:49 ` Matthias Kaehlcke [this message]
2020-03-23 14:25 ` [RFC v6 2/2] dt-bindings: mmc: sdhci-msm: Add interconnect BW scaling strings Pradeep P V K
2020-03-26 9:22 ` [RFC v6 0/2] Add SDHC interconnect bandwidth scaling Rajendra Nayak
2020-03-26 18:33 ` Saravana Kannan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200323184936.GC204494@google.com \
--to=mka@chromium.org \
--cc=adrian.hunter@intel.com \
--cc=agross@kernel.org \
--cc=asutoshd@codeaurora.org \
--cc=bjorn.andersson@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=georgi.djakov@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc-owner@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=ppvk@codeaurora.org \
--cc=rampraka@codeaurora.org \
--cc=robh+dt@kernel.org \
--cc=sayalil@codeaurora.org \
--cc=sboyd@kernel.org \
--cc=stummala@codeaurora.org \
--cc=subhashj@codeaurora.org \
--cc=ulf.hansson@linaro.org \
--cc=vbadigan@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.