From patchwork Wed Feb 5 15:59:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13961463 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3EE8192D6B for ; Wed, 5 Feb 2025 16:00:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771207; cv=none; b=JJlAWLOkcKKBpomb798MmHPTT4ZqIBWmPGGJ3TvWZpo8I2GPW6BoIisQI2pmPC3KlX8Gn5Qmx6HgtPuLe/KFDUK0ZmyZV3hNgKCqTvkt9ENZbrcQtNgghPAHqrpMQdfE5Z1gA+I4E99dlHGOibKswAJE4a3nJaEPdRgfg3M21LE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771207; c=relaxed/simple; bh=gGGEYK7VGgFWWdh/qLZbuuJY+xZwb2aTgVHnwmrr23c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g0ejduOIFraWWXEER54EkgNPWiTwo61VGWFL85UkvjNBWFJwmUNZIc+IwmaQqDv37VjbXLcjOWEB7SEvfSaq3LHq2f5Wv6+gvMyyvPOZcm1rTpj+DFKzH3JAojbZ0w5AaTHb1TKA9ZGKtRtfwD/UOehAMPNOAVLYCirg/BDBxj8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=PW163WNt; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="PW163WNt" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2164b662090so135448385ad.1 for ; Wed, 05 Feb 2025 08:00:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738771205; x=1739376005; darn=lists.linux.dev; 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=PW163WNt0Or+B7V3NJxx7k4Ai4a8xWM7BMOt0Tdx1iAXzpwynb6ZEpOADew1zB6VHK fELSRsX0+ZHzu5dW8g4/+gr7AlExt2v3mIyqo65mnnih3v7g931Hogj47VvtiyyZKrt5 OZlejyIoq6IeQ6KSOjE18QW1naFa5Cu1EfnxQbINMd2Ro9FTsJ6g5fJdMxPxvoJ/Jwvh bkoHrA5Y3Jn8Ldkj29rfV0dtKpDXb/axHnXytkFcsehFDyuiejq6L4azUyd7vomGPNwI xAuPpw37BSjUOJa2LCcouTU48Q35PapFPaLU11zu03K3A6J3aByu5PHIjP9bw40C2Oh6 yIxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738771205; x=1739376005; 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=wY7ZEB23VzRkOy0csvtvk3EtKvSD776tTqqshAgefLBLvXfwntT2CWeIIwq2N2JuhZ 8xex/qAVXn5piAlLtJRG2CCWX4jiOg13KwS+ReDz8ENXPuc5JIj7ttE687x24wqSQqpo +a47MkLbqM7JN5RfRnMIdIQIZ28l6QvaA2p0v6g4ODLBkGTRPNGlZmgMn+udhosHPWrR Q9j/JP5Oq+gs2UzbY1TIa5PKuKfElZHf4KJUlMXWqETa32v/qrmCsw0NaKXoqaNfCk8e xGdMc2NUVXdg2ABPfWOkU6Zic87hEPmnzT5Nmmag478hjzSqymRMZHoRjOI02DJ//dDf OsBQ== X-Forwarded-Encrypted: i=1; AJvYcCXI6uKXbBX2n6UDhACUkkRXdnH3Rx1c9bbTvlq9EKq98F0ZGkt/eAWR3OGtqbI9f6EK4xY=@lists.linux.dev X-Gm-Message-State: AOJu0Yzr3HdICPxMGhM1vgfD64iJCrEH2SlSQbEGsCKeWsmTVW1+RaBv NHg4IL7LVSB80srsnPYd3EQ97Nf8V07HzDeisQL+nDuMFEjzewjpLzxvEe7mn1c= X-Gm-Gg: ASbGnct16gZpSK1pjOlSm+akTWLUQt4FJcZ1kn9xWHrYZ27EF4QPgwdu+/k+CC8fp/6 IXmozv6Ay70W3MSAMW3cVKpLRdYaoWRl533GqYXaQRx2gpC6Jz+9yfFO89AePEqhOzENjauwJBE Qog/d4Ryg5Jjot3Dc9TRySLkBEh85SlsXY1PJmr9qD2fD6kqJ4HBGyeuQwkyh7Bg7OdXrPOwy8l flN+4O+f8cfwwV1gVYUQM7ld09Z4unQEtrAzt/1v/rFF9CuQgjJu2oDblmONli11qdDOznK55+l so0DhyqhiwpUosZRiNWJril1ueoOB0PjmjnU5EQboS/EnB+xYKlIR1w= X-Google-Smtp-Source: AGHT+IFxrHkC5lry9v73hirVrwz0VwaueSl7vlCr1NVutMq+Q53roymPHtPchmK1sMCpMcVptQ1tdg== X-Received: by 2002:a17:902:d28b:b0:216:410d:4c53 with SMTP id d9443c01a7336-21f17ebba71mr44908125ad.41.1738771204969; Wed, 05 Feb 2025 08:00:04 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21edddf883fsm99369015ad.4.2025.02.05.07.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2025 08:00:04 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH v4 01/11] irqchip/riscv-imsic: Set irq_set_affinity for IMSIC base Date: Wed, 5 Feb 2025 21:29:37 +0530 Message-ID: <20250205155948.81385-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250205155948.81385-1-apatel@ventanamicro.com> References: <20250205155948.81385-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Wed Feb 5 15:59:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13961464 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82462186284 for ; Wed, 5 Feb 2025 16:00:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771216; cv=none; b=Wk55NDjEIU+alPFvv/8i7eYnDBSN1ABxsRpXTJuGBjrENZMMQ2QQODx93/ussDgesqs5eEeKMx2kn0yIzXG/bxYJasilFhCdnd9WLlJiiFtBYr2AFn9SszUrWb8or3+kHzfgYcZvnGESFtNmRZYFQ/z7ecrd5y4vgE/smHMZ0Wo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771216; c=relaxed/simple; bh=GQ6h6qnifBeRvwI5lbrzx5DePz9FG/7AwYjLLcTRLyo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CF5qvrINY4XXDoFPtruK16ugbmlPhrfbFa2O2HTapiImsG2OAwBcf/20ykNKyBR0b6RVrABwq8C4MmiDQoG9KAwKRcDeZWtGlLLizVDAmQLn/KYgD1av3LCQzhl++W7CW9EsTwV84jCo5CXg/YC33RMr95Qqx9WQl/dLjhBaIbM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=DSQPySox; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="DSQPySox" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-21661be2c2dso118822925ad.1 for ; Wed, 05 Feb 2025 08:00:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738771214; x=1739376014; darn=lists.linux.dev; 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=DSQPySox5YZKmRZcWGsH2Wg8vIT5EphL+f+tNa3oHQFABkNAHKwUUFlmC8Wmo1wLdL Ehju5PY9ABlxjJb1gpYCla5lYU0R8wiUasvXQeMiwu6dewwieEmNXN1kj7mTCat3PQpY 0icUNDzAEoO0DZ0e6BI5qrVuJ5anwvgUCU1Bq/AJ7TDfi/KrIzXreefHdBAzVveEmu80 RD74CUZl+La9WVLE422M8guVcc49phPY031AZYGpbvdIP4PkzzWmtZnq73HCxIk7Q+bM zSrPLNLRNAXzVuapsrbqJA6EFqPxnIsWM7z6pCCIrqRz3YmHF7fQcEVLUBkvR4PLfVIY Uk9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738771214; x=1739376014; 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=LqNsJEejkYub1d3dnxT22yYXqzw50kmdxq5CjTIcfd3xEIPttQwoxfVTfo+nfH7mJ6 O44Gp0Ka9KKskEowwZfK6X0rJ9Q1vhmiLZ4d/vDkR+BGDWZgsMY4amvofkpPhD9KrRlu vTy9dKyMyaSIa3+0s50Tuw+/5mAi2opTwWjgntj4orMC5tlT+ENk4rAFTBH1A6mpHWDm XENrfxVmuU5JBjOjlYhruMxrQMGXAiT3TZmT3gJLZI1M702VjRu9hnvoW4VRwfeLdgB2 kO2qMtWR4N9TliVBLgAzJVQ/ZiDfcyn0wL4Gj2eA9t7BLSeJZ4OwpZVCLdLCXpY2y5HF DL2A== X-Forwarded-Encrypted: i=1; AJvYcCUoCWclxH3dcC7O3zu92wi/WOVQto9kUThTjjlPCLqBGYMT1s2qKMJggpR9OzF7QfVN1eA=@lists.linux.dev X-Gm-Message-State: AOJu0Yw7c1twGWhhgU+kVavt8HjQMnuiuoXakO8iLSUyQhb86Xi6GQx5 Nxe2NeSNsUITA5RAwmw+BA+TWPAgHhBL0Bw5dppp/jXA5P7tq1L1RZnAparQn3I= X-Gm-Gg: ASbGnctalp3gs8rjdzITWl9kexchxQ3xlfaVfSh9dxW8cO7pqB1aLSDKUJYQBfxYkS+ Nm2Q24clPL5HwsYpQch7xp/UTmYQB2nN6OiBZIZgCJwlUcwB86b8R6h6d3M7ZE2fchQktuplwtz L3ZrCC0DcfCazNf32MBmONrIUpvoYUJ4/MMuLEkrFGS+iSkdVeMbyfpgS3u5VT5H92h1eNm8gW0 u3XYWf5VlrZU7T7QMVtho88hygP7fRURLxHqqt1sKCE7XrPk4+Blm5V+nHUQvm60ynhQgVCfPyk SLlE3+EvyBiVEqB6wIe6mf9aueuSPkrZs209L/c6g0P4tweSg//SLKI= X-Google-Smtp-Source: AGHT+IEwSqSk0Kn6tNM2Qd+4lhHoUFawjz0vSYYqNHq2adsR6hxf2+kmSVPrfORkTmMSBvoi8q34cw== X-Received: by 2002:a17:903:2282:b0:21f:45d:21fb with SMTP id d9443c01a7336-21f17df5c2fmr55285685ad.3.1738771211403; Wed, 05 Feb 2025 08:00:11 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21edddf883fsm99369015ad.4.2025.02.05.08.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2025 08:00:10 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH v4 02/11] irqchip/irq-msi-lib: Optionally set default irq_eoi/irq_ack Date: Wed, 5 Feb 2025 21:29:38 +0530 Message-ID: <20250205155948.81385-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250205155948.81385-1-apatel@ventanamicro.com> References: <20250205155948.81385-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Wed Feb 5 15:59:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13961465 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 746FF1993B2 for ; Wed, 5 Feb 2025 16:00:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771223; cv=none; b=DrBZlnSCmBFRnbGC2Tf5cUrfCecqKIS+36XiApuZ8KpvDLqsoUCms2OeSaOKr0LyASuNnfYAEu7N8TsJwh11Y4LhlXNVXK7HhpqouGQw38Q0s5OKk4qzcdVCUquLpe/V6lAjczsk2QsBI43I+N4sG/6Jtd5rJQS1Glw0nxGLclU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771223; c=relaxed/simple; bh=tqqED4GgT6fv8GxxWX7wObYflu49BH84mKUSrCVBeKU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W+uhqC6q3f8ToRH/qAqDcYGgCy9tnMq21tcYsdc8JH8AE71KeDKqaTaYoO8KjgJt7+7U5OoVbAvo9vXw2N/DSxkdX+n4fy4UppXVYJ/7fKhg+kBIMrgsDb4ufGGXBL91nINUn8iap46gp4UC8t76XER3UdS/0K4KMMllJWJmWFE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=M8a0T2eW; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="M8a0T2eW" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-216728b1836so122741205ad.0 for ; Wed, 05 Feb 2025 08:00:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738771221; x=1739376021; darn=lists.linux.dev; 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=M8a0T2eWJLgPOxKLgGU5DWWzUrA0LaCIn3a+p18jDQf7Xo9wWNS9RS9zE9Y2DahEDo PyvWF62k/t2ybXjmQO4W4krD24+7h3LLAf+veiE8r68d4Dbblq7P+gXaREiN/UHCBxHJ k1L5m4q3E1ugqmpWq+/ROeKw1IgZW7W4n4WjzOoi7SdLmEZuSr5oYLThN9lY4fCvLYXx 0mHh9KxoZ/RTpnD7+9aCorfYn6xKfi2sPYPigkvFIPy4yLgsncHtmOq7OSzuQI/27V7U O60uDQil01e/uyjGXQwB13JsPC44LYVDQ3dwUHg9QJsdklPb5idip9gM1Nk3MON+24Yh Dk7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738771221; x=1739376021; 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=eeounI7rWuVg8piS0iNPjqiWaGAdR13/joyGYqVvVaTdcq1Ua169R618X0vF05KzJa IPufMc5z7rgf3fBbbUpgna/WToOUiIj3fLldhJd4yL6XQkXC/Irgg4Sn6oCD8xKcm/gt LLYcoFgP9jYe7XlOnrqcknb/SlZn/i0ljt6ouZZ7yv7G8FiB8QJZERwWNEVagM5Fb4r6 9D9+T8w+7Nedv7cBYWioJ99vSU2bU5vrnx5HsY0tMoxij71CMSZwJuQBgpzCZfL50wT/ /oinzaXYTZq6Stfu8TCnVmCnMuEctzJ3Sln1hiGF7uZ0urVy/ekJMg5Pq1Kq+5/LNgP6 +LIw== X-Forwarded-Encrypted: i=1; AJvYcCXH2HeBxKzkcqsR1eDF5UBmm6FjzY9gIL92fGskFqKMJJUlGJRQ1/MwEjCgTcEiWlU9Tsg=@lists.linux.dev X-Gm-Message-State: AOJu0YzCjf4D2qm9kRHJMpOcpAiiuoP0ku+vMaHZqGy7QJ7nnNMDVwC0 35yLB5hlJrEVCJ9f/D/cKjp21lQMLrKzU9+AFyuJeFt5Ge67RycRB+UGwmAB7Bg= X-Gm-Gg: ASbGncsWW4XQriKjBDEX/Hculbkf5GLiWxAj2vgOWHZg5UlBgKdLsth9Q/0jrui8CCS fi6FCghV8SM2G9BkhoJQeXFSnyfwYJLOAE6juXaGz3IgkLJ4uAgN+7c0IDN3s6TEZKZ1xZhHz0e ChsKx/3PYLnEXGl0tPU4JpDLOfvslLLXVCTJzjNbuIC99rbuCrgiwXeBRpwKJRr/Tl2hZPzqEny PE+4iYwgeJtqtqueoUtbSCWrn8gZMNbE6sW/8y4u7dCMgo9gOOqqQvbw8/xHAisVX6jwHceKKw8 iwL9pHw2niiZlSr1kCDSZxmFgYP5eT4L2TMrMPW+Pfr4A+FB7mqt08c= X-Google-Smtp-Source: AGHT+IE61901PT4EUuxStQafEIq8FwJCGiiY6kWb9NQ321aRytwKILvXZvBacg0xie4XwDelkjOESA== X-Received: by 2002:a17:902:f68c:b0:21b:d105:26b9 with SMTP id d9443c01a7336-21f17e45b7emr53598095ad.16.1738771219978; Wed, 05 Feb 2025 08:00:19 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21edddf883fsm99369015ad.4.2025.02.05.08.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2025 08:00:19 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH v4 03/11] irqchip/riscv-imsic: Move to common MSI lib Date: Wed, 5 Feb 2025 21:29:39 +0530 Message-ID: <20250205155948.81385-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250205155948.81385-1-apatel@ventanamicro.com> References: <20250205155948.81385-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Wed Feb 5 15:59:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13961466 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58CFB1DA617 for ; Wed, 5 Feb 2025 16:00:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771228; cv=none; b=TuPZpoTqvsLfCGh4PPFwflZKToxW4UUQf16T0frl8FC1uhMxRFx8+R/RSv5yoNIwbrKKW5121MTHYIvsqo+j4jDsdh/3YodWRgJYHmJic6fRHknWmlDpWjqn8BJHEQ+AJc2X4dguMUcZ/rz2rJigB1CUC0Ra8TpPnovkygBwtSY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771228; c=relaxed/simple; bh=3zBJABDp2VjAHeAkIM6CLZBnc4fskYwTWZG6ia7OHWI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UD3OlQmI6slEbxE2PsiWbA7vwmXnzVVDN3WtBCMK57KH8GZobnF4s7sgYPCRoc7ZEk46KUcJgWlUXxKb3+YkFnpWJsv/nksvhH4bCGGZ6XFPmgE3+6TUOZG+vABFjTbuTY9b4OVrirA79fUyyH7FVTYWg+8SB1W+yHp6JJrGgdI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=b7+keG3g; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="b7+keG3g" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2164b662090so135455905ad.1 for ; Wed, 05 Feb 2025 08:00:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738771227; x=1739376027; darn=lists.linux.dev; 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=zXz6fvQA0XjFVpb2cpM8OodOs5mmbZEn6PcelI8ZWow=; b=b7+keG3gW+MqZVyVeN5EaT2bAE1sEDzdE6TYs8IWwuCgcH8nZOtifVEyeohEjTKeB1 kypVJwNfCZ3iqTwJoB0waRVO1Vp5K2Dz2lKxbvj/ic98eboG564fam5AcfrLMsZldUmH ViepYwEOF6Rgyyfo7fut8YtgMNCUsCviXQKvvL9CI/4GvM7/yoJ/Fvnm8tUPw5kWVKCh DUnz0LW5/miuXgN2mxGgOEPNuEP+NnfIPoYPodTUKrb4tcIYbjqGorv33FnSxEJVyvhB /hKLVFzMWbkuUNxme5vYTNLcb8zxcx8sUVXuMMMC5njHwpNMHPitOZAyPn/t9HAIsdUm Iekg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738771227; x=1739376027; 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=zXz6fvQA0XjFVpb2cpM8OodOs5mmbZEn6PcelI8ZWow=; b=u/rxyDIukg7OPCJD+aYR4cdsAR2Q/eay/D53SkOlwGQkPF5v0eVhFvk5XcKmXtVg9U 2E0FYoMu7bYbY016DGMWAxWZ2Bqw1Nr9WwBu3VWpYkJkk0+kahYZdV5qLUaW+iBsCFy/ 5ux39tA+i2s8wh39oY/og9wM5z5Y4dxt71Cupm++o/0UN70rVnLUe5pDr7EEj6HUngZ8 /QEKnXaLd8QeGIPsliWrhDHxVb5G+J4jf9XdKzNfZ/EPAPRt/xh4JenieBlU8XNJmVVs s9CxrPbCRUQmWp6vE7hYJwEz4TPyDCazP9QFsltYrgdJbrrMnTjjsSOu3JicK08kiNWU KvSA== X-Forwarded-Encrypted: i=1; AJvYcCVXP8gIzADQEUS/i1W3oAKOggsiZVl7dqe05heOLnFzMkkH+17FX9eCn5ZztCvSCS7/BpU=@lists.linux.dev X-Gm-Message-State: AOJu0Yx5wL+aZI9B9lWRXoxkzp047cYA6KeMNqiw82+DfpG4CGuKv/UV KO/bwPDw7vVuCQlVrdpw34qAEYIL46ulRuhNzeiArvYIgJLE5nT/5a3PCDi3WiU= X-Gm-Gg: ASbGncvsEfCXBADJcbc2ifVxxZ9nH8mmJIjbeSyAQjpkM9n4BSYu7F0szgoJqy7RGZs KYo9drIKSb7PLaF/gDNNn5IVKotq0cv2zDW2TBeSxYMYkzS38uBes6KjLIOaTJLQbFW9gkJJ+AI yvtoNXRcWWkcN8aR5pe3ECuvBXppT9NUHXXpYsQqdYgPRliTR83pCKwhIF1rdM5GFAqXuVY+BVF D4PrZ16ebvkz+m3DYtssyWousKpGQTAPEWCjdQLwwfeLw2ixMPZIsvP4RufhGMofGYgf92TSbQU zWX0zxuaflOGYmmiZ66anW58G3XP2o2imoYy33qqtzMNnrrpydComgE= X-Google-Smtp-Source: AGHT+IF8jFyxyV/f5JzHUJJ21FDiQHGu6kpLDQlz+2/R29XsqdFXb5Fuvhx/j03+dIK/P/pfOWQ0WA== X-Received: by 2002:a17:902:ccca:b0:216:2bd7:1c27 with SMTP id d9443c01a7336-21f17ebb95cmr57042015ad.33.1738771226541; Wed, 05 Feb 2025 08:00:26 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21edddf883fsm99369015ad.4.2025.02.05.08.00.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2025 08:00:26 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH v4 04/11] genirq: Introduce common irq_force_complete_move() implementation Date: Wed, 5 Feb 2025 21:29:40 +0530 Message-ID: <20250205155948.81385-5-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250205155948.81385-1-apatel@ventanamicro.com> References: <20250205155948.81385-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 common weak implementation of the irq_force_complete_move() which lets irqchip do the actual irq_force_complete_move(). Signed-off-by: Anup Patel --- include/linux/irq.h | 5 +++++ kernel/irq/migration.c | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/irq.h b/include/linux/irq.h index 8daa17f0107a..1884fa4ec9b5 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,10 @@ struct irq_chip { int (*irq_nmi_setup)(struct irq_data *data); void (*irq_nmi_teardown)(struct irq_data *data); +#if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_PENDING_IRQ) + void (*irq_force_complete_move)(struct irq_data *data); +#endif + unsigned long flags; }; diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c index eb150afd671f..2920024475a3 100644 --- a/kernel/irq/migration.c +++ b/kernel/irq/migration.c @@ -5,6 +5,15 @@ #include "internals.h" +void __weak irq_force_complete_move(struct irq_desc *desc) +{ + struct irq_data *d = irq_desc_get_irq_data(desc); + struct irq_chip *chip = irq_data_get_irq_chip(d); + + if (chip && chip->irq_force_complete_move) + chip->irq_force_complete_move(d); +} + /** * irq_fixup_move_pending - Cleanup irq move pending from a dying CPU * @desc: Interrupt descriptor to clean up From patchwork Wed Feb 5 15:59:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13961467 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0339C195FEC for ; Wed, 5 Feb 2025 16:00:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771235; cv=none; b=taTrE5/pVeqfOOyIg+ICpe44Bnq5/mUvDaaXgVeZIfo1TjMnDB/WrB95PY9W0mt8DVxYWwlimGAXLqQNqFkt8iL03kO2QnKThgo1n75rSyRYws6Arl9e4YV0s3tgWNqSRJYzgzEH6cEIK12ayR+I9YF4JAIYyHO4Lhb8I1/p+P4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771235; c=relaxed/simple; bh=zAamzhUEpJ0Ntfo7PXDoXhLHzC064WJshCcKxat5Ftc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TQ4WoUGBoXAnzCUww8pyVA19ozNKysg3szzCw8pGpw/v5uqTHsZI0hOEqi+LvfiTdL0d1M35hEaIZ8uYeGnfOCvKy4Fobg/PBKGbUzGx/wcKvL81Db7cUX7+uqzpGRPuK7DAFXfMOW72DNw5dEcW6QY8lLoAYUnuqXozfc/82zk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=YPDDx20u; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="YPDDx20u" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-21f237fb0eeso10522755ad.2 for ; Wed, 05 Feb 2025 08:00:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738771233; x=1739376033; darn=lists.linux.dev; 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=2MMc9mwT9NVQ5mz2h0GYOBXRUS44hVyd7ty+rMv4eE4=; b=YPDDx20uIAe+PnIp7mD/A9w+8x5eGfIWPqR8kccOW1wymdBKAWwylBNum4FlQaKzUB Avj1tHygSzDE+aXlaKx4oV0wNIh64rz76HTC1R42WY4FQ1g9L3DPqhF3vfJ2rfDhpt/u GrMALKl4aA/k0i+mHjCrTNYaHtkLl8JC9X7ziZspXK7XCFTq5NjoH6HbJO9kNmeuAhFC 8lBpBZsCKf0EsYmglXhjVWoUWRKQHbY1zgkC3DGBLfYoVVcdRBZfZyARtLZZzy3z9a51 0jlBiA+2oBrzWZB7vA1Kl2pOjqxUQijP1YdfYFWYWTHISnQUo/9jCCk02HzoG9JSAdpn iiww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738771233; x=1739376033; 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=2MMc9mwT9NVQ5mz2h0GYOBXRUS44hVyd7ty+rMv4eE4=; b=OAZrBe87BfDJ2ypFivhanEM2ZVfmnSdx1PRHR2LTfSJNTgn631nyoYtvf/oXyapyRs 4mc+XeZgrqXpnqUQl3zqyhqZaNNAkF46U2agDKjHz7WurwSp7lW3H+dVpF9y3GC98LCA R8ZI0UWUuWRYbDFUo7OAaIV+ByROCepxxGG4JxWsV8AEepNCjbWWG2dxM6bm+MuQBfzq jycj3I008YyClfGajSMpuwMCjRr2d0mV3KllU0E/mFm9ge4y6ug62ULaMv+c+qN1HEk7 EpjmP6flh5QWnaoh4ACTmXfoFBuhMhAEYgB7LyLGCIqTImkD9zQ208gQoLPmhAaWqZhE 2pRw== X-Forwarded-Encrypted: i=1; AJvYcCXbhlkOZNhWAeqE1uiuz377myBjmlSsyM7O+8WJE3VnigfkP2CgNRn4DqlouEYVq6CecLQ=@lists.linux.dev X-Gm-Message-State: AOJu0YwwoPsI5OlGzEGjSadFksfogNIeI0CZOXryodZnYrziOuj6/YTw 255iJuguVlKrpLGBJdsmrZA9RqI41jZVNct6y4fiveqqkpNLx6EeDSz9ZEgtDek= X-Gm-Gg: ASbGncvBGwr4J5gsqL2YxAEr5E69J9oUivHMyNTnwWlNXHy066JXCx+4GoRliWO+vmn 2T2OOYZ1BId0W2fgf8fGp1UWlMT1FHgD5GBkNAvSMwv35cWNjNvcZFNDXytqGOaFOmclP4S1mOI 3Zvup9E6/D3pCTJfMm4qGB0U4FJI8IjzvkNRg6HzP31Vrr6D60QVhQIhqLNKHX3tndy8wJdSIkE 8giXMePINR3ZC6p9/hDxRZdRsRvzUmW7Y6/xsdZ0a5NpKciywg8gthf5uxb7I9cIZAayOrWygLO CkQ2IAwjqVsbDqrqxBsvTSJ2ucAR0P4G37hFsg1m/FBty+IfXen7Ohs= X-Google-Smtp-Source: AGHT+IFVUygBqhzTxplgfR5D4ALHtsI55bhay/IfP7Si4rFXdhEgGg1YfTQqUROzXYR+kUtbmKwJEQ== X-Received: by 2002:a17:903:8c7:b0:21f:16b2:9339 with SMTP id d9443c01a7336-21f17e2a39amr53896345ad.27.1738771233066; Wed, 05 Feb 2025 08:00:33 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21edddf883fsm99369015ad.4.2025.02.05.08.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2025 08:00:32 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH v4 05/11] genirq: Introduce irq_can_move_in_process_context() Date: Wed, 5 Feb 2025 21:29:41 +0530 Message-ID: <20250205155948.81385-6-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250205155948.81385-1-apatel@ventanamicro.com> References: <20250205155948.81385-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 1884fa4ec9b5..5b67a47da144 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -617,6 +617,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) { @@ -626,6 +627,7 @@ static inline void irq_move_irq(struct irq_data *data) void irq_move_masked_irq(struct irq_data *data); void irq_force_complete_move(struct irq_desc *desc); #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) { } static inline void irq_force_complete_move(struct irq_desc *desc) { } diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c index 2920024475a3..428e42d3bc91 100644 --- a/kernel/irq/migration.c +++ b/kernel/irq/migration.c @@ -126,3 +126,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 Wed Feb 5 15:59:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13961468 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 076E61DA61D for ; Wed, 5 Feb 2025 16:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771241; cv=none; b=ejWFRA0F4dWSTgKGKcqi2745ebi/9UC/EITOUqA2nGG3cQF2L1eb2DsBSOwgEpGfLsHDvpqy1dxw7jhBFFWsIcIANHii/zUifw5R2tRSPELSEa7o+/FG98dBLxJilP7AAt7uiOi5M3eOA2uFjdDr/eqpamPotYhnmud2Ol7xUvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771241; c=relaxed/simple; bh=rPuSUodznHcDcnkXovmaVlnFXIC34eH0em4djJco3jU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cKuepm/+MEq2C9KBUL1hVCYzJs86XeZsYm+Zsr1N5kkWFnnlfHw87M7VZ2L/uaQU/UsJwX1WaR0SO6y6gNrXcA/rcKkDY1lWHHOEjDYtz9RbVzwj+OmhQ3N1ztFtrwWIFp6mX1i9iPjWk2LSb7Xu45nerNwxtiPUW29aHCdwFzY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=TmVVHogU; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="TmVVHogU" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2164b662090so135461385ad.1 for ; Wed, 05 Feb 2025 08:00:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738771239; x=1739376039; darn=lists.linux.dev; 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=TmVVHogUkEAW4Fwm6sPu2y9kt7mV8DCuovQatRBF+PFCf6spjzxRwYoq+93XCqmQEu 2xW8H+GPQ4H3Vi+0UDpCTWQHBJwZsWC2RAhpHEoO6as3/3KhU0AtdLiv7OiuVCRmGyRN xTxdTe15l3c4imHXsIHyp7EW2spxD+KTMn6/vkk+Uj4/NQiL6GaxLORDtkegxDasJMVT wr7asDnayv8UcuPBqu+BC4wES54faiZC90lAEu1JceAQcrEIMtkdEwraDYC2CuCItO2h 0ophr5topk0nPKJ4dAqn2S5yQJduOnEyXtuFJKMh716Jud7O8iKwY+MRGVsjdvn4M8xY M8AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738771239; x=1739376039; 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=T/cNpnzWtgA0+q/aEBeAb9qY/bWnQmN/Qc61sgQzb5O+X8DTgyiN/Zn/MCvbwmaYyR DIQeGSpHIVqRoezyXVYtihLlFDbSZQcquu5LSFtVUml+kX4Q2LG6RGo7qAZFPh8aH2qg mwEzcZ03z+08DC1Qg4jD153bx7Qr/AhcdqgzX7KRhx4l0oKqdRxJS8diLRv0wa9fpDl+ hDva6z2qBnFAd/QV0zhl24dPLFcWjnSLb4BOYHxzKEsE9+TZA6YVtDUvReiMyVIM51U3 HCHx0jhaCcxZqTJohOEITlp+mF2lLJ/S7f9H105J9bnxgTfm3F0zKiaanN+HZohoSIz8 08fg== X-Forwarded-Encrypted: i=1; AJvYcCWbXmgyo9wD6LcWrJjqupRtXO6Npa2vCav8kRB0IZff7KcXics7HE3RlIk1nIHxE6+LfhE=@lists.linux.dev X-Gm-Message-State: AOJu0YzFnoYXSJwA3aK3mx75YhIwzd3oBKZUH78R7vTzXQtAAzJtdI9B aANvvfJNF0tGMcX6UNwRuqfevEGC2PQ97szmK0jbXYeHYphvo0UjQTD2pU82mSk= X-Gm-Gg: ASbGncs7R/zrNbIeo4TONSzBdvthM9v7ji7Cu8ulfRnWj3WZ0vRonBeeVRLkendnVTQ dmxQqRfSMICSD285MCB3BbKq5ypkCS+nD/3sBIOTM/KVoh2WpbjNFiPi2CRI2LMWAmBoelqcO5T K+UMM4ufw3uQwYuopRrXYTcMQekqHyN6nQ2hiuhrC7oHJHNJobY8aQDAu+z1pLk/HvwRCxOzGzL 4DrAaVhFcCoXZDKgclQVplOR/BNeLN8l9Fu8j4JGZqRvgd6U9E7ASARHgXFUTxohMIgOvdwn73a EJeZ7vBJduGpD1MV5JOaYGYyq8s1MmZMTy5dsp7IIbfyhanzEXmNJeQ= X-Google-Smtp-Source: AGHT+IEJIosY/OKbXQSnforNF3833piSl8A3TJUvYoiwSYBBjf98+ctLM/SnWJ1Zo9+v0gmQgw/WRw== X-Received: by 2002:a17:902:cf12:b0:215:8847:435c with SMTP id d9443c01a7336-21f17df09demr64343705ad.12.1738771239274; Wed, 05 Feb 2025 08:00:39 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21edddf883fsm99369015ad.4.2025.02.05.08.00.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2025 08:00:38 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH v4 06/11] genirq: Remove unused GENERIC_PENDING_IRQ_CHIPFLAGS kconfig option Date: Wed, 5 Feb 2025 21:29:42 +0530 Message-ID: <20250205155948.81385-7-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250205155948.81385-1-apatel@ventanamicro.com> References: <20250205155948.81385-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Wed Feb 5 15:59:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13961469 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A5CA1DD873 for ; Wed, 5 Feb 2025 16:00:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771248; cv=none; b=I7hRzS65jo691XfdVcxwmupHxAgTUEQ/v4BUoYpWiiFk3j+x8Pl71bxfV1bsESyBM3ZcqKi6892yBC4PqXQy0mnpHIhwNiMop53E8T7JrJ1wXe3WYqESQSYiImlzE4bVA8rZ45UGpRH2jpAdAFTVp2TzBN7pMk8LKeggZgGg0lg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771248; c=relaxed/simple; bh=n4slH+wgDA6MSJsnkDzYIOL0zzUU8vlxw6wGI5nPdQY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=reAAAUvvm73czwS9qRavv7LU0cVAuw9XlHTgvd6WPmPZoIEOT/wYRZkuyoC7FH0jXAY5eg+wyx4Ef3SEv6we86ysknb0qCL5L9qnhLjjnTFP07UneVLv8XelV2u4MtxNUZFmcxoREliAAduedMso/G1mMwEDM4sn/naSjaO/CW4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=QDQB1VbB; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="QDQB1VbB" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-21f1d4111d4so10179725ad.0 for ; Wed, 05 Feb 2025 08:00:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738771246; x=1739376046; darn=lists.linux.dev; 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=QDQB1VbB31+pZISbSFpmXdOdtCRgqAOlJHVPC6W4WnLEH3r9IFjlKntWv+el/fav2G /plSgGS3ZLzT45cynfTcv7omwAkeezmQfN/zecup2ca93WjZPXQkCq/dO19s/jPWolJ9 J5OkLKplo4KnMhRwaI39xznFPHdLEDwA20x7ZxreV1rNC22KHI0ff9+wO8pXSZkP6y/D H4A5hyNFrRdGZsEoZp/uvILY8kevgLeNtBzzCD2Ee8vzjZBhzEeLlbEU6BR6yLvWaeHU ylMHbbkabKG5KdWe5IQPLR495JaM7xVZiZ7xvWdODYHfT0fQGNk24rFHac4oQ9E07eYm HhSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738771246; x=1739376046; 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=tP2zu30vDo1VNHb2/A6teaO6V1LItJXPzMN/Cyjn6Fm08ON9oLuQN+jcBJrPNXU5DW hNoF58EyXD205POlYWJYiZfqkt/AQSq4AQc++4Wk823FC9DmaaZTOFcZWyRB5bUS5wWO et7gcPQrqf3ph/xsvOuFQ7p18u4JpMZAVQifAK8dxHv9Q08jCzTGSa7evYh+r8Rnx5w3 EpBN4QKSJkBqRqFKkmtQumIun3OOUbpa7OdIRxKHnDKq6ViMlZdjQbILbd2ONxP2TgT3 4piu4IYS8xqx1JcgeIPoB97rRVsgpg6bghM7Rl0xqcVTTFoFb5wp5RSRY0WN5N/Hpg7m ESlA== X-Forwarded-Encrypted: i=1; AJvYcCWw9aDq5aWtd3dkE0XwFHNglAxETkQCpOZ6Gdm9bnSZThXhHmGINMlIhgfCSBOaBPOu8pQ=@lists.linux.dev X-Gm-Message-State: AOJu0Yw0DIxFSbq4riDqlSybm98hBlvcSNgfdL4gFTdJY+LZivW7tYKi emzuA8Q/eaKuVrcgK9r4nb96pXI1NBq7bHTavmDfcwnKilZpOvUcR9Lo1ixkhfw= X-Gm-Gg: ASbGncsTnQ33tvHWEcqPgoCxFk+bnhxGPPUpxh3ILQTm8UXlAtiOk+029ef+HlGCrVV kvJol1c91lOEkodKI9js1KGwLTz9Bb+d4Iw9xARhEVAL1P6024UZrqviQ83Uj8nkJ4/o9LYbjSr LglhSYUhY3t7jXULeTLyhwbXQ134+j312qOl+DYC0L0ZwFid7UCTti0vD9IfBQ/I90XjfY+ejVe VwpI7Ea9jvRmE3wXtp4nfE2oWma2FpK1FG1RhyFyNapLnXFFAKdzeW8ZQH+jQs/B+WiYgDpz8q2 FoZki3OIs2xXKo8Yx9482IeUpA0Ge8kjB4Q1FR0o8R3/KQIGHSRaD+U= X-Google-Smtp-Source: AGHT+IG20/n0MlzHXXlDX+eid7Zzs/iscNjRXbzQaZokFNcd/sGA49bK8WlZsq67OCE4wBBbq10xxQ== X-Received: by 2002:a17:902:d2d1:b0:21d:3bd7:afe8 with SMTP id d9443c01a7336-21f17ed0ee5mr59541815ad.49.1738771245657; Wed, 05 Feb 2025 08:00:45 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21edddf883fsm99369015ad.4.2025.02.05.08.00.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2025 08:00:45 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH v4 07/11] RISC-V: Select GENERIC_PENDING_IRQ Date: Wed, 5 Feb 2025 21:29:43 +0530 Message-ID: <20250205155948.81385-8-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250205155948.81385-1-apatel@ventanamicro.com> References: <20250205155948.81385-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Wed Feb 5 15:59:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13961470 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3534619FA93 for ; Wed, 5 Feb 2025 16:00:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771254; cv=none; b=AGtrQ4l5ehh2qx1m2jeiDPcG66qNIVgvswdy9t7ldZ/qB2GSSgwogovAoaxMlWpYl1+W6lUG84lEdDCIKjDPkI83D0DMG8SHbR+AAtFABmKkoufrLmNXYrah7Gfpz5nQ2rtbsAcNtFDi/V9n+ZBvA/x0h1rgfbU41RF49mzgDl4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771254; c=relaxed/simple; bh=/aguk4ZYg6WQI6RlClB+Z+ge32iMkXIXY6eYPLNpAn0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ltTgwSlQ06eQujH04M3T2NGZSA40BgI8P45vxP3YA5GsC9QqPxmRyWjBJi0hkDUKtXoSdoWQza5Zrz/84Zx82x6q1a+AeznTnrk/j0yBX3UW1lngKR5YUCMPzo/zhMK3JvA1dRr11hpuZzLqVBSbY1MhcAcMSssUPmIj/sCCkZg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=Py7el5mw; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="Py7el5mw" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-21619108a6bso117152565ad.3 for ; Wed, 05 Feb 2025 08:00:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738771252; x=1739376052; darn=lists.linux.dev; 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=Py7el5mwYQj350puYD4EDmNP/lTVBt37kFPqmBzillNwZtp7I+viWSymbqXXYvrMWb jB0QB8KGV6WE/8xF3Yq7u6UZBG5+YC8f7zMtJ4yORl0HTBtIwnJU7xPF/h9BFkLa/4W/ YhhyaQiOdRefHkzpqC9SxUil0I6u+o0UcfXUkkjeMJZj2lCtrUMnWVRnsfp1S7M8JiJ6 pjVwNGjVinSleEvs2IsNjY9J2dwc8onyMSY+XEkWjXAexpGMRPwjAn15KsI8xgt+egY3 PgmYA1vVmr9gUuB4pTaz7k3XW4gYPeIwAR5xyDBS7qgb3FGYNclzr9R2M8S0AheM8mf+ YO+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738771252; x=1739376052; 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=WA0xgIZaCsiJXo0Iybq3S06bIkYfRt3k8x0hxi+C69TrucezjAe/c6esbO4PeCni7e DG07r6I1nx1kBEeoBecJq2zP1YrGoI5aQnQJwwhvZ/6uFH9QZwLnaFlhTQhLmGEomyuM YRrbgIx3iXRYiqI6cOX+XJO1ZgeRbZRctZHlfKCcRxbFvqV9h7XYxlS16HSemK6Vgc2f JzQrKHTVIjv4+FNf5g6+TOBhe+6ubVcu1HlBdTZQa7x/eoWrwQaK5eh3Kv8hIVwCW6qo sVYC24EdFZJ5EDRNFDiNJzDE+2Vu4JbAMkfOtwFqVyGKK3jQ2bfvnTDwM7Zy9H6IHd+b KsEQ== X-Forwarded-Encrypted: i=1; AJvYcCVCbJ5NjhoxlNxNLSeSuvQSqqbTKs71GrZGIfpzXm+fwyl4Ugz6VvjhQpYXxxjJnWY5tFI=@lists.linux.dev X-Gm-Message-State: AOJu0Yw1Qmk9wIIQctNyL0OnC1bRBVQ7uM0WjOjSG3R/x+BgBiWRLpWr YgtQTBx1NS58WX66QuNn04LlpoldcFSXNeXik6cAj/POZtdxvXrel5OlcCcFDHQ= X-Gm-Gg: ASbGncsQaBszr9f3i9G+zH/Lux2wH1EJFn7rtHJrwKOf5MWv5nnLJFGQUve67DY7ufA nU4X0ffChT6OvA7xew2C0Gs9wv+0TMPRhIV61gp7GCJ7763nwD6ci1g3MtIVMN+Q05TBkfcj8Yh sIu3jYi2UaW/VEUcKkDIoOVPjZDdlz78YmJvnhsKeg/xccTQhtvGt6cmXxpZ4pmh36dsPZQwngK vOw+BlwqiZOGTqOPuw/CNPoS7WCLua5Y4O/rMPPmcj8tqS8UKuzVCVjugF0bqqe07z2vW/AMDOi Wlu/trNJd4sohkOyZdXqsw6aPaXW7TF/7Bt8yRdxuY7WEd4LGEtjZtM= X-Google-Smtp-Source: AGHT+IGZXw5A6C5TRMXaRISdtNy30QCVwikmm8khroyenXQMwT2LAT21ro2VOMEOj9OPHLAZZZItVw== X-Received: by 2002:a17:902:f54b:b0:21f:f02:4176 with SMTP id d9443c01a7336-21f17ecbcfamr60758095ad.33.1738771252165; Wed, 05 Feb 2025 08:00:52 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21edddf883fsm99369015ad.4.2025.02.05.08.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2025 08:00:51 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH v4 08/11] irqchip/riscv-imsic: Separate next and previous pointers in IMSIC vector Date: Wed, 5 Feb 2025 21:29:44 +0530 Message-ID: <20250205155948.81385-9-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250205155948.81385-1-apatel@ventanamicro.com> References: <20250205155948.81385-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Wed Feb 5 15:59: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: 13961471 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0418718CC1C for ; Wed, 5 Feb 2025 16:01:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771264; cv=none; b=f0oIYmXZN64VysGUiqLfA1kyW8f86/2R/cO2K2JKYCIgFNz+ixcXyZWl4+YyAq+uTy+RcFqC7B1G4rwQb6T+pA8GPRohq3z5FvL8xdb0pkYQ8yMx4f4zIaQ7+C2IfYmFNC0nNC367eVdu0baAbKbur3SyBrrLMQrKH59v0XAZBg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771264; c=relaxed/simple; bh=mFFEh8+hZeEVXl9Ut+Oj3ibjoUtqS7w8eehuqLHhRt0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UKM0+hNXKlrDAWDvpxcBaIVk9RrOukT3sjZtvL0D/xw7VtFMKmcdnLuvmcHqKlYgQZk1P/JRH51n/9OxU4w6ykorqSmWBt0ZFKSXYtOq6O607wInSHrBvqQwKLrvwotrMporH7PL2H4XzKXtFHB561RHVyQqMe0lcz2s/S096Jo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=AMmoxh0P; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="AMmoxh0P" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-21f01fe1ce8so30821085ad.2 for ; Wed, 05 Feb 2025 08:01:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738771262; x=1739376062; darn=lists.linux.dev; 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=AMmoxh0Pnq7NJRCniRp4Uy4Skl4X1z4gkJNDg+i5KATuupnE7JtqPS/m3uINXtMQNL LAO2GC5e1epl7qI7Mle8P2EA0cwZG1CnvhCey5pyhAiGI0Dnz301WOieWJhDqGhoxuCl mpzixbuuz9bmpp+5Bt877zst3rlPsdU1oSaJegg1O08bbRDRo6NhBTVcVyCTuSAQC8rg isUiwNKPoeHGw6AFsOuKDR/PITDUd+gA85zmB+ThqCV4I+X+FZL74qDVdX+kIMeSnFtI Q5V9Eg5pYBYvrPA/RFHUXATZKAutE2mMSZbdbX3rfVkQjTtU544YjKsjcj3anZFVgTBm FfeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738771262; x=1739376062; 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=hznF3YCYa1uxau5QK+7qcypADmVfnGHiIDijRxgzey21kFjHEfYP5Xrm9Bg5GH53Rf zA23MTwf6lDDsNxYxfIXLSCFxY/2lnWMySaWdPILJjarbDudpW+d/9aYJWaDYmq2bBcq yc58zM9Km+Uy9RSx9+5D3W2XVtUgeHL3kOnNzLSOzS7/m31hqcdP6LSohQqc+uHzXVGi zC4nDEq5l8ilr1pVFU8LNk3deEVbVIlyMOLMrXSMRfRwJKKJlerejencj9vmBorPmfyD XAhEDcDjiFbu1qDn97KCPiSqjbBF8VFBb3Sko7U3EkrdNphFepNqDEg5mo0+Z/QchWyP O9jg== X-Forwarded-Encrypted: i=1; AJvYcCWSQsshW2mB3wUY9mqTa2QkEl+LOvCN2RAE7q368S9IeZdxNyj1EnflXYoPzQCpJACnP5k=@lists.linux.dev X-Gm-Message-State: AOJu0YwmW26pCpPibGigjJHQZGhDLbM/yJpAoo1cszToZDbzGz/mrlfM yphFKTpZcoDc53YQuJZ6zEH8mtEwmdhGYqF0lxT2FGrVhWLiZdr1fQxpQno3K4n0CvQEwPTP2da K7E8= X-Gm-Gg: ASbGncsH8HYkeVpp91ahWBFXFN1iQLEbCpKRIp3sjq0Dvm/EBp/dMp53/WMN/Typk+G gH0KA3nUimHA6E6slUs/wRDaMiDGHxlavZLTb/Bb3wWfvX7l49VuxLQ4dWpjgwfIKpHRXrZp3GV vWPEN1yCkxRgNA9ZSZZZUDwjuP+9bDIYEGZlBXsF3TLHKH9VrRdp6PhRWStFBQQslp4aLfQCFed 1BeMJ8A4niCYOoNxE4xuvF1TIZ6rot+7jSrcvGB7OPJbXV2Q2oz41wt0369DnnPyyC5jsoAgmtR AJATSbGJpUCMUUpt3n8wsp/eEBEDHLcV2nOxvd3tCd8WA1UOCGnApEk= X-Google-Smtp-Source: AGHT+IGA6bIArcQBSZQINkR2ug10cWLWOtAjnqU2/HK+jfs8kC57mwS6eJ+lRGDZ5WGk1pjMRxBEnA== X-Received: by 2002:a17:902:ced1:b0:215:65f3:27f2 with SMTP id d9443c01a7336-21f17e2719dmr55903235ad.8.1738771262008; Wed, 05 Feb 2025 08:01:02 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21edddf883fsm99369015ad.4.2025.02.05.08.00.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2025 08:00:58 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH v4 09/11] irqchip/riscv-imsic: Implement irq_force_complete_move() for IMSIC Date: Wed, 5 Feb 2025 21:29:45 +0530 Message-ID: <20250205155948.81385-10-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250205155948.81385-1-apatel@ventanamicro.com> References: <20250205155948.81385-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Wed Feb 5 15:59: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: 13961472 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB39A192B90 for ; Wed, 5 Feb 2025 16:01:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771273; cv=none; b=gqFZX9gBVAdA91F+FuZ/Bl4cB0aeWIVI1HJiAkyd1De+H9pOF1ChsC06sF7P//t9+5eWEibNh3HNcuyosQelGAQ1PguWdbpDRve9MtpiPc+xGVMcUx6ixbubkm6htLgHm8Yf9naWYyxVejXuoQvALsIRSIsImgOfIDmIuE+ispI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771273; c=relaxed/simple; bh=lcMa5p2pZjzeghLKvVY9ny71KeZ3wMkdol/DU/InCzE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GoxRLMefZKBIqRN4yK/6zeVXM6XHMkzWgSq1nVtBa3vX8rYm5l500gH0oGI/L1GopE4ma/8MkB2ArKqw+etnbZHZAaGaPhQa2H4hVYAcKrBga3Oxxurl+Yoi0euX+DN8IErK5BozBEXT5rOUhdPxoWhUecUV2KsWf3b9t6gyEM8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=W2dDyJj1; arc=none smtp.client-ip=209.85.216.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="W2dDyJj1" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-2f9da2a7004so2062157a91.0 for ; Wed, 05 Feb 2025 08:01:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738771269; x=1739376069; darn=lists.linux.dev; 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=W2dDyJj1iSSXiAKpyoDUiP9e6KUmvaFbUH4SZwAuiK2BOM82vBL4hrIUJEMng/yzE/ hr+n5RMcKPZVyjU0l860/GoY21mOkU1HtN3f3OEN+TGvNmxV1pS6Uu/GD+RJluBkh8P5 peSQxDj0ugHXJmiquhWsDaz8lvi8KzuewFLUNnHYwUGbpfNF7/Y3xk2bF3f2ookXzmu4 uWg+8XK0mxGPdQvM6njpUjuOGNrz0OjLO2Qq5xsd36tqHs5edymaOWd0A09smXLvntQQ N5AHH+flpM/FBDGK+iU1CcDttmc/YYOHTuYpX/kHjW6b6NzdFmvQdDmKvB7E3xh9zQ0b CtBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738771269; x=1739376069; 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=aK+1upwkfVdAHSAMW2HyXP/ySwqionSUp4wYAad0+Y0cVGkX54Pz8Dy7ZAhfpjbXTK 5x5vCtSz/2l8F0fWcF9BmLLqkmfjeuLJbq3BicJSx4QY3xg2UGvChslHA56taSRO5IqI 6OmdNnG+nGiG7eLl1gAfP5YrEaGxXeNgyRJQ2k03EFEkqJQITszjyTRMAvtKULjOCU4F AGdP8hxdLrt1X6FMKhxC4kDELv0OBKP4AXn/TI1kFnX6lxa5iOFOeYRPvvJcDpmdxkJ5 Fs6LYBgj9Lh4iC68uc9qVoFa7CKa4MXUNKnJt3uPcXlAI80jqT/GB5v41/r0gMEAtW3s feIA== X-Forwarded-Encrypted: i=1; AJvYcCUGEX3W0HYRVWEXQjktj5VvKZImOO/F1HMsFrN+iu3ChRm7e8/jNlT+42IoPjG2DiZkONQ=@lists.linux.dev X-Gm-Message-State: AOJu0YzOsBEFHGrqIblVAL4YMQv5TYfK5OAL5OwJenwKXpAUKbwuLEo8 udfcC/rHfvROvI8Clty4VewpPnMQlter/dUciCKu90gNBjAe1wXrN1qC4fCq+W8= X-Gm-Gg: ASbGncuhmblWzqjcZ0VNOLLZXdtgap2syNXWdW1Bl9l3+9FIQTCchNyNdN82R168UH3 K15mZAqLFCCyH1KMkQbMdsvidTnggX6f1MIB4NedHOq2j2SHT208IS38V3BHWU3nSnBeDyDaNNA p33T1cJ/YhQR3o+YAtPyu6x9PYxfgEXBML2i0q/GPDd0a2fO+lc8GYLIQ6IL4kytfpO52BJtwOJ BkHlnf8iB5pfx7ilDLuzDuRIIgytsgkAr27RHxJw+9UQ9IZnYCXpHfYuIBVahlUfZy9omHQJO6Y XcFKxWabDtEu2JLPFz54I+SRKES2IsuLdxPVACGrXoyJJ4eqW2qBeH8= X-Google-Smtp-Source: AGHT+IFnLvRLZKvgJpx8dmK1OqS269EnZ/fW86sG/bu7Q2nxZbfcOX7ctDxWBsYaZVjqDvgkXox9sw== X-Received: by 2002:a17:90b:4a8a:b0:2ef:67c2:4030 with SMTP id 98e67ed59e1d1-2f9e08003demr5011059a91.27.1738771268829; Wed, 05 Feb 2025 08:01:08 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21edddf883fsm99369015ad.4.2025.02.05.08.01.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2025 08:01:08 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH v4 10/11] irqchip/riscv-imsic: Replace hwirq with irq in the IMSIC vector Date: Wed, 5 Feb 2025 21:29:46 +0530 Message-ID: <20250205155948.81385-11-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250205155948.81385-1-apatel@ventanamicro.com> References: <20250205155948.81385-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Wed Feb 5 15:59: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: 13961473 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F39481F8908 for ; Wed, 5 Feb 2025 16:01:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771279; cv=none; b=f5d2yQZAF+pzlqY0woKpnZKW0f9mPG0qEBWrotRN3XlhnHpwP/b2W9GS/vERyelfyOWNZzEitTMizGP+5sjyT9kfWfVI39wakfy2Hr8UG8Ny+9eIj9xeS4s9SH0NVTO8Zl1ooLA7GYHQcb+9MkmVZ5l7BTnIL0VKZmHbhxwMV74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738771279; c=relaxed/simple; bh=tNahCfxLRgNIbiBla43nJrTI1GFGdO1edGYaRhyK8s8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F7IjrQvA29N6MlBEksapeOK4aT/cyTqEmtmnquw9hyfB30ScEmOZFsh4KVKe03dF+3OsxpJE5zG29v1lvI++948z+uSVOt1RmVveuJCMt2QOa92ctHfR1VFUsc03lcd/QSbu+p63JRAAXdhrFQyWNXYksL74AbWVKSJyqHGxtpc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=H+Ng9aFf; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="H+Ng9aFf" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-21c2f1b610dso9780215ad.0 for ; Wed, 05 Feb 2025 08:01:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1738771277; x=1739376077; darn=lists.linux.dev; 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=H+Ng9aFfe17L0cxshAvrCXzWLqJ8Sjukf+CPnS1Rcf1YXgWkWMSy6qPa91S2vG5m2+ N9V6PcbDIJ41KzbhwpCjGlVl4bei2Y3rJSyAXm/Zl45owBvUbV37Ul/Rta6vZVoGi9uy ZAm66XtZZGS5QQ5BPSZhmWCVN2EWRthfiK8O3MbGl+5CEbQL3j4HRATNm9ed/sHoBjas ahhQZT+yPvFpKcJ6/U8Iyzqkkr43E63IboBi8Hp0bTi6ICy63vTAt9WA39QB3F6b/8SI w8sQw+Ou4qfkDXmaKvb06LJ+KsTS1Jyu5VewlFw2MC9mhmBVwAL8SktWP5bKUZAL+Uo6 4cVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738771277; x=1739376077; 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=QY1m7jGpogZvINbUuUWYYfaDKHdhlljqtj5bVCTF+d3rU62OQQM9bTPlvKZIUG9/ma 9By0uZL7XopuMZ70k3Zlfskytv4YmoxrcdcoEDVMVZiH9HBq8rZVGSfpWAj2Zp1JIhTz mpTcwDwl2uSvXA/xlauYBoTOoheE5G11NfkPqKDkHHXw1wGPqlWlkun3dt3Fq2TeJZbP xVmZe3lBZxd2hwGSZxZGoWc6nJa7INEMYBIntaseHU2bRavvbU/S7NDzFl+4X/TtmzxH Je5g8jCv9SObDgOHG3dUrhyC+CwIks3IwOgBIdhUXiM829uP5YTigAdPvjqnXE1syKGj 4mHA== X-Forwarded-Encrypted: i=1; AJvYcCVecRKW5fy8GtXpyxcBG9ZH3Tz/ikKEmC1UdBnzjwhQF1lC+Vi75GYwz+7fKnM0IzGs7Qk=@lists.linux.dev X-Gm-Message-State: AOJu0Yw6ZJZq0HTVH4fOMr/WkWTGfrH/vyKiNu4ggVcvNeSYEMs/Cqxf tpe6FA1Hme5dal3SRzUOQSgLFGWnhyCnokA68OhKF3z8Th7n70YIoyi8qKJA9sA= X-Gm-Gg: ASbGncuA/ZW/I6FwE5tX4NzxDe/VkiTL7Wkjtej89zSiDw32nS6Jv3ufJNrNIpe2NkT qnL3xNzbo83FvKm5welxnVOPoLOzhBdR0htVtvrmIiv7plpYjrSlQl7fbp55volViliOhXDGIp3 IW6+7mgjWCjW7rsfvTw8OC8AupoLS9H2L6nqB7dl+TBbuf/hUIOJq8JGCLJGdQkufU7ZIforSbQ Qdku+V1U68/wXRoem1cPgbg67CEonAvuFb1ldMFFYIqYQBuiml9G6yZo1rue7DTdDdpzBCBsZwT fC0K2lsOnVF++v9+AD3un+nQ50M5bKIp/rQF5TMgqsUirNSQoK3ffU8= X-Google-Smtp-Source: AGHT+IFTclDON/r36LodehwMg78zlP6BqfcqB9QXn3ksA4PSt60KgNQ9lMw/GuAJ5JZoMSZ1KuB8Cw== X-Received: by 2002:a17:903:18f:b0:21f:75c:f7d3 with SMTP id d9443c01a7336-21f17ec7bd9mr56546085ad.38.1738771275532; Wed, 05 Feb 2025 08:01:15 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.166.196]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21edddf883fsm99369015ad.4.2025.02.05.08.01.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2025 08:01:14 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH v4 11/11] irqchip/riscv-imsic: Special handling for non-atomic device MSI update Date: Wed, 5 Feb 2025 21:29:47 +0530 Message-ID: <20250205155948.81385-12-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250205155948.81385-1-apatel@ventanamicro.com> References: <20250205155948.81385-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: