From patchwork Mon Oct 13 13:50:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 38651 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0C38E20CC8 for ; Mon, 13 Oct 2014 13:51:15 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id m15sf4111967wgh.3 for ; Mon, 13 Oct 2014 06:51:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=oyTqa34lawuOhgoCBmhMTmMDj1Kx/yM/iYp6AqiKRsc=; b=G/n5noCWIfRxl5THMretynH2jffzfj91pjoJE3IKeEMUhNRVPQrSNfYl3WgfvRi+j1 fjaE7+IpXOQDg83aOfJYebw2cYRzT0fBeLwgHCGwdr/WX13+DowMrWrbe9Q8yyJvf/v+ 2TkBFW73LttPn5Qky/wi6aqzso994VsLVDtInHkPpnkMw5ki8EDETnWgk3PjrJet6EWb 8duP+ZDkMzjUFuaNOJ5mzmhk+2CWG5nYdczVZnQn9iQg/O5V1RjqphfAdTzy8pL1PiJM ti0JdfXL9e1Reyi/MxfVymgS4PboTRvdCtQORBK8bYRxFCNdg+b/C3BLXk1zzCIbcZyB AdZw== X-Gm-Message-State: ALoCoQlw/lRyijGtlKPyzucn8eeSa+dEZaTcyS8LsTX0zOqE1P6n3O4JZFtAfYFCZnhqigzgBQqZ X-Received: by 10.181.28.169 with SMTP id jp9mr195027wid.6.1413208274114; Mon, 13 Oct 2014 06:51:14 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.39 with SMTP id 7ls413815lar.87.gmail; Mon, 13 Oct 2014 06:51:13 -0700 (PDT) X-Received: by 10.152.36.130 with SMTP id q2mr24793029laj.42.1413208273925; Mon, 13 Oct 2014 06:51:13 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com [209.85.217.169]) by mx.google.com with ESMTPS id mi5si22328508lbc.61.2014.10.13.06.51.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 13 Oct 2014 06:51:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by mail-lb0-f169.google.com with SMTP id 10so6544494lbg.28 for ; Mon, 13 Oct 2014 06:51:13 -0700 (PDT) X-Received: by 10.112.156.227 with SMTP id wh3mr23898979lbb.23.1413208273853; Mon, 13 Oct 2014 06:51:13 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp217648lbz; Mon, 13 Oct 2014 06:51:13 -0700 (PDT) X-Received: by 10.66.157.73 with SMTP id wk9mr4177889pab.101.1413208245312; Mon, 13 Oct 2014 06:50:45 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i13si10368565pat.185.2014.10.13.06.50.44 for ; Mon, 13 Oct 2014 06:50:45 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754919AbaJMNum (ORCPT + 1 other); Mon, 13 Oct 2014 09:50:42 -0400 Received: from ip4-83-240-67-251.cust.nbox.cz ([83.240.67.251]:57226 "EHLO ip4-83-240-18-248.cust.nbox.cz" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754917AbaJMNuQ (ORCPT ); Mon, 13 Oct 2014 09:50:16 -0400 Received: from ku by ip4-83-240-18-248.cust.nbox.cz with local (Exim 4.83) (envelope-from ) id 1Xdg0o-000463-8y; Mon, 13 Oct 2014 15:50:10 +0200 From: Jiri Slaby To: stable@vger.kernel.org Cc: Tero Kristo , Mike Turquette , Jiri Slaby Subject: [patch added to the 3.12 stable tree] clk: prevent erronous parsing of children during rate change Date: Mon, 13 Oct 2014 15:50:06 +0200 Message-Id: <1413208209-15396-53-git-send-email-jslaby@suse.cz> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1413208209-15396-1-git-send-email-jslaby@suse.cz> References: <1413208209-15396-1-git-send-email-jslaby@suse.cz> Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Tero Kristo This patch has been added to the 3.12 stable tree. If you have any objections, please let us know. =============== commit 067bb1741c27c8d3b74ac98c0b8fc12b31e67005 upstream. In some cases, clocks can switch their parent with clk_set_rate, for example clk_mux can do this in some cases. Current implementation of clk_change_rate uses un-safe list iteration on the clock children, which will cause wrong clocks to be parsed in case any of the clock children change their parents during the change rate operation. Fixed by using the safe list iterator instead. The problem was detected due to some divide by zero errors generated by clock init on dra7-evm board, see discussion under http://article.gmane.org/gmane.linux.ports.arm.kernel/349180 for details. Fixes: 71472c0c06cf ("clk: add support for clock reparent on set_rate") Signed-off-by: Tero Kristo Reported-by: Nishanth Menon Signed-off-by: Mike Turquette Signed-off-by: Jiri Slaby --- drivers/clk/clk.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index a004769528e6..f5966413fbb2 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1368,6 +1368,7 @@ static struct clk *clk_propagate_rate_change(struct clk *clk, unsigned long even static void clk_change_rate(struct clk *clk) { struct clk *child; + struct hlist_node *tmp; unsigned long old_rate; unsigned long best_parent_rate = 0; @@ -1391,7 +1392,11 @@ static void clk_change_rate(struct clk *clk) if (clk->notifier_count && old_rate != clk->rate) __clk_notify(clk, POST_RATE_CHANGE, old_rate, clk->rate); - hlist_for_each_entry(child, &clk->children, child_node) { + /* + * Use safe iteration, as change_rate can actually swap parents + * for certain clock types. + */ + hlist_for_each_entry_safe(child, tmp, &clk->children, child_node) { /* Skip children who will be reparented to another clock */ if (child->new_parent && child->new_parent != clk) continue;