Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1312943pxy; Fri, 23 Apr 2021 05:27:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMtpl6gdG07fERwp5/p9O63iCw7C0DyvxkQfBr43Hr7TPIZG0fztbOak1gr3N3kDy7iiyX X-Received: by 2002:a17:906:d18a:: with SMTP id c10mr3871231ejz.271.1619180858992; Fri, 23 Apr 2021 05:27:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619180858; cv=none; d=google.com; s=arc-20160816; b=t/J47n3WXC1gzsp4TCyTjQnRPEaY4bqf686LchzTgYpSSYVYpGHKU4y1zlAlIInFl+ +Q3mKjO+08NTSC8tZIRAuFr3Omyw4Y9lx6bROVUgWQeMS785pqt771H2nCsFqabbiHFS 1EaixnJri7jH/YnFT2TrCLUxJKvuqZUnTN6aa2ZbUSsIwWfcIdQgORASq5jmeJZZIY+z e+8rSw5NFKCML4ScFDyPSDUdVSJy79K7GjNsgwXv767CIQGbbP5PwEk1mpMXXOoWWNWN 9/HREYO9mB2srwRp38zKFNCNIAj10Nj0fCNE3iSSH4iwajkdVGhX6ZWVY/G676FUAB5f 37DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=IfZ+2JiNci4QRyjBF0wJiEKhtkmyRzMTA5tDnebPqoM=; b=HFG9jZUgG2LsdcxByExjNmHpajZHrLe55DpbQhHVFo37dyUyFto92EO/+kPSxc46uJ wozXVxtrW5N9ymVuLipj1h6IY6GeVCp9CqUSaS/CASeGFrVwwx+4h2exY0KtMsGuvN4a PZxr0/W/nilJDpPzRkX0zrHBodAOsA/5DD6EliyUbF2Ba7TrfvJn3wcyc9ygWe2B3Ff+ YsdnHs8+TjMZRy/NTjYKKUbvMIgpgFi2yaTJ+KPN804SxhxDlYgKkLBCVasgxyXI91Dk UB7TQg0x9molwFxDeDDlF8Q7Kj6rA4G5n3BhE8UqK74aaLvTuXdqW5VOCYQAQvmq6euR n2Ug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id h13si4970256eja.683.2021.04.23.05.27.13; Fri, 23 Apr 2021 05:27:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S242570AbhDWMXs (ORCPT + 99 others); Fri, 23 Apr 2021 08:23:48 -0400 Received: from mail-wm1-f54.google.com ([209.85.128.54]:44630 "EHLO mail-wm1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242583AbhDWMXp (ORCPT ); Fri, 23 Apr 2021 08:23:45 -0400 Received: by mail-wm1-f54.google.com with SMTP id f195-20020a1c1fcc0000b029012eb88126d7so1118716wmf.3; Fri, 23 Apr 2021 05:23:07 -0700 (PDT) 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=IfZ+2JiNci4QRyjBF0wJiEKhtkmyRzMTA5tDnebPqoM=; b=d6W7v5FGzHckzGhqIZe74LBwfC4qy/ig5KtegFpK5IaT9XZBz94RmqJhwKddiCBGzK nAZFhGuJt+wwPBeuz/3lqkg1L+rh4S/GdDmsd/S3mF7ePnHPSWBUo5SalbdOWzKyV0Rn vTydF3nEtLBrT6Zk0XOcHs/AO54yoP+trawkA/tdFo9ClrK1HqtY+zIN8sJfu6ljoP0V WFfNbocMZocDnNU6ETX+Fid3O/PcVBxok9ysW84dbeHi6XvEfYpOSwub0zt4F/jqYb1D P28pY3xvZ8ZCeAlTqMVcW5y/OIYwG9Rz0ZpzqE7MNMQU6mquZ/m/ffT4k4kna7gG25Mi axkw== X-Gm-Message-State: AOAM530rVbQAoHTJk/5FBQC4lkkND647Nphocq7sTwAbAd+QA8tPX2qp bjdrU90/g3Au8xulHlU9jO53psGhoi+WfJKwnSQ= X-Received: by 2002:a7b:cb8a:: with SMTP id m10mr5263993wmi.95.1619180586988; Fri, 23 Apr 2021 05:23:06 -0700 (PDT) MIME-Version: 1.0 References: <1619123448-10138-1-git-send-email-skomatineni@nvidia.com> <1619123448-10138-3-git-send-email-skomatineni@nvidia.com> In-Reply-To: <1619123448-10138-3-git-send-email-skomatineni@nvidia.com> From: "Rafael J. Wysocki" Date: Fri, 23 Apr 2021 14:22:55 +0200 Message-ID: Subject: Re: [RFC PATCH 2/4] cpuidle: menu: add idle_time to cpuidle_state To: Sowjanya Komatineni Cc: Sudeep Holla , Souvik Chakravarty , Thierry Reding , Mark Rutland , Lorenzo Pieralisi , Daniel Lezcano , Rob Herring , Jon Hunter , ksitaraman@nvidia.com, sanjayc@nvidia.com, Linux ARM , linux-tegra , Linux Kernel Mailing List , Linux PM , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 22, 2021 at 10:31 PM Sowjanya Komatineni wrote: > > Some platforms use separate CPU firmware running in background to > handle state transitions which may need runtime idle time of the > corresponding target state from the kernel. How exactly does this work? > This patch adds idle_time to cpuidle state to expose to cpuidle driver the > idle time that the governor menu predicts based on next events and states > target residency for selecting proper idle state. > > CPU idle driver passes this runtime state idle time to TF-A. > > Signed-off-by: Sowjanya Komatineni > --- > drivers/cpuidle/governors/menu.c | 7 ++++++- > include/linux/cpuidle.h | 1 + > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c > index c3aa8d6..0da5bc5 100644 > --- a/drivers/cpuidle/governors/menu.c > +++ b/drivers/cpuidle/governors/menu.c > @@ -382,8 +382,10 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, > * stuck in the shallow one for too long. > */ > if (drv->states[idx].target_residency_ns < TICK_NSEC && > - s->target_residency_ns <= delta_tick) > + s->target_residency_ns <= delta_tick) { > + drv->states[idx].idle_time = delta_tick / NSEC_PER_USEC; > idx = i; > + } > > return idx; > } > @@ -393,6 +395,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, > idx = i; > } > > + drv->states[idx].idle_time = predicted_ns / NSEC_PER_USEC; > if (idx == -1) > idx = 0; /* No states enabled. Must use 0. */ > > @@ -419,6 +422,8 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, > if (drv->states[i].target_residency_ns <= delta_tick) > break; > } > + > + drv->states[idx].idle_time = delta_tick / NSEC_PER_USEC; > } > } > > diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h > index fce4762..12db2e9 100644 > --- a/include/linux/cpuidle.h > +++ b/include/linux/cpuidle.h > @@ -55,6 +55,7 @@ struct cpuidle_state { > unsigned int exit_latency; /* in US */ > int power_usage; /* in mW */ > unsigned int target_residency; /* in US */ > + unsigned int idle_time; /* in US */ No way. This structure holds idle state properties of and not some random data passed between cpuidle components. And it is not per-CPU, while the governors work on the per-CPU basis. state_usage might be more suitable, but that only if I'm convinced that this is really necessary. > > int (*enter) (struct cpuidle_device *dev, > struct cpuidle_driver *drv, > --