Re: [PATCH v4 02/21] iommufd: Add iommufd_sw_map_msi()
From: Andrew Jones
Date: Wed Aug 26 2026 - 04:25:48 EST
On Tue, Aug 25, 2026 at 02:59:01PM -0300, Jason Gunthorpe wrote:
> On Tue, Aug 25, 2026 at 07:38:50PM +0200, Andrew Jones wrote:
>
> > The IRQ domain is per-device because it is part of the device's IRQ
> > hierarchy. It does not own the MSI table. It reaches the device's attached
> > IOMMU domain, which owns the mappings and MSI-table state. If a device is
> > behind parallel IOMMUs, the IOMMU domain implementation must program the
> > same mappings into all of them, just as it does for ordinary DMA.
>
> The iommu driver should not be deeply involved in managing interrupts,
> its is wrong layering. Having the irq side present things it owns,
> like the physical page to iommu_dma_prepare_msi() or an entire
> remapping table, is much more reasonable, IMHO.
>
> Even the x86 drivers with their mixed HW still put the irqdomain in
> charge of the msi related datastructures inside the iommu (including
> irqdomain directly editing device contexts!)
RISC-V uses the same basic model as x86 (an IOMMU-owned interrupt
remapping IRQ domain). x86 makes that domain per-IOMMU because its IRTE
resources belong to the IOMMU instance. RISC-V makes it per-device because
its callbacks operate on the device's attached IOMMU domain and preserve
that device's existing MSI parent. The IRQ callbacks provide the lifecycle
hooks, even though the mappings, MSI table, and device context all remain
IOMMU state.
>
> > Right, the host does not use the MSI table. Host remapping replaces the
> > physical IMSIC address composed by the irqchip with an IOVA that the
> > device's ordinary paging domain maps back to that address.
>
> That's what iommu_dma_prepare_msi() is for, it shouldn't be wrapped in
> an irqdomain.
>
As said, iommu_dma_prepare_msi() handles one fixed MSI target. RISC-V
has one target PA per IMSIC, so the proposed list API prepares them
together and guarantees contiguous IOVAs. The interrupt remapping IRQ
domain's compose callback selects the IOVA corresponding to the IMSIC PA
selected by its parent. That selection belongs in the IRQ hierarchy.
Thanks,
drew