mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-19 02:34:01 +08:00
powercap/intel_rapl: Add missing domain data update on hotplug
The domain data of packages is only updated at init time, but new packages created by hotplug miss that treatment. Add it there and remove the global update at init time, because it's now obsolete. The more interesting question is why rapl_update_domain_data() exists at all as nothing ever uses that data. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Jacob Pan <jacob.jun.pan@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
9c763584b7
commit
bed5ab6375
@ -1164,24 +1164,20 @@ static const struct x86_cpu_id rapl_ids[] __initconst = {
|
|||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(x86cpu, rapl_ids);
|
MODULE_DEVICE_TABLE(x86cpu, rapl_ids);
|
||||||
|
|
||||||
/* read once for all raw primitive data for all packages, domains */
|
/* Read once for all raw primitive data for domains */
|
||||||
static void rapl_update_domain_data(void)
|
static void rapl_update_domain_data(struct rapl_package *rp)
|
||||||
{
|
{
|
||||||
int dmn, prim;
|
int dmn, prim;
|
||||||
u64 val;
|
u64 val;
|
||||||
struct rapl_package *rp;
|
|
||||||
|
|
||||||
list_for_each_entry(rp, &rapl_packages, plist) {
|
for (dmn = 0; dmn < rp->nr_domains; dmn++) {
|
||||||
for (dmn = 0; dmn < rp->nr_domains; dmn++) {
|
pr_debug("update package %d domain %s data\n", rp->id,
|
||||||
pr_debug("update package %d domain %s data\n", rp->id,
|
rp->domains[dmn].name);
|
||||||
rp->domains[dmn].name);
|
/* exclude non-raw primitives */
|
||||||
/* exclude non-raw primitives */
|
for (prim = 0; prim < NR_RAW_PRIMITIVES; prim++) {
|
||||||
for (prim = 0; prim < NR_RAW_PRIMITIVES; prim++)
|
if (!rapl_read_data_raw(&rp->domains[dmn], prim,
|
||||||
if (!rapl_read_data_raw(&rp->domains[dmn], prim,
|
rpi[prim].unit, &val))
|
||||||
rpi[prim].unit,
|
rp->domains[dmn].rdd.primitives[prim] = val;
|
||||||
&val))
|
|
||||||
rp->domains[dmn].rdd.primitives[prim] =
|
|
||||||
val;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1234,10 +1230,12 @@ static int rapl_unregister_powercap(void)
|
|||||||
static int rapl_package_register_powercap(struct rapl_package *rp)
|
static int rapl_package_register_powercap(struct rapl_package *rp)
|
||||||
{
|
{
|
||||||
struct rapl_domain *rd;
|
struct rapl_domain *rd;
|
||||||
int ret = 0;
|
|
||||||
char dev_name[17]; /* max domain name = 7 + 1 + 8 for int + 1 for null*/
|
char dev_name[17]; /* max domain name = 7 + 1 + 8 for int + 1 for null*/
|
||||||
struct powercap_zone *power_zone = NULL;
|
struct powercap_zone *power_zone = NULL;
|
||||||
int nr_pl;
|
int nr_pl, ret;;
|
||||||
|
|
||||||
|
/* Update the domain data of the new package */
|
||||||
|
rapl_update_domain_data(rp);
|
||||||
|
|
||||||
/* first we register package domain as the parent zone*/
|
/* first we register package domain as the parent zone*/
|
||||||
for (rd = rp->domains; rd < rp->domains + rp->nr_domains; rd++) {
|
for (rd = rp->domains; rd < rp->domains + rp->nr_domains; rd++) {
|
||||||
@ -1257,8 +1255,7 @@ static int rapl_package_register_powercap(struct rapl_package *rp)
|
|||||||
if (IS_ERR(power_zone)) {
|
if (IS_ERR(power_zone)) {
|
||||||
pr_debug("failed to register package, %d\n",
|
pr_debug("failed to register package, %d\n",
|
||||||
rp->id);
|
rp->id);
|
||||||
ret = PTR_ERR(power_zone);
|
return PTR_ERR(power_zone);
|
||||||
goto exit_package;
|
|
||||||
}
|
}
|
||||||
/* track parent zone in per package/socket data */
|
/* track parent zone in per package/socket data */
|
||||||
rp->power_zone = power_zone;
|
rp->power_zone = power_zone;
|
||||||
@ -1268,8 +1265,7 @@ static int rapl_package_register_powercap(struct rapl_package *rp)
|
|||||||
}
|
}
|
||||||
if (!power_zone) {
|
if (!power_zone) {
|
||||||
pr_err("no package domain found, unknown topology!\n");
|
pr_err("no package domain found, unknown topology!\n");
|
||||||
ret = -ENODEV;
|
return -ENODEV;
|
||||||
goto exit_package;
|
|
||||||
}
|
}
|
||||||
/* now register domains as children of the socket/package*/
|
/* now register domains as children of the socket/package*/
|
||||||
for (rd = rp->domains; rd < rp->domains + rp->nr_domains; rd++) {
|
for (rd = rp->domains; rd < rp->domains + rp->nr_domains; rd++) {
|
||||||
@ -1290,9 +1286,8 @@ static int rapl_package_register_powercap(struct rapl_package *rp)
|
|||||||
goto err_cleanup;
|
goto err_cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
exit_package:
|
|
||||||
return ret;
|
|
||||||
err_cleanup:
|
err_cleanup:
|
||||||
/* clean up previously initialized domains within the package if we
|
/* clean up previously initialized domains within the package if we
|
||||||
* failed after the first domain setup.
|
* failed after the first domain setup.
|
||||||
@ -1357,8 +1352,7 @@ static int rapl_register_powercap(void)
|
|||||||
pr_debug("failed to register powercap control_type.\n");
|
pr_debug("failed to register powercap control_type.\n");
|
||||||
return PTR_ERR(control_type);
|
return PTR_ERR(control_type);
|
||||||
}
|
}
|
||||||
/* read the initial data */
|
|
||||||
rapl_update_domain_data();
|
|
||||||
list_for_each_entry(rp, &rapl_packages, plist)
|
list_for_each_entry(rp, &rapl_packages, plist)
|
||||||
if (rapl_package_register_powercap(rp))
|
if (rapl_package_register_powercap(rp))
|
||||||
goto err_cleanup_package;
|
goto err_cleanup_package;
|
||||||
|
Loading…
Reference in New Issue
Block a user