On Tue, Sep 15, 2015 at 12:10:56PM -0500, Will Davis wrote:
> Add swiotlb stub of the 'map_peer_resource' DMA operation.
> 
> Signed-off-by: Will Davis <[email protected]>
> ---
>  include/linux/swiotlb.h |  8 ++++++++
>  lib/swiotlb.c           | 17 +++++++++++++++++
>  2 files changed, 25 insertions(+)
> 
> diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
> index e7a018e..872463a 100644
> --- a/include/linux/swiotlb.h
> +++ b/include/linux/swiotlb.h
> @@ -87,6 +87,14 @@ swiotlb_unmap_sg_attrs(struct device *hwdev, struct 
> scatterlist *sgl,
>                      int nelems, enum dma_data_direction dir,
>                      struct dma_attrs *attrs);
>  
> +#ifdef CONFIG_HAS_DMA_P2P
> +extern dma_peer_addr_t
> +swiotlb_map_peer_resource(struct device *hwdev, struct device *hwpeer,
> +                       struct resource *res, unsigned long offset,
> +                       size_t size, enum dma_data_direction dir,
> +                       struct dma_attrs *attrs);
> +#endif
> +
>  extern void
>  swiotlb_sync_single_for_cpu(struct device *hwdev, dma_addr_t dev_addr,
>                           size_t size, enum dma_data_direction dir);
> diff --git a/lib/swiotlb.c b/lib/swiotlb.c
> index 76f29ec..61522a7 100644
> --- a/lib/swiotlb.c
> +++ b/lib/swiotlb.c
> @@ -945,6 +945,23 @@ swiotlb_unmap_sg(struct device *hwdev, struct 
> scatterlist *sgl, int nelems,
>  }
>  EXPORT_SYMBOL(swiotlb_unmap_sg);
>  
> +#ifdef CONFIG_HAS_DMA_P2P
> +/*
> + * Maps a single region from a peer device's resource for DMA streaming. This
> + * is currently unimplemented because there's no bounce buffer abstraction 
> for
> + * peer mappings.
> + */
> +dma_peer_addr_t
> +swiotlb_map_peer_resource(struct device *hwdev, struct device *hwpeer,
> +                       struct resource *res, unsigned long offset,
> +                       size_t size, enum dma_data_direction dir,
> +                       struct dma_attrs *attrs)
> +{
> +     return phys_to_dma(hwdev, io_tlb_overflow_buffer);

That seems to be implemented :-)

Did you mean to return DMA_ERROR_CODE instead?
> +}
> +EXPORT_SYMBOL(swiotlb_map_peer_resource);
> +#endif
> +
>  /*
>   * Make physical memory consistent for a set of streaming mode DMA 
> translations
>   * after a transfer.
> -- 
> 2.5.1
> 
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to