From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4128C33CB1 for ; Wed, 15 Jan 2020 07:17:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C071D2467A for ; Wed, 15 Jan 2020 07:17:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725999AbgAOHRw (ORCPT ); Wed, 15 Jan 2020 02:17:52 -0500 Received: from mga17.intel.com ([192.55.52.151]:62547 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725962AbgAOHRw (ORCPT ); Wed, 15 Jan 2020 02:17:52 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jan 2020 23:17:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,321,1574150400"; d="scan'208";a="225478126" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.167]) ([10.237.72.167]) by orsmga003.jf.intel.com with ESMTP; 14 Jan 2020 23:17:47 -0800 Subject: Re: [PATCH] mmc: sdhci: fix minimum clock rate for v3 controller To: =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-mmc@vger.kernel.org, Ulf Hansson , linux-kernel@vger.kernel.org References: <3f3b2ac4634802af591a20b1b98dc8d0158aec45.1577962196.git.mirq-linux@rere.qmqm.pl> <4264051e-6126-83c3-e49e-3d9050ff35ce@intel.com> <20200114155333.GA29422@qmqm.qmqm.pl> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <6ebf8a7e-faf2-aca8-edc1-e64254043f5f@intel.com> Date: Wed, 15 Jan 2020 09:16:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20200114155333.GA29422@qmqm.qmqm.pl> Content-Type: text/plain; charset=iso-8859-2 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org On 14/01/20 5:53 pm, Michał Mirosław wrote: > On Tue, Jan 14, 2020 at 03:08:08PM +0200, Adrian Hunter wrote: >> On 2/01/20 12:51 pm, Michał Mirosław wrote: >>> 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 maximum divisor in programmable clock mode is 1024. So I do not >> understand what is wrong. Can you explain some more? > > This part of code misses the fact, that you can choose (switch) between > base clock mode and programmable clock mode. The code in > sdhci_calc_clk() already does the choosing part. This is actually > required on high programmable clock base to get conformant frequency for > the card initialization phase. Ok, so please add that explanation to the commit message, and add a comment in the code too. > > Best Regards, > Michał Mirosław > > [...] >>> index 275102c0a1bf..0036ddf85674 100644 >>> --- a/drivers/mmc/host/sdhci.c >>> +++ b/drivers/mmc/host/sdhci.c >>> @@ -3902,11 +3902,9 @@ int sdhci_setup_host(struct sdhci_host *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; >>> + mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300; >>> } else >>> mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200;