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: 13908545 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 74063E7716A for ; Sat, 14 Dec 2024 17:28:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DxWY7Ul6uBA+JZibfqvkkI14zABpBAm/jf7bUpt/zrA=; b=fDX8bCAlfLgDy0 oE8HtaRR1dQB0i1GUQ2P6uD+kE4npGW1hiHSNEaxpf4N7uYunOF9XUVJQJ0phxkr8f4OvvpKqLmnT HqU9xj58Ux/Sfh/zMYhGl95hRL9dPfEfFb8+tinPCYT/G3n45S2dnoZ7clqO6Y4R2VLYTOVMKzkJR lbb36afbrZ0r/FCyGdyqEnpVRecIxyflwhX/P8RAHyN4n4InNdK8YGBlFRJGeIMTUQJW/Npg1n0gn ++jnb1N2hBW29o70lX9Yv/srt75+AiRyrMoehFjLinV+hWrvFPiEI566biOLY1vpCxVHsDd6+XpOS aCtNhR7B3KJPY3g7lx8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tMVwG-00000006gsC-4A70; Sat, 14 Dec 2024 17:28:24 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tMVu9-00000006gKf-2sZf for linux-riscv@lists.infradead.org; Sat, 14 Dec 2024 17:26:15 +0000 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-2efe25558ddso1959347a91.2 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.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CBfvQ3kWrJIo4ZX2fO574K2xNLHLI8xt5fD3UcZCgGE=; b=O8ASwWDGJDQQglYqviY9NxmKvooU405TN3d6pn1fMaBaVeclms3nsKD4qOaRsm3z3i CW5Y57IKmT5J2fVE73dc//fbljsx457DTWisSecQNvC1khBi6ngS4qEvoQPatnYsqPuk QRlJC7UOdFRfPK+xOvfPO3M5NQ6y2kwYjoV04LL6zwGOgbA78OcrvqmLG2YpoAa61Zd0 V8OEvlHxPdD/Qd1+vn+5mUeVKDzpxZSmV4AV2rE/kgL0akc8/T112+xqMrMRh/eW7/8J hPxstMIzKAVKKV7Wtn+/JHAaXpYA5GwYlSugJRkw8+6z2Mnhpq1E+OjJUkOucc7s9X8W 3+kg== 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=VTQ/eFrr1GXJHngd522UpHv/OqejekPChogHOCWN/DYB8FpSEau/i+k8WkFkFkwp36 5d3IRV0CkYAE6dQbesNWRGYxFsAexPvyMqbndVvdwkmsRpRU6CmYwbEKIk4g6WcqCN9o wt38SrRWrYjwPWAGRddoTCqf9CRP9T+4d0IvW89AlOWzK9vOuHMWgVxTnY0s91OA/pzd iV688CeMVEPfO8yKoM6GIIBbzfYP88I2j7Pu84px3355AIbl7o5I4Lu8h7wVZcO+J7N6 HNDYfqgu5qN71kYt8GxG0C2wdMQMNmDP14UF9+qTmRjoUEluJ3cBEaybvPNtOZNzP2VJ 3kJQ== X-Forwarded-Encrypted: i=1; AJvYcCWpVBNxv4eGKE4dqlM7zoyA6/En3dtk8QXXd5ylsL8NZQhLqRe/aQEbmGAXOTSf5fFkVkO6sMFfgtP7Jw==@lists.infradead.org X-Gm-Message-State: AOJu0YzSiil+SbDjOnvdM6wIeIad881kT2zJoXt6+PhmVl1xIkPyoLhc onC+/r6tD6XmqR4WH3WWhL9XaS8wpSSwMijufSbcOtcZ9OyEnJE1A04FipYYAe0= X-Gm-Gg: ASbGnctYP+x1MGkjHtktBtn/jh0aMIsn07GGzdH8LiuUMa+W0LRi4gn32c+S14rYpi4 I7mvBO+kWkpj3KOrs5odhDHCIqeOzK33l8oEBOOgNLND0OjnuKIPElycFgGqKp+o5eG8JI6HezR GqUJQ99UOchhdqi/hZACfVAt7/irJ1hAsmHqgm96M7qlQRgOpwp+KqfbMy/N0cqDt2uY5KMAb/Q kcjJf/lSi51xToxJvgijF9g8RToT1vDVuJQK/65yLHs5lj/H40WMSQ+cC9uUBT0nSenmEZIsWqM tmnrllBg4upSOfk= 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 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241214_092613_767476_2E602661 X-CRM114-Status: GOOD ( 20.94 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Atish Patra , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , Paul Walmsley , Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Device having non-atomic MSI update might see an intermediate state when changing target IMSIC vector from one CPU to another. To 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: 13908546 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 43BC1E77183 for ; Sat, 14 Dec 2024 17:28:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WlZP8SZYetYktHDMy89E58QpaLzD7a5abBH6Ap8cJUQ=; b=hnwIMWNY89sf4r WUw45d+gz6wVmCM0oZELmwPhtR+S9M5bwHCuvSNgohHPa982VVR0D/Bb94Kja7aehzPYEFCca4TUS IN1ygprrq2ZGYNLmwqTCAwS3gZtnaLnR2MT4ifXYxMYE8b7G+ac9CuiCPNmjMugdztbspzQ9yQ6VM 030QPGr+8DevjU1PGZoNvm8z70hI5BLnO7XFuNoUjNrUf40fQtvBYGYFpHBHQoZ3HAWIPeUUZcox3 wfvzXgXhUE7P5oP/YlGLr0GYsR27tkwrxN3yTfnbxhrIqMe0iCJ0fNN2HwKAvuuaVOvdBrkIkqnB2 N39ViE6SLxEekD86sFhw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tMVwH-00000006gsk-34Hn; Sat, 14 Dec 2024 17:28:25 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tMVuF-00000006gLT-1Z5a for linux-riscv@lists.infradead.org; Sat, 14 Dec 2024 17:26:20 +0000 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-2ee74291415so1870945a91.3 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.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dDa5uVtGTmKoF+EGxYZ14lQBrXBy+Zgm46G016g9yok=; b=WGyb6cCViVDYUL5u7zTLoyKm7EpSiNXDsPNB8d7QispH3CIgSJywciRj6rS78K8fQl nncYsodUSUpv99d8dVx8S0Hhn90Qvb+DJdeKGRsnqUqytP4prbEKk2EUr2p1z9Jrzs9c Su5lGTyzeLQNhOLlUFoBft4LUMOr9th0DYSxDKttbfW/iXZ4ZhYCbQVueeNL7/6rTUi6 tqV0/9yw6KH4rp10A8xb1JnvcK1M5vb99zFMg5SF9uTr8xuwWDtIr/Z8GqFHT/PwKMfj /fBD1wj6ZS8poZvkWxrCrP11xV1ssb0t8zOfUpBZPRhzYtLc+W+YEs60Oy568q+w0vRn +XnQ== 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=PQTqv3WZQxzsaU62qhEXzPl4blx5pV6YUkHf2mpU6SjNakBlIxIM813hbgtIXFmS9w 8NCvILO3cDOBpJeViAN7POoA/yO+K9hpGTfUeejTYSGi+br1OSu/osMehQPn+FSI+FWe 24QVOhfi5FON178e7jAZ+42BWbxcG4sU8k1sxsf2ZjmgNwk4kppwYiQge5AEqS5iyDav dkzkCvFi5OZjycdiAkBBEFmfHucssx1YcxI1PyDSY7ol6DdvzX3uSEiVc75EMA4orkAG Dh5ZED5Lx5cv8j4R+vyvtkdmqo8JOVH61tGEuTismGKl7+hs+lP4q6ErQH4mjPzcrTOd pShA== X-Forwarded-Encrypted: i=1; AJvYcCVvaYU6PLGajYnMSKZFDPnpdim72lVP+/wtUory9IXUHiccaa2alXNdGv94iabPMX5GqFQzBcgD9ng47A==@lists.infradead.org X-Gm-Message-State: AOJu0YzI3E7WAQqgDvzNST0MYDr/otmP2hA/3gUuwHVC1SJd/PRXdKdK Y7+/q3Bwyi5Y6HHQf6XcwmTX4Du68IhJXesgvX7vmbou8Zkh3sn0ZWum/Fdvftk= X-Gm-Gg: ASbGncvLEmt0ug9DQj4tedafRjoPj3CBVYKfEZmlKZ8Zt5J/bbAn2ugGdi/c++t+z5d k8BkdCXVKmfGpFWkrumxxiT/7sbtbhV+xBgZVAXbcdH8dtAdq8CgGTyWBrlzjH6FUJYJeS7gOZO C38ieQmxAiS27xSNum8RsDno+XEaVNpaC561UyMGvoL2iJ6HAWAFcgb2+kNI9uqWuwtn+S8oAG7 P/Oy2ok0A1+9m3YEyItO5DYpcvOODMMiB6Zsh2377V0URADe9XzxsYBIgLo3Y5khmFDcei5MiEL B3Wv1gJ8GE7tSo8= 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 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241214_092619_427650_53495061 X-CRM114-Status: GOOD ( 16.74 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Atish Patra , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , Paul Walmsley , Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Thomas Gleixner Introduce chip_flags in struct msi_parent_ops. This allows msi_lib_init_dev_msi_info() set default irq_eoi/irq_ack callbacks only when the corresponding flags are set in the chip_flags. Signed-off-by: Thomas Gleixner Signed-off-by: Anup Patel --- drivers/irqchip/irq-gic-v2m.c | 1 + drivers/irqchip/irq-imx-mu-msi.c | 1 + drivers/irqchip/irq-msi-lib.c | 11 ++++++----- drivers/irqchip/irq-mvebu-gicp.c | 1 + drivers/irqchip/irq-mvebu-odmi.c | 1 + drivers/irqchip/irq-mvebu-sei.c | 1 + include/linux/msi.h | 11 +++++++++++ 7 files changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index be35c5349986..1e3476c335ca 100644 --- a/drivers/irqchip/irq-gic-v2m.c +++ b/drivers/irqchip/irq-gic-v2m.c @@ -255,6 +255,7 @@ static void __init gicv2m_teardown(void) static struct msi_parent_ops gicv2m_msi_parent_ops = { .supported_flags = GICV2M_MSI_FLAGS_SUPPORTED, .required_flags = GICV2M_MSI_FLAGS_REQUIRED, + .chip_flags = MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_token = DOMAIN_BUS_NEXUS, .bus_select_mask = MATCH_PCI_MSI | MATCH_PLATFORM_MSI, .prefix = "GICv2m-", diff --git a/drivers/irqchip/irq-imx-mu-msi.c b/drivers/irqchip/irq-imx-mu-msi.c index 4342a21de1eb..69aacdfc8bef 100644 --- a/drivers/irqchip/irq-imx-mu-msi.c +++ b/drivers/irqchip/irq-imx-mu-msi.c @@ -214,6 +214,7 @@ static void imx_mu_msi_irq_handler(struct irq_desc *desc) static const struct msi_parent_ops imx_mu_msi_parent_ops = { .supported_flags = IMX_MU_MSI_FLAGS_SUPPORTED, .required_flags = IMX_MU_MSI_FLAGS_REQUIRED, + .chip_flags = MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_token = DOMAIN_BUS_NEXUS, .bus_select_mask = MATCH_PLATFORM_MSI, .prefix = "MU-MSI-", diff --git a/drivers/irqchip/irq-msi-lib.c b/drivers/irqchip/irq-msi-lib.c index d8e29fc0d406..51464c6257f3 100644 --- a/drivers/irqchip/irq-msi-lib.c +++ b/drivers/irqchip/irq-msi-lib.c @@ -28,6 +28,7 @@ bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain, struct msi_domain_info *info) { const struct msi_parent_ops *pops = real_parent->msi_parent_ops; + struct irq_chip *chip = info->chip; u32 required_flags; /* Parent ops available? */ @@ -92,10 +93,10 @@ bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain, info->flags |= required_flags; /* Chip updates for all child bus types */ - if (!info->chip->irq_eoi) - info->chip->irq_eoi = irq_chip_eoi_parent; - if (!info->chip->irq_ack) - info->chip->irq_ack = irq_chip_ack_parent; + if (!chip->irq_eoi && (pops->chip_flags & MSI_CHIP_FLAG_SET_EOI)) + chip->irq_eoi = irq_chip_eoi_parent; + if (!chip->irq_ack && (pops->chip_flags & MSI_CHIP_FLAG_SET_ACK)) + chip->irq_ack = irq_chip_ack_parent; /* * The device MSI domain can never have a set affinity callback. It @@ -105,7 +106,7 @@ bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain, * device MSI domain aside of mask/unmask which is provided e.g. by * PCI/MSI device domains. */ - info->chip->irq_set_affinity = msi_domain_set_affinity; + chip->irq_set_affinity = msi_domain_set_affinity; return true; } EXPORT_SYMBOL_GPL(msi_lib_init_dev_msi_info); diff --git a/drivers/irqchip/irq-mvebu-gicp.c b/drivers/irqchip/irq-mvebu-gicp.c index 2b6183919ea4..d67f93f6d750 100644 --- a/drivers/irqchip/irq-mvebu-gicp.c +++ b/drivers/irqchip/irq-mvebu-gicp.c @@ -161,6 +161,7 @@ static const struct irq_domain_ops gicp_domain_ops = { static const struct msi_parent_ops gicp_msi_parent_ops = { .supported_flags = GICP_MSI_FLAGS_SUPPORTED, .required_flags = GICP_MSI_FLAGS_REQUIRED, + .chip_flags = MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_token = DOMAIN_BUS_GENERIC_MSI, .bus_select_mask = MATCH_PLATFORM_MSI, .prefix = "GICP-", diff --git a/drivers/irqchip/irq-mvebu-odmi.c b/drivers/irqchip/irq-mvebu-odmi.c index ff19bfd258dc..28f7e81df94f 100644 --- a/drivers/irqchip/irq-mvebu-odmi.c +++ b/drivers/irqchip/irq-mvebu-odmi.c @@ -157,6 +157,7 @@ static const struct irq_domain_ops odmi_domain_ops = { static const struct msi_parent_ops odmi_msi_parent_ops = { .supported_flags = ODMI_MSI_FLAGS_SUPPORTED, .required_flags = ODMI_MSI_FLAGS_REQUIRED, + .chip_flags = MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_token = DOMAIN_BUS_GENERIC_MSI, .bus_select_mask = MATCH_PLATFORM_MSI, .prefix = "ODMI-", diff --git a/drivers/irqchip/irq-mvebu-sei.c b/drivers/irqchip/irq-mvebu-sei.c index 065166ab5dbc..ebd4a9014e8d 100644 --- a/drivers/irqchip/irq-mvebu-sei.c +++ b/drivers/irqchip/irq-mvebu-sei.c @@ -356,6 +356,7 @@ static void mvebu_sei_reset(struct mvebu_sei *sei) static const struct msi_parent_ops sei_msi_parent_ops = { .supported_flags = SEI_MSI_FLAGS_SUPPORTED, .required_flags = SEI_MSI_FLAGS_REQUIRED, + .chip_flags = MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_mask = MATCH_PLATFORM_MSI, .bus_select_token = DOMAIN_BUS_GENERIC_MSI, .prefix = "SEI-", diff --git a/include/linux/msi.h b/include/linux/msi.h index b10093c4d00e..9abef442c146 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -558,11 +558,21 @@ enum { MSI_FLAG_NO_AFFINITY = (1 << 21), }; +/* + * Flags for msi_parent_ops::chip_flags + */ +enum { + MSI_CHIP_FLAG_SET_EOI = (1 << 0), + MSI_CHIP_FLAG_SET_ACK = (1 << 1), +}; + /** * struct msi_parent_ops - MSI parent domain callbacks and configuration info * * @supported_flags: Required: The supported MSI flags of the parent domain * @required_flags: Optional: The required MSI flags of the parent MSI domain + * @chip_flags: Optional: Select MSI chip callbacks to update with defaults + * in msi_lib_init_dev_msi_info(). * @bus_select_token: Optional: The bus token of the real parent domain for * irq_domain::select() * @bus_select_mask: Optional: A mask of supported BUS_DOMAINs for @@ -575,6 +585,7 @@ enum { struct msi_parent_ops { u32 supported_flags; u32 required_flags; + u32 chip_flags; u32 bus_select_token; u32 bus_select_mask; const char *prefix; From patchwork 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: 13908552 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 838EFE7716A for ; Sat, 14 Dec 2024 17:30:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0of8vmMgsAPA/oC5M6T/vmwBB7PBmpRHztC3sxy2hio=; b=TqLS+7STR1BY53 fScvRRkGvs3kpt/Pv2qErEwasYw2dwccHkc3Xiq9XAHwJ3fw+v3A23Skj+FjB0tv1Ai5eabjxNn08 tB66Dl93e9IdbKAxN9i4lf+75uAMXEtjt0l9HkAdgdNbX84lICW/nqY0eCvGU3u/uFQFY37N4Ot2L XYyipi8E/qt0jHOulsxcVW2hJNNZfspgwrshJD8GBpnkcHhbGEzUgjtDNedZhmcX5f0Xadh+PALDp CQFA4G4vkMVGJHEuRTiYuUclyhZjFKFdK5PxrohEm2HdjWMuW5lPNVU7EuoewQf9JJWs6EtfJBYh+ boDHcFcmoADq1iRycv2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tMVyO-00000006hNe-3aWB; Sat, 14 Dec 2024 17:30:36 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tMVuM-00000006gN4-3A37 for linux-riscv@lists.infradead.org; Sat, 14 Dec 2024 17:26:27 +0000 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2ee86a1a92dso1871116a91.1 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.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+XpbAvyCPU7XjesnTrNMuPwq8s0Ofi62LAN8USKi2As=; b=WtX4Rx2xWe6RHZLgpwXWTuL/DQBRJ8G3YiGMfJ3LNbTpqTtc2/66lSGYpGm9/83Jlc ij3nDZGtNjYi0+zrz6o1Ig9Awk1kKuH/yGqCufOoGJ/wbbUbycYMxTkAw/JMgSzfqU7k YzX/+spltkD7tkCe6x92GKCQqXa23STMffqdOyrrviGWXqBRr2jV56QcoxEiyqUA4jRw Vb8wJ/ZXWRPH3Y6bWc1TuNpczmjJHHDQK01792A+dzUz7dgohIVQt+nscOCg3iNw0W9h FJL9V9WPl1Ig2jhEzMbnX7pqvoPJRDBuzdPT4j7Q3WwRT+mX1ae71BoolI6O4wHxPE9f qq8g== 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=AXJrLdqIhPN3v/jlia+QqJodVAoFugk92ikVJE9AHwzuI8cOLi438E73p+XlHIRhaU lDJkFqz7RKWFaCQAafffb1o2hozhWcGqKqoUMUR9kqY9QnClKAFTCm2npVCgZsDYAlKO pXLNyeYiSgfFrFiK75urwv6X48TfZuJv9AWMppL4LdE3qXwnXzOborFY91oBg2SSPBVZ hBTrETQnzxIlLLcfUFLANjSHXCf25RUKtcCFso+wIb8dSSNLrH/FziA6EL1JgxwAFM/K pe3mhdtklX7/ZW7n2kWrklzA6ZyzTWrV+MJvtFv79Y4dXsDBSPQncULJOgobjOOl9GTB xd5g== X-Forwarded-Encrypted: i=1; AJvYcCWe37UTEUusT4zaX98B7QzlV8DDfmC1MXpOMP04u+1RY7+EsY+JYmmJHewzDWQByzI3S3Addx4UDMhfmg==@lists.infradead.org X-Gm-Message-State: AOJu0YxDp1wmuu5rEzUA2TVyRNf1sMEN6C/AKjubyz91RxyIQt0UCeI7 mkY2hcWJFSsxF7cwhNKSk5t8qeNZv1FsrNn4yyIvJ9ii8c8V/GlNcGDQ3/NY6RQ= X-Gm-Gg: ASbGnct5c9hrnhzrgJJmPh0lj2adp7soSDTUO9AUA2AUMBu35ZSyGy0nVVUDNNDkjWU 7kCKEcF9dureme5LX6lk/HmmA6z1bloF8+5BMmSb8LmId5ZKIUImQAtWtjMGUzrRMuYTjJVraIe XkofD/IWtYPMQ7JiJFsBZcBUaMOrFr9KbWwTrrXC6VyU6BQRrqqcvEqHlayhCX5EWn0I7Ny2AqP sJnHjSeJM+VWU9jAgBxP1MqgK18pqnOWnC5mBKeP3HPpQLwkcMEdkB7Hnrr0kTlTsXfAoGeIaTS 8UcAw6D2TLL8s0c= 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 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241214_092626_783501_24358CB8 X-CRM114-Status: GOOD ( 13.69 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Atish Patra , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , Paul Walmsley , Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Andrew Jones Instead of using imsic_irq_set_affinity() for leaf MSI domains, use imsic_irq_set_affinity() for the non-leaf IMSIC base domain and use irq_chip_set_affinity_parent() for leaf MSI domains. Signed-off-by: Andrew Jones Signed-off-by: Anup Patel --- drivers/irqchip/irq-riscv-imsic-platform.c | 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: 13908553 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EEAD1E77183 for ; Sat, 14 Dec 2024 17:30:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OR9W8oYhdeRGm9xNnJSdBfyiunBHYpZC7glAP4yW/Tw=; b=VInFcJBUGTtHet zjlvQGs0u53L3sS5yVX6YKbNwsdssSXjeLFj3dV3yDYJvLSjlJGOup9HH4rjmmEPN0SWjQol1cAhJ WMjuERXidvcuFZi1AXWfYiPHpKE0qLiPnTj4g76SVKLKeP48uygMpwabD7DkEfXsN+rorMDa29GBV vyHgfubivLxjfzb2r2fSDIvawbNFhSZumqaTw6hMG7haphBGFVOdDQ8/nWAn6enGsiH+CqpgNn2En EdZqFYxmLnITir/PnrSDyaNI++gY/td6CrtZUlpwFedZLgJ4IUEe047wqF1mHThECOt1Jnu+99NpT ExPc+exDIIkJa2teVngw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tMVyP-00000006hO0-1tn2; Sat, 14 Dec 2024 17:30:37 +0000 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tMVuT-00000006gOx-3RHL for linux-riscv@lists.infradead.org; Sat, 14 Dec 2024 17:26:34 +0000 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-801c081a652so1776231a12.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.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WTMHZPsDjixID3LZgZypNI5zerTGwhJ3oNH3JU/CG6w=; b=ifEGV2kRHgQy6wgz7xKYiqbu+x+0vjWoisFz0ruUpriS5LsgyiH+Y8/cn3e0rlaAeU 6FEw6WPLgUVV2q28o3+kPF2hzVzA3cGP3HzmBHsv9EHV9ynGi0X01NaumeCN5442DJ0F p2+N9D6iR1jpTzkxsdDz7jm03TTJVOkuHBbEJjDxgf1f1VgTOAun3DUVXKDGSit6jhOa 8KuD+PxBEl9FkAroRwzHv6sQ423prjqlmt0DoGfUU0t4jxv/r+4gHbEdI0usk4FyMrdJ bg23AYd1wqz45iJns4mEihQ9O4vQajDpn1rrTtFhikT4Uxl2J2RzU1PzSZtDqjnPE+WM F/wg== 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=joNqYFyUYiUwLBVpRrMOGQ3NiSAQdEmYsrI/rV75gs5st9PxNJPBr2j0pWTSjedJeg pvqh+VNT52hPuUetY3DDVv1ij+9xGCpkaYKV0w1HAdOfhfPDvQ0XD5622k3uwA/M8gBK 8Lrko4C74KjBPA+s44TP2PEcA3r7kGepvRw8fOW28hF81Bv9MWF4dmPWxUMcVYvDgZfi Z3ahUg6z3fOJZi1b47HezA8fIDi4/ZMLEoPhhN8/BstLCITLNO8Tbi8LpR9QPF4gmDnh P+a8tfyieWrIkt8M7jv0/auvnp5wMY2lxH0Y46VIq6pw5jYIU99lcyHXj5Xwf5bHvy4X PlPQ== X-Forwarded-Encrypted: i=1; AJvYcCVK204s9G3UynOq0TXkwUrzhbZDX8lwBYEkbnrwoFSIT1V4Bt3xxyT0R7uQ4RfYkrDQZL7oIfiz2xbaOw==@lists.infradead.org X-Gm-Message-State: AOJu0YxTAyX7HdSHDQMXDiJZhkdNZ1Mi1S1bMWSIRFbX9irFdHCqo+Jh pzz5Dsr+qnRhMo1efVSZlBZd/slMaX+G+Ymq5mkqZP8ebxmbjMIN6fTNUCdQNwY= X-Gm-Gg: ASbGncumic9ojT46R1eM2db1IrGQqgHy7bo3mwjWjt1LkxNwEeqAcZVfga/JM737Tle /LnaTcHa5G/naM1QCjnJ+cGiE0EWLojXCIZl/KWcrnVmp+KTitRDLaQ7eGZ879mak6ad73RDhSN Uiq2JQTdcoR3SN8J20kjHfNu0SraO28szPyo3oHsbzsu6nKUS0PbCqUbBvpo71bSJL3hk1xXkZb LYT+zPk26DxyNauHrXuY31vrzFixjK84/Y3JXogN+qji6KAeqRIyD7ETLcVzO8ibdydGa1RdlMS joRLhSXjM3XTwOs= 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 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241214_092633_859938_BBB1D451 X-CRM114-Status: GOOD ( 16.44 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Atish Patra , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , Paul Walmsley , Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Thomas Gleixner Simplify the leaf MSI domain handling in the RISC-V IMSIC driver by using msi_lib_init_dev_msi_info() and msi_lib_irq_domain_select() provided by common MSI lib. Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Jones Signed-off-by: Anup Patel --- drivers/irqchip/Kconfig | 8 +- drivers/irqchip/irq-riscv-imsic-platform.c | 114 +-------------------- 2 files changed, 6 insertions(+), 116 deletions(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 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: 13908554 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DC093E7716A for ; Sat, 14 Dec 2024 17:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9Up5VXcIj+37TJrjvJ2sFTbnnOd4IO+r3XanfgpuYGU=; b=pUz9mFrOq1MlP5 bymieQ5/L4exf96fkI7XWhbyvbSRNnQvOkL9yz2K9L44/fY+KO8DvPhmgcK0l5zOGABCLwv0ixd84 w2VSbFbYuDriSD3l7mcgQW1EFdh3zjPpAr6DgkQNWwIrCx7gRoJ2VLd+IrLeIbE2BukWODHxHjaAq hReIORZPT4ObCa30FGEB0foyXSQNOYc1xVkgxDfaGq9XfYs4tp2BLNjjMlXFQNpdqBULiDmu9xGQ9 5/z4PU7Jb0QEbOE48GyNktKPvfUP7dErCQARR8wRlJmriPo1/mpzCeAQIHfJH5EcZ32doeS1y0G8n e4j0MI+6bKYt2fa7V0ZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tMW0X-00000006hn4-0IEN; Sat, 14 Dec 2024 17:32:49 +0000 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tMVub-00000006gQ7-2CrT for linux-riscv@lists.infradead.org; Sat, 14 Dec 2024 17:26:42 +0000 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-7fcf59a41ddso1528872a12.3 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.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u6payGCmGMW/0vjHgpi/115tsc+b1yXaj6IL2K0q/xw=; b=MlCHZHWFhhhvk9pdN+LoMtPNyl++oJlxykhxrdrnbdhtxtb7rCEByhaT6j1tPLSrR+ ff3Vg4p7aCZhfanj7Sc5KWNh8jR5q9WZrZ6gGC3MvRag/uxZKfv4GGB3hkt1z8DqgM8k eKcqNk6UeACjt6NniLVGTSiSZriEh0Spk9Nm1rJ8UOkQD13Rn22nFA8Xc2meMKY+I/v2 LpU9Ax4ZSYWjjXVOMz2+ALYlW7BsQ6QTte6BtdZGH/A2DuAYqLTxrmkBXFiB3wrOVuSW gk36qYCCWlE7XwklidHd9p++Ih+iJTvuFXLd+qvpaF76kcs6cV56NdNSfVgHpgEbzR8A JBMg== 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=WC4mQNgK2w2uV2YRo4nA8Fu5YUijif+zuwLXo6/43bLl/KXW5+cMNT+pqwiY175Pen gyDotjY2H2u8NLZ4YdF5QfkrarzzQZTvqTs/AbZzpjwVU6eeltgNhEfe3VgpxM5NqxLS NzCfHCAImOfYPgtEfRhIK2lv+tVST2peD32V/H1zStPSSOS8HbJ35BB8DMlL4YS87SsO eg8E6wa0kPV1x6U9yYM300p8yD0e6V61/0cbVNqtWQe/uZcUVr0bVwU5Fu7835Pr5BBG aOo4ONNDoDAosspdjnVx21YIWWIEBhLq5OAR/6/4IVNvjtWakMiCofkIlPr6RTbKOTis 2RZw== X-Forwarded-Encrypted: i=1; AJvYcCVys+Z/hXpavMIm8Qp8+1dqQ5vc3aojjZzWhgj0Z6PCaHUQjlu9+mIZbw+42Txn3TWW1lIoa5YIhaETtw==@lists.infradead.org X-Gm-Message-State: AOJu0Yw4r+xDVMn3AfthG3PRJLT4sZP9KMM7VWwhdJFwaPX67MUnZGPL 2yA+5bZBiJEGv5VrERmOnIl73bA6kFITvFzCTdykXWAnkhhbF0LYjeZ2aA+Lxdk= X-Gm-Gg: ASbGncv/SXS3H0EpzqoD6GP9ASqt3lVDBbU+2CkysUU1fYYGGegEuCCnVIjPwPOpqiD N4Vx6zN1rfnMoIdEEKbYLFBeGnSCWAkHJP/y52naXY8GNsRq7gB6UjawDlYMGRZSyPgkNJrPglN PluVCa/7pZ7slCnz9d4pqgGHF6ZM1qOkPt1GoLtRWlV8HVBA7CX1JlvwPOnyK/vAhs4evRPM64V nValEoKMHbjh2A7+mmtXO4RijJKbAUxuC14f6DZsFW6CjvSwPKaMrGdnilv6V8tJyWNTbSpOO9x MtuSH+MVsnIpUcc= 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 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241214_092641_573994_D5926CD4 X-CRM114-Status: GOOD ( 19.58 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Atish Patra , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , Paul Walmsley , Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Thomas Gleixner Introduce 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: 13908555 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B6E90E7716A for ; Sat, 14 Dec 2024 17:33:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AIhQbkKMsggENuXCldM3e+TFKDOO/AK14bSwFlRsaGg=; b=W9PGgj30pCt8mI GThXhDi5WtIaR9W8v2eU3WDSuhuzcwAFbMdF4LNN7WW+P89oLLanEL89QnY1B312gQsYdpGYpIyoP IV4rsfvjw2eYg29EMHqV/4oJhqjeEp9G6U2Xj+hhSwks2zwRgH+GL6M91VuJVkmlmZiQzyW9wPyFO an456HyjJjykuSeyjYl4bzw6R8D7foIuJgcq8hqB0I5RzalEDFLTBd3Ooxh5kKWPHY6P0tOXU9smf 9f86nHtbGVKgpGlm3Iix1XB840er+NtkWOayuitceoSBG+Uk4O6RJD0aST5BZ5RKQ8YpZCXon24S5 ElT9zD4TJjEivg6xh+qQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tMW1a-00000006hwo-1B1A; Sat, 14 Dec 2024 17:33:54 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tMVuh-00000006gSW-3ePB for linux-riscv@lists.infradead.org; Sat, 14 Dec 2024 17:26:49 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-2161eb94cceso18955645ad.2 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.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nBJthI+mqNYzorludLEAXvfiuDja+LCnD6djvnBek6Y=; b=XwD75bzjtZC0hcFt552Ed3Cwu2pjC74+4d2/k2A4NzxeKzmUaqnHjUAyEB31QZVDfe 3eEMLwyqjFqN/AFGGwcW8/ZWE5u7OQDLxsN9U8zt8PFIpWLQ0xxBlFeMHU+tInxEzXqV MVVkhGBi5PqoMOLTrpDZVnWVmF0R3096yQuRuJeRr0m/ZeaFoGhPaWj487SxbPN4g0fG 7oja0C2imIloG30z+vXbjb7w0NhaPmgkCkvdPpt13SBGMzMVDoopT2a5qKZMRcWpqJVe YKMLwMBZ2tHLrreVHPyPZcCBMtb730aIse06wHLyM7Jak6eOiIkiaw+vTODEXvmM8JrW 75wQ== 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=oQXoqD63FbAcmqEZmnMPBAgJqFOJEgfIRizIJ90zfugqZblrewD+3hwGq9VGcYSKp2 HdFDPMXK9Bdc6dkv3LWfJxCAftB1DR9tRLVnCe8z+QWp4PDJ7Sjkb+Tkap9dkBq/MKQb 43/IJ6TPvz+5H+IIxETOWczVGSQ+fWGjGgmMO2RAuEmumMJxUBKM45r0YPS0W+BIu1oT snT+cecOgxylbgvC0nwE0ahkluHK8WrVamqqRvQsohS0/xE2FVSW6CB9qUVTkXp09SCu zBM4tuQjXj8dLuWPBaXU5P2yEK1rfQu3pd2j335J48jm2DDXhE9LdJIUDE6UwNzhTc+8 yjZw== X-Forwarded-Encrypted: i=1; AJvYcCUYSwXt1rEe8Ghk/DgmTLlwJASC19DBqJc0snS+Z+J2lUICyeF9AAaOlUJ+rzbVcXrlPKWKonslCAxFWA==@lists.infradead.org X-Gm-Message-State: AOJu0YzNBvd2lU723o+tU2JPC6aMWpQfw3WgMAc9OY9mxx5v2cU7Beyx FstpXrmrHnwHpQU+9OXF/Nu8RF0Aq7lEfERy+DH7G17tVzt2hUPI8rP+Vmes/+s= X-Gm-Gg: ASbGncvmy01z5j7aV6lJFTs7jVUS0BWEmSq/XonX+Eg7H0HpCmgDm/XSBEHTqSpeNjN 8ntC4nRUS+OPirnM8S5hyswvRwR4Q9ADDGEMBQgGz+wv+d33aMqjUKW/H57uWvmXiyS84Aj35v9 O2ZpXR1DUOEyXz2QebU4KM/qZQKJ3/yG0vaG33E5zh4RvTQG8JkdzyiEWhXJYRZ9YwnNLeExnY2 I3k7XlpBOKZBW8EfM6k5dRs9ak0FD+ms9y/dDH3bai9IKNr7i4f8BD4wiPJhSeAX5eyCMbZa+3J 2MVAV9cgID0xvnQ= 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 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241214_092647_958083_59BE1B90 X-CRM114-Status: GOOD ( 11.38 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Atish Patra , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , Paul Walmsley , Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The GENERIC_PENDING_IRQ 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: 13908559 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D00C7E7716A for ; Sat, 14 Dec 2024 17:35:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lSNoxEQxT4nlJSCAI4qASFGtQdy5FKovx/2GRxw6gVc=; b=tQU6ysZ0NTuSWf V+THrBM59NNKu1W213sRO1TOe1COZ8NTV4lBG6Aqz6kleO5pcr4empXp72uyNQGVgO9waEAuiFzN4 ZKHvCumVZns7ZLBPN6/fihQ65WdEiJnbiJ5ZlwyUPQIedCFb8Q5dTKLscpH74OUZ84C7iGnnTh6CG 1AnjP+osrwX1GOgziGzbqMiftD/BNsVBKvUGANaFOLPUq+T7QgPcuv2F4N9R6k0UJCOb2yHxQG4Q0 +T+OvuRwIEU8UgE1uZZulYYhuAqEaDgxjOW3INGODhGgrLJEv6J5iidojCSo3s6ZDoZaSG/YlZXWm VhbqlahNUukf+ww2ZGag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tMW2d-00000006i7f-26Eq; Sat, 14 Dec 2024 17:34:59 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tMVuo-00000006gU8-1E1Y for linux-riscv@lists.infradead.org; Sat, 14 Dec 2024 17:26:55 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-216634dd574so16629595ad.2 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.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yE+w0neHmk87dMRt+p213gF5rtqgAWN6iext8wGVFRM=; b=GoFQlJy4nD3najFRD4CLhH3we4JMYqxuWrhQvzob74zv6RYqRkd7H2gH/9rxR1Vola gmFvskrU+yyH3AzgXshJNBz3IXP3K9YhawBWIp5ri4s0QAPSGToyYp1p0pDUtPQnYKrg BE9QjuaR5U9Yxjjcxm91tMU2D2mhlJexrf4VqOX/7LGajtT6M/7CIidcIiDh+wiTZR8r cWe9tGatmINEbCJSWsQ8l5TqcUxlMhLhMhs2LL8NHTPAWincZydxFs4/v/1AZWTD9L4y 6g1sIVepMsSs160tlv4z/bst43hszxgsd1HbylbFQgUUvC61eTDCBEhD7B9iqoFdPika jh/g== 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=mrIPgVYAhBK5kqy5TNKOiw///M2u00t8CkhsYPSiAWT25aHHkDsj+kFER9xSKNDiNb RWnYi0TOMAPucbJVkjBg108+cWIiwAok44HvlvP1qlEjUfzsnArgPlvKOnQiBn03y3kO q8gkZ5mnTyv3/FGmqS0Na65sEF5D2rZAZ9igUkz3RbEAg0JBpgP2EdLqQjAonPgEQq3o vMv6FOFOdagYEzRr+iiQjV3xPDM4T35DRXO9/4CZCw7L0Ebrr3M8Pa3ytraJPPHt0UYF /370oh3aJM2UvAc6QwOHxYZeGSeCRVZC5zsRSir6K0zGyaAEek3VPP20gdsyKKaEeagI YFpA== X-Forwarded-Encrypted: i=1; AJvYcCUiJooudhLse1rEeVl3nnFPY/0n2EtAEbhr7tJ0mGIapHP2r6RerpeZr0jrQwMX+I6uPmIYpGCET319+Q==@lists.infradead.org X-Gm-Message-State: AOJu0YzDDtLKYYyz6IY+iRfrQzNsyzctSnnQH6EUQl77/NX2hL33CPaZ cSQwrWFR2Aoh/x21ZOEV3c7VsEaXLT/Jae9GAz2kuMTllg1G/dVMS66ouXRlyPg= X-Gm-Gg: ASbGncv1LM/lzhT1P/rQ/DSpg1dlTiOLn8blK/266hYl9B7VmywzXiGLxTmtO8NJJUE oqTmfTUPYF5+171XCHkGN/4DPgPQ3rOb5axr5hcxglRaWuJxd+e2ngkuEYM/c3qlsp+o99BJIyR 0burKETODvRlsK+zMCtgdG3DLW0WRsS4WIhtNeIRiz3ZutwUK1sswVqIfpELUHfO1ytvEtnbxf2 vIJTm6y7E96VHxUO+SBZ5uTc5ckcoXa9cJSim3BOyMdqv56sokTioNyn6//IHVfmLLvxbrV4kZo U57VSr8cI/YAaeU= 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 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241214_092654_334399_A2DCAA5D X-CRM114-Status: UNSURE ( 8.34 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Atish Patra , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , Paul Walmsley , Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Enable GENERIC_PENDING_IRQ 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: 13908560 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A2CACE77183 for ; Sat, 14 Dec 2024 17:35:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=80AuGT4CWYZaIciPPttvYDBVhJrVYLMrRMjdddo2hgg=; b=qQ434yvrIHxsNG /s+RIc9x8OPhPx8TiFpdX+G0ZCnT8To24OF8Xb7NJpv/HfpEb8e+WI4HJ6oOWeZj7JCcmwSz0sTUC 17T14Ojpxn9179o0EoWRDoEfr/JtbhFYqTZVmkCKGazQ8vy0vwkDk9I2dWBhrVrNcMfMD5rjG6IQy aBQExYpMSe1AdCPVVnlDB6Tq5qLtkVd53kS/XwMll8vo1snggElHEHyW0e8sBoCipTb0X+/iawMsX Vzsiv7YqrMgIFMOPNfGPP+ehTK4Kn5RuvEjBss2eAevT4wzVnB8vVF+G+Mxnu68LnoYzL8Jo5O7AO c+BTdBzBmJKBEt3bl9Ww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tMW2e-00000006i83-0Zmb; Sat, 14 Dec 2024 17:35:00 +0000 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tMVuu-00000006gWJ-38V3 for linux-riscv@lists.infradead.org; Sat, 14 Dec 2024 17:27:01 +0000 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-7f71f2b1370so1694515a12.1 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.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qKWIt7ITp/X88ndEH7it4rZ1geXjjPOabq3XOqds9DM=; b=jaceKLxGXdYrTLmXc8Q399w/Zqi0QmghpUoESaQ5vbqYCdfpUc8rXyOwcsOQmNCAfp 2I2eIiriDsbReMV1a9R6n7rMGXKnlDg1++hWxdgqJipEpkZAPon7UmJft/z8a92JRTwV 2ZA4WRglHi8vEy9OHEX1esKRtSr0rOZcxiG78wJpQAmWaU5kjraaLlWtV2XqHqzKh38P Kf2Qq/L0FtGKKV8KRetZ+84DfBEUDpmBwOVh30KsThXHCyaxa8xDM+Kf2LmVUakJc4x2 zxOIIbNQmmwy0XirembEIhIUrkhBgqgrA3ioM+NhWk7qpa/jyaTwPCbH8IE3xaCNL2Kw Z75A== 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=Nj33BLYw7mdoBbdpO5VTi3Vbk8GqDpodaz7F5ye7kIO7p6tdF+Ca6pnj5OseSkBBLY Ajh0Ch2L+omalepwLzPzEBaDQRJY2sqb8gEOCBdEfCm8/2M5+mRb3XcxMQFo3TCXbXB+ JJSXWVngp0PnzI2fJoaXF4y5zhw1eVwQzO6fw99hTkgMklZg6iM0KFJqxPcU7zfa4W+E B9Nw/oG0d/GFHlGB3XyLJQW2Tc+SwjPuY3H+/w6+ZsZhOuKF+vsmnGr0yJhhxutSa3DH qzxD3kKkQKQiBAwo5IEN7U2cSltAkop2fArN5o1tz+B8hhi4NYWh9sIMhPzHSLeP0eFa aDtA== X-Forwarded-Encrypted: i=1; AJvYcCVrN3bSmM7/U7G7rTrcnO2Bin3paXdSp4LXMaLx3hI8dZElT426nmUGyJcnOn4hv3MLQknWY3RYNOWMsQ==@lists.infradead.org X-Gm-Message-State: AOJu0YxHjID2J3MUe5I6ns0OSuuEzJPZUneMQFgi+BvIA2UawRK0Ta43 Bshhg9hpYlRgNyXryiECkLCHq3cA0hm4JHQz+UUQPAmFfkr5rcJmSMw9nWX3H0o= X-Gm-Gg: ASbGncuNVs4ghVKSHLpLbiF+Kzc9XD3G70qQODYdkv2V1tEUnh59iS9T/lbEG9vFrm9 APzi3miqojhREo0ahT+BTikB2BXjqGKzKuhcTOsKhVYbbXS6YyeH+c+d4WG9SVCHA0zpXETxW86 EZuEWVF9xhHZnUbbBuVmetP6aSD0hpetyW0nG9HFb3fO/pouNdFTGu54z75jZ8IVJOFsurLY+zK Vfix85aZ2XJGlbsNMogTM022pDcub3FapEyOD2msuZ39XISJkopPabLMYZGTc2vqc/BXwcOh06T SuMZa+MpG3HUF1U= 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 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241214_092700_801309_3BE45ABA X-CRM114-Status: GOOD ( 21.73 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Atish Patra , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , Paul Walmsley , Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Currently, there is only one "move" pointer in the struct imsic_vector so during vector movement the old vector points to the new vector and new vector points to itself. To support force cleanup of old vector, add separate "move_next" and "move_prev" pointers in the struct imsic_vector where during vector movement the "move_next" pointer of the old vector points to the new vector and the "move_prev" pointer of the new vector points to the old vector. Both "move_next" 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: 13908561 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9D5EEE7716A for ; Sat, 14 Dec 2024 17:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YVK2WMLl578ns/6ZZhfHZqq1tBVmuVO0g3utRCtkI20=; b=n2GyXjr8JLTkIq DbgMM8yI8lgcAdYH0Td2NAvUW24Q2uAXidx3OgW7jqXIhsfoKktLm7Q7U6WzKE8w4Tnn1Rt9ND+3i /HbRx/eLxLozeM7yqCIfGNFcw2oozgspMWpG/WDNBFVLVtQq+p2aWUzQsawvYpJm1LkraaO9ioQyW Frrq46+K11l0xR9aIN0b5W56mq0Chebxq5UA4KyoArcXL2b1i6v8mQv6c+Nn1tyI1wA1SxNoXIIAK uxugLA16o81wdD+9mRTICUHV5Wjtg4ESRoTtHN0rW8SwAduJApHxwUHWXXBDuewuxf70eW/drIjJs Zce5st6mzF/ofIs6kIKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tMW3h-00000006iPv-27yo; Sat, 14 Dec 2024 17:36:05 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tMVv1-00000006gXp-3aNm for linux-riscv@lists.infradead.org; Sat, 14 Dec 2024 17:27:09 +0000 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-2ee8aa26415so2457007a91.1 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.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K8c4bSx6OeCafE/EjjWkj4NBjcuAlryx7NpTdvjZLKQ=; b=DyAQGC6PrV0cyPA1tAoa/aVyJn3JyNZBq6b7tYnZ3lU/vAI0vuV20DyBdUHfMh3mb0 +GpIyUwFapPXO6ekwmmMal3LPBJkP1ItZxiVrylcDtcoEHVFgB8xmr6CzBFzHaGUOC80 lLhoAvDoxE22t+MatTzrdCWo+ELJQns2uR8WPmB5BM2F+prjTV9IVEBv+4L284ggNReJ jD19Y20SGW+xtx6SZOg3EcylqCezHH0n3ddlFbXLRQEWCT2jG2GrxH9ni0ptaUNX5jBF NFpywYxu3obOLI6HwbAhaRVA/SZMhdtMcjTQuI1Bk1mREyiiC+PWYa9wwHTWZ/QjB3Kr XR/A== 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=gPdqY1+VHVhJuojOzoWzfhEWyJpBhbfRISLX7im//iapbUfPFBbhL9gR+vMK7PHZqe QRWdqZSzdboSTZu6EoiS6gd672JmBfIR3A3XPHrEACHoN7jLJLVXRiWQMxo8TCZLNhri oAHsXwpkZAXLGNXRPHgPOpLSpE2ES1YdFXQnphIcVZQb3F5TWx3EE9WLrbi7dFWCW0nX Rlk5IAInRD3aOPY0oKK3Op/s8vYA4DLKYdMrB64s0Q0O6rEpHiaGH50m1IHSbOW7KBND 3mKoC+DX0cyNBHU+vje5r6zTeIDe97OV++mxx5bCzOClVB7lx+/DxTcxH0sJVd8mGOaz kfQg== X-Forwarded-Encrypted: i=1; AJvYcCUVzJkBKjs8N0Xfc65iaINPyZCVyTWGTHORQcn6grPPUDs2WGtNbxIu0vfMKmBFYOzJ+xAsJcQRA01V3A==@lists.infradead.org X-Gm-Message-State: AOJu0YweEHzfQfdcSeKjg68k5gbhGiptkag/G9LNd1Va6Y7IPqycZtnF Wq+q9bwvbTV0FpdMrQKZsWZwDv4WyLcGm9AN6aRRNcA2PIQ20QQzWzjlSCDT0MI= X-Gm-Gg: ASbGncsZ6OGhFtEA6bBs0pc4U9A3tvyIDDr+XKKmdz0Uq+0OlDD0IvAurraiM5HpF3Q IC1Q9R31Gzpu+l3JbSpC0L0FPfyZceCd/AnasdUTf++HujGQzWdkn4HPUUodIu1dmyc7E4r+Rqd BMvU95utRkEqR3274BFIdwHjR4YwMUvuKZZS+noutFVpDHR4Kw1hOngmXC5L+IHb8TAWHBm3/FS CJ+eQ6h7fmROBzkYoO++/gK4zyxvqQ/ETHgAlQpgP24uRAxVUV7POLl8A19u3j5aD6314OgQFAD /2TODWt9Rhuh78U= 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 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241214_092707_927800_1FA6AD28 X-CRM114-Status: GOOD ( 14.64 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Atish Patra , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , Paul Walmsley , Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Implement irq_force_complete_move() for IMSIC driver so that in-flight vector movements on a CPU can be cleaned-up when the CPU goes down. Signed-off-by: Anup Patel --- drivers/irqchip/irq-riscv-imsic-platform.c | 32 ++++++++++++++++++++++ drivers/irqchip/irq-riscv-imsic-state.c | 17 ++++++++++++ drivers/irqchip/irq-riscv-imsic-state.h | 1 + 3 files changed, 50 insertions(+) diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c index 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: 13908580 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A5D40E7716A for ; Sat, 14 Dec 2024 18:46:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DKLzFrPGahRK6/mbHBMZHp6Lw7RYzlS6pnHmtyEtJnY=; b=tIa1mNqVKYHST1 NDEx1MCjcyP4cypIMSCefogad7cTdeZsb9NGns4GXiSFiPX0Ozp8Hhf9PHHhVcUNrSb6YSUp8jQge 1NRCttcHrMdatt4Y8JgspnrDLZi6vvpTnQJSXGYS4cQqp2c14QmI1EClitc08aDf6+ZUO/ydUW0B2 j5Gr51LJo2cDz/noGmortJ13uaXR9lRAIU4rVM7sWWMuYrETcinavk+jvFaJIoUq14H14OhIcXVAC AeccSkotKuBF8bFCJaQyT2HeWlytGwIRrw5XZZCAXtoVpuonSeCdQfZPhlPOf2e8rvRHjoRL2WjTh KhlbjGXQ4amVItUS057Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tMX9H-00000006nYH-0Our; Sat, 14 Dec 2024 18:45:55 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tMVv9-00000006gZt-1tZv for linux-riscv@lists.infradead.org; Sat, 14 Dec 2024 17:27:16 +0000 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-2ee51f8c47dso1914712a91.1 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.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EP+pJC86HytY47PbI5sMBg+o5TFAFMoqjjekp4WBZSk=; b=NEwm7NCgBZvTjh5PL4xLstTePcqDe4KhrPWnztezena2SxcMXXwOFjVkWHCQ93468f L6P855gjOlOfFV9arAAEaGBCPQLdGEMCqzHq9USk5LfsQt9TCxA23t9qBWDBP6aPJP3L MyZWr2dbz7fXLsJdmWOTDXaa0cHkuHqJfs1YAaZFv6BjpvAy6RZDdaxYbRRFl1jdDKna BrIjH5gDhGWcDMl2m7osUDsegpFfMzdIhfK/XMKyfv91GPfGqrBrfrsQYziiWFixcsBQ vwfdjMzSsJ+QML1GohD+EOZZbLjqk1DfGOu8EG3hfEfJmrkQyrIYm/XfKk9PyUpDeVzk Ig+g== 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=rP81E+tqtMztl5Z9HbedhV8qJ2y7farnoO2q96Yk1pom1UHr7W0bFqX7APu0lTbPTC w1hBEb8axebYjaJKs4wh1fb803q4SzjWmwEr9IpeCIODWyDq/mm0Q3mGIsavNubuUHb8 5kD4OU0mnjewCQ7axH+EVW1cQLHonqozC4kq4d/XYfK9WCzwXUtGwOz+fqxgZ1pnwm++ m87Suk6AP6g9l9tKNHWKf/j8aoy0jZBEjhmKyaKT0O3nts6WmQveJfr/EWjw4AlFX8Oy rkbQokTM846XruJbnnj5xZmo+Laop9aqhL0ge5z2KO1FR9UN000ZOmEFaRUVf2bUVJb9 90Sg== X-Forwarded-Encrypted: i=1; AJvYcCXc4+SazafCoXR+A1BT5wONSMsQor0kFqm3B08HttId9fxWX5/K1j/NmF11SlDrHef0y8R8uBBDalN1uA==@lists.infradead.org X-Gm-Message-State: AOJu0Yy6qOWfGrhs+zrUqb07QddeeiHqMsnLoEN1/cfe+Kp9YgtZQatn 7IP66mqElu3+uvcJk8l8ZMyZ3YvG1x8jHNwxpDSHS67bd/KTyQx7OJ5IGbkDPNc= X-Gm-Gg: ASbGnctUPSJBDIH0jJClwzJKK5umv5RcmjMkO5OTwsqKT6TIwiGz+g3bGKnQoT0BcB1 b7B6mPT8rJ2Dv3/DgleihOuzDQIZk5Zo9D8CukSKpHJaedSUtK+7XyW6hrDhOq7wwnQrCW+blN4 y08AE0UisVkqxvXLfJYSB+INTk/gNOSk8qPQzsbtPpQewhKoCtzFa0KNErbRJw/cU9xLUK0hJfO 020gSuOmSboattNk1QN9P6StaKo/3AgsyVxb+APysojTInUJzYih/otu6+LThC0Drk/WrDYN/fk jUk76PpK1ScB2QA= 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 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241214_092715_481244_31E735AC X-CRM114-Status: GOOD ( 16.74 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Atish Patra , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , Paul Walmsley , Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Currently, the imsic_handle_irq() uses generic_handle_domain_irq() to handle the irq which internally has an extra step of resolving hwirq using domain. This extra step can be avoided by replacing hwirq with irq in the IMSIC vector and directly calling generic_handle_irq(). Signed-off-by: Anup Patel --- drivers/irqchip/irq-riscv-imsic-early.c | 6 ++---- drivers/irqchip/irq-riscv-imsic-platform.c | 2 +- drivers/irqchip/irq-riscv-imsic-state.c | 8 ++++---- drivers/irqchip/irq-riscv-imsic-state.h | 4 ++-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-early.c b/drivers/irqchip/irq-riscv-imsic-early.c index 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: 13908564 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3FD41E77180 for ; Sat, 14 Dec 2024 17:39:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5yc33CRZ9Y2Y7HZquSM0tC5gYwwGw7IQ6HAX/+7yCOU=; b=2pNbKWSnPEdAIQ QXFuvCft23tomLqIRSMjItAxH0QdggYFITrfMFkf5S+Dy/+3yB8pMUteCB4GqddReoa9FmnI8TxS1 W05hP+UP41LUAE++Gi2P9ouSb+WuaNriw0hgihD/icO7Ith77lfHPVQXlgKeQErnzWXPfpxdtzjrg w2/Ml6Nrrg/kUDwXybjnAuJoPA37ZmdJQiSd4OxQmyir7HZ7sZBLkNy9B9Rac+RBCd/th4I95F+XA A0EGRO0KJLhjITpl2XHxjm+xRCsobpdfHw/V4JWc5qvkDmO4hVWD9tAvJ+lR+nGktw2l0e9z+2Iqz ECU23yvdNLxVln6CpeuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tMW6r-00000006j5H-0qvZ; Sat, 14 Dec 2024 17:39:21 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tMVvG-00000006gbq-0514 for linux-riscv@lists.infradead.org; Sat, 14 Dec 2024 17:27:23 +0000 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-2164b1f05caso26269345ad.3 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.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q91PIdpY0ToxJxjWetgT5wSgNIKHhdsWJzKO3onxaMI=; b=AgFzUv8z7ZTrx5avSuVUgCvjZFAn5RK/Ge6CwlBN2RP4zNq5a2nyjeh9myZjKtwkTi 1DPmpJNwm7tnkHMTPicLfviitj7x8Qs8+U1+b13/S2V3NymM0F8Kya9ImlKX1vM/qrov wXpiFyt1aRpwhUmJpwnUORbVEpiPGCx4oeDGy7xb1uO80FDqPU8mV3ZdPoe8iMrzs8sh WO+tIPtPVY3E6vC0REiQTPWc5Y3gSM/hkuXdrzBabBBYv0HPgXzsa6vFGFAcUtIDKIRF +csPcv5QuB2mYJdED47gR5T+jOWGVAylKAAgoxv0ZnaQ/vHBD8hJt2KY9C5rExTLTlp5 z+kg== 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=COtvY0LXScqmaXBV+sz749USe+3SAtTpMNBGFYgQqPUSUxMWQRKC+GeNfk09Gm1uwh Kk7rTNYf0Y1Xn4QZAV2ySZvR/wLn7k8nLg3naLuHnjINV7W8dur2CG+JIrQPjHlQjnTn rHp1SOAMQ8QgRAilmIX/jTXavgDfheDKtxHUj4P7hNxBummKTA+/HE1YdK58AiE9LRu7 fEeh9lGTbMU0/iJdLb52iKvd0hpqIkxxA9Mv0Yy+QnRN7ry/O/EvvKvmKeMAOmEYSCfe XYxFkWaZ6YJimNqzGUZUgplzRNxibC9jzWXWa19nRMV9s45X3CdSSVNjyg4xPbqa98NY KC1A== X-Forwarded-Encrypted: i=1; AJvYcCUrMN8DpSUhX1EQowt2LAl6pCl8Hhi0jNg4WoxBwi9Qj9eS+bHV4KaCgVf5YUkbkORt8AfqGoNml7XiWw==@lists.infradead.org X-Gm-Message-State: AOJu0Yy9x6Oip4FdF2JVg2Izva2Qww9JzmtcE8fPVewkWbdDHP1hYhJl N23+2mG4ZK0w8iaXrxYwFhLzny0nMCnV8TjVVEEmOwE4BZTidw57wTtkLMFIQTs= X-Gm-Gg: ASbGncu+H6/v/L1+on2ukAUYy6Zd5sfLoXd49HhjZZvC4le24LtRN8frPtN9kvrKVTC gE8TXHWCmFYvmQalo/I62ZpOjOWfWL71Ik5z3QcwMFbYEh6Ic8G6450yxj9t9VeSyjfbmA2iceZ RN7tgrRoE/Lh2wD7VwdjSH7bCeESLqj4fa1FNH4I4SFQ6bX3wUVMdWK5N3UJi9kSIBAhNyzhNlK eNEAmCSAbZvSzGi9YLt52tBAufVaGxtU2GIqHkbvfvZqVH8ThOLtSOUBqMl2kLKFoC5wqy8G1ad 97BJe4zbK7ZnO8A= 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 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241214_092722_061054_0E99CF1A X-CRM114-Status: GOOD ( 23.90 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Andrew Lunn , imx@lists.linux.dev, Marc Zyngier , Sascha Hauer , Atish Patra , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Pengutronix Kernel Team , Paul Walmsley , Anup Patel , Andrew Jones , Shawn Guo , Gregory Clement , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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);