Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp569988imu; Fri, 21 Dec 2018 04:02:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/WKbWXzLhUv6N03l8gCWHhhAp+3NveSDUNynXlykWbmmmTmLb3rp5rQkVCHgmdMjBmjkLih X-Received: by 2002:a62:d148:: with SMTP id t8mr2299507pfl.52.1545393726198; Fri, 21 Dec 2018 04:02:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545393726; cv=none; d=google.com; s=arc-20160816; b=q0nIaWRYSI1ppCdIYE9SP/vO693aTCHfVysEKJofi8TRB0PJz4ctMIaw7ix/CFzjr0 mccjCSrdOCUEZpPpByuR7xKcHTBTApz9j6LuJ//C1+C5qzBXz3gmSjXGmux4ghS41N4j lDyEgIX80VcRFHinECijBgPjttmCO8McWmaZ3CK5tSekLViErvM8eMaxFNdfKbA9Ar+y hekw6VELk1jWVCSEgBV8+zzfxOZmEBkVeMzPPY9lCt2PR+BvzWDxfHKchEEQR/696RQV joqcp8XIMMUCoJtdCfro6+tLJf/cNpUPhA7rc/W72pi+mhwbnVKb9rooIv5u54X3zTjd wiiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=z8IX5khWv6NwCaeddsyQb3gmTaVRx0LhYfdFanUsyfM=; b=jaKKApe7dqT3F3cF+ASd9B/waZJ9IjmMIYf8PwKwAJFmn4J/9E7TpG1GVMCpnERFdk 49clWbOevThVroE7QhAumsLDoSEo1VvXpMV+9AWTZRn7iMc4h8ar8H0TcelpICA11PxE aX9n391ScWBlghUN08lJSJN209sCKae2G2WXPuTSL/4eJYZjwmYMzapPTkeRaXvL2mJK +Ds5m1VJCYk8duspJXekcg9tLuAgQjzVXMVI+BZBbYoVlEDeFiATcMSDD0zDss/WQ7VH vyNjuYbv+SDmDnSOZnXtuI1XElw9XJI4bQj5DWr7LEloXdVQ2vxt6NPXONcCxne+hjP2 UJoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cE1+93jW; 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 o11si20051456pll.160.2018.12.21.04.01.50; Fri, 21 Dec 2018 04:02: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=@chromium.org header.s=google header.b=cE1+93jW; 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 S2388075AbeLUAbG (ORCPT + 99 others); Thu, 20 Dec 2018 19:31:06 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:35731 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729523AbeLUAbF (ORCPT ); Thu, 20 Dec 2018 19:31:05 -0500 Received: by mail-pf1-f193.google.com with SMTP id z9so1707493pfi.2 for ; Thu, 20 Dec 2018 16:31:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=z8IX5khWv6NwCaeddsyQb3gmTaVRx0LhYfdFanUsyfM=; b=cE1+93jWliwNGhlYPDAEWMc7vrx2LgcjvWB7bzWGqCfbTIilOB4/8ouHRGONHzkX2f iRZw1Btdp5LHCvdHtr74bo0FZvEJs3jWgiUR85qP4uZlUwOD5cEIBnVeYPQJGrthwAqC 0wwUv1MgMVZANzse9IHtodVKAmGohWY2qDh6o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=z8IX5khWv6NwCaeddsyQb3gmTaVRx0LhYfdFanUsyfM=; b=bSLxOmDBN9DCXfDcpxtLkvYLPXogVkkDK7hmk9ZNMrLEAW4cZ24BGCych7mvPvcpTs pY2jlbtVEXo7lXrI1GYiQ5s25TZuDqGThNgyI2hdyE42Jiu0k7108xYMZpnhQ7pPTSKn QnjuuqGGOW05xANkOXsOfDxLLDe7VprElB/0NcNpO6YrVNXhdIeN4FJVu19bRIuAxGUP mAOscGW+26Btk9DGgghKEsn5UbedKYRtBdhRBi8QtceG4tguP5+G4GR+VRDv/YNZWu24 WcLUzVueI6NnTgLsiw7KF+kxEHmkLLBUMOWBgXZ+iAXimBSM31oYXX/2lwCp7Cdq6fdk Qfmg== X-Gm-Message-State: AJcUukeKuByo1DrtN8ag/+mGLba083cmpbpXuXN0vK5wBQRuxG/FWghG 79hxtzNVoAN+ZNs1ugJSnV3mYQ== X-Received: by 2002:a63:c303:: with SMTP id c3mr342806pgd.268.1545352264917; Thu, 20 Dec 2018 16:31:04 -0800 (PST) Received: from exogeni.mtv.corp.google.com ([2620:15c:202:1:db8d:8e3f:2514:5db8]) by smtp.gmail.com with ESMTPSA id s21sm36607971pfk.133.2018.12.20.16.31.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 16:31:04 -0800 (PST) From: Derek Basehore To: mturquette@baylibre.com Cc: sboyd@kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Derek Basehore Subject: [PATCH] clk: Remove global clk traversal on fetch parent index Date: Thu, 20 Dec 2018 16:31:00 -0800 Message-Id: <20181221003100.157581-1-dbasehore@chromium.org> X-Mailer: git-send-email 2.20.1.415.g653613c723-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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. Change-Id: I85499d2e576249568ff508e424ca8d5009e6e2b1 Signed-off-by: Derek Basehore --- drivers/clk/clk.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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; - for (i = 0; i < core->num_parents; i++) - if (clk_core_get_parent_by_index(core, i) == parent) + for (i = 0; i < core->num_parents; i++) { + if (core->parents[i] == parent) + return i; + + if (core->parents[i]) + continue; + + if (!strcmp(parent->name, core->parent_names[i])) { + core->parents[i] = parent; return i; + } + } return -EINVAL; } -- 2.20.1.415.g653613c723-goog