All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Wang, Yang(Kevin)" <KevinYang.Wang@amd.com>
To: "Ma, Jun" <Jun.Ma2@amd.com>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>
Cc: "Feng, Kenneth" <Kenneth.Feng@amd.com>,
	"Deucher, Alexander" <Alexander.Deucher@amd.com>,
	"Koenig, Christian" <Christian.Koenig@amd.com>
Subject: RE: [PATCH 1/5] drm/amdgpu/pm: Fix the null pointer dereference for smu7
Date: Tue, 14 May 2024 02:15:39 +0000	[thread overview]
Message-ID: <PH7PR12MB599734B78CA864DE96A35DCE82E32@PH7PR12MB5997.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20240513085616.584249-1-Jun.Ma2@amd.com>

[AMD Official Use Only - AMD Internal Distribution Only]

Reviewed-by: Yang Wang <kevinyang.wang@amd.com>

Best Regards,
Kevin

-----Original Message-----
From: Ma, Jun <Jun.Ma2@amd.com>
Sent: Monday, May 13, 2024 4:56 PM
To: amd-gfx@lists.freedesktop.org
Cc: Feng, Kenneth <Kenneth.Feng@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Wang, Yang(Kevin) <KevinYang.Wang@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; Ma, Jun <Jun.Ma2@amd.com>
Subject: [PATCH 1/5] drm/amdgpu/pm: Fix the null pointer dereference for smu7

optimize the code to avoid pass a null pointer (hwmgr->backend) to function smu7_update_edc_leakage_table.

Signed-off-by: Ma Jun <Jun.Ma2@amd.com>
---
 .../drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c   | 50 +++++++++----------
 1 file changed, 24 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
index 123af237878f..632a25957477 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
@@ -2957,6 +2957,7 @@ static int smu7_update_edc_leakage_table(struct pp_hwmgr *hwmgr)

 static int smu7_hwmgr_backend_init(struct pp_hwmgr *hwmgr)  {
+       struct amdgpu_device *adev = hwmgr->adev;
        struct smu7_hwmgr *data;
        int result = 0;

@@ -2993,40 +2994,37 @@ static int smu7_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
        /* Initalize Dynamic State Adjustment Rule Settings */
        result = phm_initializa_dynamic_state_adjustment_rule_settings(hwmgr);

-       if (0 == result) {
-               struct amdgpu_device *adev = hwmgr->adev;
+       if (result)
+               goto fail;

-               data->is_tlu_enabled = false;
+       data->is_tlu_enabled = false;

-               hwmgr->platform_descriptor.hardwareActivityPerformanceLevels =
+       hwmgr->platform_descriptor.hardwareActivityPerformanceLevels =
                                                        SMU7_MAX_HARDWARE_POWERLEVELS;
-               hwmgr->platform_descriptor.hardwarePerformanceLevels = 2;
-               hwmgr->platform_descriptor.minimumClocksReductionPercentage = 50;
+       hwmgr->platform_descriptor.hardwarePerformanceLevels = 2;
+       hwmgr->platform_descriptor.minimumClocksReductionPercentage = 50;

-               data->pcie_gen_cap = adev->pm.pcie_gen_mask;
-               if (data->pcie_gen_cap & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3)
-                       data->pcie_spc_cap = 20;
-               else
-                       data->pcie_spc_cap = 16;
-               data->pcie_lane_cap = adev->pm.pcie_mlw_mask;
-
-               hwmgr->platform_descriptor.vbiosInterruptId = 0x20000400; /* IRQ_SOURCE1_SW_INT */
-/* The true clock step depends on the frequency, typically 4.5 or 9 MHz. Here we use 5. */
-               hwmgr->platform_descriptor.clockStep.engineClock = 500;
-               hwmgr->platform_descriptor.clockStep.memoryClock = 500;
-               smu7_thermal_parameter_init(hwmgr);
-       } else {
-               /* Ignore return value in here, we are cleaning up a mess. */
-               smu7_hwmgr_backend_fini(hwmgr);
-       }
+       data->pcie_gen_cap = adev->pm.pcie_gen_mask;
+       if (data->pcie_gen_cap & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3)
+               data->pcie_spc_cap = 20;
+       else
+               data->pcie_spc_cap = 16;
+       data->pcie_lane_cap = adev->pm.pcie_mlw_mask;
+
+       hwmgr->platform_descriptor.vbiosInterruptId = 0x20000400; /* IRQ_SOURCE1_SW_INT */
+       /* The true clock step depends on the frequency, typically 4.5 or 9 MHz. Here we use 5. */
+       hwmgr->platform_descriptor.clockStep.engineClock = 500;
+       hwmgr->platform_descriptor.clockStep.memoryClock = 500;
+       smu7_thermal_parameter_init(hwmgr);

        result = smu7_update_edc_leakage_table(hwmgr);
-       if (result) {
-               smu7_hwmgr_backend_fini(hwmgr);
-               return result;
-       }
+       if (result)
+               goto fail;

        return 0;
+fail:
+       smu7_hwmgr_backend_fini(hwmgr);
+       return result;
 }

 static int smu7_force_dpm_highest(struct pp_hwmgr *hwmgr)
--
2.34.1


      parent reply	other threads:[~2024-05-14  2:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-13  8:56 [PATCH 1/5] drm/amdgpu/pm: Fix the null pointer dereference for smu7 Ma Jun
2024-05-13  8:56 ` [PATCH 2/5] drm/amdgpu: Fix the null pointer dereference to ras_manager Ma Jun
2024-05-13 10:21   ` Lazar, Lijo
2024-05-13  8:56 ` [PATCH 3/5] drm/amdgpu: Fix null pointer dereference to aca_handle Ma Jun
2024-05-13 10:25   ` Lazar, Lijo
2024-05-13 23:13   ` Wang, Yang(Kevin)
2024-05-14  1:00     ` Ma, Jun
2024-05-14  4:18       ` Lazar, Lijo
2024-05-13  8:56 ` [PATCH 4/5] drm/amdgpu: Fix null pointer dereference to bo Ma Jun
2024-05-13 12:40   ` Christian König
2024-05-13  8:56 ` [PATCH 5/5] drm/amdgpu: Remove dead code in amdgpu_ras_add_mca_err_addr Ma Jun
2024-05-14  1:52   ` Chai, Thomas
2024-05-14  2:15 ` Wang, Yang(Kevin) [this message]

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=PH7PR12MB599734B78CA864DE96A35DCE82E32@PH7PR12MB5997.namprd12.prod.outlook.com \
    --to=kevinyang.wang@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Christian.Koenig@amd.com \
    --cc=Jun.Ma2@amd.com \
    --cc=Kenneth.Feng@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.