From patchwork Sun Feb 9 04:16:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13966632 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9697FC02199 for ; Sun, 9 Feb 2025 04:20:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2YG8nvKzX+4u0NuCuwmhLP+2BJ9iTaveZFvuVOPUbm8=; b=UfQlj62iaEY9RU Q3N2nCXYPauhP2UGmkkS3UlFWVTm8uuCtLegfC0yhDX44k8pIsPhtWhuRwK8oODva1lJdMpZO73s1 sPYsqC8IOxo+hi9PmOJmEk9aTR3JDNahB11OR2T6/VqNr4mDlz4yivPw6DWS5doDs2YzC/27kUfy+ +bYTYYg7JHFrQ/HgXKA7oj+Wme0uqTgUNVWQTQ+whtK5m5I8PSoouWYAWmpMdRUI39WTJNvdEhuom 8zS8Hvtap+ARmf19EvvzzhtdALcnasxc8EkbOZsM0Vq5xA0n/Zovatt8VUZ0bBXKVcY8qbIZxoN7y wtgopPAWsLQFmz1520AA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tgyng-0000000E33U-1e40; Sun, 09 Feb 2025 04:20:08 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tgyl1-0000000E2H0-0J07 for linux-riscv@lists.infradead.org; Sun, 09 Feb 2025 04:17:24 +0000 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-2f9ba87f5d4so4708275a91.3 for ; Sat, 08 Feb 2025 20:17:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1739074642; x=1739679442; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DvFsqgBHoepkWBjGC1yP+KOn/8qryanxa+3zb4U83Ao=; b=ZhA1QhQF6RbBN70YHFPxplw9pQyOyDyCcHQUzrRG1Zq75CgTyYW7SIi/4ql2bVxHc9 jBoStP4eaHWs39I/UVCQtuQVNIHnrMIOUTfsL0iGE8lBnYq7fIsttOQVVrsFLLSEt1bf KGu4NDFdsC74RMNu7SlzW3FKdShCpytmvU0pvTje0gLo5cYALvN/dbmT4NI4RMlv+M7g Cg8Ua81FkQRUIOAVcBeCIzIryR3yIVzOO+HIaQg9T7oYh6Up8PK1jghvoU7GgPIL2ECL xGStANAxnPwh5obYJy2QW/6rhrCJn0ueL1Ug6TsQYM2ieVyR3U3ymgowu1n4cEXAgtgB uedA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739074642; x=1739679442; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DvFsqgBHoepkWBjGC1yP+KOn/8qryanxa+3zb4U83Ao=; b=sCbc540a5PNrMyKctjHiUDrcrSeirLTcBd9iUC5HBYOeQMuDOJiD+E2wt8bFZ3vMnV qVTWWvPmhd7CDh/8cJPDwPkxYOgPmZtfV8crMLj4D4QrLrb6RixgBXt+CqKZLShfYIlT zOw+jMnM/GuwruJMbDPRABewRxIgwGB7Rb1hrP1hxQbJ2nB/OG7XRO9LpwYu5rurCY54 xUZfLLaeixXDKCaE7B6X8lMyV/jxr2jcM5eroxAHondwzFLzOHMUyYe5UEiKCi/D98UM gU8Mkp8ahMSTR++K1DQQHiEoG/o08ynW7CGjvJFmqzblMw1i/T1fMwmoCjLlUJ6mr3Ql p68A== X-Forwarded-Encrypted: i=1; AJvYcCUZ7IDNfWLgWw7XT8SclAsfUl6Bahpp0dv+FsGrHwbZKTfj8gaVOFwhYzH4QkhfAxyD9Gj78tb5Nm2GPA==@lists.infradead.org X-Gm-Message-State: AOJu0YyeXM3xiIrcMZEMf56EZgsPpgAi/VH5Rr6wGhepgdwt2Pob1kEe peuwJPJSZxOiAFX9F9J44iLb0gxeT/vYEMWp7OoQywsy9fs1ifbg5y49g04bf+A= X-Gm-Gg: ASbGncsbY3UrKdxrqKcpCfzoUanvS33a8iIxCheczW03zY9Rhbe1rza7WUtAzyeMs7G 1sFeo28mXv1MPiBcBL9x9wFX193G4MbsBA01KOfyQPTaw6wWHHJM5ZPQ0iaFlnRjhrtpDtQ03tN 8XiRSNb4R++i8JwvlI2hfBAQD68G3l7Md9tcp1DznkWifVh7mwEvfEQ/zMvNSWup6Q8xZFpEGmX whcNgUty8ECzSJ3Erawj0OK9f5x+tu5hZyhV4DhtlScOrz3B4cIJ2Fun/XxZwPLoxz2LZgH0Fiu 16hnJqG0FYFL4QWHLNxgdIOAHgaV5Xzmo9BbP5vXUx4bnXM+mMTMI/8= X-Google-Smtp-Source: AGHT+IHRXdIPs1mvVVeCpBykzAl+ifFcG5qlvMFYrTkFKgREylWnQV7fAuN/+eShJoWgxmV452gK/Q== X-Received: by 2002:a05:6a00:b41:b0:730:8a0a:9f06 with SMTP id d2e1a72fcca58-7308a0aad32mr287596b3a.16.1739074642169; Sat, 08 Feb 2025 20:17:22 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73073eba116sm1898410b3a.124.2025.02.08.20.17.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Feb 2025 20:17:21 -0800 (PST) From: Anup Patel To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Subject: [PATCH v5 01/11] irqchip/riscv-imsic: Set irq_set_affinity for IMSIC base Date: Sun, 9 Feb 2025 09:46:45 +0530 Message-ID: <20250209041655.331470-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250209041655.331470-1-apatel@ventanamicro.com> References: <20250209041655.331470-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250208_201723_263222_8F23E36E X-CRM114-Status: GOOD ( 12.70 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , Atish Patra , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Paul Walmsley , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , hpa@zytor.com, Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Andrew Jones Instead of using imsic_irq_set_affinity() for leaf MSI domains, use imsic_irq_set_affinity() for the non-leaf IMSIC base domain and use irq_chip_set_affinity_parent() for leaf MSI domains. Signed-off-by: Andrew Jones Signed-off-by: Anup Patel --- drivers/irqchip/irq-riscv-imsic-platform.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c index c708780e8760..5d7c30ad8855 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -96,9 +96,8 @@ static int imsic_irq_set_affinity(struct irq_data *d, const struct cpumask *mask bool force) { struct imsic_vector *old_vec, *new_vec; - struct irq_data *pd = d->parent_data; - old_vec = irq_data_get_irq_chip_data(pd); + old_vec = irq_data_get_irq_chip_data(d); if (WARN_ON(!old_vec)) return -ENOENT; @@ -116,13 +115,13 @@ static int imsic_irq_set_affinity(struct irq_data *d, const struct cpumask *mask return -ENOSPC; /* Point device to the new vector */ - imsic_msi_update_msg(d, new_vec); + imsic_msi_update_msg(irq_get_irq_data(d->irq), new_vec); /* Update irq descriptors with the new vector */ - pd->chip_data = new_vec; + d->chip_data = new_vec; - /* Update effective affinity of parent irq data */ - irq_data_update_effective_affinity(pd, cpumask_of(new_vec->cpu)); + /* Update effective affinity */ + irq_data_update_effective_affinity(d, cpumask_of(new_vec->cpu)); /* Move state of the old vector to the new vector */ imsic_vector_move(old_vec, new_vec); @@ -135,6 +134,9 @@ static struct irq_chip imsic_irq_base_chip = { .name = "IMSIC", .irq_mask = imsic_irq_mask, .irq_unmask = imsic_irq_unmask, +#ifdef CONFIG_SMP + .irq_set_affinity = imsic_irq_set_affinity, +#endif .irq_retrigger = imsic_irq_retrigger, .irq_compose_msi_msg = imsic_irq_compose_msg, .flags = IRQCHIP_SKIP_SET_WAKE | @@ -245,7 +247,7 @@ static bool imsic_init_dev_msi_info(struct device *dev, if (WARN_ON_ONCE(domain != real_parent)) return false; #ifdef CONFIG_SMP - info->chip->irq_set_affinity = imsic_irq_set_affinity; + info->chip->irq_set_affinity = irq_chip_set_affinity_parent; #endif break; default: From patchwork Sun Feb 9 04:16:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13966634 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 58470C02199 for ; Sun, 9 Feb 2025 04:21:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WlZP8SZYetYktHDMy89E58QpaLzD7a5abBH6Ap8cJUQ=; b=JZJ2fXZqolslFs vsOy5r51w5+JPX4UR8hSs3YUMZodT3nf5Ebj+yu2EEbEFiFgSXQ+NTZG8yUWPS4Ah7xr/ayD4emDv aiLVUG8sYpI4cg/YNle4Rt3WxP5wR+A5HJa0/VOF4gyFozFy80IZoTEn9XTo5KO0YSV3hFk9r8/cZ BLq+Ozwrk+wJfvOxX6VdmiibdixzMegx7iqaGdIGsmSnfbQf6MP1PM7vKV4sPQLhc95ChSQvch1cB OTj1IC6MpUjC21LRxp5qa+wybwqpQIBl+5GgYV285XO28BatH+evr1rr1mXUTzgLx651Pc3EWG/jy JuVLNqdgugcNiuUIEv0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tgyp2-0000000E3Fh-2l5c; Sun, 09 Feb 2025 04:21:32 +0000 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tgyl9-0000000E2K5-2rOk for linux-riscv@lists.infradead.org; Sun, 09 Feb 2025 04:17:32 +0000 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-2fa44590eebso1822228a91.3 for ; Sat, 08 Feb 2025 20:17:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1739074651; x=1739679451; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dDa5uVtGTmKoF+EGxYZ14lQBrXBy+Zgm46G016g9yok=; b=OC6WOEOI6P393eaTXBXRGTPIDJ49XDZsrAlE43coLCU+uCTk7LhUpBGpoe1QJ653nO 0JdgH/z0q8Ei64fhhj4RnC257Q7j7SuTbAW+otzjnZOTI01nuShezbOqszx44YdMF2WD XyY8kjSBLj9e1O16fIFiJ2pVfxc5eUwyzvzgZBAtBlFCQq6Mbp3UCAn/giUKG4RnwbeF 778rChqeGXmtfTBmP5VS3f3kYDv+SruGjLlnRdSHcJdNRCQcEbOZ5fUcCLcjuPI9h3YK mCMMGD2l69UNoW6b2F9aIrWk6FGw6/EXTlYj9JEvI+4Cai4AzcymOOLx/3j3B3y/B0I8 gP0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739074651; x=1739679451; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dDa5uVtGTmKoF+EGxYZ14lQBrXBy+Zgm46G016g9yok=; b=aDXiAmmKudz7QaLg0nVz0NVBZDssFx8u3KeuxuOOTsvi7xGiXMlo5O14nQonFx0wqm zJt6xDrUsBZ1+tZsW/9zCvv0b5H7DbKUT9daKlDc/olqp/9N/Mgz+3tFDPRP9ZJLqz0E 8w4MG0hmOXORagos0ySq/ffYtFm95E0wICQF4ZjBu4IRLZHCcAezdknYALf7XOBing9d G8F2+z2FEBKbvzUn/Yclm86vWyujRZPbaJrewB4OqFTojHPtd1SvpastNohKYV5KtZWy 7lWkjpC7F4YsNk5C+vhXxSZQH1raH7hN4+dxPiDOhmBhVbZNRWWCu5cpPq/5mkcfTYLX +juQ== X-Forwarded-Encrypted: i=1; AJvYcCW8wNGoCF6UmfAYGUcUCT/ob3swiArw6S5mTN0qxPAxYN9lQPGUGU8G4sXsxrrr25pAEXEz0pUWCQHomQ==@lists.infradead.org X-Gm-Message-State: AOJu0Yx4GwZqKTwgr/+PR+oS7/pbA5NHqxP5afoQQk+UbT4t82h4gLbU bv7fSHCyaxBYZfJtakUSRXma0Msun327HQxKkkj95rjnNikRItige5/Ik+ZOB8k= X-Gm-Gg: ASbGnctG4zWWgcJjGO4AymhiEnwppjiVQYiQbX6ANaS+grrq+Liah2ENIIwspZDAQCH xqM6bg+/QGeVrZhC4zePTpUIKfdbHovn7zVjog6mKUe2b94ZRJozQ6PiiSq3W5mJy926QW6+Olk OUI/stv0HCe+wxbG9jeVMoElPVXgzW+U7chD/8OqwPHBA6YYhu8B5tESpOR2QDhijMJpoHjKCWX 1Z9BiAyqdhn2oLGAqNbaTmyNlwuASR6dn8QWVFUkd8Iiu55qJdTZQ11Epnn6k4sBEFQGO9zPahr w5i3CQHrkAfvZPShxVdCO7RHQJ8m8u2OjSlnZwvZlYT9CcttnnZsHs0= X-Google-Smtp-Source: AGHT+IG1pX64iVcHBvRjhghD+pT2OaoFkAmw6b8bnet5SDDEvBV2yIiEcMLZqESX2yxzwT//jElybA== X-Received: by 2002:a05:6a00:cd1:b0:725:e444:2505 with SMTP id d2e1a72fcca58-7305d431970mr12792467b3a.4.1739074650717; Sat, 08 Feb 2025 20:17:30 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73073eba116sm1898410b3a.124.2025.02.08.20.17.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Feb 2025 20:17:30 -0800 (PST) From: Anup Patel To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Subject: [PATCH v5 02/11] irqchip/irq-msi-lib: Optionally set default irq_eoi/irq_ack Date: Sun, 9 Feb 2025 09:46:46 +0530 Message-ID: <20250209041655.331470-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250209041655.331470-1-apatel@ventanamicro.com> References: <20250209041655.331470-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250208_201731_712120_75DAE0AF X-CRM114-Status: GOOD ( 16.83 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , Atish Patra , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Paul Walmsley , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , hpa@zytor.com, Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Thomas Gleixner Introduce chip_flags in struct msi_parent_ops. This allows msi_lib_init_dev_msi_info() set default irq_eoi/irq_ack callbacks only when the corresponding flags are set in the chip_flags. Signed-off-by: Thomas Gleixner Signed-off-by: Anup Patel --- drivers/irqchip/irq-gic-v2m.c | 1 + drivers/irqchip/irq-imx-mu-msi.c | 1 + drivers/irqchip/irq-msi-lib.c | 11 ++++++----- drivers/irqchip/irq-mvebu-gicp.c | 1 + drivers/irqchip/irq-mvebu-odmi.c | 1 + drivers/irqchip/irq-mvebu-sei.c | 1 + include/linux/msi.h | 11 +++++++++++ 7 files changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index be35c5349986..1e3476c335ca 100644 --- a/drivers/irqchip/irq-gic-v2m.c +++ b/drivers/irqchip/irq-gic-v2m.c @@ -255,6 +255,7 @@ static void __init gicv2m_teardown(void) static struct msi_parent_ops gicv2m_msi_parent_ops = { .supported_flags = GICV2M_MSI_FLAGS_SUPPORTED, .required_flags = GICV2M_MSI_FLAGS_REQUIRED, + .chip_flags = MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_token = DOMAIN_BUS_NEXUS, .bus_select_mask = MATCH_PCI_MSI | MATCH_PLATFORM_MSI, .prefix = "GICv2m-", diff --git a/drivers/irqchip/irq-imx-mu-msi.c b/drivers/irqchip/irq-imx-mu-msi.c index 4342a21de1eb..69aacdfc8bef 100644 --- a/drivers/irqchip/irq-imx-mu-msi.c +++ b/drivers/irqchip/irq-imx-mu-msi.c @@ -214,6 +214,7 @@ static void imx_mu_msi_irq_handler(struct irq_desc *desc) static const struct msi_parent_ops imx_mu_msi_parent_ops = { .supported_flags = IMX_MU_MSI_FLAGS_SUPPORTED, .required_flags = IMX_MU_MSI_FLAGS_REQUIRED, + .chip_flags = MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_token = DOMAIN_BUS_NEXUS, .bus_select_mask = MATCH_PLATFORM_MSI, .prefix = "MU-MSI-", diff --git a/drivers/irqchip/irq-msi-lib.c b/drivers/irqchip/irq-msi-lib.c index d8e29fc0d406..51464c6257f3 100644 --- a/drivers/irqchip/irq-msi-lib.c +++ b/drivers/irqchip/irq-msi-lib.c @@ -28,6 +28,7 @@ bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain, struct msi_domain_info *info) { const struct msi_parent_ops *pops = real_parent->msi_parent_ops; + struct irq_chip *chip = info->chip; u32 required_flags; /* Parent ops available? */ @@ -92,10 +93,10 @@ bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain, info->flags |= required_flags; /* Chip updates for all child bus types */ - if (!info->chip->irq_eoi) - info->chip->irq_eoi = irq_chip_eoi_parent; - if (!info->chip->irq_ack) - info->chip->irq_ack = irq_chip_ack_parent; + if (!chip->irq_eoi && (pops->chip_flags & MSI_CHIP_FLAG_SET_EOI)) + chip->irq_eoi = irq_chip_eoi_parent; + if (!chip->irq_ack && (pops->chip_flags & MSI_CHIP_FLAG_SET_ACK)) + chip->irq_ack = irq_chip_ack_parent; /* * The device MSI domain can never have a set affinity callback. It @@ -105,7 +106,7 @@ bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain, * device MSI domain aside of mask/unmask which is provided e.g. by * PCI/MSI device domains. */ - info->chip->irq_set_affinity = msi_domain_set_affinity; + chip->irq_set_affinity = msi_domain_set_affinity; return true; } EXPORT_SYMBOL_GPL(msi_lib_init_dev_msi_info); diff --git a/drivers/irqchip/irq-mvebu-gicp.c b/drivers/irqchip/irq-mvebu-gicp.c index 2b6183919ea4..d67f93f6d750 100644 --- a/drivers/irqchip/irq-mvebu-gicp.c +++ b/drivers/irqchip/irq-mvebu-gicp.c @@ -161,6 +161,7 @@ static const struct irq_domain_ops gicp_domain_ops = { static const struct msi_parent_ops gicp_msi_parent_ops = { .supported_flags = GICP_MSI_FLAGS_SUPPORTED, .required_flags = GICP_MSI_FLAGS_REQUIRED, + .chip_flags = MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_token = DOMAIN_BUS_GENERIC_MSI, .bus_select_mask = MATCH_PLATFORM_MSI, .prefix = "GICP-", diff --git a/drivers/irqchip/irq-mvebu-odmi.c b/drivers/irqchip/irq-mvebu-odmi.c index ff19bfd258dc..28f7e81df94f 100644 --- a/drivers/irqchip/irq-mvebu-odmi.c +++ b/drivers/irqchip/irq-mvebu-odmi.c @@ -157,6 +157,7 @@ static const struct irq_domain_ops odmi_domain_ops = { static const struct msi_parent_ops odmi_msi_parent_ops = { .supported_flags = ODMI_MSI_FLAGS_SUPPORTED, .required_flags = ODMI_MSI_FLAGS_REQUIRED, + .chip_flags = MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_token = DOMAIN_BUS_GENERIC_MSI, .bus_select_mask = MATCH_PLATFORM_MSI, .prefix = "ODMI-", diff --git a/drivers/irqchip/irq-mvebu-sei.c b/drivers/irqchip/irq-mvebu-sei.c index 065166ab5dbc..ebd4a9014e8d 100644 --- a/drivers/irqchip/irq-mvebu-sei.c +++ b/drivers/irqchip/irq-mvebu-sei.c @@ -356,6 +356,7 @@ static void mvebu_sei_reset(struct mvebu_sei *sei) static const struct msi_parent_ops sei_msi_parent_ops = { .supported_flags = SEI_MSI_FLAGS_SUPPORTED, .required_flags = SEI_MSI_FLAGS_REQUIRED, + .chip_flags = MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_mask = MATCH_PLATFORM_MSI, .bus_select_token = DOMAIN_BUS_GENERIC_MSI, .prefix = "SEI-", diff --git a/include/linux/msi.h b/include/linux/msi.h index b10093c4d00e..9abef442c146 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -558,11 +558,21 @@ enum { MSI_FLAG_NO_AFFINITY = (1 << 21), }; +/* + * Flags for msi_parent_ops::chip_flags + */ +enum { + MSI_CHIP_FLAG_SET_EOI = (1 << 0), + MSI_CHIP_FLAG_SET_ACK = (1 << 1), +}; + /** * struct msi_parent_ops - MSI parent domain callbacks and configuration info * * @supported_flags: Required: The supported MSI flags of the parent domain * @required_flags: Optional: The required MSI flags of the parent MSI domain + * @chip_flags: Optional: Select MSI chip callbacks to update with defaults + * in msi_lib_init_dev_msi_info(). * @bus_select_token: Optional: The bus token of the real parent domain for * irq_domain::select() * @bus_select_mask: Optional: A mask of supported BUS_DOMAINs for @@ -575,6 +585,7 @@ enum { struct msi_parent_ops { u32 supported_flags; u32 required_flags; + u32 chip_flags; u32 bus_select_token; u32 bus_select_mask; const char *prefix; From patchwork Sun Feb 9 04:16:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13966633 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7C947C021A0 for ; Sun, 9 Feb 2025 04:21:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LOfkU+YQxegZ5CJGoO3JIFcxZ8EEupED4WM5kBBHd3U=; b=ifjywOBlN7gK8g CKCSA774RZj+pIEhtQnxbxvVcUIiqoCFDn9+gB0YeX9a+pq6EZclPMh6/hDT4HncmKTYGfm1eVjJQ MW/5l14khTvO/DlUkgU6tw53W5YxtkQtgjX6rS+OB3jabn+PFUDTrrp284jYfZDAneg9oSulOOcgG XrP0AGQOdq0eFH6Vg/fmOfLG+K8Iiyzm2AaY+ruqWzXZMavsix8vC9lw7TnthKAVh86NMwbYvNWxV T2n2EH4wo5NE9coQLh/z0qedTV5IoeXF+f8N5LI/0JG6zMb5A4lmtXYiffr9WvdWBQheDrjyJT6SQ BtPupng4reZmMsH0g/Lg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tgyp3-0000000E3G1-11kW; Sun, 09 Feb 2025 04:21:33 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tgylI-0000000E2Ng-1Wnq for linux-riscv@lists.infradead.org; Sun, 09 Feb 2025 04:17:41 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-21f3c119fe6so71873585ad.0 for ; Sat, 08 Feb 2025 20:17:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1739074659; x=1739679459; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=byPW6bNJR29pmHM6qNzPiiUHTFPpVNBWTNf2HlLXfG4=; b=XB70fzpmLxHJQMIwdTzyY4ZxIlL84Ppk/QbOktOpmYC57Q9vEcbjdI30QCnsIoiyNU InevfyS60FdRDF5yBVfq5ndhaQZTVj2CBFprlpGzoNqnYfWt9mkwbnsrZvisB0UlE0kR rbUzQSZQNGFdO5MZFXEbgnvDSzPPbnECOqKfLVfqxfY2zZSQrGQrt+ihOlLzuio3+7W6 GKJuI/EnJcPwI1ad3jgk1BG1UWnFB0bZVvTeD3kB80MZiQgIY+B5tHc0AaHIBZpR7VA8 Huxp4y42yL4iHS0PH5NRLqDMlcgQY7f6moeb5So4LGkAHU8dRA/M+SpI9PPaZ1RghFCu t71Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739074659; x=1739679459; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=byPW6bNJR29pmHM6qNzPiiUHTFPpVNBWTNf2HlLXfG4=; b=Mx+HHAJkoz1kTem5aDKKfHw6n1Mu93PAUC2iTNcnJN6lKZJ1Hw3e6QPFrt1In65RLK mdMMPkg0uGKPQ41O76YZvmjOGjux7vPmkpStZL3WtqbiqyASL8HnWZkUF9+LOdu4TToY +Xz8EfNX9BeAqxEPoDmAV04Ww+StzIQomzbXSdlgIR16f1FvBzF9gHyu9ZiZ25PN8qxJ laTJsJ2vx8sAQN3AL6L3DdaXMbm+5I984SkTcTbDuF5aolO8KLneXLIKsrol9OMYABpV k4bzgZ308g+u9u3V/xH/9MxrpBvRwYQBmkR14MrPe/9Es3zvsg6pcueqFEdSrz6mbvFh 6mQg== X-Forwarded-Encrypted: i=1; AJvYcCWQXM/uDvsVssI0+JcGPDC2MicXTvyKiEwSOEkc+0K9W5mHNhWOS2tt9eQzRvkLAVqeAKla8m2nmUlYgQ==@lists.infradead.org X-Gm-Message-State: AOJu0Yy0lVtJ01gOnGSkY7AcpBPUDx5167lkBbb4fAaNSsnmZ29gjJ6+ FnwT5W2zMAcC4MtEsjkOJ/cnTMLbXG7EjtvF3f9cEXl8I8mTrtdeLBGDaSaCg90= X-Gm-Gg: ASbGncsNgOiZV8xHUFsjfKmsJB31IwxGB/wV8jsszl4Zx452wiBP8oZXZwsAB7cOx/a zG+iZkA7Ea2tI2kxOt9SxCQQTthlPDdQJePVuMmDoaBM8LL0tuTLbYNowZ/1SwvgYtSTg4IFS4B iSEH+w77zoq5JJcECmLkcuZIOcOz7YxQlkLAYg/TaQkd4JAxsBxuZUWzX6+CbpDWJ0OigzU0tnZ pM6DHVtQk9dLorUqkG588UvkkOitl6xbui4d5Z40xJjtD92+loBQopYZPx4pxRU0XGIcr9mMQTm FiQIe/g8VB8ov731l9TKhKY3Ojcc3xB0tD23+rnxBxq9JR9zRRSRS7Y= X-Google-Smtp-Source: AGHT+IH/ik3Ur8iKEEYDe9Hd4WVhXmYUsHE6OOkf8RhOk/pD00c5WvEJC3c0LK+040dao0sK2cXHKQ== X-Received: by 2002:a05:6a20:c6c6:b0:1db:dfc0:d342 with SMTP id adf61e73a8af0-1ee03a247admr16710991637.7.1739074659234; Sat, 08 Feb 2025 20:17:39 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73073eba116sm1898410b3a.124.2025.02.08.20.17.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Feb 2025 20:17:38 -0800 (PST) From: Anup Patel To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Subject: [PATCH v5 03/11] irqchip/riscv-imsic: Move to common MSI lib Date: Sun, 9 Feb 2025 09:46:47 +0530 Message-ID: <20250209041655.331470-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250209041655.331470-1-apatel@ventanamicro.com> References: <20250209041655.331470-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250208_201740_517024_71F40DD2 X-CRM114-Status: GOOD ( 16.47 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , Atish Patra , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Paul Walmsley , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , hpa@zytor.com, Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Thomas Gleixner Simplify the leaf MSI domain handling in the RISC-V IMSIC driver by using msi_lib_init_dev_msi_info() and msi_lib_irq_domain_select() provided by common MSI lib. Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Jones Signed-off-by: Anup Patel --- drivers/irqchip/Kconfig | 8 +- drivers/irqchip/irq-riscv-imsic-platform.c | 114 +-------------------- 2 files changed, 6 insertions(+), 116 deletions(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index be063bfb50c4..bc3f12af2dc7 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -589,13 +589,7 @@ config RISCV_IMSIC select IRQ_DOMAIN_HIERARCHY select GENERIC_IRQ_MATRIX_ALLOCATOR select GENERIC_MSI_IRQ - -config RISCV_IMSIC_PCI - bool - depends on RISCV_IMSIC - depends on PCI - depends on PCI_MSI - default RISCV_IMSIC + select IRQ_MSI_LIB config SIFIVE_PLIC bool diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c index 5d7c30ad8855..9a5e7b4541f6 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -20,6 +20,7 @@ #include #include +#include "irq-msi-lib.h" #include "irq-riscv-imsic-state.h" static bool imsic_cpu_page_phys(unsigned int cpu, unsigned int guest_index, @@ -174,22 +175,6 @@ static void imsic_irq_domain_free(struct irq_domain *domain, unsigned int virq, irq_domain_free_irqs_parent(domain, virq, nr_irqs); } -static int imsic_irq_domain_select(struct irq_domain *domain, struct irq_fwspec *fwspec, - enum irq_domain_bus_token bus_token) -{ - const struct msi_parent_ops *ops = domain->msi_parent_ops; - u32 busmask = BIT(bus_token); - - if (fwspec->fwnode != domain->fwnode || fwspec->param_count != 0) - return 0; - - /* Handle pure domain searches */ - if (bus_token == ops->bus_select_token) - return 1; - - return !!(ops->bus_select_mask & busmask); -} - #ifdef CONFIG_GENERIC_IRQ_DEBUGFS static void imsic_irq_debug_show(struct seq_file *m, struct irq_domain *d, struct irq_data *irqd, int ind) @@ -206,110 +191,21 @@ static void imsic_irq_debug_show(struct seq_file *m, struct irq_domain *d, static const struct irq_domain_ops imsic_base_domain_ops = { .alloc = imsic_irq_domain_alloc, .free = imsic_irq_domain_free, - .select = imsic_irq_domain_select, + .select = msi_lib_irq_domain_select, #ifdef CONFIG_GENERIC_IRQ_DEBUGFS .debug_show = imsic_irq_debug_show, #endif }; -#ifdef CONFIG_RISCV_IMSIC_PCI - -static void imsic_pci_mask_irq(struct irq_data *d) -{ - pci_msi_mask_irq(d); - irq_chip_mask_parent(d); -} - -static void imsic_pci_unmask_irq(struct irq_data *d) -{ - irq_chip_unmask_parent(d); - pci_msi_unmask_irq(d); -} - -#define MATCH_PCI_MSI BIT(DOMAIN_BUS_PCI_MSI) - -#else - -#define MATCH_PCI_MSI 0 - -#endif - -static bool imsic_init_dev_msi_info(struct device *dev, - struct irq_domain *domain, - struct irq_domain *real_parent, - struct msi_domain_info *info) -{ - const struct msi_parent_ops *pops = real_parent->msi_parent_ops; - - /* MSI parent domain specific settings */ - switch (real_parent->bus_token) { - case DOMAIN_BUS_NEXUS: - if (WARN_ON_ONCE(domain != real_parent)) - return false; -#ifdef CONFIG_SMP - info->chip->irq_set_affinity = irq_chip_set_affinity_parent; -#endif - break; - default: - WARN_ON_ONCE(1); - return false; - } - - /* Is the target supported? */ - switch (info->bus_token) { -#ifdef CONFIG_RISCV_IMSIC_PCI - case DOMAIN_BUS_PCI_DEVICE_MSI: - case DOMAIN_BUS_PCI_DEVICE_MSIX: - info->chip->irq_mask = imsic_pci_mask_irq; - info->chip->irq_unmask = imsic_pci_unmask_irq; - break; -#endif - case DOMAIN_BUS_DEVICE_MSI: - /* - * Per-device MSI should never have any MSI feature bits - * set. It's sole purpose is to create a dumb interrupt - * chip which has a device specific irq_write_msi_msg() - * callback. - */ - if (WARN_ON_ONCE(info->flags)) - return false; - - /* Core managed MSI descriptors */ - info->flags |= MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS | - MSI_FLAG_FREE_MSI_DESCS; - break; - case DOMAIN_BUS_WIRED_TO_MSI: - break; - default: - WARN_ON_ONCE(1); - return false; - } - - /* Use hierarchial chip operations re-trigger */ - info->chip->irq_retrigger = irq_chip_retrigger_hierarchy; - - /* - * Mask out the domain specific MSI feature flags which are not - * supported by the real parent. - */ - info->flags &= pops->supported_flags; - - /* Enforce the required flags */ - info->flags |= pops->required_flags; - - return true; -} - -#define MATCH_PLATFORM_MSI BIT(DOMAIN_BUS_PLATFORM_MSI) - static const struct msi_parent_ops imsic_msi_parent_ops = { .supported_flags = MSI_GENERIC_FLAGS_MASK | MSI_FLAG_PCI_MSIX, .required_flags = MSI_FLAG_USE_DEF_DOM_OPS | - MSI_FLAG_USE_DEF_CHIP_OPS, + MSI_FLAG_USE_DEF_CHIP_OPS | + MSI_FLAG_PCI_MSI_MASK_PARENT, .bus_select_token = DOMAIN_BUS_NEXUS, .bus_select_mask = MATCH_PCI_MSI | MATCH_PLATFORM_MSI, - .init_dev_msi_info = imsic_init_dev_msi_info, + .init_dev_msi_info = msi_lib_init_dev_msi_info, }; int imsic_irqdomain_init(void) From patchwork Sun Feb 9 04:16:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13966635 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E5CCFC02199 for ; Sun, 9 Feb 2025 04:23:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9lKvx2sgyoGnedYS/J5DZyqzrYsuRYLz5F4lvWQ/R4E=; b=3DtsxPvyhiHDBA xk+geaDJbN7njSnghHYeW2npdKqoeofFkf+Eq+4UH+d8+3VOXZisAFBR+WiHp31LsKguUOTJQcElj a1Acu/SWzAfcv4iRYf7028XkyTYBB975z7s1pXDlMPGZUBJ5fKEUQnjjy7GAHaCUbM7UU7R3FwHEx ZpxPtvvSEfgCB8/LpzBfV1r8+Oc0x0UxsZhOk0VxHunG1sONVUOAG+tKykocv0Gn8gBO/Abpw51qT 0liSx8OZzHNRyR8JNJRbg8+eFc7p1Oq5KHzccqC0lv1HYLy2qzAoOArPomWU4L3Lzw1T8ZCb1VM76 qL0WGri/gQhLdl9ibWQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tgyqP-0000000E3W4-2mLg; Sun, 09 Feb 2025 04:22:57 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tgylQ-0000000E2Q5-2Hf7 for linux-riscv@lists.infradead.org; Sun, 09 Feb 2025 04:17:49 +0000 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-2fa1fb3c445so3592133a91.2 for ; Sat, 08 Feb 2025 20:17:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1739074668; x=1739679468; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=muAXlG/uZk+Ut1w5NICM8ivKf832EJKGEf1Ht7zOCxs=; b=PREU5bALDwFFP4FNFxSvx1z5LM3xcPGHfpX5tNUBQZZtT3ffytZSbkH9Hsu18AmQNt X5nlOj0U2XEyXZAwPsIjOGBp4ght/IXdp4cYYsM2rv6+BMRTSUS2SKUf7ZhgtTdoyPII vheefHGJPbuGICwkVR3wRIraHXOeuYD0FVD9jiQr2RdhtlWSUU0SPmRBYwN07Z//nMcr +BEP6MFG+qj6fJ4UPNpbJ9kBTrDi5/PdpYo9PpHZKdhk1wOHoEjVMSuyl4X3WcNrmBBw 1ipEr1ZXusodyQdhPU4CrgN2IaxEhgB0szm+ljDBIUWNZ+xlDKe5u7GDCdwTtLU314Nu cAKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739074668; x=1739679468; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=muAXlG/uZk+Ut1w5NICM8ivKf832EJKGEf1Ht7zOCxs=; b=jSYYmQAi0AWi3WS0EZEgk1EfnWyjYSrnoJz62rgV0cTFepj30rqjjRMuBxAiAu3cs/ Hj7DLfD4HVRyfCJXzdea37JqUwq2v/bjucnnM2YsaVxvCE9Osz32udfw5xIliolhL2BE IN8yj3Pahe5Q4FbJN82nzX3pVN+XtwQLZ8gdlM7Zdr0aLEHsvGQx0VdqbYyG/v03IvFz iuFiYxHiKjlK00O3aEofGMBeghZmG5su/gPbuGBRU5eCXVt7wOh1AWRj3FuggPY0tlRu 3Xpzn9+fXcOJgYE98csSdZrsbQZap5G9cbgUsXBITyl5lUOYOpldK0VJSLGk8AryER6b 6xOQ== X-Forwarded-Encrypted: i=1; AJvYcCX0EoP9axaInpvuwFHeMA1hH2R5NwlL8VvP1QYIkz2N5pWs9D8ohklX6N1y8mb722gKb0IAD/msFU1oCQ==@lists.infradead.org X-Gm-Message-State: AOJu0YwXIRZUgvp7lvTY3QLDP/ag7BrfT2ist5q52DtiUNfSQQLrt/G/ fzPqz4XsY+bMVE/Xz+Ia2XJfWKIXU4IoRCVZXp1mQlhx4uAm066dWHNZ2tQnv80= X-Gm-Gg: ASbGncuCrj8XDWowgqqXXtaz7MXaih9DxKArlvcV2FzhZC6uSCIcbGga1F9kRafjqv7 NRuhE+8hn58J1wsL4Hv8Hloxl7relAvIbH5128vyQesk+Yso0PYDfv5/c1VlcS0IXzot3OioBan PvsPVFm5s3OJJaiBlZ7Z/qaejVBvOQIBTki0cplfA7AJU7dKArOBG9GVil83FDHCu42PBWB2Kdv PYO/ur4csz5fk6876pbH7mUGgXJqQ3Q/rcQEVRUvtD/vyGG+rKoL2FEgD+a29plPNRmyDT+vlNP Vqk7stB43fxVd2U4R9ol94UArzUvjcGzWKZ95XAVZmb007GCj5PDf90= X-Google-Smtp-Source: AGHT+IEZWcVRxpCJ2TdbHZSmXzLBoI3AvA6fXMBlEU2Ke4FpcCw0vGqhdEDkzoqwQdAILQxJgujX8g== X-Received: by 2002:a05:6a00:c86:b0:725:456e:76e with SMTP id d2e1a72fcca58-7305d44a459mr14381121b3a.6.1739074667815; Sat, 08 Feb 2025 20:17:47 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73073eba116sm1898410b3a.124.2025.02.08.20.17.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Feb 2025 20:17:47 -0800 (PST) From: Anup Patel To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Subject: [PATCH v5 04/11] genirq: Introduce common irq_force_complete_move() implementation Date: Sun, 9 Feb 2025 09:46:48 +0530 Message-ID: <20250209041655.331470-5-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250209041655.331470-1-apatel@ventanamicro.com> References: <20250209041655.331470-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250208_201748_607406_5C1F9F04 X-CRM114-Status: GOOD ( 36.55 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , Atish Patra , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Paul Walmsley , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , hpa@zytor.com, Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Thomas Gleixner The GENERIC_PENDING_IRQ requires an arch specific implementation of irq_force_complete_move(). At the moment, only x86 implements this but for RISC-V the irq_force_complete_move() is only needed when RISC-V IMSIC driver is in use and not needed otherwise. To address the above, introduce a common irq_force_complete_move() implementation in kernel irq migration which lets irqchip do the actual irq_force_complete_move() and also update x86 APIC to use this common implementation. Signed-off-by: Thomas Gleixner Signed-off-by: Anup Patel --- arch/x86/kernel/apic/vector.c | 231 ++++++++++++++++------------------ include/linux/irq.h | 5 +- kernel/irq/internals.h | 2 + kernel/irq/migration.c | 10 ++ 4 files changed, 123 insertions(+), 125 deletions(-) diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c index 736f62812f5c..72fa4bb78f0a 100644 --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c @@ -888,8 +888,109 @@ static int apic_set_affinity(struct irq_data *irqd, return err ? err : IRQ_SET_MASK_OK; } +static void free_moved_vector(struct apic_chip_data *apicd) +{ + unsigned int vector = apicd->prev_vector; + unsigned int cpu = apicd->prev_cpu; + bool managed = apicd->is_managed; + + /* + * Managed interrupts are usually not migrated away + * from an online CPU, but CPU isolation 'managed_irq' + * can make that happen. + * 1) Activation does not take the isolation into account + * to keep the code simple + * 2) Migration away from an isolated CPU can happen when + * a non-isolated CPU which is in the calculated + * affinity mask comes online. + */ + trace_vector_free_moved(apicd->irq, cpu, vector, managed); + irq_matrix_free(vector_matrix, cpu, vector, managed); + per_cpu(vector_irq, cpu)[vector] = VECTOR_UNUSED; + hlist_del_init(&apicd->clist); + apicd->prev_vector = 0; + apicd->move_in_progress = 0; +} + +/* + * Called from fixup_irqs() with @desc->lock held and interrupts disabled. + */ +static void apic_force_complete_move(struct irq_data *irqd) +{ + unsigned int cpu = smp_processor_id(); + struct apic_chip_data *apicd; + unsigned int vector; + + guard(raw_spinlock)(&vector_lock); + apicd = apic_chip_data(irqd); + if (!apicd) + return; + + /* + * If prev_vector is empty or the descriptor is neither currently + * nor previously on the outgoing CPU no action required. + */ + vector = apicd->prev_vector; + if (!vector || (apicd->cpu != cpu && apicd->prev_cpu != cpu)) + return; + + /* + * This is tricky. If the cleanup of the old vector has not been + * done yet, then the following setaffinity call will fail with + * -EBUSY. This can leave the interrupt in a stale state. + * + * All CPUs are stuck in stop machine with interrupts disabled so + * calling __irq_complete_move() would be completely pointless. + * + * 1) The interrupt is in move_in_progress state. That means that we + * have not seen an interrupt since the io_apic was reprogrammed to + * the new vector. + * + * 2) The interrupt has fired on the new vector, but the cleanup IPIs + * have not been processed yet. + */ + if (apicd->move_in_progress) { + /* + * In theory there is a race: + * + * set_ioapic(new_vector) <-- Interrupt is raised before update + * is effective, i.e. it's raised on + * the old vector. + * + * So if the target cpu cannot handle that interrupt before + * the old vector is cleaned up, we get a spurious interrupt + * and in the worst case the ioapic irq line becomes stale. + * + * But in case of cpu hotplug this should be a non issue + * because if the affinity update happens right before all + * cpus rendezvous in stop machine, there is no way that the + * interrupt can be blocked on the target cpu because all cpus + * loops first with interrupts enabled in stop machine, so the + * old vector is not yet cleaned up when the interrupt fires. + * + * So the only way to run into this issue is if the delivery + * of the interrupt on the apic/system bus would be delayed + * beyond the point where the target cpu disables interrupts + * in stop machine. I doubt that it can happen, but at least + * there is a theoretical chance. Virtualization might be + * able to expose this, but AFAICT the IOAPIC emulation is not + * as stupid as the real hardware. + * + * Anyway, there is nothing we can do about that at this point + * w/o refactoring the whole fixup_irq() business completely. + * We print at least the irq number and the old vector number, + * so we have the necessary information when a problem in that + * area arises. + */ + pr_warn("IRQ fixup: irq %d move in progress, old vector %d\n", + irqd->irq, vector); + } + free_moved_vector(apicd); +} + #else -# define apic_set_affinity NULL +# define apic_set_affinity NULL +# define apic_force_complete_move NULL #endif static int apic_retrigger_irq(struct irq_data *irqd) @@ -923,39 +1024,16 @@ static void x86_vector_msi_compose_msg(struct irq_data *data, } static struct irq_chip lapic_controller = { - .name = "APIC", - .irq_ack = apic_ack_edge, - .irq_set_affinity = apic_set_affinity, - .irq_compose_msi_msg = x86_vector_msi_compose_msg, - .irq_retrigger = apic_retrigger_irq, + .name = "APIC", + .irq_ack = apic_ack_edge, + .irq_set_affinity = apic_set_affinity, + .irq_compose_msi_msg = x86_vector_msi_compose_msg, + .irq_force_complete_move = apic_force_complete_move, + .irq_retrigger = apic_retrigger_irq, }; #ifdef CONFIG_SMP -static void free_moved_vector(struct apic_chip_data *apicd) -{ - unsigned int vector = apicd->prev_vector; - unsigned int cpu = apicd->prev_cpu; - bool managed = apicd->is_managed; - - /* - * Managed interrupts are usually not migrated away - * from an online CPU, but CPU isolation 'managed_irq' - * can make that happen. - * 1) Activation does not take the isolation into account - * to keep the code simple - * 2) Migration away from an isolated CPU can happen when - * a non-isolated CPU which is in the calculated - * affinity mask comes online. - */ - trace_vector_free_moved(apicd->irq, cpu, vector, managed); - irq_matrix_free(vector_matrix, cpu, vector, managed); - per_cpu(vector_irq, cpu)[vector] = VECTOR_UNUSED; - hlist_del_init(&apicd->clist); - apicd->prev_vector = 0; - apicd->move_in_progress = 0; -} - static void __vector_cleanup(struct vector_cleanup *cl, bool check_irr) { struct apic_chip_data *apicd; @@ -1068,99 +1146,6 @@ void irq_complete_move(struct irq_cfg *cfg) __vector_schedule_cleanup(apicd); } -/* - * Called from fixup_irqs() with @desc->lock held and interrupts disabled. - */ -void irq_force_complete_move(struct irq_desc *desc) -{ - unsigned int cpu = smp_processor_id(); - struct apic_chip_data *apicd; - struct irq_data *irqd; - unsigned int vector; - - /* - * The function is called for all descriptors regardless of which - * irqdomain they belong to. For example if an IRQ is provided by - * an irq_chip as part of a GPIO driver, the chip data for that - * descriptor is specific to the irq_chip in question. - * - * Check first that the chip_data is what we expect - * (apic_chip_data) before touching it any further. - */ - irqd = irq_domain_get_irq_data(x86_vector_domain, - irq_desc_get_irq(desc)); - if (!irqd) - return; - - raw_spin_lock(&vector_lock); - apicd = apic_chip_data(irqd); - if (!apicd) - goto unlock; - - /* - * If prev_vector is empty or the descriptor is neither currently - * nor previously on the outgoing CPU no action required. - */ - vector = apicd->prev_vector; - if (!vector || (apicd->cpu != cpu && apicd->prev_cpu != cpu)) - goto unlock; - - /* - * This is tricky. If the cleanup of the old vector has not been - * done yet, then the following setaffinity call will fail with - * -EBUSY. This can leave the interrupt in a stale state. - * - * All CPUs are stuck in stop machine with interrupts disabled so - * calling __irq_complete_move() would be completely pointless. - * - * 1) The interrupt is in move_in_progress state. That means that we - * have not seen an interrupt since the io_apic was reprogrammed to - * the new vector. - * - * 2) The interrupt has fired on the new vector, but the cleanup IPIs - * have not been processed yet. - */ - if (apicd->move_in_progress) { - /* - * In theory there is a race: - * - * set_ioapic(new_vector) <-- Interrupt is raised before update - * is effective, i.e. it's raised on - * the old vector. - * - * So if the target cpu cannot handle that interrupt before - * the old vector is cleaned up, we get a spurious interrupt - * and in the worst case the ioapic irq line becomes stale. - * - * But in case of cpu hotplug this should be a non issue - * because if the affinity update happens right before all - * cpus rendezvous in stop machine, there is no way that the - * interrupt can be blocked on the target cpu because all cpus - * loops first with interrupts enabled in stop machine, so the - * old vector is not yet cleaned up when the interrupt fires. - * - * So the only way to run into this issue is if the delivery - * of the interrupt on the apic/system bus would be delayed - * beyond the point where the target cpu disables interrupts - * in stop machine. I doubt that it can happen, but at least - * there is a theoretical chance. Virtualization might be - * able to expose this, but AFAICT the IOAPIC emulation is not - * as stupid as the real hardware. - * - * Anyway, there is nothing we can do about that at this point - * w/o refactoring the whole fixup_irq() business completely. - * We print at least the irq number and the old vector number, - * so we have the necessary information when a problem in that - * area arises. - */ - pr_warn("IRQ fixup: irq %d move in progress, old vector %d\n", - irqd->irq, vector); - } - free_moved_vector(apicd); -unlock: - raw_spin_unlock(&vector_lock); -} - #ifdef CONFIG_HOTPLUG_CPU /* * Note, this is not accurate accounting, but at least good enough to diff --git a/include/linux/irq.h b/include/linux/irq.h index 8daa17f0107a..56f6583093d2 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -486,6 +486,7 @@ static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d) * @ipi_send_mask: send an IPI to destination cpus in cpumask * @irq_nmi_setup: function called from core code before enabling an NMI * @irq_nmi_teardown: function called from core code after disabling an NMI + * @irq_force_complete_move: optional function to force complete pending irq move * @flags: chip specific flags */ struct irq_chip { @@ -537,6 +538,8 @@ struct irq_chip { int (*irq_nmi_setup)(struct irq_data *data); void (*irq_nmi_teardown)(struct irq_data *data); + void (*irq_force_complete_move)(struct irq_data *data); + unsigned long flags; }; @@ -619,11 +622,9 @@ static inline void irq_move_irq(struct irq_data *data) __irq_move_irq(data); } void irq_move_masked_irq(struct irq_data *data); -void irq_force_complete_move(struct irq_desc *desc); #else static inline void irq_move_irq(struct irq_data *data) { } static inline void irq_move_masked_irq(struct irq_data *data) { } -static inline void irq_force_complete_move(struct irq_desc *desc) { } #endif extern int no_irq_affinity; diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h index a979523640d0..d4e190e690bd 100644 --- a/kernel/irq/internals.h +++ b/kernel/irq/internals.h @@ -442,6 +442,7 @@ static inline struct cpumask *irq_desc_get_pending_mask(struct irq_desc *desc) return desc->pending_mask; } bool irq_fixup_move_pending(struct irq_desc *desc, bool force_clear); +void irq_force_complete_move(struct irq_desc *desc); #else /* CONFIG_GENERIC_PENDING_IRQ */ static inline bool irq_can_move_pcntxt(struct irq_data *data) { @@ -467,6 +468,7 @@ static inline bool irq_fixup_move_pending(struct irq_desc *desc, bool fclear) { return false; } +static inline void irq_force_complete_move(struct irq_desc *desc) { } #endif /* !CONFIG_GENERIC_PENDING_IRQ */ #if !defined(CONFIG_IRQ_DOMAIN) || !defined(CONFIG_IRQ_DOMAIN_HIERARCHY) diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c index eb150afd671f..e110300ad650 100644 --- a/kernel/irq/migration.c +++ b/kernel/irq/migration.c @@ -35,6 +35,16 @@ bool irq_fixup_move_pending(struct irq_desc *desc, bool force_clear) return true; } +void irq_force_complete_move(struct irq_desc *desc) +{ + for (struct irq_data *d = irq_desc_get_irq_data(desc); d; d = d->parent_data) { + if (d->chip && d->chip->irq_force_complete_move) { + d->chip->irq_force_complete_move(d); + return; + } + } +} + void irq_move_masked_irq(struct irq_data *idata) { struct irq_desc *desc = irq_data_to_desc(idata); From patchwork Sun Feb 9 04:16:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13966641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C00F3C021A0 for ; Sun, 9 Feb 2025 04:25:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0z3G0ier8Em4QA68TK/jvDqS5I6daJj44PZyrl4jU04=; b=YVG6VIDWoMrYFV oXjsv+2/ZVGs4Rb2QFhypEUM3+wT+WiMhhaEOXWBbs53hPtxr//y05UsYh5GG6C0iBghrnzFxVYkt VtqxK3co5E2BhLjYE8FFXO6HYA9W/A563LLwnbBciypifWgEnVT7U0/n2S4mXM7z2Ot4+rZwq5FRk IHO/ioqGP8xF0nVUyhRRs5GbJTiptRQpliADSFBq6uAkVNuraVK/sXDsPqY1fBgrA0GmDaFBMrndW 5fbhoSv8xswqHUd7uQju5AU22c5GIrVaSGMlio+OaD/nBS30yybq4UTBJHjpZGU0y9EBqoiHZ6Rv9 En2m5IW8EV1qRnbBqcHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tgyt8-0000000E3ta-3rPD; Sun, 09 Feb 2025 04:25:46 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tgylY-0000000E2SC-3xjR for linux-riscv@lists.infradead.org; Sun, 09 Feb 2025 04:17:58 +0000 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-2fa51743d80so819356a91.2 for ; Sat, 08 Feb 2025 20:17:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1739074676; x=1739679476; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3sE/PXdSSokJ0Zgm0Fk4Pk1jUj6qdWvd3FyfD/aEiAI=; b=S+IYvifu3RJKwJ64EqOFpzfssoHjWXjmzBUswhqINnDP6hPZDYORuUwMINRTayjECM 9ALJKzIBwXseW5eYWB0I7RbDEZh34iuq9B0j4jceX7CMNykSMElSkpO/pzzgqW2TZwiZ F32s0WvvOfJaiF2vE7R2jy2wuXfGOg0kw7cdTOjGu80uY0pgAR//6Pd4u1ijnCg/WPHS vtTs+DZPIOjD9Aa59uRfKuPmWSWwN6uwmOOPr1mJMGBU42QKBq933//Bp3yl7r2mQPd9 +NrRF1e9P6xka8PqyzIHRHGrBMtyIb6op2UVxzSOHNnZ8BOBdxDfj9RwFZnHLBprdeRH 7hmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739074676; x=1739679476; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3sE/PXdSSokJ0Zgm0Fk4Pk1jUj6qdWvd3FyfD/aEiAI=; b=SpRNeFTTcf3BujgoK+nj1YxEKIkj74YfidIFS5daMkjAASa8Efm/UYRMQ3NKInmWsK xZowuP8SkJpr/tX5b1ebKc8KGEOeHMeBjL87HPAG4+NdGXMtycK5F2gzph17vv5u7jsR 8YiEY9TJks8xqIFbAClAfKhbJck/g2EVTyoA6rDHpwJzq3i4W056caUDD95EgZYChAcv BS230zd9tS6+RraKngDLUesetInW3mLadJATWC07jd1LyTmC37vqYMFT2aVs/sLO43Dt okVAr6/jjLvsNENM0VTv7vf4xI9yAFKis+iEkNojmfNGfXlcgOk5BR3NgDdVBkaJ45Mn ou4A== X-Forwarded-Encrypted: i=1; AJvYcCXNJ0HHnjFCKmUlxT7E0siuNI00K3JnYcUNRv7oaynvwcQZaxVVTMgIQZQ+iIBksqq8sRVGyQABC0QWyQ==@lists.infradead.org X-Gm-Message-State: AOJu0YzZPoEOKWBSRGeEmQiYcBQsKhYQGfs7E7qbhSja/ompgkD6C8hC quIKdWROuBf+r/NgFwpPduNj474R1S2r6A+3gwN65a9SczaCVhCjNq92DaHx70I= X-Gm-Gg: ASbGncvIRd4cYZjI3bZF7IWuGeFsDf6g0zLbM3CW1To8vYtsoLyGfG0ok6fUKKEXtBy sXri5GRrbsOHDdSc/I+pSiPmtwEqg5nZ7VHaFFeSMDDYmlrHtDsRC6YH1EfuhFiBRlZoKVaLBv7 FlTl9a2nLM0rik/Ion/veKwbUArhh7podL6To0kUKIhjH1QBFcySz+ceOB3E0SuWUBC6/rt5tvR 03IfwI8xZt9lpBMNauRzG0/fWf7BUFOvs3O4c6DGMN4Y/iX7SlXZQ5oY3yp/71DsizeAPI71skP NF+sFLpU6uIuyBqIwTL3h0E/dz5X35a1zrRTum4w8k6E89s8egWSnKc= X-Google-Smtp-Source: AGHT+IHDq8j70VgdWYD0/5rZSoa9FGuz2H9SOfW3ipfEG4foQkrNVKZyKea9+xF989Gz8oAitxsVGw== X-Received: by 2002:a05:6a00:a15:b0:727:d55e:4be3 with SMTP id d2e1a72fcca58-7305d463732mr13313591b3a.7.1739074676324; Sat, 08 Feb 2025 20:17:56 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73073eba116sm1898410b3a.124.2025.02.08.20.17.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Feb 2025 20:17:55 -0800 (PST) From: Anup Patel To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Subject: [PATCH v5 05/11] genirq: Introduce irq_can_move_in_process_context() Date: Sun, 9 Feb 2025 09:46:49 +0530 Message-ID: <20250209041655.331470-6-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250209041655.331470-1-apatel@ventanamicro.com> References: <20250209041655.331470-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250208_201757_045888_3A3CBC1B X-CRM114-Status: UNSURE ( 9.58 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , Atish Patra , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Paul Walmsley , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , hpa@zytor.com, Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The interrupt controller drivers which use GENERIC_PENDING_IRQ can move interrupts in process context for downstrean devices which support atomic MSI configuration. Introduce irq_can_move_in_process_context() which allows interrupt controller drivers to test whether a particular interrupt can be moved process context. Signed-off-by: Anup Patel --- include/linux/irq.h | 2 ++ kernel/irq/migration.c | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/linux/irq.h b/include/linux/irq.h index 56f6583093d2..dd5df1e2d032 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -615,6 +615,7 @@ extern int irq_affinity_online_cpu(unsigned int cpu); #endif #if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_PENDING_IRQ) +bool irq_can_move_in_process_context(struct irq_data *data); void __irq_move_irq(struct irq_data *data); static inline void irq_move_irq(struct irq_data *data) { @@ -623,6 +624,7 @@ static inline void irq_move_irq(struct irq_data *data) } void irq_move_masked_irq(struct irq_data *data); #else +static inline bool irq_can_move_in_process_context(struct irq_data *data) { return true; } static inline void irq_move_irq(struct irq_data *data) { } static inline void irq_move_masked_irq(struct irq_data *data) { } #endif diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c index e110300ad650..5acea2ac57be 100644 --- a/kernel/irq/migration.c +++ b/kernel/irq/migration.c @@ -127,3 +127,14 @@ void __irq_move_irq(struct irq_data *idata) if (!masked) idata->chip->irq_unmask(idata); } + +bool irq_can_move_in_process_context(struct irq_data *data) +{ + /* + * Get top level irq_data when CONFIG_IRQ_DOMAIN_HIERARCHY is enabled, + * and it should be optimized away when CONFIG_IRQ_DOMAIN_HIERARCHY is + * disabled. So we avoid an "#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY" here. + */ + data = irq_desc_get_irq_data(irq_data_to_desc(data)); + return irq_can_move_pcntxt(data); +} From patchwork Sun Feb 9 04:16:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13966640 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 15F79C02199 for ; Sun, 9 Feb 2025 04:25:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kwZwE69TzK4bUS7MybKdSB8OOhDDaawc7lCtPJSxgyg=; b=gUeWzXoFN8ZcLX oxIojT6P3hF/peZRy725TItVV2tNo1lO1nN1KPhMfDNTIcynH7WwT4OwSTYzaNg8wpPR1aulkW8JQ L2+BsoIIeetqxlIbw8mQgIuREO3pr2wOFyVWyQArmHURcSuP4LftOLlkArQDjsoYJCYX7cYr7XoM8 vRHwLZvH9sRGhRRLEf6HctAxaLO1adVirgfJP3SFgZM5RwkJfy9K/aYMntltgL23/GzvVORTyIdrF +2gC32efzZ28l44SO4uqcTePVUAPxMKz8gj8toC3KU1667c2fuZWt1TOpMblZT3zdPxl1vWKs9heg ibrJw5dsLUfOPCWLIKqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tgyt9-0000000E3tj-2FWd; Sun, 09 Feb 2025 04:25:47 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tgylh-0000000E2Ur-1z55 for linux-riscv@lists.infradead.org; Sun, 09 Feb 2025 04:18:06 +0000 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-2fa1d9fb990so4654470a91.2 for ; Sat, 08 Feb 2025 20:18:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1739074685; x=1739679485; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+su7Pdf8Wu86Zcml4faTN2UwZ+oipeVYumq+PsYwErw=; b=RyVhxtOk9yFTVa5fhH9FEoDTMNvWQ9pmZ45w9pGR8Pfa93CErKyNVQLdBwA2445bj7 yAQ2kpr1hkVcMVRkHsn6+cGHFNX9ShC0KaxSH8U/tGv2HqZdtfIZwEaNB8zYXHaH3Gm2 4hrhu5fIJN4/9aMLvCImleMkqs0bxjC5lPBucJjkdXki8lvw7kUKbpMsnFxDQauGVGDk EDGNhdqQWUSxqrXcvJdV7rC8Uum5aLEXP3QO/OT8hrsGoTFc9mHbvQ0BxIno5OqbnsqJ ryrKnjtoM47kQOjoX09qvXVTTOJJ11ONOovpC+x8PnPhx9/3wZt+2g6LI/7jwStLB9tF 8Fug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739074685; x=1739679485; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+su7Pdf8Wu86Zcml4faTN2UwZ+oipeVYumq+PsYwErw=; b=qeIcV4FHHksSCcQk88q2zJZki8qKb4EWB+J3UZ6QGXBlxaYxvQ76dit1mqlsnJDk6T KXPZVLVV2OlRdSSKLj53XicUWSeP5fQgFiJTboNqKogumcTU9mDciv9Lao1XLrvkHgFu 6zsw3U2WBU0QFRoj2Hm1pE3eJqp9iiEDK9+JfmrARhwVNc/1uVZ/ZAthhOVJtXJ0apJ4 jbT+NfO8g3e0mmDbU+6gGLSIO+8TTzAlt4hxXI6JjgVZQBz4nVoNxSkFkJkMGi4IZpNF UGxxiD7bEKuttrrL8VCu+htatu2328e023Em4m+nPR/gMyo8X/yHU1lFc6Hl47RH8Deb f8kA== X-Forwarded-Encrypted: i=1; AJvYcCX7fB9NghnBe2dbHzEdyChSOyVv7XzzNcEE8Qv7vZ/av5sHzjKwmRW0ofJT7+mDqJTiN75mCQYNbG4/1A==@lists.infradead.org X-Gm-Message-State: AOJu0YyCR8LVJkoIdN86OulREW7V6Vxk/XT2X1dl+JT6FLWrRxbfDmrg 9h2qND57yja6/l5VHR8DNL+8Q7FdDr9kYAnPldAHhTuQLHvJTxBPgxfK8VI2ffI= X-Gm-Gg: ASbGncvUG4tu3g6ApxUI7X8nqsntz0rtvHroqCW11L9sm26DwNizJwHFpcwpLocq8Xy sFhZctavY33qxmd79a9JFu468WhvDJaOs6u4+o1wU01eVMOYLBPwVXwj3eoZK0sg9PR1Gmk9+rA Vt+6TL1fxob0iWExlEarTVutm6g/OOXGuQSh7DFQA5KSFL047dCjgLSsfr0ziA9mMOHMRzaZG71 V/MR69Lo2UgzdDTapv/k8WhWrq1Bzr2PJeAq3py4IXot7egvTwhcR4wzj6maT8tA1Uwd4aLvjqr Sq3G97Jd794SvMnojl8tSmk9psWMEzhwSuE21txADORy768v5EeBhRs= X-Google-Smtp-Source: AGHT+IHplK1Odn1krUBJui9aJ3bXui5w4fG7ychKlkG3JoJ8qZ1jCX3WfSDt+grELpA1vaZRwG2+1g== X-Received: by 2002:a05:6a00:178c:b0:730:8a5b:6e61 with SMTP id d2e1a72fcca58-7308a5b7c17mr217952b3a.2.1739074684846; Sat, 08 Feb 2025 20:18:04 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73073eba116sm1898410b3a.124.2025.02.08.20.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Feb 2025 20:18:04 -0800 (PST) From: Anup Patel To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Subject: [PATCH v5 06/11] genirq: Remove unused GENERIC_PENDING_IRQ_CHIPFLAGS kconfig option Date: Sun, 9 Feb 2025 09:46:50 +0530 Message-ID: <20250209041655.331470-7-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250209041655.331470-1-apatel@ventanamicro.com> References: <20250209041655.331470-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250208_201805_678573_AB81F711 X-CRM114-Status: UNSURE ( 8.51 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , Atish Patra , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Paul Walmsley , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , hpa@zytor.com, Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The GENERIC_PENDING_IRQ_CHIPFLAGS kconfig option is no used anywhere hence remove it. Fixes: f94a18249b7f ("genirq: Remove IRQ_MOVE_PCNTXT and related code") Signed-off-by: Anup Patel --- kernel/irq/Kconfig | 4 ---- 1 file changed, 4 deletions(-) diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig index 5432418c0fea..875f25ed6f71 100644 --- a/kernel/irq/Kconfig +++ b/kernel/irq/Kconfig @@ -31,10 +31,6 @@ config GENERIC_IRQ_EFFECTIVE_AFF_MASK config GENERIC_PENDING_IRQ bool -# Deduce delayed migration from top-level interrupt chip flags -config GENERIC_PENDING_IRQ_CHIPFLAGS - bool - # Support for generic irq migrating off cpu before the cpu is offline. config GENERIC_IRQ_MIGRATION bool From patchwork Sun Feb 9 04:16:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13966642 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4D26AC02199 for ; Sun, 9 Feb 2025 04:27:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9VXajq6t60neUU9rMTpi4e1cYBZ5EDOWx8giU8SqC4w=; b=aTuSvhYQ/m/BOH o5Is2NEty2V4j70JJnVgREl/bWQqWi5uiRSsSyfK87enZtLrVWKjOHODpQy9cMkEccxDREhFvpPLE +CsZScefZn+yaLfwQyexeWrZTPUQiOLZQnDqKfrLhB51B26OPyt8QV2dWlYllrpsxFDzZeI5AapNt ajpDivZRud8EGmUla/JXrsYZIfXCql5H5i6ynXwdai4VEvxKO3GG5IsSxmHVvodm4usFaCwsqjqfi 9Cs9IDoeBHoGUY+oqg2/wMXL+mNLl5CEcUQAdPXIWWPP3FgtV6TEJDx2j2BNdkGbjFB3Ks7kQU2nJ r6a0FBzm6szqrD1NCouw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tgyuV-0000000E4AP-41sP; Sun, 09 Feb 2025 04:27:12 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tgylr-0000000E2Xw-1BJg for linux-riscv@lists.infradead.org; Sun, 09 Feb 2025 04:18:16 +0000 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-2fa5af6d743so698482a91.3 for ; Sat, 08 Feb 2025 20:18:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1739074695; x=1739679495; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JBZXTbuS/jzxIISJXLRWUHAJ1oANsva3E4CzlwWomJY=; b=H27wk9QWPks3qOJRzw9zAVDZV0byI+ZYSlJ9j9W1L9N7hblqCI3x/J80PFe6D1lKnb L3ezHGeugew3uGKjs95OmkFOA5iZFPj2TwhgxFGooitN6vB/cqWpjBHuigtzD+nGfOqa wLJAyDpXKdEBhUYqNOadgPNPsPhhjtgSos1BfIoBD+M+70jz/4+4Qds0fDHYktsIO6ze H4KOZZDxECif6FPSvOMWsMTNFCDrw8pgV19xWyRZmZWxYuJHd+wqq8QLhoe/x7sea1zK Kn9z4XCFG5YanELyGy+D/dN/vSlXTJCT/ni9U0aGk+/B/A3G6ex9Dz81mFhFJpNpuRnG iX7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739074695; x=1739679495; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JBZXTbuS/jzxIISJXLRWUHAJ1oANsva3E4CzlwWomJY=; b=MgeI+vNLwPobRTFuvsWwHpzXCJ/eDmLcuX9wxEqHAfYflyB6l40bJyuOVeDBZzYgSo kM4tHPW9dLSYHI64Ze2wFMFjVYwQIeY+aXL/Zw/vnvKxm/slU87aP3u8cEoQV5xKx/6u vU9bZxpJMRSVq7vCUUc21P4WHggjvcuamXF6kmXg1LAB7PfxdUeJnQpPXghcTvE5SACW 1y0G0AK/i6E1O5xUlbve19BbkyPO5nQgl4bqbTZomcxrciuW5dWCMNJ0HIeN6f+33Ugg 1zu/yFqZ+P8tGbEdIovn08z0L1wJVBRruQvgO+1v4GLS/SSGjGytjAdLyjiNB/fzvW58 DZSQ== X-Forwarded-Encrypted: i=1; AJvYcCWR1S2A+UeRedYQNfJUuvxs6oQzFYQMuxxeZhriTv+H38P/3vwMLC+KzCovjIpLkFUE7hgG7eP2IPT7qQ==@lists.infradead.org X-Gm-Message-State: AOJu0Ywim96YacWrCvUj3TWGHuCaCTRjRnf371WEexfxeHbbLATd7WJ+ sLgXk6hnrTwfJ1kVpx4LGHrWWQNEieeSdQRLdcRqxzVHqkEzQn8Hb3VUMjVPQ3A= X-Gm-Gg: ASbGncsHuX4+6gJ5SK7dV9U2/4Malz56AvpZBPEm7llxHd2dRgsIZHdD9gLBJ5cIqWM Brk9WCFNADVyfQXn6iL6UwnRu9wXRkA737Q7nr4jlHADnxvPR2TQZe+A6BtC5RZTv8rZz6ye7ld AvLAYwT/utagcOjRrfsWM9pNcnjVkI/VPMp+ZT185NWYZIBJLIa4hkQhdsqpk5iaD6vxZOc1z2C eRm9iG71F/sOuX9dUHdtYoe273r2Vl4w6je+MQFq8g/8wjfSV/CFSWmFD08nqeNjTw20C02uH1y UQcOSlwqtjkUNc4mNI2t7CjwmvOSIEkK+ISF5nytG7+evhNwhvOFF+E= X-Google-Smtp-Source: AGHT+IHL0ZAy+b2/HWpMWPKyLFtjwNwqGOrHhxJ1k6glfU7lfaN1/yKHZr4v/qmnwtb+wj+/nQhb2w== X-Received: by 2002:a05:6a00:2289:b0:725:460e:6bc0 with SMTP id d2e1a72fcca58-7305d2ac0admr15896176b3a.0.1739074694598; Sat, 08 Feb 2025 20:18:14 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73073eba116sm1898410b3a.124.2025.02.08.20.18.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Feb 2025 20:18:14 -0800 (PST) From: Anup Patel To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Subject: [PATCH v5 07/11] RISC-V: Select GENERIC_PENDING_IRQ Date: Sun, 9 Feb 2025 09:46:51 +0530 Message-ID: <20250209041655.331470-8-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250209041655.331470-1-apatel@ventanamicro.com> References: <20250209041655.331470-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250208_201815_326220_50F02706 X-CRM114-Status: UNSURE ( 7.66 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , Atish Patra , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Paul Walmsley , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , hpa@zytor.com, Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Enable GENERIC_PENDING_IRQ for RISC-V so that RISC-V irqchips can support delayed irq mirgration in the interrupt context. Signed-off-by: Anup Patel --- arch/riscv/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 7612c52e9b1e..a32f39748775 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -111,6 +111,7 @@ config RISCV select GENERIC_IRQ_SHOW select GENERIC_IRQ_SHOW_LEVEL select GENERIC_LIB_DEVMEM_IS_ALLOWED + select GENERIC_PENDING_IRQ if SMP select GENERIC_PCI_IOMAP select GENERIC_PTDUMP if MMU select GENERIC_SCHED_CLOCK From patchwork Sun Feb 9 04:16:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13966647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 56F59C021A0 for ; Sun, 9 Feb 2025 04:30:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IBiUhJKjMMWVQOjwgvu86etvnRLsIWhVEL/Jd1Xd5Rw=; b=lSz2BZnfO9LDb2 JT142HA4RIff2LTBnRPRsbEwb4NfyM42VPOrfgFe+S/x5tNANVFEsvo7aWHs0rPyhxmq+MHIy70/4 swcOa+a2FaRjWSeC4gksaqqDR8VdBi/QD6O3KNV8mpSWa615tkplenfFbemaQjJ7bwDayIAnLuDzb RCdV0Q1XlDhzB+w8awkRxUAe6uVipOpQ2TSw8VO6Ro3Bxq4ILwcC+co4jdvkNI++MerTVatEqVm/q CYGnKEZIBthBT79o8yh7rPxw2m23Q84H4kLhUEP9KKuSACU18y4xJn0Yxp73CMFI4CttC0gHA5kOI TwJtL5CuTpQ0KXW0lRHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tgyxF-0000000E4av-0lCc; Sun, 09 Feb 2025 04:30:01 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tgym0-0000000E2ba-0LP0 for linux-riscv@lists.infradead.org; Sun, 09 Feb 2025 04:18:25 +0000 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-21f573ff39bso36393905ad.1 for ; Sat, 08 Feb 2025 20:18:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1739074703; x=1739679503; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=li309BKFytEFNs0s+UiLLaDTQ3aEtuOmqKESJ/Lkwhg=; b=dvtA7pYzZ+WkmQ3YX09lX6k5O7kAW2WP7M9U84KMyCOpWMN8RLClFpc3Oq2VUyfXKt vw3K3RZEvIocEa4xaSKebMKIUIHJVVzEWbMhqgLL3P2lVcLYwqYVfZPCwmKnQ3hyjrOt SAIprxdyE23sZtJMx98aZOb8yTpAN61vgrLur+zZWdNMzdl9Is0xIXG4cLNhVNhexNjV ygW+IspCo2k6hlsC+19BOAnBrjiImKRggNe5pCh+PzasoygbA5bH3UcgLy+GF8gDJpl0 MvYVnNuQRUQJf0P4DB8Uj6lFFfTk69R1spMKOndqVsW9PVmERE4rpy/2RpBoSUeP0x3i AhFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739074703; x=1739679503; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=li309BKFytEFNs0s+UiLLaDTQ3aEtuOmqKESJ/Lkwhg=; b=JAHA5tchz+XRaUP/UbSuVEnMgGmCuOnUrUEs4X9uqGvgz6i47aTzR9t+bTHdL8SKT4 oZGoB6PqB84iOe7qCJmc9w7sJG3EfQV1qQWhFxAvlWt+TPVYM08/eYOer0hOK7i7+ldG iqsAbezGTzESNtGXw5iuUFFFIw+XNlf+ccF5W2UGxcccTKeyDwCPTVF/RFFCsoA4B5JE KeEfGw49sghuYNX07KrYI6hIgZuJ9u1qiPP+xkZEM+4kJJgqkkFLfgY2wMGOFq8OzrzM XdKDbCBIcG0YLayDtY7zWlS3VBGNHORxqJtTLBIAmfKbw/9IAHQ+7Qdsqry0O3c9Uc1Q 4LCA== X-Forwarded-Encrypted: i=1; AJvYcCXBTPnNR0J4qLBTtsc7zRk2+/Y/ej7plqmWW6Y0cnAteFunaH6sDj/TU0Qux2ZCjwQvdGwh/Hv9Tp5GRA==@lists.infradead.org X-Gm-Message-State: AOJu0YwxrLHuZikB4aw3Qc+VCaW+ZbOshZd7SvPPdcn5ADSGfALYwV2O /ZrJ6L3ldr7qWo3DjrXkWKxaQEzn3lHUhQS367k5vH+y7ICHEx76MxdYiOa2stM= X-Gm-Gg: ASbGncutJtzhHFjB5T9poxxWi7G4Sf50RXeioeKIW0FBS3JzgnZRu6W2p72xGYra01R xmGjXUg+pXUSZeIlXAVEN8y9uk4jikauwonTyWr5yyy3ya3h0f6Qyxr62s/K9dPd9GOSqTLyBz/ xxvaIguaPjx5oAVpK/ed//1hieKBlgChW45V4Ym+DNOaTbLRVCuM2zOUgKfJJxWsoHqfwc0OQRJ HvIrYQFZnNWmo9JO99GTbRtNTTVPLfkI8VsGJmWyuJtDa/ZBFCsCa5DYV/RQJYvfpOJFYEKUXJU InXN5wafljobSutBBqEwmEpg2XhkUrANnKNdQ2E4wRk2oN0L4pnBU5g= X-Google-Smtp-Source: AGHT+IGr8DIP/za6PXLubagaC8HrCh4Chcf3SqtLF6bJLforSFiwf8+xl00IhhTWFSgMBoJHAPJZQw== X-Received: by 2002:a05:6a20:6f91:b0:1dc:2365:4d7d with SMTP id adf61e73a8af0-1ee03a4744fmr14841962637.16.1739074703102; Sat, 08 Feb 2025 20:18:23 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73073eba116sm1898410b3a.124.2025.02.08.20.18.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Feb 2025 20:18:22 -0800 (PST) From: Anup Patel To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Subject: [PATCH v5 08/11] irqchip/riscv-imsic: Separate next and previous pointers in IMSIC vector Date: Sun, 9 Feb 2025 09:46:52 +0530 Message-ID: <20250209041655.331470-9-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250209041655.331470-1-apatel@ventanamicro.com> References: <20250209041655.331470-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250208_201824_138659_D9E50C75 X-CRM114-Status: GOOD ( 23.67 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , Atish Patra , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Paul Walmsley , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , hpa@zytor.com, Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Currently, there is only one "move" pointer in the struct imsic_vector so during vector movement the old vector points to the new vector and new vector points to itself. To support force cleanup of old vector, add separate "move_next" and "move_prev" pointers in the struct imsic_vector where during vector movement the "move_next" pointer of the old vector points to the new vector and the "move_prev" pointer of the new vector points to the old vector. Both "move_next" and "move_prev" pointers are cleared separately by __imsic_local_sync() with a restriction that "move_prev" on the new CPU is cleared only after old CPU has cleared "move_next". Signed-off-by: Anup Patel --- drivers/irqchip/irq-riscv-imsic-early.c | 8 ++- drivers/irqchip/irq-riscv-imsic-state.c | 96 +++++++++++++++++-------- drivers/irqchip/irq-riscv-imsic-state.h | 7 +- 3 files changed, 78 insertions(+), 33 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-early.c b/drivers/irqchip/irq-riscv-imsic-early.c index c5c2e6929a2f..b5def6268936 100644 --- a/drivers/irqchip/irq-riscv-imsic-early.c +++ b/drivers/irqchip/irq-riscv-imsic-early.c @@ -77,6 +77,12 @@ static void imsic_handle_irq(struct irq_desc *desc) struct imsic_vector *vec; unsigned long local_id; + /* + * Process pending local synchronization instead of waiting + * for per-CPU local timer to expire. + */ + imsic_local_sync_all(false); + chained_irq_enter(chip, desc); while ((local_id = csr_swap(CSR_TOPEI, 0))) { @@ -120,7 +126,7 @@ static int imsic_starting_cpu(unsigned int cpu) * Interrupts identities might have been enabled/disabled while * this CPU was not running so sync-up local enable/disable state. */ - imsic_local_sync_all(); + imsic_local_sync_all(true); /* Enable local interrupt delivery */ imsic_local_delivery(true); diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-riscv-imsic-state.c index b97e6cd89ed7..96e994443fc7 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.c +++ b/drivers/irqchip/irq-riscv-imsic-state.c @@ -124,10 +124,11 @@ void __imsic_eix_update(unsigned long base_id, unsigned long num_id, bool pend, } } -static void __imsic_local_sync(struct imsic_local_priv *lpriv) +static bool __imsic_local_sync(struct imsic_local_priv *lpriv) { struct imsic_local_config *mlocal; struct imsic_vector *vec, *mvec; + bool ret = true; int i; lockdep_assert_held(&lpriv->lock); @@ -143,35 +144,75 @@ static void __imsic_local_sync(struct imsic_local_priv *lpriv) __imsic_id_clear_enable(i); /* - * If the ID was being moved to a new ID on some other CPU - * then we can get a MSI during the movement so check the - * ID pending bit and re-trigger the new ID on other CPU - * using MMIO write. + * Clear the pervious vector pointer of the new vector only + * after the movement is complete on the old CPU. */ - mvec = READ_ONCE(vec->move); - WRITE_ONCE(vec->move, NULL); - if (mvec && mvec != vec) { + mvec = READ_ONCE(vec->move_prev); + if (mvec) { + /* + * If the old vector has not been updated then + * try again in the next sync-up call. + */ + if (READ_ONCE(mvec->move_next)) { + ret = false; + continue; + } + + WRITE_ONCE(vec->move_prev, NULL); + } + + /* + * If a vector was being moved to a new vector on some other + * CPU then we can get a MSI during the movement so check the + * ID pending bit and re-trigger the new ID on other CPU using + * MMIO write. + */ + mvec = READ_ONCE(vec->move_next); + if (mvec) { if (__imsic_id_read_clear_pending(i)) { mlocal = per_cpu_ptr(imsic->global.local, mvec->cpu); writel_relaxed(mvec->local_id, mlocal->msi_va); } + WRITE_ONCE(vec->move_next, NULL); imsic_vector_free(&lpriv->vectors[i]); } skip: bitmap_clear(lpriv->dirty_bitmap, i, 1); } + + return ret; } -void imsic_local_sync_all(void) +#ifdef CONFIG_SMP +static void __imsic_local_timer_start(struct imsic_local_priv *lpriv) +{ + lockdep_assert_held(&lpriv->lock); + + if (!timer_pending(&lpriv->timer)) { + lpriv->timer.expires = jiffies + 1; + add_timer_on(&lpriv->timer, smp_processor_id()); + } +} +#else +static inline void __imsic_local_timer_start(struct imsic_local_priv *lpriv) +{ +} +#endif + +void imsic_local_sync_all(bool force_all) { struct imsic_local_priv *lpriv = this_cpu_ptr(imsic->lpriv); unsigned long flags; raw_spin_lock_irqsave(&lpriv->lock, flags); - bitmap_fill(lpriv->dirty_bitmap, imsic->global.nr_ids + 1); - __imsic_local_sync(lpriv); + + if (force_all) + bitmap_fill(lpriv->dirty_bitmap, imsic->global.nr_ids + 1); + if (!__imsic_local_sync(lpriv)) + __imsic_local_timer_start(lpriv); + raw_spin_unlock_irqrestore(&lpriv->lock, flags); } @@ -190,12 +231,7 @@ void imsic_local_delivery(bool enable) #ifdef CONFIG_SMP static void imsic_local_timer_callback(struct timer_list *timer) { - struct imsic_local_priv *lpriv = this_cpu_ptr(imsic->lpriv); - unsigned long flags; - - raw_spin_lock_irqsave(&lpriv->lock, flags); - __imsic_local_sync(lpriv); - raw_spin_unlock_irqrestore(&lpriv->lock, flags); + imsic_local_sync_all(false); } static void __imsic_remote_sync(struct imsic_local_priv *lpriv, unsigned int cpu) @@ -216,14 +252,11 @@ static void __imsic_remote_sync(struct imsic_local_priv *lpriv, unsigned int cpu */ if (cpu_online(cpu)) { if (cpu == smp_processor_id()) { - __imsic_local_sync(lpriv); - return; + if (__imsic_local_sync(lpriv)) + return; } - if (!timer_pending(&lpriv->timer)) { - lpriv->timer.expires = jiffies + 1; - add_timer_on(&lpriv->timer, cpu); - } + __imsic_local_timer_start(lpriv); } } #else @@ -278,8 +311,9 @@ void imsic_vector_unmask(struct imsic_vector *vec) raw_spin_unlock(&lpriv->lock); } -static bool imsic_vector_move_update(struct imsic_local_priv *lpriv, struct imsic_vector *vec, - bool new_enable, struct imsic_vector *new_move) +static bool imsic_vector_move_update(struct imsic_local_priv *lpriv, + struct imsic_vector *vec, bool is_old_vec, + bool new_enable, struct imsic_vector *move_vec) { unsigned long flags; bool enabled; @@ -289,7 +323,10 @@ static bool imsic_vector_move_update(struct imsic_local_priv *lpriv, struct imsi /* Update enable and move details */ enabled = READ_ONCE(vec->enable); WRITE_ONCE(vec->enable, new_enable); - WRITE_ONCE(vec->move, new_move); + if (is_old_vec) + WRITE_ONCE(vec->move_next, move_vec); + else + WRITE_ONCE(vec->move_prev, move_vec); /* Mark the vector as dirty and synchronize */ bitmap_set(lpriv->dirty_bitmap, vec->local_id, 1); @@ -322,8 +359,8 @@ void imsic_vector_move(struct imsic_vector *old_vec, struct imsic_vector *new_ve * interrupt on the old vector while device was being moved * to the new vector. */ - enabled = imsic_vector_move_update(old_lpriv, old_vec, false, new_vec); - imsic_vector_move_update(new_lpriv, new_vec, enabled, new_vec); + enabled = imsic_vector_move_update(old_lpriv, old_vec, true, false, new_vec); + imsic_vector_move_update(new_lpriv, new_vec, false, enabled, old_vec); } #ifdef CONFIG_GENERIC_IRQ_DEBUGFS @@ -386,7 +423,8 @@ struct imsic_vector *imsic_vector_alloc(unsigned int hwirq, const struct cpumask vec = &lpriv->vectors[local_id]; vec->hwirq = hwirq; vec->enable = false; - vec->move = NULL; + vec->move_next = NULL; + vec->move_prev = NULL; return vec; } diff --git a/drivers/irqchip/irq-riscv-imsic-state.h b/drivers/irqchip/irq-riscv-imsic-state.h index 391e44280827..f02842b84ed5 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.h +++ b/drivers/irqchip/irq-riscv-imsic-state.h @@ -23,7 +23,8 @@ struct imsic_vector { unsigned int hwirq; /* Details accessed using local lock held */ bool enable; - struct imsic_vector *move; + struct imsic_vector *move_next; + struct imsic_vector *move_prev; }; struct imsic_local_priv { @@ -74,7 +75,7 @@ static inline void __imsic_id_clear_enable(unsigned long id) __imsic_eix_update(id, 1, false, false); } -void imsic_local_sync_all(void); +void imsic_local_sync_all(bool force_all); void imsic_local_delivery(bool enable); void imsic_vector_mask(struct imsic_vector *vec); @@ -87,7 +88,7 @@ static inline bool imsic_vector_isenabled(struct imsic_vector *vec) static inline struct imsic_vector *imsic_vector_get_move(struct imsic_vector *vec) { - return READ_ONCE(vec->move); + return READ_ONCE(vec->move_prev); } void imsic_vector_move(struct imsic_vector *old_vec, struct imsic_vector *new_vec); From patchwork Sun Feb 9 04:16:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13966646 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 74870C02199 for ; Sun, 9 Feb 2025 04:30:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aYkGQtD89YXF5oo41GUIndlRaba6DKliLoofi/hRVSc=; b=0a/tMHa+VDPZF8 grKbjONjv7j25JY/SjrlyWy6K5SwJcZbiOoUrOA1oWPEcDpQ/JAGjpTG2wd7Sfg4LkaiahmyytxkB b2fVBwizNTQL9ve27SYMpAns+7EFcCEeOsTcPJMp+xoXqtfLjB1vgHlfhsjn1Etd/FU4DZ1Tm/VPp Ul6W7DV/hWlHTySyWCzHhIJxxCtL03Eeq+mob1iiivI1lHqmwey4cRz/KhUrEaFumzTjS+J5ymacN hyXxHXo6FiPTcbWzpj/Chzqmac0mCwFCxbQePE70P1dnuwh0B4SKqbmwuMDHwhF4P2i0Cv/ERm0ZC U7ev3GSrAJdQ36YuBMPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tgyxG-0000000E4bC-0fiO; Sun, 09 Feb 2025 04:30:02 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tgym8-0000000E2eR-0lks for linux-riscv@lists.infradead.org; Sun, 09 Feb 2025 04:18:33 +0000 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-21f5268cf50so26802215ad.1 for ; Sat, 08 Feb 2025 20:18:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1739074712; x=1739679512; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RoqQmmMLZnhmH7e8y5iCPOfAA2UjM+1/YD5gOA06f3E=; b=GbtDVINbpEfX8FglJJetZ8ZfLA/+Sf8zkwhN8rL4+Za8TsXPOsM3IPokkgpKAWGuL8 U6OAiEVDGia0Wr5GA6yxGdVaOZbtbLVa8yu5k/wa3yuvOgJ/WXXC3JM8Mp4BayhCCOlj yoZ21NXDFPsuHqE+/6X4tcUOkSUw9bNq/TM2r/wwGHZg9u7wkWM0XjGuejKoLn+UKe3J uH+E5clDWfqS5KgFrFJE3oHj1xz2KGzM00VA6SLrYvQWTJavKOjA3isrhoPTHIJuWcQc ijjIaHZJ/95PFFBE/keBI3zYaWTpE03B/lDd/0KJ+k/Ipeu1I6lCvfGcXIVYCwacdHjN oNoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739074712; x=1739679512; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RoqQmmMLZnhmH7e8y5iCPOfAA2UjM+1/YD5gOA06f3E=; b=wUjhP3TTdTUVYdTmFxFwZuIs842mEiSYiywdwf+fLXewGMPa+/r6Rrd68JK4PX3b1o BuQwvWI4xAKQYhQYM9WFHkErC2GBZfL58qeQZ+tpr1i0gB/huwy9VnybIwYK3h5l1gYm IstM5FU9c43FYgqjfdkZzbqR2QoQQcLzmKk42BifHp5dbAECGpoWkA0BJQ5h40rcgG6C b8maZSiXdRgG9TD2axtV5/4IRZZzZm38CGaK+RIM7eXh+Udgpv3N0LuorqndO9FfhSUs jNv9mQSmbW1DVmEapu1Sobl9FDuBUnHvQXdGGxyAZAy9MJF0UKYJVosoZ5/fI3GcB1FG w8zQ== X-Forwarded-Encrypted: i=1; AJvYcCXQ+4CDnGdEsv2SwWVjidH224R3LQtZCZczWhD4YJrxTslGP81sZkw7+BYwGbwEjin+VLTy3UbcCktQdw==@lists.infradead.org X-Gm-Message-State: AOJu0YxaCUmtn5MVVg5EJfQJVjYaat+79Q2Xz84GSRxOa35ypOKnzZGC Q68Od2hPRVLi09ruaXGZpoPClBuVzI7BkphJqlFDOwpPjYQzAkDvcypoCM++yiM= X-Gm-Gg: ASbGncszQaMTl7wNpYcCNLVECDt8MhQYwHjIF9Kd4DzRKll6jP9tOgFsQxSX77r5N38 iQT9mnux+S2OG/09rC9RxyMFoNHfLXa+HVzILUVk5N6oZu2PXdiWPcbQs137n14CIocWa4PZJK+ GQwhMQNNgv4BTorcM2wBNr+QPhd+cIDStBAGBfUebeO4a4oQ4A1WXPP90WPoy2s4lEIh+bb2hBl 2wyLqIh7uiktSQaIhjdYSiEFcsnJy/VDyGkKHZ9tz8nhRy10pDt9/jqP5P9ZPkWuWPZHd+HOLxP Q/HudzRTumsoWwlk8+Cf06uKf2JtO2zZWtk3rVO4n+tg44QmQV27Nls= X-Google-Smtp-Source: AGHT+IGE4yR6cgBkkvQcZ0IHX6BsNq+H8UInEThSWisvqbLPPoF9w9oT5fD4cZTzd5CMtWIib7XuTw== X-Received: by 2002:a05:6300:6f82:b0:1ee:1910:803f with SMTP id adf61e73a8af0-1ee191082f5mr4625773637.42.1739074711624; Sat, 08 Feb 2025 20:18:31 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73073eba116sm1898410b3a.124.2025.02.08.20.18.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Feb 2025 20:18:31 -0800 (PST) From: Anup Patel To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Subject: [PATCH v5 09/11] irqchip/riscv-imsic: Implement irq_force_complete_move() for IMSIC Date: Sun, 9 Feb 2025 09:46:53 +0530 Message-ID: <20250209041655.331470-10-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250209041655.331470-1-apatel@ventanamicro.com> References: <20250209041655.331470-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250208_201832_243084_2E0F65D3 X-CRM114-Status: GOOD ( 14.38 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , Atish Patra , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Paul Walmsley , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , hpa@zytor.com, Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Implement irq_force_complete_move() for IMSIC driver so that in-flight vector movements on a CPU can be cleaned-up when the CPU goes down. Signed-off-by: Anup Patel --- drivers/irqchip/irq-riscv-imsic-platform.c | 32 ++++++++++++++++++++++ drivers/irqchip/irq-riscv-imsic-state.c | 17 ++++++++++++ drivers/irqchip/irq-riscv-imsic-state.h | 1 + 3 files changed, 50 insertions(+) diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c index 9a5e7b4541f6..b9e3f9030bdf 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -129,6 +129,37 @@ static int imsic_irq_set_affinity(struct irq_data *d, const struct cpumask *mask return IRQ_SET_MASK_OK_DONE; } + +static void imsic_irq_force_complete_move(struct irq_data *d) +{ + struct imsic_vector *mvec, *vec = irq_data_get_irq_chip_data(d); + unsigned int cpu = smp_processor_id(); + + if (WARN_ON(!vec)) + return; + + /* Do nothing if there is no in-flight move */ + mvec = imsic_vector_get_move(vec); + if (!mvec) + return; + + /* Do nothing if the old IMSIC vector does not belong to current CPU */ + if (mvec->cpu != cpu) + return; + + /* + * The best we can do is force cleanup the old IMSIC vector. + * + * The challenges over here are same as x86 vector domain so + * refer to the comments in irq_force_complete_move() function + * implemented at arch/x86/kernel/apic/vector.c. + */ + + /* Force cleanup in-flight move */ + pr_info("IRQ fixup: irq %d move in progress, old vector cpu %d local_id %d\n", + d->irq, mvec->cpu, mvec->local_id); + imsic_vector_force_move_cleanup(vec); +} #endif static struct irq_chip imsic_irq_base_chip = { @@ -137,6 +168,7 @@ static struct irq_chip imsic_irq_base_chip = { .irq_unmask = imsic_irq_unmask, #ifdef CONFIG_SMP .irq_set_affinity = imsic_irq_set_affinity, + .irq_force_complete_move = imsic_irq_force_complete_move, #endif .irq_retrigger = imsic_irq_retrigger, .irq_compose_msi_msg = imsic_irq_compose_msg, diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-riscv-imsic-state.c index 96e994443fc7..5ec2b6bdffb2 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.c +++ b/drivers/irqchip/irq-riscv-imsic-state.c @@ -311,6 +311,23 @@ void imsic_vector_unmask(struct imsic_vector *vec) raw_spin_unlock(&lpriv->lock); } +void imsic_vector_force_move_cleanup(struct imsic_vector *vec) +{ + struct imsic_local_priv *lpriv; + struct imsic_vector *mvec; + unsigned long flags; + + lpriv = per_cpu_ptr(imsic->lpriv, vec->cpu); + raw_spin_lock_irqsave(&lpriv->lock, flags); + + mvec = READ_ONCE(vec->move_prev); + WRITE_ONCE(vec->move_prev, NULL); + if (mvec) + imsic_vector_free(mvec); + + raw_spin_unlock_irqrestore(&lpriv->lock, flags); +} + static bool imsic_vector_move_update(struct imsic_local_priv *lpriv, struct imsic_vector *vec, bool is_old_vec, bool new_enable, struct imsic_vector *move_vec) diff --git a/drivers/irqchip/irq-riscv-imsic-state.h b/drivers/irqchip/irq-riscv-imsic-state.h index f02842b84ed5..19dea0c77738 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.h +++ b/drivers/irqchip/irq-riscv-imsic-state.h @@ -91,6 +91,7 @@ static inline struct imsic_vector *imsic_vector_get_move(struct imsic_vector *ve return READ_ONCE(vec->move_prev); } +void imsic_vector_force_move_cleanup(struct imsic_vector *vec); void imsic_vector_move(struct imsic_vector *old_vec, struct imsic_vector *new_vec); struct imsic_vector *imsic_vector_from_local_id(unsigned int cpu, unsigned int local_id); From patchwork Sun Feb 9 04:16:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13966648 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EA5A7C0219D for ; Sun, 9 Feb 2025 04:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ExNMvzogq+Y0cOv/uWbNl1TVVYdSsbo39ahMGzB6e60=; b=OsT2X76DYnPURc gEk2ABa5XoOMpurHX8v+FA6Mu7GU4CqOop6rt3wr4G/xgsId/PVcV+UFaDFTHByZEd9x1OFfrjVD0 D7nAnVs7DIHrYfPl2i6pMdsDLfJ1gIllb/gFWiiltjOapih/5ScomTg9uTrdB1in9AZR5Esd7G0nT dpZm3XT0oy+3b0S0+nla/WLMQpln0RlfcwsAoSKfFzN9a5Ir+Rk6iDosVtUQVHwPF4gRa/7i0ajwS 6ipXKsAIPCUDt7KeQH1dTHN/PpjH+hpmwKt/xMoAvdQD+hr19m+DNT3w0BJoVw27gFkiSG2YnMb5Y 0riM2WwGdm0rksU/BotQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tgyzy-0000000E508-1JN7; Sun, 09 Feb 2025 04:32:50 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tgymG-0000000E2hF-3paz for linux-riscv@lists.infradead.org; Sun, 09 Feb 2025 04:18:42 +0000 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2f9bac7699aso4843975a91.1 for ; Sat, 08 Feb 2025 20:18:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1739074720; x=1739679520; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2uqH0LlhZdZ1/ZJgerOy14gnMEDsVqG8t0Fz3f/FUy8=; b=TOi2f7YvdDCI1YjIVnHfKIIF8HkLUwjeIIZnsYt1FpeMDq8GS8dYcnqKnRrIxxllmv RV2RecWq4oSy5K+GfVEBYzmlw5t2YUzxVbU6XVk2e9zghV2XPoMr9WGwuBYdabjJ7p80 Ww+phkPZCVkPhxdJoOE+/JqMKb1t70Kk9KIdZymLjV/WotyoLAaYiL01a9smS6DEn5zy qn6StW9LEDnkurjITnRdEMxJhC3CieCsW/a6F3rxGiCwO0TdWStFBS55ihQU1X1C2E9Q mIS/y7NvaXCRXhLPPfJlKDnbiDMMKrIrI7MALnXC6nteANOJRbIkc9EenfLs4/KDjsmC VQ8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739074720; x=1739679520; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2uqH0LlhZdZ1/ZJgerOy14gnMEDsVqG8t0Fz3f/FUy8=; b=oqU7uNf5HH9hSFmMhBUZtIEo/ZMekcZ1FcGOFPhgEl6L+OzedSmyWDIhJpm89zyh2W dwJcKYGnTp6y+WRMQIBRvoQjAxSad+/kRJv4FfNsDvg535ANLLFnAG/upXtZ3KD1A1Vw jISNmSET6vqp4vkL6Qrrw7xy3E4l4Aj1o9sD61wK+WQ/4LuZX7iuy0hvSc07NMnpWoEP SeQ2qKPiqdkd8+0rn5xUsRkwzcsECNG8n61mhU7v6jsU0QVNd/b57wxYUCJDWTR/05cj nDDpiayTCJ6Sh9LEk+Uj5JrKR4OMssS68ieer/ecy5b9v7eanPnl9UyNMo3qYCk3Flip iE0Q== X-Forwarded-Encrypted: i=1; AJvYcCX33L5t/ilrbeE82mMdbg1ivTC1ikoU1tAnrFjNc40Gu2d2yDfyXH8/xKe7a3x8NOR2hVq0vErTh//YrQ==@lists.infradead.org X-Gm-Message-State: AOJu0YwkLGUszSkTeLKQ24kQO7q74dO1OU2ExoqP7FiMyO2dzEuJ8q92 GroPIwtcdGuCNqreOUPYpv3SMp1m9buIylI8BPlv39ENv3iXOMRuuR0h7IOQod0= X-Gm-Gg: ASbGncsmjeIPus1YKYUX4ehD9Tv4U6XJPlJS+FVo1dTobvmbFMrFa/IyhECG0nvnAyW RyCbZSH8DW01xgFxSO5JZ4vqPL+wbyC9f9DFSB6iFAKyWfIOozjj1d3n0M9aAFYF8t13JTbdsPS 4/GS3pU/YCPe1qYSA7vYTfw1mI3CTz7XTFNq3IP/pJTpXhO7oKr2LD1BDeIVgRg88BWl895HTHy OnMICo9z5ZdXeVngW/PBLyxYFIy0EoLlRKHXvPOCigR+JPiD52scNnP/vui4QGBXdaGNCa/IrQE DYT3awOlwKM+KMCf99VcwahIoAs7qbVkIdbqBUuB77hwR0yGVAKSk8k= X-Google-Smtp-Source: AGHT+IHUzy54yYs2fS4vJemZHOHOIs8APlSMaPpVV2klzUoQAT+FU5F1TyPBFlToppvPWeQiJJcXfw== X-Received: by 2002:a05:6a00:949a:b0:730:75b1:720a with SMTP id d2e1a72fcca58-73075b1752dmr5977536b3a.23.1739074719968; Sat, 08 Feb 2025 20:18:39 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73073eba116sm1898410b3a.124.2025.02.08.20.18.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Feb 2025 20:18:39 -0800 (PST) From: Anup Patel To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Subject: [PATCH v5 10/11] irqchip/riscv-imsic: Replace hwirq with irq in the IMSIC vector Date: Sun, 9 Feb 2025 09:46:54 +0530 Message-ID: <20250209041655.331470-11-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250209041655.331470-1-apatel@ventanamicro.com> References: <20250209041655.331470-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250208_201840_952494_B9E13FC6 X-CRM114-Status: GOOD ( 16.46 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , Atish Patra , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Paul Walmsley , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , hpa@zytor.com, Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Currently, the imsic_handle_irq() uses generic_handle_domain_irq() to handle the irq which internally has an extra step of resolving hwirq using domain. This extra step can be avoided by replacing hwirq with irq in the IMSIC vector and directly calling generic_handle_irq(). Signed-off-by: Anup Patel --- drivers/irqchip/irq-riscv-imsic-early.c | 6 ++---- drivers/irqchip/irq-riscv-imsic-platform.c | 2 +- drivers/irqchip/irq-riscv-imsic-state.c | 8 ++++---- drivers/irqchip/irq-riscv-imsic-state.h | 4 ++-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-early.c b/drivers/irqchip/irq-riscv-imsic-early.c index b5def6268936..d2e8ed70d396 100644 --- a/drivers/irqchip/irq-riscv-imsic-early.c +++ b/drivers/irqchip/irq-riscv-imsic-early.c @@ -73,7 +73,7 @@ static int __init imsic_ipi_domain_init(void) { return 0; } static void imsic_handle_irq(struct irq_desc *desc) { struct irq_chip *chip = irq_desc_get_chip(desc); - int err, cpu = smp_processor_id(); + int cpu = smp_processor_id(); struct imsic_vector *vec; unsigned long local_id; @@ -103,9 +103,7 @@ static void imsic_handle_irq(struct irq_desc *desc) continue; } - err = generic_handle_domain_irq(imsic->base_domain, vec->hwirq); - if (unlikely(err)) - pr_warn_ratelimited("hwirq 0x%x mapping not found\n", vec->hwirq); + generic_handle_irq(vec->irq); } chained_irq_exit(chip, desc); diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c index b9e3f9030bdf..6bf5d63f614e 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -111,7 +111,7 @@ static int imsic_irq_set_affinity(struct irq_data *d, const struct cpumask *mask return -EBUSY; /* Get a new vector on the desired set of CPUs */ - new_vec = imsic_vector_alloc(old_vec->hwirq, mask_val); + new_vec = imsic_vector_alloc(old_vec->irq, mask_val); if (!new_vec) return -ENOSPC; diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-riscv-imsic-state.c index 5ec2b6bdffb2..d0148e48ab05 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.c +++ b/drivers/irqchip/irq-riscv-imsic-state.c @@ -422,7 +422,7 @@ struct imsic_vector *imsic_vector_from_local_id(unsigned int cpu, unsigned int l return &lpriv->vectors[local_id]; } -struct imsic_vector *imsic_vector_alloc(unsigned int hwirq, const struct cpumask *mask) +struct imsic_vector *imsic_vector_alloc(unsigned int irq, const struct cpumask *mask) { struct imsic_vector *vec = NULL; struct imsic_local_priv *lpriv; @@ -438,7 +438,7 @@ struct imsic_vector *imsic_vector_alloc(unsigned int hwirq, const struct cpumask lpriv = per_cpu_ptr(imsic->lpriv, cpu); vec = &lpriv->vectors[local_id]; - vec->hwirq = hwirq; + vec->irq = irq; vec->enable = false; vec->move_next = NULL; vec->move_prev = NULL; @@ -451,7 +451,7 @@ void imsic_vector_free(struct imsic_vector *vec) unsigned long flags; raw_spin_lock_irqsave(&imsic->matrix_lock, flags); - vec->hwirq = UINT_MAX; + vec->irq = 0; irq_matrix_free(imsic->matrix, vec->cpu, vec->local_id, false); raw_spin_unlock_irqrestore(&imsic->matrix_lock, flags); } @@ -510,7 +510,7 @@ static int __init imsic_local_init(void) vec = &lpriv->vectors[i]; vec->cpu = cpu; vec->local_id = i; - vec->hwirq = UINT_MAX; + vec->irq = 0; } } diff --git a/drivers/irqchip/irq-riscv-imsic-state.h b/drivers/irqchip/irq-riscv-imsic-state.h index 19dea0c77738..3202ffa4e849 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.h +++ b/drivers/irqchip/irq-riscv-imsic-state.h @@ -20,7 +20,7 @@ struct imsic_vector { unsigned int cpu; unsigned int local_id; /* Details saved by driver in the vector */ - unsigned int hwirq; + unsigned int irq; /* Details accessed using local lock held */ bool enable; struct imsic_vector *move_next; @@ -96,7 +96,7 @@ void imsic_vector_move(struct imsic_vector *old_vec, struct imsic_vector *new_ve struct imsic_vector *imsic_vector_from_local_id(unsigned int cpu, unsigned int local_id); -struct imsic_vector *imsic_vector_alloc(unsigned int hwirq, const struct cpumask *mask); +struct imsic_vector *imsic_vector_alloc(unsigned int irq, const struct cpumask *mask); void imsic_vector_free(struct imsic_vector *vector); void imsic_vector_debug_show(struct seq_file *m, struct imsic_vector *vec, int ind); From patchwork Sun Feb 9 04:16:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13966649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE080C02199 for ; Sun, 9 Feb 2025 04:32:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=l67vx6+O+Gzz9kxEY1fAybGouRr4OJWWYxHIz/fmS4Q=; b=diyPgotolpePER g2/zSSTY7bzCilr0SdWIlK84PQMRLWSGyPCPjSlgtYOXGDh6nKLRA0841k2RHLeEzjqf5Gg1vXS/6 xtBFFpOPVkPrIZbPJEWjoYCTp/DlC53nEYaQ8/OUF7iSxcffaIAYGA7BXrmP1yuSX/WT5TrajYY6U Fuob2zjkzn4WWjd0ZG0muStYIuM3pWgag1OgKErxeF8CcKma8Z4TDnjQYtQI1YO1XCyzf66RVSNS8 w43fXIXhY/Dszvogh2YrAGEZhVgH+NKsY6FS3yyp5P8DJEKCHmItnJzvYb8QV/BYKwHr/VPFyM0HF 7bcWZ7HHsNAB3xk6XO6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tgyzz-0000000E50N-07VM; Sun, 09 Feb 2025 04:32:51 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tgymP-0000000E2lX-1qF4 for linux-riscv@lists.infradead.org; Sun, 09 Feb 2025 04:18:51 +0000 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-2f9bac7699aso4844038a91.1 for ; Sat, 08 Feb 2025 20:18:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1739074729; x=1739679529; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KEjndyBD35lV6nr6NSLWRRyly4db2axy7koFOHZTKsQ=; b=CrX4FJud+8PLqilHcLMUJvGFX7l5ypDZVsamK/wbsufkTHijrWP/+DSRasNrGY5zbm geBTq639QkwYl6YLUvOJnqZi0RaZAI8jcGQfCoInMN+awl6ox/kfDiXJXh/jlcxMfW5S 799Jr+cBnYbVffEC1R3ANniIB4qUFpDH0FEV2WEJTqAkFFRFfFbREr/qSFaovQfMmHF1 cPriR6IVo+abpImm1YLLctjhSXqtxmG3TZvAnQeuWxTrw2UYWVMzlDau5+Xg1Hk3cYAx IN0JybrYii/v4L8iu19vngNVrVzUxitkwqY7gBIvHs2iFc/Ur0fdBincBFXluy/Dtb5d VYCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739074729; x=1739679529; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KEjndyBD35lV6nr6NSLWRRyly4db2axy7koFOHZTKsQ=; b=w9KOOaT4eOoHNv9+2Jcm/lGbwSmVD4eBMT7O6NcbKenl1kX6rA5FzE62gjPyn+h7Ri XHUgld7lS7xqdh1djNl7gS9Ve0U2vOjiANJHJeET45isgBkWVCOzZQF7121PiC5jCzlR +NjoDpukN8Goj7rvK3B5Fb+WUc39OeVHET5I4qkU0tjAlkowy0A9p1JvVUJFey/od2BU n3GmYPylTWA9fZVeu5jYsRnXITuB3kX0lQTICws2uHuN91KW/A+C+njegHTzp5WhYJCl gCyd+lMY/ArxUyAQIdqEMBBRw9ZXxJZ720itxUf+yEUajcVHdrGFvlWr4+8gOg5iQMau jkWw== X-Forwarded-Encrypted: i=1; AJvYcCUmcOKraBbGj70gVJ06/KuvAaY21i0vC3govqRebRhJ54JkvHYoYDSkaYyDwk+EtqaoJqOgTESW7KQDkw==@lists.infradead.org X-Gm-Message-State: AOJu0YyR2rCVp3dNXalnf6+5OeBKot6C14xc89eJRZuuwpGlDcCB36ix 107cVQzj0j39TxswkFnvGYMqc9XnJLozhayiQYjrUJMoQxqG4zJpZ4v5iy4UxF4= X-Gm-Gg: ASbGnctB38ww+ddeHz4URoxBx1Fqo9L4w9T6PN/nYHvIk+VxCf90E1I6KmThUTil0+8 gI97OIASqEHrJy+zhLDmsF+Xo6hkd4uPTj+lcRr280FytmVrD9beT+pHQIXyaVmyNC/bihw0R6h 5PAIkA6LXlB3/lZuO3CalQDhYYzVFcs71ydr1FWa+aMO7LI90cquqfDygrjWs3ER+Zi5PUUcrQd BFNRU5gu0pF9yrlRuULSNea+eAdZIv7aKyECr2c+T1PkZwj9Hc29CqAAb5jd4tYhtUylvQGgXM6 49G5z6Bd6W85VgjlpKQi7X5Vkk2GknT8nXwNdRkFScSbIj0WFfj+xvU= X-Google-Smtp-Source: AGHT+IFzlqSdIaYHLSZI599cWVBA7dW7jlgFu/OL/NbLRylvBc/ItMiequCd7pzuj7u4ZD8d08JvJw== X-Received: by 2002:a05:6a00:2342:b0:730:7d3f:8c70 with SMTP id d2e1a72fcca58-7307d3f9339mr5011190b3a.21.1739074728662; Sat, 08 Feb 2025 20:18:48 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73073eba116sm1898410b3a.124.2025.02.08.20.18.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Feb 2025 20:18:48 -0800 (PST) From: Anup Patel To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Subject: [PATCH v5 11/11] irqchip/riscv-imsic: Special handling for non-atomic device MSI update Date: Sun, 9 Feb 2025 09:46:55 +0530 Message-ID: <20250209041655.331470-12-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250209041655.331470-1-apatel@ventanamicro.com> References: <20250209041655.331470-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250208_201849_483379_45D3E908 X-CRM114-Status: GOOD ( 21.70 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , Atish Patra , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Paul Walmsley , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , hpa@zytor.com, Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Device having non-atomic MSI update might see an intermediate state when changing target IMSIC vector from one CPU to another. To avoid losing interrupt to such intermediate state, do the following (just like x86 APIC): 1) First write a temporary IMSIC vector to the device which has MSI address same as the old IMSIC vector but with MSI data matches the new IMSIC vector. 2) Next write the new IMSIC vector to the device. Based on the above, the __imsic_local_sync() must check pending status of both old MSI data and new MSI data on the old CPU. In addition, the movement of IMSIC vector for non-atomic device MSI update must be done in interrupt context using IRQCHIP_MOVE_DEFERRED. Signed-off-by: Anup Patel --- drivers/irqchip/irq-riscv-imsic-platform.c | 73 +++++++++++++++++++++- drivers/irqchip/irq-riscv-imsic-state.c | 31 +++++++-- 2 files changed, 98 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c index 6bf5d63f614e..828102c46f51 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -64,6 +64,11 @@ static int imsic_irq_retrigger(struct irq_data *d) return 0; } +static void imsic_irq_ack(struct irq_data *d) +{ + irq_move_irq(d); +} + static void imsic_irq_compose_vector_msg(struct imsic_vector *vec, struct msi_msg *msg) { phys_addr_t msi_addr; @@ -97,6 +102,21 @@ static int imsic_irq_set_affinity(struct irq_data *d, const struct cpumask *mask bool force) { struct imsic_vector *old_vec, *new_vec; + struct imsic_vector tmp_vec; + + /* + * Requirements for the downstream irqdomains (or devices): + * + * 1) Downstream irqdomains (or devices) with atomic MSI update can + * happily do imsic_irq_set_affinity() in the process-context on + * any CPU so the irqchip of such irqdomains must not set the + * IRQCHIP_MOVE_DEFERRED flag. + * + * 2) Downstream irqdomains (or devices) with non-atomic MSI update + * must do imsic_irq_set_affinity() in the interrupt-context upon + * next interrupt so the irqchip of such irqdomains must set the + * IRQCHIP_MOVE_DEFERRED flag. + */ old_vec = irq_data_get_irq_chip_data(d); if (WARN_ON(!old_vec)) @@ -115,6 +135,33 @@ static int imsic_irq_set_affinity(struct irq_data *d, const struct cpumask *mask if (!new_vec) return -ENOSPC; + /* + * Device having non-atomic MSI update might see an intermediate + * state when changing target IMSIC vector from one CPU to another. + * + * To avoid losing interrupt to such intermediate state, do the + * following (just like x86 APIC): + * + * 1) First write a temporary IMSIC vector to the device which + * has MSI address same as the old IMSIC vector but MSI data + * matches the new IMSIC vector. + * + * 2) Next write the new IMSIC vector to the device. + * + * Based on the above, the __imsic_local_sync() must check pending + * status of both old MSI data and new MSI data on the old CPU. + */ + + if (!irq_can_move_in_process_context(d) && + new_vec->local_id != old_vec->local_id) { + /* Setup temporary vector */ + tmp_vec.cpu = old_vec->cpu; + tmp_vec.local_id = new_vec->local_id; + + /* Point device to the temporary vector */ + imsic_msi_update_msg(irq_get_irq_data(d->irq), &tmp_vec); + } + /* Point device to the new vector */ imsic_msi_update_msg(irq_get_irq_data(d->irq), new_vec); @@ -171,6 +218,7 @@ static struct irq_chip imsic_irq_base_chip = { .irq_force_complete_move = imsic_irq_force_complete_move, #endif .irq_retrigger = imsic_irq_retrigger, + .irq_ack = imsic_irq_ack, .irq_compose_msi_msg = imsic_irq_compose_msg, .flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_MASK_ON_SUSPEND, @@ -190,7 +238,7 @@ static int imsic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, return -ENOSPC; irq_domain_set_info(domain, virq, virq, &imsic_irq_base_chip, vec, - handle_simple_irq, NULL, NULL); + handle_edge_irq, NULL, NULL); irq_set_noprobe(virq); irq_set_affinity(virq, cpu_online_mask); irq_data_update_effective_affinity(irq_get_irq_data(virq), cpumask_of(vec->cpu)); @@ -229,15 +277,36 @@ static const struct irq_domain_ops imsic_base_domain_ops = { #endif }; +static bool imsic_init_dev_msi_info(struct device *dev, + struct irq_domain *domain, + struct irq_domain *real_parent, + struct msi_domain_info *info) +{ + if (!msi_lib_init_dev_msi_info(dev, domain, real_parent, info)) + return false; + + switch (info->bus_token) { + case DOMAIN_BUS_PCI_DEVICE_MSI: + case DOMAIN_BUS_PCI_DEVICE_MSIX: + info->chip->flags |= IRQCHIP_MOVE_DEFERRED; + break; + default: + break; + } + + return true; +} + static const struct msi_parent_ops imsic_msi_parent_ops = { .supported_flags = MSI_GENERIC_FLAGS_MASK | MSI_FLAG_PCI_MSIX, .required_flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | MSI_FLAG_PCI_MSI_MASK_PARENT, + .chip_flags = MSI_CHIP_FLAG_SET_ACK, .bus_select_token = DOMAIN_BUS_NEXUS, .bus_select_mask = MATCH_PCI_MSI | MATCH_PLATFORM_MSI, - .init_dev_msi_info = msi_lib_init_dev_msi_info, + .init_dev_msi_info = imsic_init_dev_msi_info, }; int imsic_irqdomain_init(void) diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-riscv-imsic-state.c index d0148e48ab05..3a2a381e4fa1 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.c +++ b/drivers/irqchip/irq-riscv-imsic-state.c @@ -126,8 +126,8 @@ void __imsic_eix_update(unsigned long base_id, unsigned long num_id, bool pend, static bool __imsic_local_sync(struct imsic_local_priv *lpriv) { - struct imsic_local_config *mlocal; - struct imsic_vector *vec, *mvec; + struct imsic_local_config *tlocal, *mlocal; + struct imsic_vector *vec, *tvec, *mvec; bool ret = true; int i; @@ -169,13 +169,36 @@ static bool __imsic_local_sync(struct imsic_local_priv *lpriv) */ mvec = READ_ONCE(vec->move_next); if (mvec) { - if (__imsic_id_read_clear_pending(i)) { + /* + * Device having non-atomic MSI update might see an + * intermediate state so check both old ID and new ID + * for pending interrupts. + * + * For details, refer imsic_irq_set_affinity(). + */ + + tvec = vec->local_id == mvec->local_id ? + NULL : &lpriv->vectors[mvec->local_id]; + if (tvec && + !irq_can_move_in_process_context(irq_get_irq_data(vec->irq)) && + __imsic_id_read_clear_pending(tvec->local_id)) { + /* Retrigger temporary vector if it was already in-use */ + if (READ_ONCE(tvec->enable)) { + tlocal = per_cpu_ptr(imsic->global.local, tvec->cpu); + writel_relaxed(tvec->local_id, tlocal->msi_va); + } + + mlocal = per_cpu_ptr(imsic->global.local, mvec->cpu); + writel_relaxed(mvec->local_id, mlocal->msi_va); + } + + if (__imsic_id_read_clear_pending(vec->local_id)) { mlocal = per_cpu_ptr(imsic->global.local, mvec->cpu); writel_relaxed(mvec->local_id, mlocal->msi_va); } WRITE_ONCE(vec->move_next, NULL); - imsic_vector_free(&lpriv->vectors[i]); + imsic_vector_free(vec); } skip: