All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: "Nícolas F. R. A. Prado" <nfraprado@collabora.com>,
	"Robin Murphy" <robin.murphy@arm.com>,
	"Joerg Roedel" <joro@8bytes.org>, "Will Deacon" <will@kernel.org>,
	"Marek Szyprowski" <m.szyprowski@samsung.com>,
	"Easwar Hariharan" <eahariha@linux.microsoft.com>,
	linux-kernel@vger.kernel.org, iommu@lists.linux.dev,
	"Jason Gunthorpe" <jgg@nvidia.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	regressions@lists.linux.dev, kernelci@lists.linux.dev,
	kernel@collabora.com
Subject: Re: [PATCH v4 2/2] dma: add IOMMU static calls with clear default ops
Date: Wed, 11 Sep 2024 12:05:08 +0300	[thread overview]
Message-ID: <20240911090508.GE4026@unreal> (raw)
In-Reply-To: <20240911080445.GA5950@lst.de>

On Wed, Sep 11, 2024 at 10:04:45AM +0200, Christoph Hellwig wrote:
> On Wed, Sep 11, 2024 at 09:43:05AM +0300, Leon Romanovsky wrote:
> > Thanks for the report, I'm looking into it. However, it is unclear to me
> > why my patch is causing this issue. The change in dma_supported() should
> > produce WARN_ON [1] if new path is taken, otherwise, we return to
> > previous behavior.
> 
> dma-iommu never implemented .dma_supported and thus claims to support
> all dma masks.  To restore that behavior we'd need something like the
> patch below:
> 
> diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c
> index 7550b5dc5e55df..d23a4d5a6b31a1 100644
> --- a/kernel/dma/mapping.c
> +++ b/kernel/dma/mapping.c
> @@ -841,17 +841,19 @@ static int dma_supported(struct device *dev, u64 mask)
>  {
>  	const struct dma_map_ops *ops = get_dma_ops(dev);
>  
> -	if (WARN_ON(ops && use_dma_iommu(dev)))
> -		return false;

The below code still has merit. It is an error to have ops and take
dma-iommu path.

>  	/*
>  	 * ->dma_supported sets the bypass flag, so we must always call
>  	 * into the method here unless the device is truly direct mapped.
>  	 */
> -	if (!ops)
> -		return dma_direct_supported(dev, mask);
> -	if (!ops->dma_supported)
> -		return 1;
> -	return ops->dma_supported(dev, mask);
> +	if (ops) {
> +		if (!ops->dma_supported)
> +			return 1;
> +		return ops->dma_supported(dev, mask);
> +	}
> +
> +	if (use_dma_iommu(dev))
> +		return true;

I would simply put this hunk below if (WARN_ON ...) without any other
changes. Should I send a patch?

Thanks

> +	return dma_direct_supported(dev, mask);
>  }
>  
>  bool dma_pci_p2pdma_supported(struct device *dev)

  reply	other threads:[~2024-09-11  9:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-24 18:04 [PATCH v4 0/2] DMA IOMMU static calls Leon Romanovsky
2024-07-24 18:04 ` [PATCH v4 1/2] dma: call unconditionally to unmap_page and unmap_sg callbacks Leon Romanovsky
2024-08-13 12:23   ` Robin Murphy
2024-07-24 18:04 ` [PATCH v4 2/2] dma: add IOMMU static calls with clear default ops Leon Romanovsky
2024-08-15 16:54   ` Robin Murphy
2024-08-15 17:06     ` Leon Romanovsky
2024-08-16  7:11     ` Christoph Hellwig
2024-08-16  8:13       ` Christoph Hellwig
2024-08-19 13:16       ` Robin Murphy
2024-08-20 12:22         ` Christoph Hellwig
2024-08-27 11:57           ` Robin Murphy
2024-09-04 14:59   ` Nícolas F. R. A. Prado
2024-09-04 15:45     ` Leon Romanovsky
2024-09-04 17:58       ` Nícolas F. R. A. Prado
2024-09-04 18:02         ` Leon Romanovsky
2024-09-10 19:01   ` Nícolas F. R. A. Prado
2024-09-11  6:43     ` Leon Romanovsky
2024-09-11  8:04       ` Christoph Hellwig
2024-09-11  9:05         ` Leon Romanovsky [this message]
2024-08-05 12:20 ` [PATCH v4 0/2] DMA IOMMU static calls Leon Romanovsky
2024-08-13  9:58   ` Greg Kroah-Hartman
2024-08-13 11:50     ` Christoph Hellwig

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=20240911090508.GE4026@unreal \
    --to=leon@kernel.org \
    --cc=eahariha@linux.microsoft.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=kernel@collabora.com \
    --cc=kernelci@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=nfraprado@collabora.com \
    --cc=regressions@lists.linux.dev \
    --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.