From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27CB8C7619A for ; Tue, 11 Apr 2023 19:21:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229639AbjDKTVu (ORCPT ); Tue, 11 Apr 2023 15:21:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229612AbjDKTVp (ORCPT ); Tue, 11 Apr 2023 15:21:45 -0400 Received: from mail-yb1-xb30.google.com (mail-yb1-xb30.google.com [IPv6:2607:f8b0:4864:20::b30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7720B46AA for ; Tue, 11 Apr 2023 12:21:44 -0700 (PDT) Received: by mail-yb1-xb30.google.com with SMTP id bv15so7581880ybb.1 for ; Tue, 11 Apr 2023 12:21:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1681240904; x=1683832904; 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=FeKha53f0k4bkkLO2dosUj09FTrVxWlUDNH1WTM2b9U=; b=G2Z+paoTiwP/7rYfsV2ErD88qTHJUNNvgN9fOc0XaaBxkdsbP0xqzqz4ToIxE93XKC N1zduCfaMZUf7nvwe/fbfznQ/2EwU85XS2D/9ikuQMCpwA/1OvikO+IZAUfuMvDFIqI2 bj6yNu7zDh7jq1/qk5ZKF7bzfFow3rhdcELfs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681240904; x=1683832904; 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=FeKha53f0k4bkkLO2dosUj09FTrVxWlUDNH1WTM2b9U=; b=ocKrj6DKHx8D7L+zMgnBRoTPehNoL6YhdDg7GLY+R7rsB4arxF0fVIfbjNVVlS5cVL bxfUaS3sWY4QwsgcdluFY76w700egL3igIL7CpsBNvRO6Hd8RG/X1DE4ZPAQZ8UwRt2d a8J+VGNStfZ56H/pFmW7FJ6o8b8y+FHRt4UgBX5MDrNWtJyrosOnaAbN+Y2BzzU+xP9F JrO0rMJ8L64ozqacOBmKYITzhG94xuO6LReXh+D404ZZL53UKSxaOEbtOhSK86qbS/To eLVNfNyfFIaPM8PjK4IzMxDTIW6M1g7+bEoy1U/r0jRkJiZxgOQjZpMDilLA5QmgKxe9 Oejg== X-Gm-Message-State: AAQBX9dXEcFCvGSZm56e35amS0BDmSG2+8Yyh/AikfS8ejxyVy10n8zU kst1dpxPwd1TZoLF6DM9RXDhRw== X-Google-Smtp-Source: AKy350ZluJDOFpd1AfULKx22Egaoc8rniZgjGxaSiTV1kSN57HEq33GJfYfvuLjFtNJ/h1PIr681mg== X-Received: by 2002:a25:6545:0:b0:b8b:d5d7:69cb with SMTP id z66-20020a256545000000b00b8bd5d769cbmr8610485ybb.47.1681240904084; Tue, 11 Apr 2023 12:21:44 -0700 (PDT) Received: from localhost ([2620:0:1035:15:2991:9b76:4e62:65bf]) by smtp.gmail.com with UTF8SMTPSA id n127-20020a25d685000000b00b8ec81d8d90sm2888837ybg.37.2023.04.11.12.21.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Apr 2023 12:21:43 -0700 (PDT) From: Mark Yacoub X-Google-Original-From: Mark Yacoub To: David Airlie , Daniel Vetter Cc: seanpaul@chromium.org, suraj.kandpal@intel.com, dianders@chromium.org, dmitry.baryshkov@linaro.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Jani Nikula , Rodrigo Vivi , Mark Yacoub , linux-kernel@vger.kernel.org Subject: [PATCH v9 03/10] drm/hdcp: Update property value on content type and user changes Date: Tue, 11 Apr 2023 15:21:27 -0400 Message-Id: <20230411192134.508113-4-markyacoub@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog In-Reply-To: <20230411192134.508113-1-markyacoub@google.com> References: <20230411192134.508113-1-markyacoub@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Paul Update the connector's property value in 2 cases which were previously missed: 1- Content type changes. The value should revert back to DESIRED from ENABLED in case the driver must re-authenticate the link due to the new content type. 2- Userspace sets value to DESIRED while ENABLED. In this case, the value should be reset immediately to ENABLED since the link is actively being encrypted. To accommodate these changes, I've split up the conditionals to make things a bit more clear (as much as one can with this mess of state). 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: -Fixed indentation issue identified by 0-day Changes in v4: -None Changes in v5: -None Changes in v6: -Rebased: modifications in drm_hdcp_helper.c instead of drm_hdcp.c Changes in v7: -Rebased as function name has changed. drivers/gpu/drm/display/drm_hdcp_helper.c | 29 +++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/display/drm_hdcp_helper.c b/drivers/gpu/drm/display/drm_hdcp_helper.c index 34baf2b97cd87..3ee1a6ae26c53 100644 --- a/drivers/gpu/drm/display/drm_hdcp_helper.c +++ b/drivers/gpu/drm/display/drm_hdcp_helper.c @@ -480,21 +480,30 @@ bool drm_hdcp_has_changed(struct drm_connector *connector, return true; /* - * Nothing to do if content type is unchanged and one of: - * - state didn't change - * - HDCP was activated since the last commit - * - attempting to set to desired while already enabled + * Content type changes require an HDCP disable/enable cycle. */ - if (old_hdcp == new_hdcp || - (old_hdcp == DRM_MODE_CONTENT_PROTECTION_DESIRED && + if (new_conn_state->hdcp_content_type != + old_conn_state->hdcp_content_type) { + new_conn_state->content_protection = + DRM_MODE_CONTENT_PROTECTION_DESIRED; + return true; + } + + /* + * Ignore meaningless state changes: + * - HDCP was activated since the last commit + * - Attempting to set to desired while already enabled + */ + if ((old_hdcp == DRM_MODE_CONTENT_PROTECTION_DESIRED && new_hdcp == DRM_MODE_CONTENT_PROTECTION_ENABLED) || (old_hdcp == DRM_MODE_CONTENT_PROTECTION_ENABLED && new_hdcp == DRM_MODE_CONTENT_PROTECTION_DESIRED)) { - if (old_conn_state->hdcp_content_type == - new_conn_state->hdcp_content_type) - return false; + new_conn_state->content_protection = + DRM_MODE_CONTENT_PROTECTION_ENABLED; + return false; } - return true; + /* Finally, if state changes, we need action */ + return old_hdcp != new_hdcp; } EXPORT_SYMBOL(drm_hdcp_has_changed); -- 2.40.0.577.gac1e443424-goog