Skip to contentSkip to conversation

drm/ttm, drm/vmwgfx: Use a configuration option for the TTM dma page pool

PATCH Superseded Thomas Hellstrom 2 participants 4 messages May 16, 2019

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/ttm, drm/vmwgfx: Use a configuration option for the TTM dma page pool

Drivers like vmwgfx may want to test whether the dma page pool is present or not. Since it's activated by default by TTM if compiled-in, define a hidden configuration option that the driver can test for.

---
 drivers/gpu/drm/Kconfig                  | 5 +++++
 drivers/gpu/drm/ttm/Makefile             | 4 ++--
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 3 ---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      | 3 +--
 include/drm/ttm/ttm_page_alloc.h         | 2 +-
 5 files changed, 9 insertions(+), 8 deletions(-)
drivers/gpu/drm/Kconfig +5 -0
index 2267e84d5cb4..f733a9273b3f 100644
@@ -160,6 +160,11 @@ config DRM_TTM
 	  GPU memory types. Will be enabled automatically if a device driver
 	  uses it.
 
+config DRM_TTM_DMA_PAGE_POOL
+        bool
+	depends on DRM_TTM && (SWIOTLB || INTEL_IOMMU)
+	default y
+
 config DRM_GEM_CMA_HELPER
 	bool
 	depends on DRM
drivers/gpu/drm/ttm/Makefile +2 -2
index 01fc670ce7a2..caea2a099496 100644
@@ -4,8 +4,8 @@
 
 ttm-y := ttm_memory.o ttm_tt.o ttm_bo.o \
 	ttm_bo_util.o ttm_bo_vm.o ttm_module.o \
-	ttm_execbuf_util.o ttm_page_alloc.o ttm_bo_manager.o \
-	ttm_page_alloc_dma.o
+	ttm_execbuf_util.o ttm_page_alloc.o ttm_bo_manager.o
 ttm-$(CONFIG_AGP) += ttm_agp_backend.o
+ttm-$(CONFIG_DRM_TTM_DMA_PAGE_POOL) += ttm_page_alloc_dma.o
 
 obj-$(CONFIG_DRM_TTM) += ttm.o
drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +0 -3
index d594f7520b7b..98d100fd1599 100644
@@ -33,7 +33,6 @@
  *   when freed).
  */
 
-#if defined(CONFIG_SWIOTLB) || defined(CONFIG_INTEL_IOMMU)
 #define pr_fmt(fmt) "[TTM] " fmt
 
 #include <linux/dma-mapping.h>
@@ -1234,5 +1233,3 @@ int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data)
 	return 0;
 }
 EXPORT_SYMBOL_GPL(ttm_dma_page_alloc_debugfs);
-
-#endif
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1 -2
index d59c474be38e..bc259d4df1cb 100644
@@ -572,8 +572,7 @@ static int vmw_dma_select_mode(struct vmw_private *dev_priv)
 	else
 		dev_priv->map_mode = vmw_dma_map_populate;
 
-	/* No TTM coherent page pool? FIXME: Ask TTM instead! */
-        if (!(IS_ENABLED(CONFIG_SWIOTLB) || IS_ENABLED(CONFIG_INTEL_IOMMU)) &&
+        if (!IS_ENABLED(CONFIG_DRM_TTM_DMA_PAGE_POOL) &&
 	    (dev_priv->map_mode == vmw_dma_alloc_coherent))
 		return -EINVAL;
 
include/drm/ttm/ttm_page_alloc.h +1 -1
index 4d9b019d253c..a6b6ef5f9bf4 100644
@@ -74,7 +74,7 @@ void ttm_unmap_and_unpopulate_pages(struct device *dev, struct ttm_dma_tt *tt);
  */
 int ttm_page_alloc_debugfs(struct seq_file *m, void *data);
 
-#if defined(CONFIG_SWIOTLB) || defined(CONFIG_INTEL_IOMMU)
+#if defined(CONFIG_DRM_TTM_DMA_PAGE_POOL)
 /**
  * Initialize pool allocator.
  */
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw

Am 16.05.19 um 11:23 schrieb Thomas Hellstrom:

Quoted 6 lines

Drivers like vmwgfx may want to test whether the dma page pool is present or not. Since it's activated by default by TTM if compiled-in, define a hidden configuration option that the driver can test for.

There are at least also occasions of this in radeon and amdgpu, but those can be cleaned up later on.

Which tree should we use for merging?

Thanks,
Christian.

Quoted 76 lines
---
  drivers/gpu/drm/Kconfig                  | 5 +++++
  drivers/gpu/drm/ttm/Makefile             | 4 ++--
  drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 3 ---
  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      | 3 +--
  include/drm/ttm/ttm_page_alloc.h         | 2 +-
  5 files changed, 9 insertions(+), 8 deletions(-)
drivers/gpu/drm/Kconfig +5 -0
index 2267e84d5cb4..f733a9273b3f 100644
@@ -160,6 +160,11 @@ config DRM_TTM
  	  GPU memory types. Will be enabled automatically if a device driver
  	  uses it.
 
+config DRM_TTM_DMA_PAGE_POOL
+        bool
+	depends on DRM_TTM && (SWIOTLB || INTEL_IOMMU)
+	default y
+
  config DRM_GEM_CMA_HELPER
  	bool
  	depends on DRM
drivers/gpu/drm/ttm/Makefile +2 -2
index 01fc670ce7a2..caea2a099496 100644
@@ -4,8 +4,8 @@
 
  ttm-y := ttm_memory.o ttm_tt.o ttm_bo.o \
  	ttm_bo_util.o ttm_bo_vm.o ttm_module.o \
-	ttm_execbuf_util.o ttm_page_alloc.o ttm_bo_manager.o \
-	ttm_page_alloc_dma.o
+	ttm_execbuf_util.o ttm_page_alloc.o ttm_bo_manager.o
  ttm-$(CONFIG_AGP) += ttm_agp_backend.o
+ttm-$(CONFIG_DRM_TTM_DMA_PAGE_POOL) += ttm_page_alloc_dma.o
 
  obj-$(CONFIG_DRM_TTM) += ttm.o
drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +0 -3
index d594f7520b7b..98d100fd1599 100644
@@ -33,7 +33,6 @@
   *   when freed).
   */
 
-#if defined(CONFIG_SWIOTLB) || defined(CONFIG_INTEL_IOMMU)
  #define pr_fmt(fmt) "[TTM] " fmt
 
  #include <linux/dma-mapping.h>
@@ -1234,5 +1233,3 @@ int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data)
  	return 0;
  }
  EXPORT_SYMBOL_GPL(ttm_dma_page_alloc_debugfs);
-
-#endif
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1 -2
index d59c474be38e..bc259d4df1cb 100644
@@ -572,8 +572,7 @@ static int vmw_dma_select_mode(struct vmw_private *dev_priv)
  	else
  		dev_priv->map_mode = vmw_dma_map_populate;
 
-	/* No TTM coherent page pool? FIXME: Ask TTM instead! */
-        if (!(IS_ENABLED(CONFIG_SWIOTLB) || IS_ENABLED(CONFIG_INTEL_IOMMU)) &&
+        if (!IS_ENABLED(CONFIG_DRM_TTM_DMA_PAGE_POOL) &&
  	    (dev_priv->map_mode == vmw_dma_alloc_coherent))
  		return -EINVAL;
 
include/drm/ttm/ttm_page_alloc.h +0 -0
index 4d9b019d253c..a6b6ef5f9bf4 100644

include/drm/ttm/ttm_page_alloc.h void ttm_unmap_and_unpopulate_pages(struct device *dev, struct ttm_dma_tt *tt); · line 80

Quoted 8 lines
include/drm/ttm/ttm_page_alloc.h +1 -1
@@ -74,7 +74,7 @@ void ttm_unmap_and_unpopulate_pages(struct device *dev, struct ttm_dma_tt *tt);
   */
  int ttm_page_alloc_debugfs(struct seq_file *m, void *data);
 
-#if defined(CONFIG_SWIOTLB) || defined(CONFIG_INTEL_IOMMU)
+#if defined(CONFIG_DRM_TTM_DMA_PAGE_POOL)
  /**
   * Initialize pool allocator.
   */

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 13 lines · Christian König

Am 16.05.19 um 11:23 schrieb Thomas Hellstrom:

Quoted 8 lines

Drivers like vmwgfx may want to test whether the dma page pool is present
or not. Since it's activated by default by TTM if compiled-in, define a
hidden configuration option that the driver can test for.

There are at least also occasions of this in radeon and amdgpu, but those can be cleaned up later on.

Quoted 6 lines

Which tree should we use for merging?

Thanks,
Christian.

We can take it through an AMD tree if it's OK with you. Then it would be easier to add similar changes to the AMD drivers.

I'll send out v2 with some whitespace cleanup, a config help text and R-b next.

Thanks,
Thomas

Quoted 89 lines
Quoted 89 lines
---
  drivers/gpu/drm/Kconfig                  | 5 +++++
  drivers/gpu/drm/ttm/Makefile             | 4 ++--
  drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 3 ---
  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      | 3 +--
  include/drm/ttm/ttm_page_alloc.h         | 2 +-
  5 files changed, 9 insertions(+), 8 deletions(-)
drivers/gpu/drm/Kconfig +0 -0
index 2267e84d5cb4..f733a9273b3f 100644
@@ -160,6 +160,11 @@ config DRM_TTM
  	  GPU memory types. Will be enabled automatically if a device

driver
uses it.

drivers/gpu/drm/Kconfig +5 -0
+config DRM_TTM_DMA_PAGE_POOL
+        bool
+	depends on DRM_TTM && (SWIOTLB || INTEL_IOMMU)
+	default y
+
  config DRM_GEM_CMA_HELPER
  	bool
  	depends on DRM
drivers/gpu/drm/ttm/Makefile +2 -2
index 01fc670ce7a2..caea2a099496 100644
@@ -4,8 +4,8 @@
 
  ttm-y := ttm_memory.o ttm_tt.o ttm_bo.o \
  	ttm_bo_util.o ttm_bo_vm.o ttm_module.o \
-	ttm_execbuf_util.o ttm_page_alloc.o ttm_bo_manager.o \
-	ttm_page_alloc_dma.o
+	ttm_execbuf_util.o ttm_page_alloc.o ttm_bo_manager.o
  ttm-$(CONFIG_AGP) += ttm_agp_backend.o
+ttm-$(CONFIG_DRM_TTM_DMA_PAGE_POOL) += ttm_page_alloc_dma.o
 
  obj-$(CONFIG_DRM_TTM) += ttm.o
drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +0 -3
index d594f7520b7b..98d100fd1599 100644
@@ -33,7 +33,6 @@
   *   when freed).
   */
 
-#if defined(CONFIG_SWIOTLB) || defined(CONFIG_INTEL_IOMMU)
  #define pr_fmt(fmt) "[TTM] " fmt
 
  #include <linux/dma-mapping.h>
@@ -1234,5 +1233,3 @@ int ttm_dma_page_alloc_debugfs(struct
 seq_file *m, void *data)
  	return 0;
  }
  EXPORT_SYMBOL_GPL(ttm_dma_page_alloc_debugfs);
-
-#endif
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +0 -2
index d59c474be38e..bc259d4df1cb 100644
@@ -572,8 +572,7 @@ static int vmw_dma_select_mode(struct
 vmw_private *dev_priv)
  	else
  		dev_priv->map_mode = vmw_dma_map_populate;
 
-	/* No TTM coherent page pool? FIXME: Ask TTM instead! */
-        if (!(IS_ENABLED(CONFIG_SWIOTLB) ||

IS_ENABLED(CONFIG_INTEL_IOMMU)) &&

drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1 -0
+        if (!IS_ENABLED(CONFIG_DRM_TTM_DMA_PAGE_POOL) &&
  	    (dev_priv->map_mode == vmw_dma_alloc_coherent))
  		return -EINVAL;
include/drm/ttm/ttm_page_alloc.h +0 -0
index 4d9b019d253c..a6b6ef5f9bf4 100644
@@ -74,7 +74,7 @@ void ttm_unmap_and_unpopulate_pages(struct device
 *dev, struct ttm_dma_tt *tt);
   */
  int ttm_page_alloc_debugfs(struct seq_file *m, void *data);
 
Quoted 5 lines
Quoted 5 lines
include/drm/ttm/ttm_page_alloc.h +1 -1
-#if defined(CONFIG_SWIOTLB) || defined(CONFIG_INTEL_IOMMU)
+#if defined(CONFIG_DRM_TTM_DMA_PAGE_POOL)
  /**
   * Initialize pool allocator.
   */

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

Am 16.05.19 um 13:23 schrieb Thomas Hellstrom:

Quoted 13 lines · Christian König
Quoted 12 lines

Am 16.05.19 um 11:23 schrieb Thomas Hellstrom:

Quoted 8 lines

Drivers like vmwgfx may want to test whether the dma page pool is present
or not. Since it's activated by default by TTM if compiled-in, define a
hidden configuration option that the driver can test for.

There are at least also occasions of this in radeon and amdgpu, but those can be cleaned up later on.

Quoted 8 lines
Quoted 6 lines

Which tree should we use for merging?

Thanks,
Christian.

We can take it through an AMD tree if it's OK with you. Then it would be easier to add similar changes to the AMD drivers.

Perfectly fine with me, going to pick that up and doing the radeon/amdgpu cleanups on top.

Christian.

Quoted 99 lines

I'll send out v2 with some whitespace cleanup, a config help text and R-b next.

Thanks,
Thomas

Quoted 88 lines
Quoted 88 lines
---
   drivers/gpu/drm/Kconfig                  | 5 +++++
   drivers/gpu/drm/ttm/Makefile             | 4 ++--
   drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 3 ---
   drivers/gpu/drm/vmwgfx/vmwgfx_drv.c      | 3 +--
   include/drm/ttm/ttm_page_alloc.h         | 2 +-
   5 files changed, 9 insertions(+), 8 deletions(-)
drivers/gpu/drm/Kconfig +0 -0
index 2267e84d5cb4..f733a9273b3f 100644
@@ -160,6 +160,11 @@ config DRM_TTM
   	  GPU memory types. Will be enabled automatically if a device

driver
uses it.

drivers/gpu/drm/Kconfig +5 -0
+config DRM_TTM_DMA_PAGE_POOL
+        bool
+	depends on DRM_TTM && (SWIOTLB || INTEL_IOMMU)
+	default y
+
   config DRM_GEM_CMA_HELPER
   	bool
   	depends on DRM
drivers/gpu/drm/ttm/Makefile +2 -2
index 01fc670ce7a2..caea2a099496 100644
@@ -4,8 +4,8 @@
 
   ttm-y := ttm_memory.o ttm_tt.o ttm_bo.o \
   	ttm_bo_util.o ttm_bo_vm.o ttm_module.o \
-	ttm_execbuf_util.o ttm_page_alloc.o ttm_bo_manager.o \
-	ttm_page_alloc_dma.o
+	ttm_execbuf_util.o ttm_page_alloc.o ttm_bo_manager.o
   ttm-$(CONFIG_AGP) += ttm_agp_backend.o
+ttm-$(CONFIG_DRM_TTM_DMA_PAGE_POOL) += ttm_page_alloc_dma.o
 
   obj-$(CONFIG_DRM_TTM) += ttm.o
drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +0 -3
index d594f7520b7b..98d100fd1599 100644
@@ -33,7 +33,6 @@
    *   when freed).
    */
 
-#if defined(CONFIG_SWIOTLB) || defined(CONFIG_INTEL_IOMMU)
   #define pr_fmt(fmt) "[TTM] " fmt
 
   #include <linux/dma-mapping.h>
@@ -1234,5 +1233,3 @@ int ttm_dma_page_alloc_debugfs(struct
 seq_file *m, void *data)
   	return 0;
   }
   EXPORT_SYMBOL_GPL(ttm_dma_page_alloc_debugfs);
-
-#endif
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +0 -2
index d59c474be38e..bc259d4df1cb 100644
@@ -572,8 +572,7 @@ static int vmw_dma_select_mode(struct
 vmw_private *dev_priv)
   	else
   		dev_priv->map_mode = vmw_dma_map_populate;
 
-	/* No TTM coherent page pool? FIXME: Ask TTM instead! */
-        if (!(IS_ENABLED(CONFIG_SWIOTLB) ||

IS_ENABLED(CONFIG_INTEL_IOMMU)) &&

drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1 -0
+        if (!IS_ENABLED(CONFIG_DRM_TTM_DMA_PAGE_POOL) &&
   	    (dev_priv->map_mode == vmw_dma_alloc_coherent))
   		return -EINVAL;
include/drm/ttm/ttm_page_alloc.h +0 -0
index 4d9b019d253c..a6b6ef5f9bf4 100644
@@ -74,7 +74,7 @@ void ttm_unmap_and_unpopulate_pages(struct device
 *dev, struct ttm_dma_tt *tt);
    */
   int ttm_page_alloc_debugfs(struct seq_file *m, void *data);
 
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
include/drm/ttm/ttm_page_alloc.h +1 -1
-#if defined(CONFIG_SWIOTLB) || defined(CONFIG_INTEL_IOMMU)
+#if defined(CONFIG_DRM_TTM_DMA_PAGE_POOL)
   /**
    * Initialize pool allocator.
    */

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel