drm/amdgpu: avoid dummy_read_page overlapping mappings
Subsystems (4)
PATCH 1/1 drm/amdgpu: avoid dummy_read_page overlapping mappings
In the A+A system, the dummy_read_page is mapped twice during the device graphics memory software initialization.
To avoid page remapping, export the ttm_glob_use_count to the driver for checking whether the same page has already been mapped.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 3 ++- drivers/gpu/drm/ttm/ttm_device.c | 7 +++---- include/drm/ttm/ttm_device.h | 5 +++++ 3 files changed, 10 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +2 -1
@@ -76,7 +76,8 @@ static int amdgpu_gart_dummy_page_init(struct amdgpu_device *adev) {struct page *dummy_page = ttm_glob.dummy_read_page; -if (adev->dummy_page_addr) +if (adev->dummy_page_addr || + ttm_glob.ttm_glob_use_count >1 )return 0 ; adev->dummy_page_addr =dma_map_page (&adev->pdev->dev, dummy_page,0 ,PAGE_SIZE ,DMA_BIDIRECTIONAL );
drivers/gpu/drm/ttm/ttm_device.c +3 -4
@@ -41,7 +41,6 @@* ttm_global_mutex - protecting the global state */ static DEFINE_MUTEX (ttm_global_mutex); -static unsigned ttm_glob_use_count;struct ttm_global ttm_glob;EXPORT_SYMBOL (ttm_glob);
@@ -52,7 +51,7 @@ static void ttm_global_release(void)struct ttm_global *glob = &ttm_glob;mutex_lock (&ttm_global_mutex); -if (--ttm_glob_use_count >0 ) +if (--glob->ttm_glob_use_count >0 ) goto out;ttm_pool_mgr_fini ();
@@ -72,7 +71,7 @@ static int ttm_global_init(void)int ret =0 ;mutex_lock (&ttm_global_mutex); -if (++ttm_glob_use_count >1 ) +if (++glob->ttm_glob_use_count >1 ) goto out;si_meminfo (&si);
@@ -118,7 +117,7 @@ static int ttm_global_init(void)if (ret && ttm_debugfs_root)debugfs_remove (ttm_debugfs_root);if (ret) - --ttm_glob_use_count; + --glob->ttm_glob_use_count;mutex_unlock (&ttm_global_mutex);return ret; }
include/drm/ttm/ttm_device.h +5 -0
@@ -56,6 +56,11 @@ extern struct ttm_global {* @bo_count: Number of buffer objects allocated by devices. */ atomic_t bo_count; + +/** +* @ttm_glob_use_count: Number of ttm glob object referenced by devices. +*/ +unsigned ttm_glob_use_count; } ttm_glob;struct ttm_device_funcs {
Signature · 1 line
2.34.1
[AMD Official Use Only - AMD Internal Distribution Only]
Hold on to this patch for a while. I need to further investigate whether it requires allocating a separate page for the second VGA device.
Thanks,
Prike
Quoted 94 lines
-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Tuesday, October 22, 2024 3:19 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH] drm/amdgpu: avoiddummy_read_pageoverlapping mappingsIn the A+A system, the
dummy_read_pageis mapped twice during the device graphics memory software initialization.To avoid page remapping, export the
ttm_glob_use_countto the driver for checking whether the same page has already been mapped.Signed-off-by Prike Liang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 3 ++- drivers/gpu/drm/ttm/ttm_device.c | 7 +++---- include/drm/ttm/ttm_device.h | 5 +++++ 3 files changed, 10 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +2
-1@@ -76,7 +76,8 @@ static int amdgpu_gart_dummy_page_init(struct amdgpu_device *adev) {struct page *dummy_page = ttm_glob.dummy_read_page; -if (adev->dummy_page_addr) +if (adev->dummy_page_addr || + ttm_glob.ttm_glob_use_count >1 )return 0 ; adev->dummy_page_addr = dma_map_page(&adev->pdev->dev, dummy_page, 0,
PAGE_SIZE,DMA_BIDIRECTIONAL); diff -
-gita/drivers/gpu/drm/ttm/ttm_device.cb/drivers/gpu/drm/ttm/ttm_device.cindex434cf0258000..d99ccfa94c67100644drivers/gpu/drm/ttm/ttm_device.c +3
-4@@ -41,7 +41,6 @@* ttm_global_mutex - protecting the global state */ static DEFINE_MUTEX (ttm_global_mutex); -static unsigned ttm_glob_use_count;struct ttm_global ttm_glob;EXPORT_SYMBOL (ttm_glob);@@ -52,7 +51,7 @@ static void ttm_global_release(void)struct ttm_global *glob = &ttm_glob;mutex_lock (&ttm_global_mutex); -if (--ttm_glob_use_count >0 ) +if (--glob->ttm_glob_use_count >0 ) goto out;ttm_pool_mgr_fini ();@@ -72,7 +71,7 @@ static int ttm_global_init(void)int ret =0 ;mutex_lock (&ttm_global_mutex); -if (++ttm_glob_use_count >1 ) +if (++glob->ttm_glob_use_count >1 ) goto out;si_meminfo (&si);@@ -118,7 +117,7 @@ static int ttm_global_init(void)if (ret && ttm_debugfs_root)debugfs_remove (ttm_debugfs_root);if (ret) - --ttm_glob_use_count; + --glob->ttm_glob_use_count;mutex_unlock (&ttm_global_mutex);return ret; }include/drm/ttm/ttm_device.h index renamed from include/drm/ttm/ttm_device.h +0
-0
c22f30535c84..8afb380989e1100644include/drm/ttm/ttm_device.h +5
-1@@ -56,6 +56,11 @@ extern struct ttm_global {* @bo_count: Number of buffer objects allocated by devices. */ atomic_t bo_count; + +/** +* @ttm_glob_use_count: Number of ttm glob object referenced by devices. +*/ +unsigned ttm_glob_use_count; } ttm_glob;struct ttm_device_funcs { --2.34.1