From: Rabin Vincent <rabin.vincent@axis.com> To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: srinivas.kandagatla@gmail.com, maxime.coquelin@st.com, patrice.chotard@st.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Rabin Vincent <rabinv@axis.com> Subject: [PATCH] clockevents/drivers/arm_global_timer: Fix erratum 740657 workaround Date: Tue, 29 Mar 2016 10:08:37 +0200 [thread overview] Message-ID: <1459238917-2240-1-git-send-email-rabin.vincent@axis.com> (raw) From: Rabin Vincent <rabinv@axis.com> According to the errata document for the Cortex A9 MPCore, the correct code sequence in the interrupt handler to workaround erratum 740657 "Global Timer can send two interrupts for the same event" is: (1) Read the ICCIAR (Interrupt Acknowledge) register (2) Modify the comparator value, to set it to a higher value (3) Clear the Global Timer flag (4) Clear the Pending Status information for Interrupt 27 (Global Timer interrupt) in the Distributor of the Interrupt Controller. (5) Write the ICCEOIR (End of Interrupt) register (1) and (5) are done by the GIC driver and (2) and (3) are done by the Global Timer driver. However, nobody does (4) and thus the workaround is inactive and the timer triggers many spurious interrupts: <idle>-0 [001] d.h2 99.850527: irq_handler_entry: irq=16 name=gt <idle>-0 [001] d.h2 99.850538: irq_handler_exit: irq=16 ret=handled <idle>-0 [001] d.H2 99.850540: irq_handler_entry: irq=16 name=gt <idle>-0 [001] d.H2 99.850542: irq_handler_exit: irq=16 ret=unhandled <idle>-0 [001] d.h2 99.987832: irq_handler_entry: irq=16 name=gt <idle>-0 [001] dnh2 99.987845: irq_handler_exit: irq=16 ret=handled <idle>-0 [001] dnh2 99.987848: irq_handler_entry: irq=16 name=gt <idle>-0 [001] dnh2 99.987850: irq_handler_exit: irq=16 ret=unhandled Make the Global Timer driver perform step (4) via the GIC driver with the help of the irq_set_irqchip_state() function, to prevent the spurious interrupts. Signed-off-by: Rabin Vincent <rabinv@axis.com> --- drivers/clocksource/arm_global_timer.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/clocksource/arm_global_timer.c b/drivers/clocksource/arm_global_timer.c index 9df0d16..b9d0f86 100644 --- a/drivers/clocksource/arm_global_timer.c +++ b/drivers/clocksource/arm_global_timer.c @@ -140,26 +140,31 @@ static int gt_clockevent_set_next_event(unsigned long evt, static irqreturn_t gt_clockevent_interrupt(int irq, void *dev_id) { struct clock_event_device *evt = dev_id; + bool workaround = clockevent_state_oneshot(evt); if (!(readl_relaxed(gt_base + GT_INT_STATUS) & GT_INT_STATUS_EVENT_FLAG)) return IRQ_NONE; /** - * ERRATA 740657( Global Timer can send 2 interrupts for + * ERRATA 740657 (Global Timer can send 2 interrupts for * the same event in single-shot mode) * Workaround: - * Either disable single-shot mode. - * Or - * Modify the Interrupt Handler to avoid the - * offending sequence. This is achieved by clearing - * the Global Timer flag _after_ having incremented - * the Comparator register value to a higher value. + * - Read the ICCIAR (Interrupt Acknowledge) register + * - Modify the comparator value, to set it to a higher value + * - Clear the Global Timer flag + * - Clear the Pending Status information for Interrupt 27 (Global + * Timer interrupt) in the Distributor of the Interrupt Controller. + * - Write the ICCEOIR (End of Interrupt) register */ - if (clockevent_state_oneshot(evt)) + if (workaround) gt_compare_set(ULONG_MAX, 0); writel_relaxed(GT_INT_STATUS_EVENT_FLAG, gt_base + GT_INT_STATUS); + + if (workaround) + irq_set_irqchip_state(irq, IRQCHIP_STATE_PENDING, false); + evt->event_handler(evt); return IRQ_HANDLED; -- 2.7.0
WARNING: multiple messages have this Message-ID (diff)
From: rabin.vincent@axis.com (Rabin Vincent) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] clockevents/drivers/arm_global_timer: Fix erratum 740657 workaround Date: Tue, 29 Mar 2016 10:08:37 +0200 [thread overview] Message-ID: <1459238917-2240-1-git-send-email-rabin.vincent@axis.com> (raw) From: Rabin Vincent <rabinv@axis.com> According to the errata document for the Cortex A9 MPCore, the correct code sequence in the interrupt handler to workaround erratum 740657 "Global Timer can send two interrupts for the same event" is: (1) Read the ICCIAR (Interrupt Acknowledge) register (2) Modify the comparator value, to set it to a higher value (3) Clear the Global Timer flag (4) Clear the Pending Status information for Interrupt 27 (Global Timer interrupt) in the Distributor of the Interrupt Controller. (5) Write the ICCEOIR (End of Interrupt) register (1) and (5) are done by the GIC driver and (2) and (3) are done by the Global Timer driver. However, nobody does (4) and thus the workaround is inactive and the timer triggers many spurious interrupts: <idle>-0 [001] d.h2 99.850527: irq_handler_entry: irq=16 name=gt <idle>-0 [001] d.h2 99.850538: irq_handler_exit: irq=16 ret=handled <idle>-0 [001] d.H2 99.850540: irq_handler_entry: irq=16 name=gt <idle>-0 [001] d.H2 99.850542: irq_handler_exit: irq=16 ret=unhandled <idle>-0 [001] d.h2 99.987832: irq_handler_entry: irq=16 name=gt <idle>-0 [001] dnh2 99.987845: irq_handler_exit: irq=16 ret=handled <idle>-0 [001] dnh2 99.987848: irq_handler_entry: irq=16 name=gt <idle>-0 [001] dnh2 99.987850: irq_handler_exit: irq=16 ret=unhandled Make the Global Timer driver perform step (4) via the GIC driver with the help of the irq_set_irqchip_state() function, to prevent the spurious interrupts. Signed-off-by: Rabin Vincent <rabinv@axis.com> --- drivers/clocksource/arm_global_timer.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/clocksource/arm_global_timer.c b/drivers/clocksource/arm_global_timer.c index 9df0d16..b9d0f86 100644 --- a/drivers/clocksource/arm_global_timer.c +++ b/drivers/clocksource/arm_global_timer.c @@ -140,26 +140,31 @@ static int gt_clockevent_set_next_event(unsigned long evt, static irqreturn_t gt_clockevent_interrupt(int irq, void *dev_id) { struct clock_event_device *evt = dev_id; + bool workaround = clockevent_state_oneshot(evt); if (!(readl_relaxed(gt_base + GT_INT_STATUS) & GT_INT_STATUS_EVENT_FLAG)) return IRQ_NONE; /** - * ERRATA 740657( Global Timer can send 2 interrupts for + * ERRATA 740657 (Global Timer can send 2 interrupts for * the same event in single-shot mode) * Workaround: - * Either disable single-shot mode. - * Or - * Modify the Interrupt Handler to avoid the - * offending sequence. This is achieved by clearing - * the Global Timer flag _after_ having incremented - * the Comparator register value to a higher value. + * - Read the ICCIAR (Interrupt Acknowledge) register + * - Modify the comparator value, to set it to a higher value + * - Clear the Global Timer flag + * - Clear the Pending Status information for Interrupt 27 (Global + * Timer interrupt) in the Distributor of the Interrupt Controller. + * - Write the ICCEOIR (End of Interrupt) register */ - if (clockevent_state_oneshot(evt)) + if (workaround) gt_compare_set(ULONG_MAX, 0); writel_relaxed(GT_INT_STATUS_EVENT_FLAG, gt_base + GT_INT_STATUS); + + if (workaround) + irq_set_irqchip_state(irq, IRQCHIP_STATE_PENDING, false); + evt->event_handler(evt); return IRQ_HANDLED; -- 2.7.0
next reply other threads:[~2016-03-29 8:08 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-03-29 8:08 Rabin Vincent [this message] 2016-03-29 8:08 ` [PATCH] clockevents/drivers/arm_global_timer: Fix erratum 740657 workaround Rabin Vincent 2016-03-29 14:21 ` Daniel Lezcano 2016-03-29 14:21 ` Daniel Lezcano 2016-04-04 10:32 ` Rabin Vincent 2016-04-04 10:32 ` Rabin Vincent 2016-03-29 16:13 ` Marc Zyngier 2016-03-29 16:13 ` Marc Zyngier 2016-04-04 11:53 ` Rabin Vincent 2016-04-04 11:53 ` Rabin Vincent
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=1459238917-2240-1-git-send-email-rabin.vincent@axis.com \ --to=rabin.vincent@axis.com \ --cc=daniel.lezcano@linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=maxime.coquelin@st.com \ --cc=patrice.chotard@st.com \ --cc=rabinv@axis.com \ --cc=srinivas.kandagatla@gmail.com \ --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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.