Commit 3dda7f63 authored by Olof Johansson's avatar Olof Johansson

Merge tag 'ccn/fixes-for-4.15' of git://git.linaro.org/people/pawel.moll/linux into fixes

bus: ARM CCN and CCI PMU driver fixes

This is a bunch of fixes CCN and (guest starring this time) CCI drivers.

* Check for potential of failed allocation for the driver name string
* Manage CPU ID properly at allocation (both CCN and CCI)
* Fix module unload warnings related to objects release order
* Small improvements like using allocating printfs and proper
  attributes constification

The one fixing potential issues have been cc-ed to stable.

* tag 'ccn/fixes-for-4.15' of git://git.linaro.org/people/pawel.moll/linux:
  bus: arm-ccn: fix module unloading Error: Removing state 147 which has instances left.
  bus: arm-cci: Fix use of smp_processor_id() in preemptible context
  bus: arm-ccn: Fix use of smp_processor_id() in preemptible context
  bus: arm-ccn: Simplify code
  bus: arm-ccn: Check memory allocation failure
  bus: arm-ccn: constify attribute_group structures.
Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
parents 69b8df5d b69f63eb
...@@ -1755,14 +1755,17 @@ static int cci_pmu_probe(struct platform_device *pdev) ...@@ -1755,14 +1755,17 @@ static int cci_pmu_probe(struct platform_device *pdev)
raw_spin_lock_init(&cci_pmu->hw_events.pmu_lock); raw_spin_lock_init(&cci_pmu->hw_events.pmu_lock);
mutex_init(&cci_pmu->reserve_mutex); mutex_init(&cci_pmu->reserve_mutex);
atomic_set(&cci_pmu->active_events, 0); atomic_set(&cci_pmu->active_events, 0);
cpumask_set_cpu(smp_processor_id(), &cci_pmu->cpus); cpumask_set_cpu(get_cpu(), &cci_pmu->cpus);
ret = cci_pmu_init(cci_pmu, pdev); ret = cci_pmu_init(cci_pmu, pdev);
if (ret) if (ret) {
put_cpu();
return ret; return ret;
}
cpuhp_state_add_instance_nocalls(CPUHP_AP_PERF_ARM_CCI_ONLINE, cpuhp_state_add_instance_nocalls(CPUHP_AP_PERF_ARM_CCI_ONLINE,
&cci_pmu->node); &cci_pmu->node);
put_cpu();
pr_info("ARM %s PMU driver probed", cci_pmu->model->name); pr_info("ARM %s PMU driver probed", cci_pmu->model->name);
return 0; return 0;
} }
......
...@@ -262,7 +262,7 @@ static struct attribute *arm_ccn_pmu_format_attrs[] = { ...@@ -262,7 +262,7 @@ static struct attribute *arm_ccn_pmu_format_attrs[] = {
NULL NULL
}; };
static struct attribute_group arm_ccn_pmu_format_attr_group = { static const struct attribute_group arm_ccn_pmu_format_attr_group = {
.name = "format", .name = "format",
.attrs = arm_ccn_pmu_format_attrs, .attrs = arm_ccn_pmu_format_attrs,
}; };
...@@ -451,7 +451,7 @@ static struct arm_ccn_pmu_event arm_ccn_pmu_events[] = { ...@@ -451,7 +451,7 @@ static struct arm_ccn_pmu_event arm_ccn_pmu_events[] = {
static struct attribute static struct attribute
*arm_ccn_pmu_events_attrs[ARRAY_SIZE(arm_ccn_pmu_events) + 1]; *arm_ccn_pmu_events_attrs[ARRAY_SIZE(arm_ccn_pmu_events) + 1];
static struct attribute_group arm_ccn_pmu_events_attr_group = { static const struct attribute_group arm_ccn_pmu_events_attr_group = {
.name = "events", .name = "events",
.is_visible = arm_ccn_pmu_events_is_visible, .is_visible = arm_ccn_pmu_events_is_visible,
.attrs = arm_ccn_pmu_events_attrs, .attrs = arm_ccn_pmu_events_attrs,
...@@ -548,7 +548,7 @@ static struct attribute *arm_ccn_pmu_cmp_mask_attrs[] = { ...@@ -548,7 +548,7 @@ static struct attribute *arm_ccn_pmu_cmp_mask_attrs[] = {
NULL NULL
}; };
static struct attribute_group arm_ccn_pmu_cmp_mask_attr_group = { static const struct attribute_group arm_ccn_pmu_cmp_mask_attr_group = {
.name = "cmp_mask", .name = "cmp_mask",
.attrs = arm_ccn_pmu_cmp_mask_attrs, .attrs = arm_ccn_pmu_cmp_mask_attrs,
}; };
...@@ -569,7 +569,7 @@ static struct attribute *arm_ccn_pmu_cpumask_attrs[] = { ...@@ -569,7 +569,7 @@ static struct attribute *arm_ccn_pmu_cpumask_attrs[] = {
NULL, NULL,
}; };
static struct attribute_group arm_ccn_pmu_cpumask_attr_group = { static const struct attribute_group arm_ccn_pmu_cpumask_attr_group = {
.attrs = arm_ccn_pmu_cpumask_attrs, .attrs = arm_ccn_pmu_cpumask_attrs,
}; };
...@@ -1268,10 +1268,12 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn) ...@@ -1268,10 +1268,12 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn)
if (ccn->dt.id == 0) { if (ccn->dt.id == 0) {
name = "ccn"; name = "ccn";
} else { } else {
int len = snprintf(NULL, 0, "ccn_%d", ccn->dt.id); name = devm_kasprintf(ccn->dev, GFP_KERNEL, "ccn_%d",
ccn->dt.id);
name = devm_kzalloc(ccn->dev, len + 1, GFP_KERNEL); if (!name) {
snprintf(name, len + 1, "ccn_%d", ccn->dt.id); err = -ENOMEM;
goto error_choose_name;
}
} }
/* Perf driver registration */ /* Perf driver registration */
...@@ -1298,7 +1300,7 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn) ...@@ -1298,7 +1300,7 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn)
} }
/* Pick one CPU which we will use to collect data from CCN... */ /* Pick one CPU which we will use to collect data from CCN... */
cpumask_set_cpu(smp_processor_id(), &ccn->dt.cpu); cpumask_set_cpu(get_cpu(), &ccn->dt.cpu);
/* Also make sure that the overflow interrupt is handled by this CPU */ /* Also make sure that the overflow interrupt is handled by this CPU */
if (ccn->irq) { if (ccn->irq) {
...@@ -1315,10 +1317,13 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn) ...@@ -1315,10 +1317,13 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn)
cpuhp_state_add_instance_nocalls(CPUHP_AP_PERF_ARM_CCN_ONLINE, cpuhp_state_add_instance_nocalls(CPUHP_AP_PERF_ARM_CCN_ONLINE,
&ccn->dt.node); &ccn->dt.node);
put_cpu();
return 0; return 0;
error_pmu_register: error_pmu_register:
error_set_affinity: error_set_affinity:
put_cpu();
error_choose_name:
ida_simple_remove(&arm_ccn_pmu_ida, ccn->dt.id); ida_simple_remove(&arm_ccn_pmu_ida, ccn->dt.id);
for (i = 0; i < ccn->num_xps; i++) for (i = 0; i < ccn->num_xps; i++)
writel(0, ccn->xp[i].base + CCN_XP_DT_CONTROL); writel(0, ccn->xp[i].base + CCN_XP_DT_CONTROL);
...@@ -1581,8 +1586,8 @@ static int __init arm_ccn_init(void) ...@@ -1581,8 +1586,8 @@ static int __init arm_ccn_init(void)
static void __exit arm_ccn_exit(void) static void __exit arm_ccn_exit(void)
{ {
cpuhp_remove_multi_state(CPUHP_AP_PERF_ARM_CCN_ONLINE);
platform_driver_unregister(&arm_ccn_driver); platform_driver_unregister(&arm_ccn_driver);
cpuhp_remove_multi_state(CPUHP_AP_PERF_ARM_CCN_ONLINE);
} }
module_init(arm_ccn_init); module_init(arm_ccn_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment