31
31
#define MSR_VR_CURRENT_CONFIG 0x00000601
32
32
33
33
/* private data for RAPL MSR Interface */
34
- static struct rapl_if_priv rapl_msr_priv = {
34
+ static struct rapl_if_priv * rapl_msr_priv ;
35
+
36
+ static struct rapl_if_priv rapl_msr_priv_intel = {
35
37
.reg_unit = MSR_RAPL_POWER_UNIT ,
36
38
.regs [RAPL_DOMAIN_PACKAGE ] = {
37
39
MSR_PKG_POWER_LIMIT , MSR_PKG_ENERGY_STATUS , MSR_PKG_PERF_STATUS , 0 , MSR_PKG_POWER_INFO },
@@ -58,9 +60,9 @@ static int rapl_cpu_online(unsigned int cpu)
58
60
{
59
61
struct rapl_package * rp ;
60
62
61
- rp = rapl_find_package_domain (cpu , & rapl_msr_priv );
63
+ rp = rapl_find_package_domain (cpu , rapl_msr_priv );
62
64
if (!rp ) {
63
- rp = rapl_add_package (cpu , & rapl_msr_priv );
65
+ rp = rapl_add_package (cpu , rapl_msr_priv );
64
66
if (IS_ERR (rp ))
65
67
return PTR_ERR (rp );
66
68
}
@@ -73,7 +75,7 @@ static int rapl_cpu_down_prep(unsigned int cpu)
73
75
struct rapl_package * rp ;
74
76
int lead_cpu ;
75
77
76
- rp = rapl_find_package_domain (cpu , & rapl_msr_priv );
78
+ rp = rapl_find_package_domain (cpu , rapl_msr_priv );
77
79
if (!rp )
78
80
return 0 ;
79
81
@@ -136,40 +138,41 @@ static int rapl_msr_probe(struct platform_device *pdev)
136
138
const struct x86_cpu_id * id = x86_match_cpu (pl4_support_ids );
137
139
int ret ;
138
140
139
- rapl_msr_priv .read_raw = rapl_msr_read_raw ;
140
- rapl_msr_priv .write_raw = rapl_msr_write_raw ;
141
+ rapl_msr_priv = & rapl_msr_priv_intel ;
142
+ rapl_msr_priv -> read_raw = rapl_msr_read_raw ;
143
+ rapl_msr_priv -> write_raw = rapl_msr_write_raw ;
141
144
142
145
if (id ) {
143
- rapl_msr_priv . limits [RAPL_DOMAIN_PACKAGE ] = 3 ;
144
- rapl_msr_priv . regs [RAPL_DOMAIN_PACKAGE ][RAPL_DOMAIN_REG_PL4 ] =
146
+ rapl_msr_priv -> limits [RAPL_DOMAIN_PACKAGE ] = 3 ;
147
+ rapl_msr_priv -> regs [RAPL_DOMAIN_PACKAGE ][RAPL_DOMAIN_REG_PL4 ] =
145
148
MSR_VR_CURRENT_CONFIG ;
146
149
pr_info ("PL4 support detected.\n" );
147
150
}
148
151
149
- rapl_msr_priv . control_type = powercap_register_control_type (NULL , "intel-rapl" , NULL );
150
- if (IS_ERR (rapl_msr_priv . control_type )) {
152
+ rapl_msr_priv -> control_type = powercap_register_control_type (NULL , "intel-rapl" , NULL );
153
+ if (IS_ERR (rapl_msr_priv -> control_type )) {
151
154
pr_debug ("failed to register powercap control_type.\n" );
152
- return PTR_ERR (rapl_msr_priv . control_type );
155
+ return PTR_ERR (rapl_msr_priv -> control_type );
153
156
}
154
157
155
158
ret = cpuhp_setup_state (CPUHP_AP_ONLINE_DYN , "powercap/rapl:online" ,
156
159
rapl_cpu_online , rapl_cpu_down_prep );
157
160
if (ret < 0 )
158
161
goto out ;
159
- rapl_msr_priv . pcap_rapl_online = ret ;
162
+ rapl_msr_priv -> pcap_rapl_online = ret ;
160
163
161
164
return 0 ;
162
165
163
166
out :
164
167
if (ret )
165
- powercap_unregister_control_type (rapl_msr_priv . control_type );
168
+ powercap_unregister_control_type (rapl_msr_priv -> control_type );
166
169
return ret ;
167
170
}
168
171
169
172
static int rapl_msr_remove (struct platform_device * pdev )
170
173
{
171
- cpuhp_remove_state (rapl_msr_priv . pcap_rapl_online );
172
- powercap_unregister_control_type (rapl_msr_priv . control_type );
174
+ cpuhp_remove_state (rapl_msr_priv -> pcap_rapl_online );
175
+ powercap_unregister_control_type (rapl_msr_priv -> control_type );
173
176
return 0 ;
174
177
}
175
178
0 commit comments