diff mbox series

[01/15] irqchip/sifive-plic: set max threshold for ignored handlers

Message ID 20190813154747.24256-2-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [01/15] irqchip/sifive-plic: set max threshold for ignored handlers | expand

Commit Message

Christoph Hellwig Aug. 13, 2019, 3:47 p.m. UTC
When running in M-mode we still the S-mode plic handlers in the DT.
Ignore them by setting the maximum threshold.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/irqchip/irq-sifive-plic.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Paul Walmsley Aug. 13, 2019, 5:44 p.m. UTC | #1
Thomas, Jason, Marc,

On Tue, 13 Aug 2019, Christoph Hellwig wrote:

> When running in M-mode we still the S-mode plic handlers in the DT.
> Ignore them by setting the maximum threshold.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

If you're happy with this, could one of you ack it so we can merge it 
with the rest of this series through the RISC-V tree?

thanks

- Paul

> ---
>  drivers/irqchip/irq-sifive-plic.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c
> index cf755964f2f8..c72c036aea76 100644
> --- a/drivers/irqchip/irq-sifive-plic.c
> +++ b/drivers/irqchip/irq-sifive-plic.c
> @@ -244,6 +244,7 @@ static int __init plic_init(struct device_node *node,
>  		struct plic_handler *handler;
>  		irq_hw_number_t hwirq;
>  		int cpu, hartid;
> +		u32 threshold = 0;
>  
>  		if (of_irq_parse_one(node, i, &parent)) {
>  			pr_err("failed to parse parent for context %d.\n", i);
> @@ -266,10 +267,16 @@ static int __init plic_init(struct device_node *node,
>  			continue;
>  		}
>  
> +		/*
> +		 * When running in M-mode we need to ignore the S-mode handler.
> +		 * Here we assume it always comes later, but that might be a
> +		 * little fragile.
> +		 */
>  		handler = per_cpu_ptr(&plic_handlers, cpu);
>  		if (handler->present) {
>  			pr_warn("handler already present for context %d.\n", i);
> -			continue;
> +			threshold = 0xffffffff;
> +			goto done;
>  		}
>  
>  		handler->present = true;
> @@ -279,8 +286,9 @@ static int __init plic_init(struct device_node *node,
>  		handler->enable_base =
>  			plic_regs + ENABLE_BASE + i * ENABLE_PER_HART;
>  
> +done:
>  		/* priority must be > threshold to trigger an interrupt */
> -		writel(0, handler->hart_base + CONTEXT_THRESHOLD);
> +		writel(threshold, handler->hart_base + CONTEXT_THRESHOLD);
>  		for (hwirq = 1; hwirq <= nr_irqs; hwirq++)
>  			plic_toggle(handler, hwirq, 0);
>  		nr_handlers++;
> -- 
> 2.20.1
> 
>
Marc Zyngier Aug. 14, 2019, 9:06 a.m. UTC | #2
On Tue, 13 Aug 2019 18:44:02 +0100,
Paul Walmsley <paul.walmsley@sifive.com> wrote:

Hi Paul,

> 
> Thomas, Jason, Marc,
> 
> On Tue, 13 Aug 2019, Christoph Hellwig wrote:
> 
> > When running in M-mode we still the S-mode plic handlers in the DT.

                           ^^^^ missing word?

> > Ignore them by setting the maximum threshold.
> > 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> If you're happy with this, could one of you ack it so we can merge it 
> with the rest of this series through the RISC-V tree?

Sure, no problem.

Acked-by: Marc Zyngier <maz@kernel.org>

Thanks,

	M.
diff mbox series

Patch

diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive-plic.c
index cf755964f2f8..c72c036aea76 100644
--- a/drivers/irqchip/irq-sifive-plic.c
+++ b/drivers/irqchip/irq-sifive-plic.c
@@ -244,6 +244,7 @@  static int __init plic_init(struct device_node *node,
 		struct plic_handler *handler;
 		irq_hw_number_t hwirq;
 		int cpu, hartid;
+		u32 threshold = 0;
 
 		if (of_irq_parse_one(node, i, &parent)) {
 			pr_err("failed to parse parent for context %d.\n", i);
@@ -266,10 +267,16 @@  static int __init plic_init(struct device_node *node,
 			continue;
 		}
 
+		/*
+		 * When running in M-mode we need to ignore the S-mode handler.
+		 * Here we assume it always comes later, but that might be a
+		 * little fragile.
+		 */
 		handler = per_cpu_ptr(&plic_handlers, cpu);
 		if (handler->present) {
 			pr_warn("handler already present for context %d.\n", i);
-			continue;
+			threshold = 0xffffffff;
+			goto done;
 		}
 
 		handler->present = true;
@@ -279,8 +286,9 @@  static int __init plic_init(struct device_node *node,
 		handler->enable_base =
 			plic_regs + ENABLE_BASE + i * ENABLE_PER_HART;
 
+done:
 		/* priority must be > threshold to trigger an interrupt */
-		writel(0, handler->hart_base + CONTEXT_THRESHOLD);
+		writel(threshold, handler->hart_base + CONTEXT_THRESHOLD);
 		for (hwirq = 1; hwirq <= nr_irqs; hwirq++)
 			plic_toggle(handler, hwirq, 0);
 		nr_handlers++;