Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp6963132rwb; Wed, 18 Jan 2023 11:34:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXtElTJ8kPKaQxVisDwko5RRopJVGRBAgzCpNDzBI5bdn1n6sUV2H6PYqMUn7lJ76eIMGOdE X-Received: by 2002:aa7:96f7:0:b0:582:5b8d:52be with SMTP id i23-20020aa796f7000000b005825b8d52bemr8845778pfq.8.1674070443623; Wed, 18 Jan 2023 11:34:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674070443; cv=none; d=google.com; s=arc-20160816; b=u9IIUsg1IfoSw0hK8pDQ1qXE/MozwB/igo06RRr4l503t3wgchBmofqjPtAQlvlMHm S6gcrRFMsYoYyETk1H8QVBb0hvnTPaL1yJErH7dcvamIEnJzCyRrpxH8ixBbRxNh0LBp jJLhQG14ilWYdxjrmcT3H5SWDmmE5Hm/NN86Sd1uDKSfG8ulgOiUOmeM+iPMOpl8SUl2 MsvagMFdWryErFhaN0IcrbN4qmQCdXfS8dZZFYMaVO9LJY1S7vKHlebunHh6bK2UilPt PW+8mIm6dPcf8Ci3XjnL0j6zyM415aCE7FZHf2FIxp5233zDTcfTdxtAPgHk9+I+lAn5 v1Rg== 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=3WLJ3xkyotDYAnQVqs4JMoPxigT63WOwpqYsliWKevY=; b=aaqJhbHVHEfJxu0kU0rjPraDobcpksnrtoJ6Aa/eg0qlicg3D3D3tyJae3bU7H0jFv 5xKIFrBbaY9Mf371OYZrBNBvenQ6Hij3arwpPfHUPDAHi1NrxxiMoiey8zsLNFKcokER AMnf0r1kjiwn+G1raqGPV6ckCFmxULX7dtxeI8y/ZKFOhvrCC0BmTlk257ygSwc6RKKp jmtXjfOL0icL5hjpTGATABWeQOsPE6pLz9BbQIChcTccno47B1xU0reWk+NfjUA8btB/ KEhqUCeoIyEVcBKpkdieKvUSvkZ5i2aISKJ9XzjLHfo8k9M3jE5txsWRY9rYnnjbU9AE 4eGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="QLg5/c8W"; 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 z21-20020aa78895000000b00557e99763d3si7783296pfe.93.2023.01.18.11.33.53; Wed, 18 Jan 2023 11:34:03 -0800 (PST) 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="QLg5/c8W"; 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 S229995AbjARTbV (ORCPT + 45 others); Wed, 18 Jan 2023 14:31:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230292AbjARTay (ORCPT ); Wed, 18 Jan 2023 14:30:54 -0500 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FCC05CE55 for ; Wed, 18 Jan 2023 11:30:44 -0800 (PST) Received: by mail-qt1-x82f.google.com with SMTP id z9so8029501qtv.5 for ; Wed, 18 Jan 2023 11:30:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; 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=3WLJ3xkyotDYAnQVqs4JMoPxigT63WOwpqYsliWKevY=; b=QLg5/c8WmKxwSvCiDaG8ArEOr4p9gviyGSkiwzUM5Iy8v53g5H2JKtX1dYuYTDfpIO Sipcn8Yf7jCq1iKME55FdGPpSMakdyhpR8QV926DNZ4ZIEktu3rm7uyY9WJTO2+RhO1Z 9gWxab9Nwvg7qYesrkXzEhFcb0nfdTytL5Mvs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=3WLJ3xkyotDYAnQVqs4JMoPxigT63WOwpqYsliWKevY=; b=Eb9R5zh4pmUNXMfxnwLSSrQAaWHkrepSh9GAOkagQwx/ojy5aRJtXGpmll1zc9mnYE L7W78ZhBOzj5TzqJ430ctd6wo/2KhhNPSrO7uxpQtjmyKAfCesmFY/QFXP5S/n8EGtdC oKdtz31yZC1033Cpc8cbZBc2lmL88fOX9Cf1ZvC8OhCHqHU/CXkFvywalCprWJSEMGmh jrF99PjBW56aV+eqNiTm5PdsNJUSFZaS4VSBtAYQvKGkbplF8/XDtZtZ9DKsZhFCQmCm 5US8A28xP3kG3qhmivhGYtbqeOcQDsjIHA1cUFmJfRFmUe7pkDyPV18aCCHyJ/N/sEg3 nh+w== X-Gm-Message-State: AFqh2kpp0nWwEPcU93c6M+q9QGQOvwQ2EzMY5PHpOuK9lX7zZ1qfFnsM pweuND+AqtpuyBM+WR7RCXOcxQ== X-Received: by 2002:ac8:524c:0:b0:3b6:378c:5cd7 with SMTP id y12-20020ac8524c000000b003b6378c5cd7mr10713401qtn.61.1674070243593; Wed, 18 Jan 2023 11:30:43 -0800 (PST) Received: from localhost (29.46.245.35.bc.googleusercontent.com. [35.245.46.29]) by smtp.gmail.com with UTF8SMTPSA id ga15-20020a05622a590f00b003b6325dfc4esm4613264qtb.67.2023.01.18.11.30.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jan 2023 11:30:43 -0800 (PST) From: Mark Yacoub X-Google-Original-From: Mark Yacoub To: quic_khsieh@quicinc.com, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: robdclark@gmail.com, quic_abhinavk@quicinc.com, dmitry.baryshkov@linaro.org, sean@poorly.run, airlied@gmail.com, daniel@ffwll.ch, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, agross@kernel.org, andersson@kernel.org, konrad.dybcio@somainline.org, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, tvrtko.ursulin@linux.intel.com, markyacoub@chromium.org, tzimmermann@suse.de, ville.syrjala@linux.intel.com, stanislav.lisovskiy@intel.com, matthew.d.roper@intel.com, imre.deak@intel.com, lucas.demarchi@intel.com, manasi.d.navare@intel.com, swati2.sharma@intel.com, bhanuprakash.modem@intel.com, javierm@redhat.com, jose.souza@intel.com, lyude@redhat.com, hbh25y@gmail.com, arun.r.murthy@intel.com, ashutosh.dixit@intel.com, ankit.k.nautiyal@intel.com, maxime@cerno.tech, swboyd@chromium.org, christophe.jaillet@wanadoo.fr, quic_sbillaka@quicinc.com, johan+linaro@kernel.org, dianders@chromium.org, marex@denx.de, quic_jesszhan@quicinc.com, bjorn.andersson@linaro.org, abhinavk@codeaurora.org, seanpaul@chromium.org, Jani Nikula Subject: [PATCH v6 06/10] drm/i915/hdcp: Retain hdcp_capable return codes Date: Wed, 18 Jan 2023 19:30:11 +0000 Message-Id: <20230118193015.911074-7-markyacoub@google.com> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog In-Reply-To: <20230118193015.911074-1-markyacoub@google.com> References: <20230118193015.911074-1-markyacoub@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,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 Link: https://patchwork.freedesktop.org/patch/msgid/20210913175747.47456-7-sean@poorly.run #v1 Link: https://patchwork.freedesktop.org/patch/msgid/20210915203834.1439-7-sean@poorly.run #v2 Link: https://patchwork.freedesktop.org/patch/msgid/20211001151145.55916-7-sean@poorly.run #v3 Link: https://patchwork.freedesktop.org/patch/msgid/20211105030434.2828845-7-sean@poorly.run #v4 Link: https://patchwork.freedesktop.org/patch/msgid/20220411204741.1074308-7-sean@poorly.run #v5 Changes in v2: -None Changes in v3: -None Changes in v4: -None Changes in v5: -None Changes in v6: -Rebased --- .../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 7c7253a2541c..13a4153bb76e 100644 --- a/drivers/gpu/drm/i915/display/intel_display_debugfs.c +++ b/drivers/gpu/drm/i915/display/intel_display_debugfs.c @@ -492,6 +492,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) { @@ -499,8 +500,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 0a20bc41be55..61a862ae1f28 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 7c5fd84a7b65..f06f6e5a2b1a 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.39.0.246.g2a6d74b583-goog