Commit 36e5e704 authored by Sean Paul's avatar Sean Paul Committed by Ramalingam C

drm/i915: Don't fully disable HDCP on a port if multiple pipes are using it

This patch is required for HDCP over MST. If a port is being used for
multiple HDCP streams, we don't want to fully disable HDCP on a port if
one of them is disabled. Instead, we just disable the HDCP signalling on
that particular pipe and exit early. The last pipe to disable HDCP will
also bring down HDCP on the port.

In order to achieve this, we need to keep a refcount in intel_digital_port
and protect it using a new hdcp_mutex.

Cc: Ramalingam C <ramalingam.c@intel.com>
Reviewed-by: default avatarRamalingam C <ramalingam.c@intel.com>
Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191203173638.94919-8-sean@poorly.run #v1
Link: https://patchwork.freedesktop.org/patch/msgid/20191212190230.188505-9-sean@poorly.run #v2
Link: https://patchwork.freedesktop.org/patch/msgid/20200117193103.156821-9-sean@poorly.run #v3
Link: https://patchwork.freedesktop.org/patch/msgid/20200218220242.107265-9-sean@poorly.run #v4
Link: https://patchwork.freedesktop.org/patch/msgid/20200305201236.152307-9-sean@poorly.run #v5
Link: https://patchwork.freedesktop.org/patch/msgid/20200429195502.39919-9-sean@poorly.run #v6
Link: https://patchwork.freedesktop.org/patch/msgid/20200623155907.22961-10-sean@poorly.run #v7

Changes in v2:
-Move the toggle_signalling call into _intel_hdcp_disable so it's called from check_work
Changes in v3:
-None
Changes in v4:
-None
Changes in v5:
-Change WARN_ON to drm_WARN_ON
Changes in v6:
-None
Changes in v7:
-Split minor intel_hdcp_disable refactor into separate patch (Ramalingam)
Changes in v8:
-None
Signed-off-by: default avatarRamalingam C <ramalingam.c@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200818153910.27894-10-sean@poorly.run
parent a1de8685
...@@ -5026,6 +5026,9 @@ void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port) ...@@ -5026,6 +5026,9 @@ void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port)
drm_encoder_init(&dev_priv->drm, &encoder->base, &intel_ddi_funcs, drm_encoder_init(&dev_priv->drm, &encoder->base, &intel_ddi_funcs,
DRM_MODE_ENCODER_TMDS, "DDI %c", port_name(port)); DRM_MODE_ENCODER_TMDS, "DDI %c", port_name(port));
mutex_init(&dig_port->hdcp_mutex);
dig_port->num_hdcp_streams = 0;
encoder->hotplug = intel_ddi_hotplug; encoder->hotplug = intel_ddi_hotplug;
encoder->compute_output_type = intel_ddi_compute_output_type; encoder->compute_output_type = intel_ddi_compute_output_type;
encoder->compute_config = intel_ddi_compute_config; encoder->compute_config = intel_ddi_compute_config;
......
...@@ -1416,6 +1416,11 @@ struct intel_digital_port { ...@@ -1416,6 +1416,11 @@ struct intel_digital_port {
enum phy_fia tc_phy_fia; enum phy_fia tc_phy_fia;
u8 tc_phy_fia_idx; u8 tc_phy_fia_idx;
/* protects num_hdcp_streams reference count */
struct mutex hdcp_mutex;
/* the number of pipes using HDCP signalling out of this port */
unsigned int num_hdcp_streams;
void (*write_infoframe)(struct intel_encoder *encoder, void (*write_infoframe)(struct intel_encoder *encoder,
const struct intel_crtc_state *crtc_state, const struct intel_crtc_state *crtc_state,
unsigned int type, unsigned int type,
......
...@@ -8342,6 +8342,8 @@ bool intel_dp_init(struct drm_i915_private *dev_priv, ...@@ -8342,6 +8342,8 @@ bool intel_dp_init(struct drm_i915_private *dev_priv,
intel_encoder = &dig_port->base; intel_encoder = &dig_port->base;
encoder = &intel_encoder->base; encoder = &intel_encoder->base;
mutex_init(&dig_port->hdcp_mutex);
if (drm_encoder_init(&dev_priv->drm, &intel_encoder->base, if (drm_encoder_init(&dev_priv->drm, &intel_encoder->base,
&intel_dp_enc_funcs, DRM_MODE_ENCODER_TMDS, &intel_dp_enc_funcs, DRM_MODE_ENCODER_TMDS,
"DP %c", port_name(port))) "DP %c", port_name(port)))
......
...@@ -792,6 +792,19 @@ static int _intel_hdcp_disable(struct intel_connector *connector) ...@@ -792,6 +792,19 @@ static int _intel_hdcp_disable(struct intel_connector *connector)
drm_dbg_kms(&dev_priv->drm, "[%s:%d] HDCP is being disabled...\n", drm_dbg_kms(&dev_priv->drm, "[%s:%d] HDCP is being disabled...\n",
connector->base.name, connector->base.base.id); connector->base.name, connector->base.base.id);
/*
* If there are other connectors on this port using HDCP, don't disable
* it. Instead, toggle the HDCP signalling off on that particular
* connector/pipe and exit.
*/
if (dig_port->num_hdcp_streams > 0) {
ret = hdcp->shim->toggle_signalling(dig_port,
cpu_transcoder, false);
if (ret)
DRM_ERROR("Failed to disable HDCP signalling\n");
return ret;
}
hdcp->hdcp_encrypted = false; hdcp->hdcp_encrypted = false;
intel_de_write(dev_priv, HDCP_CONF(dev_priv, cpu_transcoder, port), 0); intel_de_write(dev_priv, HDCP_CONF(dev_priv, cpu_transcoder, port), 0);
if (intel_de_wait_for_clear(dev_priv, if (intel_de_wait_for_clear(dev_priv,
...@@ -870,6 +883,8 @@ static struct intel_connector *intel_hdcp_to_connector(struct intel_hdcp *hdcp) ...@@ -870,6 +883,8 @@ static struct intel_connector *intel_hdcp_to_connector(struct intel_hdcp *hdcp)
static void intel_hdcp_update_value(struct intel_connector *connector, static void intel_hdcp_update_value(struct intel_connector *connector,
u64 value, bool update_property) u64 value, bool update_property)
{ {
struct drm_device *dev = connector->base.dev;
struct intel_digital_port *dig_port = intel_attached_dig_port(connector);
struct intel_hdcp *hdcp = &connector->hdcp; struct intel_hdcp *hdcp = &connector->hdcp;
drm_WARN_ON(connector->base.dev, !mutex_is_locked(&hdcp->mutex)); drm_WARN_ON(connector->base.dev, !mutex_is_locked(&hdcp->mutex));
...@@ -877,6 +892,15 @@ static void intel_hdcp_update_value(struct intel_connector *connector, ...@@ -877,6 +892,15 @@ static void intel_hdcp_update_value(struct intel_connector *connector,
if (hdcp->value == value) if (hdcp->value == value)
return; return;
drm_WARN_ON(dev, !mutex_is_locked(&dig_port->hdcp_mutex));
if (hdcp->value == DRM_MODE_CONTENT_PROTECTION_ENABLED) {
if (!drm_WARN_ON(dev, dig_port->num_hdcp_streams == 0))
dig_port->num_hdcp_streams--;
} else if (value == DRM_MODE_CONTENT_PROTECTION_ENABLED) {
dig_port->num_hdcp_streams++;
}
hdcp->value = value; hdcp->value = value;
if (update_property) { if (update_property) {
drm_connector_get(&connector->base); drm_connector_get(&connector->base);
...@@ -895,6 +919,8 @@ static int intel_hdcp_check_link(struct intel_connector *connector) ...@@ -895,6 +919,8 @@ static int intel_hdcp_check_link(struct intel_connector *connector)
int ret = 0; int ret = 0;
mutex_lock(&hdcp->mutex); mutex_lock(&hdcp->mutex);
mutex_lock(&dig_port->hdcp_mutex);
cpu_transcoder = hdcp->cpu_transcoder; cpu_transcoder = hdcp->cpu_transcoder;
/* Check_link valid only when HDCP1.4 is enabled */ /* Check_link valid only when HDCP1.4 is enabled */
...@@ -948,6 +974,7 @@ static int intel_hdcp_check_link(struct intel_connector *connector) ...@@ -948,6 +974,7 @@ static int intel_hdcp_check_link(struct intel_connector *connector)
} }
out: out:
mutex_unlock(&dig_port->hdcp_mutex);
mutex_unlock(&hdcp->mutex); mutex_unlock(&hdcp->mutex);
return ret; return ret;
} }
...@@ -2047,6 +2074,7 @@ int intel_hdcp_enable(struct intel_connector *connector, ...@@ -2047,6 +2074,7 @@ int intel_hdcp_enable(struct intel_connector *connector,
enum transcoder cpu_transcoder, u8 content_type) enum transcoder cpu_transcoder, u8 content_type)
{ {
struct drm_i915_private *dev_priv = to_i915(connector->base.dev); struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_digital_port *dig_port = intel_attached_dig_port(connector);
struct intel_hdcp *hdcp = &connector->hdcp; struct intel_hdcp *hdcp = &connector->hdcp;
unsigned long check_link_interval = DRM_HDCP_CHECK_PERIOD_MS; unsigned long check_link_interval = DRM_HDCP_CHECK_PERIOD_MS;
int ret = -EINVAL; int ret = -EINVAL;
...@@ -2055,6 +2083,7 @@ int intel_hdcp_enable(struct intel_connector *connector, ...@@ -2055,6 +2083,7 @@ int intel_hdcp_enable(struct intel_connector *connector,
return -ENOENT; return -ENOENT;
mutex_lock(&hdcp->mutex); mutex_lock(&hdcp->mutex);
mutex_lock(&dig_port->hdcp_mutex);
drm_WARN_ON(&dev_priv->drm, drm_WARN_ON(&dev_priv->drm,
hdcp->value == DRM_MODE_CONTENT_PROTECTION_ENABLED); hdcp->value == DRM_MODE_CONTENT_PROTECTION_ENABLED);
hdcp->content_type = content_type; hdcp->content_type = content_type;
...@@ -2089,12 +2118,14 @@ int intel_hdcp_enable(struct intel_connector *connector, ...@@ -2089,12 +2118,14 @@ int intel_hdcp_enable(struct intel_connector *connector,
true); true);
} }
mutex_unlock(&dig_port->hdcp_mutex);
mutex_unlock(&hdcp->mutex); mutex_unlock(&hdcp->mutex);
return ret; return ret;
} }
int intel_hdcp_disable(struct intel_connector *connector) int intel_hdcp_disable(struct intel_connector *connector)
{ {
struct intel_digital_port *dig_port = intel_attached_dig_port(connector);
struct intel_hdcp *hdcp = &connector->hdcp; struct intel_hdcp *hdcp = &connector->hdcp;
int ret = 0; int ret = 0;
...@@ -2102,6 +2133,7 @@ int intel_hdcp_disable(struct intel_connector *connector) ...@@ -2102,6 +2133,7 @@ int intel_hdcp_disable(struct intel_connector *connector)
return -ENOENT; return -ENOENT;
mutex_lock(&hdcp->mutex); mutex_lock(&hdcp->mutex);
mutex_lock(&dig_port->hdcp_mutex);
if (hdcp->value == DRM_MODE_CONTENT_PROTECTION_UNDESIRED) if (hdcp->value == DRM_MODE_CONTENT_PROTECTION_UNDESIRED)
goto out; goto out;
...@@ -2114,6 +2146,7 @@ int intel_hdcp_disable(struct intel_connector *connector) ...@@ -2114,6 +2146,7 @@ int intel_hdcp_disable(struct intel_connector *connector)
ret = _intel_hdcp_disable(connector); ret = _intel_hdcp_disable(connector);
out: out:
mutex_unlock(&dig_port->hdcp_mutex);
mutex_unlock(&hdcp->mutex); mutex_unlock(&hdcp->mutex);
cancel_delayed_work_sync(&hdcp->check_work); cancel_delayed_work_sync(&hdcp->check_work);
return ret; return ret;
......
...@@ -3341,6 +3341,8 @@ void intel_hdmi_init(struct drm_i915_private *dev_priv, ...@@ -3341,6 +3341,8 @@ void intel_hdmi_init(struct drm_i915_private *dev_priv,
intel_encoder = &dig_port->base; intel_encoder = &dig_port->base;
mutex_init(&dig_port->hdcp_mutex);
drm_encoder_init(&dev_priv->drm, &intel_encoder->base, drm_encoder_init(&dev_priv->drm, &intel_encoder->base,
&intel_hdmi_enc_funcs, DRM_MODE_ENCODER_TMDS, &intel_hdmi_enc_funcs, DRM_MODE_ENCODER_TMDS,
"HDMI %c", port_name(port)); "HDMI %c", port_name(port));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment