OSDN Git Service

drm/radeon: only enable swiotlb path when need v2
authorChunming Zhou <david1.zhou@amd.com>
Fri, 9 Feb 2018 02:44:10 +0000 (10:44 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 13 Feb 2018 18:35:14 +0000 (13:35 -0500)
swiotlb expands our card accessing range, but its path always is slower
than ttm pool allocation.
So add condition to use it.
v2: move a bit later

Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
Reviewed-by: Monk Liu <monk.liu@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180209024410.1469-3-david1.zhou@amd.com
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_device.c
drivers/gpu/drm/radeon/radeon_ttm.c

index d348878..4a2eb40 100644 (file)
@@ -2387,6 +2387,7 @@ struct radeon_device {
        struct radeon_dummy_page        dummy_page;
        bool                            shutdown;
        bool                            need_dma32;
+       bool                            need_swiotlb;
        bool                            accel_working;
        bool                            fastfb_working; /* IGP feature*/
        bool                            needs_reset, in_reset;
index 8d3e3d2..7f40c6f 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/slab.h>
 #include <drm/drmP.h>
 #include <drm/drm_crtc_helper.h>
+#include <drm/drm_cache.h>
 #include <drm/radeon_drm.h>
 #include <linux/pm_runtime.h>
 #include <linux/vgaarb.h>
@@ -1378,6 +1379,7 @@ int radeon_device_init(struct radeon_device *rdev,
                pci_set_consistent_dma_mask(rdev->pdev, DMA_BIT_MASK(32));
                pr_warn("radeon: No coherent DMA available\n");
        }
+       rdev->need_swiotlb = drm_get_max_iomem() > ((u64)1 << dma_bits);
 
        /* Registers mapping */
        /* TODO: block userspace mapping of io register */
index a0a839b..c1e3862 100644 (file)
@@ -756,7 +756,7 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm,
 #endif
 
 #ifdef CONFIG_SWIOTLB
-       if (swiotlb_nr_tbl()) {
+       if (rdev->need_swiotlb && swiotlb_nr_tbl()) {
                return ttm_dma_populate(&gtt->ttm, rdev->dev, ctx);
        }
 #endif
@@ -788,7 +788,7 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm)
 #endif
 
 #ifdef CONFIG_SWIOTLB
-       if (swiotlb_nr_tbl()) {
+       if (rdev->need_swiotlb && swiotlb_nr_tbl()) {
                ttm_dma_unpopulate(&gtt->ttm, rdev->dev);
                return;
        }
@@ -1155,7 +1155,7 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
        count = ARRAY_SIZE(radeon_ttm_debugfs_list);
 
 #ifdef CONFIG_SWIOTLB
-       if (!swiotlb_nr_tbl())
+       if (!(rdev->need_swiotlb && swiotlb_nr_tbl()))
                --count;
 #endif