forked from torvalds/linux
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RISC-V: Treat IPIs as normal Linux IRQs
Currently, the RISC-V kernel provides arch specific hooks (i.e. struct riscv_ipi_ops) to register IPI handling methods. The stats gathering of IPIs is also arch specific in the RISC-V kernel. Other architectures (such as ARM, ARM64, and MIPS) have moved away from custom arch specific IPI handling methods. Currently, these architectures have Linux irqchip drivers providing a range of Linux IRQ numbers to be used as IPIs and IPI triggering is done using generic IPI APIs. This approach allows architectures to treat IPIs as normal Linux IRQs and IPI stats gathering is done by the generic Linux IRQ subsystem. We extend the RISC-V IPI handling as-per above approach so that arch specific IPI handling methods (struct riscv_ipi_ops) can be removed and the IPI handling is done through the Linux IRQ subsystem. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
- Loading branch information
Showing
12 changed files
with
222 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
/* | ||
* Multiplex several IPIs over a single HW IPI. | ||
* | ||
* Copyright (c) 2022 Ventana Micro Systems Inc. | ||
*/ | ||
|
||
#define pr_fmt(fmt) "riscv: " fmt | ||
#include <linux/init.h> | ||
#include <linux/irq.h> | ||
#include <linux/irqdomain.h> | ||
#include <asm/sbi.h> | ||
|
||
static void sbi_send_cpumask_ipi(unsigned int parent_virq, | ||
const struct cpumask *target) | ||
{ | ||
sbi_send_ipi(target); | ||
} | ||
|
||
static void sbi_ipi_clear(unsigned int parent_virq) | ||
{ | ||
csr_clear(CSR_IP, IE_SIE); | ||
} | ||
|
||
static struct ipi_mux_ops sbi_ipi_ops = { | ||
.ipi_mux_clear = sbi_ipi_clear, | ||
.ipi_mux_send = sbi_send_cpumask_ipi, | ||
}; | ||
|
||
void __init sbi_ipi_init(void) | ||
{ | ||
int virq, parent_virq; | ||
struct irq_domain *domain; | ||
|
||
if (riscv_ipi_have_virq_range()) | ||
return; | ||
|
||
domain = irq_find_matching_fwnode(riscv_get_intc_hwnode(), | ||
DOMAIN_BUS_ANY); | ||
if (!domain) { | ||
pr_err("unable to find INTC IRQ domain\n"); | ||
return; | ||
} | ||
|
||
parent_virq = irq_create_mapping(domain, RV_IRQ_SOFT); | ||
if (!parent_virq) { | ||
pr_err("unable to create INTC IRQ mapping\n"); | ||
return; | ||
} | ||
|
||
virq = ipi_mux_create(parent_virq, &sbi_ipi_ops); | ||
if (virq <= 0) { | ||
pr_err("unable to create muxed IPIs\n"); | ||
irq_dispose_mapping(parent_virq); | ||
return; | ||
} | ||
|
||
riscv_ipi_set_virq_range(virq, IPI_MUX_NR_IRQS); | ||
pr_info("providing IPIs using SBI IPI extension\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.