All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Damato <joe@dama.to>
To: Robin Murphy <robin.murphy@arm.com>
Cc: "Joerg Roedel (AMD)" <joro@8bytes.org>,
	Will Deacon <will@kernel.org>,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] iommu/dma: Skip iova_to_phys() on unmap when unneeded
Date: Wed, 2 Dec 2026 09:50:59 -0800	[thread overview]
Message-ID: <axBag6aO+xKKnWBG@devvm20253.cco0.facebook.com> (raw)
In-Reply-To: <38e90198-68c0-4cb3-959b-4f4c7759a18d@arm.com>

On Wed, Dec 02, 2026 at 04:36:27PM +0000, Robin Murphy wrote:
> On 02/12/2026 3:33 pm, Joe Damato wrote:
> > iommu_dma_unmap_phys() looks up the physical address of every mapping
> > with iommu_iova_to_phys() before unmapping it.
> > 
> > This is unneeded for a coherent device that does not use a swiotlb.
> > Skipping this saves a page table walk.
> > 
> > iommu_dma_sync_single_for_cpu() already skips the walk for these
> > devices, so do the same in iommu_dma_unmap_phys().
> > 
> > For these devices the WARN_ON(!phys) is no longer reached, so unmapping
> > an IOVA that is not mapped no longer warns there. CONFIG_DMA_API_DEBUG
> > still catches this class of driver bug.
> 
> Thanks Joe!
> 
> Acked-by: Robin Murphy <robin.murphy@arm.com>
> 
> Although now I've made the mistake of remembering we have the higher-level
> dma_dev_need_sync() thing as well, and starting to wonder how much that now
> might effectively cover these conditions both here and for
> iommu_dma_sync_single*()...

I see what you mean. I did not know about that before, my bad.

Your call: I would be happy to send a followup cleaning up all of those sites
to use dma_dev_need_sync once the patch above is applied

or

If you prefer, I can send a v3 as a single patch that cleans up the existing
sites and inserts the call in unmap.

  reply	other threads:[~2026-12-02 17:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 15:33 [PATCH v2] iommu/dma: Skip iova_to_phys() on unmap when unneeded Joe Damato
2026-12-02 16:36 ` Robin Murphy
2026-12-02 17:50   ` Joe Damato [this message]
2026-12-03 16:38     ` Robin Murphy
2026-12-04  7:35 ` Joerg Roedel (AMD)

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=axBag6aO+xKKnWBG@devvm20253.cco0.facebook.com \
    --to=joe@dama.to \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.