From patchwork Fri Oct 17 08:11:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 38846 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 91A2720C5D for ; Fri, 17 Oct 2014 08:15:03 +0000 (UTC) Received: by mail-lb0-f199.google.com with SMTP id w7sf179793lbi.6 for ; Fri, 17 Oct 2014 01:15:02 -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: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=wfskH9NH3ff+E8wwaUheu0BzZBbBO7yUuslrCy8yobI=; b=MAv1OqcloVr1OHSCl9x9VTsYApBvHWqDPWJf0stn8j/c3fY/8N0/nbCO2dAzb1KlSR 5Odo86KWX7EiLix5MEYbeGc+Wd+mwA/POPGcQG2f3r8hHphZ8F4d0AF4bBrqjjncCoaF UJ8QKXt5qRKRXRBbmY8ovx+vFulbtg+d99uqOfaOrLw+qkZRdlMCT06bqQSQk4IrvYFk D0gO2ph8+QkjUnHE+hS/V8YybfyUoHQPrIUAhisRnXWeOLEElYLcIs3utdLdN8PdOdfp owW4HNXBiY8ZYfn8NmtUhfWXFAoZnt0rY1iW4tyNfiVcN+W7WSYmxZx6BI3dbyUB0nC7 rygQ== X-Gm-Message-State: ALoCoQmv9WPK4fbyr1ilZiraRL7X7XNz/TBisrtZ/3tGsgI6lxJ0tWUUzELiufv/6NQA6QYvEo9V X-Received: by 10.112.217.102 with SMTP id ox6mr34799lbc.19.1413533702432; Fri, 17 Oct 2014 01:15:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.207.107 with SMTP id lv11ls202491lac.27.gmail; Fri, 17 Oct 2014 01:15:02 -0700 (PDT) X-Received: by 10.112.142.33 with SMTP id rt1mr1428631lbb.85.1413533702272; Fri, 17 Oct 2014 01:15:02 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id 1si913378lax.37.2014.10.17.01.15.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Oct 2014 01:15:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id q1so254990lam.22 for ; Fri, 17 Oct 2014 01:15:02 -0700 (PDT) X-Received: by 10.152.5.38 with SMTP id p6mr2445860lap.44.1413533702182; Fri, 17 Oct 2014 01:15:02 -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 c5csp184433lbz; Fri, 17 Oct 2014 01:15:01 -0700 (PDT) X-Received: by 10.68.202.170 with SMTP id kj10mr43237pbc.161.1413533651459; Fri, 17 Oct 2014 01:14:11 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1si482018pdp.169.2014.10.17.01.14.10 for ; Fri, 17 Oct 2014 01:14:11 -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 S1753821AbaJQIOJ (ORCPT + 1 other); Fri, 17 Oct 2014 04:14:09 -0400 Received: from cantor2.suse.de ([195.135.220.15]:36351 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753822AbaJQINv (ORCPT ); Fri, 17 Oct 2014 04:13:51 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 8C505AE40; Fri, 17 Oct 2014 08:12:00 +0000 (UTC) Received: from ku by ip4-83-240-18-248.cust.nbox.cz with local (Exim 4.83) (envelope-from ) id 1Xf2dg-0000L6-9H; Fri, 17 Oct 2014 10:11:56 +0200 From: Jiri Slaby To: stable@vger.kernel.org Cc: Tero Kristo , Mike Turquette , Jiri Slaby Subject: [PATCH 3.12 152/197] clk: prevent erronous parsing of children during rate change Date: Fri, 17 Oct 2014 10:11:08 +0200 Message-Id: <3386c069c54344797c4d2da55ebef2f555a7a4a3.1413533329.git.jslaby@suse.cz> X-Mailer: git-send-email 2.1.1 In-Reply-To: <7d97f39bc813aa9f11fe03d602885f81de07007c.1413533329.git.jslaby@suse.cz> References: <7d97f39bc813aa9f11fe03d602885f81de07007c.1413533329.git.jslaby@suse.cz> In-Reply-To: References: 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.215.49 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 3.12-stable review patch. If anyone has any objections, please let me 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;