All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Wang, Kevin(Yang)" <Kevin1.Wang@amd.com>
To: "Powell, Darren" <Darren.Powell@amd.com>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>
Subject: Re: [PATCH] amdgpu/pm: replaced snprintf usage in amdgpu_pm.c with sysfs_emit
Date: Wed, 16 Jun 2021 06:01:16 +0000	[thread overview]
Message-ID: <CO6PR12MB5473F951BC8F13E819172CFCA20F9@CO6PR12MB5473.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20210616043100.2575-1-darren.powell@amd.com>


[-- Attachment #1.1: Type: text/plain, Size: 6669 bytes --]

[AMD Official Use Only]

Reviewed-by: Kevin Wang <kevin1.wang@amd.com>

Best Regards,
Kevin

________________________________
From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Darren Powell <darren.powell@amd.com>
Sent: Wednesday, June 16, 2021 12:31 PM
To: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>
Cc: Powell, Darren <Darren.Powell@amd.com>
Subject: [PATCH] amdgpu/pm: replaced snprintf usage in amdgpu_pm.c with sysfs_emit

replaced snprintf usage in amdgpu_pm.c with sysfs_emit
 fixed warning on comparing int with uint32_t in amdgpu_get_pp_num_states()

== Test ==
AMDGPU_PCI_ADDR=`lspci -nn | grep "VGA\|Display" | cut -d " " -f 1`
AMDGPU_HWMON=`ls -la /sys/class/hwmon | grep $AMDGPU_PCI_ADDR | cut -d " " -f 10`
HWMON_DIR=/sys/class/hwmon/${AMDGPU_HWMON}

lspci -nn | grep "VGA\|Display"  > scnprintf.test.log
FILES="pp_num_states
pp_od_clk_voltage
pp_features
pp_dpm_sclk
pp_dpm_mclk
pp_dpm_socclk
pp_dpm_fclk
pp_dpm_vclk
pp_dpm_dclk
pp_dpm_dcefclk
pp_power_profile_mode "

for f in $FILES
do
  echo === $f === >> scnprintf.test.log
  cat $HWMON_DIR/device/$f >> scnprintf.test.log
done

Signed-off-by: Darren Powell <darren.powell@amd.com>
---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index b2335a1d3f98..a276ebad47e6 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -411,7 +411,8 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,
         struct amdgpu_device *adev = drm_to_adev(ddev);
         const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
         struct pp_states_info data;
-       int i, buf_len, ret;
+       uint32_t i;
+       int buf_len, ret;

         if (amdgpu_in_reset(adev))
                 return -EPERM;
@@ -433,9 +434,9 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,
         pm_runtime_mark_last_busy(ddev->dev);
         pm_runtime_put_autosuspend(ddev->dev);

-       buf_len = snprintf(buf, PAGE_SIZE, "states: %d\n", data.nums);
+       buf_len = sysfs_emit(buf, "states: %d\n", data.nums);
         for (i = 0; i < data.nums; i++)
-               buf_len += snprintf(buf + buf_len, PAGE_SIZE, "%d %s\n", i,
+               buf_len += sysfs_emit_at(buf, buf_len, "%d %s\n", i,
                                 (data.states[i] == POWER_STATE_TYPE_INTERNAL_BOOT) ? "boot" :
                                 (data.states[i] == POWER_STATE_TYPE_BATTERY) ? "battery" :
                                 (data.states[i] == POWER_STATE_TYPE_BALANCED) ? "balanced" :
@@ -923,7 +924,7 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,
                 size += amdgpu_dpm_print_clock_levels(adev, OD_RANGE, buf+size);
                 size += amdgpu_dpm_print_clock_levels(adev, OD_CCLK, buf+size);
         } else {
-               size = snprintf(buf, PAGE_SIZE, "\n");
+               size = sysfs_emit(buf, "\n");
         }
         pm_runtime_mark_last_busy(ddev->dev);
         pm_runtime_put_autosuspend(ddev->dev);
@@ -1009,7 +1010,7 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,
         if (adev->powerplay.pp_funcs->get_ppfeature_status)
                 size = amdgpu_dpm_get_ppfeature_status(adev, buf);
         else
-               size = snprintf(buf, PAGE_SIZE, "\n");
+               size = sysfs_emit(buf, "\n");

         pm_runtime_mark_last_busy(ddev->dev);
         pm_runtime_put_autosuspend(ddev->dev);
@@ -1070,7 +1071,7 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,
         if (adev->powerplay.pp_funcs->print_clock_levels)
                 size = amdgpu_dpm_print_clock_levels(adev, type, buf);
         else
-               size = snprintf(buf, PAGE_SIZE, "\n");
+               size = sysfs_emit(buf, "\n");

         pm_runtime_mark_last_busy(ddev->dev);
         pm_runtime_put_autosuspend(ddev->dev);
@@ -1469,7 +1470,7 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,
         if (adev->powerplay.pp_funcs->get_power_profile_mode)
                 size = amdgpu_dpm_get_power_profile_mode(adev, buf);
         else
-               size = snprintf(buf, PAGE_SIZE, "\n");
+               size = sysfs_emit(buf, "\n");

         pm_runtime_mark_last_busy(ddev->dev);
         pm_runtime_put_autosuspend(ddev->dev);
@@ -2931,9 +2932,9 @@ static ssize_t amdgpu_hwmon_show_power_cap_max(struct device *dev,
                 r = -ENODATA;

         if (!r)
-               size = snprintf(buf, PAGE_SIZE, "%u\n", limit * 1000000);
+               size = sysfs_emit(buf, "%u\n", limit * 1000000);
         else
-               size = snprintf(buf, PAGE_SIZE, "\n");
+               size = sysfs_emit(buf, "\n");

         pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
         pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
@@ -2971,9 +2972,9 @@ static ssize_t amdgpu_hwmon_show_power_cap(struct device *dev,
                 r = -ENODATA;

         if (!r)
-               size = snprintf(buf, PAGE_SIZE, "%u\n", limit * 1000000);
+               size = sysfs_emit(buf, "%u\n", limit * 1000000);
         else
-               size = snprintf(buf, PAGE_SIZE, "\n");
+               size = sysfs_emit(buf, "\n");

         pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
         pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
@@ -3011,9 +3012,9 @@ static ssize_t amdgpu_hwmon_show_power_cap_default(struct device *dev,
                 r = -ENODATA;

         if (!r)
-               size = snprintf(buf, PAGE_SIZE, "%u\n", limit * 1000000);
+               size = sysfs_emit(buf, "%u\n", limit * 1000000);
         else
-               size = snprintf(buf, PAGE_SIZE, "\n");
+               size = sysfs_emit(buf, "\n");

         pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
         pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
--
2.31.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=04%7C01%7CKevin1.Wang%40amd.com%7Ca4803946245b4521d26e08d9307f9e27%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637594146951324361%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=FgYkesFOLYQAfD2ZS6KFFO3soJm8Xutyv6nrJLivx%2Bw%3D&amp;reserved=0

[-- Attachment #1.2: Type: text/html, Size: 13785 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

      reply	other threads:[~2021-06-16  6:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16  4:31 [PATCH] amdgpu/pm: replaced snprintf usage in amdgpu_pm.c with sysfs_emit Darren Powell
2021-06-16  6:01 ` Wang, Kevin(Yang) [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=CO6PR12MB5473F951BC8F13E819172CFCA20F9@CO6PR12MB5473.namprd12.prod.outlook.com \
    --to=kevin1.wang@amd.com \
    --cc=Darren.Powell@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.