drm/amdgpu: added AMD GPU instance counting
Subsystems (2)
PATCH 1/3 drm/amdgpu: added AMD GPU instance counting
Count all GPU instances from AMD(including iGPUs and dGPUs) in the system.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 18 +++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 7 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 52 +++++++++++++++++++++++++ 3 files changed, 77 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +18 -0
@@ -81,6 +81,23 @@#include "amdgpu_bo_list.h" #include "amdgpu_gem.h" +#define MAX_GPU_INSTANCE 16 + +struct amdgpu_gpu_instance +{ +struct amdgpu_device *adev; +int mgpu_fan_enabled; +}; + +struct amdgpu_mgpu_info +{ +struct amdgpu_gpu_instance gpu_ins[MAX_GPU_INSTANCE ]; +struct mutex mutex; +uint32_t num_gpu; +uint32_t num_dgpu; +uint32_t num_apu; +}; +/* * Modules parameters. */
@@ -134,6 +151,7 @@ extern int amdgpu_compute_multipipe;extern int amdgpu_gpu_recovery;extern int amdgpu_emu_mode;extern uint amdgpu_smu_memory_pool_size; +extern struct amdgpu_mgpu_info mgpu_info;#ifdef CONFIG_DRM_AMDGPU_SI extern int amdgpu_si_support;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +7 -0
@@ -127,6 +127,13 @@ int amdgpu_compute_multipipe = -1;int amdgpu_gpu_recovery =-1 ;/* auto */ int amdgpu_emu_mode =0 ;uint amdgpu_smu_memory_pool_size =0 ; +struct amdgpu_mgpu_info mgpu_info = { + .gpu_ins = {0 }, + .mutex =__MUTEX_INITIALIZER (mgpu_info.mutex), + .num_gpu =0 , + .num_apu =0 , + .num_dgpu =0 , +};/** * DOC: vramlimit (int)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +52 -0
76 lines not on this page · raw message
Signature · 6 lines
2.19.0 _______________________________________________ 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]
PATCH 2/3 drm/amd/powerplay: helper interfaces for MGPU fan boost feature
MGPU fan boost feature is enabled only when two or more dGPUs in the system.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 41 +++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 4 ++ .../gpu/drm/amd/include/kgd_pp_interface.h | 1 + drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 19 +++++++++ drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 1 + 5 files changed, 66 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +41 -0
@@ -1833,6 +1833,43 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)return 0 ; } +static int amdgpu_device_enable_mgpu_fan_boost (void ) +{ +struct amdgpu_gpu_instance *gpu_ins; +struct amdgpu_device *adev; +int i, ret =0 ; + +mutex_lock (&mgpu_info.mutex); + +/* +* MGPU fan boost feature should be enabled +* only when there are two or more dGPUs in +* the system +*/ +if (mgpu_info.num_dgpu <2 ) + goto out; + +for (i =0 ; i < mgpu_info.num_dgpu; i++) { + gpu_ins = &(mgpu_info.gpu_ins[i]); + adev = gpu_ins->adev; +if (!(adev->flags &AMD_IS_APU ) && + !gpu_ins->mgpu_fan_enabled && + adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->enable_mgpu_fan_boost) { + ret =amdgpu_dpm_enable_mgpu_fan_boost (adev); +if (ret) +break ; + + gpu_ins->mgpu_fan_enabled =1 ; + } + } + +out: +mutex_unlock (&mgpu_info.mutex); + +return ret; +} +/** * amdgpu_device_ip_late_init_func_handler - work handler for ib test *
@@ -1847,6 +1884,10 @@ static void amdgpu_device_ip_late_init_func_handler(struct work_struct *work) r =amdgpu_ib_ring_tests (adev);if (r)DRM_ERROR ("ib ring test failed (%d).\n" , r); + + r =amdgpu_device_enable_mgpu_fan_boost (); +if (r) +DRM_ERROR ("enable mgpu fan boost failed (%d).\n" , r); }static void amdgpu_device_delay_enable_gfx_off (struct work_struct *work)
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +4 -0
@@ -357,6 +357,10 @@ enum amdgpu_pcie_gen { ((adev)->powerplay.pp_funcs->odn_edit_dpm_table (\ (adev)->powerplay.pp_handle, type, parameter, size)) +#define amdgpu_dpm_enable_mgpu_fan_boost (adev) \ + ((adev)->powerplay.pp_funcs->enable_mgpu_fan_boost(\ + (adev)->powerplay.pp_handle)) +struct amdgpu_dpm {struct amdgpu_ps *ps;/* number of valid power states */
drivers/gpu/drm/amd/include/kgd_pp_interface.h +1 -0
@@ -272,6 +272,7 @@ struct amd_pm_funcs {int (*get_display_mode_validation_clocks)(void *handle,struct amd_pp_simple_clock_info *clocks);int (*notify_smu_enable_pwe)(void *handle); + int (*enable_mgpu_fan_boost)(void *handle); };#endif
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +19 -0
@@ -1243,6 +1243,24 @@ static int pp_notify_smu_enable_pwe(void *handle)return 0 ; } +static int pp_enable_mgpu_fan_boost (void *handle) +{ +struct pp_hwmgr *hwmgr = handle; + +if (!hwmgr || !hwmgr->pm_en) +return -EINVAL ; + +if (hwmgr->hwmgr_func->enable_mgpu_fan_boost ==NULL ) { +return 0 ; + } + +mutex_lock (&hwmgr->smu_lock); + hwmgr->hwmgr_func->enable_mgpu_fan_boost (hwmgr); +mutex_unlock (&hwmgr->smu_lock); + +return 0 ; +} +static const struct amd_pm_funcs pp_dpm_funcs = { .load_firmware = pp_dpm_load_fw, .wait_for_fw_loading_complete = pp_dpm_fw_loading_complete,
@@ -1287,4 +1305,5 @@ static const struct amd_pm_funcs pp_dpm_funcs = { .display_clock_voltage_request = pp_display_clock_voltage_request, .get_display_mode_validation_clocks = pp_get_display_mode_validation_clocks, .notify_smu_enable_pwe = pp_notify_smu_enable_pwe, + .enable_mgpu_fan_boost = pp_enable_mgpu_fan_boost, };
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +1 -0
@@ -328,6 +328,7 @@ struct pp_hwmgr_func {int (*set_power_limit)(struct pp_hwmgr *hwmgr,uint32_t n);int (*powergate_mmhub)(struct pp_hwmgr *hwmgr);int (*smus_notify_pwe)(struct pp_hwmgr *hwmgr); +int (*enable_mgpu_fan_boost)(struct pp_hwmgr *hwmgr); };struct pp_table_func {
Signature · 6 lines
2.19.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/3 drm/amd/powerplay: enable MGPU fan boost feature on Vega20
In reply to a message not in the archiveAdded Vega20 specific implementation for MGPU fan boost feature.
--- .../gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c +15 -0
@@ -1477,6 +1477,19 @@ static int vega20_init_max_sustainable_clocks(struct pp_hwmgr *hwmgr)return 0 ; } +static int vega20_enable_mgpu_fan_boost (struct pp_hwmgr *hwmgr) +{ +int result; + + result =smum_send_msg_to_smc (hwmgr, + PPSMC_MSG_SetMGpuFanBoostLimitRpm); +PP_ASSERT_WITH_CODE (!result, +"[EnableMgpuFan] Failed to enable mgpu fan boost!" , + return result); + +return 0 ; +} +static void vega20_init_powergate_state (struct pp_hwmgr *hwmgr) { struct vega20_hwmgr *data =
@@ -3488,6 +3501,8 @@ static const struct pp_hwmgr_func vega20_hwmgr_funcs = {/* smu memory related */ .notify_cac_buffer_info = vega20_notify_cac_buffer_info, + .enable_mgpu_fan_boost = + vega20_enable_mgpu_fan_boost, };int vega20_hwmgr_init (struct pp_hwmgr *hwmgr)
Signature · 6 lines
2.19.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 53 lines · Evan Quan
Count all GPU instances from AMD(including iGPUs and dGPUs) in the system.
Change-Id If62a0873c64857a3fcdf9785557e24cb3456c12eSigned-off-by Evan Quan <[email protected]>Reviewed-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 18 +++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 7 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 52 +++++++++++++++++++++++++ 3 files changed, 77 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +18
-0@@ -81,6 +81,23 @@#include "amdgpu_bo_list.h" #include "amdgpu_gem.h" +#define MAX_GPU_INSTANCE 16 + +struct amdgpu_gpu_instance +{ +struct amdgpu_device *adev; +int mgpu_fan_enabled; +}; + +struct amdgpu_mgpu_info +{ +struct amdgpu_gpu_instance gpu_ins[MAX_GPU_INSTANCE ]; +struct mutex mutex; +uint32_t num_gpu; +uint32_t num_dgpu; +uint32_t num_apu; +}; +/* * Modules parameters. */ @@ -134,6 +151,7 @@ extern int amdgpu_compute_multipipe;extern int amdgpu_gpu_recovery;extern int amdgpu_emu_mode;extern uint amdgpu_smu_memory_pool_size; +extern struct amdgpu_mgpu_info mgpu_info;#ifdef CONFIG_DRM_AMDGPU_SI extern int amdgpu_si_support;drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c int amdgpu_compute_multipipe = -1; · line 136
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +7
-0@@ -127,6 +127,13 @@ int amdgpu_compute_multipipe = -1;int amdgpu_gpu_recovery =-1 ;/* auto */ int amdgpu_emu_mode =0 ;uint amdgpu_smu_memory_pool_size =0 ; +struct amdgpu_mgpu_info mgpu_info = { + .gpu_ins = {0 }, + .mutex =__MUTEX_INITIALIZER (mgpu_info.mutex), + .num_gpu =0 , + .num_apu =0 , + .num_dgpu =0 , +};
you could init mutex only.
Quoted 80 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0
-0/** * DOC: vramlimit (int) drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +51
-0@@ -40,6 +40,30 @@#include "amdgpu_gem.h" #include "amdgpu_display.h" +static void amdgpu_unregister_gpu_instance (struct amdgpu_device *adev) +{ +struct amdgpu_gpu_instance *gpu_instance; +int i; + +mutex_lock (&mgpu_info.mutex); + +for (i =0 ; i < mgpu_info.num_gpu; i++) { + gpu_instance = &(mgpu_info.gpu_ins[i]); +if (gpu_instance->adev == adev) { + mgpu_info.gpu_ins[i] = + mgpu_info.gpu_ins[mgpu_info.num_gpu -1 ]; + mgpu_info.num_gpu--; +if (adev->flags &AMD_IS_APU ) + mgpu_info.num_apu--; +else + mgpu_info.num_dgpu--; +break ; + } + } + +mutex_unlock (&mgpu_info.mutex); +} +/** * amdgpu_driver_unload_kms - Main unload function for KMS. * @@ -55,6 +79,8 @@ void amdgpu_driver_unload_kms(struct drm_device *dev)if (adev ==NULL )return ; +amdgpu_unregister_gpu_instance (adev); +if (adev->rmmio ==NULL ) goto done_free;@@ -75,6 +101,31 @@ void amdgpu_driver_unload_kms(struct drm_device *dev) dev->dev_private =NULL ; } +static void amdgpu_register_gpu_instance (struct amdgpu_device *adev) +{ +struct amdgpu_gpu_instance *gpu_instance; + +mutex_lock (&mgpu_info.mutex); + +if (mgpu_info.num_gpu >=MAX_GPU_INSTANCE ) { +DRM_ERROR ("Cannot register more gpu instance\n" ); +mutex_unlock (&mgpu_info.mutex); +return ; + } + + gpu_instance = &(mgpu_info.gpu_ins[mgpu_info.num_gpu]); + gpu_instance->adev = adev; + gpu_instance->mgpu_fan_enabled =0 ; + + mgpu_info.num_gpu++; +if (adev->flags &AMD_IS_APU ) + mgpu_info.num_apu++; +else + mgpu_info.num_dgpu++; + +mutex_unlock (&mgpu_info.mutex); +} +/** * amdgpu_driver_load_kms - Main load function for KMS. *
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) · line 226
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1
-0@@ -169,6 +220,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)pm_runtime_put_autosuspend (dev->dev); } +amdgpu_register_gpu_instance (adev); out:if (r) {/* balance pm_runtime_get_sync in amdgpu_driver_unload_kms */
_______________________________________________
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): 517a68f7-16d6-d2f3-1fbe-840563363ccf-5C7GfCeVMHo@public.gmane.org
See comments in line.
Thanks
JimQu
________________________________________
发件人: amd-gfx <[email protected]> 代表 Flora Cui <[email protected]> 发送时间: 2018年9月28日 10:46
收件人: Quan, Evan; [email protected]
抄送: Deucher, Alexander
主题: Re: [PATCH 1/3] drm/amdgpu: added AMD GPU instance counting
Quoted 53 lines · Evan Quan
Count all GPU instances from AMD(including iGPUs and dGPUs) in the system.
Change-Id If62a0873c64857a3fcdf9785557e24cb3456c12eSigned-off-by Evan Quan <[email protected]>Reviewed-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 18 +++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 7 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 52 +++++++++++++++++++++++++ 3 files changed, 77 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +18
-0@@ -81,6 +81,23 @@#include "amdgpu_bo_list.h" #include "amdgpu_gem.h" +#define MAX_GPU_INSTANCE 16 + +struct amdgpu_gpu_instance +{ +struct amdgpu_device *adev; +int mgpu_fan_enabled; +}; + +struct amdgpu_mgpu_info +{ +struct amdgpu_gpu_instance gpu_ins[MAX_GPU_INSTANCE ]; +struct mutex mutex; +uint32_t num_gpu; +uint32_t num_dgpu; +uint32_t num_apu; +}; +/* * Modules parameters. */ @@ -134,6 +151,7 @@ extern int amdgpu_compute_multipipe;extern int amdgpu_gpu_recovery;extern int amdgpu_emu_mode;extern uint amdgpu_smu_memory_pool_size; +extern struct amdgpu_mgpu_info mgpu_info;#ifdef CONFIG_DRM_AMDGPU_SI extern int amdgpu_si_support;drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c int amdgpu_compute_multipipe = -1; · line 136
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +7
-0@@ -127,6 +127,13 @@ int amdgpu_compute_multipipe = -1;int amdgpu_gpu_recovery =-1 ;/* auto */ int amdgpu_emu_mode =0 ;uint amdgpu_smu_memory_pool_size =0 ; +struct amdgpu_mgpu_info mgpu_info = { + .gpu_ins = {0 }, + .mutex =__MUTEX_INITIALIZER (mgpu_info.mutex), + .num_gpu =0 , + .num_apu =0 , + .num_dgpu =0 , +};
you could init mutex only.
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0
-0/** * DOC: vramlimit (int) drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2
-0@@ -40,6 +40,30 @@#include "amdgpu_gem.h" #include "amdgpu_display.h" +static void amdgpu_unregister_gpu_instance (struct amdgpu_device *adev) +{
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c line 54
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +10
-0+struct amdgpu_gpu_instance *gpu_instance; +int i; + +mutex_lock (&mgpu_info.mutex); + +for (i =0 ; i < mgpu_info.num_gpu; i++) { + gpu_instance = &(mgpu_info.gpu_ins[i]); +if (gpu_instance->adev == adev) { + mgpu_info.gpu_ins[i] = + mgpu_info.gpu_ins[mgpu_info.num_gpu -1 ];
What is about set gpu_instance->adev to NULL and gpu_instance->mgpu_fan_enabled to 0, like
gpu_instance->adev = NULL;gpu_instance->mgpu_fan_enabled = 0;
Thanks
JimQu
Quoted 57 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +39
-0+ mgpu_info.num_gpu--; +if (adev->flags &AMD_IS_APU ) + mgpu_info.num_apu--; +else + mgpu_info.num_dgpu--; +break ; + } + } + +mutex_unlock (&mgpu_info.mutex); +} +/** * amdgpu_driver_unload_kms - Main unload function for KMS. * @@ -55,6 +79,8 @@ void amdgpu_driver_unload_kms(struct drm_device *dev)if (adev ==NULL )return ; +amdgpu_unregister_gpu_instance (adev); +if (adev->rmmio ==NULL ) goto done_free;@@ -75,6 +101,31 @@ void amdgpu_driver_unload_kms(struct drm_device *dev) dev->dev_private =NULL ; } +static void amdgpu_register_gpu_instance (struct amdgpu_device *adev) +{ +struct amdgpu_gpu_instance *gpu_instance; + +mutex_lock (&mgpu_info.mutex); + +if (mgpu_info.num_gpu >=MAX_GPU_INSTANCE ) { +DRM_ERROR ("Cannot register more gpu instance\n" ); +mutex_unlock (&mgpu_info.mutex); +return ; + } + + gpu_instance = &(mgpu_info.gpu_ins[mgpu_info.num_gpu]); + gpu_instance->adev = adev; + gpu_instance->mgpu_fan_enabled =0 ; + + mgpu_info.num_gpu++; +if (adev->flags &AMD_IS_APU ) + mgpu_info.num_apu++; +else + mgpu_info.num_dgpu++; + +mutex_unlock (&mgpu_info.mutex); +} +/** * amdgpu_driver_load_kms - Main load function for KMS. *
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) · line 226
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1
-0@@ -169,6 +220,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)pm_runtime_put_autosuspend (dev->dev); } +amdgpu_register_gpu_instance (adev); out:if (r) {/* balance pm_runtime_get_sync in amdgpu_driver_unload_kms */
_______________________________________________
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): BYAPR12MB27918155E0B28A4618A2DB4699EC0-ZGDeBxoHBPmJmDmz9lrjRAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Quoted 119 lines
-----Original Message-----
From: Qu, Jim
Sent: 2018年9月28日 11:10
To: Cui, Flora <[email protected]>; Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: 答复: [PATCH 1/3] drm/amdgpu: added AMD GPU instance countingSee comments in line.
Thanks
JimQu________________________________________
发件人: amd-gfx <[email protected]> 代表 Flora Cui <[email protected]>
发送时间: 2018年9月28日 10:46
收件人: Quan, Evan; [email protected]
抄送: Deucher, Alexander
主题: Re: [PATCH 1/3] drm/amdgpu: added AMD GPU instance countingQuoted 10 lines · Evan Quan
Count all GPU instances from AMD(including iGPUs and dGPUs) in the system.
Change-Id If62a0873c64857a3fcdf9785557e24cb3456c12eSigned-off-by Evan Quan <[email protected]>Reviewed-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 18 +++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 7 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 52+++++++++++++++++++++++++
Quoted 45 lines
3 files changed, 77 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +18
-0@@ -81,6 +81,23 @@#include "amdgpu_bo_list.h" #include "amdgpu_gem.h" +#define MAX_GPU_INSTANCE 16 + +struct amdgpu_gpu_instance +{ +struct amdgpu_device *adev; +int mgpu_fan_enabled; +}; + +struct amdgpu_mgpu_info +{ +struct amdgpu_gpu_instance gpu_ins[MAX_GPU_INSTANCE ]; +struct mutex mutex; +uint32_t num_gpu; +uint32_t num_dgpu; +uint32_t num_apu; +}; +/* * Modules parameters. */ @@ -134,6 +151,7 @@ extern int amdgpu_compute_multipipe;extern int amdgpu_gpu_recovery;extern int amdgpu_emu_mode;extern uint amdgpu_smu_memory_pool_size; +extern struct amdgpu_mgpu_info mgpu_info;#ifdef CONFIG_DRM_AMDGPU_SI extern int amdgpu_si_support;drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c int amdgpu_compute_multipipe = -1; · line 136
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +7
-0@@ -127,6 +127,13 @@ int amdgpu_compute_multipipe = -1;int amdgpu_gpu_recovery =-1 ;/* auto */ int amdgpu_emu_mode =0 ;uint amdgpu_smu_memory_pool_size =0 ; +struct amdgpu_mgpu_info mgpu_info = { + .gpu_ins = {0 }, + .mutex =__MUTEX_INITIALIZER (mgpu_info.mutex), + .num_gpu =0 , + .num_apu =0 , + .num_dgpu =0 , +};you could init mutex only.
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0
-0/** * DOC: vramlimit (int) drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +3
-0@@ -40,6 +40,30 @@#include "amdgpu_gem.h" #include "amdgpu_display.h" +static void amdgpu_unregister_gpu_instance (struct amdgpu_device +*adev) { +struct amdgpu_gpu_instance *gpu_instance;drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c line 55
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +10
-0+int i; + +mutex_lock (&mgpu_info.mutex); + +for (i =0 ; i < mgpu_info.num_gpu; i++) { + gpu_instance = &(mgpu_info.gpu_ins[i]); +if (gpu_instance->adev == adev) { + mgpu_info.gpu_ins[i] = + mgpu_info.gpu_ins[mgpu_info.num_gpu - +1 ];What is about set
gpu_instance->adevto NULL and gpu_instance-
Quoted 5 lines
Quoted 1 line
mgpu_fan_enabledto 0, like
gpu_instance->adev= NULL;gpu_instance->mgpu_fan_enabled= 0;
[Quan, Evan] This is done intentionally. Otherwise, if the instance to unregister is Located in middle of the array, with num_gpu-- we will lost the last instance.
Regards,
Evan
Quoted 72 lines
Thanks
JimQudrivers/gpu/drm/amd/amdgpu/amdgpu_kms.c void amdgpu_driver_unload_kms(struct drm_device
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +12
-0+ mgpu_info.num_gpu--; +if (adev->flags &AMD_IS_APU ) + mgpu_info.num_apu--; +else + mgpu_info.num_dgpu--; +break ; + } + } + +mutex_unlock (&mgpu_info.mutex); +} +/** * amdgpu_driver_unload_kms - Main unload function for KMS. * @@ -55,6 +79,8 @@ void amdgpu_driver_unload_kms(struct drm_device*dev)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c void amdgpu_driver_unload_kms(struct
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2
-0if (adev ==NULL )return ; +amdgpu_unregister_gpu_instance (adev); +if (adev->rmmio ==NULL ) goto done_free;@@ -75,6 +101,31 @@ void amdgpu_driver_unload_kms(struct
drm_device*dev)drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_driver_load_kms(struct drm_device
Quoted 32 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +25
-0dev->dev_private =NULL ; } +static void amdgpu_register_gpu_instance (struct amdgpu_device *adev) +{ +struct amdgpu_gpu_instance *gpu_instance; + +mutex_lock (&mgpu_info.mutex); + +if (mgpu_info.num_gpu >=MAX_GPU_INSTANCE ) { +DRM_ERROR ("Cannot register more gpu instance\n" ); +mutex_unlock (&mgpu_info.mutex); +return ; + } + + gpu_instance = &(mgpu_info.gpu_ins[mgpu_info.num_gpu]); + gpu_instance->adev = adev; + gpu_instance->mgpu_fan_enabled =0 ; + + mgpu_info.num_gpu++; +if (adev->flags &AMD_IS_APU ) + mgpu_info.num_apu++; +else + mgpu_info.num_dgpu++; + +mutex_unlock (&mgpu_info.mutex); +} +/** * amdgpu_driver_load_kms - Main load function for KMS. * @@ -169,6 +220,7 @@ int amdgpu_driver_load_kms(struct drm_device*dev, unsigned long flags)
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1
-0pm_runtime_put_autosuspend (dev->dev); } +amdgpu_register_gpu_instance (adev); out:if (r) {/* balance pm_runtime_get_sync in
amdgpu_driver_unload_kms*/
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
Thanks. Will get it updated.
Regards,
Evan
Quoted 161 lines
-----Original Message-----
From: Cui, Flora
Sent: 2018年9月28日 10:47
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH 1/3] drm/amdgpu: added AMD GPU instance countingQuoted 10 lines · Evan Quan
Count all GPU instances from AMD(including iGPUs and dGPUs) in the system.
Change-Id If62a0873c64857a3fcdf9785557e24cb3456c12eSigned-off-by Evan Quan <[email protected]>Reviewed-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 18 +++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 7 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 52+++++++++++++++++++++++++
Quoted 45 lines
3 files changed, 77 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +18
-0@@ -81,6 +81,23 @@#include "amdgpu_bo_list.h" #include "amdgpu_gem.h" +#define MAX_GPU_INSTANCE 16 + +struct amdgpu_gpu_instance +{ +struct amdgpu_device *adev; +int mgpu_fan_enabled; +}; + +struct amdgpu_mgpu_info +{ +struct amdgpu_gpu_instance gpu_ins[MAX_GPU_INSTANCE ]; +struct mutex mutex; +uint32_t num_gpu; +uint32_t num_dgpu; +uint32_t num_apu; +}; +/* * Modules parameters. */ @@ -134,6 +151,7 @@ extern int amdgpu_compute_multipipe;extern int amdgpu_gpu_recovery;extern int amdgpu_emu_mode;extern uint amdgpu_smu_memory_pool_size; +extern struct amdgpu_mgpu_info mgpu_info;#ifdef CONFIG_DRM_AMDGPU_SI extern int amdgpu_si_support;drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c int amdgpu_compute_multipipe = -1; · line 136
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +7
-0@@ -127,6 +127,13 @@ int amdgpu_compute_multipipe = -1;int amdgpu_gpu_recovery =-1 ;/* auto */ int amdgpu_emu_mode =0 ;uint amdgpu_smu_memory_pool_size =0 ; +struct amdgpu_mgpu_info mgpu_info = { + .gpu_ins = {0 }, + .mutex =__MUTEX_INITIALIZER (mgpu_info.mutex), + .num_gpu =0 , + .num_apu =0 , + .num_dgpu =0 , +};you could init mutex only.
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c void amdgpu_driver_unload_kms(struct drm_device
Quoted 40 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0
-0/** * DOC: vramlimit (int) drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +24
-0@@ -40,6 +40,30 @@#include "amdgpu_gem.h" #include "amdgpu_display.h" +static void amdgpu_unregister_gpu_instance (struct amdgpu_device +*adev) { +struct amdgpu_gpu_instance *gpu_instance; +int i; + +mutex_lock (&mgpu_info.mutex); + +for (i =0 ; i < mgpu_info.num_gpu; i++) { + gpu_instance = &(mgpu_info.gpu_ins[i]); +if (gpu_instance->adev == adev) { + mgpu_info.gpu_ins[i] = + mgpu_info.gpu_ins[mgpu_info.num_gpu -1 ]; + mgpu_info.num_gpu--; +if (adev->flags &AMD_IS_APU ) + mgpu_info.num_apu--; +else + mgpu_info.num_dgpu--; +break ; + } + } + +mutex_unlock (&mgpu_info.mutex); +} +/** * amdgpu_driver_unload_kms - Main unload function for KMS. * @@ -55,6 +79,8 @@ void amdgpu_driver_unload_kms(struct drm_device*dev)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c void amdgpu_driver_unload_kms(struct
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2
-0if (adev ==NULL )return ; +amdgpu_unregister_gpu_instance (adev); +if (adev->rmmio ==NULL ) goto done_free;@@ -75,6 +101,31 @@ void amdgpu_driver_unload_kms(struct
drm_device*dev)drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_driver_load_kms(struct drm_device
Quoted 32 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +25
-0dev->dev_private =NULL ; } +static void amdgpu_register_gpu_instance (struct amdgpu_device *adev) +{ +struct amdgpu_gpu_instance *gpu_instance; + +mutex_lock (&mgpu_info.mutex); + +if (mgpu_info.num_gpu >=MAX_GPU_INSTANCE ) { +DRM_ERROR ("Cannot register more gpu instance\n" ); +mutex_unlock (&mgpu_info.mutex); +return ; + } + + gpu_instance = &(mgpu_info.gpu_ins[mgpu_info.num_gpu]); + gpu_instance->adev = adev; + gpu_instance->mgpu_fan_enabled =0 ; + + mgpu_info.num_gpu++; +if (adev->flags &AMD_IS_APU ) + mgpu_info.num_apu++; +else + mgpu_info.num_dgpu++; + +mutex_unlock (&mgpu_info.mutex); +} +/** * amdgpu_driver_load_kms - Main load function for KMS. * @@ -169,6 +220,7 @@ int amdgpu_driver_load_kms(struct drm_device*dev, unsigned long flags)
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1
-0pm_runtime_put_autosuspend (dev->dev); } +amdgpu_register_gpu_instance (adev); out:if (r) {/* balance pm_runtime_get_sync in
amdgpu_driver_unload_kms*/
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx