From patchwork Mon May 7 05:08:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Turquette X-Patchwork-Id: 8425 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 6D2CF23E00 for ; Mon, 7 May 2012 05:14:17 +0000 (UTC) Received: from mail-gy0-f178.google.com (mail-gh0-f178.google.com [209.85.160.178]) by fiordland.canonical.com (Postfix) with ESMTP id 3D1B3A18140 for ; Mon, 7 May 2012 05:14:17 +0000 (UTC) Received: by mail-gy0-f178.google.com with SMTP id f1so4804632ghb.37 for ; Sun, 06 May 2012 22:14:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :mime-version:content-type:x-gm-message-state; bh=AbUzZpUgLNgA9513OeAzRxZ4PbIse9CPDK5KXU17Xns=; b=ohKjO887reDyaJvMKhao07KWYfv7m9nIdNiMZaT91LJrZZA4S/4ADQpI+4cqmnlz/+ sgovIbD9DFRUGLoKnqwQtfPPpmT/UM49L2HcAzkKHqQZzFtXEjR7cfiM9YS6ktdJLlbK 4+8LnnUQADrx+50wAhOTTeELTpN85UWwTeGTwRiMjSKkDVFMdyn1p4dUR5Q7yJg5BlWQ FztpfYb1XIhn9STWSo7sRZECYZ/pYAcVCU0ftuZT4d929/I8ABumXCBvmy675VQnYb52 PjRputT93RCKLfzdfGiiPO1C2POhyCIlyNwQVpa5yxc0IaigQjooxGVDWp+VvMGk5UcC smrw== Received: by 10.50.41.196 with SMTP id h4mr7519846igl.33.1336367656921; Sun, 06 May 2012 22:14:16 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.73.147 with SMTP id q19csp102866ibj; Sun, 6 May 2012 22:14:16 -0700 (PDT) Received: by 10.60.30.3 with SMTP id o3mr20078752oeh.9.1336367656089; Sun, 06 May 2012 22:14:16 -0700 (PDT) Received: from devils.ext.ti.com (devils.ext.ti.com. [198.47.26.153]) by mx.google.com with ESMTPS id n2si7189292oee.23.2012.05.06.22.14.15 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 06 May 2012 22:14:16 -0700 (PDT) Received-SPF: neutral (google.com: 198.47.26.153 is neither permitted nor denied by best guess record for domain of mturquette@linaro.org) client-ip=198.47.26.153; Authentication-Results: mx.google.com; spf=neutral (google.com: 198.47.26.153 is neither permitted nor denied by best guess record for domain of mturquette@linaro.org) smtp.mail=mturquette@linaro.org Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id q475E4Cq016934; Mon, 7 May 2012 00:14:04 -0500 Received: from DLEE74.ent.ti.com (dlee74.ent.ti.com [157.170.170.8]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id q475E45G022263; Mon, 7 May 2012 00:14:04 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE74.ent.ti.com (157.170.170.8) with Microsoft SMTP Server id 14.1.323.3; Mon, 7 May 2012 00:14:04 -0500 Received: from nucleus.nsc.com (nucleus.nsc.com [10.188.36.112]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id q475DxRo028783; Mon, 7 May 2012 00:14:02 -0500 From: Mike Turquette To: CC: , , , , , , , , , , , , , Mike Turquette Subject: [PATCH 2/5] clk: prevent spurious parent rate propagation Date: Sun, 6 May 2012 22:08:27 -0700 Message-ID: <1336367310-5140-3-git-send-email-mturquette@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1336367310-5140-1-git-send-email-mturquette@linaro.org> References: <1336367310-5140-1-git-send-email-mturquette@linaro.org> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQloePT1L3oJisJOpPlD//kLxufxwDLnZfeU2c3XaH7VzGSvnzQQhAqNYqT9DlHp0kS+EUet Patch 'clk: always pass parent_rate into .round_rate' made a subtle change to the semantics of .round_rate. It is now expected for the parent's rate to always be passed in, simplifying the implemenation of various .round_rate callback definitions. However the patch also introduced a bug in clk_calc_new_rates whereby a clock without the CLK_SET_RATE_PARENT flag set could still propagate a rate change up to a parent clock if the the .round_rate callback modified the &best_parent_rate value in any way. This patch fixes the issue at the framework level (in clk_calc_new_rates) by specifically handling the case where the CLK_SET_RATE_PARENT flag is not set. Signed-off-by: Mike Turquette Reported-by: Sascha Hauer Acked-by: Sascha Hauer --- drivers/clk/clk.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 8149764..7ceca0e 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -774,12 +774,18 @@ static struct clk *clk_calc_new_rates(struct clk *clk, unsigned long rate) if (IS_ERR_OR_NULL(clk)) return NULL; + /* save parent rate, if it exists */ + if (clk->parent) + best_parent_rate = clk->parent->rate; + /* never propagate up to the parent */ if (!(clk->flags & CLK_SET_RATE_PARENT)) { if (!clk->ops->round_rate) { clk->new_rate = clk->rate; return NULL; } + new_rate = clk->ops->round_rate(clk->hw, rate, &best_parent_rate); + goto out; } /* need clk->parent from here on out */ @@ -795,7 +801,6 @@ static struct clk *clk_calc_new_rates(struct clk *clk, unsigned long rate) goto out; } - best_parent_rate = clk->parent->rate; new_rate = clk->ops->round_rate(clk->hw, rate, &best_parent_rate); if (best_parent_rate != clk->parent->rate) {