linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@the-dreams.de>
To: Ben Hutchings <ben.hutchings@codethink.co.uk>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	Linux MMC List <linux-mmc@vger.kernel.org>,
	linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH v2 2/9] mmc: tmio, sh_mobile_sdhi: Add support for variable input clock frequency
Date: Fri, 15 Apr 2016 22:28:03 +0200	[thread overview]
Message-ID: <20160415202803.GA3105@katana> (raw)
In-Reply-To: <1460477978.32355.14.camel@codethink.co.uk>

[-- Attachment #1: Type: text/plain, Size: 2072 bytes --]


> >   1. The SDHI/MMC clocks now run much slower than before. Perhaps this is
> >      intentional, and a consequence of finding the best way to drive the SD
> >      card at the target frequency?
> 
> I don't think is generally a problem.  Probably even saves a little
> power.

If you insert an SD card, frequencies should be back to normal. This
happens on Lager at least.

> 
> >   2. On r8a7740, the situation is worse: the HP ("High-speed Peripheral")
> >      clock is also scaled down from 99 MHz to 12.375 MHz.
> >      As the HP clock is the parent of lots of on-chip devices, this may affect
> >      performance for all of them.
> >
> > On r8a73a4, r8a7791, and sh73a0, the SDHI clocks are children of the pll1_div2
> > clocks, which are fixed.
> > On r8a7740, the SDHI and MMC clocks are children of the HP clock,
> > which is also scaled down, affecting all other siblings.
> [...]
> 
> That seems like a bug in the clock driver.  If it doesn't have
> independent dividers for each clock client then it shouldn't allow any
> client to change the frequency.

I tend to agree.

However, I just found out that we don't check the result of
clk_set_rate(). Probably something like this is missing?


diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c
index 5923ce7e0fccb3..e51d7b01d39a3b 100644
--- a/drivers/mmc/host/sh_mobile_sdhi.c
+++ b/drivers/mmc/host/sh_mobile_sdhi.c
@@ -167,7 +167,7 @@ static unsigned int sh_mobile_sdhi_clk_update(struct tmio_mmc_host *host,
 {
 	struct sh_mobile_sdhi *priv = host_to_priv(host);
 	unsigned int freq, best_freq, diff_min, diff;
-	int i;
+	int i, ret;
 
 	diff_min = ~0;
 	best_freq = 0;
@@ -195,9 +195,9 @@ static unsigned int sh_mobile_sdhi_clk_update(struct tmio_mmc_host *host,
 		}
 	}
 
-	clk_set_rate(priv->clk, best_freq);
+	ret = clk_set_rate(priv->clk, best_freq);
 
-	return best_freq;
+	return ret == 0 ? best_freq : clk_get_rate(priv->clk);
 }
 
 static void sh_mobile_sdhi_clk_disable(struct tmio_mmc_host *host)


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-04-15 20:28 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-01 15:44 [PATCH v2 0/9] r8a7790: add UHS-I (SDR50) support to Lager Wolfram Sang
2016-04-01 15:44 ` [PATCH v2 1/9] mmc: tmio, sh_mobile_sdhi: Pass tmio_mmc_host ptr to clk_{enable,disable} ops Wolfram Sang
2016-04-01 15:44 ` [PATCH v2 2/9] mmc: tmio, sh_mobile_sdhi: Add support for variable input clock frequency Wolfram Sang
2016-04-12 12:55   ` Geert Uytterhoeven
2016-04-12 16:19     ` Ben Hutchings
2016-04-15 20:28       ` Wolfram Sang [this message]
2016-04-15 20:41         ` Wolfram Sang
2016-04-17 12:49           ` Wolfram Sang
2016-04-18  7:33             ` Geert Uytterhoeven
2016-04-26 10:18           ` Geert Uytterhoeven
2016-04-26 17:00             ` Wolfram Sang
2016-04-01 15:44 ` [PATCH v2 3/9] mmc: tmio: Add UHS-I mode support Wolfram Sang
2016-08-16 18:05   ` Geert Uytterhoeven
2016-08-16 19:55     ` Wolfram Sang
2016-08-16 20:21       ` Geert Uytterhoeven
2016-08-17 19:08     ` Wolfram Sang
2016-08-17 20:17       ` Geert Uytterhoeven
2016-08-18 18:41         ` Wolfram Sang
2016-08-23 12:34       ` Geert Uytterhoeven
2016-04-01 15:44 ` [PATCH v2 4/9] mmc: tmio: always start clock after frequency calculation Wolfram Sang
2016-04-01 15:44 ` [PATCH v2 5/9] mmc: tmio: stop clock when 0Hz is requested Wolfram Sang
2016-04-01 15:44 ` [PATCH v2 6/9] mmc: host: add note that set_ios needs to handle 0Hz properly Wolfram Sang
2016-04-01 15:44 ` [PATCH v2 7/9] mmc: sh_mobile_sdhi: Add UHS-I mode support Wolfram Sang
2016-04-04 15:04   ` Ulf Hansson
2016-04-04 15:17     ` Wolfram Sang
2016-04-04 15:52       ` Ulf Hansson
2016-04-04 15:56         ` Wolfram Sang
2016-04-01 15:44 ` [PATCH v2 8/9] ARM: shmobile: r8a7790: Set maximum frequencies for SDHI clocks Wolfram Sang
2016-04-01 15:44 ` [PATCH v2 9/9] ARM: shmobile: r8a7790: lager: Enable UHS-I SDR-50 Wolfram Sang
2016-04-06  0:56   ` [v2,9/9] " Simon Horman
2016-04-06  6:38     ` Geert Uytterhoeven
2016-04-06  7:13       ` Simon Horman
2016-04-04 15:08 ` [PATCH v2 0/9] r8a7790: add UHS-I (SDR50) support to Lager Ulf Hansson
2016-04-04 15:21   ` Wolfram Sang
2016-04-05 11:12     ` Ulf Hansson
2016-04-05 11:19       ` Wolfram Sang
2016-04-06  0:56         ` Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160415202803.GA3105@katana \
    --to=wsa@the-dreams.de \
    --cc=ben.hutchings@codethink.co.uk \
    --cc=geert@linux-m68k.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).