From patchwork Fri Apr 15 20:28:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 8858151 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 23E82BF29F for ; Fri, 15 Apr 2016 20:28:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 81E342027D for ; Fri, 15 Apr 2016 20:28:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D21282021B for ; Fri, 15 Apr 2016 20:28:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751242AbcDOU2U (ORCPT ); Fri, 15 Apr 2016 16:28:20 -0400 Received: from sauhun.de ([89.238.76.85]:48404 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750956AbcDOU2R (ORCPT ); Fri, 15 Apr 2016 16:28:17 -0400 Received: from p4fe25a1e.dip0.t-ipconnect.de ([79.226.90.30]:38166 helo=katana) by pokefinder.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1arALX-0002nb-4K; Fri, 15 Apr 2016 22:28:07 +0200 Date: Fri, 15 Apr 2016 22:28:03 +0200 From: Wolfram Sang To: Ben Hutchings Cc: Geert Uytterhoeven , Linux MMC List , linux-renesas-soc@vger.kernel.org Subject: Re: [PATCH v2 2/9] mmc: tmio, sh_mobile_sdhi: Add support for variable input clock frequency Message-ID: <20160415202803.GA3105@katana> References: <1459525479-20842-1-git-send-email-wsa@the-dreams.de> <1459525479-20842-3-git-send-email-wsa@the-dreams.de> <1460477978.32355.14.camel@codethink.co.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1460477978.32355.14.camel@codethink.co.uk> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP > > 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)