From patchwork Mon Nov 4 21:11:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zuo, Jerry" X-Patchwork-Id: 11226537 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 D866A16B1 for ; Mon, 4 Nov 2019 21:11:55 +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 BFCD320659 for ; Mon, 4 Nov 2019 21:11:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BFCD320659 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A1E116E880; Mon, 4 Nov 2019 21:11:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM05-DM3-obe.outbound.protection.outlook.com (mail-eopbgr730087.outbound.protection.outlook.com [40.107.73.87]) by gabe.freedesktop.org (Postfix) with ESMTPS id 83E806E880; Mon, 4 Nov 2019 21:11:52 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bkQ5JpBz/oK9K1sZ6/DuBROhTnsuIAxZCTJ1UZPRZXxGRvN9vocHdqG4WjwdeU7kW8bq2zrN+WtxftG6dFG/PFr/2Hpecg/CTTJnV7vVZzE4ZYRbkmCZerD+xj2NKC3qjc/xUhf1Y0Q4FT+p9NhseLPxpEmGOmVT9RZTXOolFEKO5NpC62qv5FB7e9pnWzl0PyngSzgk3uKJjr+LEBcJ+WEhWQJ1lH6wY9bvKZ0vRJG60WcDsFYbW6RpDas6M+Xk6hLr7ZM/zJLWogXg3jQnKhyHludvezsCHbwnAtpSEFwR5yFK4wztRHQj8sGswWmylHP4IW5VI8Yp2EM4y1lGVA== 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=WsCmJ8btibpeYfaBd/ErnzyTbs8PDsP56TK1DMWcySA=; b=cLlmx55a8r+vvEf3sgJwTis2VEgFePk2RnQ56b9zcMkAdg50kLnK6U/zUCzilKnY3lUxvB02AKgOi0oTfZCqw2FRF/i8nJPhfnwTYS9ZVgfAOMi/kO04/tD5etgpqnCenWKDHJ8uCYoLiz5kcYDlPgSS7yeORbPXb98H6J705qf/QZdhWsOTB71y/sK0lF1DpYPqItpDYKyNVc0zUKNtko+T/jWebiMS9LEaJnc7B74VwuskxE6c/0LCE7SJ9f4VBnXzw/uj+NLJ/Uf0Yy+XoGwd/XOmoL8Px2ocQcxNg4cKbict26jicKpNnhMQmSbo2gvVWWC9G5g81EOFiR7AHA== 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 DM5PR12CA0064.namprd12.prod.outlook.com (2603:10b6:3:103::26) by CY4PR12MB1430.namprd12.prod.outlook.com (2603:10b6:903:3e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.24; Mon, 4 Nov 2019 21:11:50 +0000 Received: from DM3NAM03FT065.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::205) by DM5PR12CA0064.outlook.office365.com (2603:10b6:3:103::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.24 via Frontend Transport; Mon, 4 Nov 2019 21:11:50 +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 DM3NAM03FT065.mail.protection.outlook.com (10.152.82.254) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.2387.20 via Frontend Transport; Mon, 4 Nov 2019 21:11:50 +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, 4 Nov 2019 15:11:49 -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, 4 Nov 2019 15:11:49 -0600 From: "Jerry (Fangzhi) Zuo" To: , Subject: [PATCH v3] drm: Add support for DP 1.4 Compliance edid corruption test 4.2.2.6 Date: Mon, 4 Nov 2019 16:11:45 -0500 Message-ID: <20191104211145.30553-1-Jerry.Zuo@amd.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20191101193839.25582-1-Jerry.Zuo@amd.com> References: <20191101193839.25582-1-Jerry.Zuo@amd.com> 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)(396003)(346002)(39860400002)(136003)(376002)(428003)(189003)(199004)(478600001)(76176011)(51416003)(8936002)(356004)(6666004)(70206006)(476003)(70586007)(2616005)(50466002)(86362001)(2906002)(14444005)(7696005)(305945005)(5660300002)(36756003)(336012)(26005)(186003)(54906003)(110136005)(16586007)(316002)(426003)(126002)(53416004)(446003)(4326008)(81166006)(81156014)(48376002)(486006)(47776003)(50226002)(11346002)(8676002)(1076003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1430; 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: 9161d580-bd46-4c9e-bc50-08d7616b9c2c X-MS-TrafficTypeDiagnostic: CY4PR12MB1430: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2657; X-Forefront-PRVS: 0211965D06 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oIL90bNie7blsDp0stXqLXfCy0c7oOesNPvX0QTwbYPyWBs9XEZ/+5Yyp++Q+fmnB6jIPCIMs0W1olQuFigIyiwz1GH5/7/erJhHoY9b5DRXbDQPl/SAwRUd2fu6yHWlHlHslF5kLSF2AUUeoI7piZMbe9lD9oDWinKbTDD7mBEFedD21nrz9mgJIhFxURomlJuuCd2PxtHdQyhDL9ddKlT+mCb4zJx6iGQQSOwA7arklvDnpnlIx67w+ck3CVsfhR2QwlFlBY+bW4XdCmWLsvX7Q5D8HJhj1qn2Mrds7DpwIFDjpOtZ+yPPRbk/8T/itiLKUuwzJmLJPFRFgHoMfgAQc09TpUsA1mLwe7F7RUorIAO2eSevnZAQu8ps2GSBJJvY80TQl7Ovirb8gNKITtIC4Z9da3AGD0buDqnDr8MT/Hu6l3C6/ifR7rPGG5tU X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2019 21:11:50.4946 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9161d580-bd46-4c9e-bc50-08d7616b9c2c 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: CY4PR12MB1430 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=WsCmJ8btibpeYfaBd/ErnzyTbs8PDsP56TK1DMWcySA=; b=iF6GOby74uE/UBduW6fGqpeXmamqZYO4QqupAuK30b5zwRHMsIy66GSamhRws4tIgkVof+pr0f9m+6FPyjEMeaiFdkVAKeoQKSbHsm81zaQH+cuTsC/AXYGV2ZFLIvJk/uJekqDPOEbgYNyDdFDJJxlf5mNGAZ+vY4+ZWvuLBF0= 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; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: manasi.d.navare@intel.com, "Jerry \(Fangzhi\) Zuo" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" DP 1.4 edid corruption test requires source DUT to write calculated CRC, not the corrupted CRC from reference sink. Return the calculated CRC back, and initiate the required sequence. -v2: Have separate routine for returning real CRC -v3: Rewrite checksum computation routine to avoid duplicated code. Rename to avoid confusion Signed-off-by: Jerry (Fangzhi) Zuo --- drivers/gpu/drm/drm_dp_helper.c | 36 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_edid.c | 18 +++++++++++++++--- include/drm/drm_connector.h | 7 +++++++ include/drm/drm_dp_helper.h | 3 +++ 4 files changed, 61 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c index ffc68d305afe..75bdffd840c6 100644 --- a/drivers/gpu/drm/drm_dp_helper.c +++ b/drivers/gpu/drm/drm_dp_helper.c @@ -336,6 +336,42 @@ 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 + * @bad_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; + u8 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_link_probe() - probe a DisplayPort link for capabilities * @aux: DisplayPort AUX channel diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 82a4ceed3fcf..ff64e5f1feb6 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1348,10 +1348,19 @@ static int drm_edid_block_checksum(const u8 *raw_edid) { int i; u8 csum = 0; - for (i = 0; i < EDID_LENGTH; i++) + + for (i = 0; i < EDID_LENGTH - 1; i++) csum += raw_edid[i]; - return csum; + return (0x100 - csum); +} + +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) @@ -1409,7 +1418,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; @@ -1572,6 +1581,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 + edid[0x7e] * EDID_LENGTH); } /* Get override or firmware EDID */ diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 681cb590f952..eb0d8c7b35fd 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1345,6 +1345,13 @@ struct drm_connector { * rev1.1 4.2.2.6 */ bool edid_corrupt; + /** + * @real_edid_checksum: real edid checksum value for corrupted edid block. + * Required in Displayport 1.4 compliance testing + * rev1.1 4.2.2.6 + */ + uint8_t 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 5a795075d5da..84709d7810f8 100644 --- a/include/drm/drm_dp_helper.h +++ b/include/drm/drm_dp_helper.h @@ -1383,6 +1383,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); + /* * DisplayPort link */