drm/amdgpu: add smu_memory_pool_size module parameter
Subsystems (2)
PATCH 1/3 drm/amdgpu: add smu_memory_pool_size module parameter
used to clamp system memmoy for smu debug usage.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 +++++ 2 files changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -132,6 +132,7 @@#ifdef CONFIG_DRM_AMDGPU_CIK extern int amdgpu_cik_support;#endif +extern uint amdgpu_smu_memory_pool_size;#define AMDGPU_DEFAULT_GTT_SIZE_MB 3072ULL/* 3GB by default */ #define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS 3000
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +5 -0
@@ -126,6 +126,7 @@int amdgpu_job_hang_limit =0 ;int amdgpu_lbpw =-1 ;int amdgpu_compute_multipipe =-1 ; +uint amdgpu_smu_memory_pool_size =0 ;MODULE_PARM_DESC (vramlimit,"Restrict VRAM for testing, in megabytes" );module_param_named (vramlimit, amdgpu_vram_limit, int,0600 );
@@ -301,6 +302,10 @@module_param_named (cik_support, amdgpu_cik_support, int,0444 );#endif +MODULE_PARM_DESC (smu_memory_pool_size, +"clamp max system memory for smu debug usage, 0 = disable," +"0x1 = 256Mbyte, 0x2 = 512Mbyte, 0x4 = 1 Gbyte, 0x8 = 2GByte" ); +module_param_named (smu_memory_pool_size, amdgpu_smu_memory_pool_size, uint,0444 );static const struct pci_device_id pciidlist[] = { #ifdef CONFIG_DRM_AMDGPU_SI
Signature · 6 lines
1.9.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): 1507631973-14165-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org
PATCH 2/3 drm/amdgpu: validate module parameter smu_prv_buffer_size
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 43 ++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 3 +++ drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 2 ++ drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 3 +++ drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 ++ drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 ++ 6 files changed, 55 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +43 -0
@@ -1152,6 +1152,46 @@ static void amdgpu_check_vm_size(struct amdgpu_device *adev) amdgpu_vm_size =-1 ; } +static void amdgpu_device_check_smu_prv_buffer_size (struct amdgpu_device *adev) +{ +struct sysinfo si; +bool is_os_64 = (sizeof (void *) ==8 ) ? true : false; +uint64_t total_memory; +uint64_t dram_size_seven_GB =0x1B8000000 ; +uint64_t dram_size_three_GB =0xB8000000 ; + +if (amdgpu_smu_memory_pool_size ==0 ) +return ; + +if (!is_os_64) { +DRM_WARN ("Not 64-bit OS, feature not supported\n" ); + goto def_value; + } +si_meminfo (&si); + total_memory = (uint64_t )si.totalram * si.mem_unit; + +if ((amdgpu_smu_memory_pool_size ==1 ) || + (amdgpu_smu_memory_pool_size ==2 )) { +if (total_memory < dram_size_three_GB) + goto def_value1; + }else if ((amdgpu_smu_memory_pool_size ==4 ) || + (amdgpu_smu_memory_pool_size ==8 )) { +if (total_memory < dram_size_seven_GB) + goto def_value1; + }else { +DRM_WARN ("Smu memory pool size not supported\n" ); + goto def_value; + } + amdgpu_smu_memory_pool_size = amdgpu_smu_memory_pool_size <<28 ; + +return ; + +def_value1: +DRM_WARN ("No enough system memory\n" ); +def_value: + amdgpu_smu_memory_pool_size =0 ; +} +/** * amdgpu_check_arguments - validate module params *
@@ -1193,6 +1233,8 @@ static void amdgpu_check_arguments(struct amdgpu_device *adev) amdgpu_vm_fragment_size =-1 ; } +amdgpu_device_check_smu_prv_buffer_size (adev); +amdgpu_check_vm_size (adev);amdgpu_check_block_size (adev);
@@ -2430,6 +2472,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev)release_firmware (adev->firmware.gpu_info_fw); adev->firmware.gpu_info_fw =NULL ; } + adev->accel_working = false;cancel_delayed_work_sync (&adev->late_init_work);/* free i2c buses */
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -0
@@ -1280,6 +1280,9 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) adev->mc.mc_vram_size); else gtt_size = (uint64_t )amdgpu_gtt_size <<20 ; + + gtt_size = gtt_size + amdgpu_smu_memory_pool_size; + r =ttm_bo_init_mm (&adev->mman.bdev,TTM_PL_TT , gtt_size >>PAGE_SHIFT );if (r) {DRM_ERROR ("Failed initializing GTT heap.\n" );
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -0
@@ -350,6 +350,8 @@ static int gmc_v6_0_mc_init(struct amdgpu_device *adev) adev->mc.gart_size = (u64 )amdgpu_gart_size <<20 ; } + adev->mc.gart_size += amdgpu_smu_memory_pool_size; +gmc_v6_0_vram_gtt_location (adev, &adev->mc);return 0 ;
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +3 -0
@@ -407,6 +407,9 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev) adev->mc.gart_size = (u64 )amdgpu_gart_size <<20 ; } + + adev->mc.gart_size += amdgpu_smu_memory_pool_size; +gmc_v7_0_vram_gtt_location (adev, &adev->mc);return 0 ;
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +2 -0
@@ -582,6 +582,8 @@ static int gmc_v8_0_mc_init(struct amdgpu_device *adev) adev->mc.gart_size = (u64 )amdgpu_gart_size <<20 ; } + adev->mc.gart_size += amdgpu_smu_memory_pool_size; +gmc_v8_0_vram_gtt_location (adev, &adev->mc);return 0 ;
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -0
@@ -511,6 +511,8 @@ static int gmc_v9_0_mc_init(struct amdgpu_device *adev) adev->mc.gart_size = (u64 )amdgpu_gart_size <<20 ; } + adev->mc.gart_size += amdgpu_smu_memory_pool_size; +gmc_v9_0_vram_gtt_location (adev, &adev->mc);return 0 ;
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/3 drm/amd/powerplay: add new sysfs pp_alloc_mem_for_smu
In reply to a message not in the archive--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 89 ++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -1637,6 +1637,8 @@ struct amdgpu_device {bool has_hw_reset;u8 reset_magic[AMDGPU_RESET_MAGIC_NUM ]; +struct amdgpu_bo *smu_prv_buffer; +/* record last mm index being written through WREG32*/ unsigned long last_mm_index;bool in_sriov_reset;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5 -1
@@ -2426,6 +2426,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,DRM_INFO ("amdgpu: acceleration disabled, skipping benchmarks\n" ); } +/* enable clockgating, etc. after ib tests, etc. since some blocks require * explicit gating rather than handling it automatically. */
@@ -2472,7 +2473,10 @@ void amdgpu_device_fini(struct amdgpu_device *adev)release_firmware (adev->firmware.gpu_info_fw); adev->firmware.gpu_info_fw =NULL ; } - +if (adev->smu_prv_buffer) { +amdgpu_bo_free_kernel (&adev->smu_prv_buffer,NULL ,NULL ); + adev->smu_prv_buffer =NULL ; + } adev->accel_working = false;cancel_delayed_work_sync (&adev->late_init_work);/* free i2c buses */
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +89 -0
107 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 34 lines · Rex Zhu
used to clamp system memmoy for smu debug usage.
Change-Id I8399f55069b8dcc05a3a79f9285744fcc8549af0Signed-off-by Rex Zhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 +++++ 2 files changed, 6 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -132,6 +132,7 @@#ifdef CONFIG_DRM_AMDGPU_CIK extern int amdgpu_cik_support;#endif +extern uint amdgpu_smu_memory_pool_size;#define AMDGPU_DEFAULT_GTT_SIZE_MB 3072ULL/* 3GB by default */ #define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS 3000drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-0@@ -126,6 +126,7 @@int amdgpu_job_hang_limit =0 ;int amdgpu_lbpw =-1 ;int amdgpu_compute_multipipe =-1 ; +uint amdgpu_smu_memory_pool_size =0 ;MODULE_PARM_DESC (vramlimit,"Restrict VRAM for testing, in megabytes" );module_param_named (vramlimit, amdgpu_vram_limit, int,0600 );
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c line 308
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4
-0@@ -301,6 +302,10 @@module_param_named (cik_support, amdgpu_cik_support, int,0444 );#endif +MODULE_PARM_DESC (smu_memory_pool_size, +"clamp max system memory for smu debug usage, 0 = disable," +"0x1 = 256Mbyte, 0x2 = 512Mbyte, 0x4 = 1 Gbyte, 0x8 = 2GByte" ); +module_param_named (smu_memory_pool_size, amdgpu_smu_memory_pool_size, uint,0444 );
Sorry, I should have been more clear. I want to avoid adding another module parameter. I was thinking of a debugfs file (e.g., amdgpu_smu_log_size or something like that) and if you set the file to 0, it would disable smu power logging and if you set it to a different size, it would allocate the memory and then send the smu messages to enable the logging. Within the debugfs handler it would check the size against the current gart size and return an error (-ENOMEM) if the gart wasn't big enough or the allocation failed.
to disable:
echo 0 > /sys/kernel/debug/dri/0/amdgpu_smu_log_size to enable a 64M SMU log:
echo 64 > /sys/kernel/debug/dri/0/amdgpu_smu_log_size
Alex
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0
-1static const struct pci_device_id pciidlist[] = { #ifdef CONFIG_DRM_AMDGPU_SI --1.9.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
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): CADnq5_P4P_A4wNchSb5qk=65c-qJtnDQS+H1yZXzL4gv+qajFw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Am 10.10.2017 um 18:33 schrieb Alex Deucher:
Quoted 51 lines · Rex Zhu
Quoted 34 lines
used to clamp system memmoy for smu debug usage.
Change-Id I8399f55069b8dcc05a3a79f9285744fcc8549af0Signed-off-by Rex Zhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 +++++ 2 files changed, 6 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -132,6 +132,7 @@#ifdef CONFIG_DRM_AMDGPU_CIK extern int amdgpu_cik_support;#endif +extern uint amdgpu_smu_memory_pool_size;#define AMDGPU_DEFAULT_GTT_SIZE_MB 3072ULL/* 3GB by default */ #define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS 3000drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1
-0@@ -126,6 +126,7 @@int amdgpu_job_hang_limit =0 ;int amdgpu_lbpw =-1 ;int amdgpu_compute_multipipe =-1 ; +uint amdgpu_smu_memory_pool_size =0 ;MODULE_PARM_DESC (vramlimit,"Restrict VRAM for testing, in megabytes" );module_param_named (vramlimit, amdgpu_vram_limit, int,0600 );drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c line 308
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4
-0@@ -301,6 +302,10 @@module_param_named (cik_support, amdgpu_cik_support, int,0444 );#endif +MODULE_PARM_DESC (smu_memory_pool_size, +"clamp max system memory for smu debug usage, 0 = disable," +"0x1 = 256Mbyte, 0x2 = 512Mbyte, 0x4 = 1 Gbyte, 0x8 = 2GByte" ); +module_param_named (smu_memory_pool_size, amdgpu_smu_memory_pool_size, uint,0444 );Sorry, I should have been more clear. I want to avoid adding another module parameter. I was thinking of a debugfs file (e.g.,
amdgpu_smu_log_sizeor something like that) and if you set the file to 0, it would disable smu power logging and if you set it to a different size, it would allocate the memory and then send the smu messages to enable the logging. Within the debugfs handler it would check the size against the current gart size and return an error (-ENOMEM) if the gart wasn't big enough or the allocation failed.
Quoted 4 lines
to disable:
echo 0 >/sys/kernel/debug/dri/0/amdgpu_smu_log_sizeto enable a 64M SMU log:
echo 64 >/sys/kernel/debug/dri/0/amdgpu_smu_log_size
Seconded, assuming that you can send the message to the SMU while it is running that sounds like a much better approach.
You also don't need to really check the size, allocating and pinning a buffer which is bigger than GART should fail no matter what.
Christian.
Quoted 8 lines
Alex
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0
-1static const struct pci_device_id pciidlist[] = { #ifdef CONFIG_DRM_AMDGPU_SI --1.9.1
Quoted 8 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx