Blob Blame History Raw
From: Ramalingam C <ramalingam.c@intel.com>
Date: Sat, 3 Feb 2018 03:39:04 +0530
Subject: drm/i915: Stop encryption for repeater with no sink
Git-commit: f179a2fc2e23ff623344717eec3b8a443a57222a
Patch-mainline: v4.17-rc1
References: FATE#326289 FATE#326079 FATE#326049 FATE#322398 FATE#326166

If a HDCP repeater is detected with zero downstream devices,
HDCP spec approves either of below actions:

1. Dont continue on second stage authentication. Disable encryption.
2. Continue with second stage authentication excluding the KSV list and
   on success, continue encryption.

Since disable encryption is agreed, repeater is not expected to have its
own display. So there is no consumption of the display content in such
setup.

Hence, incase of repeater with zero device count, this patch fails the
HDCP authentication and stops the HDCP encryption.

v2:
  Rephrased commit msg and added comments in code [Seanpaul]

v3:
  No changes. Added Reviewed-by tag.

Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/1517609350-10698-3-git-send-email-ramalingam.c@intel.com

Acked-by: Petr Tesarik <ptesarik@suse.com>
---
 drivers/gpu/drm/i915/intel_hdcp.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

--- a/drivers/gpu/drm/i915/intel_hdcp.c
+++ b/drivers/gpu/drm/i915/intel_hdcp.c
@@ -166,10 +166,16 @@ int intel_hdcp_auth_downstream(struct in
 		return -EPERM;
 	}
 
-	/* If there are no downstream devices, we're all done. */
+	/*
+	 * When repeater reports 0 device count, HDCP1.4 spec allows disabling
+	 * the HDCP encryption. That implies that repeater can't have its own
+	 * display. As there is no consumption of encrypted content in the
+	 * repeater with 0 downstream devices, we are failing the
+	 * authentication.
+	 */
 	num_downstream = DRM_HDCP_NUM_DOWNSTREAM(bstatus[0]);
 	if (num_downstream == 0)
-		return 0;
+		return -EINVAL;
 
 	ksv_fifo = kzalloc(num_downstream * DRM_HDCP_KSV_LEN, GFP_KERNEL);
 	if (!ksv_fifo)