From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Cc: Xinhui.Pan@amd.com, Patil.Reddy@amd.com,
basavaraj.natikar@amd.com, dri-devel@lists.freedesktop.org,
jikos@kernel.org, amd-gfx@lists.freedesktop.org,
platform-driver-x86@vger.kernel.org, markgross@kernel.org,
hdegoede@redhat.com, benjamin.tissoires@redhat.com,
mario.limonciello@amd.com, daniel@ffwll.ch,
linux-input@vger.kernel.org, alexander.deucher@amd.com,
airlied@gmail.com, christian.koenig@amd.com
Subject: Re: [PATCH 02/15] platform/x86/amd/pmf: Add support PMF-TA interaction
Date: Tue, 26 Sep 2023 19:48:40 +0300 (EEST) [thread overview]
Message-ID: <96a8196-723e-e884-2fe2-65f1ff342b9d@linux.intel.com> (raw)
In-Reply-To: <20230922175056.244940-3-Shyam-sundar.S-k@amd.com>
On Fri, 22 Sep 2023, Shyam Sundar S K wrote:
> PMF TA (Trusted Application) loads via the TEE environment into the
> AMD ASP.
>
> PMF-TA supports two commands:
> 1) Init: Initialize the TA with the PMF Smart PC policy binary and
> start the policy engine. A policy is a combination of inputs and
> outputs, where;
> - the inputs are the changing dynamics of the system like the user
> behaviour, system heuristics etc.
> - the outputs, which are the actions to be set on the system which
> lead to better power management and enhanced user experience.
>
> PMF driver acts as a central manager in this case to supply the
> inputs required to the TA (either by getting the information from
> the other kernel subsystems or from userland)
>
> 2) Enact: Enact the output actions from the TA. The action could be
> applying a new thermal limit to boost/throttle the power limits or
> change system behavior.
>
> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
> ---
> drivers/platform/x86/amd/pmf/pmf.h | 10 +++
> drivers/platform/x86/amd/pmf/tee-if.c | 97 ++++++++++++++++++++++++++-
> 2 files changed, 106 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
> index 02460c2a31ea..a9333ff6c0a7 100644
> --- a/drivers/platform/x86/amd/pmf/pmf.h
> +++ b/drivers/platform/x86/amd/pmf/pmf.h
> @@ -59,6 +59,9 @@
> #define ARG_NONE 0
> #define AVG_SAMPLE_SIZE 3
>
> +/* TA macros */
> +#define PMF_TA_IF_VERSION__MAJOR 1
I suppose double _ is not intentional?
> +
> /* AMD PMF BIOS interfaces */
> struct apmf_verify_interface {
> u16 size;
> @@ -184,6 +187,7 @@ struct amd_pmf_dev {
> struct tee_shm *fw_shm_pool;
> u32 session_id;
> void *shbuf;
> + struct delayed_work pb_work;
> bool smart_pc_enabled;
> };
>
> @@ -395,6 +399,12 @@ struct apmf_dyn_slider_output {
> struct apmf_cnqf_power_set ps[APMF_CNQF_MAX];
> } __packed;
>
> +/* cmd ids for TA communication */
> +enum ta_pmf_command {
> + TA_PMF_COMMAND_POLICY_BUILDER__INITIALIZE,
> + TA_PMF_COMMAND_POLICY_BUILDER__ENACT_POLICIES
Add comma to the second line too.
Did you mean to have double _?
> +};
> +
> struct ta_pmf_shared_memory {
> int command_id;
> int resp_id;
> diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c
> index b48340edbf44..1fce04beacb3 100644
> --- a/drivers/platform/x86/amd/pmf/tee-if.c
> +++ b/drivers/platform/x86/amd/pmf/tee-if.c
> @@ -13,9 +13,96 @@
> #include "pmf.h"
>
> #define MAX_TEE_PARAM 4
> +
> +/* Policy binary actions sampling frequency (in ms) */
> +static int pb_actions_ms = 1000;
> +#ifdef CONFIG_AMD_PMF_DEBUG
> +module_param(pb_actions_ms, int, 0644);
> +MODULE_PARM_DESC(pb_actions_ms, "Policy binary actions sampling frequency (default = 1000ms)");
> +#endif
> +
> static const uuid_t amd_pmf_ta_uuid = UUID_INIT(0x6fd93b77, 0x3fb8, 0x524d,
> 0xb1, 0x2d, 0xc5, 0x29, 0xb1, 0x3d, 0x85, 0x43);
>
> +static void amd_pmf_prepare_args(struct amd_pmf_dev *dev, int cmd,
> + struct tee_ioctl_invoke_arg *arg,
> + struct tee_param *param)
> +{
> + memset(arg, 0, sizeof(*arg));
> + memset(param, 0, MAX_TEE_PARAM * sizeof(*param));
> +
> + arg->func = cmd;
> + arg->session = dev->session_id;
> + arg->num_params = MAX_TEE_PARAM;
> +
> + /* Fill invoke cmd params */
> + param[0].u.memref.size = sizeof(struct ta_pmf_shared_memory);
> + param[0].attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT;
> + param[0].u.memref.shm = dev->fw_shm_pool;
> + param[0].u.memref.shm_offs = 0;
> +}
> +
> +static int amd_pmf_invoke_cmd_enact(struct amd_pmf_dev *dev)
> +{
> + struct ta_pmf_shared_memory *ta_sm = NULL;
> + struct tee_param param[MAX_TEE_PARAM];
> + struct tee_ioctl_invoke_arg arg;
> + int ret = 0;
> +
> + if (!dev->tee_ctx)
> + return -ENODEV;
> +
> + ta_sm = (struct ta_pmf_shared_memory *)dev->shbuf;
> + memset(ta_sm, 0, sizeof(struct ta_pmf_shared_memory));
> + ta_sm->command_id = TA_PMF_COMMAND_POLICY_BUILDER__ENACT_POLICIES;
> + ta_sm->if_version = PMF_TA_IF_VERSION__MAJOR;
> +
> + amd_pmf_prepare_args(dev, TA_PMF_COMMAND_POLICY_BUILDER__ENACT_POLICIES, &arg, param);
> +
> + ret = tee_client_invoke_func(dev->tee_ctx, &arg, param);
> + if (ret < 0 || arg.ret != 0) {
> + dev_err(dev->dev, "%s failed TEE err: %x, ret:%x\n", __func__, arg.ret, ret);
No __func__s please.
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
> +static int amd_pmf_invoke_cmd_init(struct amd_pmf_dev *dev)
> +{
> + struct ta_pmf_shared_memory *ta_sm = NULL;
> + struct tee_param param[MAX_TEE_PARAM];
> + struct tee_ioctl_invoke_arg arg;
> + int ret = 0;
> +
> + if (!dev->tee_ctx) {
> + dev_err(dev->dev, "%s tee_ctx no context\n", __func__);
> + return -ENODEV;
> + }
> +
> + ta_sm = (struct ta_pmf_shared_memory *)dev->shbuf;
> + ta_sm->command_id = TA_PMF_COMMAND_POLICY_BUILDER__INITIALIZE;
> + ta_sm->if_version = PMF_TA_IF_VERSION__MAJOR;
> +
> + amd_pmf_prepare_args(dev, TA_PMF_COMMAND_POLICY_BUILDER__INITIALIZE, &arg, param);
> +
> + ret = tee_client_invoke_func(dev->tee_ctx, &arg, param);
> + if (ret < 0 || arg.ret != 0) {
> + dev_err(dev->dev, "%s failed TEE err: %x, ret:%x\n", __func__, arg.ret, ret);
> + return -EINVAL;
> + }
> +
> + return ta_sm->pmf_result;
> +}
> +
> +static void amd_pmf_invoke_cmd(struct work_struct *work)
> +{
> + struct amd_pmf_dev *dev = container_of(work, struct amd_pmf_dev, pb_work.work);
> +
> + amd_pmf_invoke_cmd_enact(dev);
> + schedule_delayed_work(&dev->pb_work, msecs_to_jiffies(pb_actions_ms));
> +}
> +
> static int amd_pmf_amdtee_ta_match(struct tee_ioctl_version_data *ver, const void *data)
> {
> return ver->impl_id == TEE_IMPL_ID_AMDTEE;
> @@ -97,10 +184,18 @@ static void amd_pmf_tee_deinit(struct amd_pmf_dev *dev)
>
> int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)
> {
> - return amd_pmf_tee_init(dev);
> + int ret;
> +
> + ret = amd_pmf_tee_init(dev);
> + if (ret)
> + return ret;
> +
> + INIT_DELAYED_WORK(&dev->pb_work, amd_pmf_invoke_cmd);
> + return 0;
> }
>
> void amd_pmf_deinit_smart_pc(struct amd_pmf_dev *dev)
> {
> + cancel_delayed_work_sync(&dev->pb_work);
> amd_pmf_tee_deinit(dev);
> }
>
--
i.
next prev parent reply other threads:[~2023-09-26 16:55 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-22 17:50 [PATCH 00/15] Introduce PMF Smart PC Solution Builder Feature Shyam Sundar S K
2023-09-22 17:50 ` [PATCH 01/15] platform/x86/amd/pmf: Add PMF TEE interface Shyam Sundar S K
2023-09-26 16:42 ` Ilpo Järvinen
2023-09-22 17:50 ` [PATCH 02/15] platform/x86/amd/pmf: Add support PMF-TA interaction Shyam Sundar S K
2023-09-26 16:48 ` Ilpo Järvinen [this message]
2023-09-22 17:50 ` [PATCH 03/15] platform/x86/amd/pmf: Change signature of amd_pmf_set_dram_addr Shyam Sundar S K
2023-09-26 16:52 ` Ilpo Järvinen
2023-09-22 17:50 ` [PATCH 04/15] platform/x86/amd/pmf: Add support for PMF Policy Binary Shyam Sundar S K
2023-09-22 18:51 ` Mario Limonciello
2023-09-30 3:55 ` Shyam Sundar S K
2023-09-26 17:05 ` Ilpo Järvinen
2023-09-27 12:19 ` Ilpo Järvinen
2023-09-22 17:50 ` [PATCH 05/15] platform/x86/amd/pmf: change debugfs init sequence Shyam Sundar S K
2023-09-26 16:53 ` Ilpo Järvinen
2023-09-22 17:50 ` [PATCH 06/15] platform/x86/amd/pmf: Add support to get inputs from other subsystems Shyam Sundar S K
2023-09-26 17:08 ` Ilpo Järvinen
2023-09-30 8:40 ` Shyam Sundar S K
2023-10-02 9:10 ` Ilpo Järvinen
2023-09-22 17:50 ` [PATCH 07/15] platform/x86/amd/pmf: Add support update p3t limit Shyam Sundar S K
2023-09-27 12:19 ` Ilpo Järvinen
2023-09-22 17:50 ` [PATCH 08/15] platform/x86/amd/pmf: Add support to update system state Shyam Sundar S K
2023-09-25 21:42 ` kernel test robot
2023-09-27 12:22 ` Ilpo Järvinen
2023-09-22 17:50 ` [PATCH 09/15] platform/x86/amd/pmf: Add facility to dump TA inputs Shyam Sundar S K
2023-09-27 12:25 ` Ilpo Järvinen
2023-09-22 17:50 ` [PATCH 10/15] platform/x86/amd/pmf: Add capability to sideload of policy binary Shyam Sundar S K
2023-09-25 2:14 ` kernel test robot
2023-09-27 12:33 ` Ilpo Järvinen
2023-09-22 17:50 ` [PATCH 11/15] platform/x86/amd/pmf: dump policy binary data Shyam Sundar S K
2023-09-22 19:01 ` Mario Limonciello
2023-09-30 4:41 ` Shyam Sundar S K
2023-09-22 17:50 ` [PATCH 12/15] platform/x86/amd/pmf: Add PMF-AMDGPU get interface Shyam Sundar S K
2023-09-27 12:54 ` Ilpo Järvinen
2023-09-22 17:50 ` [PATCH 13/15] platform/x86/amd/pmf: Add PMF-AMDGPU set interface Shyam Sundar S K
2023-09-25 16:27 ` Deucher, Alexander
2023-09-25 16:30 ` Mario Limonciello
2023-09-26 11:17 ` Shyam Sundar S K
2023-09-26 11:15 ` Shyam Sundar S K
2023-09-26 10:35 ` Hans de Goede
2023-09-26 11:24 ` Shyam Sundar S K
2023-09-26 12:56 ` Hans de Goede
2023-09-26 13:17 ` Christian König
2023-09-26 13:48 ` Shyam Sundar S K
2023-09-27 13:04 ` Hans de Goede
2023-09-27 13:47 ` Shyam Sundar S K
2023-09-27 13:36 ` Ilpo Järvinen
2023-09-22 17:50 ` [PATCH 14/15] platform/x86/amd/pmf: Add PMF-AMDSFH interface for HPD Shyam Sundar S K
2023-09-22 19:04 ` Mario Limonciello
2023-09-22 21:04 ` Mario Limonciello
2023-09-27 13:32 ` Ilpo Järvinen
2023-09-22 17:50 ` [PATCH 15/15] platform/x86/amd/pmf: Add PMF-AMDSFH interface for ALS Shyam Sundar S K
2023-09-22 19:06 ` Mario Limonciello
2023-09-27 13:33 ` Ilpo Järvinen
2023-09-27 13:48 ` Shyam Sundar S K
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=96a8196-723e-e884-2fe2-65f1ff342b9d@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=Patil.Reddy@amd.com \
--cc=Shyam-sundar.S-k@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=basavaraj.natikar@amd.com \
--cc=benjamin.tissoires@redhat.com \
--cc=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=hdegoede@redhat.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=markgross@kernel.org \
--cc=platform-driver-x86@vger.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