public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Sean Z Huang <sean.z.huang@intel.com>,
	sean.z.huang@intel.com, Intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PXP CLEAN PATCH v06 17/27] drm/i915/pxp: Enable PXP power management
Date: Mon, 23 Nov 2020 17:09:42 +0200	[thread overview]
Message-ID: <874klgnm89.fsf@intel.com> (raw)
In-Reply-To: <20201114003716.4875-17-sean.z.huang@intel.com>

On Fri, 13 Nov 2020, Sean Z Huang <sean.z.huang@intel.com> wrote:
> From: "Huang, Sean Z" <sean.z.huang@intel.com>
>
> During the power event S3+ sleep/resume, hardware will lose all the
> encryption keys for every hardware session, even though the
> software session state was marked as alive after resume. So to
> handle such case, ring0 PXP should terminate all the hardware
> sessions and cleanup all the software states after the power cycle.
>
> Signed-off-by: Huang, Sean Z <sean.z.huang@intel.com>
> ---
>  drivers/gpu/drm/i915/Makefile           |  3 +-
>  drivers/gpu/drm/i915/i915_drv.c         |  8 +++
>  drivers/gpu/drm/i915/pxp/intel_pxp_pm.c | 83 +++++++++++++++++++++++++
>  drivers/gpu/drm/i915/pxp/intel_pxp_pm.h | 14 +++++
>  4 files changed, 107 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_pm.c
>  create mode 100644 drivers/gpu/drm/i915/pxp/intel_pxp_pm.h
>
> diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
> index 81432a9f44d6..6858392c1ef2 100644
> --- a/drivers/gpu/drm/i915/Makefile
> +++ b/drivers/gpu/drm/i915/Makefile
> @@ -258,7 +258,8 @@ i915-y += i915_perf.o
>  i915-y += \
>  	pxp/intel_pxp.o \
>  	pxp/intel_pxp_context.o \
> -	pxp/intel_pxp_sm.o
> +	pxp/intel_pxp_sm.o \
> +	pxp/intel_pxp_pm.o

Alphabetical order, please.

>  
>  # Post-mortem debug and GPU hang state capture
>  i915-$(CONFIG_DRM_I915_CAPTURE_ERROR) += i915_gpu_error.o
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index e61ffce52e3e..830708414f92 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -68,6 +68,8 @@
>  #include "gt/intel_gt_pm.h"
>  #include "gt/intel_rc6.h"
>  
> +#include "pxp/intel_pxp_pm.h"
> +
>  #include "i915_debugfs.h"
>  #include "i915_drv.h"
>  #include "i915_ioc32.h"
> @@ -1094,6 +1096,8 @@ static int i915_drm_prepare(struct drm_device *dev)
>  	 */
>  	i915_gem_suspend(i915);
>  
> +	intel_pxp_pm_prepare_suspend(i915);
> +
>  	return 0;
>  }
>  
> @@ -1277,6 +1281,8 @@ static int i915_drm_resume(struct drm_device *dev)
>  
>  	intel_power_domains_enable(dev_priv);
>  
> +	intel_pxp_pm_resume(dev_priv);
> +
>  	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
>  
>  	return 0;
> @@ -1348,6 +1354,8 @@ static int i915_drm_resume_early(struct drm_device *dev)
>  
>  	intel_power_domains_resume(dev_priv);
>  
> +	intel_pxp_pm_resume_early(dev_priv);
> +
>  	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
>  
>  	return ret;
> diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_pm.c b/drivers/gpu/drm/i915/pxp/intel_pxp_pm.c
> new file mode 100644
> index 000000000000..18d33efca9d9
> --- /dev/null
> +++ b/drivers/gpu/drm/i915/pxp/intel_pxp_pm.c
> @@ -0,0 +1,83 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright(c) 2020 Intel Corporation.
> + */
> +
> +#include "i915_drv.h"
> +#include "intel_pxp_context.h"
> +#include "intel_pxp_sm.h"
> +#include "intel_pxp_pm.h"
> +
> +void intel_pxp_pm_prepare_suspend(struct drm_i915_private *i915)
> +{
> +	drm_dbg(&i915->drm, ">>> %s\n", __func__);
> +
> +	if (!i915->pxp.r0ctx)
> +		return;
> +
> +	mutex_lock(&i915->pxp.r0ctx->ctx_mutex);
> +
> +	/* Disable PXP-IOCTLs */
> +	i915->pxp.r0ctx->global_state_in_suspend = true;
> +
> +	mutex_unlock(&i915->pxp.r0ctx->ctx_mutex);
> +
> +	drm_dbg(&i915->drm, "<<< %s\n", __func__);
> +}
> +
> +void intel_pxp_pm_resume_early(struct drm_i915_private *i915)
> +{
> +	drm_dbg(&i915->drm, ">>> %s\n", __func__);
> +
> +	if (!i915->pxp.r0ctx)
> +		return;
> +
> +	mutex_lock(&i915->pxp.r0ctx->ctx_mutex);
> +
> +	if (i915->pxp.r0ctx->global_state_in_suspend) {
> +		/* reset the attacked flag even there was a pending */
> +		i915->pxp.r0ctx->global_state_attacked = false;
> +
> +		i915->pxp.r0ctx->flag_display_hm_surface_keys = false;
> +	}
> +
> +	mutex_unlock(&i915->pxp.r0ctx->ctx_mutex);
> +	drm_dbg(&i915->drm, "<<< %s\n", __func__);
> +}
> +
> +int intel_pxp_pm_resume(struct drm_i915_private *i915)
> +{
> +	int ret = 0;
> +
> +	drm_dbg(&i915->drm, ">>> %s\n", __func__);
> +
> +	if (!i915->pxp.r0ctx)
> +		return 0;
> +
> +	mutex_lock(&i915->pxp.r0ctx->ctx_mutex);
> +
> +	/* Re-enable PXP-IOCTLs */
> +	if (i915->pxp.r0ctx->global_state_in_suspend) {
> +		intel_pxp_destroy_r3ctx_list(i915);
> +
> +		ret = intel_pxp_sm_terminate_all_active_sessions(i915, SESSION_TYPE_TYPE0);
> +		if (ret) {
> +			drm_dbg(&i915->drm, "Failed to intel_pxp_sm_terminate_all_active_sessions with type0\n");
> +			goto end;
> +		}
> +
> +		ret = intel_pxp_sm_terminate_all_active_sessions(i915, SESSION_TYPE_TYPE1);
> +		if (ret) {
> +			drm_dbg(&i915->drm, "Failed to intel_pxp_sm_terminate_all_active_sessions with type1\n");
> +			goto end;
> +		}
> +
> +		i915->pxp.r0ctx->global_state_in_suspend = false;
> +	}
> +
> +end:
> +	mutex_unlock(&i915->pxp.r0ctx->ctx_mutex);
> +	drm_dbg(&i915->drm, "<<< %s ret=[%d]\n", __func__, ret);
> +
> +	return ret;
> +}
> diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_pm.h b/drivers/gpu/drm/i915/pxp/intel_pxp_pm.h
> new file mode 100644
> index 000000000000..0b1e4af1d36f
> --- /dev/null
> +++ b/drivers/gpu/drm/i915/pxp/intel_pxp_pm.h
> @@ -0,0 +1,14 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright(c) 2020, Intel Corporation. All rights reserved.
> + */
> +
> +#ifndef __INTEL_PXP_PM_H__
> +#define __INTEL_PXP_PM_H__
> +
> +void intel_pxp_pm_prepare_suspend(struct drm_i915_private *i915);
> +
> +void intel_pxp_pm_resume_early(struct drm_i915_private *i915);
> +int intel_pxp_pm_resume(struct drm_i915_private *i915);

This will fail with DRM_I915_WERROR=y, which enables some more pedantic
header tests. Please use that config option while developing.

BR,
Jani.

> +
> +#endif

-- 
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2020-11-23 15:09 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-14  0:36 [Intel-gfx] [PXP CLEAN PATCH v06 01/27] drm/i915/pxp: Introduce Intel PXP component Sean Z Huang
2020-11-14  0:36 ` [Intel-gfx] [PXP CLEAN PATCH v06 02/27] drm/i915/pxp: Enable PXP irq worker and callback stub Sean Z Huang
2020-11-16 14:27   ` Souza, Jose
2020-11-23 15:01     ` Jani Nikula
2020-11-14  0:36 ` [Intel-gfx] [PXP CLEAN PATCH v06 03/27] drm/i915/pxp: Add PXP context for logical hardware states Sean Z Huang
2020-11-14  0:36 ` [Intel-gfx] [PXP CLEAN PATCH v06 04/27] drm/i915/pxp: set KCR reg init during the boot time Sean Z Huang
2020-11-14  0:36 ` [Intel-gfx] [PXP CLEAN PATCH v06 05/27] drm/i915/pxp: Enable ioctl action to set the ring3 context Sean Z Huang
2020-11-14  0:36 ` [Intel-gfx] [PXP CLEAN PATCH v06 06/27] drm/i915: Rename the whitelist to allowlist Sean Z Huang
2020-11-23 15:04   ` Jani Nikula
2020-11-14  0:36 ` [Intel-gfx] [PXP CLEAN PATCH v06 07/27] drm/i915/pxp: Add PXP-related registers into allowlist Sean Z Huang
2020-11-23 15:05   ` Jani Nikula
2020-11-14  0:36 ` [Intel-gfx] [PXP CLEAN PATCH v06 08/27] drm/i915/pxp: Read register to check hardware session state Sean Z Huang
2020-11-14  2:42   ` kernel test robot
2020-11-14  0:36 ` [Intel-gfx] [PXP CLEAN PATCH v06 09/27] drm/i915/pxp: Implement funcs to get/set PXP tag Sean Z Huang
2020-11-14  0:36 ` [Intel-gfx] [PXP CLEAN PATCH v06 10/27] drm/i915/pxp: Enable ioctl action to reserve session slot Sean Z Huang
2020-11-14  0:37 ` [Intel-gfx] [PXP CLEAN PATCH v06 11/27] drm/i915/pxp: Enable ioctl action to set session in play Sean Z Huang
2020-11-14  0:37 ` [Intel-gfx] [PXP CLEAN PATCH v06 12/27] drm/i915/pxp: Func to send hardware session termination Sean Z Huang
2020-11-14  0:37 ` [Intel-gfx] [PXP CLEAN PATCH v06 13/27] drm/i915/pxp: Enable ioctl action to terminate the session Sean Z Huang
2020-11-14  0:37 ` [Intel-gfx] [PXP CLEAN PATCH v06 14/27] drm/i915/pxp: Enable ioctl action to query PXP tag Sean Z Huang
2020-11-14  0:37 ` [Intel-gfx] [PXP CLEAN PATCH v06 15/27] drm/i915/pxp: Destroy all type0 sessions upon teardown Sean Z Huang
2020-11-14  0:37 ` [Intel-gfx] [PXP CLEAN PATCH v06 16/27] drm/i915/pxp: Termiante the session upon app crash Sean Z Huang
2020-11-14  0:37 ` [Intel-gfx] [PXP CLEAN PATCH v06 17/27] drm/i915/pxp: Enable PXP power management Sean Z Huang
2020-11-23 15:09   ` Jani Nikula [this message]
2020-11-14  0:37 ` [Intel-gfx] [PXP CLEAN PATCH v06 18/27] drm/i915/pxp: Implement funcs to create the TEE channel Sean Z Huang
2020-11-14  0:37 ` [Intel-gfx] [PXP CLEAN PATCH v06 19/27] drm/i915/pxp: Enable ioctl action to send TEE commands Sean Z Huang
2020-11-14  0:37 ` [Intel-gfx] [PXP CLEAN PATCH v06 20/27] drm/i915/pxp: Create the arbitrary session after boot Sean Z Huang
2020-11-14  0:37 ` [Intel-gfx] [PXP CLEAN PATCH v06 21/27] drm/i915/pxp: Add i915 trace logs for PXP operations Sean Z Huang
2020-11-14  0:37 ` [Intel-gfx] [PXP CLEAN PATCH v06 22/27] drm/i915/pxp: Expose session state for display protection flip Sean Z Huang
2020-11-14  0:37 ` [Intel-gfx] [PXP CLEAN PATCH v06 23/27] mei: bus: enable pavp device Sean Z Huang
2020-11-14  0:37 ` [Intel-gfx] [PXP CLEAN PATCH v06 24/27] mei: pxp: export pavp client to me client bus Sean Z Huang
2020-11-14  0:37 ` [Intel-gfx] [PXP CLEAN PATCH v06 25/27] drm/i915/uapi: introduce drm_i915_gem_create_ext for TGL Sean Z Huang
2020-11-14  0:37 ` [Intel-gfx] [PXP CLEAN PATCH v06 26/27] drm/i915/pavp: User interface for Protected buffer Sean Z Huang
2020-11-14  0:37 ` [Intel-gfx] [PXP CLEAN PATCH v06 27/27] drm/i915/pxp: Add plane decryption support Sean Z Huang
2020-11-14  0:42 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for series starting with [PXP,CLEAN,v06,01/27] drm/i915/pxp: Introduce Intel PXP component Patchwork
2020-11-23 15:13   ` Jani Nikula
2020-11-16 14:24 ` [Intel-gfx] [PXP CLEAN PATCH v06 01/27] " Souza, Jose

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=874klgnm89.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=Intel-gfx@lists.freedesktop.org \
    --cc=sean.z.huang@intel.com \
    /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