From patchwork Mon Dec 9 20:04:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zuo, Jerry" X-Patchwork-Id: 11280375 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C26441575 for ; Mon, 9 Dec 2019 20:29:05 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id AA3102068E for ; Mon, 9 Dec 2019 20:29:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA3102068E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F18536E51C; Mon, 9 Dec 2019 20:29:04 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-eopbgr770054.outbound.protection.outlook.com [40.107.77.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7FD0B6E514; Mon, 9 Dec 2019 20:05:01 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EtuWhoZHh9LuuS5Ha/yo5LjT79sB1fL77g8ctBSPvjv9ftcEM5iYD3U5Xwq49aIdwthFh0o8kNcYrrG0IoihkHHsatqAcK+33exI/iddczZ+jw6ZjVyQh1wYFd+eOMWEw5Tw6Udbye0Pgny4kyXw9co06PwMsQaHqW+jjIj/LwF8CPB0RYLnotc9r24Sjr10CcbzhgBA8q1v/9u0Y++nHCppaLStbmpXz2Td1h/Qa4Q3nWBq+k2mcp5BwtE7BV4XYTqX9EDCa5lvmMGLd2IsqbQ8wlge47rp8uoIhT/f3yEDXBbyNM+uNSQ1pMeYn82xmx6nyMFYMkIiWNDTnmWBDg== 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-SenderADCheck; bh=PE+0FZR7FLhftxpDEQeU2oWJSdhpU0ulmSpbjqkOgxc=; b=Zf90D5uMiuaqwac00Xrr6oIFh7lSo63A4CtaUY3X0UtWBPymydl71oAVBLz6ijH67Hzhaqb/HNppXqi9eAnnw15C5bZ62V/hQkNcofW6Cu85vcDxDKFC4uLWPSdb7BG4IDuGbkEFyFaFfJpbHytjLilIraQh/q4zOgqp5gQj0oYY0ijUMXxTx8XCfX8HvVnpmX28J0Q7rGHX9Is/72G5EgYD3B09L5Mwoj/7Jy4shpNz5tBM8amPbT/CGumTcsqN9atHvY0QNAajakYZlfye4DKmYy1t+OPxuJ3njwgAAuEv0KxZZ9TX99prhiqacFQJ8cUvumDto9zpj8OczjD4lw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=permerror action=none header.from=amd.com; dkim=none (message not signed); arc=none Received: from DM6PR12CA0014.namprd12.prod.outlook.com (2603:10b6:5:1c0::27) by BN6PR12MB1553.namprd12.prod.outlook.com (2603:10b6:405:6::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2516.13; Mon, 9 Dec 2019 20:04:56 +0000 Received: from DM6NAM11FT046.eop-nam11.prod.protection.outlook.com (2a01:111:f400:7eaa::201) by DM6PR12CA0014.outlook.office365.com (2603:10b6:5:1c0::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2516.13 via Frontend Transport; Mon, 9 Dec 2019 20:04:55 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXMB01.amd.com (165.204.84.17) by DM6NAM11FT046.mail.protection.outlook.com (10.13.172.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2451.23 via Frontend Transport; Mon, 9 Dec 2019 20:04:55 +0000 Received: from SATLEXMB02.amd.com (10.181.40.143) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 9 Dec 2019 14:04:54 -0600 Received: from jzuo-linux.amd.com (10.180.168.240) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Mon, 9 Dec 2019 14:04:54 -0600 From: "Jerry (Fangzhi) Zuo" To: , , Date: Mon, 9 Dec 2019 15:04:42 -0500 Message-ID: <20191209200442.2625-1-Jerry.Zuo@amd.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(136003)(396003)(376002)(39860400002)(346002)(428003)(189003)(199004)(70586007)(36756003)(70206006)(1076003)(305945005)(26005)(54906003)(110136005)(186003)(81156014)(2906002)(4326008)(426003)(8936002)(86362001)(478600001)(7696005)(5660300002)(8676002)(2616005)(336012)(356004)(6666004)(81166006)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1553; H:SATLEXMB01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 58aac1ed-c1c8-4831-6f5b-08d77ce30f6c X-MS-TrafficTypeDiagnostic: BN6PR12MB1553: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:261; X-Forefront-PRVS: 02462830BE X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7oR5ntlG8U45pQSmOlwjfhhWw5Aq4q7QkpetDVuTtTsAGM9aZcvaPpwqSxeolEfUj3vxkX7uvToWB9DMbkpECRBC/vrhQg/LD3QuTz99zYTi10QwTPIFOuhLaY2hDpBP2TyWBGSuhqY2FfMFqdwrZpkIQYqHfUU4FykOXhWsME0wa7AUXzA18qgAhgzogY8GUznpmjcs5mT6bx2O9AjuilesZgx389gBUx8/y0LKt6WIjFtBT7Iq1jPyqVwP6dld/CyXOVbOP1Tg2oZYBhKR8fPxR2LkXx1/EKBQGcPrztG51dowtEt46d84PizXWMjSGGEfezpsd+ToIgCwS3VKRGsRWhWajaK1yog4i909/1pt/rRhkK36rjYZbYKhNo27FnWMV6afbJ7qkOx3yNEBOUYbruIMxDE/Qm+UCQjTtawH81uUCI2tTTGbX/P6JkAG X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2019 20:04:55.3558 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 58aac1ed-c1c8-4831-6f5b-08d77ce30f6c 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=[SATLEXMB01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1553 X-Mailman-Approved-At: Mon, 09 Dec 2019 20:29:04 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PE+0FZR7FLhftxpDEQeU2oWJSdhpU0ulmSpbjqkOgxc=; b=uyY/mezLeM7dJM2MdDmrp/Hjssv1gdDxu2S3EymjVpMP0B3lycOckOSwwtkXllOgzdLL3D5wDURsC0sV06JfiHcXDmBqugCi8yH4JM8rD0D+hkPqTTucWmv+UA39zhKeDv0jq2grIU3Gn5WfDmndwj9CUEHYVFopNE/bcg4838Y= X-Mailman-Original-Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=permerror action=none header.from=amd.com; Subject: [Intel-gfx] [PATCH V4] drm: Add support for DP 1.4 Compliance edid corruption test X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: rodrigo.siqueira@amd.com, Jerry.Zuo@amd.com, Alexander.Deucher@amd.com, harry.wentland@amd.com, nicholas.kazlauskas@amd.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Unlike DP 1.2 edid corruption test, DP 1.4 requires to calculate real CRC value of the last edid data block, and write it back. Current edid CRC calculates routine adds the last CRC byte, and check if non-zero. This behavior is not accurate; actually, we need to return the actual CRC value when corruption is detected. This commit changes this issue by returning the calculated CRC, and initiate the required sequence. Change since v4 - Fix for CI.CHECKPATCH Change since v3 - Fix a minor typo. Change since v2 - Rewrite checksum computation routine to avoid duplicated code. - Rename to avoid confusion. Change since v1 - Have separate routine for returning real CRC. Signed-off-by: Jerry (Fangzhi) Zuo --- drivers/gpu/drm/drm_dp_helper.c | 35 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_edid.c | 23 ++++++++++++++++++---- include/drm/drm_connector.h | 6 ++++++ include/drm/drm_dp_helper.h | 3 +++ 4 files changed, 63 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c index 2c7870aef469..85a777ce98ba 100644 --- a/drivers/gpu/drm/drm_dp_helper.c +++ b/drivers/gpu/drm/drm_dp_helper.c @@ -351,6 +351,41 @@ int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux, } EXPORT_SYMBOL(drm_dp_dpcd_read_link_status); +/** + * drm_dp_send_real_edid_checksum() - send back real edid checksum value + * @aux: DisplayPort AUX channel + * @real_edid_checksum: real edid checksum for the last block + * + * Returns true on success + */ +bool drm_dp_send_real_edid_checksum(struct drm_dp_aux *aux, + u8 real_edid_checksum) +{ + u8 link_edid_read = 0, auto_test_req = 0, test_resp = 0; + + drm_dp_dpcd_read(aux, DP_DEVICE_SERVICE_IRQ_VECTOR, &auto_test_req, 1); + auto_test_req &= DP_AUTOMATED_TEST_REQUEST; + + drm_dp_dpcd_read(aux, DP_TEST_REQUEST, &link_edid_read, 1); + link_edid_read &= DP_TEST_LINK_EDID_READ; + + if (!auto_test_req || !link_edid_read) { + DRM_DEBUG_KMS("Source DUT does not support TEST_EDID_READ\n"); + return false; + } + + drm_dp_dpcd_write(aux, DP_DEVICE_SERVICE_IRQ_VECTOR, &auto_test_req, 1); + + /* send back checksum for the last edid extension block data */ + drm_dp_dpcd_write(aux, DP_TEST_EDID_CHECKSUM, &real_edid_checksum, 1); + + test_resp |= DP_TEST_EDID_CHECKSUM_WRITE; + drm_dp_dpcd_write(aux, DP_TEST_RESPONSE, &test_resp, 1); + + return true; +} +EXPORT_SYMBOL(drm_dp_send_real_edid_checksum); + /** * drm_dp_downstream_max_clock() - extract branch device max * pixel rate for legacy VGA diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 5b33b7cfd645..0e35405ecc74 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1450,11 +1450,22 @@ static int validate_displayid(u8 *displayid, int length, int idx); static int drm_edid_block_checksum(const u8 *raw_edid) { int i; - u8 csum = 0; - for (i = 0; i < EDID_LENGTH; i++) + u8 csum = 0, crc = 0; + + for (i = 0; i < EDID_LENGTH - 1; i++) csum += raw_edid[i]; - return csum; + crc = 0x100 - csum; + + return crc; +} + +static bool drm_edid_block_checksum_diff(const u8 *raw_edid, u8 real_checksum) +{ + if (raw_edid[EDID_LENGTH - 1] != real_checksum) + return true; + else + return false; } static bool drm_edid_is_zero(const u8 *in_edid, int length) @@ -1512,7 +1523,7 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid, } csum = drm_edid_block_checksum(raw_edid); - if (csum) { + if (drm_edid_block_checksum_diff(raw_edid, csum)) { if (edid_corrupt) *edid_corrupt = true; @@ -1653,6 +1664,7 @@ static void connector_bad_edid(struct drm_connector *connector, u8 *edid, int num_blocks) { int i; + u8 num_of_ext = edid[0x7e]; if (connector->bad_edid_counter++ && !drm_debug_enabled(DRM_UT_KMS)) return; @@ -1675,6 +1687,9 @@ static void connector_bad_edid(struct drm_connector *connector, prefix, DUMP_PREFIX_NONE, 16, 1, block, EDID_LENGTH, false); } + + /* Calculate real checksum for the last edid extension block data */ + connector->real_edid_checksum = drm_edid_block_checksum(edid + num_of_ext * EDID_LENGTH); } /* Get override or firmware EDID */ diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 5f8c3389d46f..b07d8276a58c 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1349,6 +1349,12 @@ struct drm_connector { * rev1.1 4.2.2.6 */ bool edid_corrupt; + /** + * @real_edid_checksum: real edid checksum for corrupted edid block. + * Required in Displayport 1.4 compliance testing + * rev1.1 4.2.2.6 + */ + u8 real_edid_checksum; /** @debugfs_entry: debugfs directory for this connector */ struct dentry *debugfs_entry; diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h index 8f8f3632e697..8f50b2d5aa1e 100644 --- a/include/drm/drm_dp_helper.h +++ b/include/drm/drm_dp_helper.h @@ -1457,6 +1457,9 @@ static inline ssize_t drm_dp_dpcd_writeb(struct drm_dp_aux *aux, int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux, u8 status[DP_LINK_STATUS_SIZE]); +bool drm_dp_send_real_edid_checksum(struct drm_dp_aux *aux, + u8 real_edid_checksum); + int drm_dp_downstream_max_clock(const u8 dpcd[DP_RECEIVER_CAP_SIZE], const u8 port_cap[4]); int drm_dp_downstream_max_bpc(const u8 dpcd[DP_RECEIVER_CAP_SIZE],