Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2014983imu; Fri, 14 Dec 2018 04:32:17 -0800 (PST) X-Google-Smtp-Source: AFSGD/UlzRas/5Z+V+ghE2c3WsS8qx+lkNh714GGnRScLvHwSsuwCnnEPg8vBoRoL+S28INuRo6M X-Received: by 2002:a63:4b60:: with SMTP id k32mr2551247pgl.186.1544790737926; Fri, 14 Dec 2018 04:32:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544790737; cv=none; d=google.com; s=arc-20160816; b=OfyDPffNlXU88POOAiDEXWYB/oDlez4TXY8AMRdMDCkGjXK4pfrqdu8cZbDijPlpTH S9XdZXkTKETlmEmB4Uk93H8uK2T2v2qIJQJnCN11xUt2CfDLzNJAF69KGgY2kleNrJE+ HDmi35D+y2ZGgXKsqNvVCFOigWe2IKkZf/74hB8drN6Vsx//xhTVvnRiDIBarF7dTI0N 4tQotiYanwOtf0uiGIoM1OIn4uBqFvtLvNGGCG5M/3i1/G+scKG/FlEChXiMns6BIrZy /RyKIMEGlB4KTLsRuDteVKL3Ot6Axkx+UPB8mP97XPiNDE2Z0OEiOwBfReAx18EeYDM0 TW4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tj7ScJHGXrlZawg4DJRg/9WPAlsEk8oXmQFLxqTvTvM=; b=Z51CxBN/WM7jkjHh1Xl0+L6/Tpm27S58KDjfFjP3NS6BQSSJI5MJ3khUNO0dLfq2YA M3eVoBsUmBPQQ1BPBHIey739W2RkoYxCDkPW9rVxkq86leyeOX0akgFj993sIR8Hm7uN EQFt3GSgUn/5i3cTKNfBiy/9/V0XjrFIr+GJijbmSAKQB5L1p96JphzjH4wCtxMiAQEI o2cJyZIMHtwqNvLmUuRsRKvko2VZ81fcx+50jFkIHK77Qs2cBSfl6BJTn0bSgMn4Z0G7 cQn/a7FTkwCOibwtsewc3Hr621CZFyTmQKxBLTzxBuuqMTQRBy1LtIJ3M0jVMzMbS40w AOAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dlTMNToL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l66si4209260pfi.5.2018.12.14.04.32.03; Fri, 14 Dec 2018 04:32:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dlTMNToL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731693AbeLNM36 (ORCPT + 99 others); Fri, 14 Dec 2018 07:29:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:56006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731265AbeLNMKO (ORCPT ); Fri, 14 Dec 2018 07:10:14 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D0D37214F0; Fri, 14 Dec 2018 12:10:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789413; bh=hcPpCIuFU330LtVBapT5+mdXPWJ5xVkg1VXH698LSxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dlTMNToLqeAParlITB7s9FVqPzTe9WuU3XTdx2vEICb5TZeywdq2CWAni+ExC/rIz LXZ7G48us109iXk0az6WgB/fZluRBxV0LAWt7mFXDr/Z1LgUGEqTEGeoQij6fbkjjA r7P6Egh08T5kLkzbZ1mgYTQ5TeOAeC5H83LC/gQk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Y.C. Chen" , Dave Airlie , Sasha Levin Subject: [PATCH 4.14 65/89] drm/ast: fixed reading monitor EDID not stable issue Date: Fri, 14 Dec 2018 13:00:18 +0100 Message-Id: <20181214115732.875470586@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115729.658859279@linuxfoundation.org> References: <20181214115729.658859279@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 300625620314194d9e6d4f6dda71f2dc9cf62d9f ] v1: over-sample data to increase the stability with some specific monitors v2: refine to avoid infinite loop v3: remove un-necessary "volatile" declaration [airlied: fix two checkpatch warnings] Signed-off-by: Y.C. Chen Signed-off-by: Dave Airlie Link: https://patchwork.freedesktop.org/patch/msgid/1542858988-1127-1-git-send-email-yc_chen@aspeedtech.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/ast/ast_mode.c | 36 ++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c index fae1176b2472..343867b182dd 100644 --- a/drivers/gpu/drm/ast/ast_mode.c +++ b/drivers/gpu/drm/ast/ast_mode.c @@ -973,9 +973,21 @@ static int get_clock(void *i2c_priv) { struct ast_i2c_chan *i2c = i2c_priv; struct ast_private *ast = i2c->dev->dev_private; - uint32_t val; + uint32_t val, val2, count, pass; + + count = 0; + pass = 0; + val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01; + do { + val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01; + if (val == val2) { + pass++; + } else { + pass = 0; + val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01; + } + } while ((pass < 5) && (count++ < 0x10000)); - val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4; return val & 1 ? 1 : 0; } @@ -983,9 +995,21 @@ static int get_data(void *i2c_priv) { struct ast_i2c_chan *i2c = i2c_priv; struct ast_private *ast = i2c->dev->dev_private; - uint32_t val; + uint32_t val, val2, count, pass; + + count = 0; + pass = 0; + val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01; + do { + val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01; + if (val == val2) { + pass++; + } else { + pass = 0; + val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01; + } + } while ((pass < 5) && (count++ < 0x10000)); - val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5; return val & 1 ? 1 : 0; } @@ -998,7 +1022,7 @@ static void set_clock(void *i2c_priv, int clock) for (i = 0; i < 0x10000; i++) { ujcrb7 = ((clock & 0x01) ? 0 : 1); - ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfe, ujcrb7); + ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf4, ujcrb7); jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x01); if (ujcrb7 == jtemp) break; @@ -1014,7 +1038,7 @@ static void set_data(void *i2c_priv, int data) for (i = 0; i < 0x10000; i++) { ujcrb7 = ((data & 0x01) ? 0 : 1) << 2; - ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfb, ujcrb7); + ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf1, ujcrb7); jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x04); if (ujcrb7 == jtemp) break; -- 2.19.1