Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1572324rwl; Fri, 24 Mar 2023 12:22:28 -0700 (PDT) X-Google-Smtp-Source: AKy350b70pKc1ka0CA539bP3iRYuYDGsjKo0utycHM452xMCTymVM9JPVlXbbJkc5o+/+19M0KtW X-Received: by 2002:a05:6402:4c3:b0:4fb:fd9f:737a with SMTP id n3-20020a05640204c300b004fbfd9f737amr4572882edw.4.1679685748627; Fri, 24 Mar 2023 12:22:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679685748; cv=none; d=google.com; s=arc-20160816; b=Z8S1SQDWR+qE44iWkJhWFheFrQWEfMJLneEvFzHr+ZAe88sLLI0tix66zvnzDMufNl kDpOwuhNAlssBZCrlWRpggJUnwJYYXZIciBZ9Dz9h1aEZA7d44Ecs3Jn7TNc1UGjs8BX tG58N6NHalb0qivevOf7px7MEOLxNlI37gX+vAuNQbE8RB82kATXOc/pKOKdRBCJMrtA YhdIxLBMa2/zfBFurx1m0fzNs7nC85mtyfV4UrMLs2q0umqhlrB1myEzPCuvQ/IqvtN0 EbKzVKQujNLqE5tNiiafG041ai5ZFvUXK4TMAecvx1GiN6mVIK7Ya0nImbnV5WZKkP1a uNaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PIYEvI2wg2lu9oowUUhESsvc0j1n7Y9hZ1EtidXwMKc=; b=SXEMdlXeCHEwHjB9/NTyRcx6DA6RUd5ZhePHW7kv0nRM47iWZCBJ7Z5924Y0OwZ5Xi zVi+NuonH7ro6+LoSBhvvQhuuW3YYfDxxCdeCtd+Esr0N9XyoE80FnOcznKxXxiuIYfT ZGllLZ1+iksgpxSxgEA1cJhC0QJ5a5hBSTLKnlw0tG5i7KspxW36D6UxValgOPCyjDvG 3G6p2fDiqGRYcm2r5TV+9XFGGzRmbTo+bu1PeoB9DjTC60qxsD2sJi36WdA+c3t3xYXu rxiCJmvJ6mO+tsimbCVPyu+0GklD7RbedID496XtYIKt4fL1K2iP5NBzUv3mHWFSE08z qecA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dr2Ppspj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d20-20020a05640208d400b005021f0d5753si2684689edz.666.2023.03.24.12.22.04; Fri, 24 Mar 2023 12:22:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dr2Ppspj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231859AbjCXTVb (ORCPT + 99 others); Fri, 24 Mar 2023 15:21:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231778AbjCXTVW (ORCPT ); Fri, 24 Mar 2023 15:21:22 -0400 Received: from mail-yw1-x1133.google.com (mail-yw1-x1133.google.com [IPv6:2607:f8b0:4864:20::1133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93400211E2 for ; Fri, 24 Mar 2023 12:21:16 -0700 (PDT) Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-53d277c1834so50624317b3.10 for ; Fri, 24 Mar 2023 12:21:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679685676; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PIYEvI2wg2lu9oowUUhESsvc0j1n7Y9hZ1EtidXwMKc=; b=dr2PpspjR/8y9dnUXNwrBO6nRLIyEc/2rKATRgRawct7rLQL3M4gqpXBwiAuEuU4vE LuIBBri+oDJpbjsJBZcU/hArIUQHrVpiQrW0y/MB0XTU0dSDZADNQbTow4BrSwMmDuih D4wTqQHoOLNrJi1QEf9yCUqQVJRUeXpOdm45M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679685676; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PIYEvI2wg2lu9oowUUhESsvc0j1n7Y9hZ1EtidXwMKc=; b=QwkwSHnDZUc2NbQA5eYwVLW6i6L/dtiqA4ITe9FECN+6HCMqd3FDOaQXGqhtOWioyn pksT5wwWhIhMA6I8mhFUmNlT5OZGV5CHXsHNLpuFfDvSBvQ/zubUAVQk5/H8xfGZMmiT FlXG9CxRLG7GfaLKaFgqZHilNsNfkBQeF+fwCMMxOouBhlgRmwlVQBk6lfAR7MwQHflE iRsRWK1iHGKhXOBZZ3ruvwJkAesqSDDM2wyfoxer/U9wMHvkhPl47fB5IuQtErCy/DSr 6jMncESrknvtehVAH1eAY9aHtrj91789cJbud3E5R1svPu4RQIxicsjgx40hw7cyEd+m N9JA== X-Gm-Message-State: AAQBX9cZQWwV8IvUMnfGtaYh/Ubqx6S0LOMrFJ39iSUo5XNVlrSCFDe/ nj/vZxjEmqOFO6RpNBW/4rDOtw== X-Received: by 2002:a81:6705:0:b0:52e:f109:ba7a with SMTP id b5-20020a816705000000b0052ef109ba7amr2814269ywc.51.1679685675550; Fri, 24 Mar 2023 12:21:15 -0700 (PDT) Received: from localhost ([2620:0:1035:15:5509:ec45:2b32:b39f]) by smtp.gmail.com with UTF8SMTPSA id u123-20020a817981000000b00545a08184a1sm570989ywc.49.2023.03.24.12.21.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Mar 2023 12:21:15 -0700 (PDT) From: Mark Yacoub X-Google-Original-From: Mark Yacoub To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter Cc: seanpaul@chromium.org, suraj.kandpal@intel.com, dianders@chromium.org, Jani Nikula , Mark Yacoub , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 06/10] drm/i915/hdcp: Retain hdcp_capable return codes Date: Fri, 24 Mar 2023 15:20:53 -0400 Message-Id: <20230324192058.3916571-7-markyacoub@google.com> X-Mailer: git-send-email 2.40.0.348.gf938b09366-goog In-Reply-To: <20230324192058.3916571-1-markyacoub@google.com> References: <20230324192058.3916571-1-markyacoub@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Paul The shim functions return error codes, but they are discarded in intel_hdcp.c. This patch plumbs the return codes through so they are properly handled. Acked-by: Jani Nikula Reviewed-by: Rodrigo Vivi Signed-off-by: Sean Paul Signed-off-by: Mark Yacoub --- Changes in v2: -None Changes in v3: -None Changes in v4: -None Changes in v5: -None Changes in v6: -Rebased Changes in v7: -None .../drm/i915/display/intel_display_debugfs.c | 9 +++- drivers/gpu/drm/i915/display/intel_hdcp.c | 51 ++++++++++--------- drivers/gpu/drm/i915/display/intel_hdcp.h | 4 +- 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_display_debugfs.c b/drivers/gpu/drm/i915/display/intel_display_debugfs.c index 7bcd90384a46d..a14b86a07e545 100644 --- a/drivers/gpu/drm/i915/display/intel_display_debugfs.c +++ b/drivers/gpu/drm/i915/display/intel_display_debugfs.c @@ -494,6 +494,7 @@ static void intel_panel_info(struct seq_file *m, static void intel_hdcp_info(struct seq_file *m, struct intel_connector *intel_connector) { + int ret; bool hdcp_cap, hdcp2_cap; if (!intel_connector->hdcp.shim) { @@ -501,8 +502,12 @@ static void intel_hdcp_info(struct seq_file *m, goto out; } - hdcp_cap = intel_hdcp_capable(intel_connector); - hdcp2_cap = intel_hdcp2_capable(intel_connector); + ret = intel_hdcp_capable(intel_connector, &hdcp_cap); + if (ret) + hdcp_cap = false; + ret = intel_hdcp2_capable(intel_connector, &hdcp2_cap); + if (ret) + hdcp2_cap = false; if (hdcp_cap) seq_puts(m, "HDCP1.4 "); diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c b/drivers/gpu/drm/i915/display/intel_hdcp.c index 0a20bc41be55d..61a862ae1f286 100644 --- a/drivers/gpu/drm/i915/display/intel_hdcp.c +++ b/drivers/gpu/drm/i915/display/intel_hdcp.c @@ -177,50 +177,49 @@ int intel_hdcp_read_valid_bksv(struct intel_digital_port *dig_port, } /* Is HDCP1.4 capable on Platform and Sink */ -bool intel_hdcp_capable(struct intel_connector *connector) +int intel_hdcp_capable(struct intel_connector *connector, bool *capable) { struct intel_digital_port *dig_port = intel_attached_dig_port(connector); const struct intel_hdcp_shim *shim = connector->hdcp.shim; - bool capable = false; u8 bksv[5]; + *capable = false; + if (!shim) - return capable; + return 0; - if (shim->hdcp_capable) { - shim->hdcp_capable(dig_port, &capable); - } else { - if (!intel_hdcp_read_valid_bksv(dig_port, shim, bksv)) - capable = true; - } + if (shim->hdcp_capable) + return shim->hdcp_capable(dig_port, capable); + + if (!intel_hdcp_read_valid_bksv(dig_port, shim, bksv)) + *capable = true; - return capable; + return 0; } /* Is HDCP2.2 capable on Platform and Sink */ -bool intel_hdcp2_capable(struct intel_connector *connector) +int intel_hdcp2_capable(struct intel_connector *connector, bool *capable) { struct intel_digital_port *dig_port = intel_attached_dig_port(connector); struct drm_i915_private *dev_priv = to_i915(connector->base.dev); struct intel_hdcp *hdcp = &connector->hdcp; - bool capable = false; + + *capable = false; /* I915 support for HDCP2.2 */ if (!hdcp->hdcp2_supported) - return false; + return 0; /* MEI interface is solid */ mutex_lock(&dev_priv->display.hdcp.comp_mutex); if (!dev_priv->display.hdcp.comp_added || !dev_priv->display.hdcp.master) { mutex_unlock(&dev_priv->display.hdcp.comp_mutex); - return false; + return 0; } mutex_unlock(&dev_priv->display.hdcp.comp_mutex); /* Sink's capability for HDCP2.2 */ - hdcp->shim->hdcp_2_2_capable(dig_port, &capable); - - return capable; + return hdcp->shim->hdcp_2_2_capable(dig_port, capable); } static bool intel_hdcp_in_use(struct drm_i915_private *dev_priv, @@ -2355,6 +2354,7 @@ int intel_hdcp_enable(struct intel_connector *connector, struct intel_digital_port *dig_port = intel_attached_dig_port(connector); struct intel_hdcp *hdcp = &connector->hdcp; unsigned long check_link_interval = DRM_HDCP_CHECK_PERIOD_MS; + bool capable; int ret = -EINVAL; if (!hdcp->shim) @@ -2373,21 +2373,27 @@ int intel_hdcp_enable(struct intel_connector *connector, * Considering that HDCP2.2 is more secure than HDCP1.4, If the setup * is capable of HDCP2.2, it is preferred to use HDCP2.2. */ - if (intel_hdcp2_capable(connector)) { + ret = intel_hdcp2_capable(connector, &capable); + if (capable) { ret = _intel_hdcp2_enable(connector); - if (!ret) + if (!ret) { check_link_interval = DRM_HDCP2_CHECK_PERIOD_MS; + goto out; + } } /* * When HDCP2.2 fails and Content Type is not Type1, HDCP1.4 will * be attempted. */ - if (ret && intel_hdcp_capable(connector) && - hdcp->content_type != DRM_MODE_HDCP_CONTENT_TYPE1) { + ret = intel_hdcp_capable(connector, &capable); + if (ret) + goto out; + + if (capable && hdcp->content_type != DRM_MODE_HDCP_CONTENT_TYPE1) ret = _intel_hdcp_enable(connector); - } +out: if (!ret) { schedule_delayed_work(&hdcp->check_work, check_link_interval); intel_hdcp_update_value(connector, @@ -2395,7 +2401,6 @@ int intel_hdcp_enable(struct intel_connector *connector, true); } -out: mutex_unlock(&dig_port->hdcp_mutex); mutex_unlock(&hdcp->mutex); return ret; diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.h b/drivers/gpu/drm/i915/display/intel_hdcp.h index 7c5fd84a7b65a..f06f6e5a2b1ad 100644 --- a/drivers/gpu/drm/i915/display/intel_hdcp.h +++ b/drivers/gpu/drm/i915/display/intel_hdcp.h @@ -33,8 +33,8 @@ void intel_hdcp_update_pipe(struct intel_atomic_state *state, const struct intel_crtc_state *crtc_state, const struct drm_connector_state *conn_state); bool is_hdcp_supported(struct drm_i915_private *dev_priv, enum port port); -bool intel_hdcp_capable(struct intel_connector *connector); -bool intel_hdcp2_capable(struct intel_connector *connector); +int intel_hdcp_capable(struct intel_connector *connector, bool *capable); +int intel_hdcp2_capable(struct intel_connector *connector, bool *capable); void intel_hdcp_component_init(struct drm_i915_private *dev_priv); void intel_hdcp_component_fini(struct drm_i915_private *dev_priv); void intel_hdcp_cleanup(struct intel_connector *connector); -- 2.40.0.348.gf938b09366-goog