Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp801203pxb; Tue, 3 Nov 2020 12:56:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqMS/QjyQoVBma1N8TIU9WbSgQkZgwXkWvmEox5fyjLBkLPtG/aiEZbJR7hnr0E5iAPCGU X-Received: by 2002:a05:6402:1112:: with SMTP id u18mr24180965edv.349.1604436965559; Tue, 03 Nov 2020 12:56:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604436965; cv=none; d=google.com; s=arc-20160816; b=0oYE4vQ8obpsTQrdvj8bWyPSvr7O/hNP/U8RonaljzHRReUBFJuXm+CqqcVYEuLGS0 cYeVrecOP6ZlkfMF6J0azm36xrBbZzZ+MxoHJgCeD4gOwlqRg8cMsfVCVOoKHIvs79Ho zyR0PCNnRcsom4lLsSYja7UvTbKobYIcFfBhDX47HVHrPUSyrvljbDi8aRILMrhvAOtw 0g71humdN1oodW2Qy3y5ScjGwDeMd6FoeARjPa4UabccSPz/G/EjCVJ9bG8apKgASUNr Oc5kqCqk/7o+yUBW9r4wJs6NYnBQWkglllsfeHtPJRd+HpZaMZEpuSND4FCHvRIfmUxO hP2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QT2HcO+gbiFWcOaBBGvWsJk3KGCL30309zRkDGRf1mY=; b=vVeOniLuoY6Zqk5uy7tY/iH3lCSrhoNKly7eSSLgB6/yj2AewBEwBYo5NaFprH+vgr GfgePofnbNsL9uH34SmHqRyDheXOc1PiwMsgA1tLFl0oA8hBS5QO6bVoVfXRfj5go2Bm DHyRcGKbyFlrgQwvATvrhltVL1Cb5gkDdSEKZHz9I2l00LQGGMUwzK853JDz8uFLRnFg pXVOOQL4dqk8g9khdqdlg8l58NEmlMt5YoQAsw1PyaM45WgenbwiP+fCobFNtH5IuudJ nJ9NRZBz/eeq+V8tyNydBMqjdZ32K/71wMCNIRno5mO2qyK9S1EQitLguJyEIq5uzOyk ygAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PptA5sJG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g8si13535736edw.77.2020.11.03.12.55.42; Tue, 03 Nov 2020 12:56:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PptA5sJG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730732AbgKCUwi (ORCPT + 99 others); Tue, 3 Nov 2020 15:52:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:49458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732109AbgKCUwh (ORCPT ); Tue, 3 Nov 2020 15:52:37 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 537E92053B; Tue, 3 Nov 2020 20:52:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436756; bh=TQuy0xxKzG1kB4DX7dwlEHjNfxPdFAfGr6t5XhepVyo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PptA5sJGX7+coA+rNZqkPODNikKETx8aOuUV0J45iqrQhVSEn1lAC2m/rvURfRHzB yRBHW2DJJtTRxwSL47YN4MFydc6wxah/NaKpAmf7Rz7lPipO+8ShbMOqsynkOTxFVb BFX3Zl7vBRu/eyoIBIRc4X7j/b34NmqPlApzaHts= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Walle , Adrian Hunter , Ulf Hansson Subject: [PATCH 5.9 351/391] mmc: sdhci-of-esdhc: set timeout to max before tuning Date: Tue, 3 Nov 2020 21:36:42 +0100 Message-Id: <20201103203410.822522977@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203348.153465465@linuxfoundation.org> References: <20201103203348.153465465@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Walle commit 0add6e9b88d0632a25323aaf4987dbacb0e4ae64 upstream. On rare occations there is the following error: mmc0: Tuning timeout, falling back to fixed sampling clock There are SD cards which takes a significant longer time to reply to the first CMD19 command. The eSDHC takes the data timeout value into account during the tuning period. The SDHCI core doesn't explicitly set this timeout for the tuning procedure. Thus on the slow cards, there might be a spurious "Buffer Read Ready" interrupt, which in turn triggers a wrong sequence of events. In the end this will lead to an unsuccessful tuning procedure and to the above error. To workaround this, set the timeout to the maximum value (which is the best we can do) and the SDHCI core will take care of the proper timeout handling. Fixes: ba49cbd0936e ("mmc: sdhci-of-esdhc: add tuning support") Signed-off-by: Michael Walle Acked-by: Adrian Hunter Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20201022222337.19857-1-michael@walle.cc Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/sdhci-of-esdhc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) --- a/drivers/mmc/host/sdhci-of-esdhc.c +++ b/drivers/mmc/host/sdhci-of-esdhc.c @@ -1069,6 +1069,17 @@ static int esdhc_execute_tuning(struct m esdhc_tuning_block_enable(host, true); + /* + * The eSDHC controller takes the data timeout value into account + * during tuning. If the SD card is too slow sending the response, the + * timer will expire and a "Buffer Read Ready" interrupt without data + * is triggered. This leads to tuning errors. + * + * Just set the timeout to the maximum value because the core will + * already take care of it in sdhci_send_tuning(). + */ + sdhci_writeb(host, 0xe, SDHCI_TIMEOUT_CONTROL); + hs400_tuning = host->flags & SDHCI_HS400_TUNING; do {