The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Andrew Jones <andrew.jones@oss.qualcomm.com>
Cc: linux-riscv@lists.infradead.org, iommu@lists.linux.dev,
	linux-kernel@vger.kernel.org, tjeznach@rivosinc.com,
	joro@8bytes.org, will@kernel.org, pjw@kernel.org,
	palmer@dabbelt.com, anup@brainfault.org
Subject: Re: [PATCH 1/2] iommu/riscv: Map IMSIC addresses for paging domains
Date: Tue, 12 May 2026 10:38:54 -0300	[thread overview]
Message-ID: <20260512133854.GA9129@nvidia.com> (raw)
In-Reply-To: <20260508212339.381933-2-andrew.jones@oss.qualcomm.com>

On Fri, May 08, 2026 at 04:23:38PM -0500, Andrew Jones wrote:
> +static void riscv_iommu_get_resv_regions(struct device *dev, struct list_head *head)
> +{
> +	const struct imsic_global_config *imsic_global;
> +	unsigned int cpu;
> +
> +	if (!imsic_enabled())
> +		return;
> +
> +	imsic_global = imsic_get_global_config();
> +
> +	for_each_possible_cpu(cpu) {
> +		const struct imsic_local_config *local;
> +		struct iommu_resv_region *reg;
> +
> +		local = per_cpu_ptr(imsic_global->local, cpu);
> +		if (!local->msi_va)
> +			continue;
> +
> +		/*
> +		 * The device always writes to the host physical IMSIC address, so install
> +		 * identity mappings directly. Use IOMMU_RESV_DIRECT_RELAXABLE instead of
> +		 * IOMMU_RESV_DIRECT since these 1:1 mappings are not required for assigned
> +		 * devices.

Oh? Why not?

> +		reg = iommu_alloc_resv_region(local->msi_pa, IMSIC_MMIO_PAGE_SZ,
> +					      IOMMU_WRITE | IOMMU_NOEXEC | IOMMU_MMIO,
> +					      IOMMU_RESV_DIRECT_RELAXABLE, GFP_KERNEL);
> +		if (reg)
> +			list_add_tail(&reg->list, head);

This seems like quite a hack, the ARM was seems much better, the
interrupt controller should be using the iommu_dma_prepare_msi() path
to obtain an appropriately translated MSI address for the aperture.

Then things will work correctly with VFIO too.

Jason

  parent reply	other threads:[~2026-05-12 13:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08 21:23 [PATCH 0/2] iommu/riscv: Enable IOMMU_DMA Andrew Jones
2026-05-08 21:23 ` [PATCH 1/2] iommu/riscv: Map IMSIC addresses for paging domains Andrew Jones
2026-05-09  2:21   ` fangyu.yu
2026-05-09 19:47     ` Andrew Jones
2026-05-10 14:40       ` fangyu.yu
2026-05-12 13:38   ` Jason Gunthorpe [this message]
2026-05-12 16:22     ` Andrew Jones
2026-05-12 16:33       ` Jason Gunthorpe
2026-05-12 17:21   ` Tomasz Jeznach
2026-05-08 21:23 ` [PATCH 2/2] iommu/dma: enable IOMMU_DMA for RISC-V Andrew Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260512133854.GA9129@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=andrew.jones@oss.qualcomm.com \
    --cc=anup@brainfault.org \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=tjeznach@rivosinc.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox