From patchwork Tue Mar 31 17:05:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todd Previte X-Patchwork-Id: 6132751 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 91FCBBF4A6 for ; Tue, 31 Mar 2015 17:05:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9EF0F2017D for ; Tue, 31 Mar 2015 17:05:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 903EF2015A for ; Tue, 31 Mar 2015 17:05:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D53DB720C5; Tue, 31 Mar 2015 10:05:45 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pd0-f176.google.com (mail-pd0-f176.google.com [209.85.192.176]) by gabe.freedesktop.org (Postfix) with ESMTP id 280FC720C5 for ; Tue, 31 Mar 2015 10:05:45 -0700 (PDT) Received: by pdbni2 with SMTP id ni2so26650150pdb.1 for ; Tue, 31 Mar 2015 10:05:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TbKQAkVVhCqbNgMaqw5MACQBHhIP6yEthKi1GaUMSTk=; b=j7FiC6RUsP4nwwTV2us0+2PQfJ8LutEAUWn2YoDWrLF4P+tLAAp8K4FzKBXY6Gpc10 PoTrWcCdqXJcHGQlZmosD42e1Q2dgvjwCZq9NOzSz4vEyalv1yQjS2RGLrbjn50mQM2+ Bcg4/xW9v22mVcHMYCjA6xBHqsug3U7a0HbCE+HFzcr/2v2XJz1fie7NWuKDDer4cOdU jfactVdGGY0HU0ZTCCos/FJxmyfVPTiy5Wa2IQYUU3cPaMKDwVF3SXiU67iQNQ3c0Rzj 7vZgWjSztf/YCjbVXVBTBYQ3FzZgyZYUC0/M3zfk7FlaASjWirXv4Rvaum3R6fyChq93 NclQ== X-Received: by 10.66.222.41 with SMTP id qj9mr3108761pac.139.1427821544775; Tue, 31 Mar 2015 10:05:44 -0700 (PDT) Received: from localhost.localdomain (ip70-162-72-208.ph.ph.cox.net. [70.162.72.208]) by mx.google.com with ESMTPSA id qh9sm11520007pbc.24.2015.03.31.10.05.43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 Mar 2015 10:05:44 -0700 (PDT) From: Todd Previte To: tprevite@gmail.com Subject: [PATCH 4/9] drm/i915: Add check for corrupt raw EDID header for Displayport compliance testing Date: Tue, 31 Mar 2015 10:05:24 -0700 Message-Id: <1427821529-27241-5-git-send-email-tprevite@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1427821529-27241-1-git-send-email-tprevite@gmail.com> References: <1427821529-27241-1-git-send-email-tprevite@gmail.com> Cc: dri-devel@lists.freedesktop.org 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, 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 Displayport compliance test 4.2.2.6 requires that a source device be capable of detecting a corrupt EDID. To do this, the test sets up an invalid EDID header to be read by the source device. Unfortunately, the DRM EDID reading and parsing functions are actually too good in this case and prevent the source from reading the corrupted EDID. The result is a failed compliance test. In order to successfully pass the test, the raw EDID header must be checked on each read to see if has been "corrupted". If an invalid raw header is detected, a flag is set that allows the compliance testing code to acknowledge that fact and react appropriately. The flag is automatically cleared on read. This code is designed to expressly work for compliance testing without disrupting normal operations for EDID reading and parsing. Signed-off-by: Todd Previte Cc: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/drm_edid.c | 33 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_dp.c | 17 +++++++++++++++++ drivers/gpu/drm/i915/intel_drv.h | 1 + include/drm/drm_edid.h | 5 +++++ 4 files changed, 56 insertions(+) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 53bc7a6..3d4f473 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -990,6 +990,32 @@ static const u8 edid_header[] = { 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 }; + +/* Flag for EDID corruption testing + * Displayport Link CTS Core 1.2 rev1.1 - 4.2.2.6 + */ +static bool raw_edid_header_corrupted; + +/** + * drm_raw_edid_header_valid - check to see if the raw header is + * corrupt or not. Used solely for Displayport compliance + * testing and required by Link CTS Core 1.2 rev1.1 4.2.2.6. + * @raw_edid: pointer to raw base EDID block + * + * Indicates whether the original EDID header as read from the + * device was corrupt or not. Clears on read. + * + * Return: true if the raw header was corrupt, otherwise false + */ +bool drm_raw_edid_header_corrupt(void) +{ + bool corrupted = raw_edid_header_corrupted; + + raw_edid_header_corrupted = 0; + return corrupted; +} +EXPORT_SYMBOL(drm_raw_edid_header_corrupt); + /** * drm_edid_header_is_valid - sanity check the header of the base EDID block * @raw_edid: pointer to raw base EDID block @@ -1006,6 +1032,13 @@ int drm_edid_header_is_valid(const u8 *raw_edid) if (raw_edid[i] == edid_header[i]) score++; + if (score != 8) { + /* Log and set flag here for EDID corruption testing + * Displayport Link CTS Core 1.2 rev1.1 - 4.2.2.6 + */ + DRM_DEBUG_DRIVER("Raw EDID header invalid\n"); + raw_edid_header_corrupted = 1; + } return score; } EXPORT_SYMBOL(drm_edid_header_is_valid); diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index dc87276..57f8e43 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -3824,6 +3824,9 @@ update_status: &response, 1); if (status <= 0) DRM_DEBUG_KMS("Could not write test response to sink\n"); + + /* Clear flag here, after testing is complete*/ + intel_dp->compliance_edid_invalid = 0; } static int @@ -3896,6 +3899,10 @@ intel_dp_check_link_status(struct intel_dp *intel_dp) { struct drm_device *dev = intel_dp_to_dev(intel_dp); struct intel_encoder *intel_encoder = &dp_to_dig_port(intel_dp)->base; + struct drm_connector *connector = &intel_dp->attached_connector->base; + struct i2c_adapter *adapter = &intel_dp->aux.ddc; + struct edid *edid_read = NULL; + u8 sink_irq_vector; u8 link_status[DP_LINK_STATUS_SIZE]; @@ -3912,6 +3919,16 @@ intel_dp_check_link_status(struct intel_dp *intel_dp) return; } + /* Compliance testing requires an EDID read for all HPD events + * Link CTS Core 1.2 rev 1.1: Test 4.2.2.1 + * Flag set here will be handled in the EDID test function + */ + edid_read = drm_get_edid(connector, adapter); + if (!edid_read || drm_raw_edid_header_corrupt() == 1) { + DRM_DEBUG_DRIVER("EDID invalid, setting flag\n"); + intel_dp->compliance_edid_invalid = 1; + } + /* Try to read the source of the interrupt */ if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11 && intel_dp_get_sink_irq(intel_dp, &sink_irq_vector)) { diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index e7b62be..42e4251 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -651,6 +651,7 @@ struct intel_dp { /* Displayport compliance testing */ unsigned long compliance_test_type; bool compliance_testing_active; + bool compliance_edid_invalid; }; struct intel_digital_port { diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 87d85e8..8a7eb22 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -388,4 +388,9 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, size_t len), void *data); +/* Check for corruption in raw EDID header - Displayport compliance + * Displayport Link CTS Core 1.2 rev1.1 - 4.2.2.6 + */ +bool drm_raw_edid_header_corrupt(void); + #endif /* __DRM_EDID_H__ */