Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4066990imm; Mon, 30 Jul 2018 08:07:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe3iGDCwYL6YVbcfb7LmhL9D7K4N+GdVeQipPLiThhMApDBTxeBQqwPjdQScmidbUlKti5g X-Received: by 2002:a65:60cd:: with SMTP id r13-v6mr16819330pgv.232.1532963251448; Mon, 30 Jul 2018 08:07:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532963251; cv=none; d=google.com; s=arc-20160816; b=NqvLFptGt2DRE8p4ZeMALc0gE/1YTWqHhbOR80QmEaAW9OTGcOTVdi7tC9L9PituD4 Y6DSU3PXFpaW+5CIw7UAyl9ltPgicamx3oOSiDI/oys2qUJTVSe0wUoTkp+9ZPNgvjIj a+WDD4+jSb8LvPM8/ctpWvIRHIlLBHO8Sci5Ay9SFWIzfcfo6Wjrf0zxv1rUdv2kEeqW 4Nf2wz7unVJB9CUaay4UYaabU8Sr0FHmNh2H90U317fMUdLOy2WYAyk+6cLXXmiiXVQJ 5WmRgW14pew/kJE3XI7vOKwptRa6Ti2kOj92sUUosmAAedurfFROoB8HswqZNmzd2LJT +HSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=HL76Jryv+IQKJBL8H2qCz74spSCaYqrw2l0Y21FmJyU=; b=ufT1AKMqpyMS3uVAEPdpuTEtzihdtd1p3MQSofgUuiWm2qx46LNuz+eZTsWsZniauC c/xtsPnVQngI67dFHw32GHlsQw8h9MMDGraeRVkzFXKNz5nMlMeENcjxgwdZIoX6B38p NLp9P9OmkTxlWTQ1QJB+JBS47FbLwytnfNPOTQDqAByezbSX7NJq5fSEKj/6TAaDgznp 058EerKm6gSF/NgLWr52GDikQ6cnKfYM8yOEWUHMbUSMEiXpKTJ/+niCbVjw5571R/mQ h6tWIOwN363ZeHwQzrBza4i3FfaKiOjnRSOMLTTrM9stdDgKSvLeIoYeARDxbkZ1hNx1 zceQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="BlmjH/xy"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b13-v6si10762373pgh.255.2018.07.30.08.07.17; Mon, 30 Jul 2018 08:07:31 -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; dkim=pass header.i=@linaro.org header.s=google header.b="BlmjH/xy"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726800AbeG3QlY (ORCPT + 99 others); Mon, 30 Jul 2018 12:41:24 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:50398 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726758AbeG3QlY (ORCPT ); Mon, 30 Jul 2018 12:41:24 -0400 Received: by mail-it0-f65.google.com with SMTP id g191-v6so6635789ita.0 for ; Mon, 30 Jul 2018 08:06:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=HL76Jryv+IQKJBL8H2qCz74spSCaYqrw2l0Y21FmJyU=; b=BlmjH/xyNEKgHPVMh3MBUkBTBZSIla+XqBLiIkjAc4dOnJCnfU5FrnI+pfzFIVWqCd xhoOVoTgYEkKBOZTG31l0fJb4mdhxVLGDU9g6lD5eWXsmfpxfspaatEPTAs43+8ZHHjo 6wdhlhlOBODuHoxvN7bKDoWdJZAf5uvLiI/dY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=HL76Jryv+IQKJBL8H2qCz74spSCaYqrw2l0Y21FmJyU=; b=So5Kh/NEuzZa/RTTtfxsvfZOcLzdG1Ri2UCpRJcXdqBOsZ5TpU7FwLLDbKllEMA/hZ YyRO1fC9LIqxTnBQceXlj8tSq2N6Ro3FkWKbTsb0BVByFu8rftyiTLT0yue+9pYRAlaV dLA3FojOPOZuZ0oU1y1yFgnrM3EDb2GYiDKQSfzVqDKrFNTcY60+gX/xrL1ld0MZrjgk JjUnR+tzbWwie8qBrgy3NStvQNvSFR0MoPCtYNsBc0uVhB82K8h2RF8S/fIR8xHRLqrv SV7vEITuortodsB0Z8U5q0gThivdZ1NxfTq+QUQdsElq1qDGcu9Z3B803nTM7BsV7Kg2 plOg== X-Gm-Message-State: AOUpUlH3EJu1cZiAyl4+HID7JPb9onp6g2xxMmZ0mRmxkdGYWwSunGF0 lAeM8YTanTzYs4zqu1SbKe4JNzP2bxmtRtYg6u4LKA== X-Received: by 2002:a24:4524:: with SMTP id y36-v6mr1539652ita.97.1532963159764; Mon, 30 Jul 2018 08:05:59 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:2b03:0:0:0:0:0 with HTTP; Mon, 30 Jul 2018 08:05:59 -0700 (PDT) In-Reply-To: <1531751669-26584-1-git-send-email-avienamo@nvidia.com> References: <1531751669-26584-1-git-send-email-avienamo@nvidia.com> From: Ulf Hansson Date: Mon, 30 Jul 2018 17:05:59 +0200 Message-ID: Subject: Re: [PATCH] mmc: tegra: Force correct divider calculation on DDR50/52 To: Aapo Vienamo Cc: Adrian Hunter , Thierry Reding , Jonathan Hunter , Marcel Ziswiler , Stefan Agner , "linux-mmc@vger.kernel.org" , linux-tegra@vger.kernel.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16 July 2018 at 16: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 Thanks, applied for next! Kind regards Uffe > --- > 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 SDHCI > + * 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); > > -- > 2.7.4 >