All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Deucher <alexdeucher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: welu <wei.lu2-5C7GfCeVMHo@public.gmane.org>
Cc: amd-gfx list <amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Subject: Re: [PATCH] drm/amdgpu: change pp_dpm clk/mclk/pcie input format
Date: Mon, 23 Apr 2018 16:06:16 -0400	[thread overview]
Message-ID: <CADnq5_NyeoyGQTqq3okvFpjNrRN2CSU+trFSTENT9cor2=aj7w@mail.gmail.com> (raw)
In-Reply-To: <1524171079-657-1-git-send-email-wei.lu2-5C7GfCeVMHo@public.gmane.org>

On Thu, Apr 19, 2018 at 4:51 PM, welu <wei.lu2@amd.com> wrote:
> 1. support more than 8 values when setting get_pp_dpm_mclk/
> sclk/pcie, the former design just parse command format like
> "echo xxxx > pp_dpm_sclk" and current can parse "echo xx xxx
>  xxxx > pp_dpm_sclk" whose operation is more user-friendly
> and convinent and can offer more values;
> 2. be compatible with former design like "xx".
> Bug:KFD-385

Please update the documentation labeled "DOC: pp_dpm_sclk pp_dpm_mclk
pp_dpm_pcie", With that fixed, patch is:
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

>
> Change-Id: Id7d95ce45f4ee0564b18ebcfc16976f1a5c6bf72
> Signed-off-by: welu <wei.lu2@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 95 ++++++++++++++++++++--------------
>  1 file changed, 55 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> index 744f105..58f46f9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> @@ -466,23 +466,27 @@ static ssize_t amdgpu_set_pp_dpm_sclk(struct device *dev,
>         struct amdgpu_device *adev = ddev->dev_private;
>         int ret;
>         long level;
> -       uint32_t i, mask = 0;
> -       char sub_str[2];
> +       uint32_t mask = 0;
> +       char *sub_str = NULL;
> +       char *tmp;
> +       char buf_cpy[count];
> +       const char delimiter[3] = {' ', '\n', '\0'};
>
> -       for (i = 0; i < strlen(buf); i++) {
> -               if (*(buf + i) == '\n')
> -                       continue;
> -               sub_str[0] = *(buf + i);
> -               sub_str[1] = '\0';
> -               ret = kstrtol(sub_str, 0, &level);
> +       memcpy(buf_cpy, buf, count+1);
> +       tmp = buf_cpy;
> +       while (tmp[0]) {
> +               sub_str =  strsep(&tmp, delimiter);
> +               if (strlen(sub_str)) {
> +                       ret = kstrtol(sub_str, 0, &level);
>
> -               if (ret) {
> -                       count = -EINVAL;
> -                       goto fail;
> -               }
> -               mask |= 1 << level;
> +                       if (ret) {
> +                               count = -EINVAL;
> +                               goto fail;
> +                       }
> +                       mask |= 1 << level;
> +               } else
> +                       break;
>         }
> -
>         if (adev->powerplay.pp_funcs->force_clock_level)
>                 amdgpu_dpm_force_clock_level(adev, PP_SCLK, mask);
>
> @@ -512,21 +516,26 @@ static ssize_t amdgpu_set_pp_dpm_mclk(struct device *dev,
>         struct amdgpu_device *adev = ddev->dev_private;
>         int ret;
>         long level;
> -       uint32_t i, mask = 0;
> -       char sub_str[2];
> +       uint32_t mask = 0;
> +       char *sub_str = NULL;
> +       char *tmp;
> +       char buf_cpy[count];
> +       const char delimiter[3] = {' ', '\n', '\0'};
>
> -       for (i = 0; i < strlen(buf); i++) {
> -               if (*(buf + i) == '\n')
> -                       continue;
> -               sub_str[0] = *(buf + i);
> -               sub_str[1] = '\0';
> -               ret = kstrtol(sub_str, 0, &level);
> +       memcpy(buf_cpy, buf, count+1);
> +       tmp = buf_cpy;
> +       while (tmp[0]) {
> +               sub_str =  strsep(&tmp, delimiter);
> +               if (strlen(sub_str)) {
> +                       ret = kstrtol(sub_str, 0, &level);
>
> -               if (ret) {
> -                       count = -EINVAL;
> -                       goto fail;
> -               }
> -               mask |= 1 << level;
> +                       if (ret) {
> +                               count = -EINVAL;
> +                               goto fail;
> +                       }
> +                       mask |= 1 << level;
> +               } else
> +                       break;
>         }
>         if (adev->powerplay.pp_funcs->force_clock_level)
>                 amdgpu_dpm_force_clock_level(adev, PP_MCLK, mask);
> @@ -557,21 +566,27 @@ static ssize_t amdgpu_set_pp_dpm_pcie(struct device *dev,
>         struct amdgpu_device *adev = ddev->dev_private;
>         int ret;
>         long level;
> -       uint32_t i, mask = 0;
> -       char sub_str[2];
> +       uint32_t mask = 0;
> +       char *sub_str = NULL;
> +       char *tmp;
> +       char buf_cpy[count];
> +       const char delimiter[3] = {' ', '\n', '\0'};
>
> -       for (i = 0; i < strlen(buf); i++) {
> -               if (*(buf + i) == '\n')
> -                       continue;
> -               sub_str[0] = *(buf + i);
> -               sub_str[1] = '\0';
> -               ret = kstrtol(sub_str, 0, &level);
> +       memcpy(buf_cpy, buf, count+1);
> +       tmp = buf_cpy;
>
> -               if (ret) {
> -                       count = -EINVAL;
> -                       goto fail;
> -               }
> -               mask |= 1 << level;
> +       while (tmp[0]) {
> +               sub_str =  strsep(&tmp, delimiter);
> +               if (strlen(sub_str)) {
> +                       ret = kstrtol(sub_str, 0, &level);
> +
> +                       if (ret) {
> +                               count = -EINVAL;
> +                               goto fail;
> +                       }
> +                       mask |= 1 << level;
> +               } else
> +                       break;
>         }
>         if (adev->powerplay.pp_funcs->force_clock_level)
>                 amdgpu_dpm_force_clock_level(adev, PP_PCIE, mask);
> --
> 2.7.4
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2018-04-23 20:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-19 20:51 [PATCH] drm/amdgpu: change pp_dpm clk/mclk/pcie input format welu
     [not found] ` <1524171079-657-1-git-send-email-wei.lu2-5C7GfCeVMHo@public.gmane.org>
2018-04-23 20:06   ` Alex Deucher [this message]
     [not found]     ` <CADnq5_NyeoyGQTqq3okvFpjNrRN2CSU+trFSTENT9cor2=aj7w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-04-24 13:22       ` Lu, Wei
2018-04-24 13:20 welu

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='CADnq5_NyeoyGQTqq3okvFpjNrRN2CSU+trFSTENT9cor2=aj7w@mail.gmail.com' \
    --to=alexdeucher-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=wei.lu2-5C7GfCeVMHo@public.gmane.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.