From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Stephen Boyd <swboyd@chromium.org>
Cc: Douglas Anderson <dianders@chromium.org>,
Jason Cooper <jason@lakedaemon.net>,
Linus Walleij <linus.walleij@linaro.org>,
Marc Zyngier <maz@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Neeraj Upadhyay <neeraju@codeaurora.org>,
Rajendra Nayak <rnayak@codeaurora.org>,
Maulik Shah <mkshah@codeaurora.org>,
linux-gpio@vger.kernel.org,
Srinivas Ramana <sramana@codeaurora.org>,
linux-arm-msm@vger.kernel.org, Andy Gross <agross@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 4/4] pinctrl: qcom: Don't clear pending interrupts when enabling
Date: Thu, 14 Jan 2021 11:07:14 -0600 [thread overview]
Message-ID: <YAB6QsmypEZa9SOP@builder.lan> (raw)
In-Reply-To: <161060848425.3661239.17417977666663714149@swboyd.mtv.corp.google.com>
On Thu 14 Jan 01:14 CST 2021, Stephen Boyd wrote:
> Quoting Douglas Anderson (2021-01-08 09:35:16)
> > Let's deal with the problem like this:
> > * When we mux away, we'll mask our interrupt. This isn't necessary in
> > the above case since the client already masked us, but it's a good
> > idea in general.
> > * When we mux back will clear any interrupts and unmask.
>
> I'm on board!
>
> >
> > Fixes: 4b7618fdc7e6 ("pinctrl: qcom: Add irq_enable callback for msm gpio")
> > Fixes: 71266d9d3936 ("pinctrl: qcom: Move clearing pending IRQ to .irq_request_resources callback")
> > Signed-off-by: Douglas Anderson <dianders@chromium.org>
> > ---
> > diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
> > index a6b0c17e2f78..d5d1f3430c6c 100644
> > --- a/drivers/pinctrl/qcom/pinctrl-msm.c
> > +++ b/drivers/pinctrl/qcom/pinctrl-msm.c
> > @@ -51,6 +51,7 @@
> > * @dual_edge_irqs: Bitmap of irqs that need sw emulated dual edge
> > * detection.
> > * @skip_wake_irqs: Skip IRQs that are handled by wakeup interrupt controller
> > + * @disabled_for_mux: These IRQs were disabled because we muxed away.
> > * @soc: Reference to soc_data of platform specific data.
> > * @regs: Base addresses for the TLMM tiles.
> > * @phys_base: Physical base address
> > @@ -72,6 +73,7 @@ struct msm_pinctrl {
> > DECLARE_BITMAP(dual_edge_irqs, MAX_NR_GPIO);
> > DECLARE_BITMAP(enabled_irqs, MAX_NR_GPIO);
> > DECLARE_BITMAP(skip_wake_irqs, MAX_NR_GPIO);
> > + DECLARE_BITMAP(disabled_for_mux, MAX_NR_GPIO);
> >
> > const struct msm_pinctrl_soc_data *soc;
> > void __iomem *regs[MAX_NR_TILES];
> > @@ -179,6 +181,10 @@ static int msm_pinmux_set_mux(struct pinctrl_dev *pctldev,
> > unsigned group)
> > {
> > struct msm_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
> > + struct gpio_chip *gc = &pctrl->chip;
> > + unsigned int irq = irq_find_mapping(gc->irq.domain, group);
> > + struct irq_data *d = irq_get_irq_data(irq);
> > + unsigned int gpio_func = pctrl->soc->gpio_func;
> > const struct msm_pingroup *g;
> > unsigned long flags;
> > u32 val, mask;
> > @@ -195,6 +201,20 @@ static int msm_pinmux_set_mux(struct pinctrl_dev *pctldev,
> > if (WARN_ON(i == g->nfuncs))
> > return -EINVAL;
> >
> > + /*
> > + * If an GPIO interrupt is setup on this pin then we need special
> > + * handling. Specifically interrupt detection logic will still see
> > + * the pin twiddle even when we're muxed away.
> > + *
> > + * When we see a pin with an interrupt setup on it then we'll disable
> > + * (mask) interrupts on it when we mux away until we mux back. Note
> > + * that disable_irq() refcounts and interrupts are disabled as long as
> > + * at least one disable_irq() has been called.
> > + */
> > + if (d && i != gpio_func &&
> > + !test_and_set_bit(d->hwirq, pctrl->disabled_for_mux))
> > + disable_irq(irq);
>
> Does it need to be forced non-lazy so that it is actually disabled at
> the GIC? I'm trying to understand how the lazy irq disabling plays into
> this. I think it's a don't care situation because if the line twiddles
> and triggers an irq then we'll actually disable it at the GIC in the
> genirq core and mark it pending for resend. I wonder if we wouldn't have
> to undo the pending state if we actually ignored it at the GIC
> forcefully. And I also worry that it may cause a random wakeup if the
> line twiddles, becomes pending at GIC and thus blocks the CPU from
> running a WFI but it isn't an irq that Linux cares about because it's
> muxed to UART, and then lazy handling runs and shuts it down. Is that
> possible?
>
> > +
> > raw_spin_lock_irqsave(&pctrl->lock, flags);
> >
> > val = msm_readl_ctl(pctrl, g);
> > @@ -204,6 +224,20 @@ static int msm_pinmux_set_mux(struct pinctrl_dev *pctldev,
> >
> > raw_spin_unlock_irqrestore(&pctrl->lock, flags);
> >
> > + if (d && i == gpio_func &&
> > + test_and_clear_bit(d->hwirq, pctrl->disabled_for_mux)) {
> > + /*
> > + * Clear interrupts detected while not GPIO since we only
> > + * masked things.
> > + */
> > + if (d->parent_data && test_bit(d->hwirq, pctrl->skip_wake_irqs))
> > + irq_chip_set_parent_state(d, IRQCHIP_STATE_PENDING, false);
>
> So if not lazy this could go away? Although I think this is to clear out
> the pending state in the GIC and not the PDC which is the parent.
>
Isn't this the PDC line after all, because the GIC only has the summary
line while the PDC (if we have d->parent_data) has a dedicated line for
this irq?
Regards,
Bjorn
> > + else
> > + msm_ack_intr_status(pctrl, g);
> > +
> > + enable_irq(irq);
> > + }
> > +
next prev parent reply other threads:[~2021-01-14 17:08 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-08 17:35 [PATCH v5 1/4] pinctrl: qcom: Allow SoCs to specify a GPIO function that's not 0 Douglas Anderson
2021-01-08 17:35 ` [PATCH v5 2/4] pinctrl: qcom: No need to read-modify-write the interrupt status Douglas Anderson
2021-01-11 15:58 ` Maulik Shah
2021-01-14 7:01 ` Stephen Boyd
2021-01-14 16:33 ` Bjorn Andersson
2021-01-08 17:35 ` [PATCH v5 3/4] pinctrl: qcom: Properly clear "intr_ack_high" interrupts when unmasking Douglas Anderson
2021-01-11 15:59 ` Maulik Shah
2021-01-14 7:03 ` Stephen Boyd
2021-01-14 16:34 ` Bjorn Andersson
2021-01-08 17:35 ` [PATCH v5 4/4] pinctrl: qcom: Don't clear pending interrupts when enabling Douglas Anderson
2021-01-09 0:36 ` Linus Walleij
2021-01-16 1:04 ` Doug Anderson
2021-01-11 16:01 ` Maulik Shah
2021-01-14 7:14 ` Stephen Boyd
2021-01-14 17:07 ` Bjorn Andersson [this message]
2021-01-14 17:15 ` Bjorn Andersson
2021-01-14 17:58 ` Doug Anderson
2021-01-14 17:58 ` Doug Anderson
2021-01-14 21:04 ` Stephen Boyd
2021-01-11 15:56 ` [PATCH v5 1/4] pinctrl: qcom: Allow SoCs to specify a GPIO function that's not 0 Maulik Shah
2021-01-14 16:32 ` Bjorn Andersson
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=YAB6QsmypEZa9SOP@builder.lan \
--to=bjorn.andersson@linaro.org \
--cc=agross@kernel.org \
--cc=dianders@chromium.org \
--cc=jason@lakedaemon.net \
--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=maz@kernel.org \
--cc=mkshah@codeaurora.org \
--cc=neeraju@codeaurora.org \
--cc=rnayak@codeaurora.org \
--cc=sramana@codeaurora.org \
--cc=swboyd@chromium.org \
--cc=tglx@linutronix.de \
/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).