pm_save_enable is a global module parameter used as a user input, but at the same time is modified on probe. There are some theoretical scenarios where the DT for one device says to save and another says not to which result in one device not allocating save state memory but later trying to save if probing happens in a certain order. We also couldn't warn if the module parameter is used for ETE because the input value is overwritten, then for the next device it looks like the user had set a value triggering a warning.
Fix it by treating the module parameter strictly as user input and adding a new per device pm_save boolean, and then add the warning that couldn't be added before.
Signed-off-by: James Clark james.clark@linaro.org --- drivers/hwtracing/coresight/coresight-etm4x-core.c | 22 ++++++++++++++++------ drivers/hwtracing/coresight/coresight-etm4x.h | 1 + 2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c index a7fb680dd383..915f348620d8 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -1366,20 +1366,30 @@ static void etm4_fixup_wrong_ccitmin(struct etmv4_drvdata *drvdata) } }
+/* + * Take the global pm_save_enable module argument and setup the CPU PM save + * setting for this device. + */ static int etm4_init_pm_save(struct device *dev, struct etmv4_drvdata *drvdata) { if (etm4x_is_ete(drvdata)) { + if (pm_save_enable) + dev_warn_once(dev, "pm_save_enable module option is only for ETM4\n"); + /* * Always do PM save for ETE. It always uses system registers * which will be lost on CPU power down. */ - pm_save_enable = PARAM_PM_SAVE_SELF_HOSTED; + drvdata->pm_save = true; } else if (pm_save_enable == PARAM_PM_SAVE_FIRMWARE) { - pm_save_enable = coresight_loses_context_with_cpu(dev) ? - PARAM_PM_SAVE_SELF_HOSTED : PARAM_PM_SAVE_NEVER; + drvdata->pm_save = coresight_loses_context_with_cpu(dev); + } else if (pm_save_enable == PARAM_PM_SAVE_SELF_HOSTED) { + drvdata->pm_save = true; + } else { + drvdata->pm_save = false; }
- if (pm_save_enable != PARAM_PM_SAVE_NEVER) { + if (drvdata->pm_save) { drvdata->save_state = devm_kmalloc(dev, sizeof(struct etmv4_save_state), GFP_KERNEL); @@ -2037,7 +2047,7 @@ static int etm4_cpu_save(struct etmv4_drvdata *drvdata) { int ret = 0;
- if (pm_save_enable != PARAM_PM_SAVE_SELF_HOSTED) + if (!drvdata->pm_save) return 0;
/* @@ -2152,7 +2162,7 @@ static void __etm4_cpu_restore(struct etmv4_drvdata *drvdata)
static void etm4_cpu_restore(struct etmv4_drvdata *drvdata) { - if (pm_save_enable != PARAM_PM_SAVE_SELF_HOSTED) + if (!drvdata->pm_save) return;
if (coresight_get_mode(drvdata->csdev)) diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtracing/coresight/coresight-etm4x.h index 89d81ce4e04e..6472677f3098 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -1078,6 +1078,7 @@ struct etmv4_drvdata { bool lpoverride : 1; bool skip_power_up : 1; bool paused : 1; + bool pm_save : 1; u64 trfcr; struct etmv4_config config; struct etmv4_save_state *save_state;