Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3508411imb; Tue, 5 Mar 2019 11:08:27 -0800 (PST) X-Google-Smtp-Source: APXvYqzKHwMXu8OHguNS4HgoJFIH5Seyp3pTEe/g1aPAFg/wGtQ9Gy3BJKnHTYUr/zEA7Z9C3JYd X-Received: by 2002:a65:5bc9:: with SMTP id o9mr2738014pgr.42.1551812907606; Tue, 05 Mar 2019 11:08:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551812907; cv=none; d=google.com; s=arc-20160816; b=nz9RqYlLMbw3SHZ/fyaNkZQDq1PG5i/j8pQbhUyMcPX7RTNJ+t3AqxhVX3Insl4pPQ p/V935N9avxztenpSLG8O+OHxiZfrFZZGnn9VXxVBmbhaJfwXkLtlEjhaxh/DdZLWaNE yi46AaGIIxN/EQd9aenM0UUpd523q79PHpc875dwXsZx5fUCSgGB92RZhxsCdCsYT25p Sjedz2gEMQCTvZb8o4/HU4zCCQTT9m4UeERnGdDDKeMW4IfY0qJ0PElvmxjSvdQYlZXy XDJ+FDn/rNWY3U4H6IT3CuKP51SBg79SjgpRhW14zye3nlrULsfaxze+YjvxexkoTe/b ib0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:user-agent:message-id:to:cc:subject :from:references:in-reply-to:content-transfer-encoding:mime-version :dkim-signature; bh=k+Iq3xwBIbt9ZPAisBgeg2pj+qY/jWn5gCD7h7gjDnA=; b=sFb5+qEg4WO/lWV0hE7FNxPckdILvhKC8H+mI2ifS61u6zWJL9SqT4R0WoqM5A+TXU KxX3ryZvH2WPluJuCu99dcFfOUyZ4pwoIA6PZUOV78NjQGMTw9yjb7N9ooMRi3hxUZkl LwMbCcl+edH2cFvzmz+RSBSGAKZFrko7549rl+UdD9Lry4IC/UgS2Gn8h6mt9C3oPOro 6R8GbTR0jYLY+zIfZLcVaUMOjetMubFF85j3re1PBbDUvW0blDKHgTapw/tDlTYkvFYO 2nwDa80t4yVpEHK+hPZT/zrowL79H1eK6ZbozlP1877gqJMWsVEqKsigB6ZxlKVjDj/O DvIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mC6lKazT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j16si8629602pgk.441.2019.03.05.11.08.12; Tue, 05 Mar 2019 11:08:27 -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; dkim=pass header.i=@kernel.org header.s=default header.b=mC6lKazT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727621AbfCESth (ORCPT + 99 others); Tue, 5 Mar 2019 13:49:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:44788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726190AbfCEStg (ORCPT ); Tue, 5 Mar 2019 13:49:36 -0500 Received: from localhost (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 15CBF208E4; Tue, 5 Mar 2019 18:49:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551811776; bh=k+Iq3xwBIbt9ZPAisBgeg2pj+qY/jWn5gCD7h7gjDnA=; h=In-Reply-To:References:From:Subject:Cc:To:Date:From; b=mC6lKazT6lIrm9i+G1AcAWAwRkMzT8/Ne7BEWwXlNXjNPYIOYPwlaerFACuAP2N03 X9CvpctEsfCQmrSSWm6IOqDTjv7d6VVZ4oGqXbf0ZrgJOd/XLwzYm3joGozHT8cp9A gYfeXENWzH1wYz6K9nVJbSL2DeYeMr5Zxvx68/Eo= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20190305044936.22267-2-dbasehore@chromium.org> References: <20190305044936.22267-1-dbasehore@chromium.org> <20190305044936.22267-2-dbasehore@chromium.org> From: Stephen Boyd Subject: Re: [PATCH v2 1/6] clk: Remove recursion in clk_core_{prepare,enable}() Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-doc@vger.kernel.org, mturquette@baylibre.com, heiko@sntech.de, aisheng.dong@nxp.com, mchehab+samsung@kernel.org, corbet@lwn.net, jbrunet@baylibre.com, Stephen Boyd , Derek Basehore To: Derek Basehore , linux-kernel@vger.kernel.org Message-ID: <155181177527.20095.15680753964583935841@swboyd.mtv.corp.google.com> User-Agent: alot/0.8 Date: Tue, 05 Mar 2019 10:49:35 -0800 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Derek Basehore (2019-03-04 20:49:31) > From: Stephen Boyd >=20 > Enabling and preparing clocks can be written quite naturally with > recursion. We start at some point in the tree and recurse up the > tree to find the oldest parent clk that needs to be enabled or > prepared. Then we enable/prepare and return to the caller, going > back to the clk we started at and enabling/preparing along the > way. This also unroll the recursion in unprepare,disable which can > just be done in the order of walking up the clk tree. >=20 > The problem is recursion isn't great for kernel code where we > have a limited stack size. Furthermore, we may be calling this > code inside clk_set_rate() which also has recursion in it, so > we're really not looking good if we encounter a tall clk tree. >=20 > Let's create a stack instead by looping over the parent chain and > collecting clks of interest. Then the enable/prepare becomes as > simple as iterating over that list and calling enable. >=20 > Modified verison of https://lore.kernel.org/patchwork/patch/814369/ > -Fixed kernel warning > -unrolled recursion in unprepare/disable too >=20 > Cc: Jerome Brunet > Signed-off-by: Stephen Boyd > Signed-off-by: Derek Basehore > --- From the original post: "I have some vague fear that this may not work if a clk op is framework=20 reentrant and attemps to call consumer clk APIs from within the clk ops. If the reentrant call tries to add a clk that's already in the list then we'll corrupt the list. Ugh." Do we have this sort of problem here? Or are you certain that we don't have clks that prepare or enable something that is already in the process of being prepared or enabled?