Remove redundant 'ptl_' prefix from amdgpu_ptl structure members
since they are already accessed through a ptl pointer, making the
prefix redundant and verbose.

Signed-off-by: Perry Yuan <[email protected]>
Reviewed-by: Yifan Zhang <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c    | 57 +++++++++++-----------
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h    | 12 ++---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c    | 12 ++---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c   | 26 +++++-----
 5 files changed, 55 insertions(+), 54 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 827fbdb81011..da7585d1c6e7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -4442,7 +4442,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
        mutex_init(&adev->virt.vf_errors.lock);
        hash_init(adev->mn_hash);
        mutex_init(&adev->psp.mutex);
-       mutex_init(&adev->psp.ptl.ptl_mutex);
+       mutex_init(&adev->psp.ptl.mutex);
        mutex_init(&adev->notifier_lock);
        mutex_init(&adev->pm.stable_pstate_ctx_lock);
        mutex_init(&adev->benchmark_mutex);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 357357523347..95af5f1d8f5b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -1267,9 +1267,9 @@ static int psp_ptl_invoke(struct psp_context *psp, u32 
req_code,
                break;
        case PSP_PTL_PERF_MON_SET:
                /* Update cached state only on success */
-               ptl->ptl_enabled = *ptl_state;
-               ptl->ptl_fmt1    = *fmt1;
-               ptl->ptl_fmt2    = *fmt2;
+               ptl->enabled = *ptl_state;
+               ptl->fmt1    = *fmt1;
+               ptl->fmt2    = *fmt2;
                break;
        }
 
@@ -1285,7 +1285,7 @@ int amdgpu_ptl_perf_monitor_ctrl(struct amdgpu_device 
*adev, u32 req_code,
 {
        uint32_t ptl_fmt1, ptl_fmt2;
        struct psp_context *psp;
-       struct amdgpu_ptl *ptl = &adev->psp.ptl;
+       struct amdgpu_ptl *ptl;
 
        if (!adev || !ptl_state || !fmt1 || !fmt2)
                return -EINVAL;
@@ -1294,6 +1294,7 @@ int amdgpu_ptl_perf_monitor_ctrl(struct amdgpu_device 
*adev, u32 req_code,
                return 0;
 
        psp = &adev->psp;
+       ptl = &psp->ptl;
 
        if (amdgpu_ip_version(adev, GC_HWIP, 0) != IP_VERSION(9, 4, 4) ||
                        psp->sos.fw_version < 0x0036081a)
@@ -1308,9 +1309,9 @@ int amdgpu_ptl_perf_monitor_ctrl(struct amdgpu_device 
*adev, u32 req_code,
         * Add check to skip if state and formats are identical to current ones
         */
        if (req_code == PSP_PTL_PERF_MON_SET &&
-                       ptl->ptl_enabled == *ptl_state &&
-                       ptl->ptl_fmt1 == ptl_fmt1 &&
-                       ptl->ptl_fmt2 == ptl_fmt2)
+                       ptl->enabled == *ptl_state &&
+                       ptl->fmt1 == ptl_fmt1 &&
+                       ptl->fmt2 == ptl_fmt2)
                return 0;
 
        return psp_ptl_invoke(psp, req_code, ptl_state, &ptl_fmt1, &ptl_fmt2);
@@ -1354,33 +1355,33 @@ static ssize_t ptl_enable_store(struct device *dev,
        uint32_t ptl_state, fmt1, fmt2;
        int ret;
 
-       mutex_lock(&ptl->ptl_mutex);
+       mutex_lock(&ptl->mutex);
        if (sysfs_streq(buf, "enabled") || sysfs_streq(buf, "1")) {
                enable = true;
        } else if (sysfs_streq(buf, "disabled") || sysfs_streq(buf, "0")) {
                enable = false;
        } else {
-               mutex_unlock(&ptl->ptl_mutex);
+               mutex_unlock(&ptl->mutex);
                return -EINVAL;
        }
 
-       fmt1 = ptl->ptl_fmt1;
-       fmt2 = ptl->ptl_fmt2;
+       fmt1 = ptl->fmt1;
+       fmt2 = ptl->fmt2;
        ptl_state = enable ? 1 : 0;
 
-       cur_enabled = READ_ONCE(psp->ptl_enabled);
+       cur_enabled = READ_ONCE(psp->enabled);
        if (cur_enabled == enable) {
-               mutex_unlock(&psp->ptl_mutex);
+               mutex_unlock(&psp->mutex);
                return count;
        }
 
        ret = amdgpu_ptl_perf_monitor_ctrl(adev, PSP_PTL_PERF_MON_SET, 
&ptl_state, &fmt1, &fmt2);
        if (ret) {
                dev_err(adev->dev, "Failed to set PTL err = %d\n", ret);
-               mutex_unlock(&ptl->ptl_mutex);
+               mutex_unlock(&ptl->mutex);
                return ret;
        }
-       mutex_unlock(&ptl->ptl_mutex);
+       mutex_unlock(&ptl->mutex);
 
        return count;
 }
@@ -1391,7 +1392,7 @@ static ssize_t ptl_enable_show(struct device *dev, struct 
device_attribute *attr
        struct amdgpu_device *adev = drm_to_adev(ddev);
        struct psp_context *psp = &adev->psp;
 
-       return sysfs_emit(buf, "%s\n", psp->ptl.ptl_enabled ? "enabled" : 
"disabled");
+       return sysfs_emit(buf, "%s\n", psp->ptl.enabled ? "enabled" : 
"disabled");
 }
 
 static ssize_t ptl_format_store(struct device *dev,
@@ -1408,13 +1409,13 @@ static ssize_t ptl_format_store(struct device *dev,
        int ret;
 
        /* Only allow format update when PTL is enabled */
-       if (!ptl->ptl_enabled)
+       if (!ptl->enabled)
                return -EPERM;
 
-       mutex_lock(&ptl->ptl_mutex);
+       mutex_lock(&ptl->mutex);
        /* Parse input, expecting "FMT1,FMT2" */
        if (sscanf(buf, "%7[^,],%7s", fmt1_str, fmt2_str) != 2) {
-               mutex_unlock(&ptl->ptl_mutex);
+               mutex_unlock(&ptl->mutex);
                return -EINVAL;
        }
 
@@ -1424,20 +1425,20 @@ static ssize_t ptl_format_store(struct device *dev,
        if (fmt1_enum >= AMDGPU_PTL_FMT_INVALID ||
                        fmt2_enum >= AMDGPU_PTL_FMT_INVALID ||
                        fmt1_enum == fmt2_enum) {
-               mutex_unlock(&ptl->ptl_mutex);
+               mutex_unlock(&ptl->mutex);
                return -EINVAL;
        }
 
-       ptl_state = ptl->ptl_enabled;
+       ptl_state = ptl->enabled;
        fmt1 = fmt1_enum;
        fmt2 = fmt2_enum;
        ret = amdgpu_ptl_perf_monitor_ctrl(adev, PSP_PTL_PERF_MON_SET, 
&ptl_state, &fmt1, &fmt2);
        if (ret) {
                dev_err(adev->dev, "Failed to update PTL err = %d\n", ret);
-               mutex_unlock(&ptl->ptl_mutex);
+               mutex_unlock(&ptl->mutex);
                return ret;
        }
-       mutex_unlock(&ptl->ptl_mutex);
+       mutex_unlock(&ptl->mutex);
 
        return count;
 }
@@ -1449,8 +1450,8 @@ static ssize_t ptl_format_show(struct device *dev, struct 
device_attribute *attr
        struct psp_context *psp = &adev->psp;
 
        return sysfs_emit(buf, "%s,%s\n",
-                       amdgpu_ptl_fmt_str[psp->ptl.ptl_fmt1],
-                       amdgpu_ptl_fmt_str[psp->ptl.ptl_fmt2]);
+                       amdgpu_ptl_fmt_str[psp->ptl.fmt1],
+                       amdgpu_ptl_fmt_str[psp->ptl.fmt2]);
 }
 
 static umode_t amdgpu_ptl_is_visible(struct kobject *kobj, struct attribute 
*attr, int idx)
@@ -1460,7 +1461,7 @@ static umode_t amdgpu_ptl_is_visible(struct kobject 
*kobj, struct attribute *att
        struct amdgpu_device *adev = drm_to_adev(ddev);
 
        /* Only show PTL sysfs files if PTL hardware is supported */
-       if (!adev->psp.ptl.ptl_hw_supported)
+       if (!adev->psp.ptl.hw_supported)
                return 0;
 
        return attr->mode;
@@ -1468,7 +1469,7 @@ static umode_t amdgpu_ptl_is_visible(struct kobject 
*kobj, struct attribute *att
 
 int amdgpu_ptl_sysfs_init(struct amdgpu_device *adev)
 {
-       if (!adev->psp.ptl.ptl_hw_supported)
+       if (!adev->psp.ptl.hw_supported)
                return 0;
 
        return sysfs_create_group(&adev->dev->kobj, &amdgpu_ptl_attr_group);
@@ -1476,7 +1477,7 @@ int amdgpu_ptl_sysfs_init(struct amdgpu_device *adev)
 
 void amdgpu_ptl_sysfs_fini(struct amdgpu_device *adev)
 {
-       if (!adev->psp.ptl.ptl_hw_supported)
+       if (!adev->psp.ptl.hw_supported)
                return;
 
        sysfs_remove_group(&adev->dev->kobj, &amdgpu_ptl_attr_group);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index d8591602b304..0997b13a5f41 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -383,13 +383,13 @@ struct psp_ptl_perf_req {
 };
 
 struct amdgpu_ptl {
-       enum amdgpu_ptl_fmt             ptl_fmt1;
-       enum amdgpu_ptl_fmt             ptl_fmt2;
-       bool                            ptl_enabled;
-       bool                            ptl_hw_supported;
+       enum amdgpu_ptl_fmt             fmt1;
+       enum amdgpu_ptl_fmt             fmt2;
+       bool                            enabled;
+       bool                            hw_supported;
        /* PTL disable reference counting */
-       atomic_t                        ptl_disable_ref;
-       struct mutex                    ptl_mutex;
+       atomic_t                        disable_ref;
+       struct mutex                    mutex;
 };
 
 struct psp_context {
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
index f53934edfd3b..13933e3ee096 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
@@ -2380,12 +2380,12 @@ static int gfx_v9_4_3_perf_monitor_ptl_init(struct 
amdgpu_device *adev, bool sta
        if (!adev->psp.funcs)
                return -EOPNOTSUPP;
 
-       if (!ptl->ptl_hw_supported) {
+       if (!ptl->hw_supported) {
                fmt1 = GFX_FTYPE_I8;
                fmt2 = GFX_FTYPE_BF16;
        } else {
-               fmt1 = ptl->ptl_fmt1;
-               fmt2 = ptl->ptl_fmt2;
+               fmt1 = ptl->fmt1;
+               fmt2 = ptl->fmt2;
        }
 
        /* initialize PTL with default formats: GFX_FTYPE_I8 & GFX_FTYPE_BF16 */
@@ -2394,9 +2394,9 @@ static int gfx_v9_4_3_perf_monitor_ptl_init(struct 
amdgpu_device *adev, bool sta
        if (r)
                return r;
 
-       ptl->ptl_hw_supported = true;
+       ptl->hw_supported = true;
 
-       atomic_set(&ptl->ptl_disable_ref, 0);
+       atomic_set(&ptl->disable_ref, 0);
 
        return 0;
 }
@@ -2406,7 +2406,7 @@ static int gfx_v9_4_3_hw_fini(struct amdgpu_ip_block 
*ip_block)
        struct amdgpu_device *adev = ip_block->adev;
        int i, num_xcc;
 
-       if (adev->psp.ptl.ptl_hw_supported)
+       if (adev->psp.ptl.hw_supported)
                gfx_v9_4_3_perf_monitor_ptl_init(adev, 0);
 
        amdgpu_irq_put(adev, &adev->gfx.priv_reg_irq, 0);
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index efdd19d6d6da..c276ef6801d0 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -1768,12 +1768,12 @@ int kfd_ptl_control(struct kfd_process_device *pdd, 
bool enable)
 {
        struct amdgpu_device *adev = pdd->dev->adev;
        struct amdgpu_ptl *ptl = &adev->psp.ptl;
-       enum amdgpu_ptl_fmt pref_format1 = ptl->ptl_fmt1;
-       enum amdgpu_ptl_fmt pref_format2 = ptl->ptl_fmt2;
+       enum amdgpu_ptl_fmt pref_format1 = ptl->fmt1;
+       enum amdgpu_ptl_fmt pref_format2 = ptl->fmt2;
        uint32_t ptl_state = enable ? 1 : 0;
        int ret;
 
-       if (!ptl->ptl_hw_supported)
+       if (!ptl->hw_supported)
                return -EOPNOTSUPP;
 
        if (!pdd->dev->kfd2kgd || !pdd->dev->kfd2kgd->ptl_ctrl)
@@ -1800,15 +1800,15 @@ int kfd_ptl_disable_request(struct kfd_process_device 
*pdd,
        struct amdgpu_ptl *ptl = &adev->psp.ptl;
        int ret = 0;
 
-       mutex_lock(&ptl->ptl_mutex);
+       mutex_lock(&ptl->mutex);
 
        if (pdd->ptl_disable_req)
                goto out;
 
-       if (atomic_inc_return(&ptl->ptl_disable_ref) == 1) {
+       if (atomic_inc_return(&ptl->disable_ref) == 1) {
                ret = kfd_ptl_control(pdd, false);
                if (ret) {
-                       atomic_dec(&ptl->ptl_disable_ref);
+                       atomic_dec(&ptl->disable_ref);
                        dev_warn(pdd->dev->adev->dev,
                                        "failed to disable PTL\n");
                        goto out;
@@ -1817,7 +1817,7 @@ int kfd_ptl_disable_request(struct kfd_process_device 
*pdd,
        pdd->ptl_disable_req = true;
 
 out:
-       mutex_unlock(&ptl->ptl_mutex);
+       mutex_unlock(&ptl->mutex);
        return ret;
 }
 
@@ -1828,15 +1828,15 @@ int kfd_ptl_disable_release(struct kfd_process_device 
*pdd,
        struct amdgpu_ptl *ptl = &adev->psp.ptl;
        int ret = 0;
 
-       mutex_lock(&ptl->ptl_mutex);
+       mutex_lock(&ptl->mutex);
 
        if (!pdd->ptl_disable_req)
                goto out;
 
-       if (atomic_dec_return(&ptl->ptl_disable_ref) == 0) {
+       if (atomic_dec_return(&ptl->disable_ref) == 0) {
                ret = kfd_ptl_control(pdd, true);
                if (ret) {
-                       atomic_inc(&ptl->ptl_disable_ref);
+                       atomic_inc(&ptl->disable_ref);
                        dev_warn(adev->dev, "Failed to enable PTL on release: 
%d\n", ret);
                        goto out;
                }
@@ -1845,7 +1845,7 @@ int kfd_ptl_disable_release(struct kfd_process_device 
*pdd,
        pdd->ptl_disable_req = false;
 
 out:
-       mutex_unlock(&ptl->ptl_mutex);
+       mutex_unlock(&ptl->mutex);
        return ret;
 }
 
@@ -3338,7 +3338,7 @@ static inline uint32_t profile_lock_device(struct 
kfd_process *p,
                        kfd->profiler_process = p;
                        status = 0;
                        mutex_unlock(&kfd->profiler_lock);
-                       if (ptl->ptl_hw_supported) {
+                       if (ptl->hw_supported) {
                                status = kfd_ptl_disable_request(pdd, p);
                                if (status != 0)
                                        dev_err(kfd_device,
@@ -3356,7 +3356,7 @@ static inline uint32_t profile_lock_device(struct 
kfd_process *p,
                status = 0;
                mutex_unlock(&kfd->profiler_lock);
 
-               if (ptl->ptl_hw_supported) {
+               if (ptl->hw_supported) {
                        status = kfd_ptl_disable_release(pdd, p);
                        if (status)
                                dev_err(kfd_device,
-- 
2.34.1

Reply via email to