mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Varadarajan Narayanan <quic_varada@quicinc.com>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: <vireshk@kernel.org>, <nm@ti.com>, <sboyd@kernel.org>,
	<robh@kernel.org>, <krzk+dt@kernel.org>, <conor+dt@kernel.org>,
	<angelogioacchino.delregno@collabora.com>, <andersson@kernel.org>,
	<konrad.dybcio@linaro.org>, <mturquette@baylibre.com>,
	<ilia.lin@kernel.org>, <rafael@kernel.org>,
	<ulf.hansson@linaro.org>, <quic_sibis@quicinc.com>,
	<quic_rjendra@quicinc.com>, <quic_rohiagar@quicinc.com>,
	<abel.vesa@linaro.org>, <otto.pflueger@abscue.de>,
	<danila@jiaxyga.com>, <quic_ipkumar@quicinc.com>,
	<luca@z3ntu.xyz>, <stephan.gerhold@kernkonzept.com>,
	<nks@flawful.org>, <linux-pm@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-arm-msm@vger.kernel.org>, <linux-clk@vger.kernel.org>
Subject: Re: [PATCH v4 01/10] soc: qcom: cpr3: Fix 'acc_desc' usage
Date: Tue, 9 Jul 2024 13:59:53 +0530	[thread overview]
Message-ID: <Zoz1AQh+6jfbgJSy@hu-varada-blr.qualcomm.com> (raw)
In-Reply-To: <bsr6l33xllblwwoa3ftbldxvqwe6tcljt3ek2petoc4hc5xgsg@b36fw3wetj5f>

On Fri, Jul 05, 2024 at 06:16:51PM +0300, Dmitry Baryshkov wrote:
> On Thu, Jul 04, 2024 at 10:30:50AM GMT, Varadarajan Narayanan wrote:
> > On Wed, Jul 03, 2024 at 01:46:54PM +0300, Dmitry Baryshkov wrote:
> > > On Wed, Jul 03, 2024 at 02:46:42PM GMT, Varadarajan Narayanan wrote:
> > > > cpr3 code assumes that 'acc_desc' is available for SoCs
> > > > implementing CPR version 4 or less. However, IPQ9574 SoC
> > > > implements CPRv4 without ACC. This causes NULL pointer accesses
> > > > resulting in crashes. Hence, check if 'acc_desc' is populated
> > > > before using it.
> > > >
> > > > Signed-off-by: Varadarajan Narayanan <quic_varada@quicinc.com>
> > > > ---
> > > > v4: Undo the acc_desc validation in probe function as that could
> > > >     affect other SoC.
> > > > ---
> > > >  drivers/pmdomain/qcom/cpr3.c | 4 ++--
> > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/pmdomain/qcom/cpr3.c b/drivers/pmdomain/qcom/cpr3.c
> > > > index c7790a71e74f..6ceb7605f84d 100644
> > > > --- a/drivers/pmdomain/qcom/cpr3.c
> > > > +++ b/drivers/pmdomain/qcom/cpr3.c
> > > > @@ -2399,12 +2399,12 @@ static int cpr_pd_attach_dev(struct generic_pm_domain *domain,
> > > >  		if (ret)
> > > >  			goto exit;
> > > >
> > > > -		if (acc_desc->config)
> > > > +		if (acc_desc && acc_desc->config)
> > > >  			regmap_multi_reg_write(drv->tcsr, acc_desc->config,
> > > >  					       acc_desc->num_regs_per_fuse);
> > > >
> > > >  		/* Enable ACC if required */
> > > > -		if (acc_desc->enable_mask)
> > > > +		if (acc_desc && acc_desc->enable_mask)
> > > >  			regmap_update_bits(drv->tcsr, acc_desc->enable_reg,
> > > >  					   acc_desc->enable_mask,
> > > >  					   acc_desc->enable_mask);
> > >
> > > Should the same fix be applied to other places which access acc_desc?
> > > For example cpr_pre_voltage() and cpr_post_voltage() which call
> > > cpr_set_acc()?
> >
> > With this patch alone, if acc_desc is NULL, cpr_probe() will fail
> > at the start itself because of this check
> >
> > 	if (!data->acc_desc && desc->cpr_type < CTRL_TYPE_CPRH)
> > 		return -EINVAL;
> >
> > After applying this patch series, cpr_probe will cross the above
> > check to accomodate IPQ9574. However, the check below will ensure
> > drv->tcsr is not initialized.
> >
> > 	if (desc->cpr_type < CTRL_TYPE_CPRH &&
> > 	    !of_device_is_compatible(dev->of_node, "qcom,ipq9574-cpr4"))
> >
> > cpr_pre_voltage() and cpr_post_voltage() call cpr_set_acc() only
> > if drv->tcsr is not NULL. Hence acc_desc need not be checked.
> >
> > Will add the check to cpr_pre_voltage() and cpr_post_voltage() if
> > you feel it will make it more robust regardless of the changes to
> > cpr_probe in future. Please let me know.
>
> Having !acc_desc check instead of the of_device_is_compatible would
> solve the issue.

Ok. Will post next version with that.

Thanks
Varada

  reply	other threads:[~2024-07-09  8:30 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-03  9:16 [PATCH v4 00/10] Enable CPR for IPQ9574 Varadarajan Narayanan
2024-07-03  9:16 ` [PATCH v4 01/10] soc: qcom: cpr3: Fix 'acc_desc' usage Varadarajan Narayanan
2024-07-03 10:46   ` Dmitry Baryshkov
2024-07-04  5:00     ` Varadarajan Narayanan
2024-07-05 15:16       ` Dmitry Baryshkov
2024-07-09  8:29         ` Varadarajan Narayanan [this message]
2024-07-03  9:16 ` [PATCH v4 02/10] cpufreq: qcom-nvmem: Add support for IPQ9574 Varadarajan Narayanan
2024-07-03 10:19   ` Viresh Kumar
2024-07-03 10:47     ` Dmitry Baryshkov
2024-07-03 11:02   ` Dmitry Baryshkov
2024-07-03  9:16 ` [PATCH v4 03/10] dt-bindings: power: rpmpd: Add IPQ9574 power domains Varadarajan Narayanan
2024-07-03  9:16 ` [PATCH v4 04/10] dt-bindings: soc: qcom: cpr3: Add bindings for IPQ9574 Varadarajan Narayanan
2024-07-04  6:35   ` Krzysztof Kozlowski
2024-07-03  9:16 ` [PATCH v4 05/10] pmdomain: qcom: rpmpd: Add IPQ9574 power domains Varadarajan Narayanan
2024-07-09  9:52   ` Konrad Dybcio
2024-07-24  4:27     ` Varadarajan Narayanan
2024-07-24  7:13       ` Dmitry Baryshkov
2024-07-03  9:16 ` [PATCH v4 06/10] dt-bindings: clock: Add CPR clock defines for IPQ9574 Varadarajan Narayanan
2024-07-03  9:16 ` [PATCH v4 07/10] clk: qcom: gcc-ipq9574: Add CPR clock definition Varadarajan Narayanan
2024-07-03  9:16 ` [PATCH v4 08/10] soc: qcom: cpr3: Add IPQ9574 definitions Varadarajan Narayanan
2024-07-03 10:49   ` Dmitry Baryshkov
2024-07-04  5:02     ` Varadarajan Narayanan
2024-07-03  9:16 ` [PATCH v4 09/10] dt-bindings: opp: v2-qcom-level: Update minItems for oloop-vadj & cloop-vadj Varadarajan Narayanan
2024-07-08 15:55   ` Rob Herring
2024-07-09  7:01     ` Varadarajan Narayanan
2024-07-09 11:28       ` Konrad Dybcio
2024-07-03  9:16 ` [PATCH v4 10/10] dts: arm64: qcom: ipq9574: Enable CPR Varadarajan Narayanan

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=Zoz1AQh+6jfbgJSy@hu-varada-blr.qualcomm.com \
    --to=quic_varada@quicinc.com \
    --cc=abel.vesa@linaro.org \
    --cc=andersson@kernel.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=conor+dt@kernel.org \
    --cc=danila@jiaxyga.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=ilia.lin@kernel.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=luca@z3ntu.xyz \
    --cc=mturquette@baylibre.com \
    --cc=nks@flawful.org \
    --cc=nm@ti.com \
    --cc=otto.pflueger@abscue.de \
    --cc=quic_ipkumar@quicinc.com \
    --cc=quic_rjendra@quicinc.com \
    --cc=quic_rohiagar@quicinc.com \
    --cc=quic_sibis@quicinc.com \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=stephan.gerhold@kernkonzept.com \
    --cc=ulf.hansson@linaro.org \
    --cc=vireshk@kernel.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

all inboxes | Powered by JetHome®