All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Huang, Sean Z" <sean.z.huang@intel.com>
To: "Vivi, Rodrigo" <rodrigo.vivi@intel.com>,
	"Intel-gfx@lists.freedesktop.org"
	<Intel-gfx@lists.freedesktop.org>
Subject: Re: [Intel-gfx] [RFC-v19 08/13] drm/i915/pxp: Enable PXP power management
Date: Tue, 12 Jan 2021 19:14:57 +0000	[thread overview]
Message-ID: <DM6PR11MB453116086A4A8A58AA38EFC6D9AA0@DM6PR11MB4531.namprd11.prod.outlook.com> (raw)
In-Reply-To: <7dd1995a02b103b5c9438555e48bf8f062e7bb01.camel@intel.com>

Hi Rodrigo,

According to our design we terminate the session after resume, and then re-create the session at i915_pxp_tee_component_bind() in intel_pxp_tee.c

We only can terminate the session after resume, instead of during the intel_pxp_pm_prepare_suspend() call, because there is a change that display is stilling rendering/playing-back the protected buffer, and protected surfaces turn corruption garbage if we terminate the session during the suspend().

Best regards,
Sean

-----Original Message-----
From: Vivi, Rodrigo <rodrigo.vivi@intel.com> 
Sent: Thursday, January 7, 2021 9:53 AM
To: Huang, Sean Z <sean.z.huang@intel.com>; Intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [RFC-v19 08/13] drm/i915/pxp: Enable PXP power management

On Wed, 2021-01-06 at 15:12 -0800, Huang, Sean Z wrote:
> 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, 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              |  1 +
>  drivers/gpu/drm/i915/gt/intel_gt_pm.c      |  4 ++
>  drivers/gpu/drm/i915/i915_drv.c            |  4 ++
>  drivers/gpu/drm/i915/pxp/intel_pxp_pm.c    | 65
> ++++++++++++++++++++++
>  drivers/gpu/drm/i915/pxp/intel_pxp_pm.h    | 31 +++++++++++
>  drivers/gpu/drm/i915/pxp/intel_pxp_types.h |  1 +
>  6 files changed, 106 insertions(+)
>  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 5599b92bea9b..7592fc8cbd89 
> 100644
> --- a/drivers/gpu/drm/i915/Makefile
> +++ b/drivers/gpu/drm/i915/Makefile
> @@ -265,6 +265,7 @@ i915-$(CONFIG_DRM_I915_PXP) += \
>         pxp/intel_pxp_arb.o \
>         pxp/intel_pxp_cmd.o \
>         pxp/intel_pxp_context.o \
> +       pxp/intel_pxp_pm.o \
>         pxp/intel_pxp_tee.o
>  
>  # Post-mortem debug and GPU hang state capture diff --git 
> a/drivers/gpu/drm/i915/gt/intel_gt_pm.c
> b/drivers/gpu/drm/i915/gt/intel_gt_pm.c
> index c94e8ac884eb..ae0387e419a2 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt_pm.c
> +++ b/drivers/gpu/drm/i915/gt/intel_gt_pm.c
> @@ -20,6 +20,7 @@
>  #include "intel_rc6.h"
>  #include "intel_rps.h"
>  #include "intel_wakeref.h"
> +#include "pxp/intel_pxp_pm.h"
>  
>  static void user_forcewake(struct intel_gt *gt, bool suspend)  { @@ 
> -266,6 +267,8 @@ int intel_gt_resume(struct intel_gt *gt)
>  
>         intel_uc_resume(&gt->uc);
>  
> +       intel_pxp_pm_resume(&gt->pxp);
> +
>         user_forcewake(gt, false);
>  
>  out_fw:
> @@ -300,6 +303,7 @@ void intel_gt_suspend_prepare(struct intel_gt
> *gt)
>         user_forcewake(gt, true);
>         wait_for_suspend(gt);
>  
> +       intel_pxp_pm_prepare_suspend(&gt->pxp);
>         intel_uc_suspend(&gt->uc);
>  }
>  
> diff --git a/drivers/gpu/drm/i915/i915_drv.c 
> b/drivers/gpu/drm/i915/i915_drv.c index 207d50226e64..5923db004d9b 
> 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"
> @@ -1338,6 +1340,8 @@ static int i915_drm_resume_early(struct 
> drm_device *dev)
>  
>         intel_power_domains_resume(dev_priv);
>  
> +       intel_pxp_pm_resume_early(&dev_priv->gt.pxp);
> +
>         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..ebe89262485c
> --- /dev/null
> +++ b/drivers/gpu/drm/i915/pxp/intel_pxp_pm.c
> @@ -0,0 +1,65 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright(c) 2020 Intel Corporation.
> + */
> +
> +#include "intel_pxp_context.h"
> +#include "intel_pxp_arb.h"
> +#include "intel_pxp_pm.h"
> +
> +void intel_pxp_pm_prepare_suspend(struct intel_pxp *pxp) {
> +       if (!pxp->ctx.inited)
> +               return;
> +
> +       mutex_lock(&pxp->ctx.mutex);
> +
> +       /* Disable PXP-IOCTLs */
> +       pxp->ctx.global_state_in_suspend = true;
> +
> +       mutex_unlock(&pxp->ctx.mutex); }
> +
> +void intel_pxp_pm_resume_early(struct intel_pxp *pxp) {
> +       if (!pxp->ctx.inited)
> +               return;
> +
> +       mutex_lock(&pxp->ctx.mutex);
> +
> +       if (pxp->ctx.global_state_in_suspend) {
> +               /* reset the attacked flag even there was a pending
> */
> +               pxp->ctx.global_state_attacked = false;
> +
> +               pxp->ctx.flag_display_hm_surface_keys = false;
> +       }
> +
> +       mutex_unlock(&pxp->ctx.mutex); }
> +
> +int intel_pxp_pm_resume(struct intel_pxp *pxp) {
> +       int ret = 0;
> +       struct intel_gt *gt = container_of(pxp, typeof(*gt), pxp);
> +
> +       if (!pxp->ctx.inited)
> +               return 0;
> +
> +       mutex_lock(&pxp->ctx.mutex);
> +
> +       /* Re-enable PXP-IOCTLs */
> +       if (pxp->ctx.global_state_in_suspend) {
> +               ret = intel_pxp_arb_terminate_session(pxp);

I'm confused. I was expecting we terminate the session at suspend and re-stablish at resume. But I'm missing or forgetting something

> +               if (ret) {
> +                       drm_err(&gt->i915->drm, "Failed to terminate
> the arb session\n");
> +                       goto end;
> +               }
> +
> +               pxp->ctx.global_state_in_suspend = false;
> +       }
> +
> +end:
> +       mutex_unlock(&pxp->ctx.mutex);
> +
> +       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..135bfb59aaf7
> --- /dev/null
> +++ b/drivers/gpu/drm/i915/pxp/intel_pxp_pm.h
> @@ -0,0 +1,31 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright(c) 2020, Intel Corporation. All rights reserved.
> + */
> +
> +#ifndef __INTEL_PXP_PM_H__
> +#define __INTEL_PXP_PM_H__
> +
> +#include "i915_drv.h"
> +
> +#ifdef CONFIG_DRM_I915_PXP
> +void intel_pxp_pm_prepare_suspend(struct intel_pxp *pxp);
> +
> +void intel_pxp_pm_resume_early(struct intel_pxp *pxp); int 
> +intel_pxp_pm_resume(struct intel_pxp *pxp); #else static inline void 
> +intel_pxp_pm_prepare_suspend(struct intel_pxp
> *pxp)
> +{
> +}
> +
> +static inline void intel_pxp_pm_resume_early(struct intel_pxp *pxp) { 
> +}
> +
> +static inline int intel_pxp_pm_resume(struct intel_pxp *pxp) {
> +       return 0;
> +}
> +#endif
> +
> +#endif /* __INTEL_PXP_PM_H__ */
> diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_types.h
> b/drivers/gpu/drm/i915/pxp/intel_pxp_types.h
> index 0b140aaeb6ed..13d7b502b7f9 100644
> --- a/drivers/gpu/drm/i915/pxp/intel_pxp_types.h
> +++ b/drivers/gpu/drm/i915/pxp/intel_pxp_types.h
> @@ -44,6 +44,7 @@ struct pxp_context {
>  
>         bool flag_display_hm_surface_keys;
>         bool global_state_attacked;
> +       bool global_state_in_suspend;
>  };
>  
>  struct intel_pxp {


_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2021-01-12 19:15 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-06 23:12 [Intel-gfx] [RFC-v19 00/13] Introduce Intel PXP component - Mesa single session Huang, Sean Z
2021-01-06 23:12 ` [Intel-gfx] [RFC-v19 01/13] drm/i915/pxp: Introduce Intel PXP component Huang, Sean Z
2021-01-07 15:28   ` Vivi, Rodrigo
2021-01-11 22:06     ` Huang, Sean Z
2021-01-06 23:12 ` [Intel-gfx] [RFC-v19 02/13] drm/i915/pxp: set KCR reg init during the boot time Huang, Sean Z
2021-01-07 15:31   ` Vivi, Rodrigo
2021-01-08 11:30     ` Joonas Lahtinen
2021-01-11 21:38       ` Huang, Sean Z
2021-01-12 11:27         ` Vivi, Rodrigo
2021-01-12 15:36           ` Jani Nikula
2021-01-06 23:12 ` [Intel-gfx] [RFC-v19 03/13] drm/i915/pxp: Implement funcs to create the TEE channel Huang, Sean Z
2021-01-07 15:36   ` Vivi, Rodrigo
2021-01-11 22:47     ` Huang, Sean Z
2021-01-06 23:12 ` [Intel-gfx] [RFC-v19 04/13] drm/i915/pxp: Create the arbitrary session after boot Huang, Sean Z
2021-01-07 15:40   ` Vivi, Rodrigo
2021-01-11 23:48     ` Huang, Sean Z
2021-01-06 23:12 ` [Intel-gfx] [RFC-v19 05/13] drm/i915/pxp: Func to send hardware session termination Huang, Sean Z
2021-01-07 15:45   ` Vivi, Rodrigo
2021-01-12 18:53     ` Huang, Sean Z
2021-01-06 23:12 ` [Intel-gfx] [RFC-v19 06/13] drm/i915/pxp: Enable PXP irq worker and callback stub Huang, Sean Z
2021-01-06 23:12 ` [Intel-gfx] [RFC-v19 07/13] drm/i915/pxp: Destroy arb session upon teardown Huang, Sean Z
2021-01-06 23:12 ` [Intel-gfx] [RFC-v19 08/13] drm/i915/pxp: Enable PXP power management Huang, Sean Z
2021-01-07 15:52   ` Vivi, Rodrigo
2021-01-12 19:14     ` Huang, Sean Z [this message]
2021-01-06 23:12 ` [Intel-gfx] [RFC-v19 09/13] drm/i915/pxp: Expose session state for display protection flip Huang, Sean Z
2021-01-07 15:54   ` Vivi, Rodrigo
2021-01-18  8:23     ` Huang, Sean Z
2021-01-06 23:12 ` [Intel-gfx] [RFC-v19 10/13] mei: pxp: export pavp client to me client bus Huang, Sean Z
2021-01-06 23:12 ` [Intel-gfx] [RFC-v19 11/13] drm/i915/uapi: introduce drm_i915_gem_create_ext Huang, Sean Z
2021-01-06 23:12 ` [Intel-gfx] [RFC-v19 12/13] drm/i915/pxp: User interface for Protected buffer Huang, Sean Z
2021-01-07 15:58   ` Vivi, Rodrigo
2021-01-18  8:29     ` Huang, Sean Z
2021-01-06 23:12 ` [Intel-gfx] [RFC-v19 13/13] drm/i915/pxp: Add plane decryption support Huang, Sean Z
2021-01-06 23:47 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Introduce Intel PXP component - Mesa single session (rev19) Patchwork
2021-01-07 16:02   ` Vivi, Rodrigo
2021-01-07  0:16 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-01-07 10:22 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2021-01-07 15:42 ` [Intel-gfx] [RFC-v19 00/13] Introduce Intel PXP component - Mesa single session Vivi, Rodrigo
2021-01-08 11:38   ` Joonas Lahtinen
2021-01-12 20:07 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for Introduce Intel PXP component - Mesa single session (rev20) Patchwork
2021-01-17  6:45 ` [Intel-gfx] [RFC-v21 00/13] Introduce Intel PXP component - Mesa single session Huang, Sean Z
2021-01-17  6:45   ` [Intel-gfx] [RFC-v21 01/13] drm/i915/pxp: Introduce Intel PXP component Huang, Sean Z
2021-01-17  6:45   ` [Intel-gfx] [RFC-v21 02/13] drm/i915/pxp: set KCR reg init during the boot time Huang, Sean Z
2021-01-17  6:45   ` [Intel-gfx] [RFC-v21 03/13] drm/i915/pxp: Implement funcs to create the TEE channel Huang, Sean Z
2021-01-17  6:45   ` [Intel-gfx] [RFC-v21 04/13] drm/i915/pxp: Create the arbitrary session after boot Huang, Sean Z
2021-01-17  6:45   ` [Intel-gfx] [RFC-v21 05/13] drm/i915/pxp: Func to send hardware session termination Huang, Sean Z
2021-01-17  6:45   ` [Intel-gfx] [RFC-v21 06/13] drm/i915/pxp: Enable PXP irq worker and callback stub Huang, Sean Z
2021-01-17  6:45   ` [Intel-gfx] [RFC-v21 07/13] drm/i915/pxp: Destroy arb session upon teardown Huang, Sean Z
2021-01-17  6:45   ` [Intel-gfx] [RFC-v21 08/13] drm/i915/pxp: Enable PXP power management Huang, Sean Z
2021-01-17  6:45   ` [Intel-gfx] [RFC-v21 09/13] drm/i915/pxp: Expose session state for display protection flip Huang, Sean Z
2021-01-17  6:45   ` [Intel-gfx] [RFC-v21 10/13] mei: pxp: export pavp client to me client bus Huang, Sean Z
2021-01-17  6:45   ` [Intel-gfx] [RFC-v21 11/13] drm/i915/uapi: introduce drm_i915_gem_create_ext Huang, Sean Z
2021-01-17  6:45   ` [Intel-gfx] [RFC-v21 12/13] drm/i915/pxp: User interface for Protected buffer Huang, Sean Z
2021-01-17  6:45   ` [Intel-gfx] [RFC-v21 13/13] drm/i915/pxp: Add plane decryption support Huang, Sean Z

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=DM6PR11MB453116086A4A8A58AA38EFC6D9AA0@DM6PR11MB4531.namprd11.prod.outlook.com \
    --to=sean.z.huang@intel.com \
    --cc=Intel-gfx@lists.freedesktop.org \
    --cc=rodrigo.vivi@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 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.