From patchwork Mon Sep 29 18:56:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todd Previte X-Patchwork-Id: 4998721 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 81503BEEA6 for ; Mon, 29 Sep 2014 18:56:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9B0AF201FA for ; Mon, 29 Sep 2014 18:56:41 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 41489200F2 for ; Mon, 29 Sep 2014 18:56:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0E2CC727B5; Mon, 29 Sep 2014 11:56:39 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pd0-f181.google.com (mail-pd0-f181.google.com [209.85.192.181]) by gabe.freedesktop.org (Postfix) with ESMTP id 58BF9727B5; Mon, 29 Sep 2014 11:56:38 -0700 (PDT) Received: by mail-pd0-f181.google.com with SMTP id z10so3755771pdj.12 for ; Mon, 29 Sep 2014 11:56:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-type:content-transfer-encoding:thread-index :content-language; bh=DmbMSfL2a6iXxTLoIw8ETikCKwmTp2ZzByGNExwdfiM=; b=MrTGIJoX6t+ci3ODyMMxI4uDH5t4GNm2sMO0QRhfL+8irAndG4a5Bq5jdxE1WQ7fdY bA/lvHsUnB2710N2ZovnYx3kdrjlKS/kjhOHLhBhbE2Noxr8FsvnoXN2DB0sl9+fylUR aKlxohQqCfJSwS3JJy1cK6bwJ1VX5qDCm0pRCQsKtRKgd7WZuvhD0MxSYMCB2eK2AhRS UFMyNFYJUiGeMqvf3A4//Wxmftpqk0ncEY7DcJrj6n8FmORtMxYyYG13nTYs7AfXdcnt aDItWKHF94vdMsBuDPfihmF/Hetr3/n/vsNh4Hn4UxtAss//SOaiLrjglZ3mxktJVWX+ BRLA== X-Received: by 10.70.134.197 with SMTP id pm5mr8163494pdb.20.1412016998011; Mon, 29 Sep 2014 11:56:38 -0700 (PDT) Received: from Panzer (ip72-201-95-47.ph.ph.cox.net. [72.201.95.47]) by mx.google.com with ESMTPSA id l6sm8104703pdr.39.2014.09.29.11.56.35 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Sep 2014 11:56:37 -0700 (PDT) From: "Todd Previte" To: "'Rodrigo Vivi'" , References: <20140916085703.GC31703@phenom.ffwll.local> <1410909492-4875-1-git-send-email-rodrigo.vivi@intel.com> In-Reply-To: <1410909492-4875-1-git-send-email-rodrigo.vivi@intel.com> Subject: RE: [PATCH] drm/i915: Fix Sink CRC Date: Mon, 29 Sep 2014 11:56:36 -0700 Message-ID: <003801cfdc17$19983e00$4cc8ba00$@gmail.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQHehKxS14X2dUtVUTOQJ8mh+EICFAHH1Ougm+zlVwA= Content-Language: en-us Cc: 'Jani Nikula' , 'Daniel Vetter' , dri-devel@lists.freedesktop.org, 'Rodrigo Vivi' X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Hi Rodrigo, This patch looks good. Reviewed-by: Todd Previte -T -----Original Message----- From: Rodrigo Vivi [mailto:rodrigo.vivi@gmail.com] Sent: Tuesday, September 16, 2014 4:18 PM To: intel-gfx@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org; Rodrigo Vivi; Todd Previte; Daniel Vetter; Jani Nikula Subject: [PATCH] drm/i915: Fix Sink CRC In some cases like when PSR just got enabled the panel need more vblank times to calculate CRC. I figured that out with the new PSR test cases facing some cases that I had a green screen but a blank CRC. Even with 2 vblank waits on kernel + 2 vblank waits on test case. So let's give up to 6 vblank wait time. However we now check for TEST_CRC_COUNT that shows when panel finished to calculate CRC and has it ready. v2: Jani pointed out attempts decrements was wrong and should never reach the error condition. And Daniel pointed out that EIO is more appropriated than EGAIN. Also I realized that I have to read test_crc_count after setting test_sink v3: Rebase and adding error message Cc: Todd Previte Cc: Daniel Vetter Cc: Jani Nikula Signed-off-by: Rodrigo Vivi --- drivers/gpu/drm/i915/intel_dp.c | 23 +++++++++++++++++------ include/drm/drm_dp_helper.h | 5 +++-- 2 files changed, 20 insertions(+), 8 deletions(-) -- 1.9.3 diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index e4d0367..d9091dc7 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -3468,21 +3468,32 @@ int intel_dp_sink_crc(struct intel_dp *intel_dp, u8 *crc) struct drm_device *dev = intel_dig_port->base.base.dev; struct intel_crtc *intel_crtc = to_intel_crtc(intel_dig_port->base.base.crtc); - u8 buf[1]; + u8 buf; + int test_crc_count; + int attempts = 6; - if (drm_dp_dpcd_readb(&intel_dp->aux, DP_TEST_SINK_MISC, buf) < 0) + if (drm_dp_dpcd_readb(&intel_dp->aux, DP_TEST_SINK_MISC, &buf) < 0) return -EIO; - if (!(buf[0] & DP_TEST_CRC_SUPPORTED)) + if (!(buf & DP_TEST_CRC_SUPPORTED)) return -ENOTTY; if (drm_dp_dpcd_writeb(&intel_dp->aux, DP_TEST_SINK, DP_TEST_SINK_START) < 0) return -EIO; - /* Wait 2 vblanks to be sure we will have the correct CRC value */ - intel_wait_for_vblank(dev, intel_crtc->pipe); - intel_wait_for_vblank(dev, intel_crtc->pipe); + drm_dp_dpcd_readb(&intel_dp->aux, DP_TEST_SINK_MISC, &buf); + test_crc_count = buf & DP_TEST_COUNT_MASK; + + do { + drm_dp_dpcd_readb(&intel_dp->aux, DP_TEST_SINK_MISC, &buf); + intel_wait_for_vblank(dev, intel_crtc->pipe); + } while (--attempts && (buf & DP_TEST_COUNT_MASK) == test_crc_count); + + if (attempts == 0) { + DRM_ERROR("Panel is unable to calculate CRC after 6 vblanks\n"); + return -EIO; + } if (drm_dp_dpcd_read(&intel_dp->aux, DP_TEST_CRC_R_CR, crc, 6) < 0) return -EIO; diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h index 9305c71..8edeed0 100644 --- a/include/drm/drm_dp_helper.h +++ b/include/drm/drm_dp_helper.h @@ -303,7 +303,8 @@ #define DP_TEST_CRC_B_CB 0x244 #define DP_TEST_SINK_MISC 0x246 -#define DP_TEST_CRC_SUPPORTED (1 << 5) +# define DP_TEST_CRC_SUPPORTED (1 << 5) +# define DP_TEST_COUNT_MASK 0x7 #define DP_TEST_RESPONSE 0x260 # define DP_TEST_ACK (1 << 0) @@ -313,7 +314,7 @@ #define DP_TEST_EDID_CHECKSUM 0x261 #define DP_TEST_SINK 0x270 -#define DP_TEST_SINK_START (1 << 0) +# define DP_TEST_SINK_START (1 << 0) #define DP_PAYLOAD_TABLE_UPDATE_STATUS 0x2c0 /* 1.2 MST */ # define DP_PAYLOAD_TABLE_UPDATED (1 << 0)