Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp478627ybl; Tue, 28 Jan 2020 06:35:26 -0800 (PST) X-Google-Smtp-Source: APXvYqxzzX0no+NwbLDiDHSrdMtVdIWGKZ+inyBlBg2f4/OCVIAYR50XBcGV8uetexc/C/YMZKC+ X-Received: by 2002:aca:1913:: with SMTP id l19mr2842396oii.47.1580222125939; Tue, 28 Jan 2020 06:35:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580222125; cv=none; d=google.com; s=arc-20160816; b=oRnBLTMzYpULjxAaN1JRMeE6mvua3k+XO0PD/kIgV+DLrmQ8uZZK24ByIiDb4vFytg xZNjpxCk9cGadwpaVuudU41aVrrBMmmVrbFN9TGjQ4kqZDll+rt+pdu08VEDSMTADVO6 bsHOfxgreXTWLWyLttGUPMa/DG90XyB8T3+ext+HmAjvZlPNXYVAoLESX4TlwLzJeC9k uAIvNTu0+e7BqZxeIXiozmBqL0tuiYZ0QMli6Dde9R+Tqnl5PiT3LJN2A36AC7ALjlob B2Wg/lFxNjn4jg6pZOgpZjsHSc0Eu9nsirgXhVfW5kY91YDE/O3EoAC1wazSSEma0bS6 c1Fw== 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=tMeyWfc14DP/LBwDaLtEZu6uZup2oUP+lWmbHRGcSKU=; b=s0zSKH21JQhMtMUZyKs8KGjkEQqOZxV8Jp5zhI83dOPeaH45iLDPhYQAxWbgjGcdQ7 8Qo9RAO12TAHutTKeSX0NmhaLVltGGDM+4eWUCk7FBJuBQOufUr8nQjOQWUaaVYQH1R/ UlkM76/e1UOcI7JxYgdlY4wRVsJRcmlE4RRnzXcNTNK4XJGEXEBb5YNM8Jghkx7+EfwH JIvU6vsB4hbYt1dmYn5Y6PchI10HeOhwK/nZCd+kheCup1TjAsPc3Cggweu9hprj+KCi 23x0Qn34ghBPmM7BKogRSeyyLBj4ctmYNAgjahhv0ROs1chJJzbwhspN7KWRa2s79Mq9 6Oiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b2PHh8CF; 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 e1si7331813otr.8.2020.01.28.06.35.14; Tue, 28 Jan 2020 06:35:25 -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=b2PHh8CF; 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 S1732865AbgA1OZK (ORCPT + 99 others); Tue, 28 Jan 2020 09:25:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:52010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732835AbgA1OZG (ORCPT ); Tue, 28 Jan 2020 09:25:06 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 E5A3E21739; Tue, 28 Jan 2020 14:25:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221505; bh=j3dOkO7BzEnopBMaA6mmgyr9Jea+DWcgOpZMXirfMnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b2PHh8CFp+4gY+CvLDMNlNK5aG0bumMNkwdrh9FYXq46p3yfpMZX879eOb0Q6Sb12 mIOcCqotOqaNr/HXBntctfnFeBFvWTsznklHS1cv6tfTB89KLfrTcvPDfksmB/fZ7C OgmK+4Ioe9lX3Nx4noFvEFzYbZgAca3KLAKxmOm8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Adrian Hunter , Ulf Hansson Subject: [PATCH 4.9 251/271] mmc: sdhci: fix minimum clock rate for v3 controller Date: Tue, 28 Jan 2020 15:06:40 +0100 Message-Id: <20200128135911.255683005@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Michał Mirosław commit 2a187d03352086e300daa2044051db00044cd171 upstream. For SDHCIv3+ with programmable clock mode, minimal clock frequency is still base clock / max(divider). Minimal programmable clock frequency is always greater than minimal divided clock frequency. Without this patch, SDHCI uses out-of-spec initial frequency when multiplier is big enough: mmc1: mmc_rescan_try_freq: trying to init card at 468750 Hz [for 480 MHz source clock divided by 1024] The code in sdhci_calc_clk() already chooses a correct SDCLK clock mode. Fixes: c3ed3877625f ("mmc: sdhci: add support for programmable clock mode") Cc: # 4f6aa3264af4: mmc: tegra: Only advertise UHS modes if IO regulator is present Cc: Signed-off-by: Michał Mirosław Acked-by: Adrian Hunter Link: https://lore.kernel.org/r/ffb489519a446caffe7a0a05c4b9372bd52397bb.1579082031.git.mirq-linux@rere.qmqm.pl Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/sdhci.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -3243,11 +3243,13 @@ int sdhci_setup_host(struct sdhci_host * if (host->ops->get_min_clock) mmc->f_min = host->ops->get_min_clock(host); else if (host->version >= SDHCI_SPEC_300) { - if (host->clk_mul) { - mmc->f_min = (host->max_clk * host->clk_mul) / 1024; + if (host->clk_mul) max_clk = host->max_clk * host->clk_mul; - } else - mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300; + /* + * Divided Clock Mode minimum clock rate is always less than + * Programmable Clock Mode minimum clock rate. + */ + mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300; } else mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200;