linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sumit Semwal <sumit.semwal@linaro.org>
To: Mark Brown <broonie@kernel.org>
Cc: agross@kernel.org, Bjorn Andersson <bjorn.andersson@linaro.org>,
	lgirdwood@gmail.com, robh+dt@kernel.org,
	Nisha Kumari <nishakumari@codeaurora.org>,
	linux-arm-msm@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>,
	devicetree@vger.kernel.org, kgunda@codeaurora.org,
	Rajendra Nayak <rnayak@codeaurora.org>
Subject: Re: [PATCH v4 5/5] regulator: qcom: labibb: Add SC interrupt handling
Date: Wed, 17 Jun 2020 17:36:43 +0530	[thread overview]
Message-ID: <CAO_48GGY2TRVPXFVCvo9fEoknw65sz9BrL-mp+SZ=_EAo88t-A@mail.gmail.com> (raw)
In-Reply-To: <20200602122205.GF5684@sirena.org.uk>

Hi Mark,

On Tue, 2 Jun 2020 at 17:52, Mark Brown <broonie@kernel.org> wrote:
>
> On Tue, Jun 02, 2020 at 03:39:24PM +0530, Sumit Semwal wrote:
>
> >  static int qcom_labibb_regulator_enable(struct regulator_dev *rdev)
> >  {
> > -     return regulator_enable_regmap(rdev);
> > +     int ret;
> > +     struct labibb_regulator *reg = rdev_get_drvdata(rdev);
> > +
> > +     ret = regulator_enable_regmap(rdev);
> > +     if (ret >= 0)
> > +             reg->enabled = true;
>
> Can we not read the register we just wrote to here?
As I mentioned in the other patch, it seems there is a (noticeable)
delay in getting the value to reflect in this register for IBB.

Also, from the notes from the downstream driver (also copied below),
it seems like during short circuit there is another protection system
that can cause the registers to be cleared, hence the need to track
the current state in software.

>
> > +     /*
> > +      * The SC(short circuit) fault would trigger PBS(Portable Batch
> > +      * System) to disable regulators for protection. This would
> > +      * cause the SC_DETECT status being cleared so that it's not
> > +      * able to get the SC fault status.
> > +      * Check if the regulator is enabled in the driver but
> > +      * disabled in hardware, this means a SC fault had happened
> > +      * and SCP handling is completed by PBS.
> > +      */
> > +     if (!in_sc_err) {
> > +
> > +             reg = labibb_reg->base + REG_LABIBB_ENABLE_CTL;
> > +
> > +             ret = regmap_read_poll_timeout(labibb_reg->regmap,
> > +                                     reg, val,
> > +                                     !(val & LABIBB_CONTROL_ENABLE),
> > +                                     POLLING_SCP_DONE_INTERVAL_US,
> > +                                     POLLING_SCP_TIMEOUT);
>
> Why do we need a timeout here?
IMHO, This seems to be the time required by the PBS to actually
disable the regulator? If the PBS is not able to disable the
regulator, then it points to a more serious problem?
I'm sorry, that's just my understanding based on the downstream driver
:/ - not much input is available from the QC teams about it.

>
> > +                                             NULL);
> > +             regulator_unlock(labibb_reg->rdev);
> > +     }
> > +     return IRQ_HANDLED;
>
> This returns IRQ_HANDLED even if we didn't detect an interrupt source...
> Especially given the need to check to see if the regulator was turned
> off by the hardware it seems like there must be some false positives.
Right - I'm not sure what else can I do here.
>
> > +     } else {
> > +             ret = devm_request_threaded_irq(reg->dev,
> > +                                             sc_irq,
> > +                                             NULL, labibb_sc_err_handler,
> > +                                             IRQF_ONESHOT,
> > +                                             "sc-err", reg);
>
> This looks like we're requesting the interrupt before we register the
> regulator which means the interrupt might fire without the regulator
> being there.  The order of registration should be reversed.

Agreed, and will update in the next version.

Best,
Sumit.

  reply	other threads:[~2020-06-17 12:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-02 10:09 [PATCH v4 0/5] Qualcomm labibb regulator driver Sumit Semwal
2020-06-02 10:09 ` [PATCH v4 1/5] regulator: Allow regulators to verify enabled during enable() Sumit Semwal
2020-06-02 11:24   ` Mark Brown
2020-06-02 11:57     ` Sumit Semwal
2020-06-18 23:44   ` Bjorn Andersson
2020-06-02 10:09 ` [PATCH v4 2/5] dt-bindings: regulator: Add labibb regulator Sumit Semwal
2020-06-09 22:52   ` Rob Herring
2020-06-02 10:09 ` [PATCH v4 3/5] arm64: dts: qcom: pmi8998: Add nodes for LAB and IBB regulators Sumit Semwal
2020-06-02 10:09 ` [PATCH v4 4/5] regulator: qcom: Add labibb driver Sumit Semwal
2020-06-02 11:32   ` Mark Brown
2020-06-02 12:10     ` Sumit Semwal
2020-06-02 12:25       ` Mark Brown
2020-06-17 11:42         ` Sumit Semwal
2020-06-17 11:47           ` Mark Brown
2020-06-17 11:57             ` Sumit Semwal
2020-06-17 12:06               ` Mark Brown
2020-06-17 12:09                 ` Sumit Semwal
2020-06-17 12:40                   ` Mark Brown
2020-06-02 10:09 ` [PATCH v4 5/5] regulator: qcom: labibb: Add SC interrupt handling Sumit Semwal
2020-06-02 12:22   ` Mark Brown
2020-06-17 12:06     ` Sumit Semwal [this message]
2020-06-17 12:38       ` Mark Brown

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='CAO_48GGY2TRVPXFVCvo9fEoknw65sz9BrL-mp+SZ=_EAo88t-A@mail.gmail.com' \
    --to=sumit.semwal@linaro.org \
    --cc=agross@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kgunda@codeaurora.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nishakumari@codeaurora.org \
    --cc=rnayak@codeaurora.org \
    --cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).