[AMD Official Use Only - Internal Distribution Only]

Reviewed-by: Harish Kasiviswanathan <harish.kasiviswanat...@amd.com>

-----Original Message-----
From: amd-gfx <amd-gfx-boun...@lists.freedesktop.org> On Behalf Of Jonathan Kim
Sent: Tuesday, September 8, 2020 9:06 AM
To: amd-gfx@lists.freedesktop.org
Cc: Kuehling, Felix <felix.kuehl...@amd.com>; Kim, Jonathan 
<jonathan....@amd.com>
Subject: [PATCH 1/4] drm/amdgpu: stop resetting xgmi perfmons on disable

Disabling perf events does not specify reset in ABI so stop doing it in
hardware.

Signed-off-by: Jonathan Kim <jonathan....@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_df.h |  4 ++--
 drivers/gpu/drm/amd/amdgpu/df_v3_6.c   | 23 ++++++++++++++---------
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_df.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_df.h
index 61a26c15c8dd..373cdebe0e2f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_df.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_df.h
@@ -44,9 +44,9 @@ struct amdgpu_df_funcs {
        void (*enable_ecc_force_par_wr_rmw)(struct amdgpu_device *adev,
                                            bool enable);
        int (*pmc_start)(struct amdgpu_device *adev, uint64_t config,
-                                        int is_enable);
+                                        int is_add);
        int (*pmc_stop)(struct amdgpu_device *adev, uint64_t config,
-                                        int is_disable);
+                                        int is_remove);
        void (*pmc_get_count)(struct amdgpu_device *adev, uint64_t config,
                                         uint64_t *count);
        uint64_t (*get_fica)(struct amdgpu_device *adev, uint32_t ficaa_val);
diff --git a/drivers/gpu/drm/amd/amdgpu/df_v3_6.c 
b/drivers/gpu/drm/amd/amdgpu/df_v3_6.c
index 2eab808fffeb..7b89fd2aa44a 100644
--- a/drivers/gpu/drm/amd/amdgpu/df_v3_6.c
+++ b/drivers/gpu/drm/amd/amdgpu/df_v3_6.c
@@ -455,7 +455,8 @@ static int df_v3_6_pmc_get_ctrl_settings(struct 
amdgpu_device *adev,
                                          uint32_t *lo_base_addr,
                                          uint32_t *hi_base_addr,
                                          uint32_t *lo_val,
-                                         uint32_t *hi_val)
+                                         uint32_t *hi_val,
+                                         bool is_enable)
 {
 
        uint32_t eventsel, instance, unitmask;
@@ -477,7 +478,8 @@ static int df_v3_6_pmc_get_ctrl_settings(struct 
amdgpu_device *adev,
        instance_5432 = (instance >> 2) & 0xf;
        instance_76 = (instance >> 6) & 0x3;
 
-       *lo_val = (unitmask << 8) | (instance_10 << 6) | eventsel | (1 << 22);
+       *lo_val = (unitmask << 8) | (instance_10 << 6) | eventsel;
+       *lo_val = is_enable ? *lo_val | (1 << 22) : *lo_val & ~(1 << 22);
        *hi_val = (instance_76 << 29) | instance_5432;
 
        DRM_DEBUG_DRIVER("config=%llx addr=%08x:%08x val=%08x:%08x",
@@ -572,14 +574,14 @@ static void df_v3_6_reset_perfmon_cntr(struct 
amdgpu_device *adev,
 }
 
 static int df_v3_6_pmc_start(struct amdgpu_device *adev, uint64_t config,
-                            int is_enable)
+                            int is_add)
 {
        uint32_t lo_base_addr, hi_base_addr, lo_val, hi_val;
        int err = 0, ret = 0;
 
        switch (adev->asic_type) {
        case CHIP_VEGA20:
-               if (is_enable)
+               if (is_add)
                        return df_v3_6_pmc_add_cntr(adev, config);
 
                df_v3_6_reset_perfmon_cntr(adev, config);
@@ -589,7 +591,8 @@ static int df_v3_6_pmc_start(struct amdgpu_device *adev, 
uint64_t config,
                                        &lo_base_addr,
                                        &hi_base_addr,
                                        &lo_val,
-                                       &hi_val);
+                                       &hi_val,
+                                       true);
 
                if (ret)
                        return ret;
@@ -612,7 +615,7 @@ static int df_v3_6_pmc_start(struct amdgpu_device *adev, 
uint64_t config,
 }
 
 static int df_v3_6_pmc_stop(struct amdgpu_device *adev, uint64_t config,
-                           int is_disable)
+                           int is_remove)
 {
        uint32_t lo_base_addr, hi_base_addr, lo_val, hi_val;
        int ret = 0;
@@ -624,15 +627,17 @@ static int df_v3_6_pmc_stop(struct amdgpu_device *adev, 
uint64_t config,
                        &lo_base_addr,
                        &hi_base_addr,
                        &lo_val,
-                       &hi_val);
+                       &hi_val,
+                       false);
 
                if (ret)
                        return ret;
 
-               df_v3_6_reset_perfmon_cntr(adev, config);
 
-               if (is_disable)
+               if (is_remove) {
+                       df_v3_6_reset_perfmon_cntr(adev, config);
                        df_v3_6_pmc_release_cntr(adev, config);
+               }
 
                break;
        default:
-- 
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Charish.kasiviswanathan%40amd.com%7Cbaec81e867af49b73e8d08d853f80fa2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637351672173732796&amp;sdata=cd5%2BhKe%2Fz9QWs0QIH5zaTG3aWyLOUsOuViawyz9awNs%3D&amp;reserved=0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to