Re: [PATCH v2 00/14] iommu/riscv: Enable MSI remapping and IOMMU_DMA
From: Andrew Jones
Date: Thu Jul 30 2026 - 09:22:10 EST
On Fri, Jul 24, 2026 at 05:12:04PM +0200, Andrew Jones wrote:
> 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.
>
> v1[1] used get_resv_regions() with IOMMU_RESV_DIRECT_RELAXABLE to identity
> map IMSIC pages, but that was rejected as only a workaround, and the
> proposal for v2 was to follow ARM's approach. ARM calls
> iommu_dma_prepare_msi() once at IRQ-alloc time, caches the IOVA on the
> msi_desc, and lets compose replay it via msi_msg_set_addr(). This series
> follows that structure by introducing an IRQ domain and a new
> iommu_dma_map_msi(). Like iommu_dma_prepare_msi(), it dispatches on the
> same domain cookie types. Unlike iommu_dma_prepare_msi(), it returns the
> IOVA to the caller instead of caching it on a descriptor. That allows the
> caller to collect all IOVAs needed (since IMSIC needs one IOVA per host
> IMSIC page). Like ARM, msi_msg_set_addr() is used at compose time to
> direct MSIs to the appropriate IOVAs.
>
> The divergence from ARM is required due to where the target address
> actually lives. ARM's doorbell PA is fixed per ITS instance (affinity
> changes only retarget hardware routing, never the composed address) so
> one IOVA cached at alloc time stays valid for the descriptor's lifetime.
> IMSIC doesn't have a fixed target, the MSI address itself changes on
> irq_set_affinity(), and that runs in atomic context, so mapping a fresh
> IOVA isn't an option. This series pre-maps every IMSIC page into a
> domain-wide PA-to-IOVA table at first IRQ-alloc time, and compose does an
> O(1) lookup to pick the right one.
>
> LLM-based coding assistants were used during development for code
> exploration ("super grep" as one of my colleagues calls it), patch review,
> test execution, and commit-message iteration, but all resulting code and
> commit messages were selected, reviewed, and finalized by me. Per-patch
> Assisted-by tags are omitted in light of the ongoing discussion about
> simplifying coding-assistant attribution[2].
>
I'm addressing sashiko's comments[1], making a few other changes, and
adding a couple patches that I think belong in this series more than
in the next series I'll be submitting (guest interrupt file support, a.k.a
irqbypass) which is getting built on this series. So a v3 is coming soon,
likely tomorrow.
[1] https://sashiko.dev/#/patchset/20260724151218.965929-1-andrew.jones@xxxxxxxxxxxxxxxx
Thanks,
drew