aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-03-10 15:47:57 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-03-10 15:47:57 -0400
commit45ba8d5d061b13494c2a7a7652d51b9da3d9e77a (patch)
treedddb4253b06a58609407ced51aaaf475f724baae /kernel
parentbb97be23db2a296c5f8b8b4c40feb0435b068c5e (diff)
parentcfdbb4ed31aa777d59b288810f66eb06249ee5b7 (diff)
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio updates from Michael Tsirkin: "Several fixes, most notably fix for virtio on swiotlb systems" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: vhost: silence an unused-variable warning virtio: hint if callbacks surprisingly might sleep virtio-ccw: wire up ->bus_name callback s390/virtio: handle find on invalid queue gracefully virtio-ccw: diag 500 may return a negative cookie virtio_balloon: remove the unnecessary 0-initialization virtio-balloon: improve update_balloon_size_func virtio-blk: Consider virtio_max_dma_size() for maximum segment size virtio: Introduce virtio_max_dma_size() dma: Introduce dma_max_mapping_size() swiotlb: Add is_swiotlb_active() function swiotlb: Introduce swiotlb_max_mapping_size()
Diffstat (limited to 'kernel')
-rw-r--r--kernel/dma/direct.c11
-rw-r--r--kernel/dma/mapping.c14
-rw-r--r--kernel/dma/swiotlb.c14
3 files changed, 39 insertions, 0 deletions
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index 7ff807f2121c..fcdb23e8d2fc 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -393,3 +393,14 @@ int dma_direct_supported(struct device *dev, u64 mask)
393 */ 393 */
394 return mask >= __phys_to_dma(dev, min_mask); 394 return mask >= __phys_to_dma(dev, min_mask);
395} 395}
396
397size_t dma_direct_max_mapping_size(struct device *dev)
398{
399 size_t size = SIZE_MAX;
400
401 /* If SWIOTLB is active, use its maximum mapping size */
402 if (is_swiotlb_active())
403 size = swiotlb_max_mapping_size(dev);
404
405 return size;
406}
diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c
index ef2aba503467..c000906348c9 100644
--- a/kernel/dma/mapping.c
+++ b/kernel/dma/mapping.c
@@ -360,3 +360,17 @@ void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
360 ops->cache_sync(dev, vaddr, size, dir); 360 ops->cache_sync(dev, vaddr, size, dir);
361} 361}
362EXPORT_SYMBOL(dma_cache_sync); 362EXPORT_SYMBOL(dma_cache_sync);
363
364size_t dma_max_mapping_size(struct device *dev)
365{
366 const struct dma_map_ops *ops = get_dma_ops(dev);
367 size_t size = SIZE_MAX;
368
369 if (dma_is_direct(ops))
370 size = dma_direct_max_mapping_size(dev);
371 else if (ops && ops->max_mapping_size)
372 size = ops->max_mapping_size(dev);
373
374 return size;
375}
376EXPORT_SYMBOL_GPL(dma_max_mapping_size);
diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
index a9ad02d4d84e..9f5851064aea 100644
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -666,6 +666,20 @@ bool swiotlb_map(struct device *dev, phys_addr_t *phys, dma_addr_t *dma_addr,
666 return true; 666 return true;
667} 667}
668 668
669size_t swiotlb_max_mapping_size(struct device *dev)
670{
671 return ((size_t)1 << IO_TLB_SHIFT) * IO_TLB_SEGSIZE;
672}
673
674bool is_swiotlb_active(void)
675{
676 /*
677 * When SWIOTLB is initialized, even if io_tlb_start points to physical
678 * address zero, io_tlb_end surely doesn't.
679 */
680 return io_tlb_end != 0;
681}
682
669#ifdef CONFIG_DEBUG_FS 683#ifdef CONFIG_DEBUG_FS
670 684
671static int __init swiotlb_create_debugfs(void) 685static int __init swiotlb_create_debugfs(void)