Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp806999pxb; Tue, 3 Nov 2020 13:04:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJw5o7IWcC5b6aEFnwbLLPeCPCSEZMdO90z1e60xQ3qT3gxOkbq+3sSkMVyFYnuC9aHlEP9I X-Received: by 2002:a50:a6d0:: with SMTP id f16mr22938091edc.135.1604437488529; Tue, 03 Nov 2020 13:04:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604437488; cv=none; d=google.com; s=arc-20160816; b=HyIQAkOugyy1TGq/e2ERMVjrKH3n0V4SI/5tqv8gBg0IqRgrMD7pqxfC5z3VLfERki AyRNFkRdsi+reh00No9DBE8hj+4Mojev/Rgd5H9sYEUlY7PQaY2Ci1eYpcVImBvd3BJa EPwv1G8L8Z7x9rmpwpQzU97nphGFwaYQRmO+k2XtBwyN+q/I1xXET4Vwa0c1dqXvAdPp 6l92pDb288C57vsMFoPu+EvJyOe+OgVVsuXilzHuKLc5wFmQxdHmMNFHz2P2LfE5MAZd gllLk4UrI2F0oqD1kuyqyA3+dm+/piWmv/DNRKQ/mKcZZp3kfeR2vraVqKb9bQXBbDKs h2Ow== 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=AaCIdNisWT+bT8jN2oJCv8ypY1pecvEBYKjszK3AeNc=; b=O+PVAQ7S6cyeGopTnqiIrSAV5BaIk0OBlGIjkPohPVQIHm7T3bUgrTaFznQkJkLHrS TzaCOem2VSzKrYZkVNP+fXY0v5KfCGIMW7PLSwqNG04WIK5vZBq8q04PY82vMHljqdUX HJZCfvnU7By+Cti3mGGsJcZjJydWfSV9r7kjmmayuiD48j5ZYzsHqermTgroNGofX+/7 vutfEbz5CHWefRdY6m6TR6tjewJBOGbaQs+k/LkZm83XKLIfEqObAeRPrH2Em0VULZQQ kImcrUDlfw3caNTXMQ4K8FD6TjYRWo2oBrbZ3eotHZGiuqh2qaI8cnmqWk9lKGI4ov4+ 5+pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zB7nMNh6; 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 e15si16750ejr.176.2020.11.03.13.04.25; Tue, 03 Nov 2020 13:04:48 -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=zB7nMNh6; 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 S2387423AbgKCVBH (ORCPT + 99 others); Tue, 3 Nov 2020 16:01:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:37260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733038AbgKCVBC (ORCPT ); Tue, 3 Nov 2020 16:01:02 -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 2A9A722226; Tue, 3 Nov 2020 21:01:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437261; bh=HhNDJzeC3EK4hMXYyYjZ2WxRqOgNM2/3kDgCDmDW1oI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zB7nMNh6UoncVa6XlcFhy3JSvcslctFBpxFwT8KdMziDJ+WLga+vQDd/3fdAhHsmQ /VCgbMAenkcmrDaiCSjbOD9AOpDW6KEMUBS0Ik1ZB3HPi0LEYCLMlj34FrOWzinQYK o1h4WHvyUZW6jKtwSJHyZYGW0gMoaMyxzPQG+Vmc= 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.4 197/214] mmc: sdhci-of-esdhc: set timeout to max before tuning Date: Tue, 3 Nov 2020 21:37:25 +0100 Message-Id: <20201103203309.110202991@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@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 @@ -1004,6 +1004,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 {