From: Joe.C <srv_yingjoe.chen@mediatek.com>
To: Marc Zyngier <marc.zyngier@arm.com>
Cc: Mark Rutland <Mark.Rutland@arm.com>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
"yingjoe.chen@gmail.com" <yingjoe.chen@gmail.com>,
Russell King <linux@arm.linux.org.uk>,
Arnd Bergmann <arnd@arndb.de>,
"yh.chen@mediatek.com" <yh.chen@mediatek.com>,
"nathan.chung@mediatek.com" <nathan.chung@mediatek.com>,
yingjoe.chen@mediatek.com,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
Jason Cooper <jason@lakedaemon.net>,
Pawel Moll <Pawel.Moll@arm.com>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Rob Herring <robh+dt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
"eddie.huang@mediatek.com" <eddie.huang@mediatek.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"srv_heupstream@mediatek.com" <srv_heupstream@mediatek.com>,
"hc.yen@mediatek.com" <hc.yen@mediatek.com>,
Rand
Subject: Re: [RESEND PATCH v2 1/4] irqchip: gic: Change irq type check when extension is present
Date: Sat, 23 Aug 2014 13:28:58 +0800 [thread overview]
Message-ID: <1408771738.25080.65.camel@mtksdaap41> (raw)
In-Reply-To: <53F724F5.3040004@arm.com>
Hi,
Thanks for your suggestions.
On Fri, 2014-08-22 at 12:09 +0100, Marc Zyngier wrote:
> Hi Joe,
>
> On 13/08/14 03:11, Joe.C wrote:
> > From: "Joe.C" <yingjoe.chen@mediatek.com>
> >
> > GIC supports the combination with external extensions. But this
> > is not reflected in the checks of the interrupt type flag.
> > This patch allows interrupt types other than the one supported by GIC,
> > if an architecture extension is present and supports them.
> >
> > Signed-off-by: Joe.C <yingjoe.chen@mediatek.com>
> > ---
> > drivers/irqchip/irq-gic.c | 27 ++++++++++++++++++---------
> > 1 file changed, 18 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
> > index 57d165e..66485ab 100644
> > --- a/drivers/irqchip/irq-gic.c
> > +++ b/drivers/irqchip/irq-gic.c
> > @@ -194,23 +194,32 @@ static int gic_set_type(struct irq_data *d, unsigned int type)
> > u32 confoff = (gicirq / 16) * 4;
> > bool enabled = false;
> > u32 val;
> > + int ret = 0;
> >
> > /* Interrupt configuration for SGIs can't be changed */
> > if (gicirq < 16)
> > return -EINVAL;
> >
> > - if (type != IRQ_TYPE_LEVEL_HIGH && type != IRQ_TYPE_EDGE_RISING)
> > - return -EINVAL;
> > -
> > raw_spin_lock(&irq_controller_lock);
> >
> > - if (gic_arch_extn.irq_set_type)
> > - gic_arch_extn.irq_set_type(d, type);
> > + if (gic_arch_extn.irq_set_type) {
> > + ret = gic_arch_extn.irq_set_type(d, type);
> > + if (ret)
> > + goto out;
> > + } else if (type != IRQ_TYPE_LEVEL_HIGH &&
> > + type != IRQ_TYPE_EDGE_RISING) {
> > + ret = -EINVAL;
> > + goto out;
> > + }
> >
> > val = readl_relaxed(base + GIC_DIST_CONFIG + confoff);
> > - if (type == IRQ_TYPE_LEVEL_HIGH)
> > + /* Check for both edge and level here, so we can support GIC irq
> > + polarity extension in gic_arch_extn.irq_set_type. If arch
> > + doesn't support polarity extension, the check above will reject
> > + improper type. */
> > + if (type & IRQ_TYPE_LEVEL_MASK)
> > val &= ~confmask;
> > - else if (type == IRQ_TYPE_EDGE_RISING)
> > + else if (type & IRQ_TYPE_EDGE_BOTH)
> > val |= confmask;
> >
> > /*
> > @@ -226,10 +235,10 @@ static int gic_set_type(struct irq_data *d, unsigned int type)
> >
> > if (enabled)
> > writel_relaxed(enablemask, base + GIC_DIST_ENABLE_SET + enableoff);
> > -
> > +out:
> > raw_spin_unlock(&irq_controller_lock);
> >
> > - return 0;
> > + return ret;
> > }
> >
> > static int gic_retrigger(struct irq_data *d)
> >
>
> You're really abusing the gic_arch_extn feature. I know this is
> tempting, but this is pushing it a bit too far.
>
> This feature exist for one particular reason: if your GIC is in the same
> power-domain as the CPUs, it will go down as well when you suspend the
> system, hence being enable to wake the CPU up. You then need a shadow
> interrupt controller to take over. This is exactly why we call the hook
> on every GIC-related operation.
Actually we are doing this too, it is called SYS_CIRQ in our IC, and
we'll need to support that in the future. This intpol is part of CIRQ
function block. Does it make more senses if I add skeleton for CIRQ
support, and implement intpol inside it?
> Here, you're using it to program something that sits between the device
> and the GIC. This is a separate block, with its own hardware
> configuration, that modifies the interrupt signal. This should be
> reflected in the device-tree and the code paths.
>
> You can probably model this as a separate irqchip for the few interrupts
> that require this, or have it configured at boot time (assuming the
> configuration never changes).
The boot loader did setup interrupt polarity for those used in boot
loader, but not all of them.
Datasheet lists components irqs as low active, so I think it makes more
sense to allow driver to use IRQF_TRIGGER_LOW instead of having them to
notice GIC only support high active and use IRQF_TRIGGER_HIGH. This
rule out configure it at boot loader or kernel init irq time.
If I implement this as a separate irqchip, I need to reuse most gic
irqchip functions. Without changing irq-gic.c to make them global,
I can only think of hack like this:
gic_init_bases(..) /* init gic */
gic_chip = irq_get_chip(0); /* to get gic irq_chip */
org_gic_set_type = gic_chip->irq_set_type;
gic_chip->irq_set_type = mt_irq_polarity_set_type;
and calling original gic_set_type from mt_irq_polarity_set_type with irq
type fixup.
Joe.C
next prev parent reply other threads:[~2014-08-23 5:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-13 2:11 [RESEND PATCH v2 0/4] arm: mediatek: Add support for GIC interrupt polarity extension Joe.C
2014-08-13 2:11 ` [RESEND PATCH v2 1/4] irqchip: gic: Change irq type check when extension is present Joe.C
2014-08-22 11:09 ` Marc Zyngier
2014-08-23 5:28 ` Joe.C [this message]
2014-08-27 9:55 ` Jan Lübbe
2014-08-27 10:36 ` Marc Zyngier
2014-08-27 12:23 ` Thomas Gleixner
2014-08-27 13:37 ` Marc Zyngier
2014-08-27 14:03 ` Thomas Gleixner
2014-08-27 14:29 ` Mark Rutland
2014-08-27 15:22 ` Thomas Gleixner
2014-08-13 2:11 ` [RESEND PATCH v2 2/4] arm: mediatek: Add support for GIC interrupt polarity extension Joe.C
2014-08-13 2:11 ` [RESEND PATCH v2 3/4] arm: mediatek: Add intpol in mt6589.dtsi Joe.C
2014-08-13 2:11 ` [RESEND PATCH v2 4/4] dt-bindings: add bindings for mediatek intpol Joe.C
2014-08-21 15:02 ` Matthias Brugger
2014-08-22 8:39 ` Joe.C
2014-08-22 9:23 ` [RESEND PATCH v2 0/4] arm: mediatek: Add support for GIC interrupt polarity extension Joe.C
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=1408771738.25080.65.camel@mtksdaap41 \
--to=srv_yingjoe.chen@mediatek.com \
--cc=Mark.Rutland@arm.com \
--cc=Pawel.Moll@arm.com \
--cc=arnd@arndb.de \
--cc=devicetree@vger.kernel.org \
--cc=eddie.huang@mediatek.com \
--cc=hc.yen@mediatek.com \
--cc=ijc+devicetree@hellion.org.uk \
--cc=jason@lakedaemon.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=marc.zyngier@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=nathan.chung@mediatek.com \
--cc=robh+dt@kernel.org \
--cc=srv_heupstream@mediatek.com \
--cc=tglx@linutronix.de \
--cc=yh.chen@mediatek.com \
--cc=yingjoe.chen@gmail.com \
--cc=yingjoe.chen@mediatek.com \
/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).