From: MD Danish Anwar <danishanwar@ti.com>
To: Grzegorz Jaszczyk <grzegorz.jaszczyk@linaro.org>,
Suman Anna <s-anna@ti.com>, David Lechner <david@lechnology.com>,
Roger Quadros <rogerq@kernel.org>, "Andrew F. Davis" <afd@ti.com>,
Marc Zyngier <maz@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>
Cc: <linux-kernel@vger.kernel.org>, <srk@ti.com>,
<danishanwar@ti.com>, <r-gunasekaran@ti.com>, <vigneshr@ti.com>
Subject: [PATCH 1/3] irqchip/irq-pruss-intc: Fix enabling of intc events
Date: Tue, 19 Sep 2023 11:48:58 +0530 [thread overview]
Message-ID: <20230919061900.369300-2-danishanwar@ti.com> (raw)
In-Reply-To: <20230919061900.369300-1-danishanwar@ti.com>
From: Suman Anna <s-anna@ti.com>
PRUSS INTC events are enabled by default once IRQ events are mapped to
channel:host pair. This may cause issues with undesirable IRQs triggering
even before a PRU IRQ is requested which are silently processed by
pruss_intc_irq_handler().
Fix it by masking all events by default except those which are routed to
various PRU cores (Host IRQs 0, 1; 10 through 19 on K3 SoCs), and any
other reserved IRQs routed to other processors. The unmasking of IRQs is
the responsibility of Linux IRQ core when IRQ is actually requested.
Fixes: 04e2d1e06978 ("irqchip/irq-pruss-intc: Add a PRUSS irqchip driver for PRUSS interrupts")
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: MD Danish Anwar <danishanwar@ti.com>
---
drivers/irqchip/irq-pruss-intc.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/drivers/irqchip/irq-pruss-intc.c b/drivers/irqchip/irq-pruss-intc.c
index 0f64ecb9b1f4..7415817d4c6c 100644
--- a/drivers/irqchip/irq-pruss-intc.c
+++ b/drivers/irqchip/irq-pruss-intc.c
@@ -101,6 +101,7 @@ struct pruss_intc_match_data {
* @soc_config: cached PRUSS INTC IP configuration data
* @dev: PRUSS INTC device pointer
* @lock: mutex to serialize interrupts mapping
+ * @irqs_reserved: bit-mask of reserved host interrupts
*/
struct pruss_intc {
struct pruss_intc_map_record event_channel[MAX_PRU_SYS_EVENTS];
@@ -111,6 +112,7 @@ struct pruss_intc {
const struct pruss_intc_match_data *soc_config;
struct device *dev;
struct mutex lock; /* PRUSS INTC lock */
+ u8 irqs_reserved;
};
/**
@@ -178,6 +180,7 @@ static void pruss_intc_update_hmr(struct pruss_intc *intc, u8 ch, u8 host)
static void pruss_intc_map(struct pruss_intc *intc, unsigned long hwirq)
{
struct device *dev = intc->dev;
+ bool enable_hwirq = false;
u8 ch, host, reg_idx;
u32 val;
@@ -187,6 +190,9 @@ static void pruss_intc_map(struct pruss_intc *intc, unsigned long hwirq)
ch = intc->event_channel[hwirq].value;
host = intc->channel_host[ch].value;
+ enable_hwirq = (host < FIRST_PRU_HOST_INT ||
+ host >= FIRST_PRU_HOST_INT + MAX_NUM_HOST_IRQS ||
+ intc->irqs_reserved & BIT(host - FIRST_PRU_HOST_INT));
pruss_intc_update_cmr(intc, hwirq, ch);
@@ -194,8 +200,10 @@ static void pruss_intc_map(struct pruss_intc *intc, unsigned long hwirq)
val = BIT(hwirq % 32);
/* clear and enable system event */
- pruss_intc_write_reg(intc, PRU_INTC_ESR(reg_idx), val);
pruss_intc_write_reg(intc, PRU_INTC_SECR(reg_idx), val);
+ /* unmask only events going to various PRU and other cores by default */
+ if (enable_hwirq)
+ pruss_intc_write_reg(intc, PRU_INTC_ESR(reg_idx), val);
if (++intc->channel_host[ch].ref_count == 1) {
pruss_intc_update_hmr(intc, ch, host);
@@ -204,7 +212,8 @@ static void pruss_intc_map(struct pruss_intc *intc, unsigned long hwirq)
pruss_intc_write_reg(intc, PRU_INTC_HIEISR, host);
}
- dev_dbg(dev, "mapped system_event = %lu channel = %d host = %d",
+ dev_dbg(dev, "mapped%s system_event = %lu channel = %d host = %d",
+ enable_hwirq ? " and enabled" : "",
hwirq, ch, host);
mutex_unlock(&intc->lock);
@@ -268,11 +277,14 @@ static void pruss_intc_init(struct pruss_intc *intc)
/*
* configure polarity (SIPR register) to active high and
- * type (SITR register) to level interrupt for all system events
+ * type (SITR register) to level interrupt for all system events,
+ * and disable and clear all the system events
*/
for (i = 0; i < num_event_type_regs; i++) {
pruss_intc_write_reg(intc, PRU_INTC_SIPR(i), 0xffffffff);
pruss_intc_write_reg(intc, PRU_INTC_SITR(i), 0);
+ pruss_intc_write_reg(intc, PRU_INTC_ECR(i), 0xffffffff);
+ pruss_intc_write_reg(intc, PRU_INTC_SECR(i), 0xffffffff);
}
/* clear all interrupt channel map registers, 4 events per register */
@@ -521,7 +533,7 @@ static int pruss_intc_probe(struct platform_device *pdev)
struct pruss_intc *intc;
struct pruss_host_irq_data *host_data;
int i, irq, ret;
- u8 max_system_events, irqs_reserved = 0;
+ u8 max_system_events;
data = of_device_get_match_data(dev);
if (!data)
@@ -542,7 +554,7 @@ static int pruss_intc_probe(struct platform_device *pdev)
return PTR_ERR(intc->base);
ret = of_property_read_u8(dev->of_node, "ti,irqs-reserved",
- &irqs_reserved);
+ &intc->irqs_reserved);
/*
* The irqs-reserved is used only for some SoC's therefore not having
@@ -561,7 +573,7 @@ static int pruss_intc_probe(struct platform_device *pdev)
return -ENOMEM;
for (i = 0; i < MAX_NUM_HOST_IRQS; i++) {
- if (irqs_reserved & BIT(i))
+ if (intc->irqs_reserved & BIT(i))
continue;
irq = platform_get_irq_byname(pdev, irq_names[i]);
--
2.34.1
next prev parent reply other threads:[~2023-09-19 6:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-19 6:18 [PATCH 0/3] Bug Fixes for PRUSS irqchip driver MD Danish Anwar
2023-09-19 6:18 ` MD Danish Anwar [this message]
2023-09-19 6:18 ` [PATCH 2/3] irqchip/irq-pruss-intc: Fix listed IRQ type in /proc/interrupts MD Danish Anwar
2023-09-19 6:19 ` [PATCH 3/3] irqchip/irq-pruss-intc: Fix processing of IEP interrupts MD Danish Anwar
2023-09-19 7:32 ` Marc Zyngier
2026-02-18 7:08 ` Meghana Malladi
2026-02-18 11:04 ` Marc Zyngier
2026-02-18 11:26 ` Meghana Malladi
2026-02-22 20:59 ` Thomas Gleixner
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=20230919061900.369300-2-danishanwar@ti.com \
--to=danishanwar@ti.com \
--cc=afd@ti.com \
--cc=david@lechnology.com \
--cc=grzegorz.jaszczyk@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=r-gunasekaran@ti.com \
--cc=rogerq@kernel.org \
--cc=s-anna@ti.com \
--cc=srk@ti.com \
--cc=tglx@linutronix.de \
--cc=vigneshr@ti.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
all inboxes | Powered by JetHome®