]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/pm: Avoid open-coded use of ratelimit_state structure's internals
authorPaul E. McKenney <paulmck@kernel.org>
Tue, 18 Mar 2025 03:28:40 +0000 (20:28 -0700)
committerPaul E. McKenney <paulmck@kernel.org>
Thu, 8 May 2025 23:13:26 +0000 (16:13 -0700)
The amdgpu_set_thermal_throttling_logging() function directly accesses
the ratelimit_state structure's ->missed field, which works, but which
also makes it more difficult to change this field.  Therefore, make use
of the ratelimit_state_reset_interval() function instead of directly
accessing the ->missed field.

Nevertheless, open-coded use of ->burst and ->interval is still permitted,
for example, for runtime sysfs adjustment of these fields.

Link: https://lore.kernel.org/all/fbe93a52-365e-47fe-93a4-44a44547d601@paulmck-laptop/
Link: https://lore.kernel.org/all/20250423115409.3425-1-spasswolf@web.de/
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202503180826.EiekA1MB-lkp@intel.com/
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Cc: Kenneth Feng <kenneth.feng@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: Xinhui Pan <Xinhui.Pan@amd.com>
Cc: David Airlie <airlied@gmail.com>
Cc: Simona Vetter <simona@ffwll.ch>
Cc: <amd-gfx@lists.freedesktop.org>
Cc: <dri-devel@lists.freedesktop.org>
drivers/gpu/drm/amd/pm/amdgpu_pm.c

index 922def51685b0af8dd177b0a94fe8531f6a3b246..d533c79f7e215285c6172ebcc6367270227be51e 100644 (file)
@@ -1606,7 +1606,6 @@ static ssize_t amdgpu_set_thermal_throttling_logging(struct device *dev,
        struct drm_device *ddev = dev_get_drvdata(dev);
        struct amdgpu_device *adev = drm_to_adev(ddev);
        long throttling_logging_interval;
-       unsigned long flags;
        int ret = 0;
 
        ret = kstrtol(buf, 0, &throttling_logging_interval);
@@ -1617,18 +1616,12 @@ static ssize_t amdgpu_set_thermal_throttling_logging(struct device *dev,
                return -EINVAL;
 
        if (throttling_logging_interval > 0) {
-               raw_spin_lock_irqsave(&adev->throttling_logging_rs.lock, flags);
                /*
                 * Reset the ratelimit timer internals.
                 * This can effectively restart the timer.
                 */
-               adev->throttling_logging_rs.interval =
-                       (throttling_logging_interval - 1) * HZ;
-               adev->throttling_logging_rs.begin = 0;
-               adev->throttling_logging_rs.printed = 0;
-               adev->throttling_logging_rs.missed = 0;
-               raw_spin_unlock_irqrestore(&adev->throttling_logging_rs.lock, flags);
-
+               ratelimit_state_reset_interval(&adev->throttling_logging_rs,
+                                              (throttling_logging_interval - 1) * HZ);
                atomic_set(&adev->throttling_logging_enabled, 1);
        } else {
                atomic_set(&adev->throttling_logging_enabled, 0);