Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp2551038pxv; Sat, 24 Jul 2021 21:28:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFJo2qGRMRMmmQ/PinXo6VCE96WcdGpASMrUPEq5b5LMQIkYuj1WanYlnSJ2AOYaLdt6AQ X-Received: by 2002:a5d:83c4:: with SMTP id u4mr9854321ior.21.1627187285201; Sat, 24 Jul 2021 21:28:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627187285; cv=none; d=google.com; s=arc-20160816; b=f5Eor4EW6L0xrUz5GEBNVKIMNlm6FBaelrV4FVUuYphSV84IYfZ/PfJACaA4vfansW zEEhV8jGdzs73yhKi4i9KEdtsi5Lr4WBX7MXF0Du+0WsWtaNgerJ6+pzfWYrEZXjSF6V g/Eti7Lb17mz7JyGBcuPjk86mVybYQaz4xfstqkt4MvjHrSqGYEw9mi8U+xLx7OQ58Q6 jaTKzU0+3gFBQe/u2zUkFhZxjUuC+BPfLT9xp2Q31eKF1rnKZawM7JQ1uAfU0upwN1lS KrNJqi5mhJgw2uWI8vuzjurs52StFae8xxE9J4R/LFPJHOzsJt0o/kuDGTyDGow5e1G6 qBmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:content-transfer-encoding:mime-version :subject:from:references:in-reply-to:message-id:date:dkim-signature; bh=v8VS1lwZI6hu8ZZjO2uCJ60mNQhSYgsucTKPE12M/xw=; b=SjurIbI57vksOcc/Oyu2oB+CqhlDaE3sCU1W2Vda8fInHdyrOF2zMTUGPmLt6Codqx XNd+8ADkPue/vb1YapYysLnR88EzvRHZpUU9STKHDsQ0vXeRWVg4930riUdQWlpXNXWB 2yXLmOsYykcW8AFt14yb31YCstwdwwaDbutrbOWsispvV4Qzs+fv/75rp0MIobvGpgSy wim2KYCLXw2SXmh+PKjSh5yIFaFu9oJmgbIH7790XrFF1cr03ru9Rm16dAQRtAt20Qy+ O07na65kcZoRKWq9BpyYihZ6RjZdrbI4bfLjZBDT5RUL6GoASQKM8rGAL83yxfzzFekv gSBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=Rj4CcHtM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=rere.qmqm.pl Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d20si29098020ioo.61.2021.07.24.21.27.31; Sat, 24 Jul 2021 21:28:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=Rj4CcHtM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=rere.qmqm.pl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230229AbhGYDpH (ORCPT + 99 others); Sat, 24 Jul 2021 23:45:07 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:32428 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbhGYDos (ORCPT ); Sat, 24 Jul 2021 23:44:48 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4GXVMx3YbFzX8; Sun, 25 Jul 2021 06:25:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1627187117; bh=j17GcKmlnE8dNVYM8Ye986ikoYzsb1uGAdqmnn6MswM=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=Rj4CcHtMtjgf2wc4QRN5AIBbNP6v9zKW6AS5crkSmit8XZtmxkWPCciRMUo2OjMdx seKWPXzqj49NnHmLUwQt8GVDyo+F2zj7EIPF8lDeKnT+eW8CcjwK2/KP2LI7lqYoNp w8iwNzJFOc10kTxQDrNJrJJhZeSUb624fqPHrmVYHrrJMoFhaN2nUuNGgI7ML9enmK V+dq2ePDhn7zSddB+ptraTD62PRN1jV/KY9dtpzA9gNnqcXrZRyBgaUlgN40kqc/Uw FXlLgdGloAh/x/Aqy7k1AWkMp0PosZ19SAhxPiqk5b+PUsH8cR2wFMo7v7sswLH5z/ kFIZWcB3qL9HQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.2 at mail Date: Sun, 25 Jul 2021 06:25:16 +0200 Message-Id: <198e2af8eb70212cdd6d85d7fb8ff547e295fa77.1627186831.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH v3 3/5] mmc: sdhci: fix SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: Suneel Garapati , Kevin Liu , Ulf Hansson Cc: Adrian Hunter , Chris Ball , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, Michal Simek Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix returned clock rate for SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN case. This fixes real_div value that was calculated as 1 (meaning no division) instead of 2 with the quirk enabled. Cc: stable@kernel.vger.org Fixes: d1955c3a9a1d ("mmc: sdhci: add quirk SDHCI_QUIRK_CLOCK_DIV_ZERO_BROKEN") Signed-off-by: Michał Mirosław --- v3: updated commit message v2: no changes --- drivers/mmc/host/sdhci.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 3ab60e7f936b..0993f7d0ce8e 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1903,9 +1903,12 @@ u16 sdhci_calc_clk(struct sdhci_host *host, unsigned int clock, if (!host->clk_mul || switch_base_clk) { /* Version 3.00 divisors must be a multiple of 2. */ - if (host->max_clk <= clock) + if (host->max_clk <= clock) { div = 1; - else { + if ((host->quirks2 & SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN) + && host->max_clk <= 25000000) + div = 2; + } else { for (div = 2; div < SDHCI_MAX_DIV_SPEC_300; div += 2) { if ((host->max_clk / div) <= clock) @@ -1914,9 +1917,6 @@ u16 sdhci_calc_clk(struct sdhci_host *host, unsigned int clock, } real_div = div; div >>= 1; - if ((host->quirks2 & SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN) - && !div && host->max_clk <= 25000000) - div = 1; } } else { /* Version 2.00 divisors must be a power of 2. */ -- 2.30.2