RE: [PATCH 19/20] dpaa_eth: add dpaa_dma_to_virt()
From: Madalin-cristian Bucur
Date: Wed Oct 09 2019 - 06:57:02 EST
> -----Original Message-----
> From: Christoph Hellwig <hch@xxxxxxxxxxxxx>
> Sent: Wednesday, October 9, 2019 10:39 AM
> To: Madalin-cristian Bucur <madalin.bucur@xxxxxxx>
> Cc: davem@xxxxxxxxxxxxx; netdev@xxxxxxxxxxxxxxx; Roy Pledge
> <roy.pledge@xxxxxxx>; Laurentiu Tudor <laurentiu.tudor@xxxxxxx>; linux-
> kernel@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH 19/20] dpaa_eth: add dpaa_dma_to_virt()
>
> On Tue, Oct 08, 2019 at 03:10:40PM +0300, Madalin Bucur wrote:
> > Centralize the phys_to_virt() calls.
>
> You don't need to centralize those, you need to fix them. Calling
> phys_to_virt on a dma_addr is completely bogus.
Hi Christoph, thank you for your input, I'm aware of the limited scenarios
that are supported with the current code state (SMMU disabled/bypassed).
The existing customers using the DPAA platforms cannot make use of the SMMU
features until this is fixed. The problem is there is no fast forward path
to fixing this, the performance requirements of the existing use-cases
preclude the use of the recommended approaches suggested to date. I'm moving
all these phys_to_virt calls into one central location specifically because
of this, as the lack of progress on the SMMU fix problem prevented me from
upstreaming other driver changes/fixes. Having this contained allows it to
follow a separate path towards a solution while it enables me to address
issues for the current users of the DPAA with minimal interference. To
illustrate the decoupling of the DPAA driver code changes from the iova
handling fix, the only change to the driver code that would be required
to make it work with the SMMU enables would look similar to this:
static void *dpaa_dma_to_virt(struct device *dev, dma_addr_t addr)
{
+ struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
+
+ if (domain)
+ return phys_to_virt(iommu_iova_to_phys(domain, addr));
+
return phys_to_virt(addr);
}
Other refinements in regards to the actual APIs to be used would only
affect this code area.
Thank you,
Madalin