From patchwork Sat Sep 7 11:48:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13795199 Received: from fhigh4-smtp.messagingengine.com (fhigh4-smtp.messagingengine.com [103.168.172.155]) (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 C7882136663; Sat, 7 Sep 2024 11:48:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.155 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709702; cv=none; b=GsRRvEnCWPEef5K9XgTh7fwT+jssx1Z1r2QADc2szVmlOKYIoE1g+IQp8+zsTz3NwtvXDgBdByUC/bpSNL0K9zWI12rOEABjM7jNaHTa5GbWyDeEPp3tRA/L4qHXm9FiP+oFOltsP0VHxQeuh8IR8ppTe1tc+l7J3V24gYhOKrA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709702; c=relaxed/simple; bh=5s0h4ltAcE89p/zvUtASu3Xd2xwz+t07XtSjNshoY3U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=I7TfZdl/YzlXAZa1MleJbV4nXm6kR9m6gNIxCmscPC7CSz4ybfqvRfR9P/Dt8fUgUAh38v5Oll2wuJsd910j6vsVyPhIjrCbaKdvcBVErDTTlWfxR+hZxVqZfoD994RXzqpykbefcmDjHsHEGhL95oHbI2PeamRfYVLdBbheJaQ= 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=rBKLe0nj; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=iY41i0DO; arc=none smtp.client-ip=103.168.172.155 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="rBKLe0nj"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="iY41i0DO" Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id EB576114037F; Sat, 7 Sep 2024 07:48:18 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Sat, 07 Sep 2024 07:48:18 -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=fm2; t=1725709698; x=1725796098; bh=iizr2apqmb8sIr9RYIGCXOfidXaPrevsrVBYN6WI6kk=; b= rBKLe0njbIGY+QfFpvzAiZ/534vLPysMeDa60Wo/xQpRVILiWXNrdQmcl7AvUTC3 79E+h+nxlWi0phlGUUkvx0CbYX+8Mc+zZ5CBDI1wX+D9nScjNuiVd8V2AGctdWmO wHft4r+kJZHxzkc7JzVbCYbKTPYy6eBKUaK2eDLjB9Su4Xz9HesTAyVWZzSC8OQr bJK5DcBB/8v7H/2WzrbIdcCxheID/FZoOeitpVgT4rKN/T8JpH1/7fJrq5nrHTsR SRfwfY44KGAo0z3/4c0aGCw4yBY71k/79qGVRG272el28suXUQESI3PRtbYy2eou Z5OLVg8hVGu5uctF5QXoPQ== 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=fm1; t=1725709698; x= 1725796098; bh=iizr2apqmb8sIr9RYIGCXOfidXaPrevsrVBYN6WI6kk=; b=i Y41i0DOSQm6/Zfqwp9QmNcNYHSjQVpg3NfjUlm4ppL6eOdJukmZyi3J+2wVgnnQ/ aMrGmFosHwiagG7pAdmN0YDm19svCOmXyg6IDmrYDBH8XluEQkUpFeicLbB00Bpz Cn4x4b4zOkjd0zsHirNn9aD8+cqCd2KfdEN6JMNGhlYgPA3hD5zK0KyQGu51bLwo pRf+3q0irdf8lDzuwkK2u1Qb8b8ikgbPCXcd10LA3SVftFX2H/W3sBeMr4hDB3Zf HC+dNEP6Sb/atZLQ1jq2LmR1Z7rKl7ku7F/Cm9qRjxJf6doi+gfgKA6Yu/T3CvRF /p84g/y0QgbCa7bu8yffw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudeifedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepuddtpdhmohguvgepshhmthhpohhuthdprhgtphhtth hopegstghmqdhkvghrnhgvlhdqfhgvvggusggrtghkqdhlihhsthessghrohgruggtohhm rdgtohhmpdhrtghpthhtohepthhglhigsehlihhnuhhtrhhonhhigidruggvpdhrtghpth htohepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomhdprhgtphhtthhopegt hhgvnhhhuhgrtggriheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqmh hiphhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepphgruhhlsghurhht ohhnsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehflhhorhhirghnrdhfrghinhgvlh hlihessghrohgruggtohhmrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghl sehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepfhgrnhgtvghrrdhlrghntg gvrhesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 7 Sep 2024 07:48:17 -0400 (EDT) From: Jiaxun Yang Date: Sat, 07 Sep 2024 12:48:07 +0100 Subject: [PATCH v4 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: <20240907-b4-mips-ipi-improvements-v4-1-ac288f9aff0b@flygoat.com> References: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@flygoat.com> In-Reply-To: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@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.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=30134; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=5s0h4ltAcE89p/zvUtASu3Xd2xwz+t07XtSjNshoY3U=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrQ7tnVPjQW3NH2YbPQpurXKNm3SpuPl1xNutM/fNeFyW MWig8yxHaUsDGJcDLJiiiwhAkp9GxovLrj+IOsPzBxWJpAhDFycAjAR00ZGhnkbJ3rXd22ZH3ya 69GVFUeqrm+d8fB8XLzFVDNhSTZThr+MDNc8mtXm7fp0TK9fovODsfAf22/3JE7ZTVrhcm2vpeq SpcwA 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. Tested-by: Serge Semin 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 | 41 +++++------ 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 | 24 +++---- 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, 221 insertions(+), 233 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 2427d76f953f..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,11 +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 - /* Mask of CPUs which are currently definitely operating coherently */ extern cpumask_t cpu_coherent_mask; @@ -62,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 @@ -71,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 @@ -108,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 395622c37325..b7bcbc4770f2 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 0362fc5df7b0..62be2ca9f990 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 147acd972a07..68db4d8625bf 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 @@ -367,35 +367,29 @@ 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) { - int cpu = smp_processor_id(); - unsigned int action; + int op, cpu = smp_processor_id(); + unsigned long action; action = ipi_read_clear(cpu); - if (action & SMP_RESCHEDULE_YOURSELF) - scheduler_ipi(); - - if (action & SMP_CALL_FUNCTION) { - irq_enter(); - generic_smp_call_function_interrupt(); - irq_exit(); - } + for_each_set_bit(op, &action, IPI_MAX) + ipi_handlers[op](0, NULL); return IRQ_HANDLED; } 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 62733e049570..0e01484535e0 100644 --- a/arch/mips/sgi-ip27/ip27-smp.c +++ b/arch/mips/sgi-ip27/ip27-smp.c @@ -96,15 +96,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: @@ -120,12 +122,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 Sat Sep 7 11:48:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13795200 Received: from fhigh4-smtp.messagingengine.com (fhigh4-smtp.messagingengine.com [103.168.172.155]) (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 99E7515ADA1; Sat, 7 Sep 2024 11:48:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.155 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709704; cv=none; b=kMZLRG2xqZPVl7WRaeMkIDrwe5pf/GGCUWBT9+7AAQL7Yka4o0lyPz0uGaF4M7RmiXknNMUIo11on0LxGb6PF7OEOXBcVbKatU/f3nfWYS2AQWPhTLbSj/KFRozb++rDXovI+pDOGHe0Mn1hd2yJYadMCf04gqc7PRattGxcu1w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709704; c=relaxed/simple; bh=58n5oftC2DnQwV0ikeHMBkl408v+iyUjhXM5NNBBF8I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=g7b7khGYyqsgRqgajYKqb/+mks9H020t1OcwBfRpG3uefWkVZc2gbP2ktOH8FQ3q8l7+XtieDl9rPBLjL/OuXVSDUQ6wNk3j7ffLzJR6tgVFXRE2aaLtOxT8n3cNLHEIT5Xy1s2dqCCMsXv/KbV2LWJczp/y/J70rDYFFIq+URQ= 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=Ffhlocie; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=gYRQR6By; arc=none smtp.client-ip=103.168.172.155 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="Ffhlocie"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="gYRQR6By" Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfhigh.phl.internal (Postfix) with ESMTP id A6B2011401A4; Sat, 7 Sep 2024 07:48:21 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-12.internal (MEProxy); Sat, 07 Sep 2024 07:48: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=fm2; t=1725709701; x=1725796101; bh=UQirE3E0tG/YLAxLIT4NHU72WgW4GIoXMBPlaai6CFo=; b= FfhlocieXvXrAKFImXyBisqc5AJZyIdsurC+20JWKXTRIiGmY8VyFOofXIlCErLB ZJ5ZrdXWK7Arspjbd/Lpi7S/8aC5QeG5ivhFQnfgnodKnvwW0edHZ9AfMfsM6er8 FwDVj4319a3hRcFkMoE4z2iQNrYcEPWk89oKBthzFAKbZZ4/hOWojG9n0eLxtCXa vtU8YGy1vS6qIprIQh99Er3OudoJ1gT256K16nwHNt36INBozp5z+mTIIyU0178S rDpRXu2B5xI/yOfWJrGo7ye7LlHwlZ/3+6HwWQBLnKSGqkp2q/Pe58RYP6wsZcCQ T4N5wN+vXtX1wT++D+Hppw== 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=fm1; t=1725709701; x= 1725796101; bh=UQirE3E0tG/YLAxLIT4NHU72WgW4GIoXMBPlaai6CFo=; b=g YRQR6BylmK2+7eZVm894FTODcKUzILzTymQbJUGBTV/JqIePLYP2xqaIPz4eGJFA DEQXm4ks5LRzQvOb5pd+CV3VyOKOjD58UigRDRsUIpfZ7Pk8m2YIZs3yHw/exzAO n7NtUJHohFWM4AgfPzE1Y2OQ7ljqzXZibut3atotZH89xlZx13QwZydr6KTc19gN 3FNs1dYlmCVYEgJ/b4KCxh349mJ/FEH+cDmGyaofX03/Xd09Kq7SQqEKU/p0T0GY sRCG0fYWl0vxCi6l/sVxQ+JKC34ShQ9Li0r4mZRgYIKiequKq1A/OVbLMsIKYk9s /UKha8ohx96B+m++0l9QQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudeifedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepuddtpdhmohguvgepshhmthhpohhuthdprhgtphhtth hopegstghmqdhkvghrnhgvlhdqfhgvvggusggrtghkqdhlihhsthessghrohgruggtohhm rdgtohhmpdhrtghpthhtohepthhglhigsehlihhnuhhtrhhonhhigidruggvpdhrtghpth htohepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomhdprhgtphhtthhopegt hhgvnhhhuhgrtggriheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqmh hiphhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepphgruhhlsghurhht ohhnsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehflhhorhhirghnrdhfrghinhgvlh hlihessghrohgruggtohhmrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghl sehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepfhgrnhgtvghrrdhlrghntg gvrhesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 7 Sep 2024 07:48:19 -0400 (EDT) From: Jiaxun Yang Date: Sat, 07 Sep 2024 12:48:08 +0100 Subject: [PATCH v4 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: <20240907-b4-mips-ipi-improvements-v4-2-ac288f9aff0b@flygoat.com> References: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@flygoat.com> In-Reply-To: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@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.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=3252; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=58n5oftC2DnQwV0ikeHMBkl408v+iyUjhXM5NNBBF8I=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrQ7tnX3hAqfmb4v+itg26nrM/WL2/I1tyNN1q/7WTZtK 7PpHOEHHaUsDGJcDLJiiiwhAkp9GxovLrj+IOsPzBxWJpAhDFycAjARFl5GhnuO2aJ1LJKJyix/ /vMF/ttXsPIL8+v3AW8frzOJW/rBo4mR4WvjfJPFnYcvGIq9nG67Y90fIRPmT294Zs9e2MmxLew RGxsA 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. Tested-by: Serge Semin Signed-off-by: Jiaxun Yang --- 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 b7bcbc4770f2..6845884086f4 100644 --- a/arch/mips/kernel/smp-cps.c +++ b/arch/mips/kernel/smp-cps.c @@ -555,6 +555,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 62be2ca9f990..9918bf341ffd 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 Sat Sep 7 11:48:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13795201 Received: from fhigh4-smtp.messagingengine.com (fhigh4-smtp.messagingengine.com [103.168.172.155]) (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 0CE6815B103; Sat, 7 Sep 2024 11:48:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.155 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709705; cv=none; b=jwF+HY9yMfQ9E+BYxo319CjO80So7QfL7nLbAkKZMDq0TkliUoDbaTVIxPe3r00ej3ONayfG+TqZg2g80IvS1VIb8TNBG3tpasYL3n6ZjqTJlV7IaWI3UlsUMmds9RcLdlnV8mfozlHHPY3MtgISN8g5alnimbG2pUe6e73qgAM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709705; c=relaxed/simple; bh=cxGEu9/e+ohTEUF7vEiqEO8BVWC89yL0ln+4HSyC6Dk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qj1ZVChRsoWXh5LgzQmMUCeyAoEaYXzgA4j2vxRrxV7MFMfHpyr28YZxUO/rBsZf4oLY92T0Vr1sm6NG/1h3OgWjXLbx5OSxBhfnaObdhcBI/ihMPPS3VQTKRws2awZUlMgDKPaj/kErqKG6AwqBdBlk1o9zbFthc11Ka8eOD3Q= 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=4lOEbOAH; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=KXMZxpnj; arc=none smtp.client-ip=103.168.172.155 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="4lOEbOAH"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="KXMZxpnj" Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfhigh.phl.internal (Postfix) with ESMTP id 3EF4C11403A5; Sat, 7 Sep 2024 07:48:23 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-11.internal (MEProxy); Sat, 07 Sep 2024 07:48:23 -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=fm2; t=1725709703; x=1725796103; bh=1qEjgEDmS59aqiM5bbsGQaznl0i55CgECr+NGuaOlLk=; b= 4lOEbOAHIVc9iiaJRiIVL6XDfV9MsPZIFbb5K/sVfDdx0laLgKXPk8ca+HAx7jW4 YazyKXod+THB4tvYYHszX+ERvZaMcgN2dgo2TA7v8iNticG4hOw8XXDhm6GfqMtF pkWsupppqSmVhyXWXaQWSvrwOJozpg8QIn+L5wAfmNdRu0pYWZL8ZczKF8PGmgza 0cotfoCwxublve9Mw4AXRIr/73tPQz3VlNGE1mAYToC0rKf1JB9pqlWhN1rkWXON BjJgFWI6NEjuWkOkB2W1qqxJXWm0euKAriO5KjkaJaEuRrM8qUKoies5sLZ5wclG uEXkhsoqnYfrjmUoIM9WBw== 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=fm1; t=1725709703; x= 1725796103; bh=1qEjgEDmS59aqiM5bbsGQaznl0i55CgECr+NGuaOlLk=; b=K XMZxpnju1k2TidejWnsZMdPuXLyUHDV2Xj1SkdI2rW7LrKQHWiWVFygz0k0BCnCb tzGj2mVwiUbGwnBOMvtRbqZQW6uHpgf5dROlbYPRdxNp5zuiLEadgZ+SK4+CxlFf usP3BYyQl/AYh+TKvVvI7SsGGLHfrshWdvvUhWk++MZOhYIGkhs9l3VD+JmbJBWn fSdtdwVCq5uQw5gHxVopP5wnlRabqwnSsow5B2+C5uZextn8tD1EBvVDUmzbVXiA w7TlCyyzZgfyxnxGjNpcem95KEgl0d1PPt8OC8kP3a0AqogEfY0iXYvk0QpYSksZ /hyjsE7m1JwtoJozWYDXA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudeifedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepuddtpdhmohguvgepshhmthhpohhuthdprhgtphhtth hopegstghmqdhkvghrnhgvlhdqfhgvvggusggrtghkqdhlihhsthessghrohgruggtohhm rdgtohhmpdhrtghpthhtohepthhglhigsehlihhnuhhtrhhonhhigidruggvpdhrtghpth htohepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomhdprhgtphhtthhopegt hhgvnhhhuhgrtggriheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqmh hiphhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepphgruhhlsghurhht ohhnsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehflhhorhhirghnrdhfrghinhgvlh hlihessghrohgruggtohhmrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghl sehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepfhgrnhgtvghrrdhlrghntg gvrhesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 7 Sep 2024 07:48:21 -0400 (EDT) From: Jiaxun Yang Date: Sat, 07 Sep 2024 12:48:09 +0100 Subject: [PATCH v4 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: <20240907-b4-mips-ipi-improvements-v4-3-ac288f9aff0b@flygoat.com> References: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@flygoat.com> In-Reply-To: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@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.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=4958; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=cxGEu9/e+ohTEUF7vEiqEO8BVWC89yL0ln+4HSyC6Dk=; b=kA0DAAoWQ3EMfdd3KcMByyZiAGbcPX6ilaIYNkt5fQyVN1Pxf4guKQsJU433iemz6GZjCn8pt 4h1BAAWCgAdFiEEVBAijrCB0aDX4Gr8Q3EMfdd3KcMFAmbcPX4ACgkQQ3EMfdd3KcPK0wEA5U+K 63m/eRc1fWy8NhiXKTAnvRDQTMn5v9h3FtoLKOEBAJerNCVt8XOk9tg4L+AE8rqteoyVjBg5omm nghlRxYEH 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. Tested-by: Serge Semin 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..7cac0f4ccf37 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 +static inline void mips_smp_ipi_set_virq_range(int virq, int nr) +{ +} + +static inline 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 9918bf341ffd..d3c7486fee3d 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 Sat Sep 7 11:48:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13795202 Received: from fhigh4-smtp.messagingengine.com (fhigh4-smtp.messagingengine.com [103.168.172.155]) (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 A5A3C15B551; Sat, 7 Sep 2024 11:48:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.155 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709707; cv=none; b=qtpqscBSBhe72dzumRX1KByNv7uetpCZ4TQbEkq5hzafYJVNMKp9S6stNLEqBfVCraAsUaiYCEHgn0v7km4iz+WWQHHhWP7FvDOxJT2X07DNWgFVTWcypRONSG+SSkuj1PjXDQQQNdC5g9+c//JxGX3pDD2bj+HY6F0rP051sDg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709707; c=relaxed/simple; bh=h1CQghwYCPF+SPQ/gns7o2gvkxa6sP1KKjEjw9Zu6Ww=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Iq2OgeBCTKj7QnLawNA4l4N1irsLFY7KcRvqVikKvx56op8fXc4DXBWFOk5E5nYzYgcFNitaSh8hIWP91AU/47t4s3NT2tRa63vOgu0fRmI/kswt+vvQY5y1v18hgyH28caUSdQ4L7FzR2HexKFECjlQ/jsdfzFN3yA6QlxRxRg= 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=lS2Ys18X; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=kK0X8Co8; arc=none smtp.client-ip=103.168.172.155 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="lS2Ys18X"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="kK0X8Co8" Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id AEDB31140397; Sat, 7 Sep 2024 07:48:24 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Sat, 07 Sep 2024 07:48:24 -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=fm2; t=1725709704; x=1725796104; bh=UYj2B4lpikMda7PIIE6TQxRt02SlCYsTBh0EWJX+0Ok=; b= lS2Ys18XMJrhJzIy948eVWDkHPjqj4x+map2exn8P6NmSALV5nA5PTsqJA4+uu6Q FaDoooqH2Z658sJIIq/7krUclbHy8WXR+2vHJLtRgZ+I0b7k6O5JXl5yvR9HWejV NhswDalwGfHt/mj8UMgS+t+kaoAi2RNmKAkFAuFyzF94fyCWwel0EW4YZ2ArsoHb qivE75Y1gUO1OnbV03nR9tjlJiupt78/bc8nKi4T08BhVzLCJexjzMQ8atIPBCvg vmiIRhDSdmE9gc+5iwU5dZUcXzQxzlzmf7u9xFL9aVvhld23TEOBPU+8ILV6jEnI P0bUyshsxfNlD/b6sSlowA== 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=fm1; t=1725709704; x= 1725796104; bh=UYj2B4lpikMda7PIIE6TQxRt02SlCYsTBh0EWJX+0Ok=; b=k K0X8Co8gN5PkImhT8+CpOx3FHDcdZvlYqkCoX6iIieb+dBTcsHoA3UqF/qqvdwAx ZUuEdeziVoppdpdcvOVoz7yAJhW695gm7f90N6Qe4YwwilNHFhKb2IXOlgv3bIZl 0cP5yz5ZNO8RmcKLiZl7ACo0SRTze1pbi6ae0xK+mWiPZ/7/hNjkr628EtPbO2tk x6LJWnmyspdzoqP4oYPqKpRxlF3PZ2Y6eRAHjkoJpSBUTy0LVcayGrWPLbyAqTGX jXd06DAcN4pMajA7/tUyOyhVDqm331uEalpk8Nma/RZekeazQkViNf0VA7a48hg3 UvOgyj4eupIheT4zMhJag== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudeifedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepuddtpdhmohguvgepshhmthhpohhuthdprhgtphhtth hopegstghmqdhkvghrnhgvlhdqfhgvvggusggrtghkqdhlihhsthessghrohgruggtohhm rdgtohhmpdhrtghpthhtohepthhglhigsehlihhnuhhtrhhonhhigidruggvpdhrtghpth htohepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomhdprhgtphhtthhopegt hhgvnhhhuhgrtggriheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqmh hiphhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepphgruhhlsghurhht ohhnsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehflhhorhhirghnrdhfrghinhgvlh hlihessghrohgruggtohhmrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghl sehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepfhgrnhgtvghrrdhlrghntg gvrhesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 7 Sep 2024 07:48:23 -0400 (EDT) From: Jiaxun Yang Date: Sat, 07 Sep 2024 12:48:10 +0100 Subject: [PATCH v4 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: <20240907-b4-mips-ipi-improvements-v4-4-ac288f9aff0b@flygoat.com> References: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@flygoat.com> In-Reply-To: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@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.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1192; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=h1CQghwYCPF+SPQ/gns7o2gvkxa6sP1KKjEjw9Zu6Ww=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrQ7tnXeN1Wj9ewvzTKt1kxq9Fw5UeDhjucqws8eR20s7 pHdtCOno5SFQYyLQVZMkSVEQKlvQ+PFBdcfZP2BmcPKBDKEgYtTACai7MPwv/rHi9LlV5MPROhL 2HXtDg4sbTC3NbNSPDa1aVP///2HpjMyLNLovDF5wv2aGnbFJXP2RCyLk3zim6axT+6Q7cd/eZs fcAIA 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. Tested-by: Serge Semin 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 d3c7486fee3d..81ae65f21f73 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 Sat Sep 7 11:48:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13795203 Received: from fhigh4-smtp.messagingengine.com (fhigh4-smtp.messagingengine.com [103.168.172.155]) (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 DAA5415957E; Sat, 7 Sep 2024 11:48:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.155 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709708; cv=none; b=qv0CjMmHw0QbvhqKVr030Oeb5/4+dM5zAA/CnnOQ0es6uFnTxid936mQhga89QUpRu+Su3uPgeVeyvrolyrpCqR+pHScFZe5ih9DAahhM65Toqymzc70XakCPm25niXD9IPx7tzaixiu3Wcve8ihRv7/L3NPlIDvmGfTIJdoHRQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709708; c=relaxed/simple; bh=ErvuYehZlH7OfBsYVUKd73rir6ScJ5aBTq7g7ZdVsaE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GxHOgbZ0PWDPD5Z2v5S2RNT16K6LMcfuiEOiSDGIzMxbMwddMfmfXUlt6SeRaAd6Io0YgzRqH9PG7/NZs7nRc08QQEtMX+SDJRpBWwga8HMVOSWrzry4XWV7X8lLB1M/G6I+aYDH+6jlzbyhqzvbE5Z/knim/i1AmLDqnnUzC1k= 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=YmcjgUmj; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=DHLNQ2cO; arc=none smtp.client-ip=103.168.172.155 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="YmcjgUmj"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="DHLNQ2cO" Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfhigh.phl.internal (Postfix) with ESMTP id 3852711403A8; Sat, 7 Sep 2024 07:48:26 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-08.internal (MEProxy); Sat, 07 Sep 2024 07:48:26 -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=fm2; t=1725709706; x=1725796106; bh=TLhrQlpte+h4C4JBu2pe373WSb7OWOLjGh/btfBRXrQ=; b= YmcjgUmjhLARICCAzJ6FF9MlKNKhaYkkVCgSgXAJjE500bcd2k5fYpK09jC93WEL vB5ZBPwXJSKEXmf0aIKmwzgccd9YXA87P2Ny7GMbhN4DTvlJh6/Bmpdh6wpDQTdd BW+2+zzFlYPuY4nbwp7AyROENXYqyN/nWz9dWcOpqPNRIon9WAYwIecWPgcZeaC2 jsXp5wy38Kxl/EaqcamIKQ1Zvv2DlaVaO54MhxfbhWncBqSKcp+T6WDH33KbPqFl 6w839rhjpP4MP9XmGwhptEFVlL3vzO04hwDpTHFlLHlYFoz8snSGtpoRtU2g9vdA qgatRj471Jcc26OMNjKPYA== 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=fm1; t=1725709706; x= 1725796106; bh=TLhrQlpte+h4C4JBu2pe373WSb7OWOLjGh/btfBRXrQ=; b=D HLNQ2cOk2VinqVLuRcywaz1xB/3Yp0V9fuU+SqmDJ0ht0SK5f5bw96zXsyDmWkir OvBsKB30izMOwkV5jHx+z0CchHu8k9L0VOmImHWV/sxbGj6DHjPCU/+Hdrum4Jp0 2b2bsD5D44sfaEx4/feSL55MTJ8PDdgbWO7uvjPz9oBB+jxZpNQLNyuGAf6qoQaM TxMFqm36+yb6HOmUw3yLLVDG+z/ZR56uc2QYOM7wPcETEGqtFCbmNI3y+BTYrWC0 MepfviB7J9SgnKP1+fXkTSuGl7baMIMXs0KdPKTfnl8S9OSGAPMROmwwGezDDNBd AlHKn1/fDblvA+ydaNbKg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudeifedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepuddtpdhmohguvgepshhmthhpohhuthdprhgtphhtth hopegstghmqdhkvghrnhgvlhdqfhgvvggusggrtghkqdhlihhsthessghrohgruggtohhm rdgtohhmpdhrtghpthhtohepthhglhigsehlihhnuhhtrhhonhhigidruggvpdhrtghpth htohepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomhdprhgtphhtthhopegt hhgvnhhhuhgrtggriheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqmh hiphhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepphgruhhlsghurhht ohhnsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehflhhorhhirghnrdhfrghinhgvlh hlihessghrohgruggtohhmrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghl sehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepfhgrnhgtvghrrdhlrghntg gvrhesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 7 Sep 2024 07:48:24 -0400 (EDT) From: Jiaxun Yang Date: Sat, 07 Sep 2024 12:48:11 +0100 Subject: [PATCH v4 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: <20240907-b4-mips-ipi-improvements-v4-5-ac288f9aff0b@flygoat.com> References: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@flygoat.com> In-Reply-To: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@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.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2722; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=ErvuYehZlH7OfBsYVUKd73rir6ScJ5aBTq7g7ZdVsaE=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrQ7tnXCP/rsmm77V26ad31q9O+s1bFLtBYvWi5zwL3kA etZZ5cnHaUsDGJcDLJiiiwhAkp9GxovLrj+IOsPzBxWJpAhDFycAjARp4OMDPf1732ySI11+7d+ l7uTlOR/r4AfT6ouxbe51bHoFiROO8TwV956gWyPruyVhd2BImqaD0N3fPphx8UkGegbbn773/3 /3AA= 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. Tested-by: Serge Semin 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 7cac0f4ccf37..7d310012962f 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 static inline 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 81ae65f21f73..aa02ca2e0fcf 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 Sat Sep 7 11:48:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13795204 Received: from fhigh4-smtp.messagingengine.com (fhigh4-smtp.messagingengine.com [103.168.172.155]) (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 B288615C14E; Sat, 7 Sep 2024 11:48:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.155 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709710; cv=none; b=n40XB4okEMxEXU6MRPTzcDVs22r9asUZOoEW/02BFCTPmNz9BiB5u1o0r+jE1hSGIrJKjZVrVeBSrup6BzW0zmoTLStwC83leKOHhchxpUf0em21GkVkza8yPmTKU84qw9x6+Mqa1jefr2jo24i8Uws23Srv2cvDU1qwp4fiLKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709710; c=relaxed/simple; bh=gg8Z/h1yFMcmiyi9C/7fVV2i0PFBzrHovJhFNEKtjaY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=g9uOZefC0SkCg7hXRrCxcYlDOGSDyPJQXtjDijv4GymKeT3WUj5wC86C5yAvgVXIbAbzeyw53PhMsPO6kiepJDJAYozq0cAZdtSVTxwkKa7LxakWFMjEf344bkGx2vwXL1beXe8JnTFLJddsyloLpIYCSR5nQCiAaWTjCdOTTJI= 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=V/g+N4IY; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=OW5/xs4o; arc=none smtp.client-ip=103.168.172.155 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="V/g+N4IY"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="OW5/xs4o" Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfhigh.phl.internal (Postfix) with ESMTP id CA8CE11403AA; Sat, 7 Sep 2024 07:48:27 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-09.internal (MEProxy); Sat, 07 Sep 2024 07:48:27 -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=fm2; t=1725709707; x=1725796107; bh=ljCeGEwB3yu6opLY+A856DZwYFxls7FWp+Jflg4ET6k=; b= V/g+N4IYI/hXOp5Mdu71TzXWL2rk0fm9nvSK+mJ12gzEkBNFbRwFf4vHvuQzlWTK ++MVwJZW8dNJX9dU8U+a6CAz1fab9Xf2miq8TOFGt8iMGYn+sPdGrP1VFgDw2X2s hKf+FOXtAVl8vnE05e/B6d9fOYvhgHPu+UjR+6IqaZhreUZnhGyoNW+r+l0xoIHT CLyCwjsbQZNuRtBUsHVMJkw5uB6qKQhsell6VQ96VAUAmXsRTBKXYIZHQc00adXr s1UQrOH7/Pw3mXTZffnZJdMjwIo/bUFZa1hh+KU0085SqtFmIedklJdky+s/5ojl 1YKLBmX4ErrH03bQsQZEgQ== 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=fm1; t=1725709707; x= 1725796107; bh=ljCeGEwB3yu6opLY+A856DZwYFxls7FWp+Jflg4ET6k=; b=O W5/xs4ohzHVjWGSrHKvesxxzjsfuX+2z7g9rFhoeAGvlra4kMtPlvYtVJBPFWM/u Mh7M0sx5Z56GEjjUnHcfjENu0iT+7fpaBJCskXwLhk2PBY3tfatf7SIO4SkXD3dd 48L0l9LZmw4sGJoMD01fuFxfKYAjn0O0dEB7jFHZAQkzXnzzezj9lF6LO9NhiXTa YlYBWYHn+/Wve5A2oMahJkYDMNkYCIKzMQqKoogK6lLVCHlG/f7K7/OqygNBz3dG jx86CGjJpOCrgyb+2afO7pHAGol3bMVXhWL/jqMIXgL8kFtMH2n4JXdbAexrDxws VQWtya2cMTnczPrbNgLyA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudeifedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepuddtpdhmohguvgepshhmthhpohhuthdprhgtphhtth hopegstghmqdhkvghrnhgvlhdqfhgvvggusggrtghkqdhlihhsthessghrohgruggtohhm rdgtohhmpdhrtghpthhtohepthhglhigsehlihhnuhhtrhhonhhigidruggvpdhrtghpth htohepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomhdprhgtphhtthhopegt hhgvnhhhuhgrtggriheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqmh hiphhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepphgruhhlsghurhht ohhnsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehflhhorhhirghnrdhfrghinhgvlh hlihessghrohgruggtohhmrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghl sehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepfhgrnhgtvghrrdhlrghntg gvrhesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 7 Sep 2024 07:48:26 -0400 (EDT) From: Jiaxun Yang Date: Sat, 07 Sep 2024 12:48:12 +0100 Subject: [PATCH v4 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: <20240907-b4-mips-ipi-improvements-v4-6-ac288f9aff0b@flygoat.com> References: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@flygoat.com> In-Reply-To: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@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.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=10449; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=gg8Z/h1yFMcmiyi9C/7fVV2i0PFBzrHovJhFNEKtjaY=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrQ7tnVlwWsZPrXVP3QMyj4SPKW7sopnceP/WuYlUwynL zyc9npNRykLgxgXg6yYIkuIgFLfhsaLC64/yPoDM4eVCWQIAxenAExENp/hf76sao3z92CJ5495 Z3JIlfJO7VmltWjVuSUZFTlhLYf82Rn+JyVWXnB9xM3KbsDwWK1Jf2rqlD/92/qTT90782Qn77f NvAA= X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Use ipi_mux to implement IPI interrupts instead of allocating separate vectors for each individual IPI messages. This reduces number of reserved GIC shared vectors from 3 per core to 1 per core, which relieves the scarcity of GIC shared vectors on MSI enabled systems. It also allows us to easily expand number of IPIs. Tested-by: Serge Semin Signed-off-by: Jiaxun Yang --- v4: - Improve commit message - Wrap up gic_is_reserved - Style fixes --- drivers/irqchip/Kconfig | 1 + drivers/irqchip/irq-mips-gic.c | 202 ++++++++++++++--------------------------- 2 files changed, 69 insertions(+), 134 deletions(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index d078bdc48c38..763070be0088 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -346,6 +346,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..53c585d598b9 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 { @@ -66,6 +68,15 @@ static struct gic_all_vpes_chip_data { bool mask; } gic_all_vpes_chip_data[GIC_NUM_LOCAL_INTRS]; +#ifdef CONFIG_GENERIC_IRQ_IPI +static inline bool gic_is_reserved(unsigned int intr) +{ + return test_bit(intr, ipi_resrv); +} +#else +static inline bool gic_is_reserved(unsigned int intr) { return false; } +#endif + static void gic_clear_pcpu_masks(unsigned int intr) { unsigned int i; @@ -108,13 +119,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 +185,10 @@ static void gic_mask_irq(struct irq_data *d) unsigned int intr = GIC_HWIRQ_TO_SHARED(d->hwirq); write_gic_rmask(intr); + + if (gic_is_reserved(intr)) + return; + gic_clear_pcpu_masks(intr); } @@ -191,6 +199,9 @@ static void gic_unmask_irq(struct irq_data *d) write_gic_smask(intr); + if (gic_is_reserved(intr)) + return; + 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 +274,9 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask, unsigned long flags; unsigned int cpu; + if (gic_is_reserved(intr)) + return; + cpu = cpumask_first_and(cpumask, cpu_online_mask); if (cpu >= NR_CPUS) return -EINVAL; @@ -304,7 +318,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 +488,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 +577,73 @@ 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) +static void gic_handle_ipi_irq(struct irq_desc *desc) { - /* - * 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; + struct irq_chip *chip = irq_desc_get_chip(desc); - return 0; + chained_irq_enter(chip, desc); + ipi_mux_process(); + chained_irq_exit(chip, desc); } -static int gic_ipi_domain_alloc(struct irq_domain *d, unsigned int virq, - unsigned int nr_irqs, void *arg) +static void gic_ipi_send(unsigned int cpu) { - 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; + write_gic_wedge(GIC_WEDGE_RW | cpu_ipi_intr[cpu]); } -static void gic_ipi_domain_free(struct irq_domain *d, unsigned int virq, - unsigned int nr_irqs) +static int gic_ipi_mux_init(struct device_node *node, struct irq_domain *d) { - irq_hw_number_t base_hwirq; - struct irq_data *data; + unsigned int i, v[2], num_ipis; + int ipi_virq, cpu = 0; - data = irq_get_irq_data(virq); - if (!data) - return; + if (node && !of_property_read_u32_array(node, "mti,reserved-ipi-vectors", v, 2)) { + bitmap_set(ipi_resrv, v[0], v[1]); + } else { + /* + * Reserve 1 interrupts per possible CPU/VP for use as IPIs + */ + num_ipis = num_possible_cpus(); + bitmap_set(ipi_resrv, gic_shared_intrs - num_ipis, num_ipis); + } - base_hwirq = GIC_HWIRQ_TO_SHARED(irqd_to_hwirq(data)); - bitmap_set(ipi_available, base_hwirq, nr_irqs); -} + ipi_virq = ipi_mux_create(IPI_MAX, gic_ipi_send); -static int gic_ipi_domain_match(struct irq_domain *d, struct device_node *node, - enum irq_domain_bus_token bus_token) -{ - bool is_ipi; + WARN_ON(bitmap_weight(ipi_resrv, GIC_MAX_INTRS) < num_possible_cpus()); - 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; - } -} + for_each_set_bit(i, ipi_resrv, GIC_MAX_INTRS) { + struct irq_fwspec fwspec; + int virq; -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, -}; + 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; -static int gic_register_ipi_domain(struct device_node *node) -{ - struct irq_domain *gic_ipi_domain; - unsigned int v[2], num_ipis; + virq = irq_create_fwspec_mapping(&fwspec); + if (!virq) + return -EINVAL; - 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; - } + 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)); - irq_domain_update_bus_token(gic_ipi_domain, DOMAIN_BUS_IPI); + cpu_ipi_intr[cpu] = i; - 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. - */ - num_ipis = 2 * num_possible_cpus(); - bitmap_set(ipi_resrv, gic_shared_intrs - num_ipis, num_ipis); + cpu++; + if (cpu >= num_possible_cpus()) + break; } - bitmap_copy(ipi_available, ipi_resrv, GIC_MAX_INTRS); + 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, struct irq_domain *d) { return 0; } @@ -809,10 +743,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 +752,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 Sat Sep 7 11:48:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13795205 Received: from fhigh4-smtp.messagingengine.com (fhigh4-smtp.messagingengine.com [103.168.172.155]) (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 43AC115D5BE; Sat, 7 Sep 2024 11:48:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.155 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709711; cv=none; b=RtHotGAlijRgjuSrkFnLxo15Begh2Rwxn5rMnmUo8HuRcGejFUbb6lsjdMb82fQfB3HjkRIDZGPCSX3YScQQXrhOSkiRObKzqQf7E4+bHXL+DibyBe3ADMIc2W6rHh1E87/fD6fyUxkWH6kxmnIunyUymzBdexr9aHkjNgqO5OA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709711; c=relaxed/simple; bh=eIhrStCFhvy6UxtCOWmxnItdfmDtk8eGTHQjAvagVJQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JgPU8BOqEpzEllHyemOCQs1ap2xPQGEQ6dG5Q2af5LpGPmQcs6euUDOUW2M0/hP7zWpSIOTSw6nJBFM5n/TOAAIYiLrqFIUyYeJ9jjQPt8fGNnE8KLLIlldhfARWLa2IqXEGLhlfiIfDs7qp9nbL4kWlHRm1IV4l8M/FOzV5KPg= 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=t6gkIibp; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=C19IDgi8; arc=none smtp.client-ip=103.168.172.155 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="t6gkIibp"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="C19IDgi8" Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfhigh.phl.internal (Postfix) with ESMTP id 5DDDC114037F; Sat, 7 Sep 2024 07:48:29 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-11.internal (MEProxy); Sat, 07 Sep 2024 07:48:29 -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=fm2; t=1725709709; x=1725796109; bh=CrRlxBx9BNlgfuT4leF0ZpEwcFYthm6BbRrRIv9TLgk=; b= t6gkIibpW6OCEsdrhqGjnJ+Fxj3xbWSvx+TI+8RY0dT4N3X0aemjymaODo3eBptD lDe254ZyqnvqJLv6lRUXmNxtoiFp78YWb+71m+KC0DEoUX4G98hTqNonMQjDZUGz Lk5kt3LmZLjNF5rICJle9+KTFlQBpl5/oMLi/jJnKaB4URU4NOWjVvlii2kSegc8 vbG1dSIFGn3GyCpCAu7jwQ4Sx0f9KY/RB08EyQvwNLkQXLxIIgiEGd9CClF2dKn2 kPloVM8olq2fmo2LtsPQVXz0SVZnEjg6ELFrcAZocEmMddl52AeRIROd+pO/y7AY uLVko2vo2dsuYV6YAqyxaw== 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=fm1; t=1725709709; x= 1725796109; bh=CrRlxBx9BNlgfuT4leF0ZpEwcFYthm6BbRrRIv9TLgk=; b=C 19IDgi8H++EwiXxh+Re/+vqE1xVRGBWiFm0tjzgt+pQ+nrpTd6o0YESAmdcDLr2G p7RX+y+IMnWy7GHuRf0VEoCF1JGCy1+vZIk1vCvDyl6lNZDQYqO7CkOlNlSs/Dx4 pu7mRrZwdedYgeRoiPqiVnvZRwnHTPzQyPmlAkvcdmjpU3WH1XQLsGvVh7AfbbUW rAkOMxf1G9cd7QTNQTLgKlRJarf3gVXiGtIqRqvqTcd8Hw9a5BoOr7yjg/OgA0p1 uF8jfqPJc2rk/32IJ8r/OnDaJJOiphvEf0ii7Y5y/ty1LubGwespYPcNIdJicMCm soU2cB47sMFovfnu4hKMA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudeifedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgepudenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepuddtpdhmohguvgepshhmthhpohhuthdprhgtphhtth hopegstghmqdhkvghrnhgvlhdqfhgvvggusggrtghkqdhlihhsthessghrohgruggtohhm rdgtohhmpdhrtghpthhtohepthhglhigsehlihhnuhhtrhhonhhigidruggvpdhrtghpth htohepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomhdprhgtphhtthhopegt hhgvnhhhuhgrtggriheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqmh hiphhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepphgruhhlsghurhht ohhnsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehflhhorhhirghnrdhfrghinhgvlh hlihessghrohgruggtohhmrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghl sehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepfhgrnhgtvghrrdhlrghntg gvrhesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 7 Sep 2024 07:48:28 -0400 (EDT) From: Jiaxun Yang Date: Sat, 07 Sep 2024 12:48:13 +0100 Subject: [PATCH v4 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: <20240907-b4-mips-ipi-improvements-v4-7-ac288f9aff0b@flygoat.com> References: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@flygoat.com> In-Reply-To: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@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.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2807; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=eIhrStCFhvy6UxtCOWmxnItdfmDtk8eGTHQjAvagVJQ=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrQ7tnWveRZEZsY7rjSvye0/9/h5K5PzplyXzSKm2y8+P Kd+cu+sjlIWBjEuBlkxRZYQAaW+DY0XF1x/kPUHZg4rE8gQBi5OAZjIPxlGhqfOSqePnukTrZOM YrK6/FDqGW+EB+NDdr8fzuemvFdv02dk+BO0/5WyuZfrpJvHj2akLEzQeGEkPmtD12kjiV9brtq f4gQA 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. Tested-by: Serge Semin 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 Sat Sep 7 11:48:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13795206 Received: from fhigh4-smtp.messagingengine.com (fhigh4-smtp.messagingengine.com [103.168.172.155]) (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 C754615ECC8; Sat, 7 Sep 2024 11:48:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.155 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709713; cv=none; b=NMPOv98i+G8R/fITn+Xsx7pZNBYO5mwCoazOqJUu3q4uj5NTjPTtseE++CjtMus+uBPpFYCGUIZzCJPeS3O1qDWGiNEKsfxavzKQya/VtZtnMr+3fergNKCir8WxIcPaZXAxh8AZx9WquCrGe5H9jvM+hO3N1d9P1eWxWeP13sU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709713; c=relaxed/simple; bh=FZsZgMo0PlKhdv7fIPEiO4rijAlOP5RWzA8dZssIKZI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UlK0mi3u2jsfuPC0o29oE1OXlxKpAPgWrrStnzCOb/YAMFLSdHXcXA67+7JoSjKJWJF+rfMtlIZiH0LpC4DFKPTGAc6V4DHCZJaCv7qW+JYFsqOjeHzFMz5qC02XEDC3RqaX61UJTsmH5DTaa8ePoy9hikGl5r4koJHuvIEixQQ= 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=1wyb4qLs; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=r8c97WPm; arc=none smtp.client-ip=103.168.172.155 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="1wyb4qLs"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="r8c97WPm" Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id C934C114038A; Sat, 7 Sep 2024 07:48:30 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Sat, 07 Sep 2024 07:48: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=fm2; t=1725709710; x=1725796110; bh=TD23Dk7CP3pr5Nxa9Vsf3EzqXkorQe0K8fg3rzSx+pU=; b= 1wyb4qLs6I20HmuUI9DFUwtiAiyUIPYtETv56XmxKJo5TEHLupehfxSYocjeOgfe ULPta46SGkJDjsD9rwdTf6S1C+8xrdQRhxF6F6F2gQ9LI2YU9EmuEy1IlS1EwuK/ TS6ephdBjuY9eo3yu0Q9jCYsulBI9f51Qtxv+0lTs2VmUWwILWQJmc/lpSE1QhlY xs1oviXJIeyy0GV0fDp7fL2GbvF7VuAH9uhI2B6pdDD98UP8k0rjceWIMQ6L52tK ii4N1Bm+WDkHSbApDAq8k3cdCxX8lAvcyLmN3BnPd6nVIbTXfUwXDZjQFu2pA05A 86026e/vu+FRr6n1jFKpCA== 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=fm1; t=1725709710; x= 1725796110; bh=TD23Dk7CP3pr5Nxa9Vsf3EzqXkorQe0K8fg3rzSx+pU=; b=r 8c97WPmx7xBvmOVM9ILJXO3baNtESCLZhtknwwLE8xLiCRtz84dwifC3yxqSZue4 iJrtJ3cYzXhJIkgNFl/qJ/fcQcISCbPaM5I15rWh2G0tR92e802sR3DGKNqb34Rf spJLqK4aZAJfIBoxXj4hHREAq6keexnETDMQZf52RTcLq8A9yi0UEXdp1yW7D8cX PyawY9Togl4uWEW3KUdCS18JRadekQOnbz1dShiVFyD0gGW2VUe0Jn/8DYExz/DL zG0y+dcoJogMHVHhyco3bVY4kZ770C91B1HfekP8z3dmawD4rO65XlhpPfRUqPFm +AXxQhZ458d/GLZlwaxhw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudeifedggeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepuddtpdhmohguvgepshhmthhpohhuthdprhgtphhtth hopegstghmqdhkvghrnhgvlhdqfhgvvggusggrtghkqdhlihhsthessghrohgruggtohhm rdgtohhmpdhrtghpthhtohepthhglhigsehlihhnuhhtrhhonhhigidruggvpdhrtghpth htohepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomhdprhgtphhtthhopegt hhgvnhhhuhgrtggriheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqmh hiphhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepphgruhhlsghurhht ohhnsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehflhhorhhirghnrdhfrghinhgvlh hlihessghrohgruggtohhmrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghl sehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepfhgrnhgtvghrrdhlrghntg gvrhesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 7 Sep 2024 07:48:29 -0400 (EDT) From: Jiaxun Yang Date: Sat, 07 Sep 2024 12:48:14 +0100 Subject: [PATCH v4 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: <20240907-b4-mips-ipi-improvements-v4-8-ac288f9aff0b@flygoat.com> References: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@flygoat.com> In-Reply-To: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@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.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2526; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=FZsZgMo0PlKhdv7fIPEiO4rijAlOP5RWzA8dZssIKZI=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrQ7tnWKT9k2B58UkNkZEBbWwd8070JG8Pv7t7Y7TNgo3 7fhz5EbHaUsDGJcDLJiiiwhAkp9GxovLrj+IOsPzBxWJpAhDFycAjCRTR8ZGS41JSuXss6dfUSr 8sFOlf8MXmyWi6YEiN61v+FXt3hexWOG/zEK2x8kRLF8Fzv7seyR2dHQnFeOH+8JuO85muejvtX 2Dx8A 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. Tested-by: Serge Semin 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 fd9da5e3beaa..3e9d1b252500 100644 --- a/arch/mips/include/asm/mips-gic.h +++ b/arch/mips/include/asm/mips-gic.h @@ -388,4 +388,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 53c585d598b9..57b8deb40489 100644 --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c @@ -152,6 +152,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 Sat Sep 7 11:48:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13795207 Received: from fout8-smtp.messagingengine.com (fout8-smtp.messagingengine.com [103.168.172.151]) (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 50B7715957E; Sat, 7 Sep 2024 11:48:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.151 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709714; cv=none; b=Eyc2ZjWU8TcVILmFMUhnQxWm2R6c/dP3vh11XcuWSWu1sGhqxv7dAOzP38ngPP2Qktw4sm4LItPL1GKZDn7sowuRvLEbKLJSEGn7Ntmc22J0FO9xmjr/MhCHm7TWFU6LLT1D1Lml0JbsessHjXTzYUXUwzEB+OV7oSo/5FbBr8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709714; c=relaxed/simple; bh=4WUwKXY4S6rrZcYJC6tMjl9r4iaCf1PK2jcPhkKx5yU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bBjt2KOnfvzKUbp1YIW41afrwpvBULvrtChb+HUs2UzUp5xRP0QL4DLfO0hQNiHGysQXlHQAmiG+Rqr1MGMpEID3ART/lupo9rNW6rbDPrGCl8VU3+H/KSPfeAQdHMt+Kofj6GLTqv7FFxCa6ran5v+7JOOsQQGM4wcZBI5mpWU= 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=K/EDRBml; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=T1UsXR4h; arc=none smtp.client-ip=103.168.172.151 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="K/EDRBml"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="T1UsXR4h" Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfout.phl.internal (Postfix) with ESMTP id 62D431380450; Sat, 7 Sep 2024 07:48:32 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-08.internal (MEProxy); Sat, 07 Sep 2024 07:48:32 -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=fm2; t=1725709712; x=1725796112; bh=kA05i1fXhZEAfbPD1jPhI8sd/40p+OHNicYDDwcgaGI=; b= K/EDRBml3cxIWH4c/7Ch5vrQK4Rst3WtGFSto3Am4SFuwKacbU76xdlpFUM19KmQ QUhz8NwCFuxUUKl9DEIIvuDXa0zbHPoCUoXJVVlv0EuxfR7z3murLVRbwzt3mDOb bxluTcQCC2ZAmzH0Lv3/5H76fqPTvXEKAGYWQgr7JoeFuxCtJu4bwlGifSEsc6Hb oAK3Zpg9XY9ewcttHUIEOWOYnTMSSJ/u9wiMTg7H1gsbkKAa4GDRwLDHq2fULFQD byuivaghOjVDopPth2Jnogr9/XAdxHi+lz45uO7b5ZWBzcKjwp8TicgPiah+7iRe Pee9Ujl1uw/c9CHuTicq/g== 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=fm1; t=1725709712; x= 1725796112; bh=kA05i1fXhZEAfbPD1jPhI8sd/40p+OHNicYDDwcgaGI=; b=T 1UsXR4hNzCIOnR9DhgRr8Ea9K9+vPQx8KZYR0VHeiO6mpUBoNFjiuYmPxrv6spB5 FGQfuGFMXE8bAWp0udo9tuSCC6sVAjurLhAKHXrHwWzbiQ+uxTSWi3VwfDgWih8I LOmGB2oBY2Y2SUIKl+rBEHSDvpKvHHse0ultMiReqgeIsAbwteSSwCMZwrO62blx NlPkGl936QC0Nzi4sfRzMZFCAzR3Ur0WMJWFXgbAmrg8/k+4mqOGoGIaYDHHf8Ma dla94ZLY7sZo/489C0VXxCy/FwjqFk4d7pbPc0Ai02EFWIBqv1r10ui6w1GDsFXR zV+18AhDvPnuUrJtDMczw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudeifedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgepudenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepuddtpdhmohguvgepshhmthhpohhuthdprhgtphhtth hopegstghmqdhkvghrnhgvlhdqfhgvvggusggrtghkqdhlihhsthessghrohgruggtohhm rdgtohhmpdhrtghpthhtohepthhglhigsehlihhnuhhtrhhonhhigidruggvpdhrtghpth htohepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomhdprhgtphhtthhopegt hhgvnhhhuhgrtggriheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqmh hiphhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepphgruhhlsghurhht ohhnsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehflhhorhhirghnrdhfrghinhgvlh hlihessghrohgruggtohhmrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghl sehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepfhgrnhgtvghrrdhlrghntg gvrhesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 7 Sep 2024 07:48:30 -0400 (EDT) From: Jiaxun Yang Date: Sat, 07 Sep 2024 12:48:15 +0100 Subject: [PATCH v4 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: <20240907-b4-mips-ipi-improvements-v4-9-ac288f9aff0b@flygoat.com> References: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@flygoat.com> In-Reply-To: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@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.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=4374; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=4WUwKXY4S6rrZcYJC6tMjl9r4iaCf1PK2jcPhkKx5yU=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrQ7tnXr13Bkfu54XZi0ZfPDc6m6cY5uE6/+t+sNtMxyX B06dyZjRykLgxgXg6yYIkuIgFLfhsaLC64/yPoDM4eVCWQIAxenAEzkHAfDHz6egL9XT96VNGlp L6h7vtVYYebTcgYB3h1z/5Y4O5/lfs7wh3PW7uA5fdWlRWGM29iuTVxf9GWH78s7UyZrBzB/mPy cnwcA X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Remove unnecessary irq_mask_ack, irq_eoi, irq_disable, irq_enable irq_chip hooks for software interrupts, as they are simple edge triggered IRQs and there is no need for those duplicated callbacks. Don't mask IRQ in mips_mt_cpu_irq_ack, that is not expected for edge IRQ handling flow. Create a irq_chip for regular (non-MT) mode software interrupts, as they are edge triggered IRQs thus need startup/ack callbacks as well. Tested-by: Serge Semin Signed-off-by: Jiaxun Yang --- v4: - Reword commit message - Style fixes --- drivers/irqchip/irq-mips-cpu.c | 68 +++++++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/drivers/irqchip/irq-mips-cpu.c b/drivers/irqchip/irq-mips-cpu.c index 7b3501485d95..99f9151cc8e7 100644 --- a/drivers/irqchip/irq-mips-cpu.c +++ b/drivers/irqchip/irq-mips-cpu.c @@ -49,7 +49,7 @@ static inline void mask_mips_irq(struct irq_data *d) irq_disable_hazard(); } -static struct irq_chip mips_cpu_irq_controller = { +static const struct irq_chip mips_cpu_irq_controller = { .name = "MIPS", .irq_ack = mask_mips_irq, .irq_mask = mask_mips_irq, @@ -60,11 +60,33 @@ static struct irq_chip mips_cpu_irq_controller = { .irq_enable = unmask_mips_irq, }; +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_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) { @@ -149,17 +167,27 @@ asmlinkage void __weak plat_irq_dispatch(void) } } +#ifdef CONFIG_MIPS_MT +static inline const struct irq_chip *mips_cpu_get_sw_irqchip(void) +{ + return cpu_has_mipsmt ? &mips_mt_cpu_sw_irq_controller : &mips_cpu_sw_irq_controller; +} +#else +static inline const struct irq_chip *mips_cpu_get_sw_irqchip(void) +{ + return &mips_cpu_sw_irq_controller; +} +#endif + 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; - } else { + if (hw < 2) + chip = mips_cpu_get_sw_irqchip(); + else chip = &mips_cpu_irq_controller; - } if (cpu_has_vint) set_vi_handler(hw, plat_irq_dispatch); From patchwork Sat Sep 7 11:48:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13795208 Received: from fhigh4-smtp.messagingengine.com (fhigh4-smtp.messagingengine.com [103.168.172.155]) (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 7E8251607AC; Sat, 7 Sep 2024 11:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.155 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709716; cv=none; b=sbG0Xpwky7rPbsH07VmahSB8lXnTQ4yIX7tCiZUQ9XEJvItiS6trRogVPr6fkPppXhi3+TYoaqi0rLq7A6760qnrpvHaEyXvtYaGuR5b0LgK+brgJJ8nKbNFs4+eDHcoq7RKNH2xdblnCl3x6JAvzKLOtj3f+lsmb1uAVJy1Ap0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725709716; c=relaxed/simple; bh=yAaGy+mfs5mfzjmMr5ympnR40rfa6oPy+WXYv0opvAY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nmEAZEiI+plfFBIloNj5CGBnQwo8B6ZDEtrMe4mL99mXV+HNUggoSuU9Aai6LvLNcFcHINoMGa8ajZTg8eZQr2vRO89KT9sExOT1cLjnlM2M6USf7NqTmOx0ghAmm3t9+PPJdz3HIrEUjL1Xe+3za/RJsmvDeo/7wTAKqpG8wsM= 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=g+aXB3Z7; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=VQN7mVDO; arc=none smtp.client-ip=103.168.172.155 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="g+aXB3Z7"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="VQN7mVDO" Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id D2350114037E; Sat, 7 Sep 2024 07:48:33 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Sat, 07 Sep 2024 07:48:33 -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=fm2; t=1725709713; x=1725796113; bh=mUaBn6aVgoiEbY+DmuAgQpvOlWt6JK4F1AoLqYdfmTk=; b= g+aXB3Z7/w+ePUptkx4XYFH/9MPs82LjZcoWQyXhnN4M3gE7DJLydRv7cnBPVKj8 19zI32E37ErC41pdwGGcBmQXh+roL4yRaxL5PiKnfiY3lgH3x21eX1mQMyf/gF7t N0Ok621+C6Q/kh99wqWPTpzMNDP+HkKYd1KbnRbv2ydCu1J6KFi0PcqaOKBO8p+3 07Q8YTjTT9l9O6o+7jh9TFmc9mk4hV87mljmGzL2MQRt+/x/Cae+xmV/okxDMX9q hwDJtI04Pu+C2kEMEsExykxEfMldgaB+O0BWvjW5kQ8XRAHKvjvYusARYhsjbZFo ZvNythwnBwypWhsBQIJEWw== 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=fm1; t=1725709713; x= 1725796113; bh=mUaBn6aVgoiEbY+DmuAgQpvOlWt6JK4F1AoLqYdfmTk=; b=V QN7mVDOwp92S7PsHJvPyf+HoJ12QQBRJ3/Lu406ZXAeuOM/rzbku9MVEwbM0s6no +1K9ThPYLMDXYb+LRIusfeM/GEJB9gGfAUTHOGke5JnphXFxMlezYEw8j6Mi9bzV wNLt3yQJaGIHemfw1rfwx4qNEmVV2CZIERhWeeBW1NFuqYoH/E6pSTz7MY+PW5l4 X/hhXG5jiTs6r07fzen49/mE/6Trzh9Nt4FGY5EAXcoP2kf2C/7xhC/jAhGarknu sFktg5H/n6re95vuKta2m7wqntdBYNER29RRtiwg7FDptkPkkxdvo0cuCYSwEqwy +NgIgHgzMW5k6hzLooPcg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudeifedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepuddtpdhmohguvgepshhmthhpohhuthdprhgtphhtth hopegstghmqdhkvghrnhgvlhdqfhgvvggusggrtghkqdhlihhsthessghrohgruggtohhm rdgtohhmpdhrtghpthhtohepthhglhigsehlihhnuhhtrhhonhhigidruggvpdhrtghpth htohepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomhdprhgtphhtthhopegt hhgvnhhhuhgrtggriheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqmh hiphhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepphgruhhlsghurhht ohhnsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehflhhorhhirghnrdhfrghinhgvlh hlihessghrohgruggtohhmrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghl sehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepfhgrnhgtvghrrdhlrghntg gvrhesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 7 Sep 2024 07:48:32 -0400 (EDT) From: Jiaxun Yang Date: Sat, 07 Sep 2024 12:48:16 +0100 Subject: [PATCH v4 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: <20240907-b4-mips-ipi-improvements-v4-10-ac288f9aff0b@flygoat.com> References: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@flygoat.com> In-Reply-To: <20240907-b4-mips-ipi-improvements-v4-0-ac288f9aff0b@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.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=8917; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=yAaGy+mfs5mfzjmMr5ympnR40rfa6oPy+WXYv0opvAY=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrQ7tnWurHv9zF6WTZOUc1s1PXfWQa208Kyv8nsdH7tkx quZf8jqKGVhEONikBVTZAkRUOrb0HhxwfUHWX9g5rAygQxh4OIUgIn8rmZkOPLzgMjtHe/Lna48 a3s5LeOjY1G1Yuvsl+wXPnqVy6vO3s/wT9XfPbhiev3PfZrrWwSu5jAxZH8LzJ/5gln/7Xm1G7J MnAA= 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. Tested-by: Serge Semin 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 43da6d596e2b..08ef79093916 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -2189,6 +2189,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 763070be0088..786ed8a6b719 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -192,7 +192,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 99f9151cc8e7..8faa2bcf55de 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); } } @@ -202,86 +169,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 */ @@ -304,13 +191,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)