diff options
author | Rex Zhu <Rex.Zhu@amd.com> | 2018-07-27 09:06:30 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-08-27 12:09:52 -0400 |
commit | 1e317b99f0c244bd8830918fdae9715210baf4fe (patch) | |
tree | 1a58b47f1992f10d20c7d0ce21971ad1b993258b | |
parent | d23ee13fba23a3039971a976b2c4857cb5ba9c73 (diff) |
drm/amdgpu: Put enable gfx off feature to a delay thread
delay to enable gfx off feature to avoid gfx on/off frequently
suggested by Alex and Evan.
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 15 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 8 |
3 files changed, 23 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 47fbe8f54036..6a8ed9b5d4fd 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -954,6 +954,8 @@ struct amdgpu_gfx { | |||
954 | bool gfx_off_state; /* true: enabled, false: disabled */ | 954 | bool gfx_off_state; /* true: enabled, false: disabled */ |
955 | struct mutex gfx_off_mutex; | 955 | struct mutex gfx_off_mutex; |
956 | uint32_t gfx_off_req_count; /* default 1, enable gfx off: dec 1, disable gfx off: add 1 */ | 956 | uint32_t gfx_off_req_count; /* default 1, enable gfx off: dec 1, disable gfx off: add 1 */ |
957 | struct delayed_work gfx_off_delay_work; | ||
958 | |||
957 | /* pipe reservation */ | 959 | /* pipe reservation */ |
958 | struct mutex pipe_reserve_mutex; | 960 | struct mutex pipe_reserve_mutex; |
959 | DECLARE_BITMAP (pipe_reserve_bitmap, AMDGPU_MAX_COMPUTE_QUEUES); | 961 | DECLARE_BITMAP (pipe_reserve_bitmap, AMDGPU_MAX_COMPUTE_QUEUES); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 2068b7fe7523..82bc329919fe 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -1925,6 +1925,19 @@ static void amdgpu_device_ip_late_init_func_handler(struct work_struct *work) | |||
1925 | DRM_ERROR("ib ring test failed (%d).\n", r); | 1925 | DRM_ERROR("ib ring test failed (%d).\n", r); |
1926 | } | 1926 | } |
1927 | 1927 | ||
1928 | static void amdgpu_device_delay_enable_gfx_off(struct work_struct *work) | ||
1929 | { | ||
1930 | struct amdgpu_device *adev = | ||
1931 | container_of(work, struct amdgpu_device, gfx.gfx_off_delay_work.work); | ||
1932 | |||
1933 | mutex_lock(&adev->gfx.gfx_off_mutex); | ||
1934 | if (!adev->gfx.gfx_off_state && !adev->gfx.gfx_off_req_count) { | ||
1935 | if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true)) | ||
1936 | adev->gfx.gfx_off_state = true; | ||
1937 | } | ||
1938 | mutex_unlock(&adev->gfx.gfx_off_mutex); | ||
1939 | } | ||
1940 | |||
1928 | /** | 1941 | /** |
1929 | * amdgpu_device_ip_suspend_phase1 - run suspend for hardware IPs (phase 1) | 1942 | * amdgpu_device_ip_suspend_phase1 - run suspend for hardware IPs (phase 1) |
1930 | * | 1943 | * |
@@ -2394,6 +2407,8 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2394 | 2407 | ||
2395 | INIT_DELAYED_WORK(&adev->late_init_work, | 2408 | INIT_DELAYED_WORK(&adev->late_init_work, |
2396 | amdgpu_device_ip_late_init_func_handler); | 2409 | amdgpu_device_ip_late_init_func_handler); |
2410 | INIT_DELAYED_WORK(&adev->gfx.gfx_off_delay_work, | ||
2411 | amdgpu_device_delay_enable_gfx_off); | ||
2397 | 2412 | ||
2398 | adev->gfx.gfx_off_req_count = 1; | 2413 | adev->gfx.gfx_off_req_count = 1; |
2399 | adev->pm.ac_power = power_supply_is_system_supplied() > 0 ? true : false; | 2414 | adev->pm.ac_power = power_supply_is_system_supplied() > 0 ? true : false; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c index 1cdb26471a03..11d4d9f93b95 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | |||
@@ -26,6 +26,9 @@ | |||
26 | #include "amdgpu.h" | 26 | #include "amdgpu.h" |
27 | #include "amdgpu_gfx.h" | 27 | #include "amdgpu_gfx.h" |
28 | 28 | ||
29 | /* 0.5 second timeout */ | ||
30 | #define GFX_OFF_DELAY_ENABLE msecs_to_jiffies(500) | ||
31 | |||
29 | /* | 32 | /* |
30 | * GPU scratch registers helpers function. | 33 | * GPU scratch registers helpers function. |
31 | */ | 34 | */ |
@@ -360,6 +363,7 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, bool enable) | |||
360 | if (!adev->powerplay.pp_funcs->set_powergating_by_smu) | 363 | if (!adev->powerplay.pp_funcs->set_powergating_by_smu) |
361 | return; | 364 | return; |
362 | 365 | ||
366 | |||
363 | mutex_lock(&adev->gfx.gfx_off_mutex); | 367 | mutex_lock(&adev->gfx.gfx_off_mutex); |
364 | 368 | ||
365 | if (!enable) | 369 | if (!enable) |
@@ -368,11 +372,11 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, bool enable) | |||
368 | adev->gfx.gfx_off_req_count--; | 372 | adev->gfx.gfx_off_req_count--; |
369 | 373 | ||
370 | if (enable && !adev->gfx.gfx_off_state && !adev->gfx.gfx_off_req_count) { | 374 | if (enable && !adev->gfx.gfx_off_state && !adev->gfx.gfx_off_req_count) { |
371 | if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true)) | 375 | schedule_delayed_work(&adev->gfx.gfx_off_delay_work, GFX_OFF_DELAY_ENABLE); |
372 | adev->gfx.gfx_off_state = true; | ||
373 | } else if (!enable && adev->gfx.gfx_off_state) { | 376 | } else if (!enable && adev->gfx.gfx_off_state) { |
374 | if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, false)) | 377 | if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, false)) |
375 | adev->gfx.gfx_off_state = false; | 378 | adev->gfx.gfx_off_state = false; |
376 | } | 379 | } |
380 | |||
377 | mutex_unlock(&adev->gfx.gfx_off_mutex); | 381 | mutex_unlock(&adev->gfx.gfx_off_mutex); |
378 | } | 382 | } |