Skip to contentSkip to conversation

powercap: RAPL: Add Power Limit4 support for Meteor Lake SoC

PATCH Applied Sumeet Pawnikar 4 participants 5 messages Feb 15, 2023 – May 18, 2023 Power management core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powercap: RAPL: Add Power Limit4 support for Meteor Lake SoC

Add Meteor Lake SoC to the list of processor models for which Power Limit4 is supported by the Intel RAPL driver.

---
 drivers/powercap/intel_rapl_msr.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/powercap/intel_rapl_msr.c +2 -0
index bc6adda58883..a27673706c3d 100644
@@ -143,6 +143,8 @@ static const struct x86_cpu_id pl4_support_ids[] = {
 	{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ALDERLAKE_N, X86_FEATURE_ANY },
 	{ X86_VENDOR_INTEL, 6, INTEL_FAM6_RAPTORLAKE, X86_FEATURE_ANY },
 	{ X86_VENDOR_INTEL, 6, INTEL_FAM6_RAPTORLAKE_P, X86_FEATURE_ANY },
+	{ X86_VENDOR_INTEL, 6, INTEL_FAM6_METEORLAKE, X86_FEATURE_ANY },
+	{ X86_VENDOR_INTEL, 6, INTEL_FAM6_METEORLAKE_L, X86_FEATURE_ANY },
 	{}
 };
 
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw
Quoted 14 lines · Sumeet Pawnikar

Add Meteor Lake SoC to the list of processor models for which Power Limit4 is supported by the Intel RAPL driver.

---
 drivers/powercap/intel_rapl_msr.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/powercap/intel_rapl_msr.c +0 -0
index bc6adda58883..a27673706c3d 100644

drivers/powercap/intel_rapl_msr.c static const struct x86_cpu_id pl4_support_ids[] = {

Quoted 9 lines
drivers/powercap/intel_rapl_msr.c +2 -1
@@ -143,6 +143,8 @@ static const struct x86_cpu_id pl4_support_ids[] = {
        { X86_VENDOR_INTEL, 6, INTEL_FAM6_ALDERLAKE_N, X86_FEATURE_ANY },
        { X86_VENDOR_INTEL, 6, INTEL_FAM6_RAPTORLAKE, X86_FEATURE_ANY },
        { X86_VENDOR_INTEL, 6, INTEL_FAM6_RAPTORLAKE_P, X86_FEATURE_ANY },
+       { X86_VENDOR_INTEL, 6, INTEL_FAM6_METEORLAKE, X86_FEATURE_ANY },
+       { X86_VENDOR_INTEL, 6, INTEL_FAM6_METEORLAKE_L, X86_FEATURE_ANY },
        {}
 };
 
--

Applied as 6.3-rc material, thanks!

#2 lore raw
In reply to Sumeet Pawnikar

drivers/powercap/intel_rapl_msr.c static const struct x86_cpu_id pl4_support_ids[] = { · line 149

Quoted 12 lines · Sumeet Pawnikar
drivers/powercap/intel_rapl_msr.c +2 -0
index bc6adda58883..a27673706c3d 100644
@@ -143,6 +143,8 @@ static const struct x86_cpu_id pl4_support_ids[] = {
 	{ X86_VENDOR_INTEL, 6, INTEL_FAM6_ALDERLAKE_N, X86_FEATURE_ANY },
 	{ X86_VENDOR_INTEL, 6, INTEL_FAM6_RAPTORLAKE, X86_FEATURE_ANY },
 	{ X86_VENDOR_INTEL, 6, INTEL_FAM6_RAPTORLAKE_P, X86_FEATURE_ANY },
+	{ X86_VENDOR_INTEL, 6, INTEL_FAM6_METEORLAKE, X86_FEATURE_ANY },
+	{ X86_VENDOR_INTEL, 6, INTEL_FAM6_METEORLAKE_L, X86_FEATURE_ANY },
 	{}
 };

Sumeet, could you _please_ go take a close look at 'struct x86_cpu_id'?

Quoted 8 lines
drivers/powercap/intel_rapl_msr.c +0 -0
 struct x86_cpu_id {
        __u16 vendor;
        __u16 family;
        __u16 model;
        __u16 steppings;
        __u16 feature;  /* bit index */
        kernel_ulong_t driver_data;
};

You might also want to very carefully count the fields in the structure.
Which field is being initialized to X86_FEATURE_ANY? Is it:

a. ->feature
b. ->steppings
c. ->model

How could this _possibly_ work, you ask yourself? Well, you lucked out:

#define X86_FAMILY_ANY 0
#define X86_MODEL_ANY 0
#define X86_STEPPING_ANY 0
#define X86_FEATURE_ANY 0

so, you actually accidentally *explicitly* specified a 0 for ->steppings *AND* accidentally *implicitly* specified a 0 for ->feature.

... and you did this in at least five separate commits over four years.

Why does this matter? Because some hapless maintainer might take your code, copy it, and then s/X86_FEATURE_ANY/X86_FEATURE_FOO/ and then scratch their head for an hour as to why it doesn't work.

Could you please fix this up? As penance, you could even fix the _ANY defines so that people can't do this accidentally any longer.

#3 lore raw
Quoted 2 lines · Dave Hansen

Could you please fix this up? As penance, you could even fix the _ANY defines so that people can't do this accidentally any longer.

See the X86_MATCH_INTEL_FAM6_MODEL() for how to do this right.

-Tony

#4 lore raw
Quoted 12 lines

-----Original Message-----
From: Luck, Tony <[email protected]>
Sent: Thursday, May 11, 2023 10:15 PM
To: Hansen, Dave <[email protected]>
Cc: Pawnikar, Sumeet R <[email protected]>; [email protected]; [email protected]; Zhang, Rui <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] powercap: RAPL: Add Power Limit4 support for Meteor Lake SoC

Quoted 6 lines
Quoted 2 lines · Dave Hansen

Could you please fix this up? As penance, you could even fix the _ANY defines so that people can't do this accidentally any longer.

See the X86_MATCH_INTEL_FAM6_MODEL() for how to do this right.

Thanks Dave and Tony for this information.
Let me check and submit the fix for this.

Regards,
Sumeet.

Quoted 1 line

-Tony