drm/amdgpu: only enable swiotlb alloc when need
Subsystems (2)
PATCH 1/1 drm/amdgpu: only enable swiotlb alloc when need
get the max io mapping address of system memory to see if it is over our card accessing range.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 ++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 1 + drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 1 + drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 1 + drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 1 + 7 files changed, 24 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -0
@@ -1437,6 +1437,7 @@ struct amdgpu_device {const struct amdgpu_asic_funcs *asic_funcs;bool shutdown;bool need_dma32; +bool need_swiotlb;bool accel_working;struct work_struct reset_work;struct notifier_block acpi_nb;
@@ -1629,6 +1630,8 @@ struct amdgpu_device {unsigned long last_mm_index;bool in_gpu_reset;struct mutex lock_reset; + +u64 sysmem_max_io; };static inline struct amdgpu_device *amdgpu_ttm_adev (struct ttm_bo_device *bdev)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +14 -0
@@ -1742,6 +1742,19 @@ bool amdgpu_device_has_dc_support(struct amdgpu_device *adev)return amdgpu_device_asic_has_dc_support (adev->asic_type); } +static void amdgpu_device_get_max_io_of_sysmem (struct amdgpu_device *adev) +{ +struct resource *tmp; + +for (tmp = iomem_resource.child; tmp; tmp = tmp->sibling) { +if (tmp->flags == (IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY )) + adev->sysmem_max_io =max (adev->sysmem_max_io, + tmp->end); + } +DRM_INFO ("System Ram max io address is 0x%llx\n" , adev->sysmem_max_io); +} + +/** * amdgpu_device_init - initialize the driver *
@@ -1795,6 +1808,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, adev->gc_cac_wreg = &amdgpu_invalid_wreg; adev->audio_endpt_rreg = &amdgpu_block_invalid_rreg; adev->audio_endpt_wreg = &amdgpu_block_invalid_wreg; +amdgpu_device_get_max_io_of_sysmem (adev); DRM_INFO("initializing kernel modesetting (%s 0x%04X:0x%04X 0x%04X:0x%04X 0x%02X).\n", amdgpu_asic_name[adev->asic_type], pdev->vendor, pdev->device,
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -3
@@ -1018,7 +1018,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm, }#ifdef CONFIG_SWIOTLB -if (swiotlb_nr_tbl ()) { +if (adev->need_swiotlb &&swiotlb_nr_tbl ()) {return ttm_dma_populate (>t->ttm, adev->dev, ctx); }#endif
@@ -1045,7 +1045,7 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm) adev =amdgpu_ttm_adev (ttm->bdev);#ifdef CONFIG_SWIOTLB -if (swiotlb_nr_tbl ()) { +if (adev->need_swiotlb &&swiotlb_nr_tbl ()) {ttm_dma_unpopulate (>t->ttm, adev->dev);return ; }
@@ -2007,7 +2007,7 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) count =ARRAY_SIZE (amdgpu_ttm_debugfs_list);#ifdef CONFIG_SWIOTLB -if (!swiotlb_nr_tbl ()) +if (!(adev->need_swiotlb &&swiotlb_nr_tbl ())) --count;#endif
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +1 -0
@@ -855,6 +855,7 @@ static int gmc_v6_0_sw_init(void *handle) adev->need_dma32 = false; dma_bits = adev->need_dma32 ?32 :40 ; + adev->need_swiotlb = adev->sysmem_max_io > (1 << dma_bits); r =pci_set_dma_mask (adev->pdev,DMA_BIT_MASK (dma_bits));if (r) { adev->need_dma32 = true;
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 -0
@@ -1003,6 +1003,7 @@ static int gmc_v7_0_sw_init(void *handle)*/ adev->need_dma32 = false; dma_bits = adev->need_dma32 ?32 :40 ; + adev->need_swiotlb = adev->sysmem_max_io > (1 << dma_bits); r =pci_set_dma_mask (adev->pdev,DMA_BIT_MASK (dma_bits));if (r) { adev->need_dma32 = true;
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 -0
@@ -1101,6 +1101,7 @@ static int gmc_v8_0_sw_init(void *handle)*/ adev->need_dma32 = false; dma_bits = adev->need_dma32 ?32 :40 ; + adev->need_swiotlb = adev->sysmem_max_io > ((u64 )1 << dma_bits); r =pci_set_dma_mask (adev->pdev,DMA_BIT_MASK (dma_bits));if (r) { adev->need_dma32 = true;
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -0
@@ -879,6 +879,7 @@ static int gmc_v9_0_sw_init(void *handle)*/ adev->need_dma32 = false; dma_bits = adev->need_dma32 ?32 :44 ; + adev->need_swiotlb = adev->sysmem_max_io > (1 << dma_bits); r =pci_set_dma_mask (adev->pdev,DMA_BIT_MASK (dma_bits));if (r) { adev->need_dma32 = true;
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Am 07.02.2018 um 12:04 schrieb Chunming Zhou:
Quoted 42 lines
get the max io mapping address of system memory to see if it is over our card accessing range.
Change-Id Ibc38dbd34a20af5b4a4b1ed154c14e1c58aa4c55Signed-off-by Chunming Zhou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 ++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 1 + drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 1 + drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 1 + drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 1 + 7 files changed, 24 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +3
-0@@ -1437,6 +1437,7 @@ struct amdgpu_device {const struct amdgpu_asic_funcs *asic_funcs;bool shutdown;bool need_dma32; +bool need_swiotlb;bool accel_working;struct work_struct reset_work;struct notifier_block acpi_nb;@@ -1629,6 +1630,8 @@ struct amdgpu_device {unsigned long last_mm_index;bool in_gpu_reset;struct mutex lock_reset; + +u64 sysmem_max_io; };static inline struct amdgpu_device *amdgpu_ttm_adev (struct ttm_bo_device *bdev)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -1742,6 +1742,19 @@ bool amdgpu_device_has_dc_support(struct amdgpu_device *adev)return amdgpu_device_asic_has_dc_support (adev->asic_type);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c bool amdgpu_device_has_dc_support(struct amdgpu_device *adev) · line 1752
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +8
-0} +static void amdgpu_device_get_max_io_of_sysmem (struct amdgpu_device *adev) +{ +struct resource *tmp; + +for (tmp = iomem_resource.child; tmp; tmp = tmp->sibling) { +if (tmp->flags == (IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY )) + adev->sysmem_max_io =max (adev->sysmem_max_io, + tmp->end);
Nifty idea. I was thinking about using max_pfn, but taking a look at iomem_resource is indeed much better.
But please drop the tmp->flags check, we need to make sure that we handle hot plugged memory and maybe other IO resources in the future as well.
Might be a good idea to make that a general drm function and fix radeon as well, see drm_arch_can_wc_memory() as well. At minimum I would send it to dri-devel for review as well.
Regards,
Christian.
Quoted 88 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6
-0+ } +DRM_INFO ("System Ram max io address is 0x%llx\n" , adev->sysmem_max_io); +} + +/** * amdgpu_device_init - initialize the driver * @@ -1795,6 +1808,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, adev->gc_cac_wreg = &amdgpu_invalid_wreg; adev->audio_endpt_rreg = &amdgpu_block_invalid_rreg; adev->audio_endpt_wreg = &amdgpu_block_invalid_wreg; +amdgpu_device_get_max_io_of_sysmem (adev); DRM_INFO("initializing kernel modesetting (%s 0x%04X:0x%04X 0x%04X:0x%04X 0x%02X).\n", amdgpu_asic_name[adev->asic_type], pdev->vendor, pdev->device,drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3
-3@@ -1018,7 +1018,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm, }#ifdef CONFIG_SWIOTLB -if (swiotlb_nr_tbl ()) { +if (adev->need_swiotlb &&swiotlb_nr_tbl ()) {return ttm_dma_populate (>t->ttm, adev->dev, ctx); }#endif @@ -1045,7 +1045,7 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm) adev =amdgpu_ttm_adev (ttm->bdev);#ifdef CONFIG_SWIOTLB -if (swiotlb_nr_tbl ()) { +if (adev->need_swiotlb &&swiotlb_nr_tbl ()) {ttm_dma_unpopulate (>t->ttm, adev->dev);return ; }@@ -2007,7 +2007,7 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) count =ARRAY_SIZE (amdgpu_ttm_debugfs_list);#ifdef CONFIG_SWIOTLB -if (!swiotlb_nr_tbl ()) +if (!(adev->need_swiotlb &&swiotlb_nr_tbl ())) --count;#endif drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +1
-0@@ -855,6 +855,7 @@ static int gmc_v6_0_sw_init(void *handle) adev->need_dma32 = false; dma_bits = adev->need_dma32 ?32 :40 ; + adev->need_swiotlb = adev->sysmem_max_io > (1 << dma_bits); r =pci_set_dma_mask (adev->pdev,DMA_BIT_MASK (dma_bits));if (r) { adev->need_dma32 = true;drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1
-0@@ -1003,6 +1003,7 @@ static int gmc_v7_0_sw_init(void *handle)*/ adev->need_dma32 = false; dma_bits = adev->need_dma32 ?32 :40 ; + adev->need_swiotlb = adev->sysmem_max_io > (1 << dma_bits); r =pci_set_dma_mask (adev->pdev,DMA_BIT_MASK (dma_bits));if (r) { adev->need_dma32 = true;drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1
-0@@ -1101,6 +1101,7 @@ static int gmc_v8_0_sw_init(void *handle)*/ adev->need_dma32 = false; dma_bits = adev->need_dma32 ?32 :40 ; + adev->need_swiotlb = adev->sysmem_max_io > ((u64 )1 << dma_bits); r =pci_set_dma_mask (adev->pdev,DMA_BIT_MASK (dma_bits));if (r) { adev->need_dma32 = true;drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_sw_init(void *handle) · line 885
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1
-0@@ -879,6 +879,7 @@ static int gmc_v9_0_sw_init(void *handle)*/ adev->need_dma32 = false; dma_bits = adev->need_dma32 ?32 :44 ; + adev->need_swiotlb = adev->sysmem_max_io > (1 << dma_bits); r =pci_set_dma_mask (adev->pdev,DMA_BIT_MASK (dma_bits));if (r) { adev->need_dma32 = true;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx