Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1998723imu; Sat, 22 Dec 2018 09:49:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN7AlfOY17KJ9FsX4/XwyDWcT0rbECDp4w7id4Ul0A/AD4G74sTU3pIPzC2qeSIYXP1Ha4LQ X-Received: by 2002:a63:9f19:: with SMTP id g25mr6804287pge.327.1545500946387; Sat, 22 Dec 2018 09:49:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545500946; cv=none; d=google.com; s=arc-20160816; b=eKjbORLAUqHPngsLyoXvBSuyJyBwGujgoQjVChj+QIBr596u6Ups/ddmR2CKlDy8wE coXcnzyjCphRt9alap561CxsP9ZL5oVLVtBE17eqnx8QklANPYR7cp9SGKUKcO6XIRSr NvaLsDNkZeBC9CfOWp7zsoaNyPttKFDT54+n+oLW2XyUAEwNBCDZyeU/EjdfY74LZ5cW yZbtcRYokQvv10wpZ6z3EqB+B/xP5XlaKk5TSAgv4Z6nPAQf5Xv58rDnZ8whRflLTcv2 XhCPY4QyF4HAlESVr8jesr0FwJkdUJBdiQM880OiyHF5gfCYnYYK0iOIdb2jk7gXmUmM qKMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:references:user-agent :in-reply-to:from:to:cc:subject:content-transfer-encoding :mime-version:dkim-signature; bh=PT0sfJsvYoWiWnIcfTV1bg4YG110htQpct9W4R4vKcI=; b=BtDAH24a7cxPeTWVc73Ah/U8/pW1ExbeDZIvueN/iVznspvmTT5a7rDy5FYwD/6Jmz M1q8AUTQDFp8aC1s6ooPMJDJxCpIUcCIAdFtlccFZiXZu22EofiP4rZiCJerlPJCxri7 TXJq+oHjjSgOWv7hKaFck2H+G1quVEXuuOvHPfzx2WAuAwFiv3p1OiECRL4OtUm4UEdy UoorB8A/7GmA0m1qkwuBQlXg8+TQ46Z7IqY/Lsn18nw+/Nxdnfk/9j5DEDV5HBxZTPi5 njF57wAnVON2gU6MYzqwGrVI1YocFVwvxH04XaOh9Q5Y+qm8ZY98QudCnIGsMAyzCYBm rSZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qxAbeRlc; 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 b2si24449248pgh.475.2018.12.22.09.48.51; Sat, 22 Dec 2018 09:49:06 -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=qxAbeRlc; 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 S2390281AbeLUUe5 (ORCPT + 99 others); Fri, 21 Dec 2018 15:34:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:54724 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732146AbeLUUe4 (ORCPT ); Fri, 21 Dec 2018 15:34:56 -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 D33D621773; Fri, 21 Dec 2018 20:34:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545424495; bh=vwPzy//5Zq8kHAFJXX1ENCRdop7FngE2euBI1e5qEUg=; h=Subject:Cc:To:From:In-Reply-To:References:Date:From; b=qxAbeRlcdqBkyIea3IXs7gOpFZ7kAwj8Vp+W8jRlKG12i+iGHUHhpeJudTIXTaa3v igAuXQ7m0vYyRDMKUo/9Nhvx7Bh1fNRdbeBII28dSJZuXTv/gmIgP/VO8f+Q9e6ZFT Bf7MLO6WJy5cIYwzFI+4p/7/2Z5sj123XS8+4DBg= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH] clk: Remove global clk traversal on fetch parent index Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Derek Basehore To: Derek Basehore , mturquette@baylibre.com From: Stephen Boyd In-Reply-To: <20181221003100.157581-1-dbasehore@chromium.org> User-Agent: alot/0.8 References: <20181221003100.157581-1-dbasehore@chromium.org> Message-ID: <154542449501.13075.1518070014652024380@swboyd.mtv.corp.google.com> Date: Fri, 21 Dec 2018 12:34:55 -0800 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Derek Basehore (2018-12-20 16:31:00) > It's not required to traverse the entire clk tree when the parents > array contains a NULL value. You already have the parent clk_core > pointer, so you can just compare the parent->name and parent_names[i] > pointers. Ok. >=20 > In cases where clk names are never registered, this can be > a substantial power improvement since a mux having an unregistered > parent name will traverse the clk tree on every set_rate. This can > happen hundreds of times a second on CPU clks. >=20 > Change-Id: I85499d2e576249568ff508e424ca8d5009e6e2b1 This should go away. > Signed-off-by: Derek Basehore > --- > drivers/clk/clk.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c > index af011974d4ec..57a95c713286 100644 > --- a/drivers/clk/clk.c > +++ b/drivers/clk/clk.c > @@ -1516,9 +1516,18 @@ static int clk_fetch_parent_index(struct clk_core = *core, > if (!parent) > return -EINVAL; > =20 > - for (i =3D 0; i < core->num_parents; i++) > - if (clk_core_get_parent_by_index(core, i) =3D=3D parent) > + for (i =3D 0; i < core->num_parents; i++) { > + if (core->parents[i] =3D=3D parent) > + return i; > + > + if (core->parents[i]) > + continue; > + > + if (!strcmp(parent->name, core->parent_names[i])) { > + core->parents[i] =3D parent; > return i; > + } > + } > =20 Wow, this looks really familiar. In fact, take a look at commit da0f0b2c3ad2 ("clk: Correct lookup logic in clk_fetch_parent_index()") and you'll see that it's almost the same code. The main difference is that this patch's clk_fetch_parent_index() doesn't call __clk_lookup() to get a pointer to the clk it already has. And then in commit 470b5e2f97cf ("clk: simplify clk_fetch_parent_index() function") we consolidated all the logic to simplify things, but it seems that we became confused that the result of !strcmp(parent, names[i]) is actually only true when the strings are equal. That was an invalid transformation. Ouch. But this is a good find! So this patch is reverting commit 470b5e2f97cf and then optimizing it to never call __clk_lookup() because it's useless. I'll need to add a comment and expand on the commit text here so that it's more obvious what's going on. Otherwise someone will come by and try to consolidate again and we'll do this all over again.