Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3722603imb; Tue, 5 Mar 2019 17:41:55 -0800 (PST) X-Google-Smtp-Source: APXvYqwQoGD510tmrbhwe7ZzqyaYFbpyLlKKEKpUJHPdeX8/wZ2uFMKajLwTy2gEYZ+a8NFUj9s4 X-Received: by 2002:aa7:8051:: with SMTP id y17mr4754856pfm.92.1551836515194; Tue, 05 Mar 2019 17:41:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551836515; cv=none; d=google.com; s=arc-20160816; b=nKNLjRq1T7C4ETkHKYuxh9OoUaV7kkX3C/WTTVDvcVwgCrjB8XybfV4/rMKjTQGD7Y rbDFFWzg1jgqT8a5fTiFXfj1Ds6HU46eRdR7Kf2R7RdUITcUc1eIt31O4mapVzZZ2eMB sToonGV1gHAtpaardV9cGnbCKbWKlKY8tWKws0Buh8iDV0pir5bXvrqf504OhV517ZSo u3I1L2IGlUV3gJ8X4CzpOtiDKUKVKyaRCZP6rqg6TcDNbFsgGq+aOtK/CfSnNMYVGbF4 nir5y4sBwbLLiRDpATYGXqL00wUB3uLkFndBycqnjNLGbzChGsA3VNvbT8FOsQWy83EO RPzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=nnH5gTz+dmOUwUqdWQFZb+nIuHdSODZLbf2vioXCAnk=; b=v/+mDLsMKPVqOCIAXk4Qc8xvziya9wSmNbPtvYKwXmbxDbDgM8V5gX5u9dZGsZ8dDE 8i9H//pHBzdjPPDg9V3+2vWE4daxX1knkeHmAlNpGaD4GEdshr6xwiMB7WokK0rn0/0B lHQt2SjKJKkoQZqQxFSq3FbIjoY9fQqPSDiBLmyDHVXa4KLhI447q8tOohDGwLvShOPB SDf4Yf1ls1uF/yiSuGABHwhdxYxWf+xcEGOWCH/y8HcKJBQujinI0QMb/3WZNkPnG4sC VNuia2j6F/uuFL4RaI1ZQgPAhvZfpKEY8Dr72KqWsC2R1j+mPOtzqvz/+O23dgbUYI06 QG9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="fCP/wRgI"; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d8si159550plo.41.2019.03.05.17.41.39; Tue, 05 Mar 2019 17:41:55 -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=@chromium.org header.s=google header.b="fCP/wRgI"; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727691AbfCFBfh (ORCPT + 99 others); Tue, 5 Mar 2019 20:35:37 -0500 Received: from mail-it1-f194.google.com ([209.85.166.194]:56019 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727089AbfCFBfh (ORCPT ); Tue, 5 Mar 2019 20:35:37 -0500 Received: by mail-it1-f194.google.com with SMTP id z131so7092275itf.5 for ; Tue, 05 Mar 2019 17:35:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nnH5gTz+dmOUwUqdWQFZb+nIuHdSODZLbf2vioXCAnk=; b=fCP/wRgIYLeiTmFflgsjdwwp0QsBmy7GKbkTMNUOTJN3bUEiQK5DVFEB7vr0vLRi3f +FA4NcDElVBKw69oVPwkI9Q8bCo8TQHlIw2YfWd4UxOAm1MHrBA4B54FXVURqogfRZY4 M50OogYNM13dMbHJZnx4IH69KvHbBup6d/KoM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nnH5gTz+dmOUwUqdWQFZb+nIuHdSODZLbf2vioXCAnk=; b=WkrLfAUr6qtZgOZ5URNXAojoXUOjcuU8XJf/pz5DEIvsxW+kZEsoY7MDmUFNkZoL+l 5YkwNtJJI3nMZWb2N8DF2qwUCyjLl86VVCADsvertnMPxbbksAkB5BQWMFVuBjNo5PoE rCRJdGN5g0KciTLbzF3B30HqPy6QFkdskEXfqqia6EZtUKr3NhMxrZEIkSzWGZD4WZIF LF98/Mnd6d05UCFK8csJ6CQER+8u9yoqYYVD+rkgnuv+Rj5B3FZgiKkqrbWIf6ERAL/m yTSjbBBlHNnmx7faxRa55gsONcvUdAvqY3vsAwFr9COtp+T4mr80DcwDOzXxdic1nkKg IM4w== X-Gm-Message-State: APjAAAUfLHok/+aRUF7nMQyN+1NnNFXIwUHLkcfoht3TTNPH2PYOiyzh 5xsjj8D+V4mf43cL4ml8ZoUQH22W8x639c4RfxKf+GTH X-Received: by 2002:a24:38c:: with SMTP id e134mr764476ite.24.1551836136101; Tue, 05 Mar 2019 17:35:36 -0800 (PST) MIME-Version: 1.0 References: <20190305044936.22267-1-dbasehore@chromium.org> <20190305044936.22267-2-dbasehore@chromium.org> <155181177527.20095.15680753964583935841@swboyd.mtv.corp.google.com> In-Reply-To: <155181177527.20095.15680753964583935841@swboyd.mtv.corp.google.com> From: "dbasehore ." Date: Tue, 5 Mar 2019 17:35:24 -0800 Message-ID: Subject: Re: [PATCH v2 1/6] clk: Remove recursion in clk_core_{prepare,enable}() To: Stephen Boyd Cc: linux-kernel , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-doc@vger.kernel.org, Michael Turquette , =?UTF-8?Q?Heiko_St=C3=BCbner?= , aisheng.dong@nxp.com, mchehab+samsung@kernel.org, Jonathan Corbet , jbrunet@baylibre.com, Stephen Boyd Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 5, 2019 at 10:49 AM Stephen Boyd wrote: > > Quoting Derek Basehore (2019-03-04 20:49:31) > > From: Stephen Boyd > > > > 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. > > > > 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. > > > > 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. > > > > Modified verison of https://lore.kernel.org/patchwork/patch/814369/ > > -Fixed kernel warning > > -unrolled recursion in unprepare/disable too > > > > 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 > 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? I can look into whether anything's doing this and add a WARN_ON which returns an error if we ever hit that case. If this is happening on some platform, we'd want to correct that anyways. >