mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-pm@vger.kernel.org,
	Vincent Guittot <vincent.guittot@linaro.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 01/33] cpufreq: Always create freq-table related sysfs file
Date: Thu, 23 Jan 2025 17:05:37 +0530	[thread overview]
Message-ID: <22b68afa4ce5a0a2e77bb3a08e1cb7ac75f70f72.1737631669.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1737631669.git.viresh.kumar@linaro.org>

Currently it is left for the individual drivers to set the available and
boost frequencies related attributes in the cpufreq_driver->attr field.
Some drivers provide them, while others don't.

A quick search revealed that only the drivers that set the
policy->freq_table field, enable these attributes. Which makes sense as
well, since the show_available_freqs() helper works only if the
freq_table is present.

In order to simplify drivers, create the relevant sysfs files forcefully
from cpufreq core.

For now, skip adding them twice. This can be removed once all the
drivers are updated.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 1a4cae54a01b..973bd6e4bdd4 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1058,9 +1058,31 @@ static int cpufreq_add_dev_interface(struct cpufreq_policy *policy)
 	struct freq_attr **drv_attr;
 	int ret = 0;
 
+	/* Attributes that need freq_table */
+	if (policy->freq_table) {
+		ret = sysfs_create_file(&policy->kobj,
+				&cpufreq_freq_attr_scaling_available_freqs.attr);
+		if (ret)
+			return ret;
+
+		if (cpufreq_boost_supported()) {
+			ret = sysfs_create_file(&policy->kobj,
+				&cpufreq_freq_attr_scaling_boost_freqs.attr);
+			if (ret)
+				return ret;
+		}
+	}
+
 	/* set up files for this cpu device */
 	drv_attr = cpufreq_driver->attr;
 	while (drv_attr && *drv_attr) {
+		/* These are already added, skip them */
+		if (*drv_attr == &cpufreq_freq_attr_scaling_available_freqs ||
+		    *drv_attr == &cpufreq_freq_attr_scaling_boost_freqs) {
+			drv_attr++;
+			continue;
+		}
+
 		ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr));
 		if (ret)
 			return ret;
-- 
2.31.1.272.g89b43f80a514


  reply	other threads:[~2025-01-23 11:38 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-23 11:35 [PATCH 00/33] cpufreq: manage common sysfs attributes from core Viresh Kumar
2025-01-23 11:35 ` Viresh Kumar [this message]
2025-01-23 19:39   ` [PATCH 01/33] cpufreq: Always create freq-table related sysfs file Rafael J. Wysocki
2025-01-23 11:35 ` [PATCH 02/33] cpufreq: dt: Stop setting cpufreq_driver->attr field Viresh Kumar
2025-01-23 11:35 ` [PATCH 03/33] cpufreq: acpi: Stop setting common freq attributes Viresh Kumar
2025-01-23 11:35 ` [PATCH 04/33] cpufreq: apple: Stop setting cpufreq_driver->attr field Viresh Kumar
2025-01-23 11:35 ` [PATCH 05/33] cpufreq: bmips: " Viresh Kumar
2025-01-23 20:27   ` Florian Fainelli
2025-01-23 11:35 ` [PATCH 06/33] cpufreq: brcmstb: Stop setting common freq attributes Viresh Kumar
2025-01-23 20:27   ` Florian Fainelli
2025-01-23 11:35 ` [PATCH 07/33] cpufreq: davinci: Stop setting cpufreq_driver->attr field Viresh Kumar
2025-01-23 11:35 ` [PATCH 08/33] cpufreq: e_powersaver: " Viresh Kumar
2025-01-23 11:35 ` [PATCH 09/33] cpufreq: elanfreq: " Viresh Kumar
2025-01-23 11:35 ` [PATCH 10/33] cpufreq: imx6q: " Viresh Kumar
2025-01-23 11:35 ` [PATCH 11/33] cpufreq: kirkwood: " Viresh Kumar
2025-01-23 11:35 ` [PATCH 12/33] cpufreq: longhaul: " Viresh Kumar
2025-01-23 11:35 ` [PATCH 13/33] cpufreq: loongson: " Viresh Kumar
2025-01-23 11:35 ` [PATCH 14/33] cpufreq: mediatek: " Viresh Kumar
2025-01-23 11:35 ` [PATCH 15/33] cpufreq: omap: " Viresh Kumar
2025-01-23 11:35 ` [PATCH 16/33] cpufreq: p4: " Viresh Kumar
2025-01-23 11:35 ` [PATCH 17/33] cpufreq: pasemi: " Viresh Kumar
2025-01-23 11:35 ` [PATCH 18/33] cpufreq: pmac: " Viresh Kumar
2025-01-23 11:35 ` [PATCH 19/33] cpufreq: powernow: " Viresh Kumar
2025-01-23 11:35 ` [PATCH 20/33] cpufreq: powernv: Stop setting common freq attributes Viresh Kumar
2025-02-03  9:53   ` [PATCH V1.1 " Viresh Kumar
2025-01-23 11:35 ` [PATCH 21/33] cpufreq: qcom: Stop setting cpufreq_driver->attr field Viresh Kumar
2025-01-23 11:35 ` [PATCH 22/33] cpufreq: qoriq: " Viresh Kumar
2025-01-23 11:35 ` [PATCH 23/33] cpufreq: sc520_freq: " Viresh Kumar
2025-01-23 11:36 ` [PATCH 24/33] cpufreq: scmi: " Viresh Kumar
2025-01-23 12:01   ` Sudeep Holla
2025-01-24  3:37     ` Viresh Kumar
2025-01-23 11:36 ` [PATCH 25/33] cpufreq: scpi: " Viresh Kumar
2025-01-23 11:52   ` Sudeep Holla
2025-01-23 11:36 ` [PATCH 26/33] cpufreq: sh: " Viresh Kumar
2025-01-23 11:36 ` [PATCH 27/33] cpufreq: spear: " Viresh Kumar
2025-01-23 11:36 ` [PATCH 28/33] cpufreq: speedstep: " Viresh Kumar
2025-01-23 11:36 ` [PATCH 29/33] cpufreq: tegra: " Viresh Kumar
2025-01-23 11:36 ` [PATCH 30/33] cpufreq: vexpress: " Viresh Kumar
2025-01-23 11:50   ` Sudeep Holla
2025-01-23 11:36 ` [PATCH 31/33] cpufreq: virtual: " Viresh Kumar
2025-01-23 11:36 ` [PATCH 32/33] cpufreq: Remove cpufreq_generic_attrs Viresh Kumar
2025-01-23 11:36 ` [PATCH 33/33] cpufreq: Stop checking for duplicate available/boost freq attributes Viresh Kumar
2025-01-23 19:40 ` [PATCH 00/33] cpufreq: manage common sysfs attributes from core Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=22b68afa4ce5a0a2e77bb3a08e1cb7ac75f70f72.1737631669.git.viresh.kumar@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®