From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.122 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796391119; b=Pz1YuOgAlMg1KwAVeYL5zWWbHbIT9tzDFWoNlksl2X93tTCsnO/HFxsfniNh7ZYZZaAF MTfk3sUF08Zqfokfzr3kzpGMia6jupgkeDnNSK8mn0kPZ8IswlM+FUUUqE12hoSrKZqEs eM4vUlDdYryKs85gtAmh6hXyuw8lxjdTEgmhiWhLcEGF/PnQedGrGyp7aM4AWRGVrrMMv mfXCBDxcPkAQv50zdGsYJNLqJ7ujbP3I8muK4nQfALcwy7FVItcOxLqocXif9UN6zZZwU ZnXNefwB3XaXAW0+wGRQnSbqAF9pjbnckUJPgp7IjYFY/gnc0l5E7BmXtUmHPpoCqhw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796391119; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=ES2cIPTL171kTu46km3P13yBT+sSLbgjuKLtxLNBKiU=; b=0q5OEO0dnKaaNQZ372B3XoE+gskGXUHXCaLDN3tsehwBlWAP1VC0+6QW4lhxcM9HvOuH Xa7njtdXLBOYv2w+gYcPDYsI5wIK7fGPzVTWcXW7X4I8w7zc4etR/mZw2ASrwq6dCZJ/A 4osbDSeYH9sOx65zdbzg2Q+acFQOpCDX+nZwfEQgf47wJoDy9U6LDm83eEcT5TVN8FxbB 8NU/iC6F33XswUa0FSoNCJF4sDZZyjEqjKImN6DE6sRthLvehsiih/l8HuZBr5HCzk6d/ LX8BaVI3nGBGgLVuwOlw/AEPOZv+jyCo2gpHMipoB1zd2AWTFIBPWgsFc9fBmLTyKeA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=unEPJici; arc=none smtp.remote-ip=95.215.58.122 Received: from mta1.migadu.com (out-122.mta1.migadu.com [95.215.58.122]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1085E606A32C for ; Fri, 4 Dec 2026 13:31:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1085E606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=unEPJici X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=EPanV4hWfWgOJmkk+xlpF4FrRUxE23uglSPr+PSs/SU=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796391116; v=1; x=1796995916; b=unEPJiciRRftK6BYYIbQz7EmttcpgbI0F/GDg8Rkgw67d9D6fbnoEgRUX5gdpx1J6PaYt+St CtRCxUqtxzYPDtp8ZbKEApg6ITI0lTcZIqRqz21WEe2JAGoN7SPqVlL8sJ9jYCRWgtGUm/gW7jZ pVwWhiZhcOhqfKVVoo9nVHpU= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 311f00e79651c620; Fri, 04 Dec 2026 13:31:55 +0000 X-Mizu-Trace-ID: 311f00e79651c620 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 0/6] iommu/riscv: Enable MSI remapping and IOMMU_DMA Date: Fri, 4 Dec 2026 14:31:00 +0100 Message-ID: <20261204133106.664239-1-andrew.jones@linux.dev> X-Mailer: git-send-email 2.56.1 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This series adds MSI remapping for IMSIC so a device's MSI target gets translated the same way its DMA does, allowing RISC-V to enable IOMMU_DMA and paging domains by default. The IMSIC MSI target address changes with interrupt affinity, so every possible target must be mapped before an affinity change can select it in atomic context. The IMSIC driver prepares an ordered list of targets with iommu_dma_prepare_msi_list() when allocating an IRQ. DMA-IOMMU maps the list into one contiguous IOVA range and caches the base in the domain. The MSI descriptor carries the base IOVA and mapping granule, allowing IMSIC to compose the target address without allocating memory or looking up IOMMU state during affinity changes. Ordered-list mappings have their own cache, separate from the existing single-page MSI cache. IOVA allocation, mapping and rollback are shared between the two paths. VFIO and iommufd support from v6[1] is deferred. This series does not enable VFIO_IOMMU_TYPE1 or introduce an IOMMU_RESV_SW_MSI reservation. I'll look into Nicolin's MSI-window configuration patches[2] in a follow-on series and see if I can avoid introducing IOMMU_RESV_SW_MSI entirely. Without that reservation, the legacy Type1 backend cannot provide the MSI mappings it needs, so I'll try to support existing Type1 userspace through iommufd's compatibility interface. That path will need automatic MSI IOVA allocation, since existing Type1 userspace won't issue Nicolin's new ioctls. LLM-based coding assistants were used during development for code exploration, patch review, test execution, and drafting and editing commit messages and this cover letter. I reviewed and finalized all resulting code and text. Per-patch Assisted-by tags are omitted in light of ongoing discussions about simplifying coding-assistant attribution. Thanks, drew [1] https://lore.kernel.org/all/20260925151659.419512-1-andrew.jones@oss.qualcomm.com/ [2] https://lore.kernel.org/linux-iommu/cover.1760487869.git.nicolinc@nvidia.com/ v8: - Rebased on linux-iommu/next at 052bac986393 - Added a patch (3/6) to introduce msi_msg_set_addr_iova_offset() in order to avoid duplicating msi_msg_set_addr() [Jason] - Addressed Jason's other v7 comments (kzalloc_objs(), 32-bit explanation) - Added Jason's r-b's Andrew Jones (5): iommu/dma: Prepare MSI physical address lists iommu/dma: Introduce iommu_dma_prepare_msi_list() genirq/msi: Add msi_msg_set_addr_iova_offset() irqchip/riscv-imsic: Add MSI address list irqchip/riscv-imsic: Support IOMMU MSI address lists Tomasz Jeznach (1): iommu/dma: Enable IOMMU_DMA for 64-bit RISC-V drivers/iommu/Kconfig | 2 +- drivers/iommu/dma-iommu.c | 77 ++++++++++++++++++++-- drivers/iommu/dma-iommu.h | 10 +++ drivers/iommu/iommu.c | 43 ++++++++++++ drivers/irqchip/Kconfig | 1 + drivers/irqchip/irq-riscv-imsic-platform.c | 21 ++++-- drivers/irqchip/irq-riscv-imsic-state.c | 32 +++++++++ drivers/irqchip/irq-riscv-imsic-state.h | 3 + include/linux/iommu.h | 9 +++ include/linux/msi.h | 25 ++++--- 10 files changed, 202 insertions(+), 21 deletions(-) -- 2.56.1