mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* "Consolidate get_dma_ops" breaks Xen on ARM
@ 2017-04-11  0:31 Stefano Stabellini
  2017-04-11  1:14 ` Bart Van Assche
  0 siblings, 1 reply; 8+ messages in thread
From: Stefano Stabellini @ 2017-04-11  0:31 UTC (permalink / raw)
  To: bart.vanassche
  Cc: sstabellini, boris.ostrovsky, jgross, benh, dwmw2, hpa, mingo,
	linux, linux-arch, linux-kernel, x86, julien.grall

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-04-13 18:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-11  0:31 "Consolidate get_dma_ops" breaks Xen on ARM Stefano Stabellini
2017-04-11  1:14 ` Bart Van Assche
2017-04-11 12:43   ` Julien Grall
2017-04-11 13:36     ` Catalin Marinas
2017-04-11 23:39       ` Stefano Stabellini
2017-04-12  8:33         ` Catalin Marinas
2017-04-13 14:04         ` Julien Grall
2017-04-13 18:04           ` Stefano Stabellini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®