linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
To: AngeloGioacchino Del Regno  <angelogioacchino.delregno@somainline.org>
Cc: Andy Gross <agross@kernel.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] regulator: qcom-labibb: avoid unbalanced IRQ enable
Date: Wed, 03 Feb 2021 08:15:21 +0200	[thread overview]
Message-ID: <e949e8f7d518f86685a9281f9c9e5c80a6083108.camel@fi.rohmeurope.com> (raw)
In-Reply-To: <67c5886a-8cfd-5c1f-0bd1-8a6f259f03fb@somainline.org>

Hello Angelo,

On Tue, 2021-02-02 at 15:42 +0100, AngeloGioacchino Del Regno wrote:
> Il 02/02/21 08:36, Matti Vaittinen ha scritto:
> > If a spurious OCP IRQ occurs the isr schedules delayed work
> > but does not disable the IRQ. The delayed work assumes IRQ was
> > disabled in handler and attempts enabling it again causing
> > unbalanced enable.
> > 
> 
> You break the logic like this. Though, I also see the problem.
> It is critical for the recovery worker to be executed whenever we
> enter
> the OCP interrupt routine, as we get in there only something wrong
> happened.

Then the comment just above this check should be adjusted. It states:
/*
 * If we (unlikely) can't read this register, to prevent hardware
 * damage at all costs, we assume that the overcurrent event was
 * real; Moreover, if the status register is not signaling OCP,
 * it was a spurious event, so it's all ok.
 */

The " if the status register is not signaling OCP, it was a spurious
event, so it's all ok." is incredibly misleading. That comment combined
with comment above qcom_labibb_check_ocp_status()

 * This function checks the STATUS1 register for the VREG_OK bit: if it
is
 * set, then there is no Over-Current event.
 *
 * Returns: Zero if there is no over-current, 1 if in over-current or
 *          negative number for error

made me to _assume_ that when qcom_labibb_check_ocp_status returns zero
we have spurious event - for which just returning the IRQ_NONE should
be perfectly sane thing to do.

> Please fix this patch.
> P.S.: You can't disable irq before qcom_labibb_check_ocp_status;
>        perhaps just after it, or in the if branch before goto?

As I said, I don't have the HW or specifications or expertise with this
IC. If this was not spurious event then I don't know what is the right
thing to do. I am just shooting this blindly. Feel free to take over
this fix and also adjust the comments so that they match the HW
behaviour :)

Best Regards
	--Matti


  reply	other threads:[~2021-02-03  6:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-02  7:36 [PATCH 1/2] regulator: qcom-labibb: avoid unbalanced IRQ enable Matti Vaittinen
2021-02-02  7:37 ` [PATCH 2/2] regulator: qcom-labibb: Use disable_irq_nosync from isr Matti Vaittinen
2021-02-02 14:36   ` AngeloGioacchino Del Regno
2021-02-02 14:42 ` [PATCH 1/2] regulator: qcom-labibb: avoid unbalanced IRQ enable AngeloGioacchino Del Regno
2021-02-03  6:15   ` Matti Vaittinen [this message]
2021-02-02 16:32 ` (subset) " 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=e949e8f7d518f86685a9281f9c9e5c80a6083108.camel@fi.rohmeurope.com \
    --to=matti.vaittinen@fi.rohmeurope.com \
    --cc=agross@kernel.org \
    --cc=angelogioacchino.delregno@somainline.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.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).