From patchwork Sun Nov 16 02:04:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Stefan_Br=C3=BCns?= X-Patchwork-Id: 5312721 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AE7B99F440 for ; Sun, 16 Nov 2014 02:14:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CCD38201FA for ; Sun, 16 Nov 2014 02:14:32 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id AE1A6201DD for ; Sun, 16 Nov 2014 02:14:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 48FD96E1F4; Sat, 15 Nov 2014 18:14:29 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 589 seconds by postgrey-1.34 at gabe; Sat, 15 Nov 2014 18:14:27 PST Received: from mx-out-2.rwth-aachen.de (mx-out-2.rwth-aachen.de [134.130.5.187]) by gabe.freedesktop.org (Postfix) with ESMTP id 3592C6E1F4 for ; Sat, 15 Nov 2014 18:14:27 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.07,394,1413237600"; d="scan'208";a="270755913" Received: from hub2.rwth-ad.de (HELO mail.rwth-aachen.de) ([134.130.26.143]) by mx-2.rz.rwth-aachen.de with ESMTP; 16 Nov 2014 03:04:58 +0100 Received: from appserver.fset.rwth-aachen.de (137.226.172.40) by mail.rwth-aachen.de (134.130.26.143) with Microsoft SMTP Server (TLS) id 14.3.195.1; Sun, 16 Nov 2014 03:04:55 +0100 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= To: Subject: [PATCH 2/2] drm/edid: Tighten checksum conditions for CEA blocks Date: Sun, 16 Nov 2014 03:04:54 +0100 X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1416103494-17019-1-git-send-email-stefan.bruens@rwth-aachen.de> References: <1416103494-17019-1-git-send-email-stefan.bruens@rwth-aachen.de> MIME-Version: 1.0 X-PMWin-Version: 3.1.3.0, Antivirus-Engine: 3.53.0, Antivirus-Data: 5.08 Message-ID: <44ca22d7-d28e-4757-b915-0e45fe864900@HUB2.rwth-ad.de> Cc: stefan.bruens@rwth-aachen.de X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 4a638b4e38234233f5c7e6705662fbc0b58d80c2 disabled the checksumming for CEA blocks. If only the checksum is wrong, reading twice should result in identical data, whereas a bad transfer will most likely corrupt diffent bytes. Signed-off-by: Stefan BrĂ¼ns --- drivers/gpu/drm/drm_edid.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 505960e..9b6b65e 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1200,6 +1200,7 @@ drm_do_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter) { int i, j = 0, valid_extensions = 0; u8 *block, *new; + u8 *saved_block = NULL; bool print_bad_edid = !connector->bad_edid_counter || (drm_debug & DRM_UT_KMS); if ((block = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL) @@ -1234,15 +1235,29 @@ drm_do_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter) block = new; for (j = 1; j <= block[0x7e]; j++) { + u8 *ext_block = block + (valid_extensions + 1) * EDID_LENGTH; + u8 csum, last_csum = 0; for (i = 0; i < 4; i++) { - if (drm_do_probe_ddc_edid(adapter, - block + (valid_extensions + 1) * EDID_LENGTH, - j, EDID_LENGTH)) + if (drm_do_probe_ddc_edid(adapter, ext_block, j, EDID_LENGTH)) goto out; - if (drm_edid_block_valid(block + (valid_extensions + 1) * EDID_LENGTH, j, print_bad_edid)) { + if ((csum = drm_edid_block_checksum(ext_block)) == 0) { valid_extensions++; break; + } else if ((ext_block[0] == CEA_EXT) && (csum == last_csum)) { + /* + * Some switches mangle CEA contents without fixing the checksum. + * Accept CEA blocks when two reads return identical data. + */ + if (!saved_block) + saved_block = kmalloc(EDID_LENGTH, GFP_KERNEL); + if (saved_block && !memcmp(ext_block, saved_block, EDID_LENGTH)) { + valid_extensions++; + break; + } + if (saved_block) + memcpy(saved_block, ext_block, EDID_LENGTH); } + last_csum = csum; } if (i == 4 && print_bad_edid) { @@ -1263,6 +1278,7 @@ drm_do_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter) block = new; } + kfree(saved_block); return block; carp: @@ -1273,6 +1289,7 @@ carp: connector->bad_edid_counter++; out: + kfree(saved_block); kfree(block); return NULL; }