aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/xen')
-rw-r--r--drivers/xen/swiotlb-xen.c47
-rw-r--r--drivers/xen/xenbus/xenbus_dev_frontend.c1
2 files changed, 47 insertions, 1 deletions
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index f8afc6dcc29f..e8cef1ad0fe3 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -681,3 +681,50 @@ xen_swiotlb_set_dma_mask(struct device *dev, u64 dma_mask)
681 return 0; 681 return 0;
682} 682}
683EXPORT_SYMBOL_GPL(xen_swiotlb_set_dma_mask); 683EXPORT_SYMBOL_GPL(xen_swiotlb_set_dma_mask);
684
685/*
686 * Create userspace mapping for the DMA-coherent memory.
687 * This function should be called with the pages from the current domain only,
688 * passing pages mapped from other domains would lead to memory corruption.
689 */
690int
691xen_swiotlb_dma_mmap(struct device *dev, struct vm_area_struct *vma,
692 void *cpu_addr, dma_addr_t dma_addr, size_t size,
693 unsigned long attrs)
694{
695#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
696 if (__generic_dma_ops(dev)->mmap)
697 return __generic_dma_ops(dev)->mmap(dev, vma, cpu_addr,
698 dma_addr, size, attrs);
699#endif
700 return dma_common_mmap(dev, vma, cpu_addr, dma_addr, size);
701}
702EXPORT_SYMBOL_GPL(xen_swiotlb_dma_mmap);
703
704/*
705 * This function should be called with the pages from the current domain only,
706 * passing pages mapped from other domains would lead to memory corruption.
707 */
708int
709xen_swiotlb_get_sgtable(struct device *dev, struct sg_table *sgt,
710 void *cpu_addr, dma_addr_t handle, size_t size,
711 unsigned long attrs)
712{
713#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
714 if (__generic_dma_ops(dev)->get_sgtable) {
715#if 0
716 /*
717 * This check verifies that the page belongs to the current domain and
718 * is not one mapped from another domain.
719 * This check is for debug only, and should not go to production build
720 */
721 unsigned long bfn = PHYS_PFN(dma_to_phys(dev, handle));
722 BUG_ON (!page_is_ram(bfn));
723#endif
724 return __generic_dma_ops(dev)->get_sgtable(dev, sgt, cpu_addr,
725 handle, size, attrs);
726 }
727#endif
728 return dma_common_get_sgtable(dev, sgt, cpu_addr, handle, size);
729}
730EXPORT_SYMBOL_GPL(xen_swiotlb_get_sgtable);
diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c
index 4d343eed08f5..1f4733b80c87 100644
--- a/drivers/xen/xenbus/xenbus_dev_frontend.c
+++ b/drivers/xen/xenbus/xenbus_dev_frontend.c
@@ -55,7 +55,6 @@
55#include <linux/string.h> 55#include <linux/string.h>
56#include <linux/slab.h> 56#include <linux/slab.h>
57#include <linux/miscdevice.h> 57#include <linux/miscdevice.h>
58#include <linux/init.h>
59 58
60#include <xen/xenbus.h> 59#include <xen/xenbus.h>
61#include <xen/xen.h> 60#include <xen/xen.h>