linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <treding@nvidia.com>
To: Sumit Gupta <sumitg@nvidia.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>,
	krzysztof.kozlowski@linaro.org, dmitry.osipenko@collabora.com,
	rafael@kernel.org, jonathanh@nvidia.com, robh+dt@kernel.org,
	lpieralisi@kernel.org, linux-kernel@vger.kernel.org,
	linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org,
	devicetree@vger.kernel.org, linux-pci@vger.kernel.org,
	mmaddireddy@nvidia.com, kw@linux.com, bhelgaas@google.com,
	vidyas@nvidia.com, sanjayc@nvidia.com, ksitaraman@nvidia.com,
	ishah@nvidia.com, bbasu@nvidia.com
Subject: Re: [Patch v2 7/9] cpufreq: tegra194: add OPP support and set bandwidth
Date: Mon, 27 Feb 2023 13:44:21 +0100	[thread overview]
Message-ID: <Y/ylpaJLMOE6zY8C@orome> (raw)
In-Reply-To: <df054fae-5195-1ef8-c72e-e5afe8d901d3@nvidia.com>

[-- Attachment #1: Type: text/plain, Size: 2186 bytes --]

On Thu, Feb 23, 2023 at 03:06:26PM +0530, Sumit Gupta wrote:
> 
> 
> On 22/02/23 09:33, Viresh Kumar wrote:
> > External email: Use caution opening links or attachments
> > 
> > 
> > On 20-02-23, 19:35, Sumit Gupta wrote:
> > > +static int tegra_cpufreq_set_bw(struct cpufreq_policy *policy, unsigned long freq_khz)
> > > +{
> > > +     struct dev_pm_opp *opp;
> > > +     struct device *dev;
> > > +     int ret;
> > > +
> > > +     dev = get_cpu_device(policy->cpu);
> > > +     if (!dev)
> > > +             return -ENODEV;
> > > +
> > > +     opp = dev_pm_opp_find_freq_exact(dev, freq_khz * KHZ, true);
> > > +     if (IS_ERR(opp))
> > > +             return PTR_ERR(opp);
> > > +
> > > +     ret = dev_pm_opp_set_opp(dev, opp);
> > > +     dev_pm_opp_put(opp);
> > 
> > What about dev_pm_opp_set_rate() instead ?
> > 
> > > +     return ret;
> > > +}
> > 
> > --
> > viresh
> 
> Tried using it and got below crash. It seems to be coming because we don't
> have clocks property within CPU node for SoC's having BPMP-FW.
> 
>  Unable to handle kernel NULL pointer dereference at virtual address
> 000000000000002e
>  ....
>  Call trace:
>   clk_round_rate+0x38/0xd8
>   dev_pm_opp_set_rate+0xe4/0x1a8
>   tegra194_cpufreq_set_target+0x74/0x88
>   __cpufreq_driver_target+0x154/0x250
>   cpufreq_online+0x7b4/0x9ac

Can you try to find out what exactly is happening here? The clock
framework should be able to deal with NULL clock pointers just fine.
Although, looking at the OPP table code, it seems like we don't use
clk_get_optional(), so opp_table->clk may end up being a pointer-
encoded error. Perhaps we need something like this:

--- >8 ---
diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index e87567dbe99f..d7baeb6ac697 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -1397,6 +1397,7 @@ static struct opp_table *_update_opp_table_clk(struct device *dev,
 		 * frequency in opp->rates and also parse the entries in DT.
 		 */
 		opp_table->clk_count = 1;
+		opp_table->clk = NULL;
 
 		dev_dbg(dev, "%s: Couldn't find clock: %d\n", __func__, ret);
 		return opp_table;
--- >8 ---

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2023-02-27 12:44 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-20 14:05 [Patch v2 0/9] Tegra234 Memory interconnect support Sumit Gupta
2023-02-20 14:05 ` [Patch v2 1/9] firmware: tegra: add function to get BPMP data Sumit Gupta
2023-02-20 14:05 ` [Patch v2 2/9] memory: tegra: add interconnect support for DRAM scaling in Tegra234 Sumit Gupta
2023-03-19 15:19   ` Krzysztof Kozlowski
2023-02-20 14:05 ` [Patch v2 3/9] memory: tegra: add mc clients for Tegra234 Sumit Gupta
2023-03-19 15:19   ` Krzysztof Kozlowski
2023-02-20 14:05 ` [Patch v2 4/9] memory: tegra: add software mc clients in Tegra234 Sumit Gupta
2023-03-19 15:19   ` Krzysztof Kozlowski
2023-02-20 14:05 ` [Patch v2 5/9] dt-bindings: tegra: add icc ids for dummy MC clients Sumit Gupta
2023-02-20 14:05 ` [Patch v2 6/9] arm64: tegra: Add cpu OPP tables and interconnects property Sumit Gupta
2023-02-20 14:05 ` [Patch v2 7/9] cpufreq: tegra194: add OPP support and set bandwidth Sumit Gupta
2023-02-22  4:03   ` Viresh Kumar
2023-02-23  9:36     ` Sumit Gupta
2023-02-27 12:44       ` Thierry Reding [this message]
2023-02-28  1:18         ` Viresh Kumar
2023-02-20 14:05 ` [Patch v2 8/9] memory: tegra: make cpu cluster bw request a multiple of mc channels Sumit Gupta
2023-03-19 15:20   ` Krzysztof Kozlowski
2023-02-20 14:05 ` [Patch v2 9/9] PCI: tegra194: add interconnect support in Tegra234 Sumit Gupta
2023-03-06 15:05 ` [Patch v2 0/9] Tegra234 Memory interconnect support Krzysztof Kozlowski
2023-03-06 15:07   ` Krzysztof Kozlowski
2023-03-06 20:43     ` Sumit Gupta
2023-03-07  9:21       ` Krzysztof Kozlowski
2023-03-06 20:19   ` Sumit Gupta

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=Y/ylpaJLMOE6zY8C@orome \
    --to=treding@nvidia.com \
    --cc=bbasu@nvidia.com \
    --cc=bhelgaas@google.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.osipenko@collabora.com \
    --cc=ishah@nvidia.com \
    --cc=jonathanh@nvidia.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=ksitaraman@nvidia.com \
    --cc=kw@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mmaddireddy@nvidia.com \
    --cc=rafael@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sanjayc@nvidia.com \
    --cc=sumitg@nvidia.com \
    --cc=vidyas@nvidia.com \
    --cc=viresh.kumar@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).