[PATCH] arm64: dma-mapping: fix dma_to_phys API for IOMMU attached devices

Arnd Bergmann arnd at arndb.de
Thu Mar 17 10:01:23 PDT 2016


On Thursday 17 March 2016 12:36:28 Sinan Kaya wrote:
> 
> The first solution that comes to my mind is to implement a weak function in
> swiotlb.c with these contents
> 
> dma_addr_t __weak swio_phys_to_dma(struct device *dev, phys_addr_t paddr)
> {
>         return paddr;
> }
> 
>  
> phys_addr_t __weak  swio_dma_to_phys(struct device *dev, dma_addr_t daddr)
> {
>         return daddr;
> }
> 
> then clean up all the duplicates in dma-mapping.h for all ARCHs that have
> identical code. 
> 
> For others move the implementation to some source file.
> 
> 

Sounds ok to me, but I'd prefer using a macro instead of a __weak symbol:

#ifndef swiotlb_phys_to_dma
static inline dma_addr_t swiotlb_phys_to_dma(struct device *dev, phys_addr_t paddr)
{
         return paddr;
}
#endif

and then let the architectures that override it provide a self-referencing
macro:

#define swiotlb_phys_to_dma swiotlb_phys_to_dma

Also note swiotlb instead of swio, to match the existing naming.

	Arnd



More information about the linux-arm-kernel mailing list