Skip to content

Commit 9780732

Browse files
Zhou Wangwilldeacon
authored andcommitted
drivers/perf: hisi: Permit modular builds of HiSilicon uncore drivers
This patch lets HiSilicon uncore PMU driver can be built as modules. A common module and three specific uncore PMU driver modules will be built. Export necessary functions in hisi_uncore_pmu module, and change irq_set_affinity to irq_set_affinity_hint to pass compile. Signed-off-by: Zhou Wang <[email protected]> Tested-by: Qi Liu <[email protected]> Reviewed-by: Shaokun Zhang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 88562f0 commit 9780732

File tree

7 files changed

+50
-22
lines changed

7 files changed

+50
-22
lines changed

drivers/perf/Kconfig

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,6 @@ config FSL_IMX8_DDR_PMU
7979
can give information about memory throughput and other related
8080
events.
8181

82-
config HISI_PMU
83-
bool "HiSilicon SoC PMU"
84-
depends on ARM64 && ACPI
85-
help
86-
Support for HiSilicon SoC uncore performance monitoring
87-
unit (PMU), such as: L3C, HHA and DDRC.
88-
8982
config QCOM_L2_PMU
9083
bool "Qualcomm Technologies L2-cache PMU"
9184
depends on ARCH_QCOM && ARM64 && ACPI
@@ -129,4 +122,6 @@ config ARM_SPE_PMU
129122
Extension, which provides periodic sampling of operations in
130123
the CPU pipeline and reports this via the perf AUX interface.
131124

125+
source "drivers/perf/hisilicon/Kconfig"
126+
132127
endmenu

drivers/perf/hisilicon/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
config HISI_PMU
3+
tristate "HiSilicon SoC PMU drivers"
4+
depends on ARM64 && ACPI
5+
help
6+
Support for HiSilicon SoC L3 Cache performance monitor, Hydra Home
7+
Agent performance monitor and DDR Controller performance monitor.

drivers/perf/hisilicon/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# SPDX-License-Identifier: GPL-2.0-only
2-
obj-$(CONFIG_HISI_PMU) += hisi_uncore_pmu.o hisi_uncore_l3c_pmu.o hisi_uncore_hha_pmu.o hisi_uncore_ddrc_pmu.o
2+
obj-$(CONFIG_HISI_PMU) += hisi_uncore_pmu.o hisi_uncore_l3c_pmu.o \
3+
hisi_uncore_hha_pmu.o hisi_uncore_ddrc_pmu.o

drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,9 @@ static int hisi_ddrc_pmu_probe(struct platform_device *pdev)
394394
ret = perf_pmu_register(&ddrc_pmu->pmu, name, -1);
395395
if (ret) {
396396
dev_err(ddrc_pmu->dev, "DDRC PMU register failed!\n");
397-
cpuhp_state_remove_instance(CPUHP_AP_PERF_ARM_HISI_DDRC_ONLINE,
398-
&ddrc_pmu->node);
397+
cpuhp_state_remove_instance_nocalls(
398+
CPUHP_AP_PERF_ARM_HISI_DDRC_ONLINE, &ddrc_pmu->node);
399+
irq_set_affinity_hint(ddrc_pmu->irq, NULL);
399400
}
400401

401402
return ret;
@@ -406,8 +407,9 @@ static int hisi_ddrc_pmu_remove(struct platform_device *pdev)
406407
struct hisi_pmu *ddrc_pmu = platform_get_drvdata(pdev);
407408

408409
perf_pmu_unregister(&ddrc_pmu->pmu);
409-
cpuhp_state_remove_instance(CPUHP_AP_PERF_ARM_HISI_DDRC_ONLINE,
410-
&ddrc_pmu->node);
410+
cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_HISI_DDRC_ONLINE,
411+
&ddrc_pmu->node);
412+
irq_set_affinity_hint(ddrc_pmu->irq, NULL);
411413

412414
return 0;
413415
}

drivers/perf/hisilicon/hisi_uncore_hha_pmu.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,9 @@ static int hisi_hha_pmu_probe(struct platform_device *pdev)
406406
ret = perf_pmu_register(&hha_pmu->pmu, name, -1);
407407
if (ret) {
408408
dev_err(hha_pmu->dev, "HHA PMU register failed!\n");
409-
cpuhp_state_remove_instance(CPUHP_AP_PERF_ARM_HISI_HHA_ONLINE,
410-
&hha_pmu->node);
409+
cpuhp_state_remove_instance_nocalls(
410+
CPUHP_AP_PERF_ARM_HISI_HHA_ONLINE, &hha_pmu->node);
411+
irq_set_affinity_hint(hha_pmu->irq, NULL);
411412
}
412413

413414
return ret;
@@ -418,8 +419,9 @@ static int hisi_hha_pmu_remove(struct platform_device *pdev)
418419
struct hisi_pmu *hha_pmu = platform_get_drvdata(pdev);
419420

420421
perf_pmu_unregister(&hha_pmu->pmu);
421-
cpuhp_state_remove_instance(CPUHP_AP_PERF_ARM_HISI_HHA_ONLINE,
422-
&hha_pmu->node);
422+
cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_HISI_HHA_ONLINE,
423+
&hha_pmu->node);
424+
irq_set_affinity_hint(hha_pmu->irq, NULL);
423425

424426
return 0;
425427
}

drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,9 @@ static int hisi_l3c_pmu_probe(struct platform_device *pdev)
396396
ret = perf_pmu_register(&l3c_pmu->pmu, name, -1);
397397
if (ret) {
398398
dev_err(l3c_pmu->dev, "L3C PMU register failed!\n");
399-
cpuhp_state_remove_instance(CPUHP_AP_PERF_ARM_HISI_L3_ONLINE,
400-
&l3c_pmu->node);
399+
cpuhp_state_remove_instance_nocalls(
400+
CPUHP_AP_PERF_ARM_HISI_L3_ONLINE, &l3c_pmu->node);
401+
irq_set_affinity_hint(l3c_pmu->irq, NULL);
401402
}
402403

403404
return ret;
@@ -408,8 +409,9 @@ static int hisi_l3c_pmu_remove(struct platform_device *pdev)
408409
struct hisi_pmu *l3c_pmu = platform_get_drvdata(pdev);
409410

410411
perf_pmu_unregister(&l3c_pmu->pmu);
411-
cpuhp_state_remove_instance(CPUHP_AP_PERF_ARM_HISI_L3_ONLINE,
412-
&l3c_pmu->node);
412+
cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_HISI_L3_ONLINE,
413+
&l3c_pmu->node);
414+
irq_set_affinity_hint(l3c_pmu->irq, NULL);
413415

414416
return 0;
415417
}

drivers/perf/hisilicon/hisi_uncore_pmu.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ ssize_t hisi_format_sysfs_show(struct device *dev,
3535

3636
return sprintf(buf, "%s\n", (char *)eattr->var);
3737
}
38+
EXPORT_SYMBOL_GPL(hisi_format_sysfs_show);
3839

3940
/*
4041
* PMU event attributes
@@ -48,6 +49,7 @@ ssize_t hisi_event_sysfs_show(struct device *dev,
4849

4950
return sprintf(page, "config=0x%lx\n", (unsigned long)eattr->var);
5051
}
52+
EXPORT_SYMBOL_GPL(hisi_event_sysfs_show);
5153

5254
/*
5355
* sysfs cpumask attributes. For uncore PMU, we only have a single CPU to show
@@ -59,6 +61,7 @@ ssize_t hisi_cpumask_sysfs_show(struct device *dev,
5961

6062
return sprintf(buf, "%d\n", hisi_pmu->on_cpu);
6163
}
64+
EXPORT_SYMBOL_GPL(hisi_cpumask_sysfs_show);
6265

6366
static bool hisi_validate_event_group(struct perf_event *event)
6467
{
@@ -97,6 +100,7 @@ int hisi_uncore_pmu_counter_valid(struct hisi_pmu *hisi_pmu, int idx)
97100
{
98101
return idx >= 0 && idx < hisi_pmu->num_counters;
99102
}
103+
EXPORT_SYMBOL_GPL(hisi_uncore_pmu_counter_valid);
100104

101105
int hisi_uncore_pmu_get_event_idx(struct perf_event *event)
102106
{
@@ -113,6 +117,7 @@ int hisi_uncore_pmu_get_event_idx(struct perf_event *event)
113117

114118
return idx;
115119
}
120+
EXPORT_SYMBOL_GPL(hisi_uncore_pmu_get_event_idx);
116121

117122
static void hisi_uncore_pmu_clear_event_idx(struct hisi_pmu *hisi_pmu, int idx)
118123
{
@@ -173,6 +178,7 @@ int hisi_uncore_pmu_event_init(struct perf_event *event)
173178

174179
return 0;
175180
}
181+
EXPORT_SYMBOL_GPL(hisi_uncore_pmu_event_init);
176182

177183
/*
178184
* Set the counter to count the event that we're interested in,
@@ -220,6 +226,7 @@ void hisi_uncore_pmu_set_event_period(struct perf_event *event)
220226
/* Write start value to the hardware event counter */
221227
hisi_pmu->ops->write_counter(hisi_pmu, hwc, val);
222228
}
229+
EXPORT_SYMBOL_GPL(hisi_uncore_pmu_set_event_period);
223230

224231
void hisi_uncore_pmu_event_update(struct perf_event *event)
225232
{
@@ -240,6 +247,7 @@ void hisi_uncore_pmu_event_update(struct perf_event *event)
240247
HISI_MAX_PERIOD(hisi_pmu->counter_bits);
241248
local64_add(delta, &event->count);
242249
}
250+
EXPORT_SYMBOL_GPL(hisi_uncore_pmu_event_update);
243251

244252
void hisi_uncore_pmu_start(struct perf_event *event, int flags)
245253
{
@@ -262,6 +270,7 @@ void hisi_uncore_pmu_start(struct perf_event *event, int flags)
262270
hisi_uncore_pmu_enable_event(event);
263271
perf_event_update_userpage(event);
264272
}
273+
EXPORT_SYMBOL_GPL(hisi_uncore_pmu_start);
265274

266275
void hisi_uncore_pmu_stop(struct perf_event *event, int flags)
267276
{
@@ -278,6 +287,7 @@ void hisi_uncore_pmu_stop(struct perf_event *event, int flags)
278287
hisi_uncore_pmu_event_update(event);
279288
hwc->state |= PERF_HES_UPTODATE;
280289
}
290+
EXPORT_SYMBOL_GPL(hisi_uncore_pmu_stop);
281291

282292
int hisi_uncore_pmu_add(struct perf_event *event, int flags)
283293
{
@@ -300,6 +310,7 @@ int hisi_uncore_pmu_add(struct perf_event *event, int flags)
300310

301311
return 0;
302312
}
313+
EXPORT_SYMBOL_GPL(hisi_uncore_pmu_add);
303314

304315
void hisi_uncore_pmu_del(struct perf_event *event, int flags)
305316
{
@@ -311,12 +322,14 @@ void hisi_uncore_pmu_del(struct perf_event *event, int flags)
311322
perf_event_update_userpage(event);
312323
hisi_pmu->pmu_events.hw_events[hwc->idx] = NULL;
313324
}
325+
EXPORT_SYMBOL_GPL(hisi_uncore_pmu_del);
314326

315327
void hisi_uncore_pmu_read(struct perf_event *event)
316328
{
317329
/* Read hardware counter and update the perf counter statistics */
318330
hisi_uncore_pmu_event_update(event);
319331
}
332+
EXPORT_SYMBOL_GPL(hisi_uncore_pmu_read);
320333

321334
void hisi_uncore_pmu_enable(struct pmu *pmu)
322335
{
@@ -329,13 +342,15 @@ void hisi_uncore_pmu_enable(struct pmu *pmu)
329342

330343
hisi_pmu->ops->start_counters(hisi_pmu);
331344
}
345+
EXPORT_SYMBOL_GPL(hisi_uncore_pmu_enable);
332346

333347
void hisi_uncore_pmu_disable(struct pmu *pmu)
334348
{
335349
struct hisi_pmu *hisi_pmu = to_hisi_pmu(pmu);
336350

337351
hisi_pmu->ops->stop_counters(hisi_pmu);
338352
}
353+
EXPORT_SYMBOL_GPL(hisi_uncore_pmu_disable);
339354

340355

341356
/*
@@ -414,10 +429,11 @@ int hisi_uncore_pmu_online_cpu(unsigned int cpu, struct hlist_node *node)
414429
hisi_pmu->on_cpu = cpu;
415430

416431
/* Overflow interrupt also should use the same CPU */
417-
WARN_ON(irq_set_affinity(hisi_pmu->irq, cpumask_of(cpu)));
432+
WARN_ON(irq_set_affinity_hint(hisi_pmu->irq, cpumask_of(cpu)));
418433

419434
return 0;
420435
}
436+
EXPORT_SYMBOL_GPL(hisi_uncore_pmu_online_cpu);
421437

422438
int hisi_uncore_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node)
423439
{
@@ -446,7 +462,10 @@ int hisi_uncore_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node)
446462
perf_pmu_migrate_context(&hisi_pmu->pmu, cpu, target);
447463
/* Use this CPU for event counting */
448464
hisi_pmu->on_cpu = target;
449-
WARN_ON(irq_set_affinity(hisi_pmu->irq, cpumask_of(target)));
465+
WARN_ON(irq_set_affinity_hint(hisi_pmu->irq, cpumask_of(target)));
450466

451467
return 0;
452468
}
469+
EXPORT_SYMBOL_GPL(hisi_uncore_pmu_offline_cpu);
470+
471+
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)