X86 platform drivers
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	markgross@kernel.org, basavaraj.natikar@amd.com,
	jikos@kernel.org, benjamin.tissoires@redhat.com,
	alexander.deucher@amd.com, christian.koenig@amd.com,
	Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch,
	Patil.Reddy@amd.com, mario.limonciello@amd.com,
	platform-driver-x86@vger.kernel.org, linux-input@vger.kernel.org,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 01/16] platform/x86/amd/pmf: Add PMF TEE interface
Date: Mon, 9 Oct 2023 13:29:59 +0300 (EEST)	[thread overview]
Message-ID: <f19e6ae-9a60-41d1-8f77-3794948f167a@linux.intel.com> (raw)
In-Reply-To: <01eef1b0-8695-4284-8a4a-973826f2c3cc@amd.com>

[-- Attachment #1: Type: text/plain, Size: 6339 bytes --]

On Mon, 9 Oct 2023, Shyam Sundar S K wrote:

> 
> 
> On 10/4/2023 4:20 PM, Ilpo Järvinen wrote:
> > On Sat, 30 Sep 2023, Shyam Sundar S K wrote:
> > 
> >> AMD PMF driver loads the PMF TA (Trusted Application) into the AMD
> >> ASP's (AMD Security Processor) TEE (Trusted Execution Environment).
> >>
> >> PMF Trusted Application is a secured firmware placed under
> >> /lib/firmware/amdtee gets loaded only when the TEE environment is
> >> initialized. Add the initial code path to build these pipes.
> >>
> >> 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/Makefile |   3 +-
> >>  drivers/platform/x86/amd/pmf/core.c   |  11 ++-
> >>  drivers/platform/x86/amd/pmf/pmf.h    |  16 ++++
> >>  drivers/platform/x86/amd/pmf/tee-if.c | 112 ++++++++++++++++++++++++++
> >>  4 files changed, 138 insertions(+), 4 deletions(-)
> >>  create mode 100644 drivers/platform/x86/amd/pmf/tee-if.c
> >>
> >> diff --git a/drivers/platform/x86/amd/pmf/Makefile b/drivers/platform/x86/amd/pmf/Makefile
> >> index fdededf54392..d2746ee7369f 100644
> >> --- a/drivers/platform/x86/amd/pmf/Makefile
> >> +++ b/drivers/platform/x86/amd/pmf/Makefile
> >> @@ -6,4 +6,5 @@
> >>  
> >>  obj-$(CONFIG_AMD_PMF) += amd-pmf.o
> >>  amd-pmf-objs := core.o acpi.o sps.o \
> >> -		auto-mode.o cnqf.o
> >> +		auto-mode.o cnqf.o \
> >> +		tee-if.o
> >> diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c
> >> index 78ed3ee22555..68f1389dda3e 100644
> >> --- a/drivers/platform/x86/amd/pmf/core.c
> >> +++ b/drivers/platform/x86/amd/pmf/core.c
> >> @@ -309,8 +309,11 @@ static void amd_pmf_init_features(struct amd_pmf_dev *dev)
> >>  		dev_dbg(dev->dev, "SPS enabled and Platform Profiles registered\n");
> >>  	}
> >>  
> >> -	/* Enable Auto Mode */
> >> -	if (is_apmf_func_supported(dev, APMF_FUNC_AUTO_MODE)) {
> >> +	if (amd_pmf_init_smart_pc(dev)) {
> >> +		/* Enable Smart PC Solution builder */
> >> +		dev_dbg(dev->dev, "Smart PC Solution Enabled\n");
> >> +	} else if (is_apmf_func_supported(dev, APMF_FUNC_AUTO_MODE)) {
> >> +		/* Enable Auto Mode */
> > 
> > I'm pretty certain neither of these two comments add any information to 
> > what's readily visible from the code itself so they can be dropped.
> > 
> >>  		amd_pmf_init_auto_mode(dev);
> >>  		dev_dbg(dev->dev, "Auto Mode Init done\n");
> >>  	} else if (is_apmf_func_supported(dev, APMF_FUNC_DYN_SLIDER_AC) ||
> >> @@ -330,7 +333,9 @@ static void amd_pmf_deinit_features(struct amd_pmf_dev *dev)
> >>  		amd_pmf_deinit_sps(dev);
> >>  	}
> >>  
> >> -	if (is_apmf_func_supported(dev, APMF_FUNC_AUTO_MODE)) {
> >> +	if (dev->smart_pc_enabled) {
> >> +		amd_pmf_deinit_smart_pc(dev);
> >> +	} else if (is_apmf_func_supported(dev, APMF_FUNC_AUTO_MODE)) {
> >>  		amd_pmf_deinit_auto_mode(dev);
> >>  	} else if (is_apmf_func_supported(dev, APMF_FUNC_DYN_SLIDER_AC) ||
> >>  			  is_apmf_func_supported(dev, APMF_FUNC_DYN_SLIDER_DC)) {
> >> diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
> >> index deba88e6e4c8..02460c2a31ea 100644
> >> --- a/drivers/platform/x86/amd/pmf/pmf.h
> >> +++ b/drivers/platform/x86/amd/pmf/pmf.h
> >> @@ -179,6 +179,12 @@ struct amd_pmf_dev {
> >>  	bool cnqf_enabled;
> >>  	bool cnqf_supported;
> >>  	struct notifier_block pwr_src_notifier;
> >> +	/* Smart PC solution builder */
> >> +	struct tee_context *tee_ctx;
> >> +	struct tee_shm *fw_shm_pool;
> >> +	u32 session_id;
> >> +	void *shbuf;
> >> +	bool smart_pc_enabled;
> >>  };
> >>  
> >>  struct apmf_sps_prop_granular {
> >> @@ -389,6 +395,13 @@ struct apmf_dyn_slider_output {
> >>  	struct apmf_cnqf_power_set ps[APMF_CNQF_MAX];
> >>  } __packed;
> >>  
> >> +struct ta_pmf_shared_memory {
> >> +	int command_id;
> >> +	int resp_id;
> >> +	u32 pmf_result;
> >> +	u32 if_version;
> >> +};
> >> +
> >>  /* Core Layer */
> >>  int apmf_acpi_init(struct amd_pmf_dev *pmf_dev);
> >>  void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev);
> >> @@ -433,4 +446,7 @@ void amd_pmf_deinit_cnqf(struct amd_pmf_dev *dev);
> >>  int amd_pmf_trans_cnqf(struct amd_pmf_dev *dev, int socket_power, ktime_t time_lapsed_ms);
> >>  extern const struct attribute_group cnqf_feature_attribute_group;
> >>  
> >> +/* Smart PC builder Layer*/
> > 
> > Missing space.
> > 
> >> +int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev);
> >> +void amd_pmf_deinit_smart_pc(struct amd_pmf_dev *dev);
> >>  #endif /* PMF_H */
> >> diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c
> >> new file mode 100644
> >> index 000000000000..4db80ca59a11
> >> --- /dev/null
> >> +++ b/drivers/platform/x86/amd/pmf/tee-if.c
> >> @@ -0,0 +1,112 @@
> >> +// SPDX-License-Identifier: GPL-2.0
> >> +/*
> >> + * AMD Platform Management Framework Driver - TEE Interface
> >> + *
> >> + * Copyright (c) 2023, Advanced Micro Devices, Inc.
> >> + * All Rights Reserved.
> >> + *
> >> + * Author: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
> >> + */
> >> +
> >> +#include <linux/tee_drv.h>
> >> +#include <linux/uuid.h>
> >> +#include "pmf.h"
> >> +
> >> +#define MAX_TEE_PARAM	4
> >> +static const uuid_t amd_pmf_ta_uuid = UUID_INIT(0x6fd93b77, 0x3fb8, 0x524d,
> >> +						0xb1, 0x2d, 0xc5, 0x29, 0xb1, 0x3d, 0x85, 0x43);
> >> +
> >> +static int amd_pmf_amdtee_ta_match(struct tee_ioctl_version_data *ver, const void *data)
> >> +{
> >> +	return ver->impl_id == TEE_IMPL_ID_AMDTEE;
> >> +}
> >> +
> >> +static int amd_pmf_ta_open_session(struct tee_context *ctx, u32 *id)
> >> +{
> >> +	struct tee_ioctl_open_session_arg sess_arg = {};
> >> +	int rc;
> >> +
> >> +	export_uuid(sess_arg.uuid, &amd_pmf_ta_uuid);
> >> +	sess_arg.clnt_login = TEE_IOCTL_LOGIN_PUBLIC;
> >> +	sess_arg.num_params = 0;
> >> +
> >> +	rc = tee_client_open_session(ctx, &sess_arg, NULL);
> >> +	if (rc < 0 || sess_arg.ret != 0) {
> >> +		pr_err("Failed to open TEE session err:%#x, ret:%#x\n", sess_arg.ret, rc);
> > 
> > Print normal -Exx error codes as %d, not %x (rc). I don't know what would 
> > be best to do with sess_arg.ret, TEEC_ERROR_* look like errnos (negative 
> > values) manually converted into u32.
> 
> in drivers/tee/amdtee/amdtee_private.h, all the TEEC_* are hex. So
> sess_arg.ret can remain %x?

Sure, you can leave it to %x.

-- 
 i.

  reply	other threads:[~2023-10-09 10:30 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-30  8:36 [PATCH v2 00/16] Introduce PMF Smart PC Solution Builder Feature Shyam Sundar S K
2023-09-30  8:37 ` [PATCH v2 01/16] platform/x86/amd/pmf: Add PMF TEE interface Shyam Sundar S K
2023-10-04 10:50   ` Ilpo Järvinen
2023-10-09  4:58     ` Shyam Sundar S K
2023-10-09 10:29       ` Ilpo Järvinen [this message]
2023-10-04 11:27   ` Ilpo Järvinen
2023-09-30  8:37 ` [PATCH v2 02/16] platform/x86/amd/pmf: Add support PMF-TA interaction Shyam Sundar S K
2023-10-04 10:56   ` Ilpo Järvinen
2023-10-04 12:02   ` Ilpo Järvinen
2023-09-30  8:37 ` [PATCH v2 03/16] platform/x86/amd/pmf: Change return type of amd_pmf_set_dram_addr() Shyam Sundar S K
2023-10-04 11:03   ` Ilpo Järvinen
2023-09-30  8:37 ` [PATCH v2 04/16] platform/x86/amd/pmf: Add support for PMF Policy Binary Shyam Sundar S K
2023-10-04 12:00   ` Ilpo Järvinen
2023-10-09  5:15     ` Shyam Sundar S K
2023-10-09 10:49       ` Ilpo Järvinen
2023-09-30  8:37 ` [PATCH v2 05/16] platform/x86/amd/pmf: change amd_pmf_init_features() call sequence Shyam Sundar S K
2023-09-30  8:37 ` [PATCH v2 06/16] platform/x86/amd/pmf: Add support to get inputs from other subsystems Shyam Sundar S K
2023-10-04 12:14   ` Ilpo Järvinen
2023-10-09  5:20     ` Shyam Sundar S K
2023-10-09 10:26       ` Ilpo Järvinen
2023-09-30  8:37 ` [PATCH v2 07/16] platform/x86/amd/pmf: Add support update p3t limit Shyam Sundar S K
2023-09-30  8:37 ` [PATCH v2 08/16] platform/x86/amd/pmf: Add support to update system state Shyam Sundar S K
2023-10-04 12:23   ` Ilpo Järvinen
2023-10-09  5:44     ` Shyam Sundar S K
2023-09-30  8:37 ` [PATCH v2 09/16] platform/x86/amd/pmf: Add facility to dump TA inputs Shyam Sundar S K
2023-10-04 12:27   ` Ilpo Järvinen
2023-09-30  8:37 ` [PATCH v2 10/16] platform/x86/amd/pmf: Add capability to sideload of policy binary Shyam Sundar S K
2023-09-30  8:37 ` [PATCH v2 11/16] platform/x86/amd/pmf: dump policy binary data Shyam Sundar S K
2023-10-04 12:32   ` Ilpo Järvinen
2023-09-30  8:37 ` [PATCH v2 12/16] platform/x86/amd/pmf: Add PMF-AMDGPU get interface Shyam Sundar S K
2023-10-04 12:49   ` Ilpo Järvinen
2023-10-09  5:56     ` Shyam Sundar S K
2023-10-09 11:02       ` Ilpo Järvinen
2023-09-30  8:37 ` [PATCH v2 13/16] platform/x86/amd/pmf: Add PMF-AMDGPU set interface Shyam Sundar S K
2023-09-30  8:37 ` [PATCH v2 14/16] HID: amd_sfh: rename float_to_int() to amd_sfh_float_to_int() Shyam Sundar S K
2023-09-30  8:37 ` [PATCH v2 15/16] platform/x86/amd/pmf: Add PMF-AMDSFH interface for HPD Shyam Sundar S K
2023-09-30  8:37 ` [PATCH v2 16/16] platform/x86/amd/pmf: Add PMF-AMDSFH interface for ALS 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=f19e6ae-9a60-41d1-8f77-3794948f167a@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