Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1998985imu; Fri, 14 Dec 2018 04:16:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vm1714fWfPRSnXQamivr2K7c1Ddgat0Ikq+/2vrIUKYq47ME8jNR/WzlpERL8vLFMYWYpu X-Received: by 2002:a17:902:a70b:: with SMTP id w11mr2673520plq.84.1544789815109; Fri, 14 Dec 2018 04:16:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544789815; cv=none; d=google.com; s=arc-20160816; b=xo8tnRDWVClaSq9vavc323pvsk/0XbSzvJWYKP1hWCfwVl/mGQ47SiXbFKUWrHqCF5 z9PTATC07IY2QE4TRZketFscYTCv2rJFmr5uOUUuZupNIdbpmsxRXc7LVl0bPd60SvQk bc+8EiwADyQOBh+HjoqWaq7RSIBLXzk4DtAWTfT2x7xV+PkIpOxzV2/3ZX/lQyHYZneF nEl1RkZuwz6JwuEEDn820/n5e3fhEZU9SZpJDEJ05uNvrTCalY/cmr28JPFV2YEfVOYv k3qKMs44f/LDSSDNATnGTbSlA+f1T3E8S2Pt+LDM9gCz4pZUe+aCLYJmxwOek0rgME0o DMsQ== 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=Cji8ms35hJ/8VwYNdii0EIZZPhn9KZ/8oF53fN0nwcU=; b=xSWoPdYbW+S3p7vAbFzRv+IvlYAWbmdjDoUf4S+DWCzCukNQRWYwow1pDDoQ88BSG4 xLkGsrZ5qdq7o2jAX68OTA4O3NMuPbc63cbv/SaWXVk5KHQDVEeNhGslfB1UBOrc2SD5 1e0u2gdoYXvJMFbHg0L/HNtZcapwb7zJbIz0gf0+hUd5QED8NhMa9vC5SfTtbts5sxMc bdmCqKnXdMGn2sfFKK4SfovFo8Bg5PJM0L7h9FRG5a1/gQCmyH/GaH+C4PnEQIM499vl oaQoKtiOoC96VToTo918g2GvG8CiIpYTu9uOBwQB8jzEEMYc3Itmynoek9X28mNnaPN3 qsQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BuXKMTVA; 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 d65si4119341pfc.201.2018.12.14.04.16.37; Fri, 14 Dec 2018 04:16:55 -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=BuXKMTVA; 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 S1732358AbeLNMOb (ORCPT + 99 others); Fri, 14 Dec 2018 07:14:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:34164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732335AbeLNMOa (ORCPT ); Fri, 14 Dec 2018 07:14:30 -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 BB12D214DE; Fri, 14 Dec 2018 12:14:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789669; bh=mLWHa1eacgUf5MnxIKuj3KaCEEaKAvRbVf/s1/NN5Ms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BuXKMTVAciLdcIgpvLaclQFV25dCt+9JFBb/DrYFrzilBLvX8gnoJ8XUoZlqAlmFo IVbJD4sXl2QKHsT+ens6sTEzaqeWGH2FXhj2g53Xx8U+LcyY3TTL4s8yMuf3ZHtooo 6rClBMrobn3wEdRAchzQJtZXkX+Zzu9B8e2zV3bM= 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.4 30/88] drm/ast: fixed reading monitor EDID not stable issue Date: Fri, 14 Dec 2018 13:00:04 +0100 Message-Id: <20181214115704.539590908@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115702.151309521@linuxfoundation.org> References: <20181214115702.151309521@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.4-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 21085f669e21..b19ba1792607 100644 --- a/drivers/gpu/drm/ast/ast_mode.c +++ b/drivers/gpu/drm/ast/ast_mode.c @@ -968,9 +968,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; } @@ -978,9 +990,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; } @@ -993,7 +1017,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; @@ -1009,7 +1033,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