From patchwork Mon Dec 2 19:04:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zuo, Jerry" X-Patchwork-Id: 11269873 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 0ADA4921 for ; Mon, 2 Dec 2019 19:59:46 +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 E6E0020833 for ; Mon, 2 Dec 2019 19:59:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E6E0020833 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 2D7756E2C4; Mon, 2 Dec 2019 19:59:44 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-eopbgr760080.outbound.protection.outlook.com [40.107.76.80]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3DB0C6E128; Mon, 2 Dec 2019 19:05:03 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RpEOwRL4v1TGetrhGxA2i+XFc610mbln/rW/kx9Hjwoo//70BS3L8z1IaVCsqYPxwsepxNbxO6CpQ88bi3/T4esqZRpe/NPab6NxU6BzvH4gfCMpMANnUb60+9ipqejMh5DA8wpl8mFyHVvHqpetIc7tNRq2nU64efgCZOI61MtszX0EvhT1xSrOH6YfB4dA9HOWY+CtUMPhcIJq2JLjJdCDKb76gEoRilto982GbnYz0l6mz4bR67A777ptdFP0Aq8e0oaaJ02qGddN8UNW+poEKRAihlRM697eR8cob7wmH6pcJ4y1jis8b+UniAsMy4/HCkzldK91ESsXrz8WZg== 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=2aWJGRSwQ5vJq2KfMboSu7jgBMW4tOjWyjhXfLglI2M=; b=gxmVSd2fN0QnS1kOvEKDhPRwIpYeSxrKlpch8ufxfMJqEpOjTObtbO50ZltderIeY3eZuxqnwuopn4pyvbPV0rie2JD/c7efCVvW9tJ0IiGIkHrPpb2XvKWOxTEPmlYybhSWZaJebUwsNVRjHjoIwTr4QImzh3jHcUrvKbw+qDg9++eOpORcf28ng0co5p1E8k+2WhtaYrpVu2ajhCTBT7t+G61WWh0cA+oM4oB2xaBesuRnKVkYwWbtVq8mtZv4o0S5w6Xa4TiPxIIoP5jnabHsw4LfoFdWVsGYQSMUXej2bFgfXmTQKo1EAVgG67+ah5GahoNwnf3skcjzHtUU/A== 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 DM3PR12CA0062.namprd12.prod.outlook.com (2603:10b6:0:56::30) by MN2PR12MB3391.namprd12.prod.outlook.com (2603:10b6:208:c3::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2495.17; Mon, 2 Dec 2019 19:05:00 +0000 Received: from BN8NAM11FT045.eop-nam11.prod.protection.outlook.com (2a01:111:f400:7eae::201) by DM3PR12CA0062.outlook.office365.com (2603:10b6:0:56::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2495.20 via Frontend Transport; Mon, 2 Dec 2019 19:05:00 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXMB02.amd.com (165.204.84.17) by BN8NAM11FT045.mail.protection.outlook.com (10.13.177.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.2451.23 via Frontend Transport; Mon, 2 Dec 2019 19:04:59 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 2 Dec 2019 13:04:59 -0600 Received: from SATLEXMB02.amd.com (10.181.40.143) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 2 Dec 2019 13:04:58 -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, 2 Dec 2019 13:04:58 -0600 From: "Jerry (Fangzhi) Zuo" To: , , Date: Mon, 2 Dec 2019 14:04:48 -0500 Message-ID: <20191202190449.2864-2-Jerry.Zuo@amd.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20191202190449.2864-1-Jerry.Zuo@amd.com> References: <20191202190449.2864-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)(376002)(136003)(39860400002)(428003)(189003)(199004)(48376002)(54906003)(1076003)(2616005)(70586007)(478600001)(26005)(426003)(305945005)(50226002)(86362001)(8936002)(81156014)(81166006)(70206006)(36756003)(336012)(8676002)(4326008)(2201001)(16586007)(6666004)(186003)(356004)(5660300002)(11346002)(7696005)(50466002)(2906002)(316002)(446003)(51416003)(110136005)(47776003)(76176011)(53416004)(14444005); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR12MB3391; H:SATLEXMB02.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 62322f1b-aa40-4603-84d2-08d7775a8769 X-MS-TrafficTypeDiagnostic: MN2PR12MB3391: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2657; X-Forefront-PRVS: 0239D46DB6 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QDWFep+QOTkCum2pHCybE94cPjOv7CkctarwfOObFIYFFemffzf4NK9dy86Za+Osc3Xn7si48uCe41Ju8UT4QoIeJLZC4Za++22cIZ4Dldh+nHMCpWpLbyHUsRTN4/H6baq/C0bVqmVhWdK/6GGebIZmyWni2Al7Z7x2pqBj0++8w7yO+pnTfu4vluTHT2bPQVA4I9x3C/S6ICKnlsbth68v90sq7coxvnVJK+dBja/jh+mJg3iCaW/y0cPLAdTK/OEUVPRleHRhz9Ln5TLFZ/O8Ee7l6LgbSsK5H5CKrBjNrg6o0K68DV11txM8XwSpP/OtyoBuFeDbLf0tNEROMIdjvzXhazQzNJ/35XB9oD1+MhKlNRrejOYsSUs8hvh685uBgniDfwMUupcg5nZ/fi+Vxy6BwdCdhzjAZMUO1mN+PYdm66IYCi5eZLbARk1m X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2019 19:04:59.8395 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 62322f1b-aa40-4603-84d2-08d7775a8769 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=[SATLEXMB02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3391 X-Mailman-Approved-At: Mon, 02 Dec 2019 19:59:44 +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=2aWJGRSwQ5vJq2KfMboSu7jgBMW4tOjWyjhXfLglI2M=; b=onKN8LhvgKFqclEufbrAhC0RdNWEjkNDILW1/lDqFtTrzts2oCf5DJR/wy2X3eQlBHA0/ifcWqnCr8U2PxccwJUe5jVGe1rZQJiDIT72qxUDtFM2JQrR3cuL7rf1whpPS0zqod8IRIcv2Eks9HNcNUdY14l9PR2Jr9O2HOGkI70= 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] [RESEND 1/2] drm: Add support for DP 1.4 Compliance edid corruption test 4.2.2.6 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" 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 -v4: Fix a minor typo. Signed-off-by: Jerry (Fangzhi) Zuo Reviewed-by: Harry Wentland --- 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..22a0e966ea9f 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 + * @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; + 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 */