diff options
| author | Rex Zhu <Rex.Zhu@amd.com> | 2018-06-13 19:30:40 +0800 | 
|---|---|---|
| committer | Alex Deucher <alexander.deucher@amd.com> | 2018-07-05 16:38:50 -0500 | 
| commit | c9f96fd5063150dce7e71ecc508989f5ff055039 (patch) | |
| tree | edc886c6dc9c7e6deb99dc26b646661a5e498119 /drivers/gpu/drm/amd/amdgpu | |
| parent | 9134c6d7f288f902d932e7cf57fab2f49e8ad70b (diff) | |
drm/amdgpu: Split set_pg_state into separate function
1. add amdgpu_device_ip_late_set_pg_state function for
   set pg state.
2. delete duplicate pg state setting on gfx_v8_0's late_init.
Reviewed-by: Evan Quan <evan.quan@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 | ||||
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 4 | 
2 files changed, 28 insertions, 9 deletions
| diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index c33a41ace028..e38564e7c5ec 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -1730,12 +1730,34 @@ static int amdgpu_device_ip_late_set_cg_state(struct amdgpu_device *adev)  		}  	} -	if (adev->powerplay.pp_feature & PP_GFXOFF_MASK) -		/* enable gfx powergating */ -		amdgpu_device_ip_set_powergating_state(adev, -						       AMD_IP_BLOCK_TYPE_GFX, -						       AMD_PG_STATE_GATE); +	return 0; +} + +static int amdgpu_device_ip_late_set_pg_state(struct amdgpu_device *adev) +{ +	int i = 0, r; +	if (amdgpu_emu_mode == 1) +		return 0; + +	for (i = 0; i < adev->num_ip_blocks; i++) { +		if (!adev->ip_blocks[i].status.valid) +			continue; +		/* skip CG for VCE/UVD, it's handled specially */ +		if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_UVD && +		    adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_VCE && +		    adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_VCN && +		    adev->ip_blocks[i].version->funcs->set_powergating_state) { +			/* enable powergating to save power */ +			r = adev->ip_blocks[i].version->funcs->set_powergating_state((void *)adev, +										     AMD_PG_STATE_GATE); +			if (r) { +				DRM_ERROR("set_powergating_state(gate) of IP block <%s> failed %d\n", +					  adev->ip_blocks[i].version->funcs->name, r); +				return r; +			} +		} +	}  	return 0;  } @@ -1898,6 +1920,7 @@ static void amdgpu_device_ip_late_init_func_handler(struct work_struct *work)  	struct amdgpu_device *adev =  		container_of(work, struct amdgpu_device, late_init_work.work);  	amdgpu_device_ip_late_set_cg_state(adev); +	amdgpu_device_ip_late_set_pg_state(adev);  }  /** diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c index e69fbc944956..551f21bad6d3 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c @@ -5596,10 +5596,6 @@ static int gfx_v8_0_late_init(void *handle)  		return r;  	} -	amdgpu_device_ip_set_powergating_state(adev, -					       AMD_IP_BLOCK_TYPE_GFX, -					       AMD_PG_STATE_GATE); -  	return 0;  } | 
