From patchwork Sat Dec 14 17:25:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13908531 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (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 46FC71A0700 for ; Sat, 14 Dec 2024 17:26:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197174; cv=none; b=nbOgJZCAARStoaavWD/Vd0fvV78wlo7923mL9pWUcK83qRBX3sI9bfzOqDD9+wSEU8xI2NNPV0g/EqJvdXFxsvxUeZB8MHnAhViGYIFew2fmqzKHwMa+SJjzGGYjbz811ayTNuH6pgV8e4WoMVT1xUpV3W6pSmLlO5iot/oTiaU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197174; c=relaxed/simple; bh=AjbhMTp1aGsIYrzh3IEvyIDO76drMFMoCVTh2CxsqAU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QK+tN5xJEJ640JllrQwxwhiZiLFoIBz9sqsQwM6yIRRvuB2YwNq42WyGqLjyZPOWnE4RYlH1K1254Lp++35aruy81R3YQ3/9Ko0N1OlOsrtA2z2rRLhsu7lgtUoX8vUkKdvNOFzjp7hqW6gTuwmMfFp/IUzHkfaxCeM/4lS70lE= 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=cxDE70ln; arc=none smtp.client-ip=209.85.216.42 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="cxDE70ln" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2ef748105deso1962434a91.1 for ; Sat, 14 Dec 2024 09:26:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1734197172; x=1734801972; 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=CBfvQ3kWrJIo4ZX2fO574K2xNLHLI8xt5fD3UcZCgGE=; b=cxDE70lnak16kqqVIPa032Kot9nhgw4iZqO2eeawga7MVAbdIt2LIAcRz0xZ2FO7hq jDiSr8GIUklAu8R5adwukWBDBnf38iZPVCcRcNZ+tXKrq4ELtu4cyFOrMAZota+oLxq3 7R6XvB0LSXlyUBDXASkgokxgUCi7wrPXdu46P5FlDrHHGAJwypbo0DCVxdOCpj3MB0zf cQH+fRBymR+NI0l22rhl6yj21cc7xgEPMD7wqw6bKSEVZmEfSRd6IaXzQYMpkZhBM6OF 8swn1zzvhdk3d5mchefRF4g1uQcEO/jtYc4eVr4Uf/4L3IZG9fmi+WXhoTzqNKrHokm0 pZaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734197172; x=1734801972; 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=CBfvQ3kWrJIo4ZX2fO574K2xNLHLI8xt5fD3UcZCgGE=; b=a3/VYFy99yEZlSpyHsb9rgjivecSbZx5gaSomf9mFjPCU9C6B57SpDknexoU1pPpgU MV0+O3P8QGVoio8X4FzN4kXcTDqLelKTNbTYZIsFCbhScPmUff8G8HE6NK/Yj6u2TXsw oOyCplH5qWKD+iTmy96gjLpRzP6I6PiCsGjxtbUEvNbwBh9uQZOZrK8+nLUDHXsel6WC SR3SXYJ9t3iyM9o9NZU4+gWnkpoThleUy5K9t1nZhUvy2U6GUpnFZIgsdiMa0YRFcJ8X jXYa/vi0NNY3JW5LILBd2lptsJAUGmkFr4J4Jv8hqyMrM8Z37qvNpiUGCss48rjTRwA0 IZww== X-Forwarded-Encrypted: i=1; AJvYcCWuovBxPJxPU414lkTVwWJDMwKDNOUlBw48LhxfZf/3S6nIwde6rMl/91uLSfjtr0+yGxo=@lists.linux.dev X-Gm-Message-State: AOJu0YyNvaktVbjvWWlMxDgWF9nYxJiScI4WuwCJQZdSr6zmj4DcGdM8 lyydL7h5ESHzDNQOurJFecISpKpGn+DtKoH2lgLnvAj29W2byzTl5SE5GKp1nu0= X-Gm-Gg: ASbGncvuoYFeTUOCEAC7v0p7yHjd9WCRchwiE2UDzylrtTp0+mXIAlSkSDJW1fmEK6i r8Dt2R1fbE8YuAUXlD1Yg7kCQkNcgzxhQl7CqQHZ7yxtWQwCzZRa5MdNAqX0J4SZqSPUZpnt14Y MhcBmvGpv5xW5gUoXqseFjYbwERT7fBAALbDAaxA8hMNDVTA/Fi7seKPL2eRzpxt0qqFtKSrEvh sLyHcGfNs6O6DCYMbwjSZAPvN2xoaw8J02IbnHYjtGkdWU8jiAYp32z5CNQALZ7OX9CLKXZFEBJ iMkak4Wm3WPLFqM= X-Google-Smtp-Source: AGHT+IHTs9Samt1nUdMUjND/qbDSnn282FzLK2X5JD8ULRiRDj00BeL2dfgDijLQRIK8XWPNIoxzrQ== X-Received: by 2002:a17:90b:180b:b0:2ee:dd9b:e402 with SMTP id 98e67ed59e1d1-2f28fb6efa6mr13056275a91.12.1734197172388; Sat, 14 Dec 2024 09:26:12 -0800 (PST) Received: from localhost.localdomain ([223.185.132.246]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f142f9e186sm5049811a91.41.2024.12.14.09.26.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Dec 2024 09:26:11 -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 v2 01/11] irqchip/riscv-imsic: Handle non-atomic MSI updates for device Date: Sat, 14 Dec 2024 22:55:39 +0530 Message-ID: <20241214172549.8842-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241214172549.8842-1-apatel@ventanamicro.com> References: <20241214172549.8842-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 handle such intermediate device state, update MSI address and MSI data through separate MSI writes to the device. Fixes: 027e125acdba ("irqchip/riscv-imsic: Add device MSI domain support for platform devices") Suggested-by: Thomas Gleixner Signed-off-by: Anup Patel --- drivers/irqchip/irq-riscv-imsic-early.c | 8 +++- drivers/irqchip/irq-riscv-imsic-platform.c | 27 ++++++++++++ drivers/irqchip/irq-riscv-imsic-state.c | 50 ++++++++++++++-------- drivers/irqchip/irq-riscv-imsic-state.h | 2 +- 4 files changed, 68 insertions(+), 19 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-early.c b/drivers/irqchip/irq-riscv-imsic-early.c index c5c2e6929a2f..73a93ce8668f 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; + /* + * First process pending IMSIC vector enable, disable and movement + * on the current CPU. + */ + 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-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c index c708780e8760..b44eb0b3990b 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -97,6 +97,7 @@ static int imsic_irq_set_affinity(struct irq_data *d, const struct cpumask *mask { struct imsic_vector *old_vec, *new_vec; struct irq_data *pd = d->parent_data; + struct imsic_vector tmp_vec; old_vec = irq_data_get_irq_chip_data(pd); if (WARN_ON(!old_vec)) @@ -115,6 +116,32 @@ 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 some 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 both + * old MSI data and new MSI data on the old CPU for pending + */ + + if (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(d, &tmp_vec); + } + /* Point device to the new vector */ imsic_msi_update_msg(d, new_vec); diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-riscv-imsic-state.c index b97e6cd89ed7..a8645084bd8f 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.c +++ b/drivers/irqchip/irq-riscv-imsic-state.c @@ -126,21 +126,21 @@ void __imsic_eix_update(unsigned long base_id, unsigned long num_id, bool pend, static void __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; int i; lockdep_assert_held(&lpriv->lock); for_each_set_bit(i, lpriv->dirty_bitmap, imsic->global.nr_ids + 1) { if (!i || i == IMSIC_IPI_ID) - goto skip; + continue; vec = &lpriv->vectors[i]; if (READ_ONCE(vec->enable)) - __imsic_id_set_enable(i); + __imsic_id_set_enable(vec->local_id); else - __imsic_id_clear_enable(i); + __imsic_id_clear_enable(vec->local_id); /* * If the ID was being moved to a new ID on some other CPU @@ -151,26 +151,47 @@ static void __imsic_local_sync(struct imsic_local_priv *lpriv) mvec = READ_ONCE(vec->move); WRITE_ONCE(vec->move, NULL); if (mvec && mvec != vec) { - 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 && __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); } - imsic_vector_free(&lpriv->vectors[i]); + 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); + } + + imsic_vector_free(vec); } -skip: - bitmap_clear(lpriv->dirty_bitmap, i, 1); + bitmap_clear(lpriv->dirty_bitmap, vec->local_id, 1); } } -void imsic_local_sync_all(void) +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); + if (force_all) + bitmap_fill(lpriv->dirty_bitmap, imsic->global.nr_ids + 1); __imsic_local_sync(lpriv); raw_spin_unlock_irqrestore(&lpriv->lock, flags); } @@ -190,12 +211,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) diff --git a/drivers/irqchip/irq-riscv-imsic-state.h b/drivers/irqchip/irq-riscv-imsic-state.h index 391e44280827..8fae6c99b019 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.h +++ b/drivers/irqchip/irq-riscv-imsic-state.h @@ -74,7 +74,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); From patchwork Sat Dec 14 17:25:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13908532 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (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 7A25A1A8F90 for ; Sat, 14 Dec 2024 17:26:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197181; cv=none; b=e0j+FPPLt6I5pouVk76+1cpbMKG1scn0n4ZlQrMFzEjwrggo8GKeCN31SBk8PEDjKmmFSHdhJFIkbEw13PKde3ycsne55iiVLzoYIZxiRjVcl22wADvAjwrDv0dKS2Wg+bGKjdo2FUTyE3iWEN/lxNpGvIOR89LJi/toKMIVYQg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197181; c=relaxed/simple; bh=GQ6h6qnifBeRvwI5lbrzx5DePz9FG/7AwYjLLcTRLyo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SeYmOET2LvglBy6d67xMKRH+qPwdLgg4XbtorPl3aYmlQpZMqtB44EdX85/WmqZVWQ309gsH2Fvg/SIB0cU8bg9zOIhaDOA2JZPKpmZftWmWt5obhSpXc9TrVh9U1cLbcR4JQ5h/HXyo/s+DraMUf0Iq6zuskqUhrYQNRncYMQ0= 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=ZEGW5259; arc=none smtp.client-ip=209.85.216.47 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="ZEGW5259" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2efd81c7ca4so1871565a91.2 for ; Sat, 14 Dec 2024 09:26:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1734197179; x=1734801979; 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=ZEGW5259/tZtgHpjK1FLA7bdKJYRtSOMCJVHivfasZvwaYA5ZPW5RiMG5CtC0QT4c4 APX4VKhYhUvziQASaQC4oKjQL0nMV2vxBsI85Rsbvn0l+Y2nBLTqR6+AEPNrX2wGvPKK kvdvzv5mpHFD5czW1LsEtNPYARRVlCGVJ/o36bUgsp8trIB+bSHyjz43WI+3sdoTQtys JCWH+7ikvzyUxuoHKbKnqRslJBQW8H+CfaR5cgk3mIGGu0iKmELYLfOuzn8KFiBibPQC VgUOz58/Upm4yTG85cM9eXYWAh3fvOODOJhFCyy5kBRCtogTeGRHdIBTHhyKu/sYNzoF uYlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734197179; x=1734801979; 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=oyJz2vp+o/t8ARdScwv0JtTxGTokFEdvO+gX3S/gK5gjQoXM4Fd99dbJE32uz4zNR4 78GzxiC+UdPGbIVIpWDHfykYUSDu8/1CREoC6I5esNtJhCLvUcaKBR0Gi10K+boUoLGy VIu1pnJekewq79aLU1Q5qSep/y/ZPtHKm7mKvX3vugOeILq8fwyEAMEtDgienL5RwAZX GxN53V2m/4JC4/t4VeGsRcqYaL94AmRdp5kh/XLqaraoiYyYKaF4AOU2Yxw+QAkfNxKJ RmEyV+tQRwVWRxDGMj7fH4dFEH+RmNFKUBa2Zar2x+ma3ANBPmDI7o+55Ivp/oOm+y43 u7lg== X-Forwarded-Encrypted: i=1; AJvYcCVJdSe0TdZYP6XKFtRaw+2PXkmlxaJWmvHDi/XLhfi95y/B7ge5AgnWpE0w9GnjvdyOnGo=@lists.linux.dev X-Gm-Message-State: AOJu0YxmHKiKUIDFL8Wt7irDWMRj/3Zs2PErTCe7jYWoK4Yzz9a2gHmG P9daNeETR4eDZKwUMdFCaVX25AaCLT8EOuvf+5ez1eC6u4QeGCzmuAw4e59FMmA= X-Gm-Gg: ASbGncvI9tu2egorZSCW7cS2NAbOTCWmQmov4fhpUKq6qjvxxtvkVcJkw29Hv4Qmo+b gM9PBPqjMdxVGEFj7mcGFRms7dk/XVMYAsm4WQfPiIYnY/1+zqRpPpA+dM3D2Jggrpjhv32ReQU fVSIj/RcIY1Bbe9hsrUfpyZ7zC44kwVr7fajNZ3zY35JSmlww2KOSLFakqj6paRgphseK30a4ot xD56QVjUgC6CNTeVSsiUsYiBIzd0+t+tHJB4colCxrwFoVIY4gqB3jeLQAAfzsmeLaSTbGBZ96s ZEpqsuSAbRmNVL0= X-Google-Smtp-Source: AGHT+IG/WGdOL5hzTQ/uQVNfvqxiM0q/u2T5n/4NTjrqHoQ7a33gOPCRMyAXNIWVjXMp94uGcfUDkA== X-Received: by 2002:a17:90b:1d8e:b0:2ee:aa95:6de9 with SMTP id 98e67ed59e1d1-2f2904a8b08mr10590547a91.33.1734197178822; Sat, 14 Dec 2024 09:26:18 -0800 (PST) Received: from localhost.localdomain ([223.185.132.246]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f142f9e186sm5049811a91.41.2024.12.14.09.26.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Dec 2024 09:26:18 -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 v2 02/11] irqchip/irq-msi-lib: Optionally set default irq_eoi/irq_ack Date: Sat, 14 Dec 2024 22:55:40 +0530 Message-ID: <20241214172549.8842-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241214172549.8842-1-apatel@ventanamicro.com> References: <20241214172549.8842-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 Sat Dec 14 17:25:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13908533 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (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 6B3F319CC32 for ; Sat, 14 Dec 2024 17:26:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197188; cv=none; b=BIZK9tB+NAB2SPSigRTGPfPyHi3sIu6BVI8XAnRrlYYVPFT/H+7yT70ulvjzgpdTDcZB1o8ocbHYuEAJaNS9aHokFY9niFJ/8PPdvcv73rAkfLr7+iHU3INWtE/CJk5JMFaJmTSxs0zPv0ptQoqttyCDKuwqdVJebcJ6dFcDmcw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197188; c=relaxed/simple; bh=PcKCiIKJzPJB4OrlTg224bcO8uJZAUgM9GlGe6uz0Po=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C6SarhlipQpWrQ4ABigaL81cLUZ6s0M+Tacsbt4AhKkyd9zKq4texTN9bcwm7qKh8eDKdshtSxsqevCn9PCB4SOYZ35O24KYCfpHwxyGP1ZFCQq8TaXqCbUq5IkJepRvmlwNIj5IxjtjkQg6Xjy6DhAEmCaFTp/aUXu5zlAIfXk= 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=bOZO+0dh; arc=none smtp.client-ip=209.85.216.43 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="bOZO+0dh" Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-2f1459b6f84so1809151a91.0 for ; Sat, 14 Dec 2024 09:26:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1734197185; x=1734801985; 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=+XpbAvyCPU7XjesnTrNMuPwq8s0Ofi62LAN8USKi2As=; b=bOZO+0dhA9I2a5vpG6pZP4wsSVixfxq7xhVqp8TKQyV9z1R4nL/gEGZP98aV5GRo3a e07apWV0boiXmyDTDJ1ftbJnA9rBUkKiYU5eLxBGdiMbio9EpaROC14r8k+0ekd5sJWU owxxLKEq5dll3B7XUaH/e40rathBeSZEQJugDskLyy3VOs1t5OC6P63PeKXKyIgJAYTa OnKlo6vm5gwnR1jkT2RvsQZknQyBnqNOs3AWhwCOy8FhHBsHSYW/q55ORGor+UTUls7k EthLlovdDVpYPW9ohhv3mmWStAhnRaMc499AXNEFqrgesYnFqDcogpwf1F52vVyNoUQz 5gZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734197185; x=1734801985; 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=+XpbAvyCPU7XjesnTrNMuPwq8s0Ofi62LAN8USKi2As=; b=t/MOiUthN2XJAUx/CXqLQ71FEi39S7vBXNlRYAwAP4gt3AbfBI792nQ+Bzt42ojO2E szohfSnZvpBC84hiYkWo2RgFkIR8XeK4/hv62qI67szvIxKceMhHytomT6r7vLJHWbWv EK59t4z/ERQ0I170cqzoxORgJmrRlIU0acfFeJx9C1DNriwLzbBfGQQQLW554dGqcTrQ EZIisFuNKa3Ue0ZoRpP8XxojREDsOkRaDq6GC0XfWhvHGbOMk2IVbs7TwYRf5e0Fh1W7 ProxWlv0XAz63iFjtIeIROijNjRzwXl87iMvCmkVhFGmGOexFyx5ikSpNDTl0e3gnztE BkYg== X-Forwarded-Encrypted: i=1; AJvYcCXpMA01WQEqfukETFpw37HR/0bnAxnM8kOkfkVebt/uezPBaPDgukRCcRHbRk4ZsprSZLU=@lists.linux.dev X-Gm-Message-State: AOJu0YzUmp/VsuFi9XxJTMkvJcmb25DBdcsKydLL+DrT6Tc3UPAGjUbt W9K4IKvmYKx8P76RCN+79fM1V5yci+SUAbUgQkEppPiP4PzLNkXYeShimKy4wE0= X-Gm-Gg: ASbGnctA5E9eWGm2QIws9K6/kBhMkWlwaQyzrFAugl5ZyncSPEi9G8VUyHNkjSE2Uly k4ZwNc8Qx5ka+3FAP3sOjgA5mcqqYxwn56Qz6VhFm/m+nvvs79C3i4QdQRQQuBk3oPdDGDmf3zh DVaqcBdJKQfnDLGQ0i6+XwbTgIMgbc907jtc6HVpgSDAwHPEQeWRzXMjGLzlH4DvX1o6Ghh7hmu FFyivFIOEm2RiNVmma/dbRKEV1X6gW9hIjqKiS6TAKRmvSiCLeFuro0kwGqFBGzP/W1wPx6iHeq 0mkaESRwPpSDi9E= X-Google-Smtp-Source: AGHT+IE1SPKm+gzJ6VGXDJy+q7RKdAC9iquVy8ivXNUGMyZxEqe5AtUA6j7vJ+xaqDvjxeC/PzggwA== X-Received: by 2002:a17:90b:3c02:b0:2ee:5958:86d with SMTP id 98e67ed59e1d1-2f28fb6764amr10436246a91.9.1734197185565; Sat, 14 Dec 2024 09:26:25 -0800 (PST) Received: from localhost.localdomain ([223.185.132.246]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f142f9e186sm5049811a91.41.2024.12.14.09.26.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Dec 2024 09:26:25 -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 v2 03/11] irqchip/riscv-imsic: Set irq_set_affinity for IMSIC base Date: Sat, 14 Dec 2024 22:55:41 +0530 Message-ID: <20241214172549.8842-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241214172549.8842-1-apatel@ventanamicro.com> References: <20241214172549.8842-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 | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c index b44eb0b3990b..dc6f63f657e4 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -96,10 +96,9 @@ 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; struct imsic_vector tmp_vec; - 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; @@ -139,17 +138,17 @@ static int imsic_irq_set_affinity(struct irq_data *d, const struct cpumask *mask tmp_vec.local_id = new_vec->local_id; /* Point device to the temporary vector */ - imsic_msi_update_msg(d, &tmp_vec); + imsic_msi_update_msg(irq_get_irq_data(d->irq), &tmp_vec); } /* 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); @@ -162,6 +161,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 | @@ -272,7 +274,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 Sat Dec 14 17:25:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13908534 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (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 5DE172033A for ; Sat, 14 Dec 2024 17:26:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197194; cv=none; b=aKwk1qcggKHmJFLvDZUTrxtKO3fH6Lmm9VrziECCEEEgWooVxgARVn375y8IyXimiHoASBtvOxiGbWc0K97skmeK1L2+6ItVOP3uBvBZH8S13POjrtTXu1wAHqEZfzPJF/+fQZect7rLy6ZfVrihLkOWwrrTIBMDE19cYz7+EW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197194; c=relaxed/simple; bh=Mfh/oKVyV/v62tUmOG9j432HyhjKXncy+MsddMkaJpM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o6CCjfJy/0QSL0aNsXUayh4pCWtEH2T52bQY4sCs+NELmZqRoAhjw3BL14aZneVVS4CxHX6VUyB24H9uLV3t3xblOQQVvbPuBC8dtHpwdYtSykDvWXhrpl9gpdQBqWjaXFyshJmZKQ78h/LFpM1eAsUMllwv4myLF8nPwW0D04k= 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=HclOy8ID; arc=none smtp.client-ip=209.85.216.52 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="HclOy8ID" Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-2ee50ffcf14so3084855a91.0 for ; Sat, 14 Dec 2024 09:26:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1734197193; x=1734801993; 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=WTMHZPsDjixID3LZgZypNI5zerTGwhJ3oNH3JU/CG6w=; b=HclOy8IDPJKAVwZ+uRL8icI4CcbJM+4gSELoBJdRQJnjFR6HcduQbwJeuyiLyIuvHx OxBFEMCBJPg/xrGq467290rtmqsEpOWz5HzmkhdZTDjfqvQOOT7SImKG073SQ75yNRU9 jHo/kDqNfiZqZFcEiLxF60YeT3hxr/6udJZgmJdQJ/LLs+I6J2O7nMJkO3lJIDpS00MN qgW556UsEusFvuurSxQGRQGdU2+JDBjHv+c9plY/z63Fr773Sb7iACw66vE0/Jpqwuue eXR4jy3FPCbqILB5S3X/3agkuxvB/miCniiErp8Tj98T+0SurDSqLbWvcusakMp3SY69 3WZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734197193; x=1734801993; 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=WTMHZPsDjixID3LZgZypNI5zerTGwhJ3oNH3JU/CG6w=; b=ptSN8rMMy9yTS/s2Db0UFcQG6UIw/w9jBdywdqpQ4wn7aN3BXih88Pv11iz5wt9jr2 kHS3al4Raua2NNAZDkW29qDUNKUTXR6bz5S1f/g4jWerTCl7HPaqDQRCPqrsF+bb1Pet JWOFRhjkBEYeIkYLk6YWbQTXpxAAA5Hi/lSjxE4I3XEd0xUYfhHu6grGOImqFZm3Jl4n RaE0EuxvVm4mYt4ZHUuhN8xHsVDfn4bZJG6jaIzB0Nkgp4EUGGtPxsVMyBRLop2O2d4W n/kjTCpsVooNn51QCo0YnaG+UfziN8Ir2tFEPIvX2h77P7Bky2VrI5F4OuhWHnw3+tgB Ey1w== X-Forwarded-Encrypted: i=1; AJvYcCUQa/IFmyHQOnme9zk0ubefpsY+x9gGvjQNxYVkSF9GsIt8Ud7uOBqLvUbyKDv6YdZX7F8=@lists.linux.dev X-Gm-Message-State: AOJu0YxoM2gvbcYTRiE5I6/cvAuRh1ylmyAPA+/pyotXdsRuMQVKkZwb dnQJVZ+wVkEFnvyFdfWMhlAYrqXW4mTYTGURE26+5OoRR9oa9S87TrGjIljlBUE= X-Gm-Gg: ASbGnctJgXz74hzpEYlBINTwnMwIt6S9HvA3Ham/3tS32Es7uxLw3KOrKxA03eu0hfm UocUDdQPLIHiClePxnbs2nNsze74wsppsUAOmDOhM1eBGswp1SKh1Qsk61bOFFOWW9s+AFC/PO+ aE4SqMhovILh2gJsroKaRpbqiiiPj+8dbjaLjbD5A3T6cX5m0+S16toewG0OU2qwrFN0cKZiESw s4mOFWq/zz8CW2a7zt0tqHk2T6+MbzDdKgEzD8h1S4UTFviSqxvgBDlLt2BwzfRPb7wjnMaqvJ1 24iDe7OXa1Xbnbo= X-Google-Smtp-Source: AGHT+IH7cEjTQcM+udD/U5XRPprvWKA6NBoe1GlzDD6yjgsEVTNKRYALRcnCyPJucGTbfWHoFFxtSg== X-Received: by 2002:a17:90b:4d05:b0:2ef:ad27:7c1a with SMTP id 98e67ed59e1d1-2f13ab74905mr16256697a91.2.1734197192577; Sat, 14 Dec 2024 09:26:32 -0800 (PST) Received: from localhost.localdomain ([223.185.132.246]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f142f9e186sm5049811a91.41.2024.12.14.09.26.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Dec 2024 09:26: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 v2 04/11] irqchip/riscv-imsic: Move to common MSI lib Date: Sat, 14 Dec 2024 22:55:42 +0530 Message-ID: <20241214172549.8842-5-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241214172549.8842-1-apatel@ventanamicro.com> References: <20241214172549.8842-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 55d7122121e2..6b767b8c974f 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -587,13 +587,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 dc6f63f657e4..2fab20d2ce3e 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, @@ -201,22 +202,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) @@ -233,110 +218,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 Sat Dec 14 17:25:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13908535 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) (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 368CC1922D4 for ; Sat, 14 Dec 2024 17:26:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197201; cv=none; b=XEClpdxJvgWvXbYeqjL5Oso269E8EQej3LiIhHNbOeB9+lM6Nc0E7ygFRbElTgvNXqRcofq12pJG6I49mJiV1HhqPiHwuv/Z9Ad+VbituQjuwoYqBg/png/aW5wNHQ198C5LAd0sxa3l77ExFioTT0VLsmkO9w7YNw1dh450HNg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197201; c=relaxed/simple; bh=6PIAjGaZKQwEt/EjBHyszo+wahqk5t1wsyFIUnbE8YI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MW38z1lKng4u6Kycd2NIx7KNczT6kxo6aW4DKi0NGrPzewKGuINtIxfTPI7b4Mw3cjBTWzeHpYNcnvzChlu47zsUVbYfH/0r2b5YtZ7RD8Qgz5DK5Ppy/yIaeCOfasNKMlFTeyfN7Vzxm3tb6/Ls7Ww/ryNDYV84dUKOXM4pGQQ= 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=bn4n5GCb; arc=none smtp.client-ip=209.85.215.179 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="bn4n5GCb" Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-7ea8de14848so1566144a12.2 for ; Sat, 14 Dec 2024 09:26:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1734197199; x=1734801999; 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=u6payGCmGMW/0vjHgpi/115tsc+b1yXaj6IL2K0q/xw=; b=bn4n5GCbmn4jlzVJCdiGzTgGBtbvw/2C4OcYJUlf7tlE3Nx9Y7GUQ6guK9bIhtXoA6 geX3/HgarZhHnr8InjKTjmPrcKIBHvQ+H41tvlqcSjzCaAVh9JMgNaY1iwX8OXCMnnub 6/hm5+4HvFjjMu4bLx/gkhA5VGATqtrGsFbeZJO75oOyfrhY0Q8+gy9luLuAEJuhTo87 EkhumccnqGTxc/9VP7EKeoXLyGPF9Q/nao5TN1JybPc5YhwhIobeoJf2zzI4ZzP6pupa ZTVEWJPmTvhOd167KgKIWioedj6Z7GOgpmD4Sj4VyVPF9is6sVJXD/YqH8EV9dIb27Ex SCfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734197199; x=1734801999; 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=u6payGCmGMW/0vjHgpi/115tsc+b1yXaj6IL2K0q/xw=; b=o7ONl5iE0oaO79Wy8r/4Pa0RXGACPcgFoRwjcteCDDpNHDtLEIMTeQM+hRFoqwoZtG FuovZ69bQge+R3ga+0iTHB2K+XPRkJqTN4XxNu/xqDgA2q2bEtTmbhyfPWfBWjfGEOy5 OCAHlkEahTyQwmzpYsTn7x8b1GhNF2tGaRpOPIcBoM+abnllgBrS4g5PqrENpKx7dV9o F9suOUrlHSYAO4kMsWLOkCUTUb2ts1IFruqeLquDfZEAbD8A1yuBXoE0q2dRPSL0Wcji nDxTnQ8jqqO6ebe2Yunvfj8qxT/Td4Af2ScTZrG8dEbWQMv2FKabe2LVaPbAY+oGzSeG y0HA== X-Forwarded-Encrypted: i=1; AJvYcCW8B9kaWYEGZvntPoAtm9u9G+wakkJhHJEAb/oTEpJysVyptkpInxElF16K82DgDjD8AcU=@lists.linux.dev X-Gm-Message-State: AOJu0Yzc8YXcca/E1C+N6GI7NXAfmA6VK++Vg7QR3Ig0JeifmO40kveF jPkqtY4UDIyJPuX781EImxy2Vptg3hrEiVTlDgizzkK4f3O9nvP5qPkf0Bopnx8= X-Gm-Gg: ASbGncv/9qiAXBu9hRCyeQrH2k65tqptURPsf/fLSgfvewCbguo0kADETk00IvvxKpU EeCCoHr98sckcUvVQtdMImvp08dbFZI4khQ4QOlTsF4jZf5kXq+mfd0HbGWPUU492iOfNiObR0X kI6LPhhyX7T9raEISjk7FbKOzo/CnEsNKUa+YavyKOOrWWj/UaqKA8an04c2hDEC7hnn98BC9ZW V8hXn+N6eMzV34JG5ccPaPuK+44Q1kognV25p0EgQO2GSKmk1Ffmtnijoe1+fwACRvbr3ZyZ4iJ GFF59Besk0Oxwfs= X-Google-Smtp-Source: AGHT+IE4G8tF4t4tobhDLydlOHpy74mKHnjdVddbrMVpE78sNcz73JzvON/bt8jZjW3R+eaoP7P0Vw== X-Received: by 2002:a17:90b:2242:b0:2ee:ba0c:1726 with SMTP id 98e67ed59e1d1-2f2901b253dmr8940041a91.34.1734197199504; Sat, 14 Dec 2024 09:26:39 -0800 (PST) Received: from localhost.localdomain ([223.185.132.246]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f142f9e186sm5049811a91.41.2024.12.14.09.26.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Dec 2024 09:26:39 -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 v2 05/11] genirq: Introduce kconfig option GENERIC_PENDING_IRQ_CHIPFLAGS Date: Sat, 14 Dec 2024 22:55:43 +0530 Message-ID: <20241214172549.8842-6-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241214172549.8842-1-apatel@ventanamicro.com> References: <20241214172549.8842-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 kconfig option GENERIC_PENDING_IRQ_CHIPFLAGS which allows irq core to set IRQD_MOVE_PCNTXT flag based on IRQCHIP_MOVE_DEFERRED flag. This kconfig option will help architectures such as x86 and RISC-V to mark top-level irqchip instances where irqs can't be moved in the process context. Signed-off-by: Thomas Gleixner Signed-off-by: Anup Patel --- include/linux/irq.h | 10 ++++++++++ kernel/irq/Kconfig | 4 ++++ kernel/irq/chip.c | 39 ++++++++++++++++++++++++++++++++++++--- kernel/irq/irqdomain.c | 1 + 4 files changed, 51 insertions(+), 3 deletions(-) diff --git a/include/linux/irq.h b/include/linux/irq.h index fa711f80957b..b689c8fe8d60 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -567,6 +567,7 @@ struct irq_chip { * in the suspend path if they are in disabled state * IRQCHIP_AFFINITY_PRE_STARTUP: Default affinity update before startup * IRQCHIP_IMMUTABLE: Don't ever change anything in this chip + * IRQCHIP_MOVE_DEFERRED: Move the interrupt in actual interrupt context */ enum { IRQCHIP_SET_TYPE_MASKED = (1 << 0), @@ -581,6 +582,7 @@ enum { IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND = (1 << 9), IRQCHIP_AFFINITY_PRE_STARTUP = (1 << 10), IRQCHIP_IMMUTABLE = (1 << 11), + IRQCHIP_MOVE_DEFERRED = (1 << 12), }; #include @@ -634,6 +636,14 @@ static inline void irq_move_masked_irq(struct irq_data *data) { } static inline void irq_force_complete_move(struct irq_desc *desc) { } #endif +#if defined(CONFIG_GENERIC_PENDING_IRQ_CHIPFLAGS) +void irq_update_pcntxt_flag(unsigned int irq, const struct irq_chip *chip); +#else +static inline void irq_update_pcntxt_flag(unsigned int irq, const struct irq_chip *chip) +{ +} +#endif + extern int no_irq_affinity; #ifdef CONFIG_HARDIRQS_SW_RESEND diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig index 529adb1f5859..6d85a47fbf41 100644 --- a/kernel/irq/Kconfig +++ b/kernel/irq/Kconfig @@ -31,6 +31,10 @@ 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 diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index 271e9139de77..623959a24464 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -33,6 +33,33 @@ struct irqaction chained_action = { .handler = bad_chained_irq, }; +#ifdef CONFIG_GENERIC_PENDING_IRQ_CHIPFLAGS +static void __irq_update_pcntxt_flag(struct irq_desc *desc, + const struct irq_chip *chip) +{ + if (chip) { + if (chip->flags & IRQCHIP_MOVE_DEFERRED) + irqd_clear(&desc->irq_data, IRQD_MOVE_PCNTXT); + else + irqd_set(&desc->irq_data, IRQD_MOVE_PCNTXT); + } +} + +void irq_update_pcntxt_flag(unsigned int irq, const struct irq_chip *chip) +{ + unsigned long flags; + struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0); + + __irq_update_pcntxt_flag(desc, chip); + irq_put_desc_unlock(desc, flags); +} +#else +static inline void __irq_update_pcntxt_flag(struct irq_desc *desc, + const struct irq_chip *chip) +{ +} +#endif + /** * irq_set_chip - set the irq chip for an irq * @irq: irq number @@ -47,6 +74,7 @@ int irq_set_chip(unsigned int irq, const struct irq_chip *chip) return -EINVAL; desc->irq_data.chip = (struct irq_chip *)(chip ?: &no_irq_chip); + __irq_update_pcntxt_flag(desc, chip); irq_put_desc_unlock(desc, flags); /* * For !CONFIG_SPARSE_IRQ make the irq show up in @@ -1114,16 +1142,21 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set) trigger = irqd_get_trigger_type(&desc->irq_data); irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU | - IRQD_TRIGGER_MASK | IRQD_LEVEL | IRQD_MOVE_PCNTXT); + IRQD_TRIGGER_MASK | IRQD_LEVEL); if (irq_settings_has_no_balance_set(desc)) irqd_set(&desc->irq_data, IRQD_NO_BALANCING); if (irq_settings_is_per_cpu(desc)) irqd_set(&desc->irq_data, IRQD_PER_CPU); - if (irq_settings_can_move_pcntxt(desc)) - irqd_set(&desc->irq_data, IRQD_MOVE_PCNTXT); if (irq_settings_is_level(desc)) irqd_set(&desc->irq_data, IRQD_LEVEL); + /* Keep this around until x86 is converted over */ + if (!IS_ENABLED(CONFIG_GENERIC_PENDING_IRQ_CHIPFLAGS)) { + irqd_clear(&desc->irq_data, IRQD_MOVE_PCNTXT); + if (irq_settings_can_move_pcntxt(desc)) + irqd_set(&desc->irq_data, IRQD_MOVE_PCNTXT); + } + tmp = irq_settings_get_trigger_mask(desc); if (tmp != IRQ_TYPE_NONE) trigger = tmp; diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index ec6d8e72d980..ec5fc1d8cebe 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -1508,6 +1508,7 @@ int irq_domain_set_hwirq_and_chip(struct irq_domain *domain, unsigned int virq, irq_data->hwirq = hwirq; irq_data->chip = (struct irq_chip *)(chip ? chip : &no_irq_chip); irq_data->chip_data = chip_data; + irq_update_pcntxt_flag(virq, chip); return 0; } From patchwork Sat Dec 14 17:25:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13908536 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 5243F194C85 for ; Sat, 14 Dec 2024 17:26:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197208; cv=none; b=aNk60qNDiJQCL1bzdX+G0iD1U9hXsfhTxvvVaNMRW/EIBLsJHEadEM4oRDoTKesx3ZrrwrKkE+DGhLQhye3DWOkdH26nfbKjYNDV07qU6GWnLnNrRvkpzOzZNRtvS4585F7C0E0hmTJRkEf2iVEhg9cAxDAHJHxHbvdktSWFr/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197208; c=relaxed/simple; bh=KQvgHMf4mn/NJ5Xhw6rUHo6j+G4++aBmhNInEZUS85A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RSNXVP+v2NqgZyjQLLNote34tuL/3uYjAoJQTvbS+9CeAYBMJQkng3bg9VxyuUc+y5U0rhexTnwFFoNFunxA5rrYjad/aAJxtYziA1DRK9t02zAqMXpSPKzWx7rRBNxwJOwKR3VIjFt3OcKGioWMzZr5A8pWob/tb9Tqp08YhXE= 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=LPkOXNDk; arc=none smtp.client-ip=209.85.214.170 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="LPkOXNDk" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2164b1f05caso26267375ad.3 for ; Sat, 14 Dec 2024 09:26:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1734197207; x=1734802007; 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=nBJthI+mqNYzorludLEAXvfiuDja+LCnD6djvnBek6Y=; b=LPkOXNDkKTPGM6GU2f1BylKoeJAFEScKcgivcR8ta6Pk2dMmuDaPU4zM0L9QHraQW9 dmmSvhyS65zuzbzvyHqgfkkFNFXd3YLZq/UDGL9Wa1d9e1y/PXt1p3W46SIDWq5q6Pwz GwMtGK8hq2UR5eyTW+9XGYvmzsMk9Ji1dyEmIqu8XFwnR7Kk3v6Vblt7t6hCGRbx0IYC q9hSRiEK5QTahX1ShOEnLULtqKCOZMuEyfTWkj+572pXZDPq284uXVQAL4vjbHRYplKA csjKj3mUxlELKiSST87Uht4qeIaxlKMjf8AkoL3vJF48DehoigOgDSFVMHO5oYPlJKTg z+9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734197207; x=1734802007; 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=nBJthI+mqNYzorludLEAXvfiuDja+LCnD6djvnBek6Y=; b=nuGEjvUAY8pEB02406Dy0G4Q0oM5NC4qnQGnXxJsYFe//r9DLdbD9Y3voc72QvWg3I AoGXi3HskHxT6tOI9T/xu5vZ9DCp0OTX49E1BrrsmZ0grVmbDF44ZXTfIMo7i7tZw4W/ WetKbKzLJ713FuwV++BSRe9/XWsEM3RPAfT0CoXi6Z7IowgXIwlOAJqBUAYjS5mrmq6z fzPAwJGbffiDMETjbKY8F/3GJVveK1usQ2qksCom/ZJolk6POkiWzb8QswxRlk/fZr1O PLMIiD+FYlut11lMimPq9Ix7ETuBUZH3p6gjg/I5HF47AsrHrLMXoUMPwDCc7Sm3i570 R7gQ== X-Forwarded-Encrypted: i=1; AJvYcCWBH92uctfWfQWVVq4RLjjEfrX37UAEnwColBQjOX1+XbmT2/eJqc7Zep18Y2sWNOJ7U3s=@lists.linux.dev X-Gm-Message-State: AOJu0Yw5kITQ8yBPamFGURekDAj1sIMfE4qmBwvm/h9OZkdetXQ6bJrN walYoIvqQA7CPIEDGvPBqzBiJLljzSKyqgH8A6C4/fr5aeITiQqdb2f3Jcni5ek= X-Gm-Gg: ASbGncuDvkJBbgY7tnhiddLfRpFPFN9d01LB8GyYEW+HWQH2xCPtUfyAOsxlixMIt16 o0/SdRv5AWO5wevWWP2bTmJaCLLhT4VKPIl4q6faaxLQdCkXIcCrO6hBOxOc53vnHLXEN/cnQDq JiqzwZeo2YTYYn0YVo4wLbHHU6dvRAAoZat2ajT4nZS6L6yMe8fE0Q+oPWdWbLcxUkliSYuYNvp /EH3glx0OG4AnnCCNiVaxD5aXb1+xcxGF11epLFtU4YeQl1y2K/U12vu3gXQR8PfYYb/lIAi4b9 NzMITJm+yNZZ9wk= X-Google-Smtp-Source: AGHT+IHWMVLk7VAHEJKffclkR/GgfiztR1cE76mj+f0onDTerIF7KBl2vajNkAVkEerHi9sn/JzVIA== X-Received: by 2002:a17:902:ccd0:b0:216:3466:7414 with SMTP id d9443c01a7336-21892a41a9dmr113376145ad.44.1734197206669; Sat, 14 Dec 2024 09:26:46 -0800 (PST) Received: from localhost.localdomain ([223.185.132.246]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f142f9e186sm5049811a91.41.2024.12.14.09.26.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Dec 2024 09:26:46 -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 v2 06/11] genirq: Introduce common irq_force_complete_move() implementation Date: Sat, 14 Dec 2024 22:55:44 +0530 Message-ID: <20241214172549.8842-7-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241214172549.8842-1-apatel@ventanamicro.com> References: <20241214172549.8842-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 b689c8fe8d60..509c0ee4ef38 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -496,6 +496,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 { @@ -547,6 +548,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 Sat Dec 14 17:25:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13908537 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 CE77F1A8F94 for ; Sat, 14 Dec 2024 17:26:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197215; cv=none; b=HISKGzwh/SHTzm/9PGg1n8jbUn0uzYi/8wGLvXAzyOtIoWMU0DoYrpEd/IfRnH75B/3Zk5tBC5Uj9az5Ol6AkuWk8PXkltNsi7xVH5hkRJ5zmKuYjMRggu1sz9+TLRCOhvtNMhakpuN1Y+kBpy+aqOO0HJlYOX3hwKUfj87Q1dA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197215; c=relaxed/simple; bh=aE+CJCpUn5kUAnEgYyEV3gtDvbC5Svv8OP258wfgmN4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LVeCrURO8m7Pi4RFYu3BWBhTExqzGOGRea56OPz7NHxNOOX9w00Vr42U+7YFpAPlwdP+KZB4HC2kPNxfXbGMKyA8TEgh+twznBC7MXLlgPupMe64MxF0Roqt9smFALI9jeBZQ6g1gYVw8g+mkcc+8MrblIti/hKq4h7F8tY6JzM= 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=RTK2KRNY; arc=none smtp.client-ip=209.85.214.174 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="RTK2KRNY" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-216401de828so22845625ad.3 for ; Sat, 14 Dec 2024 09:26:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1734197213; x=1734802013; 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=yE+w0neHmk87dMRt+p213gF5rtqgAWN6iext8wGVFRM=; b=RTK2KRNYAB1JFHMvzrBqOMU6Bc059Qt6t8ZFq/IMyuBkzbAh2Mf5Kt7TYpN33dVRd/ Zs2iTLFy1gAkFjX+puqTFdGWMlhzY1od5KG2eyXV9Gr8MB8zu/W4wHWcuEXjz72EBe3r 16YGyv3gbmojw2wb4jsjhGc53aB0i85x9v7QDrxrvCTXlTecvOpBPwCJ3nRlDBqeK8mL E9guE58g6Y5+2hr4V4BR/Ro+DzQnvqeDeKZNL0h+xu0wPUGoFhIzAC8oDDYPq9qrcrAi cXOGpPhkxlAgaIgW6mHgcoDIMSAauuafgPVrw/B00LKAvoLwAXbxkHndU8/c6XJIS4rU Vprg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734197213; x=1734802013; 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=yE+w0neHmk87dMRt+p213gF5rtqgAWN6iext8wGVFRM=; b=Q+4kttDDKnI7oia6H3rpThgtMeYQRlLd3KfcrKuZGAD1hGC384kq27Nhj4HWtbbj3r 4DVqrH3bzfmUL6rHb0oZ8hfuvMO2XKxHGDXCbxkf0VNoixxqtQRr4AcROV64/8/Y+akQ uMFrMnVzByiHcsO2DD4yK6bmEkHTwqZ1ZVU4s4N2jGtvq8ipH9j2jNeDGLvuxUE7h34G nxnQ07nKLpo3LVTiDW+jtxKbw00ZveC9svnlOplq/v8idrEtqJWOphtMp2sf2u06DoVm LDUzBBD7aF7seCeAuPET5C3vhyjyZkO+Wz42giptO0px/mXYxE4VvtF1iZLQ1k+FGA+l Qvug== X-Forwarded-Encrypted: i=1; AJvYcCVOmrlp6SBFeAlUZpMlLw/DSAKJiJkT0eOrgczxRpYwsPQ82RCyRvc01GWr6F+Oa47tBag=@lists.linux.dev X-Gm-Message-State: AOJu0Yx7QHhaCNomtvWH3Fc7Z5NIZWpu373S1nk/cz/uhm7SuIPBwcoZ ATI+j+oM49EFYpHWw6kjFC/eR99AoUr0oLoUV0XatO/g+9srasyeXsbqyR76u/I= X-Gm-Gg: ASbGncvoNJyrnpw/TwTDrHLnDX9Bqlgc1r6koWwzzA85/ujUMvVBzJ2/rNGKpRqL9gJ D7H3MAiG7UiqlZVZuHANcFWwE6qDkqDQ8pI4/5n4+1DvJLpsIUHBmmkmkg+WKtBlpix0fTDPNDR rFKmzNv2K4w5BwmlxZsJAXiReN7X7XnBNjrOlNLPBa78QXzQx1B5kX/ood0CSSccIu6DVVdeC/w Y5zHy1G5luzBCtBthEMTBtmZKTkKnPWzTvnVOzn6EQipaMj9ipmd9tfSpzxKoJsi57ShdpnDLoe Eoq03gatiQyIVno= X-Google-Smtp-Source: AGHT+IFHcRze2J0M8hyBJEZA/NeT8/eZWD7tT0rfNtTykqj4Jc1ZWMZrjfrUoQxfR7mhTVQoKpV61g== X-Received: by 2002:a17:902:e545:b0:216:30f9:93d4 with SMTP id d9443c01a7336-2189298bbf7mr99837005ad.8.1734197213088; Sat, 14 Dec 2024 09:26:53 -0800 (PST) Received: from localhost.localdomain ([223.185.132.246]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f142f9e186sm5049811a91.41.2024.12.14.09.26.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Dec 2024 09:26:52 -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 v2 07/11] RISC-V: Enable GENERIC_PENDING_IRQ and GENERIC_PENDING_IRQ_CHIPFLAGS Date: Sat, 14 Dec 2024 22:55:45 +0530 Message-ID: <20241214172549.8842-8-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241214172549.8842-1-apatel@ventanamicro.com> References: <20241214172549.8842-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 and GENERIC_PENDING_IRQ_CHIPFLAGS 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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index d4a7ca0388c0..adc878f029fb 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -110,6 +110,8 @@ 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_PENDING_IRQ_CHIPFLAGS if SMP select GENERIC_PCI_IOMAP select GENERIC_PTDUMP if MMU select GENERIC_SCHED_CLOCK From patchwork Sat Dec 14 17:25:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13908538 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (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 D1561199223 for ; Sat, 14 Dec 2024 17:27:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197222; cv=none; b=AjG5ZeIEzYV9kg/dgGCyykmK2YfimqFR1ZeJ3vKih5oAmfiKdWKnOxaOUAXGI9P2lhxepjiyaaV1u5Ir7uNAjJwg13RA1GIATYSjJ5hoWpwSjYu7yHfN4MaUSAU0n8ypF3xPDf2SX1Vh29OYhLQeC019+iXKvK89kgrsGEi+Xcs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197222; c=relaxed/simple; bh=0ljoGbT/LRu6wccIGReKAg8EOuGxkwBf9UmQIRwMDWw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tokye7S/5rmNJsyY0fgpMNdFdEBSBxh5D+bCXwvlYY1YbZ3DmemOPbMYhOOmi6QPusufE1dVUuWjpEUzrdt3ZrGESCtUEuGMSexmbW0pkna9qg9GobkVouVb5UA3vgVIpLfLjItb9Qdd3ntDzI40GqqMGsbw3WC+vW5JavQ1Adw= 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=irwGfZQN; arc=none smtp.client-ip=209.85.215.174 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="irwGfZQN" Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-7fd17f2312bso2036652a12.0 for ; Sat, 14 Dec 2024 09:27:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1734197220; x=1734802020; 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=qKWIt7ITp/X88ndEH7it4rZ1geXjjPOabq3XOqds9DM=; b=irwGfZQNqx1bl9iD3JJEes0PcHI6UWKyIMq5WIwzOY9iMUNOOkx8ULq87ceEkT+seq JAkQY7CCsauQH+OPQhQ8fsQNJEiJeu1pbclyz7205PvNLEFqZiktow468EClnf//0y7G Efxe3UkcWg++16hEKFrjl96fXzd1oFPTUHVR9g9ArfwgXPmEOS/UdB6/h7ivTI7cPSod oRhBithkbY3aDb0+beVkU5L2rrC0yp8o9i4gYDGbgf7BXSxauM7kKScObHgyYH4j7kEw 8EC27ohQF2fTmVNoZlUt0e+QIPVD3/Furr/xRkJcAGfTnn+s5CHpcgmU21D5KY4PKxe2 r/tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734197220; x=1734802020; 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=qKWIt7ITp/X88ndEH7it4rZ1geXjjPOabq3XOqds9DM=; b=nXnQrhepz9Cw9YB6Q1FLbH6M4kHr/QYr9890TkPqqDy41CGm4lsUHSRROtVEDkdF64 GtPxcvbdfEHo09JtPKAu3wSlgqYkPP/1BnRR2XqpAc51KZ/mBu0VolLMCJFz0dTvkkzl +d8uKhibtvl89VEBxDoABsjxaD8T1nUsYeChjMzEfXryayRsX1+KOl410thGICbUVldP ugZcJ6BWQbbjACDjny5tTQYts7/KdND3LXbBFl2RF1M4UL8SEwMEsA/DRpXOg8GT3TEZ ZN82423GZdGZmIgY+uhZ8oWm9U7kfHRrlK2tE5xLjh50GmH8SnhsSg+9PjR2/+ENR7VV Xflw== X-Forwarded-Encrypted: i=1; AJvYcCXzi9iwviW0A5aGW6AlIRKuisuC6wxCHujZvf3dEMZpEwxYR7jDLAQUxYamD2UBuC9OBGE=@lists.linux.dev X-Gm-Message-State: AOJu0YwmFrOtMow6Z8jgMu6edOevbgmyx4VR3q5kHm1LK+0f0Bea2GS/ IwJSx5kG5V/33vxuhFKFjlT0JfQCB42OVTuPcME7YMnpWdLLuGqvfh2lQJ3m58E= X-Gm-Gg: ASbGncuxftp62NB3S86FdAFoFw6OMabja/rRyUYsJH05c08BpE7y7LjehcEdNJ9YvdT fKxRPjQLAdSsHvFqEBf93WsLcaphk+O0nFsei+2fS4TZqk3G3lVuDElMFjJdLYh/XwJpd7oCG49 iG2Zmb2DRj6zrCMx62zFQ2x60T3zlYoNNROHXr/rquRQF0BOLPEkkagbhs5FBqCq6wuLthsdiIe O4rcw2dQs0cLZgzFaV7fO5qo1yvQidSxdR+u7tEh7EP5qysHUtGQ1LD4rOAvwmFqgkuk8DMhfmh QIbLdFGeiCeLezc= X-Google-Smtp-Source: AGHT+IGQwf+KWHUKDSuNXTV8W8BsAm/unz0Vds64eL7itxYSGgZbtZcUWjgcYwS8LtLhLbggFNNyJA== X-Received: by 2002:a17:90b:5112:b0:2ea:4c4f:bd20 with SMTP id 98e67ed59e1d1-2f2904a724dmr9248924a91.32.1734197220158; Sat, 14 Dec 2024 09:27:00 -0800 (PST) Received: from localhost.localdomain ([223.185.132.246]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f142f9e186sm5049811a91.41.2024.12.14.09.26.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Dec 2024 09:26:59 -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 v2 08/11] irqchip/riscv-imsic: Separate next and previous pointers in IMSIC vector Date: Sat, 14 Dec 2024 22:55:46 +0530 Message-ID: <20241214172549.8842-9-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241214172549.8842-1-apatel@ventanamicro.com> References: <20241214172549.8842-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" pointers are cleared separately by __imsic_local_sync() on the old and new CPUs respectively. Signed-off-by: Anup Patel --- drivers/irqchip/irq-riscv-imsic-state.c | 60 +++++++++++++++++++------ drivers/irqchip/irq-riscv-imsic-state.h | 5 ++- 2 files changed, 50 insertions(+), 15 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-riscv-imsic-state.c index a8645084bd8f..da49a160ea09 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 *tlocal, *mlocal; struct imsic_vector *vec, *tvec, *mvec; + bool ret = true; int i; lockdep_assert_held(&lpriv->lock); @@ -142,15 +143,33 @@ static void __imsic_local_sync(struct imsic_local_priv *lpriv) else __imsic_id_clear_enable(vec->local_id); + /* + * If the ID was being moved from an existing ID on some + * other CPU then we clear the pervious vector pointer + * only after the movement is complete. + */ + mvec = READ_ONCE(vec->move_prev); + if (mvec) { + /* + * If the old IMSIC 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 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. */ - mvec = READ_ONCE(vec->move); - WRITE_ONCE(vec->move, NULL); - if (mvec && mvec != vec) { + mvec = READ_ONCE(vec->move_next); + if (mvec) { /* * Device having non-atomic MSI update might see an * intermediate state so check both old ID and new ID @@ -177,11 +196,14 @@ static void __imsic_local_sync(struct imsic_local_priv *lpriv) writel_relaxed(mvec->local_id, mlocal->msi_va); } + WRITE_ONCE(vec->move_next, NULL); imsic_vector_free(vec); } bitmap_clear(lpriv->dirty_bitmap, vec->local_id, 1); } + + return ret; } void imsic_local_sync_all(bool force_all) @@ -190,9 +212,16 @@ void imsic_local_sync_all(bool force_all) unsigned long flags; raw_spin_lock_irqsave(&lpriv->lock, flags); + if (force_all) bitmap_fill(lpriv->dirty_bitmap, imsic->global.nr_ids + 1); - __imsic_local_sync(lpriv); + if (!__imsic_local_sync(lpriv)) { + if (!timer_pending(&lpriv->timer)) { + lpriv->timer.expires = jiffies + 1; + add_timer_on(&lpriv->timer, smp_processor_id()); + } + } + raw_spin_unlock_irqrestore(&lpriv->lock, flags); } @@ -232,8 +261,8 @@ 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)) { @@ -294,8 +323,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; @@ -305,7 +335,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); @@ -338,8 +371,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 @@ -402,7 +435,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 8fae6c99b019..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 { @@ -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 Sat Dec 14 17:25:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13908539 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (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 095E61B3954 for ; Sat, 14 Dec 2024 17:27:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197229; cv=none; b=TLSOzXgeia4fyoh7ycFgFTfH22xcCuBo/pW7HYPjstuD9fI7naBzOTk7Uu2DDOROUhBRVJsF828VjXmQWtJPzYbXPJHFdY2uABQ6btiUXXdJJwXo5a4QSf/ah6MtIK1LY8bcmC4ZRKAfN5W0NOiFgVeeo1CVaVZXuwLDKzh4BJU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197229; c=relaxed/simple; bh=ZmZx+N5nuIhjnt8Ku3H4Aa5bBD/jkRAUPw+E2i+2ziU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BvnUn2ZnKn5zFdDWt1o/MowwKvTLN07sxNSqsoq9TzFzUYu/RbhFlO8CnRCgRNfUUnsynSnrLLJM1r4S5wvwTom882aIgg0tz7Fp4Ghun7AYkeyUtZULZEeOTvZZnWwThRIEJ4op8W4oj/bUkOqO1KkmBo0z+u/smtzA51FzEHU= 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=abRh1YnL; arc=none smtp.client-ip=209.85.215.171 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="abRh1YnL" Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-7e9e38dd5f1so2113828a12.0 for ; Sat, 14 Dec 2024 09:27:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1734197227; x=1734802027; 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=K8c4bSx6OeCafE/EjjWkj4NBjcuAlryx7NpTdvjZLKQ=; b=abRh1YnLT2lnnkcHXJxjy3Pk/qrNVrfnrjKN9D4Y6TGB+c/IncvH8+tgDkGxNPPdla cOEIwYXMINmULlT4xBX8wz8IfZLVIVpIYGqzTDN8bWrnGoE8iLGBrJRru9vGg8+tH3/m SubuYCCwXKQUtuIx+I3bBqGOkcKskANVPed72ekzq092GV3lTGUGBaxkYrar4PlHw3hy vuRBY2Lqf/aDZGxSoW4QgDbDYCKIKNz/UTpi8CkkzAc9rAgy5flT6LqWFesgPAHIl1nu /C/4QHXBZhNLpEoYT1vcjDjAsS7QvPwoRyx8pPoatZprWlbm+xBb8vZseIaoVgTbLrBX GHtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734197227; x=1734802027; 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=K8c4bSx6OeCafE/EjjWkj4NBjcuAlryx7NpTdvjZLKQ=; b=QkN7obcHIcM2PLgBmnEmXmRot1mOpUcjVNoewIkzkgD0Sko023ZCmrQNoDVWLFVwhB gQnh0WNtjAq6wtRKdq0M+VYfFIh8GMrTxGR8ZT0cijEggiY/PY1lQ2mZ/D7QQUlBO5if 6OTzAnM0ICAd0bz2otuWYQEnaW8LMfNlG+PANPPVF0rqEipsNjMf/U90cSTIc7Sm+hWZ 0tZyzVLVVAofh4cWGg1/iOjDD8PNzFC0X0EAmkThISdAO2QiKyaqwxLQdIF6rRrWGE39 dCPIJFkBHmp4MrXZTAElE479mhyiwbCe9DI2ZIA3dqfIZf5ZoNuhl3cn1I9shGE7u20W NiEw== X-Forwarded-Encrypted: i=1; AJvYcCXCZiEYbIgE5GDnjlbDz+GPwk+vGLppJ1hcqNopRQ1XiNSLAqaze7/PIzGqeM+9d8msefc=@lists.linux.dev X-Gm-Message-State: AOJu0Yz0vN9aGklNYbjmdVPw5LdW1JEu37XHXCbJQBiPLIlfE1X19eiv PcNTXRpD+51pu0ghQgTvk7IOJCyjgCX+TqB8UlIixo8p5Xd99gkhsNjKubXX9qA= X-Gm-Gg: ASbGncv9PHNkY+6ZJMbrZbqFNxKKkQ1OUrBOEKHGTQeC1rq0e/3zjJZfqx/7Erpqr8B 4Eqf6BjLr6AKxsPo+PRNgdGwDhCKuWxQITff5Dpv8uBqIGXNdhNjmRUSjas5k/XplPgYIu47Hxg Am02MP41PKmNDUUqRgJ19pEmrK1mYKIKdqIBRb8PmxNzLdR/BNf2X/uLuBPlPfWDJUpzxZksDFM iWiLwsehvDjoyMyDNKOa6bP8DNbyh5QkfKqglJb1mRw7q5W+/VddYCVAd1bxkTHZw1Jbcr7V4V/ Q5QtpHRa3ppkTCM= X-Google-Smtp-Source: AGHT+IHUcfTVYGQvMkfUU7jHBszvrCcnJgKMrSzxBafo9cGQC89Lrd4GQaGCXdK1f1d1ktL3gp5V1w== X-Received: by 2002:a17:90b:4a4f:b0:2ee:9902:18b4 with SMTP id 98e67ed59e1d1-2f2900a9878mr10311790a91.27.1734197227250; Sat, 14 Dec 2024 09:27:07 -0800 (PST) Received: from localhost.localdomain ([223.185.132.246]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f142f9e186sm5049811a91.41.2024.12.14.09.27.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Dec 2024 09:27:06 -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 v2 09/11] irqchip/riscv-imsic: Implement irq_force_complete_move() for IMSIC Date: Sat, 14 Dec 2024 22:55:47 +0530 Message-ID: <20241214172549.8842-10-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241214172549.8842-1-apatel@ventanamicro.com> References: <20241214172549.8842-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 2fab20d2ce3e..fae47b8ccf73 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -156,6 +156,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 = { @@ -164,6 +195,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 da49a160ea09..c915a5cf4187 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.c +++ b/drivers/irqchip/irq-riscv-imsic-state.c @@ -323,6 +323,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 Sat Dec 14 17:25:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13908540 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (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 002AB1AC8A6 for ; Sat, 14 Dec 2024 17:27:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197236; cv=none; b=Wm0hrF3e9BlxTPtwYv30VOOaCtOv92zBIizA4JElNwCbdD7DReWvSf1J/fa3KpgJOMEMxBdE/q/nAmRfLkVgev04mhGSrEfajGlninwHStN0I6B17CMoFh6qgROCRXNWmw5n8rtC6olfUdWJcBD8fImQKRsDJ3r9hW08AEpv5RY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197236; c=relaxed/simple; bh=rcWXudtubpY/LSH8y20isvvWa3ivWgmUdiDIzyRLaJo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eOnOVqIFvaokQCF7U+ubnQWmlfY4XakPftU+4cZxszQi75XbP02bWruJByuqHal3hpXCbiX31fadm+pepm9s8DRT9nfScuhOUaEuAZfUHEU2kpWUiZSNGvJoHxVypvfiQioZ17ubfpmhdH3PSdHdxAmaHtoOpephM0lfbx6hoPc= 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=E8NmLHYb; arc=none smtp.client-ip=209.85.216.44 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="E8NmLHYb" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2eec9b3a1bbso1910843a91.3 for ; Sat, 14 Dec 2024 09:27:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1734197234; x=1734802034; 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=EP+pJC86HytY47PbI5sMBg+o5TFAFMoqjjekp4WBZSk=; b=E8NmLHYbAhRGB8cmXE3Kg6Fmln3D2GgzHWloeiVV7dCUN3M16Y6SXfnSr1a298Iqr6 sM7dAd6EZeSrdyZAcYP9zeRYI87/9yUIHtb+pnlzchDTT9C6AQ1HkLwQwBdp3v8L+RO+ ZlnCtC/j0gZyb4l0Q6FJp5FRXL/ZHzbY42rMmm1CniSjBvXfUVhK6z+DL54vaziFUZO3 i8cVYnl0y2PjyE6jiwcqa5z4ZEKC5oCDkIpPCMZg0B7zrOUshrHvLfrzJK0PXNbaGXPu ADR72FOHh5uXwbntmmBIUL3Ip+Ny5Sxkg8ULPNa4kJh3UqCdLGVXc262yIkfYEXq7bu1 B6vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734197234; x=1734802034; 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=EP+pJC86HytY47PbI5sMBg+o5TFAFMoqjjekp4WBZSk=; b=NLzbprrvgMJ8FD3n45Yr7tmqt074rKGvUDXDsQPu0TelBEu9OTkzmmQuxz73qjuPmP xdEkkJario/6qrE0PqX/6FKT/Q9n0mNsuSdRYXI1MB8K2e9IuMYza9MRlZ/UZdYk/Doy xJux8+VNrDFCEBhN6qsENVto19SddHwHBid3duQD7Of9fk8nsynwyS8bhT6JJJCZFG0t 2fZEuLJPARo3mvt9ww6UHBlpvcG2SNojkLfxLMZBLPJMNEhAIDBXp102H2jKNPtZa2+h /aRToveUKejWGoR6JCqSelBuA/1sHo7ATBzIw3zHz7TIoE0Y2ff9j/ojd5NqBblTrh8o Op6g== X-Forwarded-Encrypted: i=1; AJvYcCXi7XWQEoHgYERwx9vMlPXGmFCWu5ytrTAxXDsGvctrObvo2pAjgMXUcCyAyyti35W7u/s=@lists.linux.dev X-Gm-Message-State: AOJu0YwfUwGXirNcodMOfMBrmZ1Vhmi2pgDmsvvtLsKXzFyW66loXqcg RaDn/raColJp4YNp6H8hLwCdG+07yL13SHutkExJHPT+ImyTSPP/j7gRj53RfgA= X-Gm-Gg: ASbGncs+LQT/k7eQAu1O7VDktRpqMlQuNQCDMFcy9SczM7mlbpt6WON3zpVCAxlCWdj 0aacF9WtYTPnKXsc49t1IydtyuWBmmBVjkpjIzJCa2nEUHJqQuEoiiGplPmr33hyZCKG10KQxxX Sih5rvZJAoP9U6oqLDprvIuNhHFzblUNn0B7YH/9SdqPOLnikxQB/7TWyHFi5C6NP1wVJ3PF3sW uyrNCl2APzITRw0OWaihSWvQQYuJtSOnlhvmzTsYXJ1IzC8NWwgB3qYjsLKEKUrYSQVeVrcTyEp BCQJd934rmFxAZo= X-Google-Smtp-Source: AGHT+IEViE/EyOEoU9avO8xOUuGHIK7Nu4di+ccQuUelW0qrSBcAUC23H6R13dSAPO44yc0spDyzYw== X-Received: by 2002:a17:90a:ec84:b0:2ee:f80c:6889 with SMTP id 98e67ed59e1d1-2f290dbce03mr10584296a91.33.1734197234199; Sat, 14 Dec 2024 09:27:14 -0800 (PST) Received: from localhost.localdomain ([223.185.132.246]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f142f9e186sm5049811a91.41.2024.12.14.09.27.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Dec 2024 09:27:13 -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 v2 10/11] irqchip/riscv-imsic: Replace hwirq with irq in the IMSIC vector Date: Sat, 14 Dec 2024 22:55:48 +0530 Message-ID: <20241214172549.8842-11-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241214172549.8842-1-apatel@ventanamicro.com> References: <20241214172549.8842-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 73a93ce8668f..0c94ce8ce580 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 fae47b8ccf73..e6c81718ba78 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -112,7 +112,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 c915a5cf4187..aca769d915bf 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.c +++ b/drivers/irqchip/irq-riscv-imsic-state.c @@ -434,7 +434,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; @@ -450,7 +450,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; @@ -463,7 +463,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); } @@ -522,7 +522,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 Sat Dec 14 17:25:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13908541 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 99FF71AC429 for ; Sat, 14 Dec 2024 17:27:21 +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=1734197243; cv=none; b=qorSvZo/DZkHGWP0zA99/gwKP0Hxxd4JIjPK68wZpi0WyUQMn/4f6X1IakoiQbXWH3iPqEYHnYtvunlNJKS7tHMh1kLh9yTDSmhiBm0M3Th/Oiw7UFk5BkdVsaWMdjv/OJIK+VsjxsZVbft3fxeoxUt0Hw149TApEw51N7xXj50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734197243; c=relaxed/simple; bh=y8LyhxLnr8gL59ez8smjdkMSejl79VB7Tc2egqGrEC8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dY2WThnjyvSBOkoUgGvUGpqiybd8RtlO+H8QVf3IE7py82rQuoLUIRzI08ywqfBLFbA+4QKxHgpVM1tgT5oAZEDmVFHpXjElL53wehvn1nBpnCAxIj7eQnrMZdXYKKzGAeGguT/Q18HZnGQnoqwTXYIkzdMe8GWZgnSGvnjGPOQ= 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=pKrTH6A9; 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="pKrTH6A9" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2164b662090so22398355ad.1 for ; Sat, 14 Dec 2024 09:27:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1734197241; x=1734802041; 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=Q91PIdpY0ToxJxjWetgT5wSgNIKHhdsWJzKO3onxaMI=; b=pKrTH6A924CjPnoo+Wj+MBlHhrRuRUFOD3buVWu3CtowrvkTUnIZNEdGfJPt1gZMk4 Q4IEcYgny32wfzqD1/sYK/vPTncW0Tmb6qagR97qaK0G/AZMNG5DGEY4NblzzOJZ1ww+ W4ZijJi2K18qpIkhh+N+OY9pAroBgcsgav+YaXTf5vO62EzVhE/2qa7Qo/RWL2e/ZzSH W0QUCXixikKrqAEg1luCjehFpz9FXACoisk2Bli0L8ULoVeLXGc+aj2vvOq015tROkHE RkHuOrhfdw9L4SPssa3Jt+GPKlSiCqloydXtIb0DrtrW9iW3he5QPb1Nm41JstXJ6+Gl QYvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734197241; x=1734802041; 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=Q91PIdpY0ToxJxjWetgT5wSgNIKHhdsWJzKO3onxaMI=; b=Tjpbgfe1qNtKGZl88+HrKOp+3HZ1zsCrZPY/7P5cMftNbAfjBdzbXeLLnW+IcME+96 hWEUrCa6kpNFmncCFZlg6LXRf68SaZrKYJ6zEEBIjsL+g8cc+N4I2THyLR6LOGQwpgqE iw+Mnah5s7BIvvUxhbzeSjc7bs/35mlhngNIdSeEo+nxMgAYpM569xpIaZSDERY5VNCK n+nLX0Xhzrd2J8dnnBaGLZarq4H2AjDpBMDsCp1shmvuE6rF4WssRWGJu7v24b05O/m1 BHF5UtxmgoFvOztmlszIUIYmCJaDCmc8CZC4C/voGKVkAxu+KT1tGSggE2VhOzwEAWj5 lp1w== X-Forwarded-Encrypted: i=1; AJvYcCW3RuT7mI5l6xNi1/PKZfdtd8no/IQ0fCUOIiOgNy5WWnv1ZHc1RVpN7NXx4sulKbHGrjY=@lists.linux.dev X-Gm-Message-State: AOJu0YxmD7AV9EtNxrTY95ZXCz48zO8UIEeS5AIxP0xOePwt7qY2lr+r f3Vql9epFcntoKPjHdCXZsRHTH5xrYNyqQmsWrxddGc9c63GYsW67Inbgk4jNu4= X-Gm-Gg: ASbGnct1Dslpd7Sr1ZtQtmQYGqHEZyzV/SU+q9qmTpicSe0DYHQDxIeuZmGrsm6OgY+ 34lTyRSr8dXhouypvDn4gCQ5V++b2NTLZJX/utY1cMIMTWgVDExxK6YNqnc4ZV4o3Fi7UOyoFt+ oJv9MkaNkxnMufySg+EGqOKeoj3F+gx8neOFWVBrb93au1FcWPamLuaLHITcspElwyUhzwdO09R Z+GrAprAKbZFFIoLDHLdurE54CBkg4HYbOHPmZobFZOyZRme79n5C/qqO5V8U7KIoxaLNoJFuj2 FxPlGZtO9IATR9M= X-Google-Smtp-Source: AGHT+IHMsJ5YCvABWOrU64w2NgYzPATagi+l1J7ESIDXSbMnwGULGsvQOBHQ97Lfbn1IK/p1gbun3A== X-Received: by 2002:a17:902:ecc1:b0:216:46f4:7e30 with SMTP id d9443c01a7336-21892a42024mr107832805ad.43.1734197240770; Sat, 14 Dec 2024 09:27:20 -0800 (PST) Received: from localhost.localdomain ([223.185.132.246]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f142f9e186sm5049811a91.41.2024.12.14.09.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Dec 2024 09:27:20 -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 v2 11/11] irqchip/riscv-imsic: Use IRQCHIP_MOVE_DEFERRED flag for PCI devices Date: Sat, 14 Dec 2024 22:55:49 +0530 Message-ID: <20241214172549.8842-12-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241214172549.8842-1-apatel@ventanamicro.com> References: <20241214172549.8842-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Devices (such as PCI) which have non-atomic MSI update should migrate irq in the interrupt-context so use IRQCHIP_MOVE_DEFERRED flag for corresponding irqchips. The use of IRQCHIP_MOVE_DEFERRED further simplifies IMSIC vector movement as follows: 1) No need to handle the intermediate state seen by devices with non-atomic MSI update because imsic_irq_set_affinity() is called in the interrupt-context with interrupt masked. 2) No need to check temporary vector when completing vector movement on the old CPU in __imsic_local_sync(). 3) No need to call imsic_local_sync_all() from imsic_handle_irq() Signed-off-by: Anup Patel --- drivers/irqchip/irq-riscv-imsic-platform.c | 74 ++++++++++++++-------- drivers/irqchip/irq-riscv-imsic-state.c | 25 +------- 2 files changed, 50 insertions(+), 49 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c index e6c81718ba78..eac7f358bbba 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,7 +102,20 @@ 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)) @@ -117,31 +135,13 @@ static int imsic_irq_set_affinity(struct irq_data *d, const struct cpumask *mask 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 some 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 both - * old MSI data and new MSI data on the old CPU for pending + * Downstream irqdomains (or devices) with non-atomic MSI update + * may see an intermediate state when changing target IMSIC vector + * from one CPU to another but using the IRQCHIP_MOVE_DEFERRED + * flag this is taken care because imsic_irq_set_affinity() is + * called in the interrupt-context with interrupt masked. */ - if (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); @@ -198,6 +198,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, @@ -217,7 +218,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)); @@ -256,15 +257,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 aca769d915bf..c7649fb6bbe6 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 *tlocal, *mlocal; - struct imsic_vector *vec, *tvec, *mvec; + struct imsic_local_config *mlocal; + struct imsic_vector *vec, *mvec; bool ret = true; int i; @@ -170,27 +170,6 @@ static bool __imsic_local_sync(struct imsic_local_priv *lpriv) */ mvec = READ_ONCE(vec->move_next); if (mvec) { - /* - * 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 && __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);