aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>2019-08-28 08:35:40 -0400
committerChristoph Hellwig <hch@lst.de>2019-09-03 02:33:01 -0400
commit6ba99411b858bd70bae966633561e698cd6de38c (patch)
tree5679bf75e3c4fc1a8bba626da01c2d0ce42f556f
parent38c38cb73223218f6eedf485280917af1f8a0af2 (diff)
dma-mapping: introduce dma_get_merge_boundary()
This patch adds a new DMA API "dma_get_merge_boundary". This function returns the DMA merge boundary if the DMA layer can merge the segments. This patch also adds the implementation for a new dma_map_ops pointer. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Reviewed-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--Documentation/DMA-API.txt8
-rw-r--r--include/linux/dma-mapping.h6
-rw-r--r--kernel/dma/mapping.c11
3 files changed, 25 insertions, 0 deletions
diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
index e47c63bd4887..9c4dd3d779ed 100644
--- a/Documentation/DMA-API.txt
+++ b/Documentation/DMA-API.txt
@@ -204,6 +204,14 @@ Returns the maximum size of a mapping for the device. The size parameter
204of the mapping functions like dma_map_single(), dma_map_page() and 204of the mapping functions like dma_map_single(), dma_map_page() and
205others should not be larger than the returned value. 205others should not be larger than the returned value.
206 206
207::
208
209 unsigned long
210 dma_get_merge_boundary(struct device *dev);
211
212Returns the DMA merge boundary. If the device cannot merge any the DMA address
213segments, the function returns 0.
214
207Part Id - Streaming DMA mappings 215Part Id - Streaming DMA mappings
208-------------------------------- 216--------------------------------
209 217
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 48ebe8295987..de41a4f0b9f6 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -131,6 +131,7 @@ struct dma_map_ops {
131 int (*dma_supported)(struct device *dev, u64 mask); 131 int (*dma_supported)(struct device *dev, u64 mask);
132 u64 (*get_required_mask)(struct device *dev); 132 u64 (*get_required_mask)(struct device *dev);
133 size_t (*max_mapping_size)(struct device *dev); 133 size_t (*max_mapping_size)(struct device *dev);
134 unsigned long (*get_merge_boundary)(struct device *dev);
134}; 135};
135 136
136#define DMA_MAPPING_ERROR (~(dma_addr_t)0) 137#define DMA_MAPPING_ERROR (~(dma_addr_t)0)
@@ -467,6 +468,7 @@ int dma_set_mask(struct device *dev, u64 mask);
467int dma_set_coherent_mask(struct device *dev, u64 mask); 468int dma_set_coherent_mask(struct device *dev, u64 mask);
468u64 dma_get_required_mask(struct device *dev); 469u64 dma_get_required_mask(struct device *dev);
469size_t dma_max_mapping_size(struct device *dev); 470size_t dma_max_mapping_size(struct device *dev);
471unsigned long dma_get_merge_boundary(struct device *dev);
470#else /* CONFIG_HAS_DMA */ 472#else /* CONFIG_HAS_DMA */
471static inline dma_addr_t dma_map_page_attrs(struct device *dev, 473static inline dma_addr_t dma_map_page_attrs(struct device *dev,
472 struct page *page, size_t offset, size_t size, 474 struct page *page, size_t offset, size_t size,
@@ -572,6 +574,10 @@ static inline size_t dma_max_mapping_size(struct device *dev)
572{ 574{
573 return 0; 575 return 0;
574} 576}
577static inline unsigned long dma_get_merge_boundary(struct device *dev)
578{
579 return 0;
580}
575#endif /* CONFIG_HAS_DMA */ 581#endif /* CONFIG_HAS_DMA */
576 582
577static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr, 583static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c
index 1b96616c9f20..72c825c1788e 100644
--- a/kernel/dma/mapping.c
+++ b/kernel/dma/mapping.c
@@ -407,3 +407,14 @@ size_t dma_max_mapping_size(struct device *dev)
407 return size; 407 return size;
408} 408}
409EXPORT_SYMBOL_GPL(dma_max_mapping_size); 409EXPORT_SYMBOL_GPL(dma_max_mapping_size);
410
411unsigned long dma_get_merge_boundary(struct device *dev)
412{
413 const struct dma_map_ops *ops = get_dma_ops(dev);
414
415 if (!ops || !ops->get_merge_boundary)
416 return 0; /* can't merge */
417
418 return ops->get_merge_boundary(dev);
419}
420EXPORT_SYMBOL_GPL(dma_get_merge_boundary);