From: Marc Zyngier <maz@kernel.org>
To: Leo Yan <leo.yan@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
linux-kernel@vger.kernel.org,
Orito Takao <orito.takao@socionext.com>
Subject: Re: [RFC PATCH] irqchip/gic, gic-v3: Ensure data visibility in peripheral
Date: Wed, 01 Sep 2021 08:03:52 +0100 [thread overview]
Message-ID: <87bl5cwzdz.wl-maz@kernel.org> (raw)
In-Reply-To: <20210901063115.383026-1-leo.yan@linaro.org>
On Wed, 01 Sep 2021 07:31:15 +0100,
Leo Yan <leo.yan@linaro.org> wrote:
>
> When an interrupt line is assered, GIC handles interrupt with the flow
> (with EOImode == 1):
>
> gic_handle_irq()
> `> do_read_iar() => Change int state to active
> `> gic_write_eoir() => Drop int priority
> `> handle_domain_irq()
> `> generic_handle_irq_desc()
> `> handle_fasteoi_irq()
> `> handle_irq_event() => Peripheral handler and
> de-assert int line
> `> cond_unmask_eoi_irq()
> `> chip->irq_eoi()
> `> gic_eoimode1_eoi_irq() => Change int state to inactive
>
> In this flow, it has no explicit memory barrier between the functions
> handle_irq_event() and chip->irq_eoi(), it's possible that the
> outstanding data has not reached device in handle_irq_event() but the
> callback chip->irq_eoi() is invoked, this can lead to state transition
> for level triggered interrupt:
>
> Flow | Interrupt state in GIC
> ---------------------------------+-------------------------------------
> Interrupt line is asserted | 'inactive' -> 'pending'
> do_read_iar() | 'pending' -> 'pending & active'
> handle_irq_event() | Write peripheral register but it's
> | not visible for device, so the
> | interrupt line is still asserted
> chip->irq_eoi() | 'pending & active' -> 'pending'
> ...
> Produce spurious interrupt |
> with interrupt ID: 1024 |
1024? Surely not.
> | Finally the peripheral reigster is
> | updated and the interrupt line is
> | deasserted: 'pending' -> 'inactive'
>
> To avoid this potential issue, this patch adds wmb() barrier prior to
> invoke EOI operation, this can make sure the interrupt line is
> de-asserted in peripheral before deactivating interrupt in GIC. At the
> end, this can avoid spurious interrupt.
If you want to ensure completion of device-specific writes, why isn't
this the job of the device driver to implement whatever semantic it
desires? What if the interrupt is (shock, horror!) driven by a system
register instead?
I think this is merely papering over a driver bug, and adds a
significant cost to all interrupts for no good reasons.
M.
--
Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2021-09-01 7:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-01 6:31 [RFC PATCH] irqchip/gic, gic-v3: Ensure data visibility in peripheral Leo Yan
2021-09-01 7:03 ` Marc Zyngier [this message]
2021-09-01 7:27 ` Leo Yan
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=87bl5cwzdz.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=leo.yan@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=orito.takao@socionext.com \
--cc=tglx@linutronix.de \
--cc=will@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