Skip to contentSkip to conversation

Refactor i915 HDCP for XE

PATCH Superseded Suraj Kandpal 2 participants 5 messages Oct 9, 2023

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

v5 cover Refactor i915 HDCP for XE

This patch series contains some refactors for i915 side of things which will help with a cleaner code and maximum reuse of code for XE going forward.

Suraj Kandpal (2):
drm/i915/hdcp: Move checks for gsc health status drm/i915/hdcp: Move common message filling function to its own file

 drivers/gpu/drm/i915/Makefile                 |   1 +
 drivers/gpu/drm/i915/display/intel_hdcp.c     |   8 +-
 drivers/gpu/drm/i915/display/intel_hdcp_gsc.c | 617 +-----------------
 drivers/gpu/drm/i915/display/intel_hdcp_gsc.h |   1 +
 .../drm/i915/display/intel_hdcp_gsc_message.c | 592 +++++++++++++++++
 .../drm/i915/display/intel_hdcp_gsc_message.h |  72 ++
 6 files changed, 692 insertions(+), 599 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/display/intel_hdcp_gsc_message.c
 create mode 100644 drivers/gpu/drm/i915/display/intel_hdcp_gsc_message.h
Signature · 1 line
2.25.1
#1 lore raw

PATCH v5 1/2 drm/i915/hdcp: Move checks for gsc health status

Move checks for gsc components required for HDCP 2.2 to work into intel_hdcp_gsc.c. This will also help with XE refactor on HDCP's side.

---
 drivers/gpu/drm/i915/display/intel_hdcp.c     |  8 +-------
 drivers/gpu/drm/i915/display/intel_hdcp_gsc.c | 14 ++++++++++++++
 drivers/gpu/drm/i915/display/intel_hdcp_gsc.h |  1 +
 3 files changed, 16 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/display/intel_hdcp.c +1 -7
index 8cca4793cf92..c89da3568ebd 100644
@@ -173,14 +173,8 @@ bool intel_hdcp2_capable(struct intel_connector *connector)
 
 	/* If MTL+ make sure gsc is loaded and proxy is setup */
 	if (intel_hdcp_gsc_cs_required(i915)) {
-		struct intel_gt *gt = i915->media_gt;
-		struct intel_gsc_uc *gsc = gt ? &gt->uc.gsc : NULL;
-
-		if (!gsc || !intel_uc_fw_is_running(&gsc->fw)) {
-			drm_dbg_kms(&i915->drm,
-				    "GSC components required for HDCP2.2 are not ready\n");
+		if (!intel_hdcp_gsc_check_status(i915))
 			return false;
-		}
 	}
 
 	/* MEI/GSC interface is solid depending on which is used */
drivers/gpu/drm/i915/display/intel_hdcp_gsc.c +14 -0
index d753db3eef15..d355d610bc9f 100644
@@ -17,6 +17,20 @@ bool intel_hdcp_gsc_cs_required(struct drm_i915_private *i915)
 	return DISPLAY_VER(i915) >= 14;
 }
 
+bool intel_hdcp_gsc_check_status(struct drm_i915_private *i915)
+{
+	struct intel_gt *gt = i915->media_gt;
+	struct intel_gsc_uc *gsc = gt ? &gt->uc.gsc : NULL;
+
+	if (!gsc || !intel_uc_fw_is_running(&gsc->fw)) {
+		drm_dbg_kms(&i915->drm,
+			    "GSC components required for HDCP2.2 are not ready\n");
+		return false;
+	}
+
+	return true;
+}
+
 static int
 gsc_hdcp_initiate_session(struct device *dev, struct hdcp_port_data *data,
 			  struct hdcp2_ake_init *ake_data)
drivers/gpu/drm/i915/display/intel_hdcp_gsc.h +1 -0
index cbf96551e534..eba2057c5a9e 100644
@@ -23,5 +23,6 @@ ssize_t intel_hdcp_gsc_msg_send(struct drm_i915_private *i915, u8 *msg_in,
 				size_t msg_out_len);
 int intel_hdcp_gsc_init(struct drm_i915_private *i915);
 void intel_hdcp_gsc_fini(struct drm_i915_private *i915);
+bool intel_hdcp_gsc_check_status(struct drm_i915_private *i915);
 
 #endif /* __INTEL_HDCP_GCS_H__ */
Signature · 1 line
2.25.1
maintainer
#2 lore raw

Re: [Intel-gfx] [PATCH v5 1/2] drm/i915/hdcp: Move checks for gsc health status

Quoted 17 lines · Suraj Kandpal

Move checks for gsc components required for HDCP 2.2 to work into intel_hdcp_gsc.c. This will also help with XE refactor on HDCP's side.

---
 drivers/gpu/drm/i915/display/intel_hdcp.c     |  8 +-------
 drivers/gpu/drm/i915/display/intel_hdcp_gsc.c | 14 ++++++++++++++
 drivers/gpu/drm/i915/display/intel_hdcp_gsc.h |  1 +
 3 files changed, 16 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/display/intel_hdcp.c +0 -0
index 8cca4793cf92..c89da3568ebd 100644

drivers/gpu/drm/i915/display/intel_hdcp.c bool intel_hdcp2_capable(struct intel_connector *connector) · line 176

Quoted 10 lines
drivers/gpu/drm/i915/display/intel_hdcp.c +1 -6
@@ -173,14 +173,8 @@ bool intel_hdcp2_capable(struct intel_connector *connector)
 
 	/* If MTL+ make sure gsc is loaded and proxy is setup */
 	if (intel_hdcp_gsc_cs_required(i915)) {
-		struct intel_gt *gt = i915->media_gt;
-		struct intel_gsc_uc *gsc = gt ? &gt->uc.gsc : NULL;
-
-		if (!gsc || !intel_uc_fw_is_running(&gsc->fw)) {
-			drm_dbg_kms(&i915->drm,
-				    "GSC components required for HDCP2.2 are not ready\n");
+		if (!intel_hdcp_gsc_check_status(i915))

Naming nitpick, though not intended to block the patch:

I always stop at functions named "check" that return a value. What does the return value mean? The above code reads, "if not check status".

So I usually try to name functions so that it's obvious on both sides what it means, when you read it aloud. For example, "if not status ok".

Just something to consider for the future.

BR,
Jani.

Quoted 41 lines
drivers/gpu/drm/i915/display/intel_hdcp.c +0 -1
 			return false;
-		}
 	}
 
 	/* MEI/GSC interface is solid depending on which is used */
drivers/gpu/drm/i915/display/intel_hdcp_gsc.c +14 -0
index d753db3eef15..d355d610bc9f 100644
@@ -17,6 +17,20 @@ bool intel_hdcp_gsc_cs_required(struct drm_i915_private *i915)
 	return DISPLAY_VER(i915) >= 14;
 }
 
+bool intel_hdcp_gsc_check_status(struct drm_i915_private *i915)
+{
+	struct intel_gt *gt = i915->media_gt;
+	struct intel_gsc_uc *gsc = gt ? &gt->uc.gsc : NULL;
+
+	if (!gsc || !intel_uc_fw_is_running(&gsc->fw)) {
+		drm_dbg_kms(&i915->drm,
+			    "GSC components required for HDCP2.2 are not ready\n");
+		return false;
+	}
+
+	return true;
+}
+
 static int
 gsc_hdcp_initiate_session(struct device *dev, struct hdcp_port_data *data,
 			  struct hdcp2_ake_init *ake_data)
drivers/gpu/drm/i915/display/intel_hdcp_gsc.h +1 -0
index cbf96551e534..eba2057c5a9e 100644
@@ -23,5 +23,6 @@ ssize_t intel_hdcp_gsc_msg_send(struct drm_i915_private *i915, u8 *msg_in,
 				size_t msg_out_len);
 int intel_hdcp_gsc_init(struct drm_i915_private *i915);
 void intel_hdcp_gsc_fini(struct drm_i915_private *i915);
+bool intel_hdcp_gsc_check_status(struct drm_i915_private *i915);
 
 #endif /* __INTEL_HDCP_GCS_H__ */
Signature · 1 line
Jani Nikula, Intel
#3 lore raw

Re: [Intel-gfx] [PATCH v5 1/2] drm/i915/hdcp: Move checks for gsc health status

Quoted 42 lines

-----Original Message-----
From: Jani Nikula <[email protected]>
Sent: Monday, October 9, 2023 3:37 PM
To: Kandpal, Suraj <[email protected]>; [email protected]
Subject: Re: [Intel-gfx] [PATCH v5 1/2] drm/i915/hdcp: Move checks for gsc health status

Quoted 17 lines · Suraj Kandpal

Move checks for gsc components required for HDCP 2.2 to work into intel_hdcp_gsc.c. This will also help with XE refactor on HDCP's side.

---
 drivers/gpu/drm/i915/display/intel_hdcp.c     |  8 +-------
 drivers/gpu/drm/i915/display/intel_hdcp_gsc.c | 14 ++++++++++++++
drivers/gpu/drm/i915/display/intel_hdcp_gsc.h |  1 +
 3 files changed, 16 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/display/intel_hdcp.c +0 -0
index 8cca4793cf92..c89da3568ebd 100644

drivers/gpu/drm/i915/display/intel_hdcp.c bool intel_hdcp2_capable(struct intel_connector · line 182

Quoted 10 lines
drivers/gpu/drm/i915/display/intel_hdcp.c +0 -6
@@ -173,14 +173,8 @@ bool intel_hdcp2_capable(struct intel_connector
 *connector)
 
 	/* If MTL+ make sure gsc is loaded and proxy is setup */
 	if (intel_hdcp_gsc_cs_required(i915)) {
-		struct intel_gt *gt = i915->media_gt;
-		struct intel_gsc_uc *gsc = gt ? &gt->uc.gsc : NULL;
-
-		if (!gsc || !intel_uc_fw_is_running(&gsc->fw)) {
-			drm_dbg_kms(&i915->drm,
-				    "GSC components required for HDCP2.2 are

not ready\n");

drivers/gpu/drm/i915/display/intel_hdcp.c bool intel_hdcp2_capable(struct intel_connector *connector) · line 176

Quoted 1 line
drivers/gpu/drm/i915/display/intel_hdcp.c +1 -0
+		if (!intel_hdcp_gsc_check_status(i915))

Naming nitpick, though not intended to block the patch:

Quoted 9 lines

I always stop at functions named "check" that return a value. What does the return value mean? The above code reads, "if not check status".

So I usually try to name functions so that it's obvious on both sides what it means, when you read it aloud. For example, "if not status ok".

Just something to consider for the future.

Got it Jani will keep this in mind in future

Regards,
Suraj Kandpal

Quoted 53 lines

BR,
Jani.

drivers/gpu/drm/i915/display/intel_hdcp_gsc.c bool intel_hdcp_gsc_cs_required(struct

Quoted 11 lines
drivers/gpu/drm/i915/display/intel_hdcp.c +0 -1
 			return false;
-		}
 	}
 

/* MEI/GSC interface is solid depending on which is used */ diff
--git a/drivers/gpu/drm/i915/display/intel_hdcp_gsc.c b/drivers/gpu/drm/i915/display/intel_hdcp_gsc.c
index d753db3eef15..d355d610bc9f 100644

drivers/gpu/drm/i915/display/intel_hdcp_gsc.c +0 -0
@@ -17,6 +17,20 @@ bool intel_hdcp_gsc_cs_required(struct

drm_i915_private *i915)

drivers/gpu/drm/i915/display/intel_hdcp_gsc.c bool intel_hdcp_gsc_cs_required(struct drm_i915_private *i915)

Quoted 10 lines
drivers/gpu/drm/i915/display/intel_hdcp_gsc.c +7 -0
 	return DISPLAY_VER(i915) >= 14;
 }
 
+bool intel_hdcp_gsc_check_status(struct drm_i915_private *i915) {
+	struct intel_gt *gt = i915->media_gt;
+	struct intel_gsc_uc *gsc = gt ? &gt->uc.gsc : NULL;
+
+	if (!gsc || !intel_uc_fw_is_running(&gsc->fw)) {
+		drm_dbg_kms(&i915->drm,
+			    "GSC components required for HDCP2.2 are not

ready\n");

drivers/gpu/drm/i915/display/intel_hdcp_gsc.h ssize_t intel_hdcp_gsc_msg_send(struct

Quoted 15 lines
drivers/gpu/drm/i915/display/intel_hdcp_gsc.c +6 -0
+		return false;
+	}
+
+	return true;
+}
+
 static int
 gsc_hdcp_initiate_session(struct device *dev, struct hdcp_port_data *data,
 			  struct hdcp2_ake_init *ake_data) diff --git

a/drivers/gpu/drm/i915/display/intel_hdcp_gsc.h
b/drivers/gpu/drm/i915/display/intel_hdcp_gsc.h
index cbf96551e534..eba2057c5a9e 100644

drivers/gpu/drm/i915/display/intel_hdcp_gsc.h +0 -0
@@ -23,5 +23,6 @@ ssize_t intel_hdcp_gsc_msg_send(struct

drm_i915_private *i915, u8 *msg_in,

drivers/gpu/drm/i915/display/intel_hdcp_gsc.h ssize_t intel_hdcp_gsc_msg_send(struct drm_i915_private *i915, u8 *msg_in, · line 28

Quoted 6 lines
drivers/gpu/drm/i915/display/intel_hdcp_gsc.h +1 -0
 				size_t msg_out_len);
 int intel_hdcp_gsc_init(struct drm_i915_private *i915);  void
 intel_hdcp_gsc_fini(struct drm_i915_private *i915);
+bool intel_hdcp_gsc_check_status(struct drm_i915_private *i915);
 
 #endif /* __INTEL_HDCP_GCS_H__ */

--
Jani Nikula, Intel

#4 lore raw

PATCH v5 2/2 drm/i915/hdcp: Move common message filling function to its own file

In reply to Suraj Kandpal

Create a new file intel_hdcp_gsc_message that contain functions which fill the hdcp messages we send to gsc cs this refactor will help us reuse code for Xe later on

--v2
-add the missed file for proper build

--v3
-use forward declarations instead of #includes [Jani]

--v4
-move linux/err.h to intel_hdcp_gsc_message.c from intel_hdcp_gsc_message.h [Jani]

--v5
-move linux include on top of drm includes [Uma]

---
 drivers/gpu/drm/i915/Makefile                 |   1 +
 drivers/gpu/drm/i915/display/intel_hdcp_gsc.c | 615 +-----------------
 .../drm/i915/display/intel_hdcp_gsc_message.c | 592 +++++++++++++++++
 .../drm/i915/display/intel_hdcp_gsc_message.h |  72 ++
 4 files changed, 682 insertions(+), 598 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/display/intel_hdcp_gsc_message.c
 create mode 100644 drivers/gpu/drm/i915/display/intel_hdcp_gsc_message.h
drivers/gpu/drm/i915/Makefile +1 -0
index dec78efa452a..332ff7021cf2 100644
@@ -269,6 +269,7 @@ i915-y += \
 	display/intel_global_state.o \
 	display/intel_hdcp.o \
 	display/intel_hdcp_gsc.o \
+	display/intel_hdcp_gsc_message.o \
 	display/intel_hotplug.o \
 	display/intel_hotplug_irq.o \
 	display/intel_hti.o \
drivers/gpu/drm/i915/display/intel_hdcp_gsc.c +17 -598

633 lines not on this page · raw message

drivers/gpu/drm/i915/display/intel_hdcp_gsc_message.c new file +592 -0

592 lines not on this page · raw message

drivers/gpu/drm/i915/display/intel_hdcp_gsc_message.h new file +72 -0

72 lines not on this page · raw message

Signature · 1 line
2.25.1