Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1620809

"Consolidate get_dma_ops" breaks Xen on ARM

From Stefano Stabellini <sstabellini@kernel.org>
Newsgroups linux.kernel
Subject "Consolidate get_dma_ops" breaks Xen on ARM
Date 2017-04-11 02:40 +0200
Message-ID <tuS0F-88h-3@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


Hi all,

Julien Grall (CC'ed) discovered that the following commit breaks Xen on ARM:


  commit 815dd18788fe0d41899f51b91d0560279cf16b0d
  Author: Bart Van Assche <bart.vanassche@sandisk.com>
  Date:   Fri Jan 20 13:04:04 2017 -0800
  
      treewide: Consolidate get_dma_ops() implementations
   

The relevant changes are:

diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index c7432d6..7166569 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -23,12 +23,12 @@ static inline const struct dma_map_ops *__generic_dma_ops(struct device *dev)
 	return &arm_dma_ops;
 }
 
-static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
 {
 	if (xen_initial_domain())
 		return xen_dma_ops;
 	else
-		return __generic_dma_ops(dev);
+		return __generic_dma_ops(NULL);
 }
 
 #define HAVE_ARCH_DMA_SUPPORTED 1
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index e97f23e..ab87108 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -164,6 +164,13 @@ int dma_mmap_from_coherent(struct device *dev, struct vm_area_struct *vma,
 
 #ifdef CONFIG_HAS_DMA
 #include <asm/dma-mapping.h>
+static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
+{
+	if (dev && dev->dma_ops)
+		return dev->dma_ops;
+	return get_arch_dma_ops(dev ? dev->bus : NULL);
+}
+
 static inline void set_dma_ops(struct device *dev,
 			       const struct dma_map_ops *dma_ops)
 {


I think the reason is that, as you can see, if (dev && dev->dma_ops),
dev->dma_ops is returned, while before this changes, xen_dma_ops was
returned on Xen on ARM.

Unfortunately DMA cannot work properly without using the appropriate
xen_dma_ops. See drivers/xen/swiotlb-xen.c and arch/arm/xen/mm.c for
more details. (The problem is easy to spot, but I wasn't CC'ed on the
patch.)

I don't know how to solve this problem without introducing some sort of
if (xen()) in include/linux/dma-mapping.h.

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

"Consolidate get_dma_ops" breaks Xen on ARM Stefano Stabellini <sstabellini@kernel.org> - 2017-04-11 02:40 +0200
  Re: "Consolidate get_dma_ops" breaks Xen on ARM Bart Van Assche <Bart.VanAssche@sandisk.com> - 2017-04-11 03:20 +0200
    Re: "Consolidate get_dma_ops" breaks Xen on ARM Julien Grall <julien.grall@arm.com> - 2017-04-11 14:50 +0200
      Re: "Consolidate get_dma_ops" breaks Xen on ARM Catalin Marinas <catalin.marinas@arm.com> - 2017-04-11 15:40 +0200
        Re: "Consolidate get_dma_ops" breaks Xen on ARM Stefano Stabellini <sstabellini@kernel.org> - 2017-04-12 01:40 +0200
          Re: "Consolidate get_dma_ops" breaks Xen on ARM Catalin Marinas <catalin.marinas@arm.com> - 2017-04-12 10:40 +0200
          Re: "Consolidate get_dma_ops" breaks Xen on ARM Julien Grall <julien.grall@arm.com> - 2017-04-13 16:10 +0200
            Re: "Consolidate get_dma_ops" breaks Xen on ARM Stefano Stabellini <sstabellini@kernel.org> - 2017-04-13 20:10 +0200

csiph-web