From patchwork Sun Dec 8 15:07:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13898588 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 49E40E7717F for ; Sun, 8 Dec 2024 15:09:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=DPiL+4+uUrxsUPNFNe0qcu/2Buvw2EBCmaBEkU4Ga+k=; b=2RnznLOR3rMyJt8wtuQ2cwjLqE 4UyExCfsuddNuHTIpaiVS+OXwSYASySAZsErEOPoY0ONarBzzpCzcM9RaYLHCQ5myUcTBt1XMHA2G gfGcON5EO9NupAXNaCSr7NrTiq+HyVS7ixB50L70NmHip2oBns805ECu9lFUIXBfNxqrkZj+VSk7r /1ckMp6sXV+AdmG8Dfms+M/GM/YfcnU38uIEVx/OVxk/vnYMmYw4sg6WnoU6PAdirVabgBTyZ4ZOG C+fKOld8U83EEZzHcLW3NPzdtNIu+AD2rkpEYGEEuFNz0ZHRTaWNhbPbvmghsE5NM6aHzmhZ4QrQR VVeTV0KA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tKIua-00000005QWS-1GuJ; Sun, 08 Dec 2024 15:09:32 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tKIsb-00000005Q51-08ab for linux-arm-kernel@lists.infradead.org; Sun, 08 Dec 2024 15:07:30 +0000 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-21634338cfdso8868325ad.2 for ; Sun, 08 Dec 2024 07:07:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1733670448; x=1734275248; 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=DPiL+4+uUrxsUPNFNe0qcu/2Buvw2EBCmaBEkU4Ga+k=; b=czm/e5o3GwrIWk9vvk3bUgZlbd6rGHjSDPxY8xKaZIR0+8QvpRWT952pq7/l4C5ZSE uVje1xffP+IVcxMmIqa+s0udULVHkdPeiVqCV4/c4+CoZXIXh42mjmp7BpNk6rdd7ZIu lz4VOO6KIM7nGn/wt16DGbAfHlH/li81P+uBdkNlUuWRdfsIZwvBz1aEmysZBD4oeZZ1 ZmhTAZaL77O5mGpsi7rUB4a+a5OL/cQGEXo5Xc0nWaAJy9bfWw/ttq2kOlXBiP9C+/Dn eJNS2Ehd7o/udFJK7SyiOVq8wpkUcBTHLQBJ8BbvthzgLV6jgxZOU2lsIDtQQi0YLUPe 6qlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733670448; x=1734275248; 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=DPiL+4+uUrxsUPNFNe0qcu/2Buvw2EBCmaBEkU4Ga+k=; b=Z2lMOAQ2piwz5M5pnwmqYeooCqzZyjO49xGghjbSWDlaJhwEgI3jMxY6pszxlVkrjD LuXz0dE6g0AV1KomgSHvACyhbr3e0s2b6BVRSFBIW7GOBNuXWvWzqtK2Yo88u1exFM1B +tQuUllsQqn1wXsQW0i//Pn04dBToHrc6LcZF4hU2Wzf/uuxgVFSS0OMPlkZqA2getV/ ZS6+IWECmCih7/Jq56JoSzEQ9sIuuCCdTeWURAhbOZcMnS/FxCIMjwvi6cfB/unNtiMJ BXIO25EDVSECqxatFrsbHzlhUHewphgG9LU7xzdlWHAx4ker2Oe6i5lnBjST0gUJtUEI 0qeQ== X-Forwarded-Encrypted: i=1; AJvYcCVyHP3VAXfcCdYbX5BQ7uLEFEgcIoSeUDwp1voKGE70hskBCAh2LhYvwVYtNAnDUr0lFNJNjFXJZgBdXYT1d3io@lists.infradead.org X-Gm-Message-State: AOJu0YzbJ2EoZe/pLv08v7gdpa/nzpWfpyXyR9iD5W9Rs7ZSNObC4UEK Smuw9Hz1shNBnyhNxXkNQmDDLoTLvOMG2xxzMimM6Q1jaTBRS0ykl/Wo7FndXhg= X-Gm-Gg: ASbGnctL81IIDzoWeMmqqwYrLac2GBSUJS/JYrCItZSXwW5uFku+aOJopE3wcJdwcI/ C6R6ggf+1GJiPcq4a9qELrZzeLhfaaE+5Yt8k2va0lKRMDXYf3oR0zKqcJbr++kFYmQBP+69HdE 0ZlCteLN7JQAJEPaVtqHXcNlJGqMs7nYqz0HJfIirw74O53IlPawSGN4fWGeMdlVjoURcAMskQU 4xhH2fnyYQiyOQb7hsCA+NcsUI9OUCufAzEImeoFrHoz2iBDVH8PwVWCoVQo+yh2eTWR9L/LKB+ MYirh5N0OPwkqDM= X-Google-Smtp-Source: AGHT+IGeMHvOT6RCYMvwhhYpeZ8b5RyMdQq1g0U5HspyszP4RDGsvXBxsgKTLdGXoqrj8jvGvqY46w== X-Received: by 2002:a17:902:ec90:b0:215:b5d6:5fa8 with SMTP id d9443c01a7336-21614d98c11mr163726535ad.22.1733670448046; Sun, 08 Dec 2024 07:07:28 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([223.185.130.223]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-216412293d2sm10274515ad.237.2024.12.08.07.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 07:07:27 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH 1/4] irqchip/riscv-imsic: Handle non-atomic MSI updates for device Date: Sun, 8 Dec 2024 20:37:08 +0530 Message-ID: <20241208150711.297624-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241208150711.297624-1-apatel@ventanamicro.com> References: <20241208150711.297624-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241208_070729_102034_5469E30F X-CRM114-Status: GOOD ( 18.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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-platform.c | 27 ++++++++++++++++++++++ drivers/irqchip/irq-riscv-imsic-state.c | 27 +++++++++++++++++++--- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c index c708780e8760..707c7ccb4d08 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)) @@ -110,11 +111,37 @@ static int imsic_irq_set_affinity(struct irq_data *d, const struct cpumask *mask if (imsic_vector_get_move(old_vec)) return -EBUSY; + /* + * 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 + */ + /* Get a new vector on the desired set of CPUs */ new_vec = imsic_vector_alloc(old_vec->hwirq, mask_val); if (!new_vec) return -ENOSPC; + 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..230b917136e6 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 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); @@ -151,7 +151,28 @@ 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); + } + + 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); } From patchwork Sun Dec 8 15:07:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13898589 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 232DEE7717F for ; Sun, 8 Dec 2024 15:10:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dDa5uVtGTmKoF+EGxYZ14lQBrXBy+Zgm46G016g9yok=; b=bq1poGZQT5y9F2KmmnLYg/S43f 8OpBi0M47raJ/xpcPzgrtznzIeTchUz+zo4AIef/cQSe7PQtTVxJDUhnlu0DcDI1UdtIyjoTL5tC7 uwwlQTBGV1BedIqlsWDyxhMvb8wh8QHjtAoSTso29ot7+e2vQzUYWmwiLeU4H1MCWeyDBv6+E0im+ jGEdiRr8sW29nuZhem2mFBQfvk8Yy1bAfO/JGNPnnaEfb+Nnsymd4arzffebKMx4DlsuZyW6ubVre rG0mFpQuST/mutac7Xk1L08aKnh9p/ODk6fg9lTInIlw0xD7K4LqrNDEjMhOVDgTA047ulKygyOMZ Wd4aZVvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tKIvc-00000005Qri-0x5F; Sun, 08 Dec 2024 15:10:36 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tKIsg-00000005Q6S-1ahd for linux-arm-kernel@lists.infradead.org; Sun, 08 Dec 2024 15:07:35 +0000 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-21644e6140cso3043185ad.1 for ; Sun, 08 Dec 2024 07:07:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1733670453; x=1734275253; 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=Hm8Kym6Vcd+F8xm+7D1klRhpb9t2YGbwDMBttB4Bd4kfxv6kNWVrOy6t6XdX8jwdFx kCKl3+GA2HMZuAlB1OYT8kDIOMqxeiMH93YdFbjUk4fz9E/gDoE4LjnrdIX9/z6MSLmh KGDEO7k0i+ERBaM9fDFbwR6SpvC2mtzjO7G2LTN9rQy+ELOirGnSRZx6GutDc6GcfyWU n0bRV67BlZMtcKolNDHLzwPtLwbOxX5i8u8dkPu3uWVVwDCd6wG9jDqb1p/mLN91s+4P 4hKSREIFB4IahrxwGbhJ9s/HztnXYBwycf2DGAk19euqCNuR4x6QJTdKJ6t92tLSRLiS twnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733670453; x=1734275253; 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=CIS08oLglvxtcMTBbK+PUuLTi+PaA85MMx24l56bwO/qfizInUokahQ341RPGR84KB cTgsgNKT2OXFXMlNrCaW87fSuRnpVSH9P53EEER0D6GgndulIz/pLbKTv5ZbqaScpAha zPlLFWmOv0zMVniziac+px897XR9LINTM3resojChsDL45Yrp6rgcPj1tfhuUJ5SvGXK 8u6T88U0bg2N4oTC2UVsRagzTf1JMJaVuABYuKBeMZAcKXcs/As4y/ryxxALPuQkGvoT KA99QszHB4UgGnLBG/fnrw2yG2UIlkAO1aH0kaQnmxubXyifSKRrDf6OXJ6+RMRevROV OyZg== X-Forwarded-Encrypted: i=1; AJvYcCXxfgdubfCn6KivyIbfkt/gqNAHshIZhtUngdaXZfoR8DFwc/dkDK4mw8KiIO4PIGb48jyd+SbYHbWT4jJ8AsFy@lists.infradead.org X-Gm-Message-State: AOJu0Yyjh46BMJEhov3L4kVPAfsynU3C4quF6jQVswvLHBCaQpu5TK/C b88h4vuLc1HCenzh33QwJYUKS3kI2EFrfZnpMQQLNGDHCEk7VdkwbO8sCXlAFKE= X-Gm-Gg: ASbGncu2weq/Lofnmgeswft+aKOFVkeKhMdUlbgvdNNJ29POlY9txSEdiGdneAasO9l qWNrSPaJX/dy44WnH3prKA+kW+AD5ffnmnPjPPVpDkJ50XTxvwGU4yb8gBxNYdk0TSTrVs0tZmp YCzls4RrVodp6Ajh0ozrUGLYkLhugOhvoBQltu/1GtgYu7W1V6+opyRkKY9k2ud3TWhG3VHhbWL nPTdnDb7Lt2VsETHjr8DCAV/eIjOhdMqR6zbS02/6QR0RTMY+GLWfe7Pi1ENi7x6KdF3ZC3+IaK ladUV6FFv2FK0W0= X-Google-Smtp-Source: AGHT+IHyj7sXoNPiIJh6cz0a5ruVm18syQJN52TbYaMiqQ+76Oy4OAu0uMksfaRalPqaCn9B1Ej6QQ== X-Received: by 2002:a17:903:8d0:b0:215:7f94:2b8 with SMTP id d9443c01a7336-21614da3e0dmr176826745ad.24.1733670453399; Sun, 08 Dec 2024 07:07:33 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([223.185.130.223]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-216412293d2sm10274515ad.237.2024.12.08.07.07.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 07:07:32 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH 2/4] irqchip/irq-msi-lib: Optionally set default irq_eoi/irq_ack Date: Sun, 8 Dec 2024 20:37:09 +0530 Message-ID: <20241208150711.297624-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241208150711.297624-1-apatel@ventanamicro.com> References: <20241208150711.297624-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241208_070734_409158_FFDA50BB X-CRM114-Status: GOOD ( 17.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Thomas Gleixner Introduce chip_flags in struct msi_parent_ops. This allows msi_lib_init_dev_msi_info() set default irq_eoi/irq_ack callbacks only when the corresponding flags are set in the chip_flags. Signed-off-by: Thomas Gleixner Signed-off-by: Anup Patel --- drivers/irqchip/irq-gic-v2m.c | 1 + drivers/irqchip/irq-imx-mu-msi.c | 1 + drivers/irqchip/irq-msi-lib.c | 11 ++++++----- drivers/irqchip/irq-mvebu-gicp.c | 1 + drivers/irqchip/irq-mvebu-odmi.c | 1 + drivers/irqchip/irq-mvebu-sei.c | 1 + include/linux/msi.h | 11 +++++++++++ 7 files changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index be35c5349986..1e3476c335ca 100644 --- a/drivers/irqchip/irq-gic-v2m.c +++ b/drivers/irqchip/irq-gic-v2m.c @@ -255,6 +255,7 @@ static void __init gicv2m_teardown(void) static struct msi_parent_ops gicv2m_msi_parent_ops = { .supported_flags = GICV2M_MSI_FLAGS_SUPPORTED, .required_flags = GICV2M_MSI_FLAGS_REQUIRED, + .chip_flags = MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_token = DOMAIN_BUS_NEXUS, .bus_select_mask = MATCH_PCI_MSI | MATCH_PLATFORM_MSI, .prefix = "GICv2m-", diff --git a/drivers/irqchip/irq-imx-mu-msi.c b/drivers/irqchip/irq-imx-mu-msi.c index 4342a21de1eb..69aacdfc8bef 100644 --- a/drivers/irqchip/irq-imx-mu-msi.c +++ b/drivers/irqchip/irq-imx-mu-msi.c @@ -214,6 +214,7 @@ static void imx_mu_msi_irq_handler(struct irq_desc *desc) static const struct msi_parent_ops imx_mu_msi_parent_ops = { .supported_flags = IMX_MU_MSI_FLAGS_SUPPORTED, .required_flags = IMX_MU_MSI_FLAGS_REQUIRED, + .chip_flags = MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_token = DOMAIN_BUS_NEXUS, .bus_select_mask = MATCH_PLATFORM_MSI, .prefix = "MU-MSI-", diff --git a/drivers/irqchip/irq-msi-lib.c b/drivers/irqchip/irq-msi-lib.c index d8e29fc0d406..51464c6257f3 100644 --- a/drivers/irqchip/irq-msi-lib.c +++ b/drivers/irqchip/irq-msi-lib.c @@ -28,6 +28,7 @@ bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain, struct msi_domain_info *info) { const struct msi_parent_ops *pops = real_parent->msi_parent_ops; + struct irq_chip *chip = info->chip; u32 required_flags; /* Parent ops available? */ @@ -92,10 +93,10 @@ bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain, info->flags |= required_flags; /* Chip updates for all child bus types */ - if (!info->chip->irq_eoi) - info->chip->irq_eoi = irq_chip_eoi_parent; - if (!info->chip->irq_ack) - info->chip->irq_ack = irq_chip_ack_parent; + if (!chip->irq_eoi && (pops->chip_flags & MSI_CHIP_FLAG_SET_EOI)) + chip->irq_eoi = irq_chip_eoi_parent; + if (!chip->irq_ack && (pops->chip_flags & MSI_CHIP_FLAG_SET_ACK)) + chip->irq_ack = irq_chip_ack_parent; /* * The device MSI domain can never have a set affinity callback. It @@ -105,7 +106,7 @@ bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain, * device MSI domain aside of mask/unmask which is provided e.g. by * PCI/MSI device domains. */ - info->chip->irq_set_affinity = msi_domain_set_affinity; + chip->irq_set_affinity = msi_domain_set_affinity; return true; } EXPORT_SYMBOL_GPL(msi_lib_init_dev_msi_info); diff --git a/drivers/irqchip/irq-mvebu-gicp.c b/drivers/irqchip/irq-mvebu-gicp.c index 2b6183919ea4..d67f93f6d750 100644 --- a/drivers/irqchip/irq-mvebu-gicp.c +++ b/drivers/irqchip/irq-mvebu-gicp.c @@ -161,6 +161,7 @@ static const struct irq_domain_ops gicp_domain_ops = { static const struct msi_parent_ops gicp_msi_parent_ops = { .supported_flags = GICP_MSI_FLAGS_SUPPORTED, .required_flags = GICP_MSI_FLAGS_REQUIRED, + .chip_flags = MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_token = DOMAIN_BUS_GENERIC_MSI, .bus_select_mask = MATCH_PLATFORM_MSI, .prefix = "GICP-", diff --git a/drivers/irqchip/irq-mvebu-odmi.c b/drivers/irqchip/irq-mvebu-odmi.c index ff19bfd258dc..28f7e81df94f 100644 --- a/drivers/irqchip/irq-mvebu-odmi.c +++ b/drivers/irqchip/irq-mvebu-odmi.c @@ -157,6 +157,7 @@ static const struct irq_domain_ops odmi_domain_ops = { static const struct msi_parent_ops odmi_msi_parent_ops = { .supported_flags = ODMI_MSI_FLAGS_SUPPORTED, .required_flags = ODMI_MSI_FLAGS_REQUIRED, + .chip_flags = MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_token = DOMAIN_BUS_GENERIC_MSI, .bus_select_mask = MATCH_PLATFORM_MSI, .prefix = "ODMI-", diff --git a/drivers/irqchip/irq-mvebu-sei.c b/drivers/irqchip/irq-mvebu-sei.c index 065166ab5dbc..ebd4a9014e8d 100644 --- a/drivers/irqchip/irq-mvebu-sei.c +++ b/drivers/irqchip/irq-mvebu-sei.c @@ -356,6 +356,7 @@ static void mvebu_sei_reset(struct mvebu_sei *sei) static const struct msi_parent_ops sei_msi_parent_ops = { .supported_flags = SEI_MSI_FLAGS_SUPPORTED, .required_flags = SEI_MSI_FLAGS_REQUIRED, + .chip_flags = MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK, .bus_select_mask = MATCH_PLATFORM_MSI, .bus_select_token = DOMAIN_BUS_GENERIC_MSI, .prefix = "SEI-", diff --git a/include/linux/msi.h b/include/linux/msi.h index b10093c4d00e..9abef442c146 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -558,11 +558,21 @@ enum { MSI_FLAG_NO_AFFINITY = (1 << 21), }; +/* + * Flags for msi_parent_ops::chip_flags + */ +enum { + MSI_CHIP_FLAG_SET_EOI = (1 << 0), + MSI_CHIP_FLAG_SET_ACK = (1 << 1), +}; + /** * struct msi_parent_ops - MSI parent domain callbacks and configuration info * * @supported_flags: Required: The supported MSI flags of the parent domain * @required_flags: Optional: The required MSI flags of the parent MSI domain + * @chip_flags: Optional: Select MSI chip callbacks to update with defaults + * in msi_lib_init_dev_msi_info(). * @bus_select_token: Optional: The bus token of the real parent domain for * irq_domain::select() * @bus_select_mask: Optional: A mask of supported BUS_DOMAINs for @@ -575,6 +585,7 @@ enum { struct msi_parent_ops { u32 supported_flags; u32 required_flags; + u32 chip_flags; u32 bus_select_token; u32 bus_select_mask; const char *prefix; From patchwork Sun Dec 8 15:07:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13898590 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 4B7E4E77173 for ; Sun, 8 Dec 2024 15:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=BkXmty9V9UumQmJiSKG/1C8V4fnfZ0RhcvZQ4ROkR2w=; b=yY9cJJNU3Z1iq4/1gs8HVFV5yb GIRii1f0ForTNLuh4c3JomiTLAoAKX8Rcdy+JJ7h8KqRlTFsAi3HiX66Tv2bbsUB5f0xKGs9r0CDG +NGTJ5gFFxDocszibewzG7sNMxzIfRZOV6mUwNN9xoiMjfD7Z/8S9XKSiN6FPkDviXr99CUJI6iHZ hJbNEHxq9HiMc03/qJPkVaGG8ATpnqGvUT4Bh+Up81Di3fUVPSG6gAOk1MApmnp3s4clNa/+DYLaL +/l1BvDQDRkWgd9Fw8eknBObpC6SsHFBmu0lnCUHi06IWuS5GrWVLQX31OfTuQswATghy492P3Rke WIdY8+vg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tKIwc-00000005R41-33fS; Sun, 08 Dec 2024 15:11:38 +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 1tKIsm-00000005Q8V-0lai for linux-arm-kernel@lists.infradead.org; Sun, 08 Dec 2024 15:07:41 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-21631789fcdso4788995ad.1 for ; Sun, 08 Dec 2024 07:07:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1733670459; x=1734275259; 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=BkXmty9V9UumQmJiSKG/1C8V4fnfZ0RhcvZQ4ROkR2w=; b=gmvqFq96nKrMOKGocaWoq9D1d3ELVaUiUUEaM72MrAlm2CkDBTysvb0cSvLfqg+Up5 /gaFBBxugq6i+PqTt6EvCeZaP6aD8qjgLolAuMdsYe59JkYbz2Q8u0+m2mEbyoDUXRbY +Sb59VuP3GNmxMyWlbq3tu/8vfgDScgaEyo5jsgnqXD9gami1vcrXXxvTi9nACBr9kaA mxyxtPHhO3fQz/DsV+VdqdoqYojEV42nrbsWe5PaL4qy506szW9hbZSiOEIj1dybexDY tsxKyS3KACwMXQX0o3YCOsu1fqR5W+MuSqL67xvaJf+2wmzuUq/Cxciige6m5iwnsFB+ MQ8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733670459; x=1734275259; 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=BkXmty9V9UumQmJiSKG/1C8V4fnfZ0RhcvZQ4ROkR2w=; b=IEufaIxHDABrM2EJJtpc0alg0ReRLx4rJ+DkpP5JWk0G4SnaJpCI8NCvXg8T6J5DIa g9GlWKmGCD4B1VeslA1T0D3K4LVvUlg9/ZwtazgyLVOdDeClRDQgMEnwS0/TP+Qiae2E DPfebd4AYbhr90LMoeyWfNj8LRerppK1D3xJFcHWi5Esxz/peadH5Gd2TOjNQVBlMhRP WKB9/ttkbkX1YguqMWxdl7Ly5Hj2Kmvx16JivtvEq7SLlTHgiTBpOJrjzBBOfUr/1CCl cy0aY6OLo3WcT3doJJ9jN+dzu1FGWsJkBuoKca5nRmz0HO6BmSjAyNU+Jyq+iP5qA7wN 27lg== X-Forwarded-Encrypted: i=1; AJvYcCUcvcNVbM0B1W0s6Nigeqxq2Y5nU7n310WQj27ZZAJaNjrKc/+nZvIvv/6KTAQBqKXUm95fputayOcMmdogqAmk@lists.infradead.org X-Gm-Message-State: AOJu0YyJVbWGmugVdlqyZZKOQvOrpvu0o7OuDNGspVetg8ZZDSCvp0RO qwZtSMApz6C4zPF+uti5ZcLYqBYyjVt9AfPiNgkS8UQWCNtY7qVeUtC7a2zsPLw= X-Gm-Gg: ASbGncvwtl/RlJL/96py4p4VRO657hiSeBYPSlNRQSB3IUHJe29LtKnEhUI2xQLvdf6 AsCNQQhri/Cbyq7opDce6Es7y6oVl3Bd3bh3EGkVRTbrbUJwxEI4aF7qPF4UnhR8OCiX2HsP238 yPbv12EbdtJYLTWV1ulaKOT503vcC77iMP9Wjj8Z8KvPzRnUfp2sFScP5SNDrgsjI8YKFJtHSbJ 1oOgeeZI9SrOecxR/aEmIjicfHyvqqN6sQ5GeWSP9HLwotzwcMD3TNjqL0Poxm4HuyYR05hC+Sc ZNPfek+i7AzE208= X-Google-Smtp-Source: AGHT+IEdCvop71IxVDmxbyI+VLG1bHMgUFJCX254kjusIKOtBxnkHakfEgU6KYI1lpBx+kU5iAXctw== X-Received: by 2002:a17:902:ef48:b0:215:742e:5cff with SMTP id d9443c01a7336-216114e67eamr186694365ad.16.1733670458958; Sun, 08 Dec 2024 07:07:38 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([223.185.130.223]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-216412293d2sm10274515ad.237.2024.12.08.07.07.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 07:07:38 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH 3/4] irqchip/riscv-imsic: Set irq_set_affinity for IMSIC base Date: Sun, 8 Dec 2024 20:37:10 +0530 Message-ID: <20241208150711.297624-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241208150711.297624-1-apatel@ventanamicro.com> References: <20241208150711.297624-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241208_070740_226453_DD2E92F7 X-CRM114-Status: GOOD ( 14.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Andrew Jones Instead of using imsic_irq_set_affinity() for non-leaf MSI domains, use imsic_irq_set_affinity() for the leaf IMSIC base domain and use irq_chip_set_affinity_parent() for non-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 707c7ccb4d08..33a8261e6017 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 Sun Dec 8 15:07:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13898591 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 87A6EE7717F for ; Sun, 8 Dec 2024 15:12:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=20bETIAPAH9IUNDRRJ4w+seEOsz0uHbvsdHALnvxjtk=; b=i6SkVd/9C0tJE6hoWneK1VpsLs j2qyAMjDZzxMBDV/DxEcb2I3hIFNDb8yUrciQPk/KKu3zxVh2mZEIb7vK4uOA3U6Bbij0Mm+igOWR sOTwP0l1L1v9NNs2n1bF0I2gNhDTH9r7CkIXpqkqV0clLAGFi2XhQcre9aBIHFkiXJcW9Cvh7wauN mznc3Lv/LJ4GgnEhg5cHXY5d3iXrE+VuNTW/VZfvjPbpvobmq3Ys26TokWGry1x6tyB5hLyLbyzYu tdrodl/2H72syrmBGiAMLmsJl2+HGugnG183ixleh+7RQC/XoTnIiqnJXNEScB1DI7VS55aXpR7Pk XQyPywLg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tKIxc-00000005RE7-1yfS; Sun, 08 Dec 2024 15:12:40 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tKIsr-00000005QB2-0MOi for linux-arm-kernel@lists.infradead.org; Sun, 08 Dec 2024 15:07:46 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-21631789fcdso4789245ad.1 for ; Sun, 08 Dec 2024 07:07:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1733670464; x=1734275264; 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=20bETIAPAH9IUNDRRJ4w+seEOsz0uHbvsdHALnvxjtk=; b=EPPFtzLD8JSxCjbTh6+4HzWvA1rayF2/wIPILxE+gLTLuygXHEB/ixak7e2rshrjqj hpflGdV2SZVH4yiQM74pIXen04uUewqpRliSDNWnW+SRC5vTegldFB9vMiziKEAdld70 jGYxLgECPcxzsqZ150zCDUOw2EFoNcuqgID+TAPX46+GeeBnraNzmTJt0G4RnvEgRhtS Kf4pV1btEc7wwpB5bbSSXvEGQTOqlNKFUPKx0SyoeSbVUcXMM3ylkcGYhZ9UJlwzHJXR BNy+kQnwfJfLDxPw3u77X6C2U3eU91TpYCn5oFTI7BPXcLGeUhQiMSJGW/KcMFAwi/78 DkDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733670464; x=1734275264; 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=20bETIAPAH9IUNDRRJ4w+seEOsz0uHbvsdHALnvxjtk=; b=UgWZeQufHgBqwYwfKicFZhT1nN6kXT4Rm44wO5Jify0jkAEVsjtLE7yT1uU3wg96hL u4nUJEVac9YxxBcawD2z2741S2hlx/d55Fr2l+B9X9GMl5EKLKMF4PCdoL597ZU/I+aw bKAr9NeyNydZf9/DZMHbG1Tk4dBEZAlnCXVWR+9pLUrPtmMUiqC/02o8YwqbXvh7DNxL Jjs6r9PJEKJLmeB5QsKUneFo2xUcQ3nMAVuVQtwR3VdFUYx1Fega8UPTdMzJY6sUJXgP 5iWS5fTydJb7edzccGqJ8ZZTJsJ8Akl9Zxa5113X594wD1hm5LvqDVqZxEqgwTFz38Dm O1AA== X-Forwarded-Encrypted: i=1; AJvYcCVif3n01XVSVhcdqCYvn3jNf4PudfLf+uD7IFoqvUMeNf32bDrJy8piEXBzenEySmhZ/HT1ImEMWOmk4xmTrIjq@lists.infradead.org X-Gm-Message-State: AOJu0Yy2+PwfdY5zcSe42NT6BFOXT4e0faV2kGGKSieiBo4spPkk1EzK 0vPnHDBzVWf0pPqzNpwebfCt/3qhY16Ks9v032KpEaz8vImQ2NbjRMfgKz/0/vI= X-Gm-Gg: ASbGnct1rNQINd7FHFgURGEoLnlzcLYbULNbxlG7sLZ4QNM+kOQQmgxh+h+yeJSms58 Yg1hrQT+Ru08VFE9NznNMKKqdEFDVYmWuHW0cJbnZL/sz9hYAL+HY38C8We/ugaFOxdZln4o5Ce j4oEel914PvTW4mgfHmqi377nStLk6R97vAJNIW2Q9fwzsjMPjlcSNG/Zhi7IW99nFDIU542RUl NrsNnZOY1hn7/WqRmLmwbmOm5fMBxmbFNBYnyOH3vpurIYMqDiHtqzrCPg8A0zz5Ezl8sZnCxH9 QeVVE+k9mvIBEnQ= X-Google-Smtp-Source: AGHT+IHR0mdD2VEjATAsegpj67+DjOHvUJ0NNqFfY3GS7J9zIfiIPyfQ/Az29m1dRZNe7ffz6IP15Q== X-Received: by 2002:a17:902:da8f:b0:215:8847:4377 with SMTP id d9443c01a7336-216112fb5e7mr156331235ad.15.1733670464396; Sun, 08 Dec 2024 07:07:44 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([223.185.130.223]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-216412293d2sm10274515ad.237.2024.12.08.07.07.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 07:07:43 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH 4/4] irqchip/riscv-imsic: Move to common MSI lib Date: Sun, 8 Dec 2024 20:37:11 +0530 Message-ID: <20241208150711.297624-5-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241208150711.297624-1-apatel@ventanamicro.com> References: <20241208150711.297624-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241208_070745_126624_0CADE0D7 X-CRM114-Status: GOOD ( 17.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Thomas Gleixner Simplify the non-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 33a8261e6017..5bc1f03cbacb 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)