From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 905A7606A33E for ; Fri, 4 Dec 2026 13:32:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=xKUt/A8m; dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=FUQCmdL8 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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=9s8lNeE0BeKZHHvwlhzXWahClRLLxZR754tOoDUIi9M=; b=xKUt/A8mpKLuDJ+6EtwyV5+W0H FBh0UZWxwOeItLCstDtFDoBfVUtQc9zUU6EZRnNcFmdhYyETkncVTD2de20C6EZ7ZKNan4nVBLlz2 oTaAjPZ2Xf0N0TVBNKVEaNv0F6vO0Hf2B6yNFShjstremOU5A5Zz92dPrl4syZq4ATt7Q2CJLWHJy RWRffvZ9xWf9iVvSinm47YLS5XeLOFV0MHXfQowu52f7FCVmNdPAQOOr2lKKMxzJIG/sAMl8s0Jb6 XRIBv+p2CFjit0vAvkiSBeK6NFemhrFsBTFdJjiPg2sGfotsd+WhY8kHPipXuuyYv/Ty6pYGVE+V9 tsZ9aA3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZTOi-00000000PbF-1vnY; Fri, 04 Dec 2026 13:32:30 +0000 Received: from out-170.mta1.migadu.com ([2001:41d0:203:375::aa] helo=mta1.migadu.com) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZTOZ-00000000PUc-3GZD for linux-riscv@lists.infradead.org; Fri, 04 Dec 2026 13:32:17 +0000 X-Envelope-To: linux-riscv@lists.infradead.org DKIM-Signature: a=rsa-sha256; bh=Ceusz8JwpKd5jIA05Y3ZMdjW0UxMGrdHfsSRID9OEdk=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796391133; v=1; x=1796995933; b=FUQCmdL8q5fgUdYnPgiV8StyIVV9W8Gvd0NrXPfiRqlp32u3Z+R1MtibghHV7ZBvaYqaln11 Gi05lv85O1NALPnVOCQY7wbGll0AR5ChnA6w2iw2+7guu2CTlhJB8l0ruzkO6kNCFeWuQxeK1rt nYlvs+zrrwdVQEZOtjTAondA= X-Envelope-To: linux-riscv@lists.infradead.org Received: by smtp.migadu.com with ESMTPS id 29b0a22ca122607b; Fri, 04 Dec 2026 13:32:13 +0000 X-Mizu-Trace-ID: 29b0a22ca122607b X-Migadu-Flow: FLOW_OUT From: Andrew Jones To: linux-riscv@lists.infradead.org, iommu@lists.linux.dev Cc: linux-kernel@vger.kernel.org, tomasz.jeznach@linux.dev, jgg@ziepe.ca, jgg@nvidia.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, pjw@kernel.org, palmer@dabbelt.com, anup@brainfault.org, tglx@kernel.org, kevin.tian@intel.com, fangyu.yu@linux.alibaba.com, nutty.liu@hotmail.com Subject: [PATCH v8 5/6] irqchip/riscv-imsic: Support IOMMU MSI address lists Date: Fri, 4 Dec 2026 14:31:05 +0100 Message-ID: <20261204133106.664239-6-andrew.jones@linux.dev> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204133106.664239-1-andrew.jones@linux.dev> References: <20261204133106.664239-1-andrew.jones@linux.dev> X-Archived-By: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261204_053215_967618_A975DCD1 X-CRM114-Status: GOOD ( 15.32 ) X-Spam-Score: -2.8 (--) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Andrew Jones RISC-V IOMMU host interrupt remapping maps every possible host IMSIC target into one contiguous IOVA range. MSI message composition therefore needs each target's position within that range. Prepare the complete IMSIC address list while allocating an IRQ. The list is guaranteed to exist after IMSIC state initialization. The IOMMU backend maps the pages and caches the contiguous base IOVA in the MSI descriptor when translation is needed. Compose messages with msi_msg_set_addr_iova_offset(), using the selected logical CPU directly as the page index within the IOVA range. Use the same path for initial composition and affinity updates. The helper also covers messages that need no translation, so it replaces setting address_hi/lo directly. Signed-off-by: Andrew Jones Signed-off-by: Andrew Jones Tested-by: Fangyu Yu Acked-by: Thomas Gleixner Reviewed-by: Nutty Liu Reviewed-by: Anup Patel Acked-by: Anup Patel --- drivers/irqchip/Kconfig | 1 + drivers/irqchip/irq-riscv-imsic-platform.c | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index ca915fca0ef5..f976c312ad94 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -653,6 +653,7 @@ config RISCV_IMSIC select IRQ_DOMAIN_HIERARCHY select GENERIC_IRQ_MATRIX_ALLOCATOR select GENERIC_MSI_IRQ + select IRQ_MSI_IOMMU select IRQ_MSI_LIB config RISCV_RPMI_SYSMSI diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c index 5f72b2a80887..f424a04a03c5 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -69,7 +70,8 @@ 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) +static void imsic_irq_compose_vector_msg(struct irq_data *d, struct imsic_vector *vec, + struct msi_msg *msg) { phys_addr_t msi_addr; @@ -79,14 +81,14 @@ static void imsic_irq_compose_vector_msg(struct imsic_vector *vec, struct msi_ms if (WARN_ON(!imsic_cpu_page_phys(vec->cpu, 0, &msi_addr))) return; - msg->address_hi = upper_32_bits(msi_addr); - msg->address_lo = lower_32_bits(msi_addr); + msi_msg_set_addr_iova_offset(irq_data_get_msi_desc(d), msg, msi_addr, + (u64)vec->cpu * IMSIC_MMIO_PAGE_SZ); msg->data = vec->local_id; } static void imsic_irq_compose_msg(struct irq_data *d, struct msi_msg *msg) { - imsic_irq_compose_vector_msg(irq_data_get_irq_chip_data(d), msg); + imsic_irq_compose_vector_msg(d, irq_data_get_irq_chip_data(d), msg); } #ifdef CONFIG_SMP @@ -94,7 +96,7 @@ static void imsic_msi_update_msg(struct irq_data *d, struct imsic_vector *vec) { struct msi_msg msg = { }; - imsic_irq_compose_vector_msg(vec, &msg); + imsic_irq_compose_vector_msg(d, vec, &msg); irq_data_get_irq_chip(d)->irq_write_msi_msg(d, &msg); } @@ -225,7 +227,9 @@ static struct irq_chip imsic_irq_base_chip = { static int imsic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, unsigned int nr_irqs, void *args) { + msi_alloc_info_t *info = args; struct imsic_vector *vec; + int ret; /* Multi-MSI is not supported yet. */ if (nr_irqs > 1) @@ -235,6 +239,13 @@ static int imsic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, if (!vec) return -ENOSPC; + ret = iommu_dma_prepare_msi_list(info->desc, imsic->msi_pa_list, + num_possible_cpus(), IMSIC_MMIO_PAGE_SZ); + if (ret) { + imsic_vector_free(vec); + return ret; + } + irq_domain_set_info(domain, virq, virq, &imsic_irq_base_chip, vec, handle_edge_irq, NULL, NULL); irq_set_noprobe(virq); -- 2.56.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv