From patchwork Wed Oct 31 17:13:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 1680431 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 6508BDFB80 for ; Wed, 31 Oct 2012 17:13:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756579Ab2JaRNQ (ORCPT ); Wed, 31 Oct 2012 13:13:16 -0400 Received: from mail-qa0-f46.google.com ([209.85.216.46]:35514 "EHLO mail-qa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754341Ab2JaRNQ (ORCPT ); Wed, 31 Oct 2012 13:13:16 -0400 Received: by mail-qa0-f46.google.com with SMTP id c26so3042877qad.19 for ; Wed, 31 Oct 2012 10:13:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=NDGgqe6+8KLBaacqqYlkjp6iDTiv0xSc0UVGEDwmDXA=; b=bY2NLrFSlbrcDkuEbypGwdZALblFMFPTGsBkPzDuqZl+9rFA++vdIJI1IIWIw1GiVX 53UEDPgVnqKANh1pIsr0WbhStyVbfeWRbIMhPYsPZ3a/EMSBx31aKJo3h/Znaq33rVrd mYxbxqaBbg6rkVgx5QiA332beIiHqUd4DaoEY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=NDGgqe6+8KLBaacqqYlkjp6iDTiv0xSc0UVGEDwmDXA=; b=jh2693YZzpE8bu8xaqeds6ZaBMTwYT9Nn/Fxf8+0dzEoF3Tn/LNAmNiJJar+4AaS1W DbBtrJG0/W6rM3LEG6s0V3khFyhbT5qXq1SsH4DTuaPXpMYez0eeYPK9GrHRr2YJxgbs iV4muHifL6y7ajpVXT8AehHnY3V4Bg4aqB4CrofcJk53rzVUxBVJbc7xEnj2iSs13VO+ gxoxC0sz8dieQP5mBXJRJn7XfqMQqZFdIQtCI14nDG3TZzuihE0X4sMx3EdxlBH4ye0G URxKXb4XY3ivnXTJfIy8pGKrOkx/Lu//ebUm1nASZSAAdR3nDCsbDPAakG3474DuodRT KQFQ== Received: by 10.224.200.196 with SMTP id ex4mr24791219qab.46.1351703595405; Wed, 31 Oct 2012 10:13:15 -0700 (PDT) Received: from seanpaul-linux2.cnc.corp.google.com (seanpaul-linux2.cnc.corp.google.com [172.29.92.76]) by mx.google.com with ESMTPS id j3sm1650163qek.7.2012.10.31.10.13.14 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 31 Oct 2012 10:13:14 -0700 (PDT) From: Sean Paul To: jg1.han@samsung.com, linux-fbdev@vger.kernel.org Cc: FlorianSchandinat@gmx.de, Sean Paul Subject: [PATCH] video: exynos_dp: Improve EDID error handling Date: Wed, 31 Oct 2012 13:13:07 -0400 Message-Id: <1351703587-3175-1-git-send-email-seanpaul@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <004d01cd7eb5$50bf7f40$f23e7dc0$%han@samsung.com> References: <004d01cd7eb5$50bf7f40$f23e7dc0$%han@samsung.com> X-Gm-Message-State: ALoCoQkqLIRghDNpIOIht2q9a0KZbYFHUagC9Nyu23Re41/Ln5Yv0sP16Via3OMbyVWOBXRlgeIA Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org EDID error handling has 2 problems: - It doesn't fail as early as it can - The retry counts for i2c and aux transactions are huge This patch fails if the initial i2c transaction fails, and reduces the aux and i2c retry counts down to 3. Signed-off-by: Sean Paul --- drivers/video/exynos/exynos_dp_core.c | 13 ++++++++----- drivers/video/exynos/exynos_dp_reg.c | 9 ++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c index ef9b003..f761ec2 100644 --- a/drivers/video/exynos/exynos_dp_core.c +++ b/drivers/video/exynos/exynos_dp_core.c @@ -90,9 +90,11 @@ static int exynos_dp_read_edid(struct exynos_dp_device *dp) */ /* Read Extension Flag, Number of 128-byte EDID extension blocks */ - exynos_dp_read_byte_from_i2c(dp, I2C_EDID_DEVICE_ADDR, + retval = exynos_dp_read_byte_from_i2c(dp, I2C_EDID_DEVICE_ADDR, EDID_EXTENSION_FLAG, &extend_block); + if (retval) + return retval; if (extend_block > 0) { dev_dbg(dp->dev, "EDID data includes a single extension!\n"); @@ -181,14 +183,15 @@ static int exynos_dp_handle_edid(struct exynos_dp_device *dp) int retval; /* Read DPCD DPCD_ADDR_DPCD_REV~RECEIVE_PORT1_CAP_1 */ - exynos_dp_read_bytes_from_dpcd(dp, - DPCD_ADDR_DPCD_REV, - 12, buf); + retval = exynos_dp_read_bytes_from_dpcd(dp, DPCD_ADDR_DPCD_REV, 12, + buf); + if (retval) + return retval; /* Read EDID */ for (i = 0; i < 3; i++) { retval = exynos_dp_read_edid(dp); - if (retval == 0) + if (!retval) break; } diff --git a/drivers/video/exynos/exynos_dp_reg.c b/drivers/video/exynos/exynos_dp_reg.c index 3f5ca8a..9a939aa 100644 --- a/drivers/video/exynos/exynos_dp_reg.c +++ b/drivers/video/exynos/exynos_dp_reg.c @@ -552,7 +552,7 @@ int exynos_dp_write_bytes_to_dpcd(struct exynos_dp_device *dp, else cur_data_count = count - start_offset; - for (i = 0; i < 10; i++) { + for (i = 0; i < 3; i++) { /* Select DPCD device address */ reg = AUX_ADDR_7_0(reg_addr + start_offset); writel(reg, dp->reg_base + EXYNOS_DP_AUX_ADDR_7_0); @@ -617,7 +617,7 @@ int exynos_dp_read_bytes_from_dpcd(struct exynos_dp_device *dp, cur_data_count = count - start_offset; /* AUX CH Request Transaction process */ - for (i = 0; i < 10; i++) { + for (i = 0; i < 3; i++) { /* Select DPCD device address */ reg = AUX_ADDR_7_0(reg_addr + start_offset); writel(reg, dp->reg_base + EXYNOS_DP_AUX_ADDR_7_0); @@ -700,7 +700,7 @@ int exynos_dp_read_byte_from_i2c(struct exynos_dp_device *dp, int i; int retval; - for (i = 0; i < 10; i++) { + for (i = 0; i < 3; i++) { /* Clear AUX CH data buffer */ reg = BUF_CLR; writel(reg, dp->reg_base + EXYNOS_DP_BUFFER_DATA_CTL); @@ -708,7 +708,6 @@ int exynos_dp_read_byte_from_i2c(struct exynos_dp_device *dp, /* Select EDID device */ retval = exynos_dp_select_i2c_device(dp, device_addr, reg_addr); if (retval != 0) { - dev_err(dp->dev, "Select EDID device fail!\n"); continue; } @@ -750,7 +749,7 @@ int exynos_dp_read_bytes_from_i2c(struct exynos_dp_device *dp, int retval = 0; for (i = 0; i < count; i += 16) { - for (j = 0; j < 100; j++) { + for (j = 0; j < 3; j++) { /* Clear AUX CH data buffer */ reg = BUF_CLR; writel(reg, dp->reg_base + EXYNOS_DP_BUFFER_DATA_CTL);