aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2017-12-09 23:22:46 -0500
committerOlof Johansson <olof@lixom.net>2017-12-09 23:22:46 -0500
commit3dda7f63e0e46db96b5373e740d03be2c44529c7 (patch)
tree4fa7be8d76b9342860127b776fa65854df86970f
parent69b8df5d6a4222fd6996227ae8ef60fe44db74fc (diff)
parentb69f63ebf553504739cc8534cbed31bd530c6f0b (diff)
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: Olof Johansson <olof@lixom.net>
-rw-r--r--drivers/bus/arm-cci.c7
-rw-r--r--drivers/bus/arm-ccn.c25
2 files changed, 20 insertions, 12 deletions
diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
index 3c29d36702a8..5426c04fe24b 100644
--- a/drivers/bus/arm-cci.c
+++ b/drivers/bus/arm-cci.c
@@ -1755,14 +1755,17 @@ static int cci_pmu_probe(struct platform_device *pdev)
1755 raw_spin_lock_init(&cci_pmu->hw_events.pmu_lock); 1755 raw_spin_lock_init(&cci_pmu->hw_events.pmu_lock);
1756 mutex_init(&cci_pmu->reserve_mutex); 1756 mutex_init(&cci_pmu->reserve_mutex);
1757 atomic_set(&cci_pmu->active_events, 0); 1757 atomic_set(&cci_pmu->active_events, 0);
1758 cpumask_set_cpu(smp_processor_id(), &cci_pmu->cpus); 1758 cpumask_set_cpu(get_cpu(), &cci_pmu->cpus);
1759 1759
1760 ret = cci_pmu_init(cci_pmu, pdev); 1760 ret = cci_pmu_init(cci_pmu, pdev);
1761 if (ret) 1761 if (ret) {
1762 put_cpu();
1762 return ret; 1763 return ret;
1764 }
1763 1765
1764 cpuhp_state_add_instance_nocalls(CPUHP_AP_PERF_ARM_CCI_ONLINE, 1766 cpuhp_state_add_instance_nocalls(CPUHP_AP_PERF_ARM_CCI_ONLINE,
1765 &cci_pmu->node); 1767 &cci_pmu->node);
1768 put_cpu();
1766 pr_info("ARM %s PMU driver probed", cci_pmu->model->name); 1769 pr_info("ARM %s PMU driver probed", cci_pmu->model->name);
1767 return 0; 1770 return 0;
1768} 1771}
diff --git a/drivers/bus/arm-ccn.c b/drivers/bus/arm-ccn.c
index 3063f5312397..b52332e52ca5 100644
--- a/drivers/bus/arm-ccn.c
+++ b/drivers/bus/arm-ccn.c
@@ -262,7 +262,7 @@ static struct attribute *arm_ccn_pmu_format_attrs[] = {
262 NULL 262 NULL
263}; 263};
264 264
265static struct attribute_group arm_ccn_pmu_format_attr_group = { 265static const struct attribute_group arm_ccn_pmu_format_attr_group = {
266 .name = "format", 266 .name = "format",
267 .attrs = arm_ccn_pmu_format_attrs, 267 .attrs = arm_ccn_pmu_format_attrs,
268}; 268};
@@ -451,7 +451,7 @@ static struct arm_ccn_pmu_event arm_ccn_pmu_events[] = {
451static struct attribute 451static struct attribute
452 *arm_ccn_pmu_events_attrs[ARRAY_SIZE(arm_ccn_pmu_events) + 1]; 452 *arm_ccn_pmu_events_attrs[ARRAY_SIZE(arm_ccn_pmu_events) + 1];
453 453
454static struct attribute_group arm_ccn_pmu_events_attr_group = { 454static const struct attribute_group arm_ccn_pmu_events_attr_group = {
455 .name = "events", 455 .name = "events",
456 .is_visible = arm_ccn_pmu_events_is_visible, 456 .is_visible = arm_ccn_pmu_events_is_visible,
457 .attrs = arm_ccn_pmu_events_attrs, 457 .attrs = arm_ccn_pmu_events_attrs,
@@ -548,7 +548,7 @@ static struct attribute *arm_ccn_pmu_cmp_mask_attrs[] = {
548 NULL 548 NULL
549}; 549};
550 550
551static struct attribute_group arm_ccn_pmu_cmp_mask_attr_group = { 551static const struct attribute_group arm_ccn_pmu_cmp_mask_attr_group = {
552 .name = "cmp_mask", 552 .name = "cmp_mask",
553 .attrs = arm_ccn_pmu_cmp_mask_attrs, 553 .attrs = arm_ccn_pmu_cmp_mask_attrs,
554}; 554};
@@ -569,7 +569,7 @@ static struct attribute *arm_ccn_pmu_cpumask_attrs[] = {
569 NULL, 569 NULL,
570}; 570};
571 571
572static struct attribute_group arm_ccn_pmu_cpumask_attr_group = { 572static const struct attribute_group arm_ccn_pmu_cpumask_attr_group = {
573 .attrs = arm_ccn_pmu_cpumask_attrs, 573 .attrs = arm_ccn_pmu_cpumask_attrs,
574}; 574};
575 575
@@ -1268,10 +1268,12 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn)
1268 if (ccn->dt.id == 0) { 1268 if (ccn->dt.id == 0) {
1269 name = "ccn"; 1269 name = "ccn";
1270 } else { 1270 } else {
1271 int len = snprintf(NULL, 0, "ccn_%d", ccn->dt.id); 1271 name = devm_kasprintf(ccn->dev, GFP_KERNEL, "ccn_%d",
1272 1272 ccn->dt.id);
1273 name = devm_kzalloc(ccn->dev, len + 1, GFP_KERNEL); 1273 if (!name) {
1274 snprintf(name, len + 1, "ccn_%d", ccn->dt.id); 1274 err = -ENOMEM;
1275 goto error_choose_name;
1276 }
1275 } 1277 }
1276 1278
1277 /* Perf driver registration */ 1279 /* Perf driver registration */
@@ -1298,7 +1300,7 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn)
1298 } 1300 }
1299 1301
1300 /* Pick one CPU which we will use to collect data from CCN... */ 1302 /* Pick one CPU which we will use to collect data from CCN... */
1301 cpumask_set_cpu(smp_processor_id(), &ccn->dt.cpu); 1303 cpumask_set_cpu(get_cpu(), &ccn->dt.cpu);
1302 1304
1303 /* Also make sure that the overflow interrupt is handled by this CPU */ 1305 /* Also make sure that the overflow interrupt is handled by this CPU */
1304 if (ccn->irq) { 1306 if (ccn->irq) {
@@ -1315,10 +1317,13 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn)
1315 1317
1316 cpuhp_state_add_instance_nocalls(CPUHP_AP_PERF_ARM_CCN_ONLINE, 1318 cpuhp_state_add_instance_nocalls(CPUHP_AP_PERF_ARM_CCN_ONLINE,
1317 &ccn->dt.node); 1319 &ccn->dt.node);
1320 put_cpu();
1318 return 0; 1321 return 0;
1319 1322
1320error_pmu_register: 1323error_pmu_register:
1321error_set_affinity: 1324error_set_affinity:
1325 put_cpu();
1326error_choose_name:
1322 ida_simple_remove(&arm_ccn_pmu_ida, ccn->dt.id); 1327 ida_simple_remove(&arm_ccn_pmu_ida, ccn->dt.id);
1323 for (i = 0; i < ccn->num_xps; i++) 1328 for (i = 0; i < ccn->num_xps; i++)
1324 writel(0, ccn->xp[i].base + CCN_XP_DT_CONTROL); 1329 writel(0, ccn->xp[i].base + CCN_XP_DT_CONTROL);
@@ -1581,8 +1586,8 @@ static int __init arm_ccn_init(void)
1581 1586
1582static void __exit arm_ccn_exit(void) 1587static void __exit arm_ccn_exit(void)
1583{ 1588{
1584 cpuhp_remove_multi_state(CPUHP_AP_PERF_ARM_CCN_ONLINE);
1585 platform_driver_unregister(&arm_ccn_driver); 1589 platform_driver_unregister(&arm_ccn_driver);
1590 cpuhp_remove_multi_state(CPUHP_AP_PERF_ARM_CCN_ONLINE);
1586} 1591}
1587 1592
1588module_init(arm_ccn_init); 1593module_init(arm_ccn_init);