Linux IOMMU Development
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Leon Romanovsky <leon@kernel.org>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
	Leon Romanovsky <leonro@nvidia.com>,
	iommu@lists.linux.dev
Subject: Re: [PATCH 1/2] dma-mapping: prepare dma_map_ops to conversion to physical address
Date: Thu, 17 Jul 2025 10:44:35 -0300	[thread overview]
Message-ID: <20250717134435.GA2206214@ziepe.ca> (raw)
In-Reply-To: <1798a3351dcabccaf0749221e9e9b66585a7b2c6.1752734252.git.leon@kernel.org>

On Thu, Jul 17, 2025 at 09:47:09AM +0300, Leon Romanovsky wrote:

> @@ -183,7 +187,11 @@ dma_addr_t dma_map_phys(struct device *dev, phys_addr_t phys, size_t size,
>  		 * All platforms which implement .map_page() don't support
>  		 * non-struct page backed addresses.
>  		 */
> -		addr = ops->map_page(dev, page, offset, size, dir, attrs);
> +		if (ops->map_phys)
> +			addr = ops->map_phys(dev, phys, size, dir, attrs);
> +		if (ops->map_page)
> +			addr = ops->map_page(dev, page, offset, size, dir,
> +					     attrs);

I would expect 'else if'

> @@ -213,8 +221,16 @@ void dma_unmap_phys(struct device *dev, dma_addr_t addr, size_t size,
>  		dma_direct_unmap_phys(dev, addr, size, dir, attrs);
>  	else if (use_dma_iommu(dev))
>  		iommu_dma_unmap_phys(dev, addr, size, dir, attrs);
> -	else
> -		ops->unmap_page(dev, addr, size, dir, attrs);
> +	else {
> +		if (IS_ENABLED(CONFIG_DMA_API_DEBUG))
> +			/* We shouldn't have both functions */
> +			WARN_ON_ONCE(ops->unmap_page && ops->unmap_phys);
> +
> +		if (ops->unmap_phys)
> +			ops->unmap_phys(dev, addr, size, dir, attrs);
> +		if (ops->unmap_page)
> +			ops->unmap_page(dev, addr, size, dir, attrs);

Here too

What is the practical difference between unmap_phys and unmap_page?

Do we expect implementations of map/unmap phys to never touch the
struct page? I see a few cases of dma_ops that are doing this, eg for
cache flushing so they won't be converted?

If not, how are the ops supposed to know if a KVA is available or not
for the phys argument?

Jason

  reply	other threads:[~2025-07-17 13:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-17  6:47 [PATCH 0/2] Preparation to .map_page and .unmap_page removal Leon Romanovsky
2025-07-17  6:47 ` [PATCH 1/2] dma-mapping: prepare dma_map_ops to conversion to physical address Leon Romanovsky
2025-07-17 13:44   ` Jason Gunthorpe [this message]
2025-07-17 14:52     ` Leon Romanovsky
2025-07-17 17:07       ` Jason Gunthorpe
2025-07-20  6:52         ` Leon Romanovsky
2025-07-17  6:47 ` [PATCH 2/2] dma-mapping: convert dummy ops to physical address mapping Leon Romanovsky

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=20250717134435.GA2206214@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=iommu@lists.linux.dev \
    --cc=leon@kernel.org \
    --cc=leonro@nvidia.com \
    --cc=m.szyprowski@samsung.com \
    /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