Re: [PATCH v4 02/21] iommufd: Add iommufd_sw_map_msi()

Jason Gunthorpe <[email protected]>
Newsgroups dev.linux.lists.iommu,org.infradead.lists.linux-riscv,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Thu, Aug 20, 2026 at 11:41:31PM +0200, Andrew Jones wrote:
> Add a descriptor-free counterpart to iommufd_sw_msi(). The existing
> function is tied to a struct msi_desc and stores the result in the
> descriptor. This variant returns the IOVA directly so callers can
> pre-map MSI targets before any descriptor has been allocated.

I haven't grasped why it is like this?

The cover letter says:

  ARM can map a fixed doorbell PA per ITS and cache its IOVA on the
  descriptor because affinity changes only hardware routing, not the
  composed address. An IMSIC target PA changes with affinity, and MSI
  composition may run in atomic context, so mapping the selected target on
  demand is not an option. This series pre-maps the supervisor IMSIC page
  for every possible CPU into a domain-local PA-to-IOVA table when remapped
  IRQs are first allocated, allowing composition to select the target with
  an O(1) lookup. If iommufd replaces a paging domain while IRQs remain
  allocated, the incoming domain's table is rebuilt before it is attached.

There are a few confusiong things with this statement:
 1) Okay the IMSIC PA changes dynamically but since it can be
    premapped the PAs required is fixed and known. ARM doesn't change
    the PA dynamically?
 2) Why do you say mapping on demand is not possible? ARM's
    iommu_dma_prepare_msi() is not called in an atomic context and
    does do the iommu mapping.

What I rather expected was for riscv to have a PA window that is very
big and not just one page, eg adjust iommu_dma_prepare_msi() so you
can pass in the entire PA space that you need for the affinity
changes. Maybe this is a list of phys_addr_t ?

Then keep with the ARM flow where everything happens at the same
times as today. Instead of just mapping one page you map the entire
list.

I'm not keen on this design where things get pre-mapped into the
domain by the iommu driver, the ARM version is much easier to
understand :\

Jason
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.