From: Christoph Hellwig <hch@lst.de>
To: Leon Romanovsky <leon@kernel.org>
Cc: Anumula Murali Mohan Reddy <anumula@chelsio.com>,
jgg@nvidia.com, linux-rdma@vger.kernel.org,
Potnuri Bharat Teja <bharat@chelsio.com>,
Christoph Hellwig <hch@lst.de>,
Robin Murphy <robin.murphy@arm.com>
Subject: Re: [PATCH for-next] RDMA/cxgb4: use dma_mmap_coherent() for mapping non-contiguous memory
Date: Sun, 7 Jul 2024 13:31:03 +0200 [thread overview]
Message-ID: <20240707113103.GA4441@lst.de> (raw)
In-Reply-To: <20240707091105.GG6695@unreal>
On Sun, Jul 07, 2024 at 12:11:05PM +0300, Leon Romanovsky wrote:
> On Fri, Jul 05, 2024 at 06:47:53PM +0530, Anumula Murali Mohan Reddy wrote:
> > dma_alloc_coherent() allocates contiguous memory irrespective of
> > iommu mode, but after commit f5ff79fddf0e ("dma-mapping: remove
> > CONFIG_DMA_REMAP") if iommu is enabled in translate mode,
> > dma_alloc_coherent() may allocate non-contiguous memory.
> > Attempt to map this memory results in panic.
> > This patch fixes the issue by using dma_mmap_coherent() to map each page
> > to user space.
>
> It is perfect time to move to use rdma_user_mmap_io(), instead of
> open-code it in the driver.
rdma_user_mmap_io does not work on dma coherent allocations.
> > Fixes: f5ff79fddf0e ("dma-mapping: remove CONFIG_DMA_REMAP")
>
> + authors of the commit mentioned in Fixes.
If that commit triggered a bug for you it was buggy before, you
just didn't hit it. The fixes tag needs to point to the commit
assuming trying to convert the return value from dma_alloc* into
a page/pfn/physical address.
> > +++ b/drivers/infiniband/hw/cxgb4/cq.c
> > @@ -1127,12 +1127,16 @@ int c4iw_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
> >
> > mm->key = uresp.key;
> > mm->addr = virt_to_phys(chp->cq.queue);
... aka this one. And it still is buggy and needs to go away.
> > + if (vaddr && is_vmalloc_addr(vaddr)) {
And this check is broken. The virtual address returned from
dma_alloc_coherent can also be other things than a vmalloc address.
>
>
> > + vm_pgoff = vma->vm_pgoff;
> > + vma->vm_pgoff = 0;
> > + ret = dma_mmap_coherent(&rdev->lldi.pdev->dev, vma,
> > + vaddr, dma_addr, size);
> > + vma->vm_pgoff = vm_pgoff;
... and you thus must use this path unconditionally.
Same for the other hunks.
next prev parent reply other threads:[~2024-07-07 11:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-05 13:17 [PATCH for-next] RDMA/cxgb4: use dma_mmap_coherent() for mapping non-contiguous memory Anumula Murali Mohan Reddy
2024-07-06 0:16 ` Zhu Yanjun
2024-07-07 9:11 ` Leon Romanovsky
2024-07-07 11:31 ` Christoph Hellwig [this message]
2024-07-07 11:39 ` Leon Romanovsky
2024-07-08 10:05 ` 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=20240707113103.GA4441@lst.de \
--to=hch@lst.de \
--cc=anumula@chelsio.com \
--cc=bharat@chelsio.com \
--cc=jgg@nvidia.com \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=robin.murphy@arm.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 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.