From patchwork Fri Jul 5 14:16:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13725202 Received: from fhigh2-smtp.messagingengine.com (fhigh2-smtp.messagingengine.com [103.168.172.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F39B016B741; Fri, 5 Jul 2024 14:17:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189045; cv=none; b=njXsl16WDEGNBtt4pRAAgMfI6a2bvBkFB/stRVhfGCJygXlo/uIlcgqnz1a1PP2IecM/xiN0S+IiUsTu3k99MsO/nsfLSCnuHnlwkkliE6OD+HBJz1P6ZRzxtAWjC9wvmdV8RNyIeaKmzSrw2r1MIaZeOpslNVyDjYGby+YxrMw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189045; c=relaxed/simple; bh=WRfoBuexMadsWame2fNh2rILty4lO1jQ4CpB+8CiYgo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KrNwz+APY1tycQ9L9uaCeFTI1cjVL9+Xv84fZJjutAtUVCJhYFeeqOxRKvPPs05VfAf6ifIb+dyHuLD6eDlBCQqDkF4oCAhsmS1XSj4zQGhLyIdvmWhsXvXVKpM76sxd7AT/Tj07jtFJ2HFNeeSHTeiyJb3bJcZWK2ARhzW+zZU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=PhcNIk3D; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=bhAe6gdY; arc=none smtp.client-ip=103.168.172.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="PhcNIk3D"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="bhAe6gdY" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfhigh.nyi.internal (Postfix) with ESMTP id F2F121140065; Fri, 5 Jul 2024 10:17:21 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 05 Jul 2024 10:17:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1720189041; x=1720275441; bh=t/w2fgisjV5hQEdkUgdZJovN6vGi67b6qnolYYpgQ60=; b= PhcNIk3DLj+fQkRGGTV77ue6cpfwg+RmNTF9rMpjrEuQK2uIsscTdPXDCmovusTC R3WVQ1ILi3RgsGvWH/URqrkQLIUDBR6MED/3s3V3ds6mmU5rVy0PB9XCJssSDP9c 1I9EfoiJyoPXDQXFJIzID18qiPGQQ549Nuva/tvkgwDQAiVo4Hn32SNl/wF1RwMU XW7JKuRpdOdy0ZrXUHy05lHCS8FDDgnlMR27bEBTe0r8eGqtb5rOxns7dLkBn3Wg kjbEIHDv0OGBiZqPE6WLhuZegpfc8ILxMY2Wfttu7pvePlyoTT/Yrg6Y1s4Hj54m SCzTJIiUBFgZCM8LzBKGMw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1720189041; x= 1720275441; bh=t/w2fgisjV5hQEdkUgdZJovN6vGi67b6qnolYYpgQ60=; b=b hAe6gdYpwo7reB8Xh8fMUkmkWYSGCD9XRNjDih8eKjyd1i7kmVKHAtXeu8Kda06s esyY5NerbqX+FXPWZJMgsjFEeSi4qNcuBbSFWzpTWS3ohtVWuXcXaiw3HtPlwgoa FWp7nabv0CwxbhFF6r4LOIsfjyfYSHbjsP9MXqH6JHTgBla3KWbtrcrjRBjynUga 4aLwNcdf6hLAhsl6TxfzOw5H8hYSaDnpZfEhXTAPnZLq4kVa/VkzFkW6dWq7a41p PLB9sfN57y7Ad18zoF4n1s4CBhlGt2lAdTO6PQXB9joW1xUUH05aAhmd4wLjJqir MFRMTkp+QSl2fuKTAzl4w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddugdejfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheplfhirgig uhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhmqeenuc ggtffrrghtthgvrhhnpedvkeeihfefveekueevteefleffkeegudeghfdtuddugefhueev geffgedukeejleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 Jul 2024 10:17:18 -0400 (EDT) From: Jiaxun Yang Date: Fri, 05 Jul 2024 22:16:53 +0800 Subject: [PATCH v2 01/10] MIPS: smp: Make IPI interrupts scalable Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240705-b4-mips-ipi-improvements-v2-1-2d50b56268e8@flygoat.com> References: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> In-Reply-To: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> To: Thomas Bogendoerfer , Florian Fainelli , Broadcom internal kernel review list , Huacai Chen , Thomas Gleixner , Serge Semin , Paul Burton Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=31406; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=WRfoBuexMadsWame2fNh2rILty4lO1jQ4CpB+8CiYgo=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrQOhnSJFQVuAiZHeTmiBCcaWpZPPPdu3Vv9LV8VQ0xqv j7+/+xGRykLgxgXg6yYIkuIgFLfhsaLC64/yPoDM4eVCWQIAxenAExEfyUjw5mTikVvFDZN6NzO dOKA7Ub1Z1f3dAcwnF3Gbqxr823/ly6G//HRIsV3Vl5++rXcvoxdN+HBjHauS/8fWuSrnrks5OD JwwUA X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Define enum ipi_message_type as other architectures did to allow easy extension to number of IPI interrupts, fiddle around platform IPI code to adopt to the new infra, add extensive BUILD_BUG_ON on IPI numbers to ensure future extensions won't break existing platforms. IPI related stuff are pulled to asm/ipi.h to avoid include linux/interrupt.h in asm/smp.h. Signed-off-by: Jiaxun Yang --- arch/mips/cavium-octeon/smp.c | 111 ++++++++++-------------------- arch/mips/fw/arc/init.c | 1 - arch/mips/include/asm/ipi.h | 34 ++++++++++ arch/mips/include/asm/octeon/octeon.h | 2 + arch/mips/include/asm/smp-ops.h | 8 +-- arch/mips/include/asm/smp.h | 42 +++++------- arch/mips/kernel/smp-bmips.c | 43 ++++++------ arch/mips/kernel/smp-cps.c | 1 + arch/mips/kernel/smp.c | 124 +++++++++++++++++----------------- arch/mips/loongson64/smp.c | 52 +++++++------- arch/mips/mm/c-octeon.c | 3 +- arch/mips/sgi-ip27/ip27-smp.c | 15 ++-- arch/mips/sgi-ip30/ip30-smp.c | 15 ++-- arch/mips/sibyte/bcm1480/smp.c | 19 +++--- arch/mips/sibyte/sb1250/smp.c | 13 ++-- 15 files changed, 240 insertions(+), 243 deletions(-) diff --git a/arch/mips/cavium-octeon/smp.c b/arch/mips/cavium-octeon/smp.c index 08ea2cde1eb5..229bb8f1f791 100644 --- a/arch/mips/cavium-octeon/smp.c +++ b/arch/mips/cavium-octeon/smp.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -40,30 +41,19 @@ EXPORT_SYMBOL(octeon_bootloader_entry_addr); extern void kernel_entry(unsigned long arg1, ...); -static void octeon_icache_flush(void) +static irqreturn_t octeon_icache_flush(int irq, void *dev_id) { asm volatile ("synci 0($0)\n"); + return IRQ_HANDLED; } -static void (*octeon_message_functions[8])(void) = { - scheduler_ipi, - generic_smp_call_function_interrupt, - octeon_icache_flush, -}; - static irqreturn_t mailbox_interrupt(int irq, void *dev_id) { u64 mbox_clrx = CVMX_CIU_MBOX_CLRX(cvmx_get_core_num()); - u64 action; - int i; + unsigned long action; + int op; - /* - * Make sure the function array initialization remains - * correct. - */ - BUILD_BUG_ON(SMP_RESCHEDULE_YOURSELF != (1 << 0)); - BUILD_BUG_ON(SMP_CALL_FUNCTION != (1 << 1)); - BUILD_BUG_ON(SMP_ICACHE_FLUSH != (1 << 2)); + BUILD_BUG_ON(IPI_MAX > 8); /* * Load the mailbox register to figure out what we're supposed @@ -79,16 +69,10 @@ static irqreturn_t mailbox_interrupt(int irq, void *dev_id) /* Clear the mailbox to clear the interrupt */ cvmx_write_csr(mbox_clrx, action); - for (i = 0; i < ARRAY_SIZE(octeon_message_functions) && action;) { - if (action & 1) { - void (*fn)(void) = octeon_message_functions[i]; - - if (fn) - fn(); - } - action >>= 1; - i++; + for_each_set_bit(op, &action, IPI_MAX) { + ipi_handlers[op](0, NULL); } + return IRQ_HANDLED; } @@ -97,23 +81,23 @@ static irqreturn_t mailbox_interrupt(int irq, void *dev_id) * cpu. When the function has finished, increment the finished field of * call_data. */ -void octeon_send_ipi_single(int cpu, unsigned int action) +void octeon_send_ipi_single(int cpu, enum ipi_message_type op) { int coreid = cpu_logical_map(cpu); /* pr_info("SMP: Mailbox send cpu=%d, coreid=%d, action=%u\n", cpu, coreid, action); */ - cvmx_write_csr(CVMX_CIU_MBOX_SETX(coreid), action); + cvmx_write_csr(CVMX_CIU_MBOX_SETX(coreid), op); } -static inline void octeon_send_ipi_mask(const struct cpumask *mask, - unsigned int action) +static void octeon_send_ipi_mask(const struct cpumask *mask, + enum ipi_message_type op) { unsigned int i; for_each_cpu(i, mask) - octeon_send_ipi_single(i, action); + octeon_send_ipi_single(i, op); } /* @@ -149,6 +133,9 @@ static void __init octeon_smp_setup(void) unsigned int num_cores = cvmx_octeon_num_cores(); #endif + ipi_handlers[IPI_ICACHE_FLUSH] = octeon_icache_flush; + ipi_names[IPI_ICACHE_FLUSH] = "Octeon ICache Flush"; + /* The present CPUs are initially just the boot cpu (CPU 0). */ for (id = 0; id < NR_CPUS; id++) { set_cpu_possible(id, id == 0); @@ -427,67 +414,41 @@ static const struct plat_smp_ops octeon_smp_ops = { #endif }; -static irqreturn_t octeon_78xx_reched_interrupt(int irq, void *dev_id) -{ - scheduler_ipi(); - return IRQ_HANDLED; -} - -static irqreturn_t octeon_78xx_call_function_interrupt(int irq, void *dev_id) -{ - generic_smp_call_function_interrupt(); - return IRQ_HANDLED; -} - -static irqreturn_t octeon_78xx_icache_flush_interrupt(int irq, void *dev_id) -{ - octeon_icache_flush(); - return IRQ_HANDLED; -} - /* * Callout to firmware before smp_init */ static void octeon_78xx_prepare_cpus(unsigned int max_cpus) { - if (request_irq(OCTEON_IRQ_MBOX0 + 0, - octeon_78xx_reched_interrupt, - IRQF_PERCPU | IRQF_NO_THREAD, "Scheduler", - octeon_78xx_reched_interrupt)) { - panic("Cannot request_irq for SchedulerIPI"); - } - if (request_irq(OCTEON_IRQ_MBOX0 + 1, - octeon_78xx_call_function_interrupt, - IRQF_PERCPU | IRQF_NO_THREAD, "SMP-Call", - octeon_78xx_call_function_interrupt)) { - panic("Cannot request_irq for SMP-Call"); - } - if (request_irq(OCTEON_IRQ_MBOX0 + 2, - octeon_78xx_icache_flush_interrupt, - IRQF_PERCPU | IRQF_NO_THREAD, "ICache-Flush", - octeon_78xx_icache_flush_interrupt)) { - panic("Cannot request_irq for ICache-Flush"); + int i; + + /* + * FIXME: Hardware have 10 MBOX but only 4 virqs are reserved + * for CIU3 MBOX. + */ + BUILD_BUG_ON(IPI_MAX > 4); + + for (i = 0; i < IPI_MAX; i++) { + if (request_irq(OCTEON_IRQ_MBOX0 + i, + ipi_handlers[i], + IRQF_PERCPU | IRQF_NO_THREAD, "IPI", + ipi_handlers[i])) { + panic("Cannot request_irq for %s", ipi_names[i]); + } } } -static void octeon_78xx_send_ipi_single(int cpu, unsigned int action) +static void octeon_78xx_send_ipi_single(int cpu, enum ipi_message_type op) { - int i; - - for (i = 0; i < 8; i++) { - if (action & 1) - octeon_ciu3_mbox_send(cpu, i); - action >>= 1; - } + octeon_ciu3_mbox_send(cpu, op); } static void octeon_78xx_send_ipi_mask(const struct cpumask *mask, - unsigned int action) + enum ipi_message_type op) { unsigned int cpu; for_each_cpu(cpu, mask) - octeon_78xx_send_ipi_single(cpu, action); + octeon_78xx_send_ipi_single(cpu, op); } static const struct plat_smp_ops octeon_78xx_smp_ops = { diff --git a/arch/mips/fw/arc/init.c b/arch/mips/fw/arc/init.c index f9d1dea9b2ca..3d69d2f851bc 100644 --- a/arch/mips/fw/arc/init.c +++ b/arch/mips/fw/arc/init.c @@ -12,7 +12,6 @@ #include #include -#include #undef DEBUG_PROM_INIT diff --git a/arch/mips/include/asm/ipi.h b/arch/mips/include/asm/ipi.h new file mode 100644 index 000000000000..df7a0ac4227a --- /dev/null +++ b/arch/mips/include/asm/ipi.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#include +#include + +#ifndef __ASM_IPI_H +#define __ASM_IPI_H + +#ifdef CONFIG_SMP +extern const char *ipi_names[]; +extern irq_handler_t ipi_handlers[]; + +#ifdef CONFIG_GENERIC_IRQ_IPI +extern void mips_smp_send_ipi_single(int cpu, + enum ipi_message_type op); +extern void mips_smp_send_ipi_mask(const struct cpumask *mask, + enum ipi_message_type op); + +/* + * This function will set up the necessary IPIs for Linux to communicate + * with the CPUs in mask. + * Return 0 on success. + */ +int mips_smp_ipi_allocate(const struct cpumask *mask); + +/* + * This function will free up IPIs allocated with mips_smp_ipi_allocate to the + * CPUs in mask, which must be a subset of the IPIs that have been configured. + * Return 0 on success. + */ +int mips_smp_ipi_free(const struct cpumask *mask); +#endif /* CONFIG_GENERIC_IRQ_IPI */ +#endif /* CONFIG_SMP */ +#endif diff --git a/arch/mips/include/asm/octeon/octeon.h b/arch/mips/include/asm/octeon/octeon.h index 5c1d726c702f..534155e88107 100644 --- a/arch/mips/include/asm/octeon/octeon.h +++ b/arch/mips/include/asm/octeon/octeon.h @@ -49,6 +49,8 @@ extern void octeon_init_cvmcount(void); extern void octeon_setup_delays(void); extern void octeon_io_clk_delay(unsigned long); +extern void octeon_send_ipi_single(int cpu, enum ipi_message_type op); + #define OCTEON_ARGV_MAX_ARGS 64 #define OCTEON_SERIAL_LEN 20 diff --git a/arch/mips/include/asm/smp-ops.h b/arch/mips/include/asm/smp-ops.h index 1617b207723f..8cf4156cb301 100644 --- a/arch/mips/include/asm/smp-ops.h +++ b/arch/mips/include/asm/smp-ops.h @@ -20,8 +20,8 @@ struct task_struct; struct plat_smp_ops { - void (*send_ipi_single)(int cpu, unsigned int action); - void (*send_ipi_mask)(const struct cpumask *mask, unsigned int action); + void (*send_ipi_single)(int cpu, enum ipi_message_type op); + void (*send_ipi_mask)(const struct cpumask *mask, enum ipi_message_type op); void (*init_secondary)(void); void (*smp_finish)(void); int (*boot_secondary)(int cpu, struct task_struct *idle); @@ -47,10 +47,6 @@ static inline void plat_smp_setup(void) mp_ops->smp_setup(); } -extern void mips_smp_send_ipi_single(int cpu, unsigned int action); -extern void mips_smp_send_ipi_mask(const struct cpumask *mask, - unsigned int action); - #else /* !CONFIG_SMP */ struct plat_smp_ops; diff --git a/arch/mips/include/asm/smp.h b/arch/mips/include/asm/smp.h index bc2c240f414b..0c7467f15014 100644 --- a/arch/mips/include/asm/smp.h +++ b/arch/mips/include/asm/smp.h @@ -16,8 +16,6 @@ #include #include -#include - extern int smp_num_siblings; extern cpumask_t cpu_sibling_map[]; extern cpumask_t cpu_core_map[]; @@ -46,12 +44,6 @@ extern int __cpu_logical_map[NR_CPUS]; #define NO_PROC_ID (-1) -#define SMP_RESCHEDULE_YOURSELF 0x1 /* XXX braindead */ -#define SMP_CALL_FUNCTION 0x2 -/* Octeon - Tell another core to flush its icache */ -#define SMP_ICACHE_FLUSH 0x4 -#define SMP_ASK_C0COUNT 0x8 - /* Mask of CPUs which are currently definitely operating coherently */ extern cpumask_t cpu_coherent_mask; @@ -63,6 +55,20 @@ extern void calculate_cpu_foreign_map(void); asmlinkage void start_secondary(void); +enum ipi_message_type { + IPI_RESCHEDULE, + IPI_CALL_FUNC, +#ifdef CONFIG_CAVIUM_OCTEON_SOC + IPI_ICACHE_FLUSH, +#endif +#ifdef CONFIG_MACH_LOONGSON64 + IPI_ASK_C0COUNT, +#endif + IPI_MAX +}; + +#include + /* * this function sends a 'reschedule' IPI to another CPU. * it goes straight through and wastes no time serializing @@ -72,7 +78,7 @@ static inline void arch_smp_send_reschedule(int cpu) { extern const struct plat_smp_ops *mp_ops; /* private */ - mp_ops->send_ipi_single(cpu, SMP_RESCHEDULE_YOURSELF); + mp_ops->send_ipi_single(cpu, IPI_RESCHEDULE); } #ifdef CONFIG_HOTPLUG_CPU @@ -109,32 +115,18 @@ static inline void *kexec_nonboot_cpu_func(void) } #endif -/* - * This function will set up the necessary IPIs for Linux to communicate - * with the CPUs in mask. - * Return 0 on success. - */ -int mips_smp_ipi_allocate(const struct cpumask *mask); - -/* - * This function will free up IPIs allocated with mips_smp_ipi_allocate to the - * CPUs in mask, which must be a subset of the IPIs that have been configured. - * Return 0 on success. - */ -int mips_smp_ipi_free(const struct cpumask *mask); - static inline void arch_send_call_function_single_ipi(int cpu) { extern const struct plat_smp_ops *mp_ops; /* private */ - mp_ops->send_ipi_single(cpu, SMP_CALL_FUNCTION); + mp_ops->send_ipi_single(cpu, IPI_CALL_FUNC); } static inline void arch_send_call_function_ipi_mask(const struct cpumask *mask) { extern const struct plat_smp_ops *mp_ops; /* private */ - mp_ops->send_ipi_mask(mask, SMP_CALL_FUNCTION); + mp_ops->send_ipi_mask(mask, IPI_CALL_FUNC); } #endif /* __ASM_SMP_H */ diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c index 35b8d810833c..fa9ccefa8392 100644 --- a/arch/mips/kernel/smp-bmips.c +++ b/arch/mips/kernel/smp-bmips.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -282,36 +283,31 @@ static void bmips_smp_finish(void) * BMIPS5000 raceless IPIs * * Each CPU has two inbound SW IRQs which are independent of all other CPUs. - * IPI0 is used for SMP_RESCHEDULE_YOURSELF - * IPI1 is used for SMP_CALL_FUNCTION */ -static void bmips5000_send_ipi_single(int cpu, unsigned int action) +static void bmips5000_send_ipi_single(int cpu, enum ipi_message_type op) { - write_c0_brcm_action(ACTION_SET_IPI(cpu, action == SMP_CALL_FUNCTION)); + write_c0_brcm_action(ACTION_SET_IPI(cpu, op)); } static irqreturn_t bmips5000_ipi_interrupt(int irq, void *dev_id) { int action = irq - IPI0_IRQ; - write_c0_brcm_action(ACTION_CLR_IPI(smp_processor_id(), action)); + BUILD_BUG_ON(IPI_MAX > 2); - if (action == 0) - scheduler_ipi(); - else - generic_smp_call_function_interrupt(); + write_c0_brcm_action(ACTION_CLR_IPI(smp_processor_id(), action)); - return IRQ_HANDLED; + return ipi_handlers[action](0, NULL); } static void bmips5000_send_ipi_mask(const struct cpumask *mask, - unsigned int action) + enum ipi_message_type op) { unsigned int i; for_each_cpu(i, mask) - bmips5000_send_ipi_single(i, action); + bmips5000_send_ipi_single(i, op); } /* @@ -325,23 +321,26 @@ static void bmips5000_send_ipi_mask(const struct cpumask *mask, */ static DEFINE_SPINLOCK(ipi_lock); -static DEFINE_PER_CPU(int, ipi_action_mask); +static DEFINE_PER_CPU(unsigned long, ipi_action_mask); -static void bmips43xx_send_ipi_single(int cpu, unsigned int action) +static void bmips43xx_send_ipi_single(int cpu, enum ipi_message_type op) { unsigned long flags; spin_lock_irqsave(&ipi_lock, flags); set_c0_cause(cpu ? C_SW1 : C_SW0); - per_cpu(ipi_action_mask, cpu) |= action; + per_cpu(ipi_action_mask, cpu) |= BIT(op); irq_enable_hazard(); spin_unlock_irqrestore(&ipi_lock, flags); } static irqreturn_t bmips43xx_ipi_interrupt(int irq, void *dev_id) { - unsigned long flags; - int action, cpu = irq - IPI0_IRQ; + unsigned long flags, action; + int cpu = irq - IPI0_IRQ; + int op; + + BUILD_BUG_ON(IPI_MAX > BITS_PER_LONG); spin_lock_irqsave(&ipi_lock, flags); action = __this_cpu_read(ipi_action_mask); @@ -349,21 +348,19 @@ static irqreturn_t bmips43xx_ipi_interrupt(int irq, void *dev_id) clear_c0_cause(cpu ? C_SW1 : C_SW0); spin_unlock_irqrestore(&ipi_lock, flags); - if (action & SMP_RESCHEDULE_YOURSELF) - scheduler_ipi(); - if (action & SMP_CALL_FUNCTION) - generic_smp_call_function_interrupt(); + for_each_set_bit(op, &action, IPI_MAX) + ipi_handlers[op](0, NULL); return IRQ_HANDLED; } static void bmips43xx_send_ipi_mask(const struct cpumask *mask, - unsigned int action) + enum ipi_message_type op) { unsigned int i; for_each_cpu(i, mask) - bmips43xx_send_ipi_single(i, action); + bmips43xx_send_ipi_single(i, op); } #ifdef CONFIG_HOTPLUG_CPU diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c index 9cc087dd1c19..8c322f441164 100644 --- a/arch/mips/kernel/smp-cps.c +++ b/arch/mips/kernel/smp-cps.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c index 0b53d35a116e..a6cf6444533e 100644 --- a/arch/mips/kernel/smp.c +++ b/arch/mips/kernel/smp.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -92,11 +93,6 @@ static int __init early_smt(char *s) } early_param("smt", early_smt); -#ifdef CONFIG_GENERIC_IRQ_IPI -static struct irq_desc *call_desc; -static struct irq_desc *sched_desc; -#endif - static inline void set_cpu_sibling_map(int cpu) { int i; @@ -164,13 +160,42 @@ void register_smp_ops(const struct plat_smp_ops *ops) mp_ops = ops; } +static irqreturn_t ipi_resched_interrupt(int irq, void *dev_id) +{ + scheduler_ipi(); + + return IRQ_HANDLED; +} + +static irqreturn_t ipi_call_interrupt(int irq, void *dev_id) +{ + generic_smp_call_function_interrupt(); + + return IRQ_HANDLED; +} + + +const char *ipi_names[IPI_MAX] __read_mostly = { + [IPI_RESCHEDULE] = "Rescheduling interrupts", + [IPI_CALL_FUNC] = "Function call interrupts", +}; + +irq_handler_t ipi_handlers[IPI_MAX] __read_mostly = { + [IPI_RESCHEDULE] = ipi_resched_interrupt, + [IPI_CALL_FUNC] = ipi_call_interrupt, +}; + #ifdef CONFIG_GENERIC_IRQ_IPI -void mips_smp_send_ipi_single(int cpu, unsigned int action) +static int ipi_virqs[IPI_MAX] __ro_after_init; +static struct irq_desc *ipi_desc[IPI_MAX] __read_mostly; + +void mips_smp_send_ipi_single(int cpu, enum ipi_message_type op) { - mips_smp_send_ipi_mask(cpumask_of(cpu), action); + mips_smp_send_ipi_mask(cpumask_of(cpu), op); } -void mips_smp_send_ipi_mask(const struct cpumask *mask, unsigned int action) +void mips_smp_send_ipi_mask(const struct cpumask *mask, + enum ipi_message_type op) { unsigned long flags; unsigned int core; @@ -178,18 +203,7 @@ void mips_smp_send_ipi_mask(const struct cpumask *mask, unsigned int action) local_irq_save(flags); - switch (action) { - case SMP_CALL_FUNCTION: - __ipi_send_mask(call_desc, mask); - break; - - case SMP_RESCHEDULE_YOURSELF: - __ipi_send_mask(sched_desc, mask); - break; - - default: - BUG(); - } + __ipi_send_mask(ipi_desc[op], mask); if (mips_cpc_present()) { for_each_cpu(cpu, mask) { @@ -211,21 +225,6 @@ void mips_smp_send_ipi_mask(const struct cpumask *mask, unsigned int action) local_irq_restore(flags); } - -static irqreturn_t ipi_resched_interrupt(int irq, void *dev_id) -{ - scheduler_ipi(); - - return IRQ_HANDLED; -} - -static irqreturn_t ipi_call_interrupt(int irq, void *dev_id) -{ - generic_smp_call_function_interrupt(); - - return IRQ_HANDLED; -} - static void smp_ipi_init_one(unsigned int virq, const char *name, irq_handler_t handler) { @@ -236,11 +235,9 @@ static void smp_ipi_init_one(unsigned int virq, const char *name, BUG_ON(ret); } -static unsigned int call_virq, sched_virq; - int mips_smp_ipi_allocate(const struct cpumask *mask) { - int virq; + int virq, i; struct irq_domain *ipidomain; struct device_node *node; @@ -267,33 +264,30 @@ int mips_smp_ipi_allocate(const struct cpumask *mask) * setup, if we're running with only a single CPU. */ if (!ipidomain) { - BUG_ON(num_present_cpus() > 1); + WARN_ON(num_present_cpus() > 1); return 0; } - virq = irq_reserve_ipi(ipidomain, mask); - BUG_ON(!virq); - if (!call_virq) - call_virq = virq; - - virq = irq_reserve_ipi(ipidomain, mask); - BUG_ON(!virq); - if (!sched_virq) - sched_virq = virq; + for (i = 0; i < IPI_MAX; i++) { + virq = irq_reserve_ipi(ipidomain, mask); + WARN_ON(!virq); + ipi_virqs[i] = virq; + } if (irq_domain_is_ipi_per_cpu(ipidomain)) { int cpu; for_each_cpu(cpu, mask) { - smp_ipi_init_one(call_virq + cpu, "IPI call", - ipi_call_interrupt); - smp_ipi_init_one(sched_virq + cpu, "IPI resched", - ipi_resched_interrupt); + for (i = 0; i < IPI_MAX; i++) { + smp_ipi_init_one(ipi_virqs[i] + cpu, ipi_names[i], + ipi_handlers[i]); + } } } else { - smp_ipi_init_one(call_virq, "IPI call", ipi_call_interrupt); - smp_ipi_init_one(sched_virq, "IPI resched", - ipi_resched_interrupt); + for (i = 0; i < IPI_MAX; i++) { + smp_ipi_init_one(ipi_virqs[i], ipi_names[i], + ipi_handlers[i]); + } } return 0; @@ -301,6 +295,7 @@ int mips_smp_ipi_allocate(const struct cpumask *mask) int mips_smp_ipi_free(const struct cpumask *mask) { + int i; struct irq_domain *ipidomain; struct device_node *node; @@ -321,25 +316,32 @@ int mips_smp_ipi_free(const struct cpumask *mask) int cpu; for_each_cpu(cpu, mask) { - free_irq(call_virq + cpu, NULL); - free_irq(sched_virq + cpu, NULL); + for (i = 0; i < IPI_MAX; i++) + free_irq(ipi_virqs[i] + cpu, NULL); } } - irq_destroy_ipi(call_virq, mask); - irq_destroy_ipi(sched_virq, mask); + + for (i = 0; i < IPI_MAX; i++) + irq_destroy_ipi(ipi_virqs[i], mask); + return 0; } static int __init mips_smp_ipi_init(void) { + int i; + if (num_possible_cpus() == 1) return 0; mips_smp_ipi_allocate(cpu_possible_mask); - call_desc = irq_to_desc(call_virq); - sched_desc = irq_to_desc(sched_virq); + for (i = 0; i < IPI_MAX; i++) { + ipi_desc[i] = irq_to_desc(ipi_virqs[i]); + if (!ipi_desc[i]) + return -ENODEV; + } return 0; } diff --git a/arch/mips/loongson64/smp.c b/arch/mips/loongson64/smp.c index 66d049cdcf14..b916be479041 100644 --- a/arch/mips/loongson64/smp.c +++ b/arch/mips/loongson64/smp.c @@ -13,8 +13,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -368,44 +368,44 @@ static void ipi_mailbox_buf_init(void) /* * Simple enough, just poke the appropriate ipi register */ -static void loongson3_send_ipi_single(int cpu, unsigned int action) +static void loongson3_send_ipi_single(int cpu, enum ipi_message_type op) { - ipi_write_action(cpu_logical_map(cpu), (u32)action); + ipi_write_action(cpu_logical_map(cpu), BIT(op)); } static void -loongson3_send_ipi_mask(const struct cpumask *mask, unsigned int action) +loongson3_send_ipi_mask(const struct cpumask *mask, enum ipi_message_type op) { unsigned int i; for_each_cpu(i, mask) - ipi_write_action(cpu_logical_map(i), (u32)action); + ipi_write_action(cpu_logical_map(i), BIT(op)); } - -static irqreturn_t loongson3_ipi_interrupt(int irq, void *dev_id) +static irqreturn_t loongson3_ask_c0count(int irq, void *dev_id) { int i, cpu = smp_processor_id(); - unsigned int action, c0count; + unsigned long c0count; - action = ipi_read_clear(cpu); + BUG_ON(cpu != 0); + c0count = read_c0_count(); + c0count = c0count ? c0count : 1; + for (i = 1; i < nr_cpu_ids; i++) + core0_c0count[i] = c0count; + nudge_writes(); /* Let others see the result ASAP */ - if (action & SMP_RESCHEDULE_YOURSELF) - scheduler_ipi(); + return IRQ_HANDLED; +} - if (action & SMP_CALL_FUNCTION) { - irq_enter(); - generic_smp_call_function_interrupt(); - irq_exit(); - } +static irqreturn_t loongson3_ipi_interrupt(int irq, void *dev_id) +{ + int op, cpu = smp_processor_id(); + unsigned long action; + + action = ipi_read_clear(cpu); - if (action & SMP_ASK_C0COUNT) { - BUG_ON(cpu != 0); - c0count = read_c0_count(); - c0count = c0count ? c0count : 1; - for (i = 1; i < nr_cpu_ids; i++) - core0_c0count[i] = c0count; - nudge_writes(); /* Let others see the result ASAP */ + for_each_set_bit(op, &action, IPI_MAX) { + ipi_handlers[op](0, NULL); } return IRQ_HANDLED; @@ -435,7 +435,7 @@ static void loongson3_init_secondary(void) i = 0; core0_c0count[cpu] = 0; - loongson3_send_ipi_single(0, SMP_ASK_C0COUNT); + loongson3_send_ipi_single(0, IPI_ASK_C0COUNT); while (!core0_c0count[cpu]) { i++; cpu_relax(); @@ -505,6 +505,10 @@ static void __init loongson3_smp_setup(void) __cpu_logical_map[num] = -1; num++; } + + ipi_handlers[IPI_ASK_C0COUNT] = loongson3_ask_c0count; + ipi_names[IPI_ASK_C0COUNT] = "Loongson Ask C0 Count"; + csr_ipi_probe(); ipi_set0_regs_init(); ipi_clear0_regs_init(); diff --git a/arch/mips/mm/c-octeon.c b/arch/mips/mm/c-octeon.c index b7393b61cfa7..5eef34720b87 100644 --- a/arch/mips/mm/c-octeon.c +++ b/arch/mips/mm/c-octeon.c @@ -62,7 +62,6 @@ static void local_octeon_flush_icache_range(unsigned long start, */ static void octeon_flush_icache_all_cores(struct vm_area_struct *vma) { - extern void octeon_send_ipi_single(int cpu, unsigned int action); #ifdef CONFIG_SMP int cpu; cpumask_t mask; @@ -85,7 +84,7 @@ static void octeon_flush_icache_all_cores(struct vm_area_struct *vma) cpumask_clear_cpu(cpu, &mask); #ifdef CONFIG_CAVIUM_OCTEON_SOC for_each_cpu(cpu, &mask) - octeon_send_ipi_single(cpu, SMP_ICACHE_FLUSH); + octeon_send_ipi_single(cpu, IPI_ICACHE_FLUSH); #else smp_call_function_many(&mask, (smp_call_func_t)octeon_local_flush_icache, NULL, 1); diff --git a/arch/mips/sgi-ip27/ip27-smp.c b/arch/mips/sgi-ip27/ip27-smp.c index 5d2652a1d35a..87da545d0c3f 100644 --- a/arch/mips/sgi-ip27/ip27-smp.c +++ b/arch/mips/sgi-ip27/ip27-smp.c @@ -94,15 +94,17 @@ static __init void intr_clear_all(nasid_t nasid) REMOTE_HUB_CLR_INTR(nasid, i); } -static void ip27_send_ipi_single(int destid, unsigned int action) +static void ip27_send_ipi_single(int destid, enum ipi_message_type op) { int irq; - switch (action) { - case SMP_RESCHEDULE_YOURSELF: + BUILD_BUG_ON(IPI_MAX > 2); + + switch (op) { + case IPI_RESCHEDULE: irq = CPU_RESCHED_A_IRQ; break; - case SMP_CALL_FUNCTION: + case IPI_CALL_FUNC: irq = CPU_CALL_A_IRQ; break; default: @@ -118,12 +120,13 @@ static void ip27_send_ipi_single(int destid, unsigned int action) REMOTE_HUB_SEND_INTR(cpu_to_node(destid), irq); } -static void ip27_send_ipi_mask(const struct cpumask *mask, unsigned int action) +static void ip27_send_ipi_mask(const struct cpumask *mask, + enum ipi_message_type op) { unsigned int i; for_each_cpu(i, mask) - ip27_send_ipi_single(i, action); + ip27_send_ipi_single(i, op); } static void ip27_init_cpu(void) diff --git a/arch/mips/sgi-ip30/ip30-smp.c b/arch/mips/sgi-ip30/ip30-smp.c index 4bfe654602b1..1c674c0cf419 100644 --- a/arch/mips/sgi-ip30/ip30-smp.c +++ b/arch/mips/sgi-ip30/ip30-smp.c @@ -43,15 +43,17 @@ struct mpconf { u32 idleflag; }; -static void ip30_smp_send_ipi_single(int cpu, u32 action) +static void ip30_smp_send_ipi_single(int cpu, enum ipi_message_type op) { int irq; - switch (action) { - case SMP_RESCHEDULE_YOURSELF: + BUILD_BUG_ON(IPI_MAX > 2); + + switch (op) { + case IPI_RESCHEDULE: irq = HEART_L2_INT_RESCHED_CPU_0; break; - case SMP_CALL_FUNCTION: + case IPI_CALL_FUNC: irq = HEART_L2_INT_CALL_CPU_0; break; default: @@ -64,12 +66,13 @@ static void ip30_smp_send_ipi_single(int cpu, u32 action) heart_write(BIT_ULL(irq), &heart_regs->set_isr); } -static void ip30_smp_send_ipi_mask(const struct cpumask *mask, u32 action) +static void ip30_smp_send_ipi_mask(const struct cpumask *mask, + enum ipi_message_type op) { u32 i; for_each_cpu(i, mask) - ip30_smp_send_ipi_single(i, action); + ip30_smp_send_ipi_single(i, op); } static void __init ip30_smp_setup(void) diff --git a/arch/mips/sibyte/bcm1480/smp.c b/arch/mips/sibyte/bcm1480/smp.c index 5861e50255bf..040230e3f4a0 100644 --- a/arch/mips/sibyte/bcm1480/smp.c +++ b/arch/mips/sibyte/bcm1480/smp.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -64,18 +65,18 @@ void bcm1480_smp_init(void) * Simple enough; everything is set up, so just poke the appropriate mailbox * register, and we should be set */ -static void bcm1480_send_ipi_single(int cpu, unsigned int action) +static void bcm1480_send_ipi_single(int cpu, enum ipi_message_type op) { - __raw_writeq((((u64)action)<< 48), mailbox_0_set_regs[cpu]); + __raw_writeq((((u64)BIT_ULL(op)) << 48), mailbox_0_set_regs[cpu]); } static void bcm1480_send_ipi_mask(const struct cpumask *mask, - unsigned int action) + enum ipi_message_type op) { unsigned int i; for_each_cpu(i, mask) - bcm1480_send_ipi_single(i, action); + bcm1480_send_ipi_single(i, op); } /* @@ -159,19 +160,21 @@ void bcm1480_mailbox_interrupt(void) { int cpu = smp_processor_id(); int irq = K_BCM1480_INT_MBOX_0_0; - unsigned int action; + u64 action; + + BUILD_BUG_ON(IPI_MAX > 2); kstat_incr_irq_this_cpu(irq); /* Load the mailbox register to figure out what we're supposed to do */ action = (__raw_readq(mailbox_0_regs[cpu]) >> 48) & 0xffff; /* Clear the mailbox to clear the interrupt */ - __raw_writeq(((u64)action)<<48, mailbox_0_clear_regs[cpu]); + __raw_writeq(((u64)action) << 48, mailbox_0_clear_regs[cpu]); - if (action & SMP_RESCHEDULE_YOURSELF) + if (action & BIT_ULL(IPI_RESCHEDULE)) scheduler_ipi(); - if (action & SMP_CALL_FUNCTION) { + if (action & BIT_ULL(IPI_CALL_FUNC)) { irq_enter(); generic_smp_call_function_interrupt(); irq_exit(); diff --git a/arch/mips/sibyte/sb1250/smp.c b/arch/mips/sibyte/sb1250/smp.c index 7a794234e3d7..dc2c889fa0b6 100644 --- a/arch/mips/sibyte/sb1250/smp.c +++ b/arch/mips/sibyte/sb1250/smp.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -53,18 +54,18 @@ void sb1250_smp_init(void) * Simple enough; everything is set up, so just poke the appropriate mailbox * register, and we should be set */ -static void sb1250_send_ipi_single(int cpu, unsigned int action) +static void sb1250_send_ipi_single(int cpu, enum ipi_message_type op) { - __raw_writeq((((u64)action) << 48), mailbox_set_regs[cpu]); + __raw_writeq((((u64)BIT_ULL(op)) << 48), mailbox_set_regs[cpu]); } static inline void sb1250_send_ipi_mask(const struct cpumask *mask, - unsigned int action) + enum ipi_message_type op) { unsigned int i; for_each_cpu(i, mask) - sb1250_send_ipi_single(i, action); + sb1250_send_ipi_single(i, op); } /* @@ -157,10 +158,10 @@ void sb1250_mailbox_interrupt(void) /* Clear the mailbox to clear the interrupt */ ____raw_writeq(((u64)action) << 48, mailbox_clear_regs[cpu]); - if (action & SMP_RESCHEDULE_YOURSELF) + if (action & BIT(IPI_RESCHEDULE)) scheduler_ipi(); - if (action & SMP_CALL_FUNCTION) { + if (action & BIT(IPI_CALL_FUNC)) { irq_enter(); generic_smp_call_function_interrupt(); irq_exit(); From patchwork Fri Jul 5 14:16:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13725203 Received: from fout6-smtp.messagingengine.com (fout6-smtp.messagingengine.com [103.168.172.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9CFA816C6A3; Fri, 5 Jul 2024 14:17:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189049; cv=none; b=Jz3t9194dg/wLhzQsTuf+i6XYfufwfty5SjQ5XyEFtn3OVkDqYbQ36yxTeaFzkTITKsXRUsGRrtS6caF8b5WsDdQZd5snMw3INwlzGbiwoAgaAH8Bjyzr2a9NXTEDb0jpLonx6kxDZoSVSEEhK1J681qcD8wTUtJGgtTFSjOFuw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189049; c=relaxed/simple; bh=QmvEUCmyhXptfa5Dx5DyMMnQpepc6ypUBq9OV5q7HLE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ILcN4UYciU5k2XNjn9yBAuBnRNoPCVvmei3tBuSRUCmohVQUIxRCGVPMP6vC+gge4r7gdAL84rfgTFyHvYUR/zcCb8vMx/sJlu8n3A5Xd3KKr+CpMC60ZMEUmwBCvwSz8eMvXkA+5HyKQWUZzuYuvF7rzxLdFIVND8WJBDUhS+A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=Dqks+SKA; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=VzfK/FPA; arc=none smtp.client-ip=103.168.172.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="Dqks+SKA"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="VzfK/FPA" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.nyi.internal (Postfix) with ESMTP id B35AE138024E; Fri, 5 Jul 2024 10:17:25 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 05 Jul 2024 10:17:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1720189045; x=1720275445; bh=vwX5MtwwH9KdyKa29HBdsuoSuR0qfhJDxNQizN8Tafw=; b= Dqks+SKA85YJMZuQnGg7YhjSvApgBwLjAzoBi/YXS2G/g5YPSaYTNzlwBfaqvnLb tBqLd/snFrz+WztRd4/0Hddhd/xrvkC/4gm/BQqYcZQhTrG5SA+sshJp4mdwDOBH 5+ba8P5VpqnNcmAnEJB3zSWEznjj60FdHyLgRQbufEBgatnPL8qpEGvzojCjQa/E JQ/XwyyoiMIwjfJlacr2u6GMVHYpowzfUfwL0h28mZoosKDnrp23uVinRrrye+lp Eg8jxT7kb9rMrTYPO7QIlrAsZxS2av8NZPfr8y41Mr3RYCJiY563/bZMNPXT7ysL JRnFLnw49/UgYAikdXpuBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1720189045; x= 1720275445; bh=vwX5MtwwH9KdyKa29HBdsuoSuR0qfhJDxNQizN8Tafw=; b=V zfK/FPAhS7i0X7Wdmb3LN9rG/SzwcW38PO58Eq/lGAlETMQLADlDUktnXQqlqgUM h5uJ6B+j5OhNmX1aR/qaSYlpy9flsLljZHYJmmQywIq4BibupsQjNmtRhH/is56w VOreDU309WgFoH3xUD/JGxQajv4Y54lXEBUZypRftFjNIEBhTd7ZaWYKougSq3oA bD7INqME8BiBVRW4hFs/U9CNE32L+qpXPzOQBhoV8Zu9BCORKA3kFdugXM5Mexy6 t53dvRUNcCDPT5U1zm9kgpOteiago/TlcsItZoKMQ84exKbG5APLwG1Kr9kzrfi6 5Xg09LSsFtekQOXbNeMlQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddugdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheplfhirgig uhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhmqeenuc ggtffrrghtthgvrhhnpedvkeeihfefveekueevteefleffkeegudeghfdtuddugefhueev geffgedukeejleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 Jul 2024 10:17:22 -0400 (EDT) From: Jiaxun Yang Date: Fri, 05 Jul 2024 22:16:54 +0800 Subject: [PATCH v2 02/10] MIPS: smp: Manage IPI interrupts as percpu_devid interrupts Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240705-b4-mips-ipi-improvements-v2-2-2d50b56268e8@flygoat.com> References: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> In-Reply-To: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> To: Thomas Bogendoerfer , Florian Fainelli , Broadcom internal kernel review list , Huacai Chen , Thomas Gleixner , Serge Semin , Paul Burton Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3259; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=QmvEUCmyhXptfa5Dx5DyMMnQpepc6ypUBq9OV5q7HLE=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrQOhvRHySIp02O6C4Ub65bk6fov03wufG3y/Wmv7GVKK iXXWjztKGVhEONikBVTZAkRUOrb0HhxwfUHWX9g5rAygQxh4OIUgIk0qDAyXOC4Y9ds8yVsk6dh lUrRhHtCP6aqfDq/63rz1C2/nhupnWJkWHO7UztAyzBrztzLzydfCN244/mMOBth+44FTR3PHmo uZAUA X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 IPI interrupts need to be enabled when a new CPU coming up. Manage them as percpu_devid interrupts and invoke enable/disable functions at appropriate time to perform enabling as required, similar to what RISC-V and Arm doing. This is required by generic IPI-Mux and some IPI drivers. Signed-off-by: Jiaxun Yang --- v2: Call mips_smp_ipi_disable in CPS disable flow. --- arch/mips/include/asm/ipi.h | 11 +++++++++++ arch/mips/kernel/smp-cps.c | 1 + arch/mips/kernel/smp.c | 26 ++++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/arch/mips/include/asm/ipi.h b/arch/mips/include/asm/ipi.h index df7a0ac4227a..88b507339f51 100644 --- a/arch/mips/include/asm/ipi.h +++ b/arch/mips/include/asm/ipi.h @@ -29,6 +29,17 @@ int mips_smp_ipi_allocate(const struct cpumask *mask); * Return 0 on success. */ int mips_smp_ipi_free(const struct cpumask *mask); + +void mips_smp_ipi_enable(void); +void mips_smp_ipi_disable(void); +#else +static inline void mips_smp_ipi_enable(void) +{ +} + +static inline void mips_smp_ipi_disable(void) +{ +} #endif /* CONFIG_GENERIC_IRQ_IPI */ #endif /* CONFIG_SMP */ #endif diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c index 8c322f441164..a9adf879e2f3 100644 --- a/arch/mips/kernel/smp-cps.c +++ b/arch/mips/kernel/smp-cps.c @@ -552,6 +552,7 @@ static int cps_cpu_disable(void) smp_mb__after_atomic(); set_cpu_online(cpu, false); calculate_cpu_foreign_map(); + mips_smp_ipi_disable(); irq_migrate_all_off_this_cpu(); return 0; diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c index a6cf6444533e..710644d47106 100644 --- a/arch/mips/kernel/smp.c +++ b/arch/mips/kernel/smp.c @@ -186,6 +186,7 @@ irq_handler_t ipi_handlers[IPI_MAX] __read_mostly = { }; #ifdef CONFIG_GENERIC_IRQ_IPI +static DEFINE_PER_CPU_READ_MOSTLY(int, ipi_dummy_dev); static int ipi_virqs[IPI_MAX] __ro_after_init; static struct irq_desc *ipi_desc[IPI_MAX] __read_mostly; @@ -225,13 +226,29 @@ void mips_smp_send_ipi_mask(const struct cpumask *mask, local_irq_restore(flags); } +void mips_smp_ipi_enable(void) +{ + int i; + + for (i = 0; i < IPI_MAX; i++) + enable_percpu_irq(ipi_virqs[i], IRQ_TYPE_NONE); +} + +void mips_smp_ipi_disable(void) +{ + int i; + + for (i = 0; i < IPI_MAX; i++) + disable_percpu_irq(ipi_virqs[i]); +} + static void smp_ipi_init_one(unsigned int virq, const char *name, irq_handler_t handler) { int ret; - irq_set_handler(virq, handle_percpu_irq); - ret = request_irq(virq, handler, IRQF_PERCPU, name, NULL); + irq_set_percpu_devid(virq); + ret = request_percpu_irq(virq, handler, "IPI", &ipi_dummy_dev); BUG_ON(ret); } @@ -343,6 +360,9 @@ static int __init mips_smp_ipi_init(void) return -ENODEV; } + /* Enable IPI for Boot CPU */ + mips_smp_ipi_enable(); + return 0; } early_initcall(mips_smp_ipi_init); @@ -383,6 +403,8 @@ asmlinkage void start_secondary(void) synchronise_count_slave(cpu); + mips_smp_ipi_enable(); + /* The CPU is running and counters synchronised, now mark it online */ set_cpu_online(cpu, true); From patchwork Fri Jul 5 14:16:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13725204 Received: from fout6-smtp.messagingengine.com (fout6-smtp.messagingengine.com [103.168.172.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBC9216CD11; Fri, 5 Jul 2024 14:17:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189052; cv=none; b=ndZ0jfMEOLSN7YPrfWOeZB32anvsb8qWFhUuBtLHruc1bonVY6X2LrQYRA8eleSQUEw3VbCN7GPm14wIO4/y1CZJ9HIRYp7TW7BTsQd8DloUfL6sDIKgrGrnF+CrQNBdOzeib28dVnsBU8K95KdRsdkhQ+ZYCDpmKm/hOUalghg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189052; c=relaxed/simple; bh=Br2js4A2Cf1elwIAfgcBCccgVoEMFdJRRdeziSGkutI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RJYVzcNz7w000s9AcD6npso09MzkKoUHvbII4LKyd8Yevbxogs4H3UAzIQPK1Rbj5eN4mq73pAnY3+oXSKsByw+bDjTQ7o3SC7OTKJExHqNXf/xVsUvPCpXwC4TVGM7Sz/aCqp4vVFp47WWewCTc4ToFsbATQmKH7wnGPxm5phM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=IV58Yzms; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=UOa61+p2; arc=none smtp.client-ip=103.168.172.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="IV58Yzms"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="UOa61+p2" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.nyi.internal (Postfix) with ESMTP id 1079A13800B8; Fri, 5 Jul 2024 10:17:30 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 05 Jul 2024 10:17:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1720189050; x=1720275450; bh=wcuSHIa8hukrwBebB6AD7SpuJq4kKBq0g+3vqQ2Abbs=; b= IV58YzmsxvfkWuDu+NnDcqveZI6Qy22R8YS8GeOZzmItBLAaEOiMTMVqtquTQ2nU kA3LhsDCJpoZpW2qzF1HZmBXm9pVUhtNlkHx6bPK05sVpccjppL3SVbsxnqgAVIk aYZzMQsk0REJDsAJG9k5W/246vANC2i7isv+Y3ir48xlIjaafVvG9ty9G2V0/P2C QDGL5jonm8Mm3CvbtSS/vTK+mJqQfAXrquNzfO46iuRR+xL6R0ghvyI0UCn+CPLq LG6hNumoOFDEJFkB5Vjx9Yy2TcTmGxotNCf4wryG99VbiovvB/H0x1XFqq+B63xQ akrDoZc5SVC2F4dgU0DU8Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1720189050; x= 1720275450; bh=wcuSHIa8hukrwBebB6AD7SpuJq4kKBq0g+3vqQ2Abbs=; b=U Oa61+p2o/y8vNC+QP5cBS7gRi+2dksymRu2FTlYlBSLGi/LbfCDkwP17Ob2uxKxf hiaE4pu9kQEoF/eKVvHYmHJ1FfchmCJhimzK3Niy/iXXKsNQgwINaip0SY+mup88 eTFfCgIcqYBdLfBJcgpjOU1zDm994L6pfuAyEtg/YBd6w3s/Zuz+GxuB+snTkUTt w0A5twLVhayZjMJCtxwPRXvX2uHiVjbJm5Pe+8g/tkJhLEondUnDGyvW7Z2jtxPN higpSGa9TZ4ZbAfa6gJ/RXtPcvW/2bGLSTzmDEkAuohNRVi+rWmQ3tpRzNbjybrK 3pYXlzM3sEUBktZnbsSNg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddugdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheplfhirgig uhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhmqeenuc ggtffrrghtthgvrhhnpedvkeeihfefveekueevteefleffkeegudeghfdtuddugefhueev geffgedukeejleenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfh hrohhmpehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 Jul 2024 10:17:25 -0400 (EDT) From: Jiaxun Yang Date: Fri, 05 Jul 2024 22:16:55 +0800 Subject: [PATCH v2 03/10] MIPS: smp: Provide platform IPI virq & domain hooks Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240705-b4-mips-ipi-improvements-v2-3-2d50b56268e8@flygoat.com> References: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> In-Reply-To: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> To: Thomas Bogendoerfer , Florian Fainelli , Broadcom internal kernel review list , Huacai Chen , Thomas Gleixner , Serge Semin , Paul Burton Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4880; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=Br2js4A2Cf1elwIAfgcBCccgVoEMFdJRRdeziSGkutI=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrQOhvTfuw5rWu5m/aO8ej7bomqLDxskJvx53M2j+uyD6 la1DXclO0pZGMS4GGTFFFlCBJT6NjReXHD9QdYfmDmsTCBDGLg4BWAiqVEM/5RfP5/d4y/ccyVz 9vJPN+Z81rG76mIrcj1/9safR7y1Facz/LM5I66Vq86w8vWTnElV05wXzT+xN2qy2XHJTVUnq8y e5HACAA== X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Provide platform virq & domain hooks to allow platform interrupt controllers or SMP code to override IPI interrupt allocation. This is required by ipi-mux, the API is aligned with RISC-V and Arm. Signed-off-by: Jiaxun Yang --- arch/mips/include/asm/ipi.h | 17 ++++++++++ arch/mips/kernel/smp.c | 78 +++++++++++++++++++++++++-------------------- 2 files changed, 61 insertions(+), 34 deletions(-) diff --git a/arch/mips/include/asm/ipi.h b/arch/mips/include/asm/ipi.h index 88b507339f51..0fc8c31c6a52 100644 --- a/arch/mips/include/asm/ipi.h +++ b/arch/mips/include/asm/ipi.h @@ -2,6 +2,7 @@ #include #include +#include #ifndef __ASM_IPI_H #define __ASM_IPI_H @@ -32,6 +33,9 @@ int mips_smp_ipi_free(const struct cpumask *mask); void mips_smp_ipi_enable(void); void mips_smp_ipi_disable(void); +extern bool mips_smp_ipi_have_virq_range(void); +void mips_smp_ipi_set_irqdomain(struct irq_domain *d); +extern void mips_smp_ipi_set_virq_range(int virq, int nr); #else static inline void mips_smp_ipi_enable(void) { @@ -41,5 +45,18 @@ static inline void mips_smp_ipi_disable(void) { } #endif /* CONFIG_GENERIC_IRQ_IPI */ +#else +void mips_smp_ipi_set_virq_range(int virq, int nr) +{ +} + +void mips_smp_ipi_set_irqdomain(struct irq_domain *d) +{ +} + +static inline bool mips_smp_ipi_have_virq_range(void) +{ + return false; +} #endif /* CONFIG_SMP */ #endif diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c index 710644d47106..fe053fe52147 100644 --- a/arch/mips/kernel/smp.c +++ b/arch/mips/kernel/smp.c @@ -189,6 +189,7 @@ irq_handler_t ipi_handlers[IPI_MAX] __read_mostly = { static DEFINE_PER_CPU_READ_MOSTLY(int, ipi_dummy_dev); static int ipi_virqs[IPI_MAX] __ro_after_init; static struct irq_desc *ipi_desc[IPI_MAX] __read_mostly; +static struct irq_domain *ipidomain; void mips_smp_send_ipi_single(int cpu, enum ipi_message_type op) { @@ -255,11 +256,12 @@ static void smp_ipi_init_one(unsigned int virq, const char *name, int mips_smp_ipi_allocate(const struct cpumask *mask) { int virq, i; - struct irq_domain *ipidomain; struct device_node *node; - node = of_irq_find_parent(of_root); - ipidomain = irq_find_matching_host(node, DOMAIN_BUS_IPI); + if (!ipidomain) { + node = of_irq_find_parent(of_root); + ipidomain = irq_find_matching_host(node, DOMAIN_BUS_IPI); + } /* * Some platforms have half DT setup. So if we found irq node but @@ -291,43 +293,15 @@ int mips_smp_ipi_allocate(const struct cpumask *mask) ipi_virqs[i] = virq; } - if (irq_domain_is_ipi_per_cpu(ipidomain)) { - int cpu; - - for_each_cpu(cpu, mask) { - for (i = 0; i < IPI_MAX; i++) { - smp_ipi_init_one(ipi_virqs[i] + cpu, ipi_names[i], - ipi_handlers[i]); - } - } - } else { - for (i = 0; i < IPI_MAX; i++) { - smp_ipi_init_one(ipi_virqs[i], ipi_names[i], - ipi_handlers[i]); - } - } - return 0; } int mips_smp_ipi_free(const struct cpumask *mask) { int i; - struct irq_domain *ipidomain; - struct device_node *node; - - node = of_irq_find_parent(of_root); - ipidomain = irq_find_matching_host(node, DOMAIN_BUS_IPI); - - /* - * Some platforms have half DT setup. So if we found irq node but - * didn't find an ipidomain, try to search for one that is not in the - * DT. - */ - if (node && !ipidomain) - ipidomain = irq_find_matching_host(NULL, DOMAIN_BUS_IPI); - BUG_ON(!ipidomain); + if (!ipidomain) + return -ENODEV; if (irq_domain_is_ipi_per_cpu(ipidomain)) { int cpu; @@ -344,6 +318,25 @@ int mips_smp_ipi_free(const struct cpumask *mask) return 0; } +void mips_smp_ipi_set_virq_range(int virq, int nr) +{ + int i; + + WARN_ON(nr < IPI_MAX); + + for (i = 0; i < IPI_MAX; i++) + ipi_virqs[i] = virq + i; +} + +void mips_smp_ipi_set_irqdomain(struct irq_domain *d) +{ + ipidomain = d; +} + +bool mips_smp_ipi_have_virq_range(void) +{ + return ipi_virqs[0]; +} static int __init mips_smp_ipi_init(void) { @@ -352,7 +345,24 @@ static int __init mips_smp_ipi_init(void) if (num_possible_cpus() == 1) return 0; - mips_smp_ipi_allocate(cpu_possible_mask); + if (!mips_smp_ipi_have_virq_range()) + mips_smp_ipi_allocate(cpu_possible_mask); + + if (ipidomain && irq_domain_is_ipi_per_cpu(ipidomain)) { + int cpu; + + for_each_possible_cpu(cpu) { + for (i = 0; i < IPI_MAX; i++) { + smp_ipi_init_one(ipi_virqs[i] + cpu, ipi_names[i], + ipi_handlers[i]); + } + } + } else { + for (i = 0; i < IPI_MAX; i++) { + smp_ipi_init_one(ipi_virqs[i], ipi_names[i], + ipi_handlers[i]); + } + } for (i = 0; i < IPI_MAX; i++) { ipi_desc[i] = irq_to_desc(ipi_virqs[i]); From patchwork Fri Jul 5 14:16:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13725205 Received: from fhigh2-smtp.messagingengine.com (fhigh2-smtp.messagingengine.com [103.168.172.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D95FF16B38F; Fri, 5 Jul 2024 14:17:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189056; cv=none; b=qYzNN268UYgfnUBGYnsH497j6Muoegf2LQBbiFJ2/GdGMpQyRUi89Le7Y0NJtwnzpQsvKZIHLXJYmTxKm1KdmzOgmfyN60vdIiamvo3xHThH1EXV+5o4RP/HQM76nVA2Jk6O/FIi/zBnweVSj+8KbdLCZOdh7OTC9NsCRqXEovw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189056; c=relaxed/simple; bh=pkTb9ZrA+jNYT1SUqR3EAOxZwBarpbO5ne+aLusK+J8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OXgEWNS8BbsYOKEKF+COs5scsgAo6ActX6H+4F4UAluHdRNb96VW+Q16PYyL2xTn3iRjD8LmlCQAFWQddS39GJVhs12HMDKW7ekdyT3i7j6YhTGPD/Ni11JKKAbY5cXKcc2V8eLsof/Jj/lL49KKrNHZl6HqqgQYPrNqQxn/MfQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=XPJcFh4q; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=khH93IFn; arc=none smtp.client-ip=103.168.172.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="XPJcFh4q"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="khH93IFn" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 0C6AC114012F; Fri, 5 Jul 2024 10:17:34 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 05 Jul 2024 10:17:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1720189054; x=1720275454; bh=vOqH4swpVxiGjhFEjcycoSM2yvtG7Krg9TnYMF+1RBA=; b= XPJcFh4qlxX3Xgl3O9N7s0+KCDJtIeJ7W4H6W9Cml7pJDLx2JPceMtz0tgwdk/J1 8n/dkJNaNHrBG8j/qAB01A3ebcJiAcQMrBBgnyLLIbwG6gnHLjVsf1czbRhiqSoz ivUPymhIsucyMBlHj9L8aeggId6UMqkJVUzHWUY7SKkK9eBURFdGHSabah/a/EvW I7s+3oxGnt8WeKrpdbuF9yCZ8ozSY/oFK4BWiu2QJ26a4np4aM+ADuJCBJ18cu/W JDqwMX5Lt4lyO4S4BvmuuXG6JZnz9c/6I2EHDE9i3zJ6PBjnedbjd1qjjqrpknOW HZvLNaVojBK64XdMqzEysg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1720189054; x= 1720275454; bh=vOqH4swpVxiGjhFEjcycoSM2yvtG7Krg9TnYMF+1RBA=; b=k hH93IFnlI3GXhehp845rNHLe23Dg0vO/vS0zgSrz+1sD7ki7ATzuGr8tUVLmKnxw hX/0hNMf7lA24Sl+yNl5hZ9drz6ZPrRCASM0QiSFGGBMucVf4FXOEy+o5Wlbj3jj eSs8warVKxAHW6uvhDh4DW9HcDF78S3fQxpqOkMrehpjg25y87FgSx0tcZMz86m3 AF9y+i4O5okPo1e9e9h9qQwo5eNwXJAcXDjl8mdSgTstdxEreiq4RwkIl/ASirlW /aTWrJc31ccKmKXb+fHVM6LRU8TJUbyDXwfFpZ2OBX39NeTylohEycjRu0IwlMdI k1FsbiMklVE5ClCQ4VL7w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddugdejfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheplfhirgig uhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhmqeenuc ggtffrrghtthgvrhhnpedvkeeihfefveekueevteefleffkeegudeghfdtuddugefhueev geffgedukeejleenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfh hrohhmpehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 Jul 2024 10:17:30 -0400 (EDT) From: Jiaxun Yang Date: Fri, 05 Jul 2024 22:16:56 +0800 Subject: [PATCH v2 04/10] MIPS: Move mips_smp_ipi_init call after prepare_cpus Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240705-b4-mips-ipi-improvements-v2-4-2d50b56268e8@flygoat.com> References: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> In-Reply-To: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> To: Thomas Bogendoerfer , Florian Fainelli , Broadcom internal kernel review list , Huacai Chen , Thomas Gleixner , Serge Semin , Paul Burton Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1142; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=pkTb9ZrA+jNYT1SUqR3EAOxZwBarpbO5ne+aLusK+J8=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrQOhvTMK3/vz7nKISvy4Xfvqqk6s/dXcPzk2LJt9ZqOS onvPCu/d5SyMIhxMciKKbKECCj1bWi8uOD6g6w/MHNYmUCGMHBxCsBE9p1k+F/ZuMywl73lTnOW RZ5cR1akyv2NFgVnZfzP757rs/NT22KGn4zHTI+WP9v5doW8Ie8R0bnfToh8fZKeszxnw6c9B7x K7TgB X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 This will give platform code a genuine chance to setup IPI IRQ in prepare_cpus. For most systems IPI should be registered by irqchip drivers fairly early, but if IPI IRQ is tightly coupled with platform's SMP implementation it makes sense to do it here. Signed-off-by: Jiaxun Yang --- arch/mips/kernel/smp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c index fe053fe52147..f29259d16a37 100644 --- a/arch/mips/kernel/smp.c +++ b/arch/mips/kernel/smp.c @@ -375,7 +375,6 @@ static int __init mips_smp_ipi_init(void) return 0; } -early_initcall(mips_smp_ipi_init); #endif /* @@ -466,6 +465,13 @@ void __init smp_prepare_cpus(unsigned int max_cpus) set_cpu_sibling_map(0); set_cpu_core_map(0); calculate_cpu_foreign_map(); +#ifdef CONFIG_GENERIC_IRQ_IPI + if (mips_smp_ipi_init()) { + pr_err("Failed to initialize IPI - disabling SMP"); + init_cpu_present(cpumask_of(0)); + return; + } +#endif #ifndef CONFIG_HOTPLUG_CPU init_cpu_present(cpu_possible_mask); #endif From patchwork Fri Jul 5 14:16:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13725206 Received: from fout6-smtp.messagingengine.com (fout6-smtp.messagingengine.com [103.168.172.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C385116D9D7; Fri, 5 Jul 2024 14:17:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189061; cv=none; b=f2RYAfQAAjIzJmUJW8XWcYiOY4uroRqJ80U0DLNI1KYfZurPzOIyjz0Hiykl71MJ0KObnHl9SBIt/m+t5Bwmlp0114J5lNYXhFX/8zZ38ggU6FGiiWym8UGDgRWWZ8y18SQr7+BtHtFpcT4F/FV1cBaycDro4UVZdwGO7ypJAKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189061; c=relaxed/simple; bh=JgrXh5b0b3kb7CqdIZH20CH0eWL/loCTfbjij0wpKpA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dBfdeLs+LgvrSo/mkHABrj9ZRZt4N6T8GqJ1w0Urd+5u6QdZiSEKkiHZkcsFfnsO7BzOqlu2cR1RtgF2RktMQbIAlJ4csvYT4mhciwipjvXTp+L7rxv0nJVfF3ksRg6DUR0FIcz44Yw9dXv6Cq6lPcKZRw6RGAEHQMJB5OYQyvs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=aXcDa5S5; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=fX1IKAtU; arc=none smtp.client-ip=103.168.172.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="aXcDa5S5"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="fX1IKAtU" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfout.nyi.internal (Postfix) with ESMTP id C6C06138045B; Fri, 5 Jul 2024 10:17:38 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 05 Jul 2024 10:17:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1720189058; x=1720275458; bh=P85+6svbeBePQGWrJs8s548IqlhdLiIHmy5J5r0xeqw=; b= aXcDa5S5/QzX3r7eHETVVBsDzWLT/kg/WXZUqJaAtvsuSeOmqhW0o+qowMstdGsi Z7BIVw/uUEVU6QYAMXFC0v2xCpNlP5TwxRRYUmdUi5M0GRemTYxBlaVIO89RWqa3 /QIERlWDTxwEQtpQnTT7ERtXbwS+tusgYHxWpEBx5h8E6uXNk0PpAdXUfltU/mal KZpPGWktdHxijJCN7Dr8guO7Rp3DtBlmUFPRzeLsYvPYQxtcoFqaONZ8m0/d9hsb sbOtQdvWclEsazYjcIO/h9CJdxY+VTKPy1IhWYvMDlqM5hA85LSVXW/RO19+ObgZ Hz51FKHRM2ePZXSbJU4WhQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1720189058; x= 1720275458; bh=P85+6svbeBePQGWrJs8s548IqlhdLiIHmy5J5r0xeqw=; b=f X1IKAtUAg87uKdICLeTajQDtyOUFoHGWuHmKwLnHQOVck/MGIgMulSp3I+PD35Ty xlw4RAALTO4ej5tggWHCMgYT9K/wth8QeIH5odKJMLaokYBspDBdH0phBgbncnKM frtEyq2PUfC8vLjdf2Ks26gGbVtwn892QgAY8lSSOmPL/zfSIV3SYY3Qmt8u9h0F 9Z4A8vU1Q4vS/M2q28R4NsdYmgQhwHbl4St38coLMvc7/jZteFvOQO5TfYd9NTTJ LyglPH4VfP80q0YmLAyJEcksIhOMPx/DGUHsvfEmQ8hxEdTQ6xyZg4T1hSwthgOW 9HyVNfTWBwqryD/15MU7A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddugdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheplfhirgig uhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhmqeenuc ggtffrrghtthgvrhhnpedvkeeihfefveekueevteefleffkeegudeghfdtuddugefhueev geffgedukeejleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 Jul 2024 10:17:34 -0400 (EDT) From: Jiaxun Yang Date: Fri, 05 Jul 2024 22:16:57 +0800 Subject: [PATCH v2 05/10] MIPS: smp: Implement IPI stats Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240705-b4-mips-ipi-improvements-v2-5-2d50b56268e8@flygoat.com> References: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> In-Reply-To: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> To: Thomas Bogendoerfer , Florian Fainelli , Broadcom internal kernel review list , Huacai Chen , Thomas Gleixner , Serge Semin , Paul Burton Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2658; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=JgrXh5b0b3kb7CqdIZH20CH0eWL/loCTfbjij0wpKpA=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrQOhnRWxZS/LsdN3AzWSSgpdFYqV05MM5yp+sE8I+HAC 63PXLM7SlkYxLgYZMUUWUIElPo2NF5ccP1B1h+YOaxMIEMYuDgFYCKcjIwMHdtd+9+IOZglx7eu 0GATvXs9J3avHo/We8mfP79lT5rnwMhwZuuT1wIzhZj9Jh4U4zjysXHbHae/mWUXljO2aD/Qc05 hAAA= X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Show IPI statistics in arch_show_interrupts to help users analysis IPI performance. Signed-off-by: Jiaxun Yang --- arch/mips/include/asm/ipi.h | 9 +++++++++ arch/mips/kernel/irq.c | 4 ++++ arch/mips/kernel/smp.c | 13 +++++++++++++ 3 files changed, 26 insertions(+) diff --git a/arch/mips/include/asm/ipi.h b/arch/mips/include/asm/ipi.h index 0fc8c31c6a52..96c6e76d72c9 100644 --- a/arch/mips/include/asm/ipi.h +++ b/arch/mips/include/asm/ipi.h @@ -36,6 +36,7 @@ void mips_smp_ipi_disable(void); extern bool mips_smp_ipi_have_virq_range(void); void mips_smp_ipi_set_irqdomain(struct irq_domain *d); extern void mips_smp_ipi_set_virq_range(int virq, int nr); +extern void mips_smp_show_ipi_stats(struct seq_file *p, int prec); #else static inline void mips_smp_ipi_enable(void) { @@ -44,6 +45,10 @@ static inline void mips_smp_ipi_enable(void) static inline void mips_smp_ipi_disable(void) { } + +static inline void mips_smp_show_ipi_stats(struct seq_file *p, int prec) +{ +} #endif /* CONFIG_GENERIC_IRQ_IPI */ #else void mips_smp_ipi_set_virq_range(int virq, int nr) @@ -58,5 +63,9 @@ static inline bool mips_smp_ipi_have_virq_range(void) { return false; } + +static inline void mips_smp_show_ipi_stats(struct seq_file *p, int prec) +{ +} #endif /* CONFIG_SMP */ #endif diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c index 5e11582fe308..c3ea8d80e0cb 100644 --- a/arch/mips/kernel/irq.c +++ b/arch/mips/kernel/irq.c @@ -26,6 +26,8 @@ #include #include +#include + void *irq_stack[NR_CPUS]; /* @@ -42,6 +44,8 @@ atomic_t irq_err_count; int arch_show_interrupts(struct seq_file *p, int prec) { seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count)); + mips_smp_show_ipi_stats(p, prec); + return 0; } diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c index f29259d16a37..49be86e15b49 100644 --- a/arch/mips/kernel/smp.c +++ b/arch/mips/kernel/smp.c @@ -243,6 +243,19 @@ void mips_smp_ipi_disable(void) disable_percpu_irq(ipi_virqs[i]); } +void mips_smp_show_ipi_stats(struct seq_file *p, int prec) +{ + unsigned int cpu, i; + + for (i = 0; i < IPI_MAX; i++) { + seq_printf(p, "%*s%u:%s", prec - 1, "IPI", i, + prec >= 4 ? " " : ""); + for_each_online_cpu(cpu) + seq_printf(p, "%10u ", irq_desc_kstat_cpu(ipi_desc[i], cpu)); + seq_printf(p, " %s\n", ipi_names[i]); + } +} + static void smp_ipi_init_one(unsigned int virq, const char *name, irq_handler_t handler) { From patchwork Fri Jul 5 14:16:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13725207 Received: from fhigh2-smtp.messagingengine.com (fhigh2-smtp.messagingengine.com [103.168.172.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A59E16B74D; Fri, 5 Jul 2024 14:17:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189065; cv=none; b=Qaa37+RYh6vy2fxwqDVM5zhYQcMRA3e3X5NC7IzQeyJnn2cFK6UB4I5Sx+ewzAUjaiQ6bebC6k0AZOLVVrCkkDUGMrY7wwAPSTweWTbplRGH2TpQ5ZhG/uVjuozliXqcWC7kUkayNV6pBaog5XEJzIq6Hs172U6pDc6r/DcGS9Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189065; c=relaxed/simple; bh=M5PTw2JGYRuwkF/Z6Na1xAnPXX+za7+A+yk3rK99cG8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N9Ehc8Ib1S38e+RXYbBuUmGDjaRxwDmHbmaIrglW1XXAKg+9bgINLdSTZKsbymvPQlkQAETKhLz5gcEPFzttbfORNlIGbrgjIFixz4cfMaGsCIVed8P71tTmEjT8yucuzFTfI5tCy36WC17zcH/NtcpJBG688NAtQTE/fle835k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=OUMMiDv5; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=nhIJ/CYY; arc=none smtp.client-ip=103.168.172.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="OUMMiDv5"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="nhIJ/CYY" Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 36AFF114016A; Fri, 5 Jul 2024 10:17:43 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 05 Jul 2024 10:17:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1720189063; x=1720275463; bh=aHAGPgY3TRPydV0uDWZcikjrrn5KeIh86puKszgtHOs=; b= OUMMiDv5Ok/MeTQoB0lfzO8iirVxlN91YmiF6UvtpTBnYtI/O2b20TO2GjEeHuQi NH3fZjVEIF6T3YFUgtJ8Z8+YfdpDPN+2iQoCMgHwvIy4L8vptkwNnN43V9BBZHw5 mBtzFYNP65IAwJRvy/RKm/k8TQh2CuD24VeeFB7r9P40gCWNUu1ve6a5v1zOWauD d9kIBvNED94dvkdtSEPdhCVMfX/oIs7o8/FVpJ4V4ZDw5LjF0J+ixh6jU72SJ0oV ZYOzEc+4Bu8N5TqizGbLYN+3OCNLhjKHMNPtCDrQGceBXTzKJgA8p/YXdh6inJCP ipz98Cfl4JZX//p7niFUcQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1720189063; x= 1720275463; bh=aHAGPgY3TRPydV0uDWZcikjrrn5KeIh86puKszgtHOs=; b=n hIJ/CYYh3DqnoGxDO061P6DMdcvjzCDaxKDJxhOMo9LFkj2iS19BSztbGRKVf3qK 0M/ssXv8WboT2rbqvpZ/XqSUaPx+8fppSyndd8re9r/gXMXhtWBGunz3gB6hnyJz RvF4MXUobsQUhhwRbvOxHjJ167fqwgD6Hno1SLoqO777FTo5Q/d7/sP9VMxIaiDP iJpCFxz/1YxB+ERznjK3IYrQlpEkXJezr3VAi8sEZJxNsocfWlPXmYY6GK2Raf5V f8dFmDMFKdQF9PPUUKfLRJhG7x8h9S6c6+wb6nyDvY/wHVlIH3PQWsjUhaw2C6Aq voojF9mdE44dwwTgrjdVg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddugdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheplfhirgig uhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhmqeenuc ggtffrrghtthgvrhhnpedvkeeihfefveekueevteefleffkeegudeghfdtuddugefhueev geffgedukeejleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 Jul 2024 10:17:39 -0400 (EDT) From: Jiaxun Yang Date: Fri, 05 Jul 2024 22:16:58 +0800 Subject: [PATCH v2 06/10] irqchip: irq-mips-gic: Switch to ipi_mux Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240705-b4-mips-ipi-improvements-v2-6-2d50b56268e8@flygoat.com> References: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> In-Reply-To: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> To: Thomas Bogendoerfer , Florian Fainelli , Broadcom internal kernel review list , Huacai Chen , Thomas Gleixner , Serge Semin , Paul Burton Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=9752; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=M5PTw2JGYRuwkF/Z6Na1xAnPXX+za7+A+yk3rK99cG8=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrQOhnSN2S+Yhfq+KO5v1ulq6l19T9ii+4f1Wgn3nKkNl urLVgV3lLIwiHExyIopsoQIKPVtaLy44PqDrD8wc1iZQIYwcHEKwESMFzD8synq3rX5jMyDN0df XrsexajBJxT0mLdS6d+3+9+uB9csTGdk+CT+IEH6K/emCFmLZCcfi7KVabnRH/h/mfFZa/hGREk wAwA= X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Use ipi_mux to implement IPI interrupts instead of allocating vector for each individual IPI messages. This can reduce number of reserved GIC shared vectors, which is a huge problem on MSI enabled GIC systems. It also allowed us to easily expand number of IPIs. Signed-off-by: Jiaxun Yang --- drivers/irqchip/Kconfig | 1 + drivers/irqchip/irq-mips-gic.c | 200 ++++++++++++++--------------------------- 2 files changed, 66 insertions(+), 135 deletions(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 344c484736af..d5b841601731 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -341,6 +341,7 @@ config KEYSTONE_IRQ config MIPS_GIC bool select GENERIC_IRQ_IPI if SMP + select GENERIC_IRQ_IPI_MUX if SMP select IRQ_DOMAIN_HIERARCHY select MIPS_CM diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c index 76253e864f23..eb58392f0e66 100644 --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c @@ -17,12 +17,14 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -58,7 +60,7 @@ static struct irq_chip gic_level_irq_controller, gic_edge_irq_controller; #ifdef CONFIG_GENERIC_IRQ_IPI static DECLARE_BITMAP(ipi_resrv, GIC_MAX_INTRS); -static DECLARE_BITMAP(ipi_available, GIC_MAX_INTRS); +static int cpu_ipi_intr[NR_CPUS] __read_mostly; #endif /* CONFIG_GENERIC_IRQ_IPI */ static struct gic_all_vpes_chip_data { @@ -108,13 +110,6 @@ static void gic_bind_eic_interrupt(int irq, int set) write_gic_vl_eic_shadow_set(irq, set); } -static void gic_send_ipi(struct irq_data *d, unsigned int cpu) -{ - irq_hw_number_t hwirq = GIC_HWIRQ_TO_SHARED(irqd_to_hwirq(d)); - - write_gic_wedge(GIC_WEDGE_RW | hwirq); -} - int gic_get_c0_compare_int(void) { if (!gic_local_irq_is_routable(GIC_LOCAL_INT_TIMER)) @@ -181,6 +176,11 @@ static void gic_mask_irq(struct irq_data *d) unsigned int intr = GIC_HWIRQ_TO_SHARED(d->hwirq); write_gic_rmask(intr); + +#ifdef CONFIG_GENERIC_IRQ_IPI + if (test_bit(intr, ipi_resrv)) + return; +#endif gic_clear_pcpu_masks(intr); } @@ -191,6 +191,10 @@ static void gic_unmask_irq(struct irq_data *d) write_gic_smask(intr); +#ifdef CONFIG_GENERIC_IRQ_IPI + if (test_bit(intr, ipi_resrv)) + return; +#endif gic_clear_pcpu_masks(intr); cpu = cpumask_first(irq_data_get_effective_affinity_mask(d)); set_bit(intr, per_cpu_ptr(pcpu_masks, cpu)); @@ -263,6 +267,11 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask, unsigned long flags; unsigned int cpu; +#ifdef CONFIG_GENERIC_IRQ_IPI + if (test_bit(irq, ipi_resrv)) + return -EINVAL; +#endif + cpu = cpumask_first_and(cpumask, cpu_online_mask); if (cpu >= NR_CPUS) return -EINVAL; @@ -304,7 +313,6 @@ static struct irq_chip gic_edge_irq_controller = { #ifdef CONFIG_SMP .irq_set_affinity = gic_set_affinity, #endif - .ipi_send_single = gic_send_ipi, }; static void gic_handle_local_int(bool chained) @@ -475,12 +483,6 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq, u32 map; if (hwirq >= GIC_SHARED_HWIRQ_BASE) { -#ifdef CONFIG_GENERIC_IRQ_IPI - /* verify that shared irqs don't conflict with an IPI irq */ - if (test_bit(GIC_HWIRQ_TO_SHARED(hwirq), ipi_resrv)) - return -EBUSY; -#endif /* CONFIG_GENERIC_IRQ_IPI */ - err = irq_domain_set_hwirq_and_chip(d, virq, hwirq, &gic_level_irq_controller, NULL); @@ -570,146 +572,74 @@ static const struct irq_domain_ops gic_irq_domain_ops = { }; #ifdef CONFIG_GENERIC_IRQ_IPI - -static int gic_ipi_domain_xlate(struct irq_domain *d, struct device_node *ctrlr, - const u32 *intspec, unsigned int intsize, - irq_hw_number_t *out_hwirq, - unsigned int *out_type) -{ - /* - * There's nothing to translate here. hwirq is dynamically allocated and - * the irq type is always edge triggered. - * */ - *out_hwirq = 0; - *out_type = IRQ_TYPE_EDGE_RISING; - - return 0; -} - -static int gic_ipi_domain_alloc(struct irq_domain *d, unsigned int virq, - unsigned int nr_irqs, void *arg) -{ - struct cpumask *ipimask = arg; - irq_hw_number_t hwirq, base_hwirq; - int cpu, ret, i; - - base_hwirq = find_first_bit(ipi_available, gic_shared_intrs); - if (base_hwirq == gic_shared_intrs) - return -ENOMEM; - - /* check that we have enough space */ - for (i = base_hwirq; i < nr_irqs; i++) { - if (!test_bit(i, ipi_available)) - return -EBUSY; - } - bitmap_clear(ipi_available, base_hwirq, nr_irqs); - - /* map the hwirq for each cpu consecutively */ - i = 0; - for_each_cpu(cpu, ipimask) { - hwirq = GIC_SHARED_TO_HWIRQ(base_hwirq + i); - - ret = irq_domain_set_hwirq_and_chip(d, virq + i, hwirq, - &gic_edge_irq_controller, - NULL); - if (ret) - goto error; - - ret = irq_domain_set_hwirq_and_chip(d->parent, virq + i, hwirq, - &gic_edge_irq_controller, - NULL); - if (ret) - goto error; - - ret = irq_set_irq_type(virq + i, IRQ_TYPE_EDGE_RISING); - if (ret) - goto error; - - ret = gic_shared_irq_domain_map(d, virq + i, hwirq, cpu); - if (ret) - goto error; - - i++; - } - - return 0; -error: - bitmap_set(ipi_available, base_hwirq, nr_irqs); - return ret; -} - -static void gic_ipi_domain_free(struct irq_domain *d, unsigned int virq, - unsigned int nr_irqs) +static void gic_handle_ipi_irq(struct irq_desc *desc) { - irq_hw_number_t base_hwirq; - struct irq_data *data; + struct irq_chip *chip = irq_desc_get_chip(desc); - data = irq_get_irq_data(virq); - if (!data) - return; - - base_hwirq = GIC_HWIRQ_TO_SHARED(irqd_to_hwirq(data)); - bitmap_set(ipi_available, base_hwirq, nr_irqs); + chained_irq_enter(chip, desc); + ipi_mux_process(); + chained_irq_exit(chip, desc); } -static int gic_ipi_domain_match(struct irq_domain *d, struct device_node *node, - enum irq_domain_bus_token bus_token) +static void gic_ipi_send(unsigned int cpu) { - bool is_ipi; - - switch (bus_token) { - case DOMAIN_BUS_IPI: - is_ipi = d->bus_token == bus_token; - return (!node || to_of_node(d->fwnode) == node) && is_ipi; - break; - default: - return 0; - } + write_gic_wedge(GIC_WEDGE_RW | cpu_ipi_intr[cpu]); } -static const struct irq_domain_ops gic_ipi_domain_ops = { - .xlate = gic_ipi_domain_xlate, - .alloc = gic_ipi_domain_alloc, - .free = gic_ipi_domain_free, - .match = gic_ipi_domain_match, -}; - -static int gic_register_ipi_domain(struct device_node *node) +static int gic_ipi_mux_init(struct device_node *node, struct irq_domain *d) { - struct irq_domain *gic_ipi_domain; - unsigned int v[2], num_ipis; - - gic_ipi_domain = irq_domain_add_hierarchy(gic_irq_domain, - IRQ_DOMAIN_FLAG_IPI_PER_CPU, - GIC_NUM_LOCAL_INTRS + gic_shared_intrs, - node, &gic_ipi_domain_ops, NULL); - if (!gic_ipi_domain) { - pr_err("Failed to add IPI domain"); - return -ENXIO; - } - - irq_domain_update_bus_token(gic_ipi_domain, DOMAIN_BUS_IPI); + unsigned int i, v[2], num_ipis; + int ipi_virq, cpu = 0; if (node && !of_property_read_u32_array(node, "mti,reserved-ipi-vectors", v, 2)) { bitmap_set(ipi_resrv, v[0], v[1]); } else { /* - * Reserve 2 interrupts per possible CPU/VP for use as IPIs, - * meeting the requirements of arch/mips SMP. + * Reserve 1 interrupts per possible CPU/VP for use as IPIs */ - num_ipis = 2 * num_possible_cpus(); + num_ipis = num_possible_cpus(); bitmap_set(ipi_resrv, gic_shared_intrs - num_ipis, num_ipis); } - bitmap_copy(ipi_available, ipi_resrv, GIC_MAX_INTRS); + ipi_virq = ipi_mux_create(IPI_MAX, gic_ipi_send); + + WARN_ON(bitmap_weight(ipi_resrv, GIC_MAX_INTRS) < num_possible_cpus()); + + for_each_set_bit(i, ipi_resrv, GIC_MAX_INTRS) { + struct irq_fwspec fwspec; + int virq; + + fwspec.fwnode = of_node_to_fwnode(node); + fwspec.param_count = 3; + fwspec.param[0] = GIC_SHARED; + fwspec.param[1] = i; + fwspec.param[2] = IRQ_TYPE_EDGE_RISING; + + virq = irq_create_fwspec_mapping(&fwspec); + if (!virq) + return -EINVAL; + + gic_shared_irq_domain_map(d, virq, GIC_SHARED_TO_HWIRQ(i), cpu); + irq_set_chained_handler(virq, gic_handle_ipi_irq); + gic_clear_pcpu_masks(i); + set_bit(i, per_cpu_ptr(pcpu_masks, cpu)); + + cpu_ipi_intr[cpu] = i; + + cpu++; + if (cpu >= num_possible_cpus()) + break; + } + + mips_smp_ipi_set_virq_range(ipi_virq, IPI_MAX); return 0; } #else /* !CONFIG_GENERIC_IRQ_IPI */ -static inline int gic_register_ipi_domain(struct device_node *node) +static inline int gic_ipi_mux_init(struct device_node *node) { return 0; } @@ -809,10 +739,6 @@ static int __init gic_of_init(struct device_node *node, return -ENXIO; } - ret = gic_register_ipi_domain(node); - if (ret) - return ret; - board_bind_eic_interrupt = &gic_bind_eic_interrupt; /* Setup defaults */ @@ -822,6 +748,10 @@ static int __init gic_of_init(struct device_node *node, write_gic_rmask(i); } + ret = gic_ipi_mux_init(node, gic_irq_domain); + if (ret) + return ret; + return cpuhp_setup_state(CPUHP_AP_IRQ_MIPS_GIC_STARTING, "irqchip/mips/gic:starting", gic_cpu_startup, NULL); From patchwork Fri Jul 5 14:16:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13725208 Received: from fhigh2-smtp.messagingengine.com (fhigh2-smtp.messagingengine.com [103.168.172.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24C4316C444; Fri, 5 Jul 2024 14:17:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189069; cv=none; b=UnlPKKweMK5bG/nBVdv5DTvO4o6ytieg8jBmzQ4idny9KcDVH6R2MRhxVcfbvqLZEkc59j+1zBfC7mORtIiB5DtjWUX8CpAMbsXmE3h6iwlhpQ7VRLcL6zXzyGJFIURsEAkNHWb+p/PIPIVj3g6KBdhZFki9KnObxnp++/FLp4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189069; c=relaxed/simple; bh=Mtw71kZDNXKmS+k3RytF2dUin0ut6WFNIUi8/LiPrxE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EKCJaiLLwwL9e1GCy1ttXzdTQasYK5/YXm8WQS+gL6oywt3cc1Ym6KAIsLJmLuaG7O/Nn5y2q6A5USbvHxJgpOZsQ+1UkAkQKyWWfVXRW9mb8ZiTlnrJAD5ky1w6Jnsf1F0NscYPk4kpHNjvCO2wSgL9x7isfDEN19RcYXdXOiY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=oH7S6mqX; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=IDKBf33n; arc=none smtp.client-ip=103.168.172.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="oH7S6mqX"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="IDKBf33n" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 6DF07114012F; Fri, 5 Jul 2024 10:17:47 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 05 Jul 2024 10:17:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1720189067; x=1720275467; bh=OwayQ/jpWvBmzwZjicSGPWrJdk2dM+e2Rs6em9mUXrk=; b= oH7S6mqXSciHNd/SOyNFaHRlzatvl8FYabHPwtx8yuse1XATgQuo00XG2XnqkOCy ScSvDXQk+OBXkbebxx3XhrHo2db898CfIq4XGJkJTPz9jNpDQSLnke3BFfaqwuC2 edZYv4O67pf3v7jrC/un8/ABhO3le8g0wrX35ghln8/J/UVZNnNhbgUF7pcei3GG XDtasK+Ztz3o+i/w3pgGk/fQJ0V4VlbdwToeWB6v6cScMX5d65B6SRfwfoswik4y sYSClzIwewF7oHtYw2E1wXTYzWcCcDm+1LjppN722fDvZuBweLXlRC0Of+U9oRMe vsPv3k/onQ7B+guqJjal+w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1720189067; x= 1720275467; bh=OwayQ/jpWvBmzwZjicSGPWrJdk2dM+e2Rs6em9mUXrk=; b=I DKBf33n7CzboSm+7JJHfYuzCU8GFo+/kvbnA5ULJW/96u0ITtKEEEDtUT8DBKvZi LbrBpJJ/a/Nt3Gd5kQmPEBxuoE8Sv+LgrfT8Dmfdz0+/Di/2e4ZBAtqxko4UUlbL 18JPHxxbK41PpZj2/O79ZcRci756P03kGu9EVrD6DTJmn7mHrsDrXbSSDhMJdgCR W67f3edbhcAcQnsabSKqIN13p+9J6s7QDyVBJrOuq/cVooLavhSZtNgAKJdJ3ERo FlwQaGGFeFjUsGwLZfB82ykgxLrArjSSbDmO9fLGchNP/yE765bBL3StCsSJnfaP Jp1MSwBATHm6wjyj7OpAw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddugdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheplfhirgig uhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhmqeenuc ggtffrrghtthgvrhhnpedvkeeihfefveekueevteefleffkeegudeghfdtuddugefhueev geffgedukeejleenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfh hrohhmpehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 Jul 2024 10:17:43 -0400 (EDT) From: Jiaxun Yang Date: Fri, 05 Jul 2024 22:16:59 +0800 Subject: [PATCH v2 07/10] MIPS: Implement get_mips_sw_int hook Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240705-b4-mips-ipi-improvements-v2-7-2d50b56268e8@flygoat.com> References: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> In-Reply-To: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> To: Thomas Bogendoerfer , Florian Fainelli , Broadcom internal kernel review list , Huacai Chen , Thomas Gleixner , Serge Semin , Paul Burton Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2757; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=Mtw71kZDNXKmS+k3RytF2dUin0ut6WFNIUi8/LiPrxE=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrQOhvQ8pgqzeytib34Rl7he/XbC1mJtLeXQNAvtZT+Xv KiOvN/fUcrCIMbFICumyBIioNS3ofHigusPsv7AzGFlAhnCwMUpABPh+8fwP/V5RNaXMquLv25r fdg9c0VkcEjsHh2+GUHn+lil+mNyShkZ5qiLibE1NoZM6st7vkK4dFfz9Juav87d/bCjnSP6mkU dKwA= X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 For MIPS CPUs with VEIC, SW0 and SW1 interrupts are also routed through external sources. We need such hook to allow architecture code to get interrupt source from platform EIC controllers. Signed-off-by: Jiaxun Yang --- arch/mips/include/asm/irq.h | 1 + arch/mips/include/asm/irq_cpu.h | 3 +++ arch/mips/kernel/irq.c | 17 +++++++++++++++++ drivers/irqchip/irq-mips-cpu.c | 11 +++++++++++ 4 files changed, 32 insertions(+) diff --git a/arch/mips/include/asm/irq.h b/arch/mips/include/asm/irq.h index 3a848e7e69f7..6edad40ef663 100644 --- a/arch/mips/include/asm/irq.h +++ b/arch/mips/include/asm/irq.h @@ -51,6 +51,7 @@ static inline int irq_canonicalize(int irq) #else #define irq_canonicalize(irq) (irq) /* Sane hardware, sane code ... */ #endif +int get_mips_sw_int(int hwint); asmlinkage void plat_irq_dispatch(void); diff --git a/arch/mips/include/asm/irq_cpu.h b/arch/mips/include/asm/irq_cpu.h index 83d7331ab215..50a99ba2d503 100644 --- a/arch/mips/include/asm/irq_cpu.h +++ b/arch/mips/include/asm/irq_cpu.h @@ -9,7 +9,10 @@ #ifndef _ASM_IRQ_CPU_H #define _ASM_IRQ_CPU_H +#include + extern void mips_cpu_irq_init(void); +extern int mips_cpu_get_sw_int(int hwint); #ifdef CONFIG_IRQ_DOMAIN struct device_node; diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c index c3ea8d80e0cb..c79504b12134 100644 --- a/arch/mips/kernel/irq.c +++ b/arch/mips/kernel/irq.c @@ -26,10 +26,27 @@ #include #include +#include #include void *irq_stack[NR_CPUS]; +int __weak get_mips_sw_int(int hwint) +{ + /* Only SW0 and SW1 */ + WARN_ON(hwint > 1); + + /* SW int is routed to external source */ + if (cpu_has_veic) + return 0; + +#ifdef CONFIG_IRQ_MIPS_CPU + return mips_cpu_get_sw_int(hwint); +#endif + + return MIPS_CPU_IRQ_BASE + hwint; +} + /* * 'what should we do if we get a hw irq event on an illegal vector'. * each architecture has to answer this themselves. diff --git a/drivers/irqchip/irq-mips-cpu.c b/drivers/irqchip/irq-mips-cpu.c index 0c7ae71a0af0..7b3501485d95 100644 --- a/drivers/irqchip/irq-mips-cpu.c +++ b/drivers/irqchip/irq-mips-cpu.c @@ -254,6 +254,17 @@ static inline void mips_cpu_register_ipi_domain(struct device_node *of_node) {} #endif /* !CONFIG_GENERIC_IRQ_IPI */ +int mips_cpu_get_sw_int(int hwint) +{ + /* Only 0 and 1 for SW INT */ + WARN_ON(hwint > 1); + + if (!irq_domain) + return 0; + + return irq_create_mapping(irq_domain, hwint); +} + static void __init __mips_cpu_irq_init(struct device_node *of_node) { /* Mask interrupts. */ From patchwork Fri Jul 5 14:17:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13725209 Received: from fout6-smtp.messagingengine.com (fout6-smtp.messagingengine.com [103.168.172.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 946F416EB68; Fri, 5 Jul 2024 14:17:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189074; cv=none; b=aaf+4S7Om3cCuT8rmLKml39XoxoN4Aru/HNaCUdIStDEkqAnDxpnqkGVKZyshMqoDQasLYCQK73EwkmbG7PMrYFS19iMsWiwajKBLny5b1YPXuAzl/IxNLYRx1YnoNLtrhl/+mLvkXFtdW6bcK0k/gR5aH24aoDnswnDiClc160= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189074; c=relaxed/simple; bh=MbvCb3pQ9sVxGj9YsZ2Bo3mcT7SECuL2ErrwnpMxUQY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Jbf5qrSdBaW9vtCX8ILGzy5fvPsr1PMW47SAy155MZBSomWx/CG5QvhHLxtrgOPOPeXcV5kD4vmQhgQu+sEpm6kdk+420HYVpRhwiWL92dZMoxmoGI/wW2pYlVNRZyW1LTcaO9GUvpQeh8E0caCY0lsNKofnHpjjhIYVvsR6GZw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=mzK7iLqT; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=L4VSJLvI; arc=none smtp.client-ip=103.168.172.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="mzK7iLqT"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="L4VSJLvI" Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.nyi.internal (Postfix) with ESMTP id C23F31380455; Fri, 5 Jul 2024 10:17:51 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 05 Jul 2024 10:17:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1720189071; x=1720275471; bh=+pkna8QIAs1fgaQPH6H7ayDirkuVCIQG5px4bmS7Rx0=; b= mzK7iLqT+C6KK/OjImFylkfO7J+RMRaSEiK8HfmdLGm5x/xTyvAzkeivnRMSY5zL PKshXGPM6db+/nQhkv3/jkmptAZyl4ofu+K1JzHhGCp7KOd/j8CnjNoTH0vnrhTO 3kPIQwFgBjO5J3vXZQaltbTg4HplB7k7olE3bt5KM6vJt61En1KejR/SiWZNgbUz Fs8HKdFoRW33Xl4NDmkR9h+ANMi9mpgSViDfr5auTKLptWWhnP9lBzMVb+XyP6me bKayP31u15tEhe81N+oCiQESNn5xEWmCPlonJw5TOYODttU91S5G0Yf7O1r3MfO4 4yYiahfXuzv75hC9F0HDsw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1720189071; x= 1720275471; bh=+pkna8QIAs1fgaQPH6H7ayDirkuVCIQG5px4bmS7Rx0=; b=L 4VSJLvIapCyR3RBY833JMDztUn7d31bxFKvxM0vAU3kAqMQuf0QZMIb1fwvkU0Gn NGst3fH7S9h/9VXYtWOGHx1T/Dn43Ssi1Eob7xIkkX+MA19X8u/UYX0gJIQnS8xn hsIzTME1i687TfO5fuomj+yVna6dBe8CmVf7/lf5dmq+e8N5ysNfetBQgkijQ18b Eg0Q/qCDeMuBpdSeSfzd5A3Yq1DqRK0ADT7LlcAQQ8ha46bZYP209BM5mqf0ZfBs c5ezHNA6mwNLMyFJEuP7zDmdi+YYhNgOrkBnf2TpEz8+/9ugdKEq+aSvSJysgYCC fMtgKs2vqgDjLvD57d5mg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddugdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheplfhirgig uhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhmqeenuc ggtffrrghtthgvrhhnpedvkeeihfefveekueevteefleffkeegudeghfdtuddugefhueev geffgedukeejleenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfh hrohhmpehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 Jul 2024 10:17:47 -0400 (EDT) From: Jiaxun Yang Date: Fri, 05 Jul 2024 22:17:00 +0800 Subject: [PATCH v2 08/10] MIPS: GIC: Implement get_sw_int hook Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240705-b4-mips-ipi-improvements-v2-8-2d50b56268e8@flygoat.com> References: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> In-Reply-To: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> To: Thomas Bogendoerfer , Florian Fainelli , Broadcom internal kernel review list , Huacai Chen , Thomas Gleixner , Serge Semin , Paul Burton Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2476; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=MbvCb3pQ9sVxGj9YsZ2Bo3mcT7SECuL2ErrwnpMxUQY=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrQOhvSbQiX7dfwXHnip8FE+fe6uwKmGTwMZj2cnuM6Sq E1g+9HWUcrCIMbFICumyBIioNS3ofHigusPsv7AzGFlAhnCwMUpABMxPcHIsC5Efbfly6acRtae a59+MmzsDiyqs/8wXShO2uv6bZdjZxgZeh2clr02MdP/8bYxfMfCS7enRa9a2t3Y9j9VS/QAW/l +LgA= X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 SW0 and SW1 interrupts are routed through GIC in EIC mode, implement get_sw_int hook for GIC and generic platform to create IRQ mapping for SW0 and SW1 in such mode. Signed-off-by: Jiaxun Yang --- arch/mips/generic/irq.c | 15 +++++++++++++++ arch/mips/include/asm/mips-gic.h | 10 ++++++++++ drivers/irqchip/irq-mips-gic.c | 15 +++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/arch/mips/generic/irq.c b/arch/mips/generic/irq.c index 933119262943..bc3599a76014 100644 --- a/arch/mips/generic/irq.c +++ b/arch/mips/generic/irq.c @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -59,3 +60,17 @@ unsigned int get_c0_compare_int(void) return mips_cpu_timer_irq; } + +int get_mips_sw_int(int hwint) +{ + int mips_sw_int_irq; + + if (mips_gic_present()) + mips_sw_int_irq = gic_get_sw_int(hwint); + else if (cpu_has_veic) + panic("Unimplemented!"); + else + mips_sw_int_irq = mips_cpu_get_sw_int(hwint); + + return mips_sw_int_irq; +} diff --git a/arch/mips/include/asm/mips-gic.h b/arch/mips/include/asm/mips-gic.h index 084cac1c5ea2..83f0d04763bb 100644 --- a/arch/mips/include/asm/mips-gic.h +++ b/arch/mips/include/asm/mips-gic.h @@ -370,4 +370,14 @@ extern int gic_get_c0_perfcount_int(void); */ extern int gic_get_c0_fdc_int(void); +/** + * gic_get_sw_int() - Return software interrupt virq + * + * Determine the virq number to use for SWINT0 or SWINT1 interrupts, + * which may be routed via the GIC. + * + * Returns the virq number or a negative error number. + */ +extern int gic_get_sw_int(int hwirq); + #endif /* __MIPS_ASM_MIPS_CPS_H__ */ diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c index eb58392f0e66..1fbd7de3796b 100644 --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c @@ -143,6 +143,21 @@ int gic_get_c0_fdc_int(void) GIC_LOCAL_TO_HWIRQ(GIC_LOCAL_INT_FDC)); } +int gic_get_sw_int(int hwint) +{ + int local_irq; + + WARN_ON(hwint > 1); + + local_irq = GIC_LOCAL_INT_SWINT0 + hwint; + + if (!gic_local_irq_is_routable(local_irq)) + return MIPS_CPU_IRQ_BASE + hwint; + + return irq_create_mapping(gic_irq_domain, + GIC_LOCAL_TO_HWIRQ(local_irq)); +} + static void gic_handle_shared_int(bool chained) { unsigned int intr; From patchwork Fri Jul 5 14:17:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13725210 Received: from fout6-smtp.messagingengine.com (fout6-smtp.messagingengine.com [103.168.172.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DF7816EC0A; Fri, 5 Jul 2024 14:17:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189078; cv=none; b=qJ3WgDK2g2r7v+VjiiXPmJQkmSOjcg+GIsc3TeGtdOgd4gbZxz4T9U+5vwWEQYRdfJQ97t4K7ognKptoNraUO39pLyRz1jf2OJF43lJuePPW7Sy9rxHfX6yvI4hED5/myTYt4dcCVuyowWOETVZcSHUpfEnjP6tGPMG79i5bNIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189078; c=relaxed/simple; bh=mF8x5POR0JWocejCEm9t9GQmijFAUrqV9j/pcGQiv4E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=erOEytxKCjidcbx7a/ZgYJ051FN1E+wPEil5EbAb333b2E/nfZDVfVee9+EMyg7SsSFHNnU1Xk0hYz2f6mMF1muUt/r6Vc778TmZGiHC0tndLanwWX472ofqGGFiiTfLPA9ez1uWpbvy7Nz14P9ChUKwevh36PlHhl/zk12rx18= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=cCxqpO5J; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=RLeslqk6; arc=none smtp.client-ip=103.168.172.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="cCxqpO5J"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="RLeslqk6" Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.nyi.internal (Postfix) with ESMTP id C4221138016D; Fri, 5 Jul 2024 10:17:55 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 05 Jul 2024 10:17:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1720189075; x=1720275475; bh=jtNsz/USWp6cQ4gHMWhrcXI8O4aiXMuAzcA0q0zAbQo=; b= cCxqpO5JgvGj2CsNYmh8GzMup0SvPqp6KfX8i/f1fPkT1Z3RCnMATIiQn18YFJsh Lmt0OeOnW7QsWUGfNjzMWjVFd9kVdkxmK5j64Ar3MPjTjbhJj1Lxt4qO+V46fOS4 m0I4hHSOGTiBrFRzm6R9kRO3j2S9xduQV4kYdgaGJ20v0zaQTgam4ihc6dJVgjsD GwYcU+yV1YQb3iKAnITDwUvL89Xh5Wl7+f/b3h6rkO1w2RYPudfH0dPA3V30GtMU BNlwMKBIFb8I6qLalr3Edu/xoIi35GeboIDpR2XaNIUIhCk51zn5NhkLNkkntUUu DvFHB8R5mXPCnBNl4Ivhmw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1720189075; x= 1720275475; bh=jtNsz/USWp6cQ4gHMWhrcXI8O4aiXMuAzcA0q0zAbQo=; b=R Leslqk6CB9LfdRo+Wy9SHBlFQ/5sZXu2NREc121K7whT/jnJKLiY8rHsoAONvhu9 p/65PO64mY4EDxxyeeYBMQFHXJN4oW85YShODqrRzcPuvadTp1LOMRKfI5VDM8ja 4lgbnsDTwXMA85KgNGFI+x0u+p0Q9hxZ49QuQ20W3ndfcuC/lEGeeg59idvvFDEU /TFWOQAkOEtX3JYD9PbmJOdR8gL7IUIGZq2DdnSLyrokbE48eyw9eY//rlFDYZlm gDhFQnEISdWnwaUIez1a1Et/hZLPh5OheT9uMXnBVPDgw420gFRy6qmSSemrN9I9 IqlDZwe/peIANeIhzK9Ug== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddugdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheplfhirgig uhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhmqeenuc ggtffrrghtthgvrhhnpedvkeeihfefveekueevteefleffkeegudeghfdtuddugefhueev geffgedukeejleenucevlhhushhtvghrufhiiigvpedvnecurfgrrhgrmhepmhgrihhlfh hrohhmpehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 Jul 2024 10:17:52 -0400 (EDT) From: Jiaxun Yang Date: Fri, 05 Jul 2024 22:17:01 +0800 Subject: [PATCH v2 09/10] irqchip: irq-mips-cpu: Rework software IRQ handling flow Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240705-b4-mips-ipi-improvements-v2-9-2d50b56268e8@flygoat.com> References: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> In-Reply-To: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> To: Thomas Bogendoerfer , Florian Fainelli , Broadcom internal kernel review list , Huacai Chen , Thomas Gleixner , Serge Semin , Paul Burton Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3767; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=mF8x5POR0JWocejCEm9t9GQmijFAUrqV9j/pcGQiv4E=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrQOhvS8D+wG+iuKwrac4IjifVPU8EPR9WZbyc4o+1N69 3hvMBZ0lLIwiHExyIopsoQIKPVtaLy44PqDrD8wc1iZQIYwcHEKwERkLRgZvm5XVriyItR6H3vn vNNBZhorP/zTO3orwfJQa46fxOwjgQz/lKpTjjpdV/p+m/OTPJfqu+fh7NsMdrjWey09vE5y5q3 3DAA= X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Remove unnecessary irq_chip hooks for software interrupts, and don't mask them in ack hook to match kernel's expectation on handling flow. Create a irq_chip for regular (non-MT) mode software interrupts so they will be acked as well. Signed-off-by: Jiaxun Yang --- drivers/irqchip/irq-mips-cpu.c | 57 +++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/drivers/irqchip/irq-mips-cpu.c b/drivers/irqchip/irq-mips-cpu.c index 7b3501485d95..4854c06ce652 100644 --- a/drivers/irqchip/irq-mips-cpu.c +++ b/drivers/irqchip/irq-mips-cpu.c @@ -49,7 +49,21 @@ static inline void mask_mips_irq(struct irq_data *d) irq_disable_hazard(); } -static struct irq_chip mips_cpu_irq_controller = { +static unsigned int mips_sw_irq_startup(struct irq_data *d) +{ + clear_c0_cause(C_SW0 << d->hwirq); + back_to_back_c0_hazard(); + unmask_mips_irq(d); + return 0; +} + +static void mips_sw_irq_ack(struct irq_data *d) +{ + clear_c0_cause(C_SW0 << d->hwirq); + back_to_back_c0_hazard(); +} + +static const struct irq_chip mips_cpu_irq_controller = { .name = "MIPS", .irq_ack = mask_mips_irq, .irq_mask = mask_mips_irq, @@ -60,11 +74,19 @@ static struct irq_chip mips_cpu_irq_controller = { .irq_enable = unmask_mips_irq, }; +static const struct irq_chip mips_cpu_sw_irq_controller = { + .name = "MIPS", + .irq_startup = mips_sw_irq_startup, + .irq_ack = mips_sw_irq_ack, + .irq_mask = mask_mips_irq, + .irq_unmask = unmask_mips_irq, +}; + +#ifdef CONFIG_MIPS_MT /* * Basically the same as above but taking care of all the MT stuff */ - -static unsigned int mips_mt_cpu_irq_startup(struct irq_data *d) +static unsigned int mips_mt_sw_irq_startup(struct irq_data *d) { unsigned int vpflags = dvpe(); @@ -76,14 +98,14 @@ static unsigned int mips_mt_cpu_irq_startup(struct irq_data *d) /* * While we ack the interrupt interrupts are disabled and thus we don't need - * to deal with concurrency issues. Same for mips_cpu_irq_end. + * to deal with concurrency issues. */ -static void mips_mt_cpu_irq_ack(struct irq_data *d) +static void mips_mt_sw_irq_ack(struct irq_data *d) { unsigned int vpflags = dvpe(); + clear_c0_cause(C_SW0 << d->hwirq); evpe(vpflags); - mask_mips_irq(d); } #ifdef CONFIG_GENERIC_IRQ_IPI @@ -108,21 +130,17 @@ static void mips_mt_send_ipi(struct irq_data *d, unsigned int cpu) } #endif /* CONFIG_GENERIC_IRQ_IPI */ - -static struct irq_chip mips_mt_cpu_irq_controller = { +static const struct irq_chip mips_mt_cpu_irq_controller = { .name = "MIPS", - .irq_startup = mips_mt_cpu_irq_startup, - .irq_ack = mips_mt_cpu_irq_ack, + .irq_startup = mips_mt_sw_irq_startup, + .irq_ack = mips_mt_sw_irq_ack, .irq_mask = mask_mips_irq, - .irq_mask_ack = mips_mt_cpu_irq_ack, .irq_unmask = unmask_mips_irq, - .irq_eoi = unmask_mips_irq, - .irq_disable = mask_mips_irq, - .irq_enable = unmask_mips_irq, #ifdef CONFIG_GENERIC_IRQ_IPI .ipi_send_single = mips_mt_send_ipi, #endif }; +#endif asmlinkage void __weak plat_irq_dispatch(void) { @@ -152,11 +170,14 @@ asmlinkage void __weak plat_irq_dispatch(void) static int mips_cpu_intc_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw) { - struct irq_chip *chip; + const struct irq_chip *chip; - if (hw < 2 && cpu_has_mipsmt) { - /* Software interrupts are used for MT/CMT IPI */ - chip = &mips_mt_cpu_irq_controller; + if (hw < 2) { + chip = &mips_cpu_sw_irq_controller; +#ifdef CONFIG_MIPS_MT + if (cpu_has_mipsmt) + chip = &mips_mt_cpu_irq_controller; +#endif } else { chip = &mips_cpu_irq_controller; } From patchwork Fri Jul 5 14:17:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13725211 Received: from fout6-smtp.messagingengine.com (fout6-smtp.messagingengine.com [103.168.172.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B133516F299; Fri, 5 Jul 2024 14:18:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189082; cv=none; b=QTWQnP46/BiJMDkZI9kObJ9djG2wktjCkZtN6k4ojIbU0JYWG2voufoiMxYWTzYflSeSSs5V6OzcreHOUkDa688f4w4ymnSneQ22oRCt7ASC7XHskl308vVaQUs6uplhkLWrEfuvzviCOAUiBeO/cucUWlKYRWTiWGgwEIR4nzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720189082; c=relaxed/simple; bh=cizl+DqTY489BbMEQErJ507xnLbDf/+NyP9+YRFm6L0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qaE6sYWLbsHo1i5wcMIK3yMluxaJ5TxyTQODdkjJFsm861IVuyC3xC1DWuFjOi/m+xAJZ9St8/he1cH40eIMKY2lNxaDP8gkOcXt4M0PGym81r/2nJJaRS2H6oE29fbObd5xlj9gji62lKA0nHI4DOp80HbRSlXhk82sPlxTP9s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=bTMW+ecp; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=KlsnSBeK; arc=none smtp.client-ip=103.168.172.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="bTMW+ecp"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="KlsnSBeK" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfout.nyi.internal (Postfix) with ESMTP id D85CC13804A2; Fri, 5 Jul 2024 10:17:59 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 05 Jul 2024 10:17:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1720189079; x=1720275479; bh=pJ/eXGiO1EqWL0yvuR70WSTmCMtipawNq+jdUdKI+14=; b= bTMW+ecp3NvWSFRjKrflE1gGb1qF1Uaol0SR1Ah/NfeXQF/paCjf6xQezPRJet0k HdBUrKexGstFq7bPaJke9FBmdila0UukfBfGc4/kaWA31Lw+nqvMK5VrhTORdnjd 0EihY8AX4mqYXbb6sR5psStbCR9JRrVCLzsRxitWsXr1iQFVlaTglFjx/mxG46Ym x/iEWjE0igOGlzPM67zfHZ7EC5z+rFWJqmokzl/JU1vxRFU/rZs4HlgqtMxTHpDZ iPWkdv6N22aXzhiTFOiJ4nc0VfzLCmtk9G5hUFTO4h6Udn2LRLAkJSGMdVJYW4X6 +VLjAOmjyVPTVgZNg371ag== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1720189079; x= 1720275479; bh=pJ/eXGiO1EqWL0yvuR70WSTmCMtipawNq+jdUdKI+14=; b=K lsnSBeKn6JYmjv0Kc83HrwwZ9jMpcHEuB9snFIoy5yXChpBGPEpNV1uBr8bH143k 3o4oeVqZCkouNj9XhDEIXgUUe8aeB5P1Zz4KjXIV+FueMviRruyBFGGekunDD5OB JTgadBsH2xnkVE/C2x+h4JloJpfuf2PbglCK/ypkx2/03QDRHm2QrQVJYsuqGNHU 3XIjxsFpnpKg4heWx618xglO1to62HgxpjJn97BVZuy7UuLwYr2+QVqMAJUknl7a 58+APyQy89Q7khoYviHogOaWTPgadltAfCPQWt1LETXL939Myu9QcqeZ0ilYSFve Lhfl/Iwsl858mZIAL+97w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddugdejfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomheplfhirgig uhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhmqeenuc ggtffrrghtthgvrhhnpedvkeeihfefveekueevteefleffkeegudeghfdtuddugefhueev geffgedukeejleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 5 Jul 2024 10:17:56 -0400 (EDT) From: Jiaxun Yang Date: Fri, 05 Jul 2024 22:17:02 +0800 Subject: [PATCH v2 10/10] MIPS: smp-mt: Rework IPI functions Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240705-b4-mips-ipi-improvements-v2-10-2d50b56268e8@flygoat.com> References: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> In-Reply-To: <20240705-b4-mips-ipi-improvements-v2-0-2d50b56268e8@flygoat.com> To: Thomas Bogendoerfer , Florian Fainelli , Broadcom internal kernel review list , Huacai Chen , Thomas Gleixner , Serge Semin , Paul Burton Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=8867; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=cizl+DqTY489BbMEQErJ507xnLbDf/+NyP9+YRFm6L0=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrQOhnQW3TXB6nPnxcdfLDOaMqdthsYWCQ/mzEVZYnu5t m15+Yi7o5SFQYyLQVZMkSVEQKlvQ+PFBdcfZP2BmcPKBDKEgYtTACYSuYXhv0vK05N5LUZ3TQ78 TtkzSZBP/JVXkUjAZdcrGptUNnYVbmX4w98ZV96ss1zn7RKLPku+ZzunTMj5r75f6ov+NY/4s9O jeAE= X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Move smp IRQ code from irq-mips-cpu to smp-mt as IPI is not really relavant to CPU intc. In VEIC mode we can have irq-mips-cpu not registered and SW interrupts comes from EIC controllers. Implement IPI with ipi-mux to allow easy extension to number of IPIs. Signed-off-by: Jiaxun Yang --- arch/mips/Kconfig | 2 + arch/mips/kernel/smp-mt.c | 70 +++++++++++++++++++++++ drivers/irqchip/Kconfig | 1 - drivers/irqchip/irq-mips-cpu.c | 124 +---------------------------------------- 4 files changed, 74 insertions(+), 123 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 1236ea122061..de06c7425e94 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -2188,6 +2188,8 @@ config MIPS_MT_SMP depends on SYS_SUPPORTS_MULTITHREADING && !CPU_MICROMIPS select CPU_MIPSR2_IRQ_VI select CPU_MIPSR2_IRQ_EI + select GENERIC_IRQ_IPI + select GENERIC_IRQ_IPI_MUX select SYNC_R4K select MIPS_MT select SMP diff --git a/arch/mips/kernel/smp-mt.c b/arch/mips/kernel/smp-mt.c index 7729cc733421..2f00077dbf07 100644 --- a/arch/mips/kernel/smp-mt.c +++ b/arch/mips/kernel/smp-mt.c @@ -10,6 +10,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -19,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +31,65 @@ #include #include +static int vsmp_sw0_virq __ro_after_init; + +static void smvp_handle_ipi_irq(struct irq_desc *desc) +{ + struct irq_chip *chip = irq_desc_get_chip(desc); + + chained_irq_enter(chip, desc); + + /* irq-mips-cpu would ack for us, but EIC drivers won't */ + if (cpu_has_veic) { + unsigned int vpflags = dvpe(); + + clear_c0_cause(C_SW0); + evpe(vpflags); + } + ipi_mux_process(); + + chained_irq_exit(chip, desc); +} + +static void smvp_ipi_send(unsigned int cpu) +{ + unsigned long flags; + int vpflags; + + local_irq_save(flags); + + /* We can only send IPIs to VPEs within the local core */ + WARN_ON(!cpus_are_siblings(smp_processor_id(), cpu)); + vpflags = dvpe(); + settc(cpu_vpe_id(&cpu_data[cpu])); + write_vpe_c0_status(read_vpe_c0_status() | C_SW0); + write_vpe_c0_cause(read_vpe_c0_cause() | C_SW0); + evpe(vpflags); + + local_irq_restore(flags); +} + +static int __init vsmp_ipi_init(void) +{ + int sw0_virq, mux_virq; + + /* SW0 Interrupt for IPI */ + sw0_virq = get_mips_sw_int(0); + if (!sw0_virq) + return -EINVAL; + + mux_virq = ipi_mux_create(IPI_MAX, smvp_ipi_send); + if (!mux_virq) + return -EINVAL; + + irq_set_percpu_devid(sw0_virq); + irq_set_chained_handler(sw0_virq, smvp_handle_ipi_irq); + mips_smp_ipi_set_virq_range(mux_virq, IPI_MAX); + vsmp_sw0_virq = sw0_virq; + + return 0; +} + static void __init smvp_copy_vpe_config(void) { write_vpe_c0_status( @@ -123,6 +187,8 @@ static void vsmp_smp_finish(void) /* CDFIXME: remove this? */ write_c0_compare(read_c0_count() + (8* mips_hpt_frequency/HZ)); + enable_percpu_irq(vsmp_sw0_virq, IRQ_TYPE_NONE); + #ifdef CONFIG_MIPS_MT_FPAFF /* If we have an FPU, enroll ourselves in the FPU-full mask */ if (cpu_has_fpu) @@ -226,7 +292,11 @@ static void __init vsmp_smp_setup(void) static void __init vsmp_prepare_cpus(unsigned int max_cpus) { + int rc; + mips_mt_set_cpuoptions(); + rc = vsmp_ipi_init(); + WARN_ON(rc); } const struct plat_smp_ops vsmp_smp_ops = { diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index d5b841601731..56bba95eb3ef 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -187,7 +187,6 @@ config MADERA_IRQ config IRQ_MIPS_CPU bool select GENERIC_IRQ_CHIP - select GENERIC_IRQ_IPI if SMP && SYS_SUPPORTS_MULTITHREADING select IRQ_DOMAIN select GENERIC_IRQ_EFFECTIVE_AFF_MASK if SMP diff --git a/drivers/irqchip/irq-mips-cpu.c b/drivers/irqchip/irq-mips-cpu.c index 4854c06ce652..456f58729d00 100644 --- a/drivers/irqchip/irq-mips-cpu.c +++ b/drivers/irqchip/irq-mips-cpu.c @@ -34,8 +34,7 @@ #include #include -static struct irq_domain *irq_domain; -static struct irq_domain *ipi_domain; +static struct irq_domain *irq_domain __read_mostly; static inline void unmask_mips_irq(struct irq_data *d) { @@ -108,37 +107,12 @@ static void mips_mt_sw_irq_ack(struct irq_data *d) evpe(vpflags); } -#ifdef CONFIG_GENERIC_IRQ_IPI - -static void mips_mt_send_ipi(struct irq_data *d, unsigned int cpu) -{ - irq_hw_number_t hwirq = irqd_to_hwirq(d); - unsigned long flags; - int vpflags; - - local_irq_save(flags); - - /* We can only send IPIs to VPEs within the local core */ - WARN_ON(!cpus_are_siblings(smp_processor_id(), cpu)); - - vpflags = dvpe(); - settc(cpu_vpe_id(&cpu_data[cpu])); - write_vpe_c0_cause(read_vpe_c0_cause() | (C_SW0 << hwirq)); - evpe(vpflags); - - local_irq_restore(flags); -} - -#endif /* CONFIG_GENERIC_IRQ_IPI */ static const struct irq_chip mips_mt_cpu_irq_controller = { .name = "MIPS", .irq_startup = mips_mt_sw_irq_startup, .irq_ack = mips_mt_sw_irq_ack, .irq_mask = mask_mips_irq, .irq_unmask = unmask_mips_irq, -#ifdef CONFIG_GENERIC_IRQ_IPI - .ipi_send_single = mips_mt_send_ipi, -#endif }; #endif @@ -154,15 +128,8 @@ asmlinkage void __weak plat_irq_dispatch(void) pending >>= CAUSEB_IP; while (pending) { - struct irq_domain *d; - irq = fls(pending) - 1; - if (IS_ENABLED(CONFIG_GENERIC_IRQ_IPI) && irq < 2) - d = ipi_domain; - else - d = irq_domain; - - do_domain_IRQ(d, irq); + do_domain_IRQ(irq_domain, irq); pending &= ~BIT(irq); } } @@ -195,86 +162,6 @@ static const struct irq_domain_ops mips_cpu_intc_irq_domain_ops = { .xlate = irq_domain_xlate_onecell, }; -#ifdef CONFIG_GENERIC_IRQ_IPI - -struct cpu_ipi_domain_state { - DECLARE_BITMAP(allocated, 2); -}; - -static int mips_cpu_ipi_alloc(struct irq_domain *domain, unsigned int virq, - unsigned int nr_irqs, void *arg) -{ - struct cpu_ipi_domain_state *state = domain->host_data; - unsigned int i, hwirq; - int ret; - - for (i = 0; i < nr_irqs; i++) { - hwirq = find_first_zero_bit(state->allocated, 2); - if (hwirq == 2) - return -EBUSY; - bitmap_set(state->allocated, hwirq, 1); - - ret = irq_domain_set_hwirq_and_chip(domain, virq + i, hwirq, - &mips_mt_cpu_irq_controller, - NULL); - if (ret) - return ret; - - ret = irq_domain_set_hwirq_and_chip(domain->parent, virq + i, hwirq, - &mips_mt_cpu_irq_controller, - NULL); - - if (ret) - return ret; - - ret = irq_set_irq_type(virq + i, IRQ_TYPE_LEVEL_HIGH); - if (ret) - return ret; - } - - return 0; -} - -static int mips_cpu_ipi_match(struct irq_domain *d, struct device_node *node, - enum irq_domain_bus_token bus_token) -{ - bool is_ipi; - - switch (bus_token) { - case DOMAIN_BUS_IPI: - is_ipi = d->bus_token == bus_token; - return (!node || (to_of_node(d->fwnode) == node)) && is_ipi; - default: - return 0; - } -} - -static const struct irq_domain_ops mips_cpu_ipi_chip_ops = { - .alloc = mips_cpu_ipi_alloc, - .match = mips_cpu_ipi_match, -}; - -static void mips_cpu_register_ipi_domain(struct device_node *of_node) -{ - struct cpu_ipi_domain_state *ipi_domain_state; - - ipi_domain_state = kzalloc(sizeof(*ipi_domain_state), GFP_KERNEL); - ipi_domain = irq_domain_add_hierarchy(irq_domain, - IRQ_DOMAIN_FLAG_IPI_SINGLE, - 2, of_node, - &mips_cpu_ipi_chip_ops, - ipi_domain_state); - if (!ipi_domain) - panic("Failed to add MIPS CPU IPI domain"); - irq_domain_update_bus_token(ipi_domain, DOMAIN_BUS_IPI); -} - -#else /* !CONFIG_GENERIC_IRQ_IPI */ - -static inline void mips_cpu_register_ipi_domain(struct device_node *of_node) {} - -#endif /* !CONFIG_GENERIC_IRQ_IPI */ - int mips_cpu_get_sw_int(int hwint) { /* Only 0 and 1 for SW INT */ @@ -297,13 +184,6 @@ static void __init __mips_cpu_irq_init(struct device_node *of_node) NULL); if (!irq_domain) panic("Failed to add irqdomain for MIPS CPU"); - - /* - * Only proceed to register the software interrupt IPI implementation - * for CPUs which implement the MIPS MT (multi-threading) ASE. - */ - if (cpu_has_mipsmt) - mips_cpu_register_ipi_domain(of_node); } void __init mips_cpu_irq_init(void)