Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2726851imm; Mon, 16 Jul 2018 13:04:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcghfDXw3jFyO3pSj/aXaEAW29CuTwq4OyxdvFV52E8106/8fpRhrhiKoFxk/Oy9pJ8iZPA X-Received: by 2002:a63:5d58:: with SMTP id o24-v6mr16952613pgm.349.1531771444827; Mon, 16 Jul 2018 13:04:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531771444; cv=none; d=google.com; s=arc-20160816; b=kZNXUTg2YpH4CP2/cdZXA8ymkefUes/UMEuIAAWOS6D1umnJHkbSpvAnhOz+pGrv5g VoRahX5zl8LtTt5yPueeyg7JQKD7q75tSuMeZyXJoNks11ZKL1iyB+ppt0S9Vw1DQ1DT NKtkphOu5KKTAOVVej8zslkWWILBRrUdIBMDs9zhijVEjHLpPKCOOJksUGusag7FwaIT D7KdprfetnPgVLz+0pJsk++HELlZG/4CvY35PH8w+5V+6YymxvfjGUcI2/b2BZV8MowU HR/ajRAv6E4h/iTkQhARqsE75dENKvYgI71SYqlbSGbN6vdTfdPHgDLeVU0HL48OORCi xrpQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=LtXAKXNjJ9eMHZIIuc5vyqcfzFhHr3XdoMXQ3MUqZao=; b=EcGxAa392TNGQKSR8yu7m4biut0cpvEJBPJbitYFe1waQnfZhqIE4fWbWo2gxBqKyc 9rAB5zjZL1pWX3skgfJDbAKJockPpqv/LUsyW+WNAZyEOBY/dHY9HPYdtDAe1CDmnH46 P7fuCrSwKIehTigezw+qoJKfZRBFpNTtGk6gjgae0qlXDRTSafpLNF6B94es64B6KpxT CrFNlalaQJoI7Fg3XluRQnUCFUrvTI1p8HDjfGRfbhiiKBsoIQ9I9XaWykJsulpirSo2 wGtt+KowD85pSovJyR32QyxWEWCgujMQACEZ6VI5sPNz8jTDgmk1aKz82PHmuCbkuvS3 R4JA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q2-v6si30444096plh.136.2018.07.16.13.03.49; Mon, 16 Jul 2018 13:04:04 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729350AbeGPUcN (ORCPT + 99 others); Mon, 16 Jul 2018 16:32:13 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:2551 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728116AbeGPUcM (ORCPT ); Mon, 16 Jul 2018 16:32:12 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1, AES128-SHA) id ; Mon, 16 Jul 2018 13:03:10 -0700 Received: from HQMAIL101.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Mon, 16 Jul 2018 13:03:13 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Mon, 16 Jul 2018 13:03:13 -0700 Received: from [10.26.11.196] (10.124.1.5) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Mon, 16 Jul 2018 20:03:11 +0000 Subject: Re: [PATCH] mmc: tegra: Force correct divider calculation on DDR50/52 To: Aapo Vienamo , Adrian Hunter , Ulf Hansson , Thierry Reding , Marcel Ziswiler , Stefan Agner CC: , , References: <1531751669-26584-1-git-send-email-avienamo@nvidia.com> From: Jon Hunter Message-ID: <16caa6d0-4368-8931-a77c-23fb76bee200@nvidia.com> Date: Mon, 16 Jul 2018 21:03:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <1531751669-26584-1-git-send-email-avienamo@nvidia.com> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL101.nvidia.com (172.20.187.10) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16/07/18 15:34, Aapo Vienamo wrote: > Tegra SDHCI controllers require the SDHCI clock divider to be configured > to divide the clock by two in DDR50/52 modes. Incorrectly configured > clock divider results in corrupted data. > > Prevent the possibility of incorrectly calculating the divider value due > to clock rate rounding or low parent clock frequency by not assigning > host->max_clk to clk_get_rate() on tegra_sdhci_set_clock(). > > See the comments for further details. > > Fixes: a8e326a ("mmc: tegra: implement module external clock change") > Signed-off-by: Aapo Vienamo > --- > drivers/mmc/host/sdhci-tegra.c | 17 ++++++++++++++++- > 1 file changed, 16 insertions(+), 1 deletion(-) > > diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c > index ddf00166..908b23e 100644 > --- a/drivers/mmc/host/sdhci-tegra.c > +++ b/drivers/mmc/host/sdhci-tegra.c > @@ -210,9 +210,24 @@ static void tegra_sdhci_set_clock(struct sdhci_host *host, unsigned int clock) > if (!clock) > return sdhci_set_clock(host, clock); > > + /* > + * In DDR50/52 modes the Tegra SDHCI controllers require the SDHCI > + * divider to be configured to divided the host clock by two. The SDHC > + * clock divider is calculated as part of sdhci_set_clock() by > + * sdhci_calc_clk(). The divider is calculated from host->max_clk and > + * the requested clock rate. > + * > + * By setting the host->max_clk to clock * 2 the divider calculation > + * will always result in the correct value for DDR50/52 modes, > + * regardless of clock rate rounding, which may happen if the value > + * from clk_get_rate() is used. > + */ > host_clk = tegra_host->ddr_signaling ? clock * 2 : clock; > clk_set_rate(pltfm_host->clk, host_clk); > - host->max_clk = clk_get_rate(pltfm_host->clk); > + if (tegra_host->ddr_signaling) > + host->max_clk = host_clk; > + else > + host->max_clk = clk_get_rate(pltfm_host->clk); > > sdhci_set_clock(host, clock); > I see what you are saying, but should we be concerned that we are not getting the rate we are requesting in the first place? Maybe it would help if you could provide a specific example showing a case where we request rate X and get Y, and then this leads to a bad rate Z later. Cheers Jon -- nvpublic