From patchwork Fri Sep 23 20:52:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hamza Mahfooz X-Patchwork-Id: 12987195 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7ACC9C07E9D for ; Fri, 23 Sep 2022 20:52:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5C59410E1F1; Fri, 23 Sep 2022 20:52:48 +0000 (UTC) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2042.outbound.protection.outlook.com [40.107.220.42]) by gabe.freedesktop.org (Postfix) with ESMTPS id 22E6A10E1F1; Fri, 23 Sep 2022 20:52:44 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aYISXiCXslb+QgM8KcKXVngvVgEO+clVNzaVXyd8xFuaawwnwdcRwACcEuCIjxlwwKigJFKsDAU8wnn72XQ5VXJ65pro0AlKB8H+tAOlpuSZm6td/pNT1s+2Af2GvtjKShRuK6yo/WTsffa8hYsQ9J6YhP8Gu5KKuaUzJ11w9SEyUkPHeYVDveXwXztexgHrpydBtKj4tT3TtVPCVblY2umoMtpIhe5krQKg/Y25vRgg3je/MhwZKCNID4SyorDnonqB18WZ4bM3RXl53oXDYBGY7cY9tBcRevefkm99vqfgJaJfPDGZ/sTDz68dbppx9E5yrW8ttXhN9FE5PyJksg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JIHfBcJrCmnBRxtjis+sCa2mamAhQ+etIHBFLKZQ1/w=; b=VWRD39Onxrb6/E/9OEiaqbN0oisxIeaQSi/ZuQfs2SIz0jfYX3FDjU/7NjUt050ngAfslABxlpO3L/RijKo5rmxdEqzSLlzwTsS3MORcu9z4Ee4Yi0LmLj3BxIHs0vtc+IbPHHKGZStHpU7dzxeSD+Gu1zABxwIXvTVhz92MzXuyBcmvFQ7WA8V8BXAYc34i41rZCTTyTwbMdD7ctqa0btyYItxIqpScVYX7ERdTK0j4VUvxcegI/MD0+rp3pxwWpAjhmUdaNoKInw7tQwTufSM3Ikx9ff7WFEtSwAlPtEJjR5O5FTTAEFOGcpeBd7WDaFk1i7r/xJvFSdGYskmI+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JIHfBcJrCmnBRxtjis+sCa2mamAhQ+etIHBFLKZQ1/w=; b=E0udaQMgrKseJFuzs2huo1FNF9l80LoGWsAcGVInddN2pmGD55Qcxztw/x1Mjh/Pd0PLMdjOQe0RFL1MOhkuwygFaNbOHOaF+iaO6smqXvnuNa0wah1AjmcAVoeVSmkIuZwWvtLzhdWRqcT2Z3gA9asHyqNQizb+3cJC7N4Rrlo= Received: from DM6PR06CA0088.namprd06.prod.outlook.com (2603:10b6:5:336::21) by IA1PR12MB6209.namprd12.prod.outlook.com (2603:10b6:208:3e7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.20; Fri, 23 Sep 2022 20:52:41 +0000 Received: from DM6NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:5:336:cafe::8b) by DM6PR06CA0088.outlook.office365.com (2603:10b6:5:336::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.20 via Frontend Transport; Fri, 23 Sep 2022 20:52:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT058.mail.protection.outlook.com (10.13.172.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5654.14 via Frontend Transport; Fri, 23 Sep 2022 20:52:41 +0000 Received: from hamza-pc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Fri, 23 Sep 2022 15:52:38 -0500 From: Hamza Mahfooz To: Subject: [PATCH 1/3] drm/amd/display: fix HDCP drm prop update for MST Date: Fri, 23 Sep 2022 16:52:28 -0400 Message-ID: <20220923205234.207628-1-hamza.mahfooz@amd.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT058:EE_|IA1PR12MB6209:EE_ X-MS-Office365-Filtering-Correlation-Id: 4c17acfe-5c42-4a5f-eab3-08da9da58e88 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mBw9PxeIwVtfkT/RzL691vsujth81IJOjAX4YKDFVNJC5IW2dIlsTblVrWqH3QhpCLK74gBQughowDr47yfXZ5Cx5dlA0gVex7pSaZo1/e9py1azhsg7Iblq27WWCgCB1ws0YSfqTs1UMjCJcDVuPhwy1ZW6vbCTLVUMj39VVgVISBzp7Mwq1n1SmpMjLGyMKkKRnedwBzOpMTIEjWQEq1hL6GBRRZAzKfmc1kHAp9H+dq/fPT9v1/bZkAAdPi4w4BJFVv08NHmFPWBnw+PiW4aErn5YVJtypYOQebEK9MfDQqqmcMj6INynTGDC5iS8hmap0Tv8HFqzeUuGMnKEJty34B2tiAo2PE4w9td0U3hbj8wT+4kRwKBkHUj5+11TEzQ9o3RZgstx1shmwBkfNSsMx2l7m8YA+hqz1fjO7D/qhW1eIXk/sjocR2TzomX+yM5yz6GgjdkS/w5Nqq0SOaxp3IzL5ZduFr+cX6VlIpnbpwMm/iEJEGVbzYTw7UiElOXNeWxDvpg62SadqZpkyfa+xaRn53zDqcMBvtHT9SDYg5J2/tF67DDObJlATmhMXtqHg7X8bENpQL4h6/XJin9KyxFBhK+bnJOIc91DUmj33SRdYYYVmWMNwxjalOr8Kg0xFgQWTeXqVM+AENY2WGGRkHYVj7fbYWGrLbnEJwKp2SeQ9QEUFOJ/Dsax3+EuxHuh6JkU+H3JX9cn6ualZSUAjf6QgPLr0jZQQlM3Fwg64b44310TCjo+NgfJh06WrY1ui/E9JzYEloTe+WcP+odna4txAFknif1Qe2BEGVlgxhMCYmz7znqx4zyB5A73RN+yRGtMF/YA0lIFFkQmHA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(376002)(39860400002)(136003)(396003)(346002)(451199015)(46966006)(36840700001)(40470700004)(426003)(36756003)(1076003)(2616005)(6666004)(15650500001)(41300700001)(16526019)(336012)(26005)(44832011)(2906002)(8936002)(7696005)(186003)(5660300002)(82740400003)(81166007)(82310400005)(47076005)(83380400001)(40480700001)(86362001)(40460700003)(356005)(36860700001)(478600001)(316002)(54906003)(6916009)(70586007)(4326008)(70206006)(8676002)(16060500005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2022 20:52:41.1755 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4c17acfe-5c42-4a5f-eab3-08da9da58e88 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6209 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann , Leo Li , Jude Shih , Qingqing Zhuo , "Pan, Xinhui" , Rodrigo Siqueira , Roman Li , amd-gfx@lists.freedesktop.org, Nicholas Kazlauskas , David Airlie , Fangzhi Zuo , Aurabindo Pillai , hersen wu , Hamza Mahfooz , Wayne Lin , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" For MST topology with 1 physical link and multiple connectors (e.g. a one-to-many MST hub), if userspace enables HDCP simultaneously on all connected outputs, the commit tail iteratively calls hdcp_update_display() for each display (connector). However, the HDCP workqueue data structure for each link has only one DM connector and encryption status member, which means the workqueue of property_validate/update() would only be triggered for the last connector within this physical link, and therefore the HDCP property value of other connectors would stay on DESIRED instead of switching to ENABLED. So, to ensure that all of the connectors switch from DESIRED to ENABLED keep track of each connector's status in an array instead of only keeping track of the status of the most recent connector that userspace has interacted with. Signed-off-by: Hamza Mahfooz --- .../amd/display/amdgpu_dm/amdgpu_dm_hdcp.c | 145 +++++++++++++----- .../amd/display/amdgpu_dm/amdgpu_dm_hdcp.h | 5 +- 2 files changed, 113 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c index 6202e31c7e3a..922ec91940e4 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c @@ -170,9 +170,10 @@ void hdcp_update_display(struct hdcp_workqueue *hdcp_work, struct mod_hdcp_display *display = &hdcp_work[link_index].display; struct mod_hdcp_link *link = &hdcp_work[link_index].link; struct mod_hdcp_display_query query; + unsigned int conn_index = aconnector->base.index; mutex_lock(&hdcp_w->mutex); - hdcp_w->aconnector = aconnector; + hdcp_w->aconnector[conn_index] = aconnector; query.display = NULL; mod_hdcp_query_display(&hdcp_w->hdcp, aconnector->base.index, &query); @@ -204,7 +205,8 @@ void hdcp_update_display(struct hdcp_workqueue *hdcp_work, msecs_to_jiffies(DRM_HDCP_CHECK_PERIOD_MS)); } else { display->adjust.disable = MOD_HDCP_DISPLAY_DISABLE_AUTHENTICATION; - hdcp_w->encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF; + hdcp_w->encryption_status[conn_index] = + MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF; cancel_delayed_work(&hdcp_w->property_validate_dwork); } @@ -223,9 +225,10 @@ static void hdcp_remove_display(struct hdcp_workqueue *hdcp_work, { struct hdcp_workqueue *hdcp_w = &hdcp_work[link_index]; struct drm_connector_state *conn_state = aconnector->base.state; + unsigned int conn_index = aconnector->base.index; mutex_lock(&hdcp_w->mutex); - hdcp_w->aconnector = aconnector; + hdcp_w->aconnector[conn_index] = aconnector; /* the removal of display will invoke auth reset -> hdcp destroy and * we'd expect the Content Protection (CP) property changed back to @@ -247,13 +250,18 @@ static void hdcp_remove_display(struct hdcp_workqueue *hdcp_work, void hdcp_reset_display(struct hdcp_workqueue *hdcp_work, unsigned int link_index) { struct hdcp_workqueue *hdcp_w = &hdcp_work[link_index]; + unsigned int conn_index; mutex_lock(&hdcp_w->mutex); mod_hdcp_reset_connection(&hdcp_w->hdcp, &hdcp_w->output); cancel_delayed_work(&hdcp_w->property_validate_dwork); - hdcp_w->encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF; + + for (conn_index = 0; conn_index < AMDGPU_DM_MAX_DISPLAY_INDEX; + conn_index++) + hdcp_w->encryption_status[conn_index] = + MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF; process_output(hdcp_w); @@ -290,45 +298,85 @@ static void event_callback(struct work_struct *work) } -static void event_property_update(struct work_struct *work) + +static struct amdgpu_dm_connector *find_first_connected_output(struct hdcp_workqueue *hdcp_work) { + unsigned int conn_index; + for (conn_index = 0; conn_index < AMDGPU_DM_MAX_DISPLAY_INDEX; + conn_index++) + if (hdcp_work->aconnector[conn_index]) + return hdcp_work->aconnector[conn_index]; + + return NULL; +} + +static void event_property_update(struct work_struct *work) +{ struct hdcp_workqueue *hdcp_work = container_of(work, struct hdcp_workqueue, property_update_work); - struct amdgpu_dm_connector *aconnector = hdcp_work->aconnector; - struct drm_device *dev = hdcp_work->aconnector->base.dev; + struct amdgpu_dm_connector *aconnector = + find_first_connected_output(hdcp_work); + struct drm_device *dev; long ret; + unsigned int conn_index; + struct drm_connector *connector; + struct drm_connector_state *conn_state; + + if (!aconnector) + return; + + dev = aconnector->base.dev; drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); mutex_lock(&hdcp_work->mutex); + for (conn_index = 0; conn_index < AMDGPU_DM_MAX_DISPLAY_INDEX; + conn_index++) { + aconnector = hdcp_work->aconnector[conn_index]; + + if (!aconnector) + continue; + + if (!aconnector->base.index) + continue; + + connector = &aconnector->base; + conn_state = aconnector->base.state; - if (aconnector->base.state && aconnector->base.state->commit) { - ret = wait_for_completion_interruptible_timeout(&aconnector->base.state->commit->hw_done, 10 * HZ); + if (!conn_state) + continue; - if (ret == 0) { - DRM_ERROR("HDCP state unknown! Setting it to DESIRED"); - hdcp_work->encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF; + if (conn_state->commit) { + ret = wait_for_completion_interruptible_timeout(&conn_state->commit->hw_done, + 10 * HZ); + if (!ret) { + DRM_ERROR("HDCP state unknown! Setting it to DESIRED"); + hdcp_work->encryption_status[conn_index] = + MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF; + } } - } - if (aconnector->base.state) { - if (hdcp_work->encryption_status != MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF) { - if (aconnector->base.state->hdcp_content_type == - DRM_MODE_HDCP_CONTENT_TYPE0 && - hdcp_work->encryption_status <= - MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE0_ON) - drm_hdcp_update_content_protection(&aconnector->base, + if (hdcp_work->encryption_status[conn_index] != + MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF) { + if (conn_state->hdcp_content_type == + DRM_MODE_HDCP_CONTENT_TYPE0 && + hdcp_work->encryption_status[conn_index] <= + MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE0_ON) + + drm_hdcp_update_content_protection(connector, DRM_MODE_CONTENT_PROTECTION_ENABLED); - else if (aconnector->base.state->hdcp_content_type == - DRM_MODE_HDCP_CONTENT_TYPE1 && - hdcp_work->encryption_status == - MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON) - drm_hdcp_update_content_protection(&aconnector->base, + else if (conn_state->hdcp_content_type == + DRM_MODE_HDCP_CONTENT_TYPE1 && + hdcp_work->encryption_status[conn_index] == + MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON) + + drm_hdcp_update_content_protection(connector, DRM_MODE_CONTENT_PROTECTION_ENABLED); } else { - drm_hdcp_update_content_protection(&aconnector->base, + drm_hdcp_update_content_protection(connector, DRM_MODE_CONTENT_PROTECTION_DESIRED); } + } mutex_unlock(&hdcp_work->mutex); @@ -340,19 +388,37 @@ static void event_property_validate(struct work_struct *work) struct hdcp_workqueue *hdcp_work = container_of(to_delayed_work(work), struct hdcp_workqueue, property_validate_dwork); struct mod_hdcp_display_query query; - struct amdgpu_dm_connector *aconnector = hdcp_work->aconnector; - - if (!aconnector) - return; + struct amdgpu_dm_connector *aconnector; + unsigned int conn_index; mutex_lock(&hdcp_work->mutex); - query.encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF; - mod_hdcp_query_display(&hdcp_work->hdcp, aconnector->base.index, &query); + for (conn_index = 0; conn_index < AMDGPU_DM_MAX_DISPLAY_INDEX; + conn_index++) { + aconnector = hdcp_work->aconnector[conn_index]; - if (query.encryption_status != hdcp_work->encryption_status) { - hdcp_work->encryption_status = query.encryption_status; - schedule_work(&hdcp_work->property_update_work); + if (!aconnector) + continue; + + if (!aconnector->base.index) + continue; + + query.encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF; + mod_hdcp_query_display(&hdcp_work->hdcp, aconnector->base.index, + &query); + + DRM_DEBUG_DRIVER("[HDCP_DM] display %d, CP %u, (query->enc_st, work->enc_st): (%d, %d)\n", + aconnector->base.index, + aconnector->base.state->content_protection, + query.encryption_status, + hdcp_work->encryption_status[conn_index]); + + if (query.encryption_status != + hdcp_work->encryption_status[conn_index]) { + hdcp_work->encryption_status[conn_index] = + query.encryption_status; + schedule_work(&hdcp_work->property_update_work); + } } mutex_unlock(&hdcp_work->mutex); @@ -686,6 +752,15 @@ struct hdcp_workqueue *hdcp_create_workqueue(struct amdgpu_device *adev, struct hdcp_work[i].hdcp.config.ddc.funcs.read_i2c = lp_read_i2c; hdcp_work[i].hdcp.config.ddc.funcs.write_dpcd = lp_write_dpcd; hdcp_work[i].hdcp.config.ddc.funcs.read_dpcd = lp_read_dpcd; + + memset(hdcp_work[i].aconnector, 0, + sizeof(struct amdgpu_dm_connector *) * + AMDGPU_DM_MAX_DISPLAY_INDEX); + + memset(hdcp_work[i].encryption_status, 0, + sizeof(enum mod_hdcp_encryption_status) * + AMDGPU_DM_MAX_DISPLAY_INDEX); + } cp_psp->funcs.update_stream_config = update_config; diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.h index 09294ff122fe..b2dbc0719472 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.h +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.h @@ -43,7 +43,7 @@ struct hdcp_workqueue { struct delayed_work callback_dwork; struct delayed_work watchdog_timer_dwork; struct delayed_work property_validate_dwork; - struct amdgpu_dm_connector *aconnector; + struct amdgpu_dm_connector *aconnector[AMDGPU_DM_MAX_DISPLAY_INDEX]; struct mutex mutex; struct mod_hdcp hdcp; @@ -51,7 +51,8 @@ struct hdcp_workqueue { struct mod_hdcp_display display; struct mod_hdcp_link link; - enum mod_hdcp_encryption_status encryption_status; + enum mod_hdcp_encryption_status encryption_status[ + AMDGPU_DM_MAX_DISPLAY_INDEX]; uint8_t max_link; uint8_t *srm; From patchwork Fri Sep 23 20:52:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hamza Mahfooz X-Patchwork-Id: 12987197 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8B154C07E9D for ; Fri, 23 Sep 2022 20:53:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A8C3410E99C; Fri, 23 Sep 2022 20:53:06 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2068.outbound.protection.outlook.com [40.107.244.68]) by gabe.freedesktop.org (Postfix) with ESMTPS id C016F10E993; Fri, 23 Sep 2022 20:52:53 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OSpfBGoukY5A1r2ot67wVWFYJNU3FTN9fy2ZyjP8yPsB15X3iRVlq7B0YCyY0KSOEVUfToVcJ0xmJBe/H/kWKbPjiRBSvWMZ3a8RcVeU82S8kO9D/KrCQ2gDq+FzOyn1MZb9DzFGs7bxNXGCtsHTJXt0KGP+jqs1OrFMHQF++MSxIUi40xxGXZfhOiZsTpi+bUI7b3cS9T/HeN2lwcetHVbAwEcjyQYfLinKmUwUGkfWs+AlOAvPmZUAUD3SUbWKLwIEC+ZLH0iLcuMMQJ0aCSKEtC5KXKSiZkW5pHcDbA6RqEhy+NLW8K2lyHIsz1NDCeL7t8eaVFrpbLzRYGaVzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wPPpZbvK0rrna2XUNIBSgOVGlDsfDzSm/99WzeOdlao=; b=Ye4Zb0vqoRriLSJVA5UXTDP+ZPx77aNYIomkKD+NUDFR7pjlPs19j57lvha+/2ByYjatvlPt0W7eoecqzbBnC4wmPVlb4hWhI6zpBK7lhArOTNnemJfqbNHCY7ySV16+b3SrDXA38K2qTKId2HLx/qqWLBILxEulfxyqCrRXB8veQD5InkhEux+E2PiNPnaw9hFmRYLdj8l7/XlRFdo5SQR5s6OHkhCwW/k5lS6KPmY0aa4nX0tYT8XMmfRwumrAmdOpjqZWRiqdxgDYURhRjsLBZH1SZmJBWXYXj5a31ULF1Sam9ywQkjUL514DVsBjv05yPAwqr5xDinZJc3o/KA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wPPpZbvK0rrna2XUNIBSgOVGlDsfDzSm/99WzeOdlao=; b=xO+A57WVISAIm7tULeUTotwxuoDmwXyXP4EY/G/LlQR0ksHOp0doQR0LP8TL0kcS88Jlk+8BlE1JhRYx1mfeLAOpyA6Fm0usXnk+LWi8JZ2aFS43Lxhyja90Mp/UGW39n+T1T8bMNCvrHdsPi3AoniQjmqZBknCZGB08vVUzQuM= Received: from DM6PR02CA0125.namprd02.prod.outlook.com (2603:10b6:5:1b4::27) by DM4PR12MB5326.namprd12.prod.outlook.com (2603:10b6:5:39a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.20; Fri, 23 Sep 2022 20:52:51 +0000 Received: from DM6NAM11FT051.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1b4:cafe::e9) by DM6PR02CA0125.outlook.office365.com (2603:10b6:5:1b4::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.20 via Frontend Transport; Fri, 23 Sep 2022 20:52:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT051.mail.protection.outlook.com (10.13.172.243) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5654.14 via Frontend Transport; Fri, 23 Sep 2022 20:52:51 +0000 Received: from hamza-pc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Fri, 23 Sep 2022 15:52:49 -0500 From: Hamza Mahfooz To: Subject: [PATCH 2/3] drm/amd/display: save and restore a connector's HDCP properties Date: Fri, 23 Sep 2022 16:52:29 -0400 Message-ID: <20220923205234.207628-2-hamza.mahfooz@amd.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220923205234.207628-1-hamza.mahfooz@amd.com> References: <20220923205234.207628-1-hamza.mahfooz@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT051:EE_|DM4PR12MB5326:EE_ X-MS-Office365-Filtering-Correlation-Id: fdd4d57a-9507-4b53-26c4-08da9da594c0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bttjQjTJcajWq/pQske2jYN4vZ4Nnt0Pd8wb+qYJ563t1TKlNt4E7a/ZwCyzgc5TokV8E/LhuDDMs5S3PXbhdYvQWkiIkmJFWL4jNHRQSu3EmJC3XEzzfGPLe8nGUnMxXWL54a9V/09A2NXrJ9yqkWzTPgn+WERs5M52AE1fXE6EjdFGB8evxQ+jwGPurhbsroK2ZoIY0YThz0sIixtD95qsVvcI7hUnfodiuJXkxmQdwkIiTS6/Dlrwc3WezCPqP+8CzC65sbruhGbc+EU54FilN/LYfcnXV30zwRh+84X0z+MGEk/G8X61VGO9fB8VxuNpPYzHq7WV9ZTcyTWND6ZVDDz4dJIkeXlzRGermMcHpNEXjQH2zc2ooSf6SwHBNb2vU79dAhrLgMZaTtd77wquh7+QpSSHh8oSWhXxkN3T92N6jKkOILGdDrFKOESbCputBuuRpIXUs52aubRuO/iIC1B61t+nnPxIpIwmTVQLQWLodSNm3G9Y2gtUUyRP1sWIjYn8q2BUI+rl2+9xovxkun4ZA0QziV8LgXFXtSQphbGky6SY7pbEYzYJbZ1NeuQL9q9LNgXVjQl9STUGI6IjESLNOs1rbLEaeBbFZ+sucNGvAgez9NkhFvZCsLFwGQYoKtYwQe26CWXpLww3OMsyS1iG6wI61T9Tjgf6/miSa48g16JZPhi4PO/c+wvTa0MHyhlZYUBHwk/jRnxc/GjGUCZJgSr2/X/Z5XS8CIY9/CU7R3r+YbWHUvLgQZUXxluGntKHX//yPNO8+IalXwgu78LP3yrH4hhKqhso0RYrK1oNFf5aWx+iVJA99ZfSAEtRqv/8idK9AiBLLR1WPA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(346002)(376002)(396003)(136003)(39860400002)(451199015)(36840700001)(40470700004)(46966006)(2906002)(44832011)(356005)(82310400005)(26005)(81166007)(36756003)(40460700003)(2616005)(1076003)(16526019)(186003)(4326008)(70586007)(70206006)(5660300002)(86362001)(8676002)(8936002)(426003)(6916009)(316002)(54906003)(478600001)(6666004)(7696005)(82740400003)(36860700001)(40480700001)(41300700001)(336012)(47076005)(83380400001)(16060500005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2022 20:52:51.6194 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fdd4d57a-9507-4b53-26c4-08da9da594c0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT051.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5326 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann , Leo Li , Jude Shih , Qingqing Zhuo , "Pan, Xinhui" , Rodrigo Siqueira , Roman Li , amd-gfx@lists.freedesktop.org, Nicholas Kazlauskas , David Airlie , Fangzhi Zuo , Aurabindo Pillai , hersen wu , Hamza Mahfooz , Wayne Lin , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" When a display is unplugged from a MST hub, the connector will be destroyed in dm_dp_mst_connector_destroy(). The connector's HDCP properties, like HDCP state will be lost. So, save the connector's HDCP properties into hdcp_work in amdgpu_dm_atomic_commit_tail(). Also, if the same display is plugged back in with the same display index, restore its HDCP properties from hdcp_work in dm_dp_mst_get_modes(). Signed-off-by: Hamza Mahfooz --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 56 +++++++++++++++++-- .../amd/display/amdgpu_dm/amdgpu_dm_hdcp.h | 13 +++++ .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 33 +++++++++++ 3 files changed, 97 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index ece2003a74cc..8d8788792f7d 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -7990,6 +7990,12 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) struct drm_connector *connector; struct drm_connector_state *old_con_state, *new_con_state; struct dm_crtc_state *dm_old_crtc_state, *dm_new_crtc_state; +#ifdef CONFIG_DRM_AMD_DC_HDCP + struct dc_edid_caps *edid_caps; + struct hdcp_workqueue *hdcp_work, *hdcp_w; + unsigned int index; + bool enable_encryption = false; +#endif int crtc_disable_count = 0; bool mode_set_reset_required = false; @@ -8165,11 +8171,51 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) continue; } - if (is_content_protection_different(new_con_state, old_con_state, connector, adev->dm.hdcp_workqueue)) - hdcp_update_display( - adev->dm.hdcp_workqueue, aconnector->dc_link->link_index, aconnector, - new_con_state->hdcp_content_type, - new_con_state->content_protection == DRM_MODE_CONTENT_PROTECTION_DESIRED); + if (is_content_protection_different(new_con_state, + old_con_state, + connector, + adev->dm.hdcp_workqueue)) { + + if (new_con_state->content_protection == + DRM_MODE_CONTENT_PROTECTION_DESIRED) + enable_encryption = true; + + if (aconnector->dc_link && aconnector->dc_sink && + aconnector->dc_link->type == + dc_connection_mst_branch) { + hdcp_work = adev->dm.hdcp_workqueue; + hdcp_w = &hdcp_work[ + aconnector->dc_link->link_index]; + edid_caps = &aconnector->dc_sink->edid_caps; + index = connector->index; + + hdcp_w->sink_edid_id[index].manufacturer_id = + edid_caps->manufacturer_id; + hdcp_w->sink_edid_id[index].product_id = + edid_caps->product_id; + hdcp_w->sink_edid_id[index].serial_number = + edid_caps->serial_number; + hdcp_w->sink_edid_id[index].manufacture_week = + edid_caps->manufacture_week; + hdcp_w->sink_edid_id[index].manufacture_year = + edid_caps->manufacture_year; + + hdcp_w->hdcp_content_type[index] = + new_con_state->hdcp_content_type; + hdcp_w->content_protection[index] = + new_con_state->content_protection; + + if (new_crtc_state && + new_crtc_state->mode_changed) + enable_encryption = true; + } + + hdcp_update_display(adev->dm.hdcp_workqueue, + aconnector->dc_link->link_index, + aconnector, + new_con_state->hdcp_content_type, + enable_encryption); + } } #endif diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.h index b2dbc0719472..31a81ee5ab69 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.h +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.h @@ -37,6 +37,14 @@ struct mod_hdcp_link; struct mod_hdcp_display; struct cp_psp; +struct sink_identification { + uint16_t manufacturer_id; + uint16_t product_id; + uint32_t serial_number; + uint8_t manufacture_week; + uint8_t manufacture_year; +}; + struct hdcp_workqueue { struct work_struct cpirq_work; struct work_struct property_update_work; @@ -53,6 +61,11 @@ struct hdcp_workqueue { enum mod_hdcp_encryption_status encryption_status[ AMDGPU_DM_MAX_DISPLAY_INDEX]; + + struct sink_identification sink_edid_id[AMDGPU_DM_MAX_DISPLAY_INDEX]; + unsigned int hdcp_content_type[AMDGPU_DM_MAX_DISPLAY_INDEX]; + unsigned int content_protection[AMDGPU_DM_MAX_DISPLAY_INDEX]; + uint8_t max_link; uint8_t *srm; diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c index ce6929224a6e..872c83e61a13 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c @@ -31,6 +31,9 @@ #include "amdgpu.h" #include "amdgpu_dm.h" #include "amdgpu_dm_mst_types.h" +#ifdef CONFIG_DRM_AMD_DC_HDCP +#include "amdgpu_dm_hdcp.h" +#endif #include "dc.h" #include "dm_helpers.h" @@ -272,6 +275,10 @@ static bool retrieve_downstream_port_device(struct amdgpu_dm_connector *aconnect static int dm_dp_mst_get_modes(struct drm_connector *connector) { struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector); +#ifdef CONFIG_DRM_AMD_DC_HDCP + struct hdcp_workqueue *hdcp_work, *hdcp_w; + unsigned int index; +#endif int ret = 0; if (!aconnector) @@ -344,6 +351,32 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector) /* dc_link_add_remote_sink returns a new reference */ aconnector->dc_sink = dc_sink; +#ifdef CONFIG_DRM_AMD_DC_HDCP + if (aconnector->dc_sink && connector->state) { + hdcp_work = + drm_to_adev(connector->dev)->dm.hdcp_workqueue; + hdcp_w = &hdcp_work[aconnector->dc_link->link_index]; + index = connector->index; + + if (hdcp_w->sink_edid_id[index].manufacturer_id == + aconnector->dc_sink->edid_caps.manufacturer_id && + hdcp_w->sink_edid_id[index].product_id == + aconnector->dc_sink->edid_caps.product_id && + hdcp_w->sink_edid_id[index].serial_number == + aconnector->dc_sink->edid_caps.serial_number && + hdcp_w->sink_edid_id[index].manufacture_week == + aconnector->dc_sink->edid_caps.manufacture_week && + hdcp_w->sink_edid_id[index].manufacture_year == + aconnector->dc_sink->edid_caps.manufacture_year) { + + connector->state->hdcp_content_type = + hdcp_w->hdcp_content_type[index]; + connector->state->content_protection = + hdcp_w->content_protection[index]; + } + } +#endif + if (aconnector->dc_sink) { amdgpu_dm_update_freesync_caps( connector, aconnector->edid); From patchwork Fri Sep 23 20:52:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hamza Mahfooz X-Patchwork-Id: 12987196 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6B860C6FA83 for ; Fri, 23 Sep 2022 20:53:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F269A10E997; Fri, 23 Sep 2022 20:53:05 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2084.outbound.protection.outlook.com [40.107.244.84]) by gabe.freedesktop.org (Postfix) with ESMTPS id 986E010E997; Fri, 23 Sep 2022 20:53:00 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nil4m0AfGZ5RtG1kCbXuktQ8RX+fZSPepBc+pMEmi08jqhbSzObZ6XpT/2V18Ny/uDNYzE/0UQmvuf9za6f+4GYPXtdfosoR/vGdIlKRsbvEshNsUnw5azSt/D4Zn7C525PJ1YIXSvZkhPSGkxlZ6yLu9F+QW87f4NTmB1ip6ZGxedwfKHdKvU53TxlV1/+1T5nQ4KeIxAzGqVocHpCHqqNBPNBLZ+w9kLlANkM7rbz+jhBze+zreHK47v4yOah5gXWYwkKNBS5LGqcU/+kHpz9vMy79m8xHoHNSk81HgPfqys+7Se3hpvRxdMKtrHWkwYFyDH5OSfTbiJ1CPcaD6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wINproSnQ2zV4otvYodZUjfYe3xxLum1SI8Z1fK1vMM=; b=Do5UH6QaSF+zjAQGd2s9F1192BMSY+eoVtK8aEmBKT5kztCY9HpnbVWfdI53QOwSD48z00bVpUHeSgnxBNGTTMy+lltSCIGgjZlvXrhCIpek7c8oi2UfGSoCCKSKkJSRM6OqTJQMvA2diCZ7SgHaf+11uzlzJygFY/YOqZ2ygm8UlNq/GLLaWgRD6pakvju0FjRjJpTH1qz50VPppCtJS5yiggPAxrPYdUAUZk6GDMY1BGAjgSk0jCJImIjZhYyZFePtmAuAanf8C2X2uwNo5Yxv+fhfKnuS9D1yXcl5isLxvhaaK7Ahaim+W2xMco3CbY3Ji56sspovQVdgrkO+DA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wINproSnQ2zV4otvYodZUjfYe3xxLum1SI8Z1fK1vMM=; b=mqdmeGf4GVVAXyy10ZqQagRr0mCBe+I6DVCEI29mdYNR/PD1pZVtQ1qN1vGHT1o0MlKOHgsRRZ/kHBlE7MqNzleDkYqSAGW/O9eQyYSCR9ThTfFkQY0z7ExFdlj0r3ii8XiZRb/1h1G6tpec5grHAe9+rEVLSnLfi5Eg9uc+odg= Received: from DM6PR08CA0060.namprd08.prod.outlook.com (2603:10b6:5:1e0::34) by DM4PR12MB5182.namprd12.prod.outlook.com (2603:10b6:5:395::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.20; Fri, 23 Sep 2022 20:52:59 +0000 Received: from DM6NAM11FT020.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1e0:cafe::f3) by DM6PR08CA0060.outlook.office365.com (2603:10b6:5:1e0::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.20 via Frontend Transport; Fri, 23 Sep 2022 20:52:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT020.mail.protection.outlook.com (10.13.172.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5654.14 via Frontend Transport; Fri, 23 Sep 2022 20:52:58 +0000 Received: from hamza-pc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Fri, 23 Sep 2022 15:52:55 -0500 From: Hamza Mahfooz To: Subject: [PATCH 3/3] drm/amd/display: fix a crash caused by hot plugging on certain MST hubs Date: Fri, 23 Sep 2022 16:52:30 -0400 Message-ID: <20220923205234.207628-3-hamza.mahfooz@amd.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220923205234.207628-1-hamza.mahfooz@amd.com> References: <20220923205234.207628-1-hamza.mahfooz@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT020:EE_|DM4PR12MB5182:EE_ X-MS-Office365-Filtering-Correlation-Id: 312b1384-f1aa-4634-0ab2-08da9da5990c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8gZxDE3JQzwD0qketMib39a0qj0KukO5ptQIX+5kKhrQgPEutz2r7IqRs5UH4WNeLamk4KriYPFUSa/IyzwGZXCuhK5IAK7kt1ZhhYyd5XsU1g1C+ta5v4ZCjC34O+2nhdrptASPDCZqShxUWEnvyBmaNY1k68jsG5ldyktCUSrYvYmcpvSFC34ljZZLRSHp3UAhP/qJTkRfipO5mD/w6pXPJTwEGNcZYeLuTL+6HTgjWWhsZN4WnTfv4k7bxNlq7qrjqY7R0COohD1lFcvwpUYUT4AK2nTSR4VFjNyxnykAkG6mw9wqOI332dy/y7L6nk/SQ9JyEIyTbE4lbEJi0dNVAXvYUDtj5NgU7J7olSCmTvDOHuOuy5Sme2EqzQw4RPd6v09GnDoTGUipDVyKucBseMIwJf2YspS571YQEy/RIUCreTkpvc2uSeWJM9BTrW5Jc7BjES8trrhpza9YCYRmoAB0AIQXYRN+QkUhfC3TmLFRM5cFykWd9aoht2FC5TkEmwzLka6SlQDXCcvsscegQMrIJ+Y5eEqliHj9S+xNYLvyXtmA9MZSHYfIzHMqBNDDGT2C2cnDgTIy4e0J68IRgMEwxeHUjXYLzwb1n6U668xENDpl0kQO8BUdk0I2DcehIivzZT6tOdhNxZyQkDJVk0cnLqRV17rdrDNcTvUeZDWV0sMzrd4rsnqSHl1PebOVwW1mfvt9CW5zSPb3AmO7YfWh6nXvd9uiH22c6RRr4C0cJmdRn6dnYaJ+YMsMLsjjc2u/M0IzBcV3GfV2IiilBRZa6SVGpU2+jSH5Jzyt97DTiruWJVZ2Z5MZCeEgZ24/bijawChTtfymSt6bBg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(396003)(39860400002)(346002)(376002)(136003)(451199015)(46966006)(36840700001)(40470700004)(81166007)(356005)(36860700001)(2906002)(70206006)(70586007)(478600001)(82310400005)(316002)(6916009)(54906003)(426003)(47076005)(1076003)(186003)(40480700001)(16526019)(86362001)(336012)(26005)(36756003)(41300700001)(8936002)(82740400003)(5660300002)(4326008)(83380400001)(44832011)(7696005)(40460700003)(2616005)(6666004)(8676002)(16060500005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2022 20:52:58.8276 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 312b1384-f1aa-4634-0ab2-08da9da5990c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT020.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5182 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann , Leo Li , Jude Shih , Qingqing Zhuo , "Pan, Xinhui" , Rodrigo Siqueira , Roman Li , amd-gfx@lists.freedesktop.org, Nicholas Kazlauskas , Bhawanpreet Lakha , David Airlie , Fangzhi Zuo , Aurabindo Pillai , hersen wu , Hamza Mahfooz , Wayne Lin , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Currently we aren't considering the mode_changed property of struct drm_crtc_state, which can mean that we might not update the display when it is otherwise necessary, and cause a crash. So, consider mode_changed in is_content_protection_different(). Signed-off-by: Hamza Mahfooz --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 8d8788792f7d..78bd1a5099f1 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -7222,9 +7222,11 @@ is_scaling_state_different(const struct dm_connector_state *dm_state, } #ifdef CONFIG_DRM_AMD_DC_HDCP -static bool is_content_protection_different(struct drm_connector_state *state, +static bool is_content_protection_different(const struct drm_crtc_state *crtc_state, + struct drm_connector_state *state, const struct drm_connector_state *old_state, - const struct drm_connector *connector, struct hdcp_workqueue *hdcp_w) + const struct drm_connector *connector, + struct hdcp_workqueue *hdcp_w) { struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector); struct dm_connector_state *dm_con_state = to_dm_connector_state(connector->state); @@ -7289,7 +7291,9 @@ static bool is_content_protection_different(struct drm_connector_state *state, * ENABLED -> ENABLED */ if (old_state->content_protection == state->content_protection) - return false; + return state->content_protection >= + DRM_MODE_CONTENT_PROTECTION_DESIRED && + crtc_state && crtc_state->mode_changed; /* * Handles: UNDESIRED -> DESIRED @@ -8171,7 +8175,8 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) continue; } - if (is_content_protection_different(new_con_state, + if (is_content_protection_different(new_crtc_state, + new_con_state, old_con_state, connector, adev->dm.hdcp_workqueue)) {