[PATCH] LoongArch: Fix the !CONFIG_SMP build for irqchip drivers

From: Huacai Chen
Date: Wed Aug 10 2022 - 06:32:00 EST


1, Guard get_ipi_irq() in CONFIG_SMP;
2, Define cpu_logical_map() for the EIOINTC driver;
3, Make eiointc_set_irq_affinity() return early for !CONFIG_SMP.

Signed-off-by: Huacai Chen <chenhuacai@xxxxxxxxxxx>
---
arch/loongarch/include/asm/smp.h | 8 ++++++++
arch/loongarch/kernel/irq.c | 2 ++
drivers/irqchip/irq-loongson-eiointc.c | 5 +++++
3 files changed, 15 insertions(+)

diff --git a/arch/loongarch/include/asm/smp.h b/arch/loongarch/include/asm/smp.h
index 71189b28bfb2..9ee5a309df5b 100644
--- a/arch/loongarch/include/asm/smp.h
+++ b/arch/loongarch/include/asm/smp.h
@@ -12,6 +12,8 @@
#include <linux/threads.h>
#include <linux/cpumask.h>

+#ifdef CONFIG_SMP
+
extern int smp_num_siblings;
extern int num_processors;
extern int disabled_cpus;
@@ -112,4 +114,10 @@ static inline void __cpu_die(unsigned int cpu)
extern void play_dead(void);
#endif

+#else /* !CONFIG_SMP */
+
+#define cpu_logical_map(cpu) 0
+
+#endif
+
#endif /* __ASM_SMP_H */
diff --git a/arch/loongarch/kernel/irq.c b/arch/loongarch/kernel/irq.c
index 1ba19c76563e..d83623bc59fa 100644
--- a/arch/loongarch/kernel/irq.c
+++ b/arch/loongarch/kernel/irq.c
@@ -87,6 +87,7 @@ static void __init init_vec_parent_group(void)
acpi_table_parse(ACPI_SIG_MCFG, early_pci_mcfg_parse);
}

+#ifdef CONFIG_SMP
static int __init get_ipi_irq(void)
{
struct irq_domain *d = irq_find_matching_fwnode(cpuintc_handle, DOMAIN_BUS_ANY);
@@ -96,6 +97,7 @@ static int __init get_ipi_irq(void)

return -EINVAL;
}
+#endif

void __init init_IRQ(void)
{
diff --git a/drivers/irqchip/irq-loongson-eiointc.c b/drivers/irqchip/irq-loongson-eiointc.c
index 80d8ca6f2d46..17f94f3c11af 100644
--- a/drivers/irqchip/irq-loongson-eiointc.c
+++ b/drivers/irqchip/irq-loongson-eiointc.c
@@ -18,6 +18,8 @@
#include <linux/of_irq.h>
#include <linux/of_platform.h>

+#include <asm/smp.h>
+
#define EIOINTC_REG_NODEMAP 0x14a0
#define EIOINTC_REG_IPMAP 0x14c0
#define EIOINTC_REG_ENABLE 0x1600
@@ -96,6 +98,9 @@ static int eiointc_set_irq_affinity(struct irq_data *d, const struct cpumask *af
struct cpumask intersect_affinity;
struct eiointc_priv *priv = d->domain->host_data;

+ if (!IS_ENABLED(CONFIG_SMP))
+ return -EPERM;
+
raw_spin_lock_irqsave(&affinity_lock, flags);

cpumask_and(&intersect_affinity, affinity, cpu_online_mask);
--
2.31.1