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=-15.4 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable 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 1228EC432BE for ; Wed, 4 Aug 2021 10:51:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E9B4A60FC3 for ; Wed, 4 Aug 2021 10:51:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237617AbhHDKwE (ORCPT ); Wed, 4 Aug 2021 06:52:04 -0400 Received: from mga17.intel.com ([192.55.52.151]:29882 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237593AbhHDKwD (ORCPT ); Wed, 4 Aug 2021 06:52:03 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10065"; a="194176956" X-IronPort-AV: E=Sophos;i="5.84,293,1620716400"; d="scan'208";a="194176956" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2021 03:51:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,293,1620716400"; d="scan'208";a="419390433" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.174]) ([10.237.72.174]) by orsmga006.jf.intel.com with ESMTP; 04 Aug 2021 03:51:47 -0700 Subject: Re: [PATCH v4 2/5] mmc: sdhci: always obey programmable clock config in preset value To: =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Kevin Liu , Michal Simek , Suneel Garapati , Ulf Hansson Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Al Cooper References: From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: Date: Wed, 4 Aug 2021 13:52:21 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25/07/21 12:20 pm, Michał Mirosław wrote: > When host controller uses programmable clock presets but doesn't > advertise programmable clock support, we can only guess what frequency > it generates. Let's at least return correct SDHCI_PROG_CLOCK_MODE bit > value in this case. If the preset value doesn't make sense, why use it at all? > > Fixes: 52983382c74f ("mmc: sdhci: enhance preset value function") > Signed-off-by: Michał Mirosław > --- > v4: no changes > v3: added a comment for this case > v2: no changes > --- > drivers/mmc/host/sdhci.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > index c7438dd13e3e..3ab60e7f936b 100644 > --- a/drivers/mmc/host/sdhci.c > +++ b/drivers/mmc/host/sdhci.c > @@ -1859,11 +1859,14 @@ u16 sdhci_calc_clk(struct sdhci_host *host, unsigned int clock, > > pre_val = sdhci_get_preset_value(host); > div = FIELD_GET(SDHCI_PRESET_SDCLK_FREQ_MASK, pre_val); > - if (host->clk_mul && > - (pre_val & SDHCI_PRESET_CLKGEN_SEL)) { > + if (pre_val & SDHCI_PRESET_CLKGEN_SEL) { > clk = SDHCI_PROG_CLOCK_MODE; > real_div = div + 1; > clk_mul = host->clk_mul; > + if (!clk_mul) { > + /* The clock frequency is unknown. Assume undivided base. */ > + clk_mul = 1; > + } > } else { > real_div = max_t(int, 1, div << 1); > } >