All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ramalingam C <ramalingam.c@intel.com>
To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	daniel.vetter@ffwll.ch, tomas.winkler@intel.com,
	uma.shankar@intel.com
Subject: [PATCH v14 14/32] drm/i915: CP_IRQ handling for DP HDCP2.2 msgs
Date: Sat, 16 Feb 2019 02:21:03 +0530	[thread overview]
Message-ID: <1550263881-16082-15-git-send-email-ramalingam.c@intel.com> (raw)
In-Reply-To: <1550263881-16082-1-git-send-email-ramalingam.c@intel.com>

Implements the
	Waitqueue is created to wait for CP_IRQ
	Signaling the CP_IRQ arrival through atomic variable.
	For applicable DP HDCP2.2 msgs read wait for CP_IRQ.

As per HDCP2.2 spec "HDCP Transmitters must process CP_IRQ interrupts
when they are received from HDCP Receivers"

Without CP_IRQ processing, DP HDCP2.2 H_Prime msg was getting corrupted
while reading it based on corresponding status bit. This creates the
random failures in reading the DP HDCP2.2 msgs.

v2:
  CP_IRQ arrival is tracked based on the atomic val inc [daniel]
  Recording the reviewed-by Daniel from IRC.

Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/i915/intel_dp.c   | 31 +++++++++++++++++++++++--------
 drivers/gpu/drm/i915/intel_drv.h  |  8 ++++++++
 drivers/gpu/drm/i915/intel_hdcp.c | 11 ++++-------
 3 files changed, 35 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index e9fe25f21200..e1a051c0fbfe 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -5623,6 +5623,18 @@ void intel_dp_encoder_suspend(struct intel_encoder *intel_encoder)
 		edp_panel_vdd_off_sync(intel_dp);
 }
 
+static void intel_dp_hdcp_wait_for_cp_irq(struct intel_hdcp *hdcp, int timeout)
+{
+	long ret;
+
+#define C (hdcp->cp_irq_count_cached != atomic_read(&hdcp->cp_irq_count))
+	ret = wait_event_interruptible_timeout(hdcp->cp_irq_queue, C,
+					       msecs_to_jiffies(timeout));
+
+	if (!ret)
+		DRM_DEBUG_KMS("Timedout at waiting for CP_IRQ\n");
+}
+
 static
 int intel_dp_hdcp_write_an_aksv(struct intel_digital_port *intel_dig_port,
 				u8 *an)
@@ -5967,14 +5979,13 @@ intel_dp_hdcp2_wait_for_msg(struct intel_digital_port *intel_dig_port,
 		mdelay(timeout);
 		ret = 0;
 	} else {
-		/* TODO: In case if you need to wait on CP_IRQ, do it here */
-		ret = __wait_for(ret =
-				 hdcp2_detect_msg_availability(intel_dig_port,
-							       msg_id,
-							       &msg_ready),
-				 !ret && msg_ready, timeout * 1000,
-				 1000, 5 * 1000);
-
+		/*
+		 * As we want to check the msg availability at timeout, Ignoring
+		 * the timeout at wait for CP_IRQ.
+		 */
+		intel_dp_hdcp_wait_for_cp_irq(hdcp, timeout);
+		ret = hdcp2_detect_msg_availability(intel_dig_port,
+						    msg_id, &msg_ready);
 		if (!msg_ready)
 			ret = -ETIMEDOUT;
 	}
@@ -6001,6 +6012,8 @@ static
 int intel_dp_hdcp2_write_msg(struct intel_digital_port *intel_dig_port,
 			     void *buf, size_t size)
 {
+	struct intel_dp *dp = &intel_dig_port->dp;
+	struct intel_hdcp *hdcp = &dp->attached_connector->hdcp;
 	unsigned int offset;
 	u8 *byte = buf;
 	ssize_t ret, bytes_to_write, len;
@@ -6016,6 +6029,8 @@ int intel_dp_hdcp2_write_msg(struct intel_digital_port *intel_dig_port,
 	bytes_to_write = size - 1;
 	byte++;
 
+	hdcp->cp_irq_count_cached = atomic_read(&hdcp->cp_irq_count);
+
 	while (bytes_to_write) {
 		len = bytes_to_write > DP_AUX_MAX_PAYLOAD_BYTES ?
 				DP_AUX_MAX_PAYLOAD_BYTES : bytes_to_write;
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index dfedcc2b076c..1d1ef7f04f93 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -474,6 +474,14 @@ struct intel_hdcp {
 	 * over re-Auth has to be triggered.
 	 */
 	u32 seq_num_m;
+
+	/*
+	 * Work queue to signal the CP_IRQ. Used for the waiters to read the
+	 * available information from HDCP DP sink.
+	 */
+	wait_queue_head_t cp_irq_queue;
+	atomic_t cp_irq_count;
+	int cp_irq_count_cached;
 };
 
 struct intel_connector {
diff --git a/drivers/gpu/drm/i915/intel_hdcp.c b/drivers/gpu/drm/i915/intel_hdcp.c
index fe0445c0eaac..6178fe93f398 100644
--- a/drivers/gpu/drm/i915/intel_hdcp.c
+++ b/drivers/gpu/drm/i915/intel_hdcp.c
@@ -1806,6 +1806,7 @@ int intel_hdcp_init(struct intel_connector *connector,
 
 	if (is_hdcp2_supported(dev_priv))
 		intel_hdcp2_init(connector);
+	init_waitqueue_head(&hdcp->cp_irq_queue);
 
 	return 0;
 }
@@ -1935,12 +1936,8 @@ void intel_hdcp_handle_cp_irq(struct intel_connector *connector)
 	if (!hdcp->shim)
 		return;
 
-	/*
-	 * CP_IRQ could be triggered due to 1. HDCP2.2 auth msgs availability,
-	 * 2. link failure and 3. repeater reauth request. At present we dont
-	 * handle the CP_IRQ for the HDCP2.2 auth msg availability for read.
-	 * To handle other two causes for CP_IRQ we have the work_fn which is
-	 * scheduled here.
-	 */
+	atomic_inc(&connector->hdcp.cp_irq_count);
+	wake_up_all(&connector->hdcp.cp_irq_queue);
+
 	schedule_delayed_work(&hdcp->check_work, 0);
 }
-- 
2.7.4

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

  parent reply	other threads:[~2019-02-15 20:51 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-15 20:50 [PATCH v14 00/32] drm/i915: Implement HDCP2.2 Ramalingam C
2019-02-15 20:50 ` [PATCH v14 01/32] drm/i915: Gathering the HDCP1.4 routines together Ramalingam C
2019-02-15 20:50 ` [PATCH v14 02/32] drm/i915: Initialize HDCP2.2 Ramalingam C
2019-02-15 20:50 ` [PATCH v14 03/32] drm/i915: MEI interface implementation Ramalingam C
2019-02-16  1:40   ` [Intel-gfx] " kbuild test robot via dri-devel
2019-02-16  3:28   ` kbuild test robot via dri-devel
2019-02-15 20:50 ` [PATCH v14 04/32] drm/i915: hdcp1.4 CP_IRQ handling and SW encryption tracking Ramalingam C
2019-02-15 20:50 ` [PATCH v14 05/32] drm/i915: Enable and Disable of HDCP2.2 Ramalingam C
2019-02-15 20:50 ` [PATCH v14 06/32] drm/i915: Implement HDCP2.2 receiver authentication Ramalingam C
2019-02-15 20:50 ` [PATCH v14 07/32] drm/i915: Implement HDCP2.2 repeater authentication Ramalingam C
2019-02-15 20:50 ` [PATCH v14 08/32] drm: HDCP2.2 link check period Ramalingam C
2019-02-15 20:50 ` [PATCH v14 09/32] drm/i915: Implement HDCP2.2 link integrity check Ramalingam C
2019-02-15 20:50 ` [PATCH v14 10/32] drm/i915: Handle HDCP2.2 downstream topology change Ramalingam C
2019-02-15 20:51 ` [PATCH v14 11/32] drm: removing the DP Errata msg and its msg id Ramalingam C
2019-02-15 20:51 ` [PATCH v14 12/32] drm/i915: Implement the HDCP2.2 support for DP Ramalingam C
2019-02-15 20:51 ` [PATCH v14 13/32] drm/i915: Implement the HDCP2.2 support for HDMI Ramalingam C
2019-02-15 20:51 ` Ramalingam C [this message]
2019-02-15 20:51 ` [PATCH v14 15/32] drm/i915: Fix KBL HDCP2.2 encrypt status signalling Ramalingam C
2019-02-15 20:51 ` [PATCH v14 16/32] mei: bus: whitelist hdcp client Ramalingam C
2019-02-15 20:51 ` [PATCH v14 17/32] mei: bus: export to_mei_cl_device for mei client device drivers Ramalingam C
2019-02-15 20:51 ` [PATCH v14 18/32] misc/mei/hdcp: Client driver for HDCP application Ramalingam C
2019-02-15 20:51 ` [PATCH v14 19/32] misc/mei/hdcp: Define ME FW interface for HDCP2.2 Ramalingam C
2019-02-15 20:51 ` [PATCH v14 20/32] misc/mei/hdcp: Initiate Wired HDCP2.2 Tx Session Ramalingam C
2019-02-16  2:43   ` kbuild test robot
2019-02-15 20:51 ` [PATCH v14 21/32] misc/mei/hdcp: Verify Receiver Cert and prepare km Ramalingam C
2019-02-15 20:51 ` [PATCH v14 22/32] misc/mei/hdcp: Verify H_prime Ramalingam C
2019-02-15 20:51 ` [PATCH v14 23/32] misc/mei/hdcp: Store the HDCP Pairing info Ramalingam C
2019-02-15 20:51 ` [PATCH v14 24/32] misc/mei/hdcp: Initiate Locality check Ramalingam C
2019-02-15 20:51 ` [PATCH v14 25/32] misc/mei/hdcp: Verify L_prime Ramalingam C
2019-02-15 20:51 ` [PATCH v14 26/32] misc/mei/hdcp: Prepare Session Key Ramalingam C
2019-02-15 20:51 ` [PATCH v14 27/32] misc/mei/hdcp: Repeater topology verification and ack Ramalingam C
2019-02-15 20:51 ` [PATCH v14 28/32] misc/mei/hdcp: Verify M_prime Ramalingam C
2019-02-15 20:51 ` [PATCH v14 29/32] misc/mei/hdcp: Enabling the HDCP authentication Ramalingam C
2019-02-15 20:51 ` [PATCH v14 30/32] misc/mei/hdcp: Closing wired HDCP2.2 Tx Session Ramalingam C
2019-02-15 20:51 ` [PATCH v14 31/32] misc/mei/hdcp: Component framework for I915 Interface Ramalingam C
2019-02-15 20:51 ` [PATCH v14 32/32] FOR_TEST_ONLY: i915/Kconfig: Select mei_hdcp by I915 Ramalingam C
2019-02-15 23:30 ` ✗ Fi.CI.BAT: failure for drm/i915: Implement HDCP2.2 Patchwork
2019-02-16  4:52 ` [PATCH v14] drm/audio: declaration of struct device Ramalingam C

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=1550263881-16082-15-git-send-email-ramalingam.c@intel.com \
    --to=ramalingam.c@intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=tomas.winkler@intel.com \
    --cc=uma.shankar@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.