Skip to contentSkip to conversation

drm/i915/pxp: Bail early in pxp tee backend on first teardown error

PATCH In review Alan Previn 2 participants 3 messages Nov 16, 2023 – Nov 17, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915/pxp: Bail early in pxp tee backend on first teardown error

For Gen12 when using mei-pxp tee backend tranport, if we are coming up from a cold boot or from a resume (not runtime resume), we can optionally quicken the very first session cleanup that would occur as part of starting up a default PXP session. Typically a cleanup from a cold-start is expected to be quick so we can use a shorter timeout and skip retries (when getting non-success on calling backend transport for intel_pxp_tee_end_arb_fw_session).

While we are touching this area of code, lets not update pxp->platform_cfg_is_bad so its not done inside an "is_foo" helper, move that to the helper's caller.

---
 drivers/gpu/drm/i915/pxp/intel_pxp.c         |  1 +
 drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.c   |  3 ++-
 drivers/gpu/drm/i915/pxp/intel_pxp_pm.c      |  1 +
 drivers/gpu/drm/i915/pxp/intel_pxp_session.c |  1 +
 drivers/gpu/drm/i915/pxp/intel_pxp_tee.c     | 23 +++++++++++++-------
 drivers/gpu/drm/i915/pxp/intel_pxp_types.h   | 10 +++++++++
 6 files changed, 30 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/pxp/intel_pxp.c +1 -0
index dc327cf40b5a..b4de34e6ad01 100644
@@ -140,6 +140,7 @@ static void pxp_init_full(struct intel_pxp *pxp)
 	if (ret)
 		return;
 
+	pxp->hw_state_coldstart = true;
 	if (HAS_ENGINE(pxp->ctrl_gt, GSC0))
 		ret = intel_pxp_gsccs_init(pxp);
 	else
drivers/gpu/drm/i915/pxp/intel_pxp_gsccs.c +2 -1
index 75df959b0aa0..94a26faac14f 100644
@@ -24,7 +24,6 @@ is_fw_err_platform_config(struct intel_pxp *pxp, u32 type)
 	case PXP_STATUS_ERROR_API_VERSION:
 	case PXP_STATUS_PLATFCONFIG_KF1_NOVERIF:
 	case PXP_STATUS_PLATFCONFIG_KF1_BAD:
-		pxp->platform_cfg_is_bad = true;
 		return true;
 	default:
 		break;
@@ -228,6 +227,7 @@ int intel_pxp_gsccs_create_session(struct intel_pxp *pxp,
 		drm_err(&i915->drm, "Failed to init session %d, ret=[%d]\n", arb_session_id, ret);
 	} else if (msg_out.header.status != 0) {
 		if (is_fw_err_platform_config(pxp, msg_out.header.status)) {
+			pxp->platform_cfg_is_bad = true;
 			drm_info_once(&i915->drm,
 				      "PXP init-session-%d failed due to BIOS/SOC:0x%08x:%s\n",
 				      arb_session_id, msg_out.header.status,
@@ -271,6 +271,7 @@ void intel_pxp_gsccs_end_arb_fw_session(struct intel_pxp *pxp, u32 session_id)
 			session_id, ret);
 	} else if (msg_out.header.status != 0) {
 		if (is_fw_err_platform_config(pxp, msg_out.header.status)) {
+			pxp->platform_cfg_is_bad = true;
 			drm_info_once(&i915->drm,
 				      "PXP inv-stream-key-%u failed due to BIOS/SOC :0x%08x:%s\n",
 				      session_id, msg_out.header.status,
drivers/gpu/drm/i915/pxp/intel_pxp_pm.c +1 -0
index 6dfd24918953..fd53b4fd7bac 100644
@@ -60,6 +60,7 @@ static void _pxp_resume(struct intel_pxp *pxp, bool take_wakeref)
 void intel_pxp_resume_complete(struct intel_pxp *pxp)
 {
 	_pxp_resume(pxp, true);
+	pxp->hw_state_coldstart = true;
 }
 
 void intel_pxp_runtime_resume(struct intel_pxp *pxp)
drivers/gpu/drm/i915/pxp/intel_pxp_session.c +1 -0
index 0a3e66b0265e..7979648c6a2c 100644
@@ -114,6 +114,7 @@ static int pxp_terminate_arb_session_and_global(struct intel_pxp *pxp)
 		intel_pxp_gsccs_end_arb_fw_session(pxp, ARB_SESSION);
 	else
 		intel_pxp_tee_end_arb_fw_session(pxp, ARB_SESSION);
+	pxp->hw_state_coldstart = false;
 
 	return ret;
 }
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c +15 -8
index b00d6c280159..07696738d31b 100644
@@ -22,6 +22,7 @@
 #include "intel_pxp_types.h"
 
 #define PXP_TRANSPORT_TIMEOUT_MS 5000 /* 5 sec */
+#define PXP_TRANSPORT_TIMEOUT_FAST_MS 1000 /* 1 sec */
 
 static bool
 is_fw_err_platform_config(struct intel_pxp *pxp, u32 type)
@@ -30,7 +31,6 @@ is_fw_err_platform_config(struct intel_pxp *pxp, u32 type)
 	case PXP_STATUS_ERROR_API_VERSION:
 	case PXP_STATUS_PLATFCONFIG_KF1_NOVERIF:
 	case PXP_STATUS_PLATFCONFIG_KF1_BAD:
-		pxp->platform_cfg_is_bad = true;
 		return true;
 	default:
 		break;
@@ -58,7 +58,8 @@ fw_err_to_string(u32 type)
 static int intel_pxp_tee_io_message(struct intel_pxp *pxp,
 				    void *msg_in, u32 msg_in_size,
 				    void *msg_out, u32 msg_out_max_size,
-				    u32 *msg_out_rcv_size)
+				    u32 *msg_out_rcv_size,
+				    unsigned long timeout_ms)
 {
 	struct drm_i915_private *i915 = pxp->ctrl_gt->i915;
 	struct i915_pxp_component *pxp_component = pxp->pxp_component;
@@ -76,14 +77,14 @@ static int intel_pxp_tee_io_message(struct intel_pxp *pxp,
 	}
 
 	ret = pxp_component->ops->send(pxp_component->tee_dev, msg_in, msg_in_size,
-				       PXP_TRANSPORT_TIMEOUT_MS);
+				       timeout_ms);
 	if (ret) {
 		drm_err(&i915->drm, "Failed to send PXP TEE message\n");
 		goto unlock;
 	}
 
 	ret = pxp_component->ops->recv(pxp_component->tee_dev, msg_out, msg_out_max_size,
-				       PXP_TRANSPORT_TIMEOUT_MS);
+				       timeout_ms);
 	if (ret < 0) {
 		drm_err(&i915->drm, "Failed to receive PXP TEE message\n");
 		goto unlock;
@@ -344,12 +345,13 @@ int intel_pxp_tee_cmd_create_arb_session(struct intel_pxp *pxp,
 	ret = intel_pxp_tee_io_message(pxp,
 				       &msg_in, sizeof(msg_in),
 				       &msg_out, sizeof(msg_out),
-				       NULL);
+				       NULL, PXP_TRANSPORT_TIMEOUT_MS);
 
 	if (ret) {
 		drm_err(&i915->drm, "Failed to send tee msg init arb session, ret=[%d]\n", ret);
 	} else if (msg_out.header.status != 0) {
 		if (is_fw_err_platform_config(pxp, msg_out.header.status)) {
+			pxp->platform_cfg_is_bad = true;
 			drm_info_once(&i915->drm,
 				      "PXP init-arb-session-%d failed due to BIOS/SOC:0x%08x:%s\n",
 				      arb_session_id, msg_out.header.status,
@@ -387,10 +389,14 @@ void intel_pxp_tee_end_arb_fw_session(struct intel_pxp *pxp, u32 session_id)
 	ret = intel_pxp_tee_io_message(pxp,
 				       &msg_in, sizeof(msg_in),
 				       &msg_out, sizeof(msg_out),
-				       NULL);
+				       NULL, pxp->hw_state_coldstart ?
+				       PXP_TRANSPORT_TIMEOUT_FAST_MS : PXP_TRANSPORT_TIMEOUT_MS);
 
-	/* Cleanup coherency between GT and Firmware is critical, so try again if it fails */
-	if ((ret || msg_out.header.status != 0x0) && ++trials < 3)
+	/*
+	 * Cleanup coherency between GT and Firmware is critical, so try again if it
+	 * fails, unless we are performing a cold-start reset
+	 */
+	if ((ret || msg_out.header.status != 0x0) && !pxp->hw_state_coldstart &&  ++trials < 3)
 		goto try_again;
 
 	if (ret) {
@@ -398,6 +404,7 @@ void intel_pxp_tee_end_arb_fw_session(struct intel_pxp *pxp, u32 session_id)
 			session_id, ret);
 	} else if (msg_out.header.status != 0) {
 		if (is_fw_err_platform_config(pxp, msg_out.header.status)) {
+			pxp->platform_cfg_is_bad = true;
 			drm_info_once(&i915->drm,
 				      "PXP inv-stream-key-%u failed due to BIOS/SOC :0x%08x:%s\n",
 				      session_id, msg_out.header.status,
drivers/gpu/drm/i915/pxp/intel_pxp_types.h +10 -0
index 7e11fa8034b2..acafd5dfe12f 100644
@@ -108,6 +108,16 @@ struct intel_pxp {
 	 * we only re-start the arb session when required.
 	 */
 	bool hw_state_invalidated;
+	/**
+	 * @hw_state_coldstart: If we are coming up from a cold boot or from
+	 * resume (not runtime resume) condition, we can optionally quicken
+	 * the very first session cleanup that would occur as part of starting
+	 * up a default PXP session. Typically a cleanup from a cold-start
+	 * is expected to be quick so we can use a shorter timeout and skip
+	 * retries (when getting non-success on calling backend transport
+	 * for intel_pxp_tee_end_arb_fw_session).
+	 */
+	bool hw_state_coldstart;
 
 	/** @irq_enabled: tracks the status of the kcr irqs */
 	bool irq_enabled;

base-commit: 346f47e69d27a4b3177c2939b1f6f26d093ad8c4

Signature · 1 line
2.39.0
#1 lore raw
Quoted 7 lines · Alan Previn

For Gen12 when using mei-pxp tee backend tranport, if we are coming up from a cold boot or from a resume (not runtime resume), we can optionally quicken the very first session cleanup that would occur as part of starting up a default PXP session. Typically a cleanup from a cold-start is expected to be quick so we can use a shorter timeout and skip retries (when getting non-success on calling backend transport for intel_pxp_tee_end_arb_fw_session).

alan:snip

Quoted 5 lines
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c +0 -1
@@ -387,10 +389,14 @@ void intel_pxp_tee_end_arb_fw_session(struct intel_pxp *pxp, u32 session_id)
 	ret = intel_pxp_tee_io_message(pxp,
 				       &msg_in, sizeof(msg_in),
 				       &msg_out, sizeof(msg_out),
-				       NULL);

drivers/gpu/drm/i915/pxp/intel_pxp_tee.c void intel_pxp_tee_end_arb_fw_session(struct intel_pxp *pxp, u32 session_id) · line 399

Quoted 10 lines
drivers/gpu/drm/i915/pxp/intel_pxp_tee.c +7 -2
+				       NULL, pxp->hw_state_coldstart ?
+				       PXP_TRANSPORT_TIMEOUT_FAST_MS : PXP_TRANSPORT_TIMEOUT_MS);
 
-	/* Cleanup coherency between GT and Firmware is critical, so try again if it fails */
-	if ((ret || msg_out.header.status != 0x0) && ++trials < 3)
+	/*
+	 * Cleanup coherency between GT and Firmware is critical, so try again if it
+	 * fails, unless we are performing a cold-start reset
+	 */
+	if ((ret || msg_out.header.status != 0x0) && !pxp->hw_state_coldstart &&  ++trials < 3)

alan: Take note I am working offline with sister teams to perform some end to end conformance testing with more comprehensive OS stacks before we can verify that this optimization doesnt break any existing use-cases.

#2 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for series starting with [v1,1/1] drm/i915/pxp: Bail early in pxp tee backend on first teardown error

In reply to Alan Previn
== Series Details ==

== Series Details ==

Series: series starting with [v1,1/1] drm/i915/pxp: Bail early in pxp tee backend on first teardown error
URL : https://patchwork.freedesktop.org/series/126559/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_13885 -> Patchwork_126559v1
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_126559v1 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes
introduced in Patchwork_126559v1, please notify your bug team ([email protected]) to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126559v1/index.html

Participating hosts (36 -> 38)
------------------------------

Additional (4): bat-rpls-1 bat-kbl-2 fi-ivb-3770 fi-bsw-n3050
Missing (2): bat-dg2-9 fi-snb-2520m

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_126559v1:

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@live@perf:
- fi-kbl-soraka: NOTRUN -> [ABORT][1]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126559v1/fi-kbl-soraka/igt@i915_selftest@[email protected]

* igt@kms_force_connector_basic@force-connector-state:
- bat-rpls-1: NOTRUN -> [ABORT][2]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126559v1/bat-rpls-1/igt@[email protected]

* igt@vgem_basic@unload:
- fi-hsw-4770: [PASS][3] -> [INCOMPLETE][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13885/fi-hsw-4770/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126559v1/fi-hsw-4770/igt@[email protected]

Known issues
------------

Here are the changes found in Patchwork_126559v1 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@debugfs_test@basic-hwmon:
- bat-rpls-1: NOTRUN -> [SKIP][5] ([i915#9318])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126559v1/bat-rpls-1/igt@[email protected]

* igt@fbdev@info:
- bat-rpls-1: NOTRUN -> [SKIP][6] ([i915#1849] / [i915#2582])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126559v1/bat-rpls-1/igt@[email protected]
- bat-kbl-2: NOTRUN -> [SKIP][7] ([fdo#109271] / [i915#1849])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126559v1/bat-kbl-2/igt@[email protected]

* igt@fbdev@write:
- bat-rpls-1: NOTRUN -> [SKIP][8] ([i915#2582]) +3 other tests skip
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126559v1/bat-rpls-1/igt@[email protected]

* igt@gem_huc_copy@huc-copy:
- fi-ivb-3770: NOTRUN -> [SKIP][9] ([fdo#109271]) +15 other tests skip
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126559v1/fi-ivb-3770/igt@[email protected]

* igt@gem_lmem_swapping@parallel-random-engines:
- bat-kbl-2: NOTRUN -> [SKIP][10] ([fdo#109271]) +20 other tests skip
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126559v1/bat-kbl-2/igt@[email protected]

* igt@gem_lmem_swapping@random-engines:
- fi-bsw-n3050: NOTRUN -> [SKIP][11] ([fdo#109271]) +14 other tests skip
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126559v1/fi-bsw-n3050/igt@[email protected]

* igt@gem_tiled_pread_basic:
- bat-rpls-1: NOTRUN -> [SKIP][12] ([i915#3282])
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126559v1/bat-rpls-1/igt@gem_tiled_pread_basic.html

* igt@kms_cursor_legacy@basic-flip-after-cursor-legacy:
- bat-rpls-1: NOTRUN -> [SKIP][13] ([i915#1845]) +9 other tests skip
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126559v1/bat-rpls-1/igt@[email protected]

* igt@kms_flip@basic-flip-vs-modeset:
- bat-rpls-1: NOTRUN -> [SKIP][14] ([i915#3637]) +3 other tests skip
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126559v1/bat-rpls-1/igt@[email protected]

* igt@kms_hdmi_inject@inject-audio:
- fi-bsw-n3050: NOTRUN -> [FAIL][15] ([IGT#3])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126559v1/fi-bsw-n3050/igt@[email protected]

* igt@kms_pipe_crc_basic@read-crc-frame-sequence:
- bat-kbl-2: NOTRUN -> [SKIP][16] ([fdo#109271] / [i915#1845]) +14 other tests skip
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126559v1/bat-kbl-2/igt@[email protected]

#### Possible fixes ####

* igt@kms_addfb_basic@invalid-get-prop-any:
- fi-kbl-soraka: [INCOMPLETE][17] -> [PASS][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13885/fi-kbl-soraka/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126559v1/fi-kbl-soraka/igt@[email protected]

* igt@kms_hdmi_inject@inject-audio:
- fi-kbl-guc: [FAIL][19] ([IGT#3]) -> [PASS][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13885/fi-kbl-guc/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126559v1/fi-kbl-guc/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[IGT#3]: https://gitlab.freedesktop.org/drm/igt-gpu-tools/issues/3
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#1849]: https://gitlab.freedesktop.org/drm/intel/issues/1849
[i915#2582]: https://gitlab.freedesktop.org/drm/intel/issues/2582
[i915#3282]: https://gitlab.freedesktop.org/drm/intel/issues/3282
[i915#3637]: https://gitlab.freedesktop.org/drm/intel/issues/3637
[i915#7359]: https://gitlab.freedesktop.org/drm/intel/issues/7359
[i915#8981]: https://gitlab.freedesktop.org/drm/intel/issues/8981
[i915#9318]: https://gitlab.freedesktop.org/drm/intel/issues/9318
[i915#9648]: https://gitlab.freedesktop.org/drm/intel/issues/9648

Build changes
-------------

* Linux: CI_DRM_13885 -> Patchwork_126559v1

CI-20190529: 20190529
CI_DRM_13885: 346f47e69d27a4b3177c2939b1f6f26d093ad8c4 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7591: b88e512c11fb52704d388a1314614905f2704457 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_126559v1: 346f47e69d27a4b3177c2939b1f6f26d093ad8c4 @ git://anongit.freedesktop.org/gfx-ci/linux

### Linux commits

3f39bf4e7271 drm/i915/pxp: Bail early in pxp tee backend on first teardown error

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_126559v1/index.html