[PATCH 03/10] drm/i915/hdcp: split HDCP GSC message alloc/save responsibilities
Jani Nikula
jani.nikula at intel.com
Thu Apr 24 20:01:35 UTC 2025
Allocate and initialize the HDCP GSC message in
intel_hdcp_gsc_hdcp2_init() as before, but store the pointer to
display->hdcp.hdcp_message in the caller. Similarly, pass in the pointer
to intel_hdcp_gsc_free_message().
Cc: Suraj Kandpal <suraj.kandpal at intel.com>
Signed-off-by: Jani Nikula <jani.nikula at intel.com>
---
drivers/gpu/drm/i915/display/intel_hdcp_gsc.c | 22 +++++++++----------
drivers/gpu/drm/i915/display/intel_hdcp_gsc.h | 4 ++--
.../drm/i915/display/intel_hdcp_gsc_message.c | 12 ++++++----
drivers/gpu/drm/xe/display/xe_hdcp_gsc.c | 22 ++++++++-----------
4 files changed, 29 insertions(+), 31 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_hdcp_gsc.c b/drivers/gpu/drm/i915/display/intel_hdcp_gsc.c
index 92a3ad2166f6..68d912dbd658 100644
--- a/drivers/gpu/drm/i915/display/intel_hdcp_gsc.c
+++ b/drivers/gpu/drm/i915/display/intel_hdcp_gsc.c
@@ -90,37 +90,35 @@ static int intel_hdcp_gsc_initialize_message(struct drm_i915_private *i915,
return err;
}
-int intel_hdcp_gsc_hdcp2_init(struct intel_display *display)
+struct intel_hdcp_gsc_message *intel_hdcp_gsc_hdcp2_init(struct intel_display *display)
{
struct drm_i915_private *i915 = to_i915(display->drm);
struct intel_hdcp_gsc_message *hdcp_message;
int ret;
hdcp_message = kzalloc(sizeof(*hdcp_message), GFP_KERNEL);
-
if (!hdcp_message)
- return -ENOMEM;
+ return ERR_PTR(-ENOMEM);
/*
* NOTE: No need to lock the comp mutex here as it is already
* going to be taken before this function called
*/
- display->hdcp.hdcp_message = hdcp_message;
ret = intel_hdcp_gsc_initialize_message(i915, hdcp_message);
-
- if (ret)
+ if (ret) {
drm_err(display->drm, "Could not initialize hdcp_message\n");
+ kfree(hdcp_message);
+ hdcp_message = ERR_PTR(ret);
+ }
- return ret;
+ return hdcp_message;
}
-void intel_hdcp_gsc_free_message(struct intel_display *display)
+void intel_hdcp_gsc_free_message(struct intel_hdcp_gsc_message *hdcp_message)
{
- struct intel_hdcp_gsc_message *hdcp_message =
- display->hdcp.hdcp_message;
+ if (!hdcp_message)
+ return;
- hdcp_message->hdcp_cmd_in = NULL;
- hdcp_message->hdcp_cmd_out = NULL;
i915_vma_unpin_and_release(&hdcp_message->vma, I915_VMA_RELEASE_MAP);
kfree(hdcp_message);
}
diff --git a/drivers/gpu/drm/i915/display/intel_hdcp_gsc.h b/drivers/gpu/drm/i915/display/intel_hdcp_gsc.h
index ad41e7e80095..f3362720d742 100644
--- a/drivers/gpu/drm/i915/display/intel_hdcp_gsc.h
+++ b/drivers/gpu/drm/i915/display/intel_hdcp_gsc.h
@@ -19,7 +19,7 @@ ssize_t intel_hdcp_gsc_msg_send(struct drm_i915_private *i915, u8 *msg_in,
size_t msg_out_len);
bool intel_hdcp_gsc_check_status(struct intel_display *display);
-int intel_hdcp_gsc_hdcp2_init(struct intel_display *display);
-void intel_hdcp_gsc_free_message(struct intel_display *display);
+struct intel_hdcp_gsc_message *intel_hdcp_gsc_hdcp2_init(struct intel_display *display);
+void intel_hdcp_gsc_free_message(struct intel_hdcp_gsc_message *hdcp_message);
#endif /* __INTEL_HDCP_GCS_H__ */
diff --git a/drivers/gpu/drm/i915/display/intel_hdcp_gsc_message.c b/drivers/gpu/drm/i915/display/intel_hdcp_gsc_message.c
index 8e2aafff71d5..11aa6772f272 100644
--- a/drivers/gpu/drm/i915/display/intel_hdcp_gsc_message.c
+++ b/drivers/gpu/drm/i915/display/intel_hdcp_gsc_message.c
@@ -633,8 +633,9 @@ static const struct i915_hdcp_ops gsc_hdcp_ops = {
int intel_hdcp_gsc_init(struct intel_display *display)
{
+ struct intel_hdcp_gsc_message *hdcp_message;
struct i915_hdcp_arbiter *arbiter;
- int ret;
+ int ret = 0;
arbiter = kzalloc(sizeof(*arbiter), GFP_KERNEL);
if (!arbiter)
@@ -642,8 +643,9 @@ int intel_hdcp_gsc_init(struct intel_display *display)
mutex_lock(&display->hdcp.hdcp_mutex);
- ret = intel_hdcp_gsc_hdcp2_init(display);
- if (ret) {
+ hdcp_message = intel_hdcp_gsc_hdcp2_init(display);
+ if (IS_ERR(hdcp_message)) {
+ ret = PTR_ERR(hdcp_message);
kfree(arbiter);
goto out;
}
@@ -651,6 +653,7 @@ int intel_hdcp_gsc_init(struct intel_display *display)
display->hdcp.arbiter = arbiter;
display->hdcp.arbiter->hdcp_dev = display->drm->dev;
display->hdcp.arbiter->ops = &gsc_hdcp_ops;
+ display->hdcp.hdcp_message = hdcp_message;
out:
mutex_unlock(&display->hdcp.hdcp_mutex);
@@ -660,7 +663,8 @@ int intel_hdcp_gsc_init(struct intel_display *display)
void intel_hdcp_gsc_fini(struct intel_display *display)
{
- intel_hdcp_gsc_free_message(display);
+ intel_hdcp_gsc_free_message(display->hdcp.hdcp_message);
+ display->hdcp.hdcp_message = NULL;
kfree(display->hdcp.arbiter);
display->hdcp.arbiter = NULL;
}
diff --git a/drivers/gpu/drm/xe/display/xe_hdcp_gsc.c b/drivers/gpu/drm/xe/display/xe_hdcp_gsc.c
index 21cfecf077bf..d15565bf2f9f 100644
--- a/drivers/gpu/drm/xe/display/xe_hdcp_gsc.c
+++ b/drivers/gpu/drm/xe/display/xe_hdcp_gsc.c
@@ -99,15 +99,14 @@ static int intel_hdcp_gsc_initialize_message(struct intel_display *display,
return ret;
}
-int intel_hdcp_gsc_hdcp2_init(struct intel_display *display)
+struct intel_hdcp_gsc_message *intel_hdcp_gsc_hdcp2_init(struct intel_display *display)
{
struct intel_hdcp_gsc_message *hdcp_message;
int ret;
hdcp_message = kzalloc(sizeof(*hdcp_message), GFP_KERNEL);
-
if (!hdcp_message)
- return -ENOMEM;
+ return ERR_PTR(-ENOMEM);
/*
* NOTE: No need to lock the comp mutex here as it is already
@@ -117,22 +116,19 @@ int intel_hdcp_gsc_hdcp2_init(struct intel_display *display)
if (ret) {
drm_err(display->drm, "Could not initialize hdcp_message\n");
kfree(hdcp_message);
- return ret;
+ hdcp_message = ERR_PTR(ret);
}
- display->hdcp.hdcp_message = hdcp_message;
- return ret;
+ return hdcp_message;
}
-void intel_hdcp_gsc_free_message(struct intel_display *display)
+void intel_hdcp_gsc_free_message(struct intel_hdcp_gsc_message *hdcp_message)
{
- struct intel_hdcp_gsc_message *hdcp_message = display->hdcp.hdcp_message;
+ if (!hdcp_message)
+ return;
- if (hdcp_message) {
- xe_bo_unpin_map_no_vm(hdcp_message->hdcp_bo);
- kfree(hdcp_message);
- display->hdcp.hdcp_message = NULL;
- }
+ xe_bo_unpin_map_no_vm(hdcp_message->hdcp_bo);
+ kfree(hdcp_message);
}
static int xe_gsc_send_sync(struct xe_device *xe,
--
2.39.5
More information about the Intel-xe
mailing list