linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Daniel Palmer <daniel@0x0f.com>
Cc: DTML <devicetree@vger.kernel.org>,
	jason@lakedaemon.net, Arnd Bergmann <arnd@arndb.de>,
	linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
	mark-pk.tsai@mediatek.com, tglx@linutronix.de,
	Willy Tarreau <w@1wt.eu>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 2/3] irqchip: mstar: msc313-intc interrupt controller driver
Date: Thu, 06 Aug 2020 13:36:14 +0100	[thread overview]
Message-ID: <3e177112a804b54589464853ff8ac8ad@kernel.org> (raw)
In-Reply-To: <CAFr9PXmzZmHWv+DWppaXOih9p5pJK=3JYCCC+-XrnQ+S7sV+fw@mail.gmail.com>

On 2020-08-06 11:03, Daniel Palmer wrote:
> Hi Marc,
> 
> On Thu, 6 Aug 2020 at 01:26, Marc Zyngier <maz@kernel.org> wrote:
>> > +struct msc313_intc {
>> > +     struct irq_domain *domain;
>> > +     void __iomem *base;
>> > +     struct irq_chip irqchip;
>> 
>> Why do you need to embed the irq_chip on a per-controller basis?
> 
> Current chips have 1 instance of each type of controller but some of 
> the
> newer ones seem to have an extra copy of the non-FIQ version with 
> different
> offset to the GIC.

It is much better to have an irqchip structure per irqchip type,
rather than one per instance, as you can then make the irqchip const.
It also saves memory when you have more than a single instance.

The only case where it doesn't work is when PM gets involved, as the
parent_device pointer is stupidly stored in the irqchip device.

> 
>> > +};
>> > +
>> > +static void msc313_intc_maskunmask(struct msc313_intc *intc, int
>> > hwirq, bool mask)
>> > +{
>> > +     int regoff = REGOFF(hwirq);
>> > +     void __iomem *addr = intc->base + REGOFF_MASK + regoff;
>> > +     u16 bit = IRQBIT(hwirq);
>> > +     u16 reg = readw_relaxed(addr);
>> > +
>> > +     if (mask)
>> > +             reg |= bit;
>> > +     else
>> > +             reg &= ~bit;
>> > +
>> > +     writew_relaxed(reg, addr);
>> 
>> RMW on a shared MMIO register. Not going to end well. This is valid
>> for all the callbacks, I believe.
> 
> Do you have any suggestions on how to resolve that? It seems usually
> an interrupt controller has set and clear registers to get around this.
> Would defining a spinlock at the top of the driver and using that 
> around
> the read and modify sequences be good enough?

Yes, a spinlock is the conventional way to solve it. Make sure
you use the irqsave/irqrestore versions, as mask/unmask can
also occur whilst in interrupt context.

> 
>> > +
>> > +     if (flow_type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_LEVEL_HIGH))
>> > +             reg &= ~bit;
>> > +     else
>> > +             reg |= bit;
>> 
>> I don't follow grasp the logic here. What happens on EDGE_BOTH, for
>> example?
> 
> To be honest I don't quite remember. I'll check and rewrite this.
> 
>> This driver has a massive feeling of déja-vu. It is almost
>> a copy of the one posted at [1], which I reviewed early
>> this week. The issues are the exact same, and I'm 98%
>> sure this is the same IP block used by two SoC vendors.
> 
> This would make a lot of sense considering MediaTek bought MStar
> for their TV SoCs. The weirdness with only using 16 bits in a register
> suggests they've inherited the shared ARM/8051 bus that the MStar
> chips have. Thanks for the tip off.

It is indeed the 16bit accesses that reminded me of the MTK
code, as that's very unusual.

Hopefully you can work with the MTK guys to resolve this quickly.

         M.
-- 
Jazz is not dead. It just smells funny...

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-05 11:00 [PATCH 0/3] irqchip: mstar: msc313 intc driver Daniel Palmer
2020-08-05 11:00 ` [PATCH 1/3] dt: bindings: interrupt-controller: Add binding description for msc313-intc Daniel Palmer
2020-08-06 14:10   ` Rob Herring
2020-08-06 14:15   ` Rob Herring
2020-08-06 14:46     ` Daniel Palmer
2020-08-05 11:00 ` [PATCH 2/3] irqchip: mstar: msc313-intc interrupt controller driver Daniel Palmer
2020-08-05 16:26   ` Marc Zyngier
2020-08-06 10:03     ` Daniel Palmer
2020-08-06 12:36       ` Marc Zyngier [this message]
2020-08-05 11:00 ` [PATCH 3/3] ARM: mstar: Add interrupt controller to base dtsi Daniel Palmer

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=3e177112a804b54589464853ff8ac8ad@kernel.org \
    --to=maz@kernel.org \
    --cc=arnd@arndb.de \
    --cc=daniel@0x0f.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jason@lakedaemon.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark-pk.tsai@mediatek.com \
    --cc=robh+dt@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=w@1wt.eu \
    /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).