From patchwork Sat Apr 8 10:45:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 81161 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp820880vqo; Sat, 8 Apr 2023 04:39:36 -0700 (PDT) X-Google-Smtp-Source: AKy350bNqP3XZ7qSHmbUDmQSIkR78156W/Fr9SOyA9U2HFMlyI0E3DuRqS50WVeEzqajeY5PV65s X-Received: by 2002:a62:7992:0:b0:626:2ab1:19a8 with SMTP id u140-20020a627992000000b006262ab119a8mr2200915pfc.25.1680953975928; Sat, 08 Apr 2023 04:39:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680953975; cv=none; d=google.com; s=arc-20160816; b=SaZ8LVVZzs8x/UDj89ncLhLkHdpwtOPV7MNMhoBa5h5eCu24inM3irI/8tFtX8TMFe z0maC97tcVcQNI+07oc/tS1MMAnucl/QEEGGW0G6+TTn6MGRlDeLQM2yLB22wq//xFQe ZjIOmDJfWSDRuYtepJQGY6hspiOe6k0NZ40RFYGj+Em4N9OKcThFgn//DM5N+IVHaHJj zjo1ACjsz1dFH9Too9ORYTX81tZNEY6UP7xurtOOkjZwgmqbQZVB4T2PbmRujLebSBlZ qtY/kWraTY/KJZYAo1Nqa2V7hDzibAvKCe609n46+TNB/+IBGcOrHf5psma0YHn64K+W upOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=rlXM2oUJ+UDGCP6iYnQRbV/QcA072fozjL9IZh3YPHU=; b=c51n9h4xJKiOf9CdlRfYMOvIrNPkxvTIMnbxbuVkpvMfrGGV8vracD2Q18s9Go9j8i 7dVPOJAC1yqaXy15WPvDsVB2oSCUJOyc/lV2wVmLqx4OhIRPDqQnxFjBOn2Z03uEirF9 Vna9AC/0YMnWBpFy1QDelr2rEqmByQ+ku6MRFAuuTU8QreLykuZIcUv3k6s4By9XVO/c 9R9HhMs715EUaiwLzyFSffc4l7j78Y8p0ys2kLAtyfo3LeYCCjfcy++/h7254PKJ6FyQ egOeQxzX/1gViVE361UnOkIBD+zhsC55yUOJf0BX4oKQnoprGMl/S2iCqMDAgbXIXpGu 1p6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0vCUWkE2; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v129-20020a626187000000b0062af7928e45si5873887pfb.268.2023.04.08.04.39.23; Sat, 08 Apr 2023 04:39:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0vCUWkE2; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230272AbjDHKt0 (ORCPT + 99 others); Sat, 8 Apr 2023 06:49:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230095AbjDHKsy (ORCPT ); Sat, 8 Apr 2023 06:48:54 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82F9DE1AB for ; Sat, 8 Apr 2023 03:48:16 -0700 (PDT) Date: Sat, 08 Apr 2023 10:45:17 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1680950718; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rlXM2oUJ+UDGCP6iYnQRbV/QcA072fozjL9IZh3YPHU=; b=0vCUWkE2jE1ZER98A9UEASokEbboYrEaOcg+xSgiHO3mNJKOUWnU0dtD9LyR4wwVUv1P0F IY6vSWqO7cnUhQYDOvYSLcB3tqmyBVUtYPML6UiQzNzr1VM/whzvLoMLtAa6ITsTo8gAGf vEj8liOa4trcZvoK4DOrAe8Dog4gaOVCqCkk4Kumjd1yzmNVd5qtHgpP1XjBe3kWSDzdMZ BOajo6GBhVxdYPEEOWG82D7Wd0vOBkoKea0+pRI6PFZDLQmybO9c+p/6ZC7FUcGeO6H2gs dGhfubAKRNQ5KVgZSehfAewX2nRb5j8s84dREPCyjeKzdKdMvFP9jmzw9s241A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1680950718; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rlXM2oUJ+UDGCP6iYnQRbV/QcA072fozjL9IZh3YPHU=; b=OjUJizKP2j80uZRrGkPDKvGwFuj15b0Hfhzun6nWrVUJw4rB9EE9hRUyvxrJtxnd32UyZ7 RMLPCd8VrVQ3bRDg== From: "irqchip-bot for Anup Patel" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-kernel@vger.kernel.org Subject: [irqchip: irq/irqchip-next] RISC-V: Allow marking IPIs as suitable for remote FENCEs Cc: Anup Patel , Atish Patra , Palmer Dabbelt , Marc Zyngier , tglx@linutronix.de In-Reply-To: <20230328035223.1480939-5-apatel@ventanamicro.com> References: <20230328035223.1480939-5-apatel@ventanamicro.com> MIME-Version: 1.0 Message-ID: <168095071786.404.9640710405026668539.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761583855525105155?= X-GMAIL-MSGID: =?utf-8?q?1762607996574369936?= The following commit has been merged into the irq/irqchip-next branch of irqchip: Commit-ID: fb0f3d281b7f81a11e210783940f3798c4744179 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/fb0f3d281b7f81a11e210783940f3798c4744179 Author: Anup Patel AuthorDate: Tue, 28 Mar 2023 09:22:20 +05:30 Committer: Marc Zyngier CommitterDate: Sat, 08 Apr 2023 11:26:24 +01:00 RISC-V: Allow marking IPIs as suitable for remote FENCEs To do remote FENCEs (i.e. remote TLB flushes) using IPI calls on the RISC-V kernel, we need hardware mechanism to directly inject IPI from the supervisor mode (i.e. RISC-V kernel) instead of using SBI calls. The upcoming AIA IMSIC devices allow direct IPI injection from the supervisor mode (i.e. RISC-V kernel). To support this, we extend the riscv_ipi_set_virq_range() function so that IPI provider (i.e. irqchip drivers can mark IPIs as suitable for remote FENCEs. Signed-off-by: Anup Patel Reviewed-by: Atish Patra Acked-by: Palmer Dabbelt Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20230328035223.1480939-5-apatel@ventanamicro.com --- arch/riscv/include/asm/smp.h | 18 ++++++++++++++++-- arch/riscv/kernel/sbi-ipi.c | 2 +- arch/riscv/kernel/smp.c | 11 ++++++++++- drivers/clocksource/timer-clint.c | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/arch/riscv/include/asm/smp.h b/arch/riscv/include/asm/smp.h index 4fe7a88..c4b7701 100644 --- a/arch/riscv/include/asm/smp.h +++ b/arch/riscv/include/asm/smp.h @@ -16,6 +16,9 @@ struct seq_file; extern unsigned long boot_cpu_hartid; #ifdef CONFIG_SMP + +#include + /* * Mapping between linux logical cpu index and hartid. */ @@ -46,7 +49,12 @@ void riscv_ipi_disable(void); bool riscv_ipi_have_virq_range(void); /* Set the IPI interrupt numbers for arch (called by irqchip drivers) */ -void riscv_ipi_set_virq_range(int virq, int nr); +void riscv_ipi_set_virq_range(int virq, int nr, bool use_for_rfence); + +/* Check if we can use IPIs for remote FENCEs */ +DECLARE_STATIC_KEY_FALSE(riscv_ipi_for_rfence); +#define riscv_use_ipi_for_rfence() \ + static_branch_unlikely(&riscv_ipi_for_rfence) /* Check other CPUs stop or not */ bool smp_crash_stop_failed(void); @@ -96,10 +104,16 @@ static inline bool riscv_ipi_have_virq_range(void) return false; } -static inline void riscv_ipi_set_virq_range(int virq, int nr) +static inline void riscv_ipi_set_virq_range(int virq, int nr, + bool use_for_rfence) { } +static inline bool riscv_use_ipi_for_rfence(void) +{ + return false; +} + #endif /* CONFIG_SMP */ #if defined(CONFIG_HOTPLUG_CPU) && (CONFIG_SMP) diff --git a/arch/riscv/kernel/sbi-ipi.c b/arch/riscv/kernel/sbi-ipi.c index 41981ab..a455969 100644 --- a/arch/riscv/kernel/sbi-ipi.c +++ b/arch/riscv/kernel/sbi-ipi.c @@ -72,6 +72,6 @@ void __init sbi_ipi_init(void) "irqchip/sbi-ipi:starting", sbi_ipi_starting_cpu, NULL); - riscv_ipi_set_virq_range(virq, BITS_PER_BYTE); + riscv_ipi_set_virq_range(virq, BITS_PER_BYTE, false); pr_info("providing IPIs using SBI IPI extension\n"); } diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c index 47e7ecf..5f985a1 100644 --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -177,7 +177,10 @@ bool riscv_ipi_have_virq_range(void) return (ipi_virq_base) ? true : false; } -void riscv_ipi_set_virq_range(int virq, int nr) +DEFINE_STATIC_KEY_FALSE(riscv_ipi_for_rfence); +EXPORT_SYMBOL_GPL(riscv_ipi_for_rfence); + +void riscv_ipi_set_virq_range(int virq, int nr, bool use_for_rfence) { int i, err; @@ -200,6 +203,12 @@ void riscv_ipi_set_virq_range(int virq, int nr) /* Enabled IPIs for boot CPU immediately */ riscv_ipi_enable(); + + /* Update RFENCE static key */ + if (use_for_rfence) + static_branch_enable(&riscv_ipi_for_rfence); + else + static_branch_disable(&riscv_ipi_for_rfence); } static const char * const ipi_names[] = { diff --git a/drivers/clocksource/timer-clint.c b/drivers/clocksource/timer-clint.c index 7ccc16d..9a55e73 100644 --- a/drivers/clocksource/timer-clint.c +++ b/drivers/clocksource/timer-clint.c @@ -251,7 +251,7 @@ static int __init clint_timer_init_dt(struct device_node *np) } irq_set_chained_handler(clint_ipi_irq, clint_ipi_interrupt); - riscv_ipi_set_virq_range(rc, BITS_PER_BYTE); + riscv_ipi_set_virq_range(rc, BITS_PER_BYTE, true); clint_clear_ipi(); #endif