From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Stephen Boyd <swboyd@chromium.org>
Cc: Linus Walleij <linus.walleij@linaro.org>,
linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
linux-arm-msm@vger.kernel.org,
Doug Anderson <dianders@chromium.org>
Subject: Re: [PATCH 1/3] pinctrl: msm: Really mask level interrupts to prevent latching
Date: Fri, 22 Jun 2018 10:56:08 -0700 [thread overview]
Message-ID: <20180622175608.GB3402@tuxbook-pro> (raw)
In-Reply-To: <152959405220.16708.279861218299564639@swboyd.mtv.corp.google.com>
On Thu 21 Jun 08:14 PDT 2018, Stephen Boyd wrote:
> Quoting Bjorn Andersson (2018-06-19 23:45:09)
> > On Mon 18 Jun 13:52 PDT 2018, Stephen Boyd wrote:
> > > @@ -647,6 +660,10 @@ static void msm_gpio_irq_unmask(struct irq_data *d)
> > > raw_spin_lock_irqsave(&pctrl->lock, flags);
> > >
> > > val = readl(pctrl->regs + g->intr_cfg_reg);
> > > + if (irqd_get_trigger_type(d) & IRQ_TYPE_LEVEL_MASK) {
> > > + val |= BIT(g->intr_raw_status_bit);
> > > + writel(val, pctrl->regs + g->intr_cfg_reg);
> > > + }
> > > val |= BIT(g->intr_enable_bit);
> > > writel(val, pctrl->regs + g->intr_cfg_reg);
> >
> > I looked at the TLMM documentation, which states that the status bit
> > should be cleared after handling the interrupt and this driver used to
> > do this.
>
> Nice!
>
> >
> > But Timur managed to hit the race where we lost edge triggered
> > interrupts with this behavior, so we changed it in the following commit:
> >
> > a6566710adaa ("pinctrl: qcom: Don't clear status bit on irq_unmask")
> >
> >
> > But the reason that I had this in the driver originally is that msm-3.10
> > does this (clear status bit in unmask), so perhaps the appropriate way
> > to solve is to follow the documentation and the downstream driver and
> > ack the interrupt in unmask - but do so only for level triggered
> > interrupts?
> >
>
> Clearing the status bit (basically acking the gpio irq) can be done in
> unmask for level triggered interrupts. That works and as you say it's
> even documented.
>
> I didn't implement that because it felt better to prevent the status
> from latching in the hardware while the interrupt is masked. My
> understanding of irq mask semantics is that the interrupt shouldn't be
> "pending" during the time between mask and unmask and clearing the raw
> status allows us to do that properly without messing with the status bit
> on the unmask path. It also means that the ack operation really does ack
> the irq status bit and cause it to go away. I suppose there is one case
> where I'm wrong though, and that is when the irq is unmasked on irq
> startup where we don't want to see a spurious latched level interrupt
> that occurred before we booted.
>
I took another pass through the irq code and I agree, while the late ack
does solve the problem it's more intuitive if we can prevent the
latching.
> That problem may be possible with bad bootloaders that are leaving some
> status bit latched in there, but also we would want to fix that for edge
> type interrupts too, so we would need to clear the status bit regardless
> of the level on irq startup and hope an edge isn't lost on startup.
>
I would prefer that we handle that case explicitly.
There are some concerns from msm-3.10 regarding writing the intr-raw bit
at the same time as the other bits, but I think that relates to the fact
that the downstream driver used to configure and enabled raw-state in
the same write. So please respin v2 as you planned.
Regards,
Bjorn
next prev parent reply other threads:[~2018-06-22 17:56 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-18 20:52 [PATCH 0/3] pinctrl: msm interrupt and muxing fixes Stephen Boyd
2018-06-18 20:52 ` [PATCH 1/3] pinctrl: msm: Really mask level interrupts to prevent latching Stephen Boyd
2018-06-18 22:43 ` Doug Anderson
2018-06-18 23:28 ` Stephen Boyd
2018-06-18 23:38 ` Doug Anderson
2018-06-19 21:14 ` Stephen Boyd
2018-06-20 6:45 ` Bjorn Andersson
2018-06-20 15:52 ` Doug Anderson
2018-06-21 15:14 ` Stephen Boyd
2018-06-22 17:56 ` Bjorn Andersson [this message]
2018-06-18 20:52 ` [PATCH 2/3] pinctrl: msm: Mux out gpio function with gpio_request() Stephen Boyd
2018-06-18 23:54 ` Doug Anderson
2018-06-19 21:18 ` Stephen Boyd
2018-06-19 21:38 ` Doug Anderson
2018-06-20 5:53 ` Stephen Boyd
2018-06-22 17:58 ` Bjorn Andersson
2018-06-22 18:31 ` Bjorn Andersson
2018-06-28 14:25 ` Linus Walleij
2018-06-28 17:14 ` Stephen Boyd
2018-06-28 18:45 ` Doug Anderson
2018-07-02 17:56 ` Stephen Boyd
2018-07-09 13:54 ` Linus Walleij
2018-07-09 15:37 ` Stephen Boyd
2018-07-13 6:59 ` Linus Walleij
2018-07-02 19:09 ` Bjorn Andersson
2018-07-06 17:23 ` Stephen Boyd
2018-06-18 20:52 ` [PATCH 3/3] pinctrl: msm: Configure interrupts as input and gpio mode Stephen Boyd
2018-06-19 15:48 ` Doug Anderson
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=20180622175608.GB3402@tuxbook-pro \
--to=bjorn.andersson@linaro.org \
--cc=dianders@chromium.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=swboyd@chromium.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).