Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp390012imu; Tue, 20 Nov 2018 00:34:56 -0800 (PST) X-Google-Smtp-Source: AFSGD/V9xRbllJryyujQbQVU1/hrGP0+/m5rThr0JoLtSXXID/3A2rfY/VdnQ6TZJ95J21CWVFJX X-Received: by 2002:a63:2141:: with SMTP id s1mr1103786pgm.148.1542702896782; Tue, 20 Nov 2018 00:34:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542702896; cv=none; d=google.com; s=arc-20160816; b=ZWpPmwbXWkARgCK0i2AISLgbCdHPB+pTYYs/FVe99mQK4XT7lPcoIHtl/Zh7sdYIvC nJeGFu7nNYQcTOjhV4s3nQCYY13n5t2cH6guVgWJdD+4moeKvJnawJan1yX2P6q48nDe gXCSoyyTsxd1mpovTBYkQ0Bul11WeE3pZUOB2EJH2Etm3YnyQ6fE/NfBL3yj5UE9hNG0 0jOK7Xzxsova+l4XeADpRpWfyNZouyscGFm/qoI2Vdz7bx3wAZwVAMKfhT2Lf1ib6u2Z w5KtpyWbDHYwylPSwCnGdaf8ysmEiGJcrLRWx5Za/xF5TGSea1oZQi7zPyXredVsCzl7 p6kQ== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=/IrsteUZclDKDczoP8UANNe1jVZ27luRhC7wTguJ+UA=; b=VSxmwkKiCrUivxOdBRBE/QSXLmUgX1gM3Y6rVNEM36rk3+cqvQqmdnpEHomGxiRIgh FuFY/yw6QSitxuutcexUX4FwQj6u4vZQ7gyHgEn1k2VsfH5sLtb5ipcYsMH9TX9fU91I vezAycYXPrXJqVutRnP6kqziR55gXBAOzZX0RPYalP2TblJP7ZK3iuc/QJY7hnR8KFoY X4SR2dM4yxmY33PCcZVfG1Es4HQ7+EJ0QWHWPmWZYf06fDffZWef6sLHymtEcq8lkYWx iyzQqDYgRIQHJhacpkgTuwRXqA5zncG2HwXJWA+Dkf4PYyi2871mnDpOdpH4oHrBBWPn iSyg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y191si40976043pgd.4.2018.11.20.00.34.41; Tue, 20 Nov 2018 00:34:56 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726485AbeKTSiy (ORCPT + 99 others); Tue, 20 Nov 2018 13:38:54 -0500 Received: from mail.bootlin.com ([62.4.15.54]:49551 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726215AbeKTSiy (ORCPT ); Tue, 20 Nov 2018 13:38:54 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 3C09A2074F; Tue, 20 Nov 2018 09:11:03 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from bbrezillon (aaubervilliers-681-1-13-146.w90-88.abo.wanadoo.fr [90.88.134.146]) by mail.bootlin.com (Postfix) with ESMTPSA id DDEA6206A1; Tue, 20 Nov 2018 09:10:52 +0100 (CET) Date: Tue, 20 Nov 2018 09:10:52 +0100 From: Boris Brezillon To: Geert Uytterhoeven Cc: masonccyang@mxic.com.tw, Mark Brown , Trent Piepho , Linux Kernel Mailing List , linux-spi , Linux-Renesas , Simon Horman , juliensu@mxic.com.tw, Geert Uytterhoeven , zhengxunli@mxic.com.tw Subject: Re: [PATCH 1/2] spi: Add Renesas R-Car RPC SPI controller driver Message-ID: <20181120091052.096ab7e3@bbrezillon> In-Reply-To: References: <1542621690-10229-1-git-send-email-masonccyang@mxic.com.tw> <1542621690-10229-2-git-send-email-masonccyang@mxic.com.tw> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 20 Nov 2018 09:01:29 +0100 Geert Uytterhoeven wrote: > > --- /dev/null > > +++ b/drivers/spi/spi-renesas-rpc.c > > @@ -0,0 +1,750 @@ > > > +static int rpc_spi_set_freq(struct rpc_spi *rpc, unsigned long freq) > > +{ > > + int ret; > > + > > + if (rpc->cur_speed_hz == freq) > > + return 0; > > + > > + clk_disable_unprepare(rpc->clk_rpc); > > + ret = clk_set_rate(rpc->clk_rpc, freq); > > + if (ret) > > + return ret; > > + > > + ret = clk_prepare_enable(rpc->clk_rpc); > > + if (ret) > > + return ret; > > The clk_{disable_unprepare,prepare_enable}() may be needed on the Macronix > controller you based this driver on, but will be futile on Renesas SoCs. > > As the RPC is part of the CPG/MSSR clock domain, its clock will be controlled > by the Runtime PM. As you've already called pm_runtime_get_sync() from your > .probe() calback, Runtime PM will have enabled the clock. > If you disable it manually, you create an imbalance between automatic and > manual clock control. > > So please don't control the clock explicitly, but always use > pm_runtime_*() calls. More about that. The reason we did that on MXIC is that the clk rate can't be changed when the clk is enabled. So we have to 1/ explicitly disable the clk that has been enabled by runtime PM 2/ set the new rate 3/ re-enable the clk So the clk enable/disable are not unbalanced, but it's also true that this disable/set_rate/enable dance might be unneeded on your platform.