RE: [PATCH 3/4] ntb_perf: pass correct struct device to dma_alloc_coherent

From: Nath, Arindam
Date: Fri Feb 07 2020 - 03:40:39 EST


[AMD Official Use Only - Internal Distribution Only]

> -----Original Message-----
> From: Logan Gunthorpe <logang@xxxxxxxxxxxx>
> Sent: Thursday, February 6, 2020 00:14
> To: Nath, Arindam <Arindam.Nath@xxxxxxx>; Jon Mason
> <jdmason@xxxxxxxx>; Dave Jiang <dave.jiang@xxxxxxxxx>; Allen Hubbe
> <allenbh@xxxxxxxxx>; Mehta, Sanju <Sanju.Mehta@xxxxxxx>
> Cc: linux-ntb@xxxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH 3/4] ntb_perf: pass correct struct device to
> dma_alloc_coherent
>
>
>
> On 2020-02-05 10:16 a.m., Arindam Nath wrote:
> > From: Sanjay R Mehta <sanju.mehta@xxxxxxx>
> >
> > Currently, ntb->dev is passed to dma_alloc_coherent
> > and dma_free_coherent calls. The returned dma_addr_t
> > is the CPU physical address. This works fine as long
> > as IOMMU is disabled. But when IOMMU is enabled, we
> > need to make sure that IOVA is returned for dma_addr_t.
> > So the correct way to achieve this is by changing the
> > first parameter of dma_alloc_coherent() as ntb->pdev->dev
> > instead.
> >
> > Fixes: 5648e56 ("NTB: ntb_perf: Add full multi-port NTB API support")
> > Signed-off-by: Sanjay R Mehta <sanju.mehta@xxxxxxx>
> > Signed-off-by: Arindam Nath <arindam.nath@xxxxxxx>
>
> Ugh, this has been fixed repeatedly and independently by a number of
> people. I sent a fix[1] in more than a year ago and Sanjay repeated the
> effort a couple months ago[2].
>
> I have the same feed back for you that I had for him: once we fix the
> bug we should also go in and remove the now unnecessary
> dma_coerce_mask_and_coherent() calls in the drivers at the same time
> seeing it no longer makes any sense. My patch did this already.

Thanks Logan. I will include your patches in my next version of the set,
and mention you in the "From" tag.

Arindam

>
> Thanks,
>
> Logan
>
> [1]
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.
> kernel.org%2Flkml%2F20190109192233.5752-3-
> logang%40deltatee.com%2F&amp;data=02%7C01%7Carindam.nath%40amd.
> com%7Cabc7298c86c54b82db1a08d7aa6b66aa%7C3dd8961fe4884e608e11a82
> d994e183d%7C0%7C0%7C637165251004193969&amp;sdata=52DOTHpKjseZjv
> E6jmWWVVLQLeRiaykbVTQipGQbLT0%3D&amp;reserved=0
> [2]
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.
> kernel.org%2Flkml%2F1575983255-70377-1-git-send-email-
> Sanju.Mehta%40amd.com%2F&amp;data=02%7C01%7Carindam.nath%40am
> d.com%7Cabc7298c86c54b82db1a08d7aa6b66aa%7C3dd8961fe4884e608e11a
> 82d994e183d%7C0%7C0%7C637165251004193969&amp;sdata=RFR%2BLFp5a
> ON1MA4Erx4soqL9pLHc%2BLWVNuLY0%2B0zcbo%3D&amp;reserved=0