diff mbox

[11/22] swiotlb: Add map_peer_resource stub

Message ID 1442337067-22964-12-git-send-email-wdavis@nvidia.com
State Changes Requested
Headers show

Commit Message

wdavis@nvidia.com Sept. 15, 2015, 5:10 p.m. UTC
Add swiotlb stub of the 'map_peer_resource' DMA operation.

Signed-off-by: Will Davis <wdavis@nvidia.com>
---
 include/linux/swiotlb.h |  8 ++++++++
 lib/swiotlb.c           | 17 +++++++++++++++++
 2 files changed, 25 insertions(+)

Comments

Konrad Rzeszutek Wilk Sept. 15, 2015, 7:40 p.m. UTC | #1
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 <wdavis@nvidia.com>
> ---
>  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
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
wdavis@nvidia.com Sept. 15, 2015, 7:49 p.m. UTC | #2
> -----Original Message-----
> From: Konrad Rzeszutek Wilk [mailto:konrad.wilk@oracle.com]
> Sent: Tuesday, September 15, 2015 2:40 PM
> To: William Davis
> Cc: Bjorn Helgaas; Alex Williamson; Joerg Roedel; iommu@lists.linux-foundation.org; linux-
> pci@vger.kernel.org; Mark Hounschell; David S. Miller; Jonathan Corbet; Terence Ripperda; John
> Hubbard; Jerome Glisse
> Subject: Re: [PATCH 11/22] swiotlb: Add map_peer_resource stub
> 
> 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 <wdavis@nvidia.com>
> > ---
> >  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?

I didn't see DMA_ERROR_CODE used in lib/swiotlb.c, and
swiotlb_dma_mapping_error is implemented as:

	return (dma_addr == phys_to_dma(hwdev, io_tlb_overflow_buffer));

So I figured that phys_to_dma(hwdev, io_tlb_overflow_buffer) was intended
to be used as DMA_ERROR_CODE instead.

Thanks,
Will

> > +}
> > +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
> >

--
nvpublic
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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);
+}
+EXPORT_SYMBOL(swiotlb_map_peer_resource);
+#endif
+
 /*
  * Make physical memory consistent for a set of streaming mode DMA translations
  * after a transfer.