Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1572328rwl; Fri, 24 Mar 2023 12:22:29 -0700 (PDT) X-Google-Smtp-Source: AKy350ZZyR1Qv0jClao4O3DDFqNT+/YtlMrX/r2+NuDr1NQNlnJNpyBNesBgxjGTK5awIF+isxXz X-Received: by 2002:a17:906:3f89:b0:877:a9d2:e5e9 with SMTP id b9-20020a1709063f8900b00877a9d2e5e9mr3736978ejj.42.1679685748819; 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=YblVFbBLb/IZxYQxOxeJG4/D8cob+m4zc1W9GAD0Uuqgf4iYvbE/XL0G5/cND0pW6m yWLlIqfudXagOXFC+uvVk4aAoGlR3B7fhzOOVTWFhTFAaCJbClGbGqYPJnmRCsSfkydS iCUpjGKeO1giTQjC9aAyOGzpHabXwsE7zIUs4xheQbzizOmKhxoM/b6+1Jpm3zyl5HNg t39VhG4F1AGP+DX9TmCF8+HIPqcVrhd1EpYV1wZf3DZxgxlK44mUloSRmfwpSzThLDpO cRrhkiLs+qlB2SO2mS8s9PlakaqZj4HJ5lMY+XSNK2Zr4ltfruA0AcZYDEXGu1X04lhU yL8A== 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=Exj6+hryfx7clb9QaiGo28Nm0qDVjYvxkFoG4ObE4LU=; b=OuUiQ9fpqYWucIFWJJxulyvqVvF25Q+samjjZjuK7L5wIVfaDGnUlTYmRVzYLWrTlf J5jA7S5L9qzA2Cuj/HH7rTIGQzRHif5VLT9OfphgGh/XZYNQ7QPeIM+KElxlipvl2uyw Q6ieB6TJpmEpQQqUubL4FY0/pxKsyHVpkIHxY+jj1C71zgVFj65Bw3mXhX5m8AlKjzgX YacMMRVENl/Vn3ONGHluAECeYgW6n/9ZIiXzN144//pdPqMqOO/AdeAw2tRe2v/MNdQo QPWzqC6GrrupzI8oga2FyMvupcFOJ2UUjxl2en3tOARyScsTzPSAlIqMV4A6wQFNarRE 08eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HiFhAenn; 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 qa6-20020a170907868600b009333d508e9asi20523551ejc.82.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=HiFhAenn; 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 S231740AbjCXTVP (ORCPT + 99 others); Fri, 24 Mar 2023 15:21:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231667AbjCXTVK (ORCPT ); Fri, 24 Mar 2023 15:21:10 -0400 Received: from mail-yb1-xb2e.google.com (mail-yb1-xb2e.google.com [IPv6:2607:f8b0:4864:20::b2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84F8B136EA for ; Fri, 24 Mar 2023 12:21:09 -0700 (PDT) Received: by mail-yb1-xb2e.google.com with SMTP id p15so3493786ybl.9 for ; Fri, 24 Mar 2023 12:21:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679685669; 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=Exj6+hryfx7clb9QaiGo28Nm0qDVjYvxkFoG4ObE4LU=; b=HiFhAennZ7QDfcVFoB2hqG5Q8Bxnn/Hndx9rv0x/8+PyhUbXqyAnJd+LGeNTjt9Y/T CnYABaW5l979X3mAv7mhqHmtN2XMYN3chJdJPx0r9VpfmqNxAHZ/RcqEKllQbYbXNCwJ 4/hladp//G9rn7GyJPpV1mjKT/ivLugKUTHf8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679685669; 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=Exj6+hryfx7clb9QaiGo28Nm0qDVjYvxkFoG4ObE4LU=; b=Xj4ztUnVlGDhXrGNNIJjJVJaeMcSeKwTJb4+SBBw6/vIte+eAc5UAi6Ow89wE4cnza Q7Hh787N6SMQh4WzKPS1umMaWuo26+opeHvvyIeRL24O7Okpp3Zek9I7o9a+OfTgNo9S mn7Pf1wOPugtMOA5Flc9xOzMm5ehkiv4ciTvI2OYlRHcuTFZXHHObe/K2cACGf3++UHv xD0zjLfV+gW81obhwD+XKmApl1UVGw5S4TA0aotNwAyUeMZE81Ri2j4LU3hsALy7/g6w z18lz2qM06eZ3QVbJGY9hvFCWmMsQKh2Vme4FXpmkSacdZdAYZ2SasW63IILjewxGbgd LLNg== X-Gm-Message-State: AAQBX9c5yenagEK5PunOhUXkv6TGDdad00tgOkz0XU8bXbAyooy8uygZ NnV1VD8WOE9ITt8MGscgPbxi4w== X-Received: by 2002:a25:10d4:0:b0:b6c:5b2f:ca61 with SMTP id 203-20020a2510d4000000b00b6c5b2fca61mr2646401ybq.26.1679685668745; Fri, 24 Mar 2023 12:21:08 -0700 (PDT) Received: from localhost ([2620:0:1035:15:5509:ec45:2b32:b39f]) by smtp.gmail.com with UTF8SMTPSA id i11-20020a25220b000000b00b7767ca7488sm625068ybi.37.2023.03.24.12.21.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Mar 2023 12:21:08 -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, Jani Nikula , Rodrigo Vivi , Mark Yacoub , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 03/10] drm/hdcp: Update property value on content type and user changes Date: Fri, 24 Mar 2023 15:20:50 -0400 Message-Id: <20230324192058.3916571-4-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 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.348.gf938b09366-goog