From: Naveen Krishna Chatradhi <nchatrad@amd.com>
To: linux-hwmon@vger.kernel.org
Cc: linux@roeck-us.net, Akshay Gupta <Akshay.Gupta@amd.com>
Subject: [PATCH 1/6] hwmon: amd_energy: Move label out of accumulation structure
Date: Sat, 5 Sep 2020 20:02:25 +0530 [thread overview]
Message-ID: <20200905143230.195049-2-nchatrad@amd.com> (raw)
In-Reply-To: <20200905143230.195049-1-nchatrad@amd.com>
From: Akshay Gupta <Akshay.Gupta@amd.com>
At present, core & socket labels are defined in struct sensor_accumulator
This patch moves it to the amd_energy_data structure, which will
help in calling memset on struct sensor_accumulator to optimize the code.
Signed-off-by: Akshay Gupta <Akshay.Gupta@amd.com>
---
drivers/hwmon/amd_energy.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/hwmon/amd_energy.c b/drivers/hwmon/amd_energy.c
index 29603742c858..9580a16185b8 100644
--- a/drivers/hwmon/amd_energy.c
+++ b/drivers/hwmon/amd_energy.c
@@ -35,7 +35,6 @@
struct sensor_accumulator {
u64 energy_ctr;
u64 prev_value;
- char label[10];
};
struct amd_energy_data {
@@ -52,6 +51,7 @@ struct amd_energy_data {
int nr_cpus;
int nr_socks;
int core_id;
+ char (*label)[10];
};
static int amd_energy_read_labels(struct device *dev,
@@ -61,7 +61,7 @@ static int amd_energy_read_labels(struct device *dev,
{
struct amd_energy_data *data = dev_get_drvdata(dev);
- *str = data->accums[channel].label;
+ *str = data->label[channel];
return 0;
}
@@ -253,6 +253,7 @@ static int amd_create_sensor(struct device *dev,
struct sensor_accumulator *accums;
int i, num_siblings, cpus, sockets;
u32 *s_config;
+ char (*label_l)[10];
/* Identify the number of siblings per core */
num_siblings = ((cpuid_ebx(0x8000001e) >> 8) & 0xff) + 1;
@@ -276,21 +277,25 @@ static int amd_create_sensor(struct device *dev,
if (!accums)
return -ENOMEM;
+ label_l = devm_kcalloc(dev, cpus + sockets,
+ sizeof(*label_l), GFP_KERNEL);
+ if (!label_l)
+ return -ENOMEM;
+
info->type = type;
info->config = s_config;
data->nr_cpus = cpus;
data->nr_socks = sockets;
data->accums = accums;
+ data->label = label_l;
for (i = 0; i < cpus + sockets; i++) {
s_config[i] = config;
if (i < cpus)
- scnprintf(accums[i].label, 10,
- "Ecore%03u", i);
+ scnprintf(label_l[i], 10, "Ecore%03u", i);
else
- scnprintf(accums[i].label, 10,
- "Esocket%u", (i - cpus));
+ scnprintf(label_l[i], 10, "Esocket%u", (i - cpus));
}
return 0;
--
2.26.2
next prev parent reply other threads:[~2020-09-05 14:32 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-05 14:32 [PATCH 0/6] RFC: hwmon: few improvements to amd_energy driver Naveen Krishna Chatradhi
2020-09-05 14:32 ` Naveen Krishna Chatradhi [this message]
2020-09-05 14:32 ` [PATCH 2/6] hwmon: amd_energy: optimize accumulation interval Naveen Krishna Chatradhi
2020-09-05 15:11 ` Guenter Roeck
[not found] ` <DM6PR12MB4388DCF9B42BA0093774606FE82A0@DM6PR12MB4388.namprd12.prod.outlook.com>
2020-09-05 16:27 ` Naveen Krishna Ch
2020-09-05 14:32 ` [PATCH 3/6] hwmon: amd_energy: Improve the accumulation logic Naveen Krishna Chatradhi
2020-09-05 15:14 ` Guenter Roeck
[not found] ` <DM6PR12MB438850F9DFD14163F11AA946E82A0@DM6PR12MB4388.namprd12.prod.outlook.com>
2020-09-05 16:31 ` FW: " Naveen Krishna Ch
2020-09-05 14:32 ` [PATCH 4/6] hwmon: amd_energy: let user enable/disable the sw accumulation Naveen Krishna Chatradhi
2020-09-05 15:17 ` Guenter Roeck
2020-09-05 15:33 ` Guenter Roeck
[not found] ` <DM6PR12MB4388A21B749811BBE1309AA3E8290@DM6PR12MB4388.namprd12.prod.outlook.com>
2020-09-08 16:21 ` FW: " Naveen Krishna Ch
2020-09-08 16:36 ` Guenter Roeck
2020-09-05 14:32 ` [PATCH 5/6] hwmon: amd_energy: dump energy counters via debugfs Naveen Krishna Chatradhi
2020-09-05 15:19 ` Guenter Roeck
[not found] ` <DM6PR12MB4388C77E35BD61F4DC2EAEC9E82A0@DM6PR12MB4388.namprd12.prod.outlook.com>
2020-09-05 16:41 ` FW: " Naveen Krishna Ch
2020-09-05 16:58 ` Guenter Roeck
2020-09-08 16:10 ` Naveen Krishna Ch
2020-09-08 16:34 ` Guenter Roeck
2020-09-08 16:46 ` Naveen Krishna Ch
2020-09-08 17:11 ` Guenter Roeck
2020-09-25 7:23 ` Chatradhi, Naveen Krishna
2020-09-05 14:32 ` [PATCH 6/6] hwmon: (amd_energy) Update driver documentation Naveen Krishna Chatradhi
2020-09-25 7:26 ` [PATCH 0/6] RFC: hwmon: few improvements to amd_energy driver Chatradhi, Naveen Krishna
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=20200905143230.195049-2-nchatrad@amd.com \
--to=nchatrad@amd.com \
--cc=Akshay.Gupta@amd.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux@roeck-us.net \
/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