drm/ttm, drm/vmwgfx: Use a configuration option for the TTM dma page pool
authorThomas Hellstrom <thellstrom@vmware.com>
Wed, 13 Nov 2019 18:02:42 +0000 (19:02 +0100)
committerThomas Hellstrom <thellstrom@vmware.com>
Thu, 14 Nov 2019 07:41:23 +0000 (08:41 +0100)
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.

Cc: Christian König <christian.koenig@amd.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
drivers/gpu/drm/Kconfig
drivers/gpu/drm/ttm/Makefile
drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
include/drm/ttm/ttm_page_alloc.h

index 617d9c3a86c3f013f8a386967a614b440aa21434..1168351267fda9daf9ffaf664491cd9a1d0aa7a4 100644 (file)
@@ -179,6 +179,13 @@ 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
+       help
+         Choose this if you need the TTM dma page pool
+
 config DRM_VRAM_HELPER
        tristate
        depends on DRM
index 01fc670ce7a21978881c2603034c84142d943bea..caea2a0994966a7aa42f77c4f38fe0db11eaf6a3 100644 (file)
@@ -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
index ff54e7609e8ff994dc38c3500e7c4047926dbefc..bf876faea5921f9bed2358d736d7983a3d3270ba 100644 (file)
@@ -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>
@@ -1238,5 +1237,3 @@ int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data)
        return 0;
 }
 EXPORT_SYMBOL_GPL(ttm_dma_page_alloc_debugfs);
-
-#endif
index 81a95651643f2c58b3abd61f6c104c82c322d85e..e962048f65d20f2618923ecea8ec905952226fb1 100644 (file)
@@ -576,8 +576,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;
 
index 4d9b019d253cdc2646dc056f224b8293a525a727..a6b6ef5f9bf4884b58564d07cc9953dde2d5360a 100644 (file)
@@ -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.
  */