From patchwork Fri Jan 5 17:09:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 10146815 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C963E601A1 for ; Fri, 5 Jan 2018 17:10:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACE3A28686 for ; Fri, 5 Jan 2018 17:10:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1D2028701; Fri, 5 Jan 2018 17:10:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1D3AB28686 for ; Fri, 5 Jan 2018 17:10:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=YqSoQYOd51szOnGZ58ZjISlZZbh2NZj0rYhU2CUPJws=; b=h3IFfhoG0Htvp6aHIOyp400sMP PZVgwakYqj5VztXMz4ES59Oqwgcr4h2Yv9MzoY+XM27KJKdzUKO1BbDMZPkvZZEQJ4Gsp8hkCUSSZ KGgAdBJsSQVzmaksL9OlLm50oKpOMzlB1V7ACdgo1hZ5I/VTX63h10VZAUWCEazM1MxOXTsJPMsA7 PU0igJc7sMFYy19RUmMGTscSesbxfcuGJ+LA14biTbtVEhSZ1HWt303jCNyW5BdpJwuv6KPwT0Xv1 8qeenhGRyVf30sHEX3avos3vyzHOY4ioWVcMT4WaAqNFOasqULThAyrYOh1h1rQXwVLRYtlcVkKL+ YTAcckbA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eXVW8-0003O2-QW; Fri, 05 Jan 2018 17:10:52 +0000 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eXVVX-0001sG-Jp for linux-arm-kernel@lists.infradead.org; Fri, 05 Jan 2018 17:10:18 +0000 Received: by mail-wr0-x243.google.com with SMTP id p6so4896517wrd.0 for ; Fri, 05 Jan 2018 09:10:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vhTiE1q+W9XLMnKuM8pGuls+KnGKWREcmhY32m5XW7A=; b=TtN2eKPzpFjCzkWFKt2Z158U3X+Uax/n0MZQhRdedfx7AFahGbpIzZN+LZLS2f86nH FkVDTDGM/PO5xn0SN0jqafjUWk5rN/S17BxnVyLqyiMwof5e5db8D/kfMj9nI9fxD85g uaTZkm5OxuzMDeW5qrfDFylon4iKYBGi42t3M8GEz187JZW/GIRjy8RJyNWyuYznMcbn QJBHTPy+apVLEO+a8GFEMHbtkJ9RU6zXCNulgxHzRjhGW9pUBME57VF6tMotg6k9MDl8 cZicKuKWdbqvm7oO7/YmdvWgzTaGRqpx2Zt5nzyGgLFkSBaJFrF4Vmti/q8l1HpbiknY /o0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vhTiE1q+W9XLMnKuM8pGuls+KnGKWREcmhY32m5XW7A=; b=Umoka7iP58hSsu12fgtevrv2oaakhjhla2zbvOPHUb/XFrPXIEgSn9W6lPjA4jr938 5WiXRLHlZgKu17eKetJ+R5LSy26ZCYG09eCRpAkyOialRj++2ElyQL/WO6gQI7p2zSem pL0c5QJGo4rIFzEJQSGFuCzFYyj/eCNseeTR7pBb+PmlN2hFBX/uYySmiK4NyM/bZLdX RuKWUWkaiPTB8kHvz7GS3TtGqLY3FMzM+Birlxufxpqd8X+0DPlf25c61GO58lYPrbtV MqqpMMh7lrPcLd8NSFTbKpOGm71/WNZpdEPwiWdcE9gfqbu2Wx4h+eqQPgNFND8Op9O7 lTXg== X-Gm-Message-State: AKGB3mJmr5eAdNmntRGdlpyDOaX78eR7rA/H5i6VXXMl8MrTMBxHHyWj 2xdcWztA2lEnB6vE/QyDZhnbyg== X-Google-Smtp-Source: ACJfBospcfryz1/poKdTP45k3/cCXTsVp0PUB+K+HhSCJMcpM7aFgo3rKa9syBiOyqzHU4hEBDrsgw== X-Received: by 10.223.160.149 with SMTP id m21mr3215526wrm.112.1515172204475; Fri, 05 Jan 2018 09:10:04 -0800 (PST) Received: from boomer.baylibre.local ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id g17sm3263661wra.6.2018.01.05.09.10.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jan 2018 09:10:03 -0800 (PST) From: Jerome Brunet To: Stephen Boyd , Michael Turquette , linux-clk@vger.kernel.org Subject: [PATCH 1/5] clk: divider: read-only divider can propagate rate change Date: Fri, 5 Jan 2018 18:09:55 +0100 Message-Id: <20180105170959.17266-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180105170959.17266-1-jbrunet@baylibre.com> References: <20180105170959.17266-1-jbrunet@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180105_091015_741286_AF0195A7 X-CRM114-Status: GOOD ( 10.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Zapolskiy , David Brown , Sylvain Lemieux , Andy Gross , linux-arm-kernel@lists.infradead.org, Jerome Brunet MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When a divider clock has CLK_DIVIDER_READ_ONLY set, it means that the register shall be left un-touched, but it does not mean the clock should stop rate propagation if CLK_SET_RATE_PARENT is set This is properly handled in qcom clk-regmap-divider but it was not in the generic divider Fixes: e6d5e7d90be9 ("clk-divider: Fix READ_ONLY when divider > 1") Signed-off-by: Jerome Brunet Tested-by: David Lechner --- drivers/clk/clk-divider.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c index b49942b9fe50..a851d3e04c7f 100644 --- a/drivers/clk/clk-divider.c +++ b/drivers/clk/clk-divider.c @@ -348,6 +348,7 @@ static long clk_divider_round_rate(struct clk_hw *hw, unsigned long rate, unsigned long *prate) { struct clk_divider *divider = to_clk_divider(hw); + struct clk_hw *hw_parent = clk_hw_get_parent(hw); int bestdiv; /* if read only, just return current value */ @@ -356,6 +357,15 @@ static long clk_divider_round_rate(struct clk_hw *hw, unsigned long rate, bestdiv &= div_mask(divider->width); bestdiv = _get_div(divider->table, bestdiv, divider->flags, divider->width); + + /* Even a read-only clock can propagate a rate change */ + if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) { + if (!hw_parent) + return -EINVAL; + + *prate = clk_hw_round_rate(hw_parent, rate * bestdiv); + } + return DIV_ROUND_UP_ULL((u64)*prate, bestdiv); }