From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB015230BFB for ; Wed, 2 Jul 2025 12:25:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751459105; cv=none; b=keNtIyOFUY/HEqfU5sjhy+VqMr6W1YSpUbNXujCE9Ex+g6ar+CHlFIJrbOZnP64M22UNpA4c9rbqL99Ddxq8iHD2HGzEg41Kv63lU1J9LfqUmxowjfoipS+JR5JW6Wj3Gl845WrE93vhLJiKgjjaz4ObHwLfFDnV8LPIBAUj3Ng= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751459105; c=relaxed/simple; bh=bYeNN8vsgLwUwh3/64Fr+1MpEfsYUrXCytYoEB996QQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=m1FDOSz340pZuhw+9QOia0JdyERgasoNRGv3AJW1n3vYI3krbEt+SYPMfnOqMyLEuPPKMX8qepZfNurgOOw0VkAHujRoYYfgO5+NReeoPuJ/pfrHTOhFW/otmYf+pmOixnpKITunONSBA+5AlHkn6sw5hhZHBVWuU1dPwor4Dd0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=XLu9RRDj; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="XLu9RRDj" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2353a2bc210so40780755ad.2 for ; Wed, 02 Jul 2025 05:25:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1751459103; x=1752063903; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=d2/Oz6A0ZcrKaCz3NC9OtHbxQaQqo8pmpupCjGRpV8w=; b=XLu9RRDjURRUHaYASmcPPUUHFDA0sBNar/rLhu8CyeK9UAc47C0N7Jg9z5vn75nMRy ecPVPenX4/PtlosRxFYn0jSQWdnsay2n+kv7UW6ITKnCq0XSdu1t2e2NyOyjw1MuRadJ fnGxE/1BYLAyDOBARFaKQz6L32F8pTfwZkc4qectpxU2fTp5rF4Z+TgFxujM02oE9n56 R3J0E15qtHdYX12GLFlp+zBA+aUwzseiZuwJadHFWEM8n4pPhavBVzFeR3slldo3mBbY upcOlbPsDNTMN/sCNOEgk6QNrrjyrnEB9lZE72LDQUb+W5r8waxYWk0bkVMSXzD8Ajwh jkTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751459103; x=1752063903; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=d2/Oz6A0ZcrKaCz3NC9OtHbxQaQqo8pmpupCjGRpV8w=; b=KwrZ4Om9C+JaqwtkIC23GdztG1BCikeF9sQBZUM0uBGl+hXLmAOAXvm20cGSXqhsSp zvtsHQ2lPiC5o2VlMCKQqrhWPi3+DxRuebqWJasZktnK2AxDGlhe3SfK1uA9k9if36Bz Ekq89fBaybwV9J6KRYkJVHq0n9kYYBsj0n3VkdN1nmYNNpJ/UiHhJi+LR5B4sVS2N8+4 KTH7OlIY0unG//OUuAi5badm/ZIajmfum9JRvV7W9DxMAFrIFypFGPrRy7P35ey4Oqyt eTRpcKeA9tnnzmpkW88Rk1uzl/Y8ADipCYmZJWWMyjEozNC3IHbhOwoHKSxZQxbH5Fwi vZWg== X-Forwarded-Encrypted: i=1; AJvYcCWFmeQXGuX28CI9uE7aAHA1DvD0a92uzD3gkpGeugMw7eGSGCWzykuAv3MnjmxNyRbM1UGNe75BQi0=@vger.kernel.org X-Gm-Message-State: AOJu0YxijlN5gJ3UTqzrA20gzYR1OBjMNSpuwznF+UqEPkMPZSgO3t6V jSh28jEwQUTVHC2LuSlTNkV4AT2pNbLFx0RRZkJqCBlibK1cEvmhIeTOaVi96xBKNxE= X-Gm-Gg: ASbGncvgZSmEs+mz2ho2+Zc5OysEMT0SFNA6z3osSKjJWgpc0H+WTjNJQuWTZNjN/oF KVmiRdRVS+TGBEvZoQG/hsCo721XEre4OPbhbQL/fihQwGgNQ2omq354xrhYWpdm1Fec9QBaHqA S3fTwH9kM7D8lCO56k10jHgRx1Z4Xi2I3ILB8Sw6ots1reRxMakLLXFadWrZfzp0KkcSZc8M3oJ ofmQTZ1tlc3iWjSWMEL3ZEvvEEH1OriBO/xqCOpz9+D38xc+5FKpWyhETMLMA89fS5CVdB0Tus9 vVn+dgMj0LdaVFFwOJ/4R3d9pRjf3TQwSenuJoTZCZhoX2NpEfUO+1cLJFXySuXf0gYjHqoVu99 GoJpBZ+3XRpN/RqTGDtI= X-Google-Smtp-Source: AGHT+IFIlXXlzsuMFgHtCxyhdIuOG14wM/hhcIz6P+W+5GsHULhVeQI6sehkPkzz7x0xAIuoLbb44w== X-Received: by 2002:a17:902:ccd0:b0:235:ed02:288b with SMTP id d9443c01a7336-23c6e552cacmr40153115ad.30.1751459103084; Wed, 02 Jul 2025 05:25:03 -0700 (PDT) Received: from localhost.localdomain ([122.171.22.240]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23acb2e1b49sm131147265ad.22.2025.07.02.05.24.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jul 2025 05:25:02 -0700 (PDT) From: Anup Patel To: Jonathan Corbet , Thomas Gleixner Cc: Anup Patel , Atish Patra , Palmer Dabbelt , Paul Walmsley , Alexandre Ghiti , Andrew Jones , linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel Subject: [PATCH v3] irqchip/riscv-imsic: Add kernel parameter to disable IPIs Date: Wed, 2 Jul 2025 17:54:34 +0530 Message-ID: <20250702122434.1514328-1-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When injecting IPIs to a set of harts, the IMSIC IPI support will do a separate MMIO write to the SETIPNUM_LE register of each target hart. This means on a platform where IMSIC is trap-n-emulated, there will be N MMIO traps when injecting IPI to N target harts hence IMSIC IPIs will be slow on such platform compared to the SBI IPI extension. Unfortunately, there is no DT, ACPI, or any other way of discovering whether the underlying IMSIC is trap-n-emulated. Using MMIO write to the SETIPNUM_LE register for injecting IPI is purely a software choice in the IMSIC driver hence add a kernel parameter to allow users disable IMSIC IPIs on platforms with trap-n-emulated IMSIC. Signed-off-by: Anup Patel --- Changes since v2: - Skip enabling/disabling IMSIC_IPI_ID in imsic_ipi_starting_cpu() and imsic_ipi_dying_cpu() when imsic_noipi is set - Re-use the reserved IPI ID for devices when imsic_noipi is set Changes since v1: - Added more details to patch description --- .../admin-guide/kernel-parameters.txt | 7 +++++++ drivers/irqchip/irq-riscv-imsic-early.c | 20 ++++++++++++++++++- drivers/irqchip/irq-riscv-imsic-state.c | 7 ++++--- drivers/irqchip/irq-riscv-imsic-state.h | 1 + 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index f1f2c0874da9..7f0e12d0d260 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2538,6 +2538,13 @@ requires the kernel to be built with CONFIG_ARM64_PSEUDO_NMI. + irqchip.riscv_imsic_noipi + [RISC-V,EARLY] + Force the kernel to not use IMSIC software injected MSIs + as IPIs. Intended for system where IMSIC is trap-n-emulated, + and thus want to reduce MMIO traps when triggering IPIs + to multiple harts. + irqfixup [HW] When an interrupt is not handled search all handlers for it. Intended to get systems with badly broken diff --git a/drivers/irqchip/irq-riscv-imsic-early.c b/drivers/irqchip/irq-riscv-imsic-early.c index 1dbc41d7fe80..7e71f41c0d46 100644 --- a/drivers/irqchip/irq-riscv-imsic-early.c +++ b/drivers/irqchip/irq-riscv-imsic-early.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,14 @@ #include "irq-riscv-imsic-state.h" static int imsic_parent_irq; +bool imsic_noipi; + +static int __init imsic_noipi_cfg(char *buf) +{ + imsic_noipi = true; + return 0; +} +early_param("irqchip.riscv_imsic_noipi", imsic_noipi_cfg); #ifdef CONFIG_SMP static void imsic_ipi_send(unsigned int cpu) @@ -33,12 +42,18 @@ static void imsic_ipi_send(unsigned int cpu) static void imsic_ipi_starting_cpu(void) { + if (imsic_noipi) + return; + /* Enable IPIs for current CPU. */ __imsic_id_set_enable(IMSIC_IPI_ID); } static void imsic_ipi_dying_cpu(void) { + if (imsic_noipi) + return; + /* Disable IPIs for current CPU. */ __imsic_id_clear_enable(IMSIC_IPI_ID); } @@ -47,6 +62,9 @@ static int __init imsic_ipi_domain_init(void) { int virq; + if (imsic_noipi) + return 0; + /* Create IMSIC IPI multiplexing */ virq = ipi_mux_create(IMSIC_NR_IPI, imsic_ipi_send); if (virq <= 0) @@ -89,7 +107,7 @@ static void imsic_handle_irq(struct irq_desc *desc) while ((local_id = csr_swap(CSR_TOPEI, 0))) { local_id >>= TOPEI_ID_SHIFT; - if (local_id == IMSIC_IPI_ID) { + if (!imsic_noipi && local_id == IMSIC_IPI_ID) { if (IS_ENABLED(CONFIG_SMP)) ipi_mux_process(); continue; diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-riscv-imsic-state.c index 77670dd645ac..dc95ad856d80 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.c +++ b/drivers/irqchip/irq-riscv-imsic-state.c @@ -134,7 +134,7 @@ static bool __imsic_local_sync(struct imsic_local_priv *lpriv) lockdep_assert_held(&lpriv->lock); for_each_set_bit(i, lpriv->dirty_bitmap, imsic->global.nr_ids + 1) { - if (!i || i == IMSIC_IPI_ID) + if (!i || (!imsic_noipi && i == IMSIC_IPI_ID)) goto skip; vec = &lpriv->vectors[i]; @@ -419,7 +419,7 @@ void imsic_vector_debug_show(struct seq_file *m, struct imsic_vector *vec, int i seq_printf(m, "%*starget_cpu : %5u\n", ind, "", vec->cpu); seq_printf(m, "%*starget_local_id : %5u\n", ind, "", vec->local_id); seq_printf(m, "%*sis_reserved : %5u\n", ind, "", - (vec->local_id <= IMSIC_IPI_ID) ? 1 : 0); + (!imsic_noipi && vec->local_id <= IMSIC_IPI_ID) ? 1 : 0); seq_printf(m, "%*sis_enabled : %5u\n", ind, "", is_enabled ? 1 : 0); seq_printf(m, "%*sis_move_pending : %5u\n", ind, "", mvec ? 1 : 0); if (mvec) { @@ -583,7 +583,8 @@ static int __init imsic_matrix_init(void) irq_matrix_assign_system(imsic->matrix, 0, false); /* Reserve IPI ID because it is special and used internally */ - irq_matrix_assign_system(imsic->matrix, IMSIC_IPI_ID, false); + if (!imsic_noipi) + irq_matrix_assign_system(imsic->matrix, IMSIC_IPI_ID, false); return 0; } diff --git a/drivers/irqchip/irq-riscv-imsic-state.h b/drivers/irqchip/irq-riscv-imsic-state.h index 3202ffa4e849..57f951952b0c 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.h +++ b/drivers/irqchip/irq-riscv-imsic-state.h @@ -61,6 +61,7 @@ struct imsic_priv { struct irq_domain *base_domain; }; +extern bool imsic_noipi; extern struct imsic_priv *imsic; void __imsic_eix_update(unsigned long base_id, unsigned long num_id, bool pend, bool val); -- 2.43.0