From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Mario Limonciello <superm1@kernel.org>
Cc: mario.limonciello@amd.com, Shyam-sundar.S-k@amd.com,
Hans de Goede <hdegoede@redhat.com>,
Yijun Shen <Yijun.Shen@dell.com>,
stable@vger.kernel.org, Yijun Shen <Yijun_Shen@Dell.com>,
platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH v2] platform/x86: amd: pmf: Fix STT limits
Date: Mon, 7 Apr 2025 18:47:06 +0300 (EEST) [thread overview]
Message-ID: <333df1fe-b9d7-9396-240d-e586a9f4088a@linux.intel.com> (raw)
In-Reply-To: <392938bb-24b8-4873-ba89-aacf2c404499@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 4173 bytes --]
On Mon, 7 Apr 2025, Mario Limonciello wrote:
> On 4/7/2025 10:19 AM, Ilpo Järvinen wrote:
> > On Mon, 7 Apr 2025, Mario Limonciello wrote:
> >
> > > From: Mario Limonciello <mario.limonciello@amd.com>
> > >
> > > On some platforms it has been observed that STT limits are not being
> > > applied
> > > properly causing poor performance as power limits are set too low.
> > >
> > > STT limits that are sent to the platform are supposed to be in Q8.8
> > > format. Convert them before sending.
> > >
> > > Reported-by: Yijun Shen <Yijun.Shen@dell.com>
> > > Fixes: 7c45534afa443 ("platform/x86/amd/pmf: Add support for PMF Policy
> > > Binary")
> > > Cc: stable@vger.kernel.org
> > > Tested-By: Yijun Shen <Yijun_Shen@Dell.com>
> > > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> > > ---
> > > v2:
> > > * Handle cases for auto-mode, cnqf, and sps as well
> > > ---
> > > drivers/platform/x86/amd/pmf/auto-mode.c | 4 ++--
> > > drivers/platform/x86/amd/pmf/cnqf.c | 4 ++--
> > > drivers/platform/x86/amd/pmf/sps.c | 8 ++++----
> > > drivers/platform/x86/amd/pmf/tee-if.c | 4 ++--
> > > 4 files changed, 10 insertions(+), 10 deletions(-)
> > >
> > > diff --git a/drivers/platform/x86/amd/pmf/auto-mode.c
> > > b/drivers/platform/x86/amd/pmf/auto-mode.c
> > > index 02ff68be10d01..df37f8a84a007 100644
> > > --- a/drivers/platform/x86/amd/pmf/auto-mode.c
> > > +++ b/drivers/platform/x86/amd/pmf/auto-mode.c
> > > @@ -120,9 +120,9 @@ static void amd_pmf_set_automode(struct amd_pmf_dev
> > > *dev, int idx,
> > > amd_pmf_send_cmd(dev, SET_SPPT_APU_ONLY, false,
> > > pwr_ctrl->sppt_apu_only, NULL);
> > > amd_pmf_send_cmd(dev, SET_STT_MIN_LIMIT, false, pwr_ctrl->stt_min,
> > > NULL);
> > > amd_pmf_send_cmd(dev, SET_STT_LIMIT_APU, false,
> > > - pwr_ctrl->stt_skin_temp[STT_TEMP_APU], NULL);
> > > + pwr_ctrl->stt_skin_temp[STT_TEMP_APU] << 8, NULL);
> >
> > Hi Mario,
> >
> > Could we add some helper on constructing the fixed-point number from the
> > integer part as this magic shifting makes the intent somewhat harder to
> > follow just by reading the code itself?
> >
> > I hoped that include/linux/ would have had something for this but it seems
> > generic fixed-point helpers are almost non-existing except for very
> > specific use cases such as averages so maybe add a helper only for this
> > driver for now as this will be routed through fixes branch so doing random
> > things i include/linux/ might not be preferrable and would require larger
> > review audience.
> >
> > What I mean for general helpers is that it would be nice to have something
> > like DECLARE_FIXEDPOINT() similar to DECLARE_EWMA() macro (and maybe a
> > signed variant too) which creates a few helper functions for the given
> > name prefix. It seems there's plenty of code which would benefit from such
> > helpers and would avoid the need to comment the fixed-point operations
> > (not to speak of how many of such ops likely lack the comment). So at
> > least keep that in mind for naming the helpers so the conversion to
> > a generic helper could be done smoothly.
> >
>
> Do I follow right that you mean something like this?
>
> static inline u32 amd_pmf_convert_q88 (u32 val)
As with the ewma example, the operation should be the last part. And we'd
probably want to have some common prefix for all those to make it obvious
it's fixed-point related, so lets say e.g.:
fixp_amd_pmf_q88_from_integer()
I'm not entirely sure though if we really need per driver in the prefix at
all as fixed-points are more general concept than a single driver/hw. So
if it's only used for temperature, maybe just fixp_temp_q88_from_integer()
or even just fixp_q88_from_integer(), Q8.8 should really be the same for
all users, shouldn't it, so the last one would seem okay too to me
(although I'm not sure what people in general will think of that).
I suspect ..._from_int() isn't good name for operation because "int" is a
type in C but it would be shorted than from_integer.
> {
> return val << 8;
> }
>
>
--
i.
prev parent reply other threads:[~2025-04-07 15:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 13:36 [PATCH v2] platform/x86: amd: pmf: Fix STT limits Mario Limonciello
2025-04-07 15:19 ` Ilpo Järvinen
2025-04-07 15:25 ` Mario Limonciello
2025-04-07 15:47 ` Ilpo Järvinen [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=333df1fe-b9d7-9396-240d-e586a9f4088a@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=Shyam-sundar.S-k@amd.com \
--cc=Yijun.Shen@dell.com \
--cc=Yijun_Shen@Dell.com \
--cc=hdegoede@redhat.com \
--cc=mario.limonciello@amd.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=superm1@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox