AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Evan Quan <evan.quan@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Alexander.Deucher@amd.com, Lijo.Lazar@amd.com,
	Evan Quan <evan.quan@amd.com>,
	rui.huang@amd.com
Subject: [PATCH 09/12] drm/amd/pm: drop redundant !pp_funcs check
Date: Fri, 11 Feb 2022 15:52:06 +0800	[thread overview]
Message-ID: <20220211075209.894833-9-evan.quan@amd.com> (raw)
In-Reply-To: <20220211075209.894833-1-evan.quan@amd.com>

As it can be covered by the "!adev->pm.dpm_enabled" check. As long as
"adev->pm.dpm_enabled != NULL", "pp_funcs != NULL" can be also guarded.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Change-Id: Iec801f18a0069ad5fd384c4133016977fb2b67e8
---
 drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
index 5f1d3342f87b..f237dd3a3f66 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
@@ -104,7 +104,7 @@ int amdgpu_dpm_set_powergating_by_smu(struct amdgpu_device *adev, uint32_t block
 	case AMD_IP_BLOCK_TYPE_JPEG:
 	case AMD_IP_BLOCK_TYPE_GMC:
 	case AMD_IP_BLOCK_TYPE_ACP:
-		if (pp_funcs && pp_funcs->set_powergating_by_smu)
+		if (pp_funcs->set_powergating_by_smu)
 			ret = (pp_funcs->set_powergating_by_smu(
 				(adev)->powerplay.pp_handle, block_type, gate));
 		break;
@@ -314,7 +314,7 @@ int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev,
 	if (amdgpu_sriov_vf(adev))
 		return 0;
 
-	if (pp_funcs && pp_funcs->switch_power_profile) {
+	if (pp_funcs->switch_power_profile) {
 		mutex_lock(&adev->pm.mutex);
 		ret = pp_funcs->switch_power_profile(
 			adev->powerplay.pp_handle, type, en);
@@ -333,7 +333,7 @@ int amdgpu_dpm_set_xgmi_pstate(struct amdgpu_device *adev,
 	if (!adev->pm.dpm_enabled)
 		return -EOPNOTSUPP;
 
-	if (pp_funcs && pp_funcs->set_xgmi_pstate) {
+	if (pp_funcs->set_xgmi_pstate) {
 		mutex_lock(&adev->pm.mutex);
 		ret = pp_funcs->set_xgmi_pstate(adev->powerplay.pp_handle,
 								pstate);
@@ -353,7 +353,7 @@ int amdgpu_dpm_set_df_cstate(struct amdgpu_device *adev,
 	if (!adev->pm.dpm_enabled)
 		return -EOPNOTSUPP;
 
-	if (pp_funcs && pp_funcs->set_df_cstate) {
+	if (pp_funcs->set_df_cstate) {
 		mutex_lock(&adev->pm.mutex);
 		ret = pp_funcs->set_df_cstate(pp_handle, cstate);
 		mutex_unlock(&adev->pm.mutex);
@@ -389,7 +389,7 @@ int amdgpu_dpm_enable_mgpu_fan_boost(struct amdgpu_device *adev)
 	if (!adev->pm.dpm_enabled)
 		return -EOPNOTSUPP;
 
-	if (pp_funcs && pp_funcs->enable_mgpu_fan_boost) {
+	if (pp_funcs->enable_mgpu_fan_boost) {
 		mutex_lock(&adev->pm.mutex);
 		ret = pp_funcs->enable_mgpu_fan_boost(pp_handle);
 		mutex_unlock(&adev->pm.mutex);
@@ -409,7 +409,7 @@ int amdgpu_dpm_set_clockgating_by_smu(struct amdgpu_device *adev,
 	if (!adev->pm.dpm_enabled)
 		return -EOPNOTSUPP;
 
-	if (pp_funcs && pp_funcs->set_clockgating_by_smu) {
+	if (pp_funcs->set_clockgating_by_smu) {
 		mutex_lock(&adev->pm.mutex);
 		ret = pp_funcs->set_clockgating_by_smu(pp_handle,
 						       msg_id);
@@ -430,7 +430,7 @@ int amdgpu_dpm_smu_i2c_bus_access(struct amdgpu_device *adev,
 	if (!adev->pm.dpm_enabled)
 		return -EOPNOTSUPP;
 
-	if (pp_funcs && pp_funcs->smu_i2c_bus_access) {
+	if (pp_funcs->smu_i2c_bus_access) {
 		mutex_lock(&adev->pm.mutex);
 		ret = pp_funcs->smu_i2c_bus_access(pp_handle,
 						   acquire);
@@ -449,8 +449,7 @@ void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev)
 		else
 			adev->pm.ac_power = false;
 
-		if (adev->powerplay.pp_funcs &&
-		    adev->powerplay.pp_funcs->enable_bapm)
+		if (adev->powerplay.pp_funcs->enable_bapm)
 			amdgpu_dpm_enable_bapm(adev, adev->pm.ac_power);
 
 		if (is_support_sw_smu(adev))
@@ -472,7 +471,7 @@ int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors senso
 	if (!data || !size)
 		return -EINVAL;
 
-	if (pp_funcs && pp_funcs->read_sensor) {
+	if (pp_funcs->read_sensor) {
 		mutex_lock(&adev->pm.mutex);
 		ret = pp_funcs->read_sensor(adev->powerplay.pp_handle,
 					    sensor,
@@ -719,8 +718,7 @@ void amdgpu_dpm_gfx_state_change(struct amdgpu_device *adev,
 		return;
 
 	mutex_lock(&adev->pm.mutex);
-	if (adev->powerplay.pp_funcs &&
-	    adev->powerplay.pp_funcs->gfx_state_change_set)
+	if (adev->powerplay.pp_funcs->gfx_state_change_set)
 		((adev)->powerplay.pp_funcs->gfx_state_change_set(
 			(adev)->powerplay.pp_handle, state));
 	mutex_unlock(&adev->pm.mutex);
-- 
2.29.0


  parent reply	other threads:[~2022-02-11  7:53 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-11  7:51 [PATCH 01/12] drm/amd/pm: drop unused structure members Evan Quan
2022-02-11  7:51 ` [PATCH 02/12] drm/amd/pm: drop unused interfaces Evan Quan
2022-02-11  7:52 ` [PATCH 03/12] drm/amd/pm: drop unneeded !smu->pm_enabled check Evan Quan
2022-02-11  7:52 ` [PATCH 04/12] drm/amd/pm: use adev->pm.dpm_enabled for dpm enablement check Evan Quan
2022-02-11  7:52 ` [PATCH 05/12] drm/amd/pm: move the check for dpm enablement to amdgpu_dpm.c Evan Quan
2022-02-11  8:06   ` Chen, Guchun
2022-02-17  1:53     ` Quan, Evan
2022-02-11 13:39   ` Lazar, Lijo
2022-02-17  2:35     ` Quan, Evan
2022-02-17  4:55       ` Lazar, Lijo
2022-02-11  7:52 ` [PATCH 06/12] drm/amd/pm: correct the checks for sriov(pp_one_vf) Evan Quan
2022-02-11  7:52 ` [PATCH 07/12] drm/amd/pm: correct the checks for granting gpu reset APIs Evan Quan
2022-02-14  4:04   ` Lazar, Lijo
2022-02-17  2:48     ` Quan, Evan
2022-02-17  5:00       ` Lazar, Lijo
2022-02-11  7:52 ` [PATCH 08/12] drm/amd/pm: add proper check for amdgpu_dpm before granting pp_dpm_load_fw Evan Quan
2022-02-11  7:52 ` Evan Quan [this message]
2022-02-11  7:52 ` [PATCH 10/12] drm/amd/pm: drop nonsense !smu->ppt_funcs check Evan Quan
2022-02-11  7:52 ` [PATCH 11/12] drm/amd/pm: drop extra non-necessary null pointers checks Evan Quan
2022-02-11  7:52 ` [PATCH 12/12] drm/amd/pm: revise the implementations for asic reset Evan Quan
2022-02-11 13:21   ` Lazar, Lijo
2022-02-17  2:53     ` Quan, Evan
2022-02-11  7:55 ` [PATCH 01/12] drm/amd/pm: drop unused structure members Christian König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220211075209.894833-9-evan.quan@amd.com \
    --to=evan.quan@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Lijo.Lazar@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=rui.huang@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox