Skip to content

Commit cb87771

Browse files
committed
Merge branch 'for-next/perf' of git://git.kernel.org/pub/scm/linux/kernel/git/will/linux
- perf/arm-cci: allow building as module - perf/arm-ccn: demote dev_warn() to dev_dbg() in event_init() - miscellaneous perf/arm cleanups * 'for-next/perf' of git://git.kernel.org/pub/scm/linux/kernel/git/will/linux: ARM: mcpm, perf/arm-cci: export mcpm_is_available drivers/bus: arm-cci: fix build warnings drivers/perf: Remove ARM_SPE_PMU explicit PERF_EVENTS dependency drivers/perf: arm-ccn: don't log to dmesg in event_init perf/arm-cci: Allow building as a module perf/arm-cci: Remove pointless PMU disabling perf/arm-cc*: Fix MODULE_LICENSE() tags arm_pmu: simplify arm_pmu::handle_irq perf/arm-cci: Remove unnecessary period adjustment perf: simplify getting .drvdata
2 parents 5d81f7d + 73acc03 commit cb87771

File tree

11 files changed

+64
-69
lines changed

11 files changed

+64
-69
lines changed

arch/arm/common/mcpm_entry.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* published by the Free Software Foundation.
1010
*/
1111

12+
#include <linux/export.h>
1213
#include <linux/kernel.h>
1314
#include <linux/init.h>
1415
#include <linux/irqflags.h>
@@ -174,6 +175,7 @@ bool mcpm_is_available(void)
174175
{
175176
return (platform_ops) ? true : false;
176177
}
178+
EXPORT_SYMBOL_GPL(mcpm_is_available);
177179

178180
/*
179181
* We can't use regular spinlocks. In the switcher case, it is possible

arch/arm/kernel/perf_event_v6.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,10 @@ static void armv6pmu_enable_event(struct perf_event *event)
303303
}
304304

305305
static irqreturn_t
306-
armv6pmu_handle_irq(int irq_num,
307-
void *dev)
306+
armv6pmu_handle_irq(struct arm_pmu *cpu_pmu)
308307
{
309308
unsigned long pmcr = armv6_pmcr_read();
310309
struct perf_sample_data data;
311-
struct arm_pmu *cpu_pmu = (struct arm_pmu *)dev;
312310
struct pmu_hw_events *cpuc = this_cpu_ptr(cpu_pmu->hw_events);
313311
struct pt_regs *regs;
314312
int idx;

arch/arm/kernel/perf_event_v7.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -946,11 +946,10 @@ static void armv7pmu_disable_event(struct perf_event *event)
946946
raw_spin_unlock_irqrestore(&events->pmu_lock, flags);
947947
}
948948

949-
static irqreturn_t armv7pmu_handle_irq(int irq_num, void *dev)
949+
static irqreturn_t armv7pmu_handle_irq(struct arm_pmu *cpu_pmu)
950950
{
951951
u32 pmnc;
952952
struct perf_sample_data data;
953-
struct arm_pmu *cpu_pmu = (struct arm_pmu *)dev;
954953
struct pmu_hw_events *cpuc = this_cpu_ptr(cpu_pmu->hw_events);
955954
struct pt_regs *regs;
956955
int idx;

arch/arm/kernel/perf_event_xscale.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,10 @@ xscale1_pmnc_counter_has_overflowed(unsigned long pmnc,
142142
}
143143

144144
static irqreturn_t
145-
xscale1pmu_handle_irq(int irq_num, void *dev)
145+
xscale1pmu_handle_irq(struct arm_pmu *cpu_pmu)
146146
{
147147
unsigned long pmnc;
148148
struct perf_sample_data data;
149-
struct arm_pmu *cpu_pmu = (struct arm_pmu *)dev;
150149
struct pmu_hw_events *cpuc = this_cpu_ptr(cpu_pmu->hw_events);
151150
struct pt_regs *regs;
152151
int idx;
@@ -489,11 +488,10 @@ xscale2_pmnc_counter_has_overflowed(unsigned long of_flags,
489488
}
490489

491490
static irqreturn_t
492-
xscale2pmu_handle_irq(int irq_num, void *dev)
491+
xscale2pmu_handle_irq(struct arm_pmu *cpu_pmu)
493492
{
494493
unsigned long pmnc, of_flags;
495494
struct perf_sample_data data;
496-
struct arm_pmu *cpu_pmu = (struct arm_pmu *)dev;
497495
struct pmu_hw_events *cpuc = this_cpu_ptr(cpu_pmu->hw_events);
498496
struct pt_regs *regs;
499497
int idx;

arch/arm64/kernel/perf_event.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,11 +670,10 @@ static void armv8pmu_disable_event(struct perf_event *event)
670670
raw_spin_unlock_irqrestore(&events->pmu_lock, flags);
671671
}
672672

673-
static irqreturn_t armv8pmu_handle_irq(int irq_num, void *dev)
673+
static irqreturn_t armv8pmu_handle_irq(struct arm_pmu *cpu_pmu)
674674
{
675675
u32 pmovsr;
676676
struct perf_sample_data data;
677-
struct arm_pmu *cpu_pmu = (struct arm_pmu *)dev;
678677
struct pmu_hw_events *cpuc = this_cpu_ptr(cpu_pmu->hw_events);
679678
struct pt_regs *regs;
680679
int idx;

drivers/perf/Kconfig

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,32 @@ menu "Performance monitor support"
66
depends on PERF_EVENTS
77

88
config ARM_CCI_PMU
9-
bool
9+
tristate "ARM CCI PMU driver"
10+
depends on (ARM && CPU_V7) || ARM64
1011
select ARM_CCI
12+
help
13+
Support for PMU events monitoring on the ARM CCI (Cache Coherent
14+
Interconnect) family of products.
15+
16+
If compiled as a module, it will be called arm-cci.
1117

1218
config ARM_CCI400_PMU
13-
bool "ARM CCI400 PMU support"
14-
depends on (ARM && CPU_V7) || ARM64
19+
bool "support CCI-400"
20+
default y
21+
depends on ARM_CCI_PMU
1522
select ARM_CCI400_COMMON
16-
select ARM_CCI_PMU
1723
help
18-
Support for PMU events monitoring on the ARM CCI-400 (cache coherent
19-
interconnect). CCI-400 supports counting events related to the
20-
connected slave/master interfaces.
24+
CCI-400 provides 4 independent event counters counting events related
25+
to the connected slave/master interfaces, plus a cycle counter.
2126

2227
config ARM_CCI5xx_PMU
23-
bool "ARM CCI-500/CCI-550 PMU support"
24-
depends on (ARM && CPU_V7) || ARM64
25-
select ARM_CCI_PMU
28+
bool "support CCI-500/CCI-550"
29+
default y
30+
depends on ARM_CCI_PMU
2631
help
27-
Support for PMU events monitoring on the ARM CCI-500/CCI-550 cache
28-
coherent interconnects. Both of them provide 8 independent event counters,
29-
which can count events pertaining to the slave/master interfaces as well
30-
as the internal events to the CCI.
31-
32-
If unsure, say Y
32+
CCI-500/CCI-550 both provide 8 independent event counters, which can
33+
count events pertaining to the slave/master interfaces as well as the
34+
internal events to the CCI.
3335

3436
config ARM_CCN
3537
tristate "ARM CCN driver support"
@@ -94,7 +96,7 @@ config XGENE_PMU
9496

9597
config ARM_SPE_PMU
9698
tristate "Enable support for the ARMv8.2 Statistical Profiling Extension"
97-
depends on PERF_EVENTS && ARM64
99+
depends on ARM64
98100
help
99101
Enable perf support for the ARMv8.2 Statistical Profiling
100102
Extension, which provides periodic sampling of operations in

drivers/perf/arm-cci.c

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ enum cci_models {
120120

121121
static void pmu_write_counters(struct cci_pmu *cci_pmu,
122122
unsigned long *mask);
123-
static ssize_t cci_pmu_format_show(struct device *dev,
123+
static ssize_t __maybe_unused cci_pmu_format_show(struct device *dev,
124124
struct device_attribute *attr, char *buf);
125-
static ssize_t cci_pmu_event_show(struct device *dev,
125+
static ssize_t __maybe_unused cci_pmu_event_show(struct device *dev,
126126
struct device_attribute *attr, char *buf);
127127

128128
#define CCI_EXT_ATTR_ENTRY(_name, _func, _config) \
@@ -1184,16 +1184,11 @@ static int cci_pmu_add(struct perf_event *event, int flags)
11841184
struct cci_pmu_hw_events *hw_events = &cci_pmu->hw_events;
11851185
struct hw_perf_event *hwc = &event->hw;
11861186
int idx;
1187-
int err = 0;
1188-
1189-
perf_pmu_disable(event->pmu);
11901187

11911188
/* If we don't have a space for the counter then finish early. */
11921189
idx = pmu_get_event_idx(hw_events, event);
1193-
if (idx < 0) {
1194-
err = idx;
1195-
goto out;
1196-
}
1190+
if (idx < 0)
1191+
return idx;
11971192

11981193
event->hw.idx = idx;
11991194
hw_events->events[idx] = event;
@@ -1205,9 +1200,7 @@ static int cci_pmu_add(struct perf_event *event, int flags)
12051200
/* Propagate our changes to the userspace mapping. */
12061201
perf_event_update_userpage(event);
12071202

1208-
out:
1209-
perf_pmu_enable(event->pmu);
1210-
return err;
1203+
return 0;
12111204
}
12121205

12131206
static void cci_pmu_del(struct perf_event *event, int flags)
@@ -1304,15 +1297,6 @@ static int __hw_perf_event_init(struct perf_event *event)
13041297
*/
13051298
hwc->config_base |= (unsigned long)mapping;
13061299

1307-
/*
1308-
* Limit the sample_period to half of the counter width. That way, the
1309-
* new counter value is far less likely to overtake the previous one
1310-
* unless you have some serious IRQ latency issues.
1311-
*/
1312-
hwc->sample_period = CCI_PMU_CNTR_MASK >> 1;
1313-
hwc->last_period = hwc->sample_period;
1314-
local64_set(&hwc->period_left, hwc->sample_period);
1315-
13161300
if (event->group_leader != event) {
13171301
if (validate_group(event) != 0)
13181302
return -EINVAL;
@@ -1423,6 +1407,7 @@ static int cci_pmu_init(struct cci_pmu *cci_pmu, struct platform_device *pdev)
14231407
pmu_format_attr_group.attrs = model->format_attrs;
14241408

14251409
cci_pmu->pmu = (struct pmu) {
1410+
.module = THIS_MODULE,
14261411
.name = cci_pmu->model->name,
14271412
.task_ctx_nr = perf_invalid_context,
14281413
.pmu_enable = cci_pmu_enable,
@@ -1466,7 +1451,7 @@ static int cci_pmu_offline_cpu(unsigned int cpu)
14661451
return 0;
14671452
}
14681453

1469-
static struct cci_pmu_model cci_pmu_models[] = {
1454+
static __maybe_unused struct cci_pmu_model cci_pmu_models[] = {
14701455
#ifdef CONFIG_ARM_CCI400_PMU
14711456
[CCI400_R0] = {
14721457
.name = "CCI_400",
@@ -1588,6 +1573,7 @@ static const struct of_device_id arm_cci_pmu_matches[] = {
15881573
#endif
15891574
{},
15901575
};
1576+
MODULE_DEVICE_TABLE(of, arm_cci_pmu_matches);
15911577

15921578
static bool is_duplicate_irq(int irq, int *irqs, int nr_irqs)
15931579
{
@@ -1709,14 +1695,27 @@ static int cci_pmu_probe(struct platform_device *pdev)
17091695
return 0;
17101696
}
17111697

1698+
static int cci_pmu_remove(struct platform_device *pdev)
1699+
{
1700+
if (!g_cci_pmu)
1701+
return 0;
1702+
1703+
cpuhp_remove_state(CPUHP_AP_PERF_ARM_CCI_ONLINE);
1704+
perf_pmu_unregister(&g_cci_pmu->pmu);
1705+
g_cci_pmu = NULL;
1706+
1707+
return 0;
1708+
}
1709+
17121710
static struct platform_driver cci_pmu_driver = {
17131711
.driver = {
17141712
.name = DRIVER_NAME,
17151713
.of_match_table = arm_cci_pmu_matches,
17161714
},
17171715
.probe = cci_pmu_probe,
1716+
.remove = cci_pmu_remove,
17181717
};
17191718

1720-
builtin_platform_driver(cci_pmu_driver);
1721-
MODULE_LICENSE("GPL");
1719+
module_platform_driver(cci_pmu_driver);
1720+
MODULE_LICENSE("GPL v2");
17221721
MODULE_DESCRIPTION("ARM CCI PMU support");

drivers/perf/arm-ccn.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -736,20 +736,20 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
736736
ccn = pmu_to_arm_ccn(event->pmu);
737737

738738
if (hw->sample_period) {
739-
dev_warn(ccn->dev, "Sampling not supported!\n");
739+
dev_dbg(ccn->dev, "Sampling not supported!\n");
740740
return -EOPNOTSUPP;
741741
}
742742

743743
if (has_branch_stack(event) || event->attr.exclude_user ||
744744
event->attr.exclude_kernel || event->attr.exclude_hv ||
745745
event->attr.exclude_idle || event->attr.exclude_host ||
746746
event->attr.exclude_guest) {
747-
dev_warn(ccn->dev, "Can't exclude execution levels!\n");
747+
dev_dbg(ccn->dev, "Can't exclude execution levels!\n");
748748
return -EINVAL;
749749
}
750750

751751
if (event->cpu < 0) {
752-
dev_warn(ccn->dev, "Can't provide per-task data!\n");
752+
dev_dbg(ccn->dev, "Can't provide per-task data!\n");
753753
return -EOPNOTSUPP;
754754
}
755755
/*
@@ -771,25 +771,25 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
771771
switch (type) {
772772
case CCN_TYPE_MN:
773773
if (node_xp != ccn->mn_id) {
774-
dev_warn(ccn->dev, "Invalid MN ID %d!\n", node_xp);
774+
dev_dbg(ccn->dev, "Invalid MN ID %d!\n", node_xp);
775775
return -EINVAL;
776776
}
777777
break;
778778
case CCN_TYPE_XP:
779779
if (node_xp >= ccn->num_xps) {
780-
dev_warn(ccn->dev, "Invalid XP ID %d!\n", node_xp);
780+
dev_dbg(ccn->dev, "Invalid XP ID %d!\n", node_xp);
781781
return -EINVAL;
782782
}
783783
break;
784784
case CCN_TYPE_CYCLES:
785785
break;
786786
default:
787787
if (node_xp >= ccn->num_nodes) {
788-
dev_warn(ccn->dev, "Invalid node ID %d!\n", node_xp);
788+
dev_dbg(ccn->dev, "Invalid node ID %d!\n", node_xp);
789789
return -EINVAL;
790790
}
791791
if (!arm_ccn_pmu_type_eq(type, ccn->node[node_xp].type)) {
792-
dev_warn(ccn->dev, "Invalid type 0x%x for node %d!\n",
792+
dev_dbg(ccn->dev, "Invalid type 0x%x for node %d!\n",
793793
type, node_xp);
794794
return -EINVAL;
795795
}
@@ -808,19 +808,19 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
808808
if (event_id != e->event)
809809
continue;
810810
if (e->num_ports && port >= e->num_ports) {
811-
dev_warn(ccn->dev, "Invalid port %d for node/XP %d!\n",
811+
dev_dbg(ccn->dev, "Invalid port %d for node/XP %d!\n",
812812
port, node_xp);
813813
return -EINVAL;
814814
}
815815
if (e->num_vcs && vc >= e->num_vcs) {
816-
dev_warn(ccn->dev, "Invalid vc %d for node/XP %d!\n",
816+
dev_dbg(ccn->dev, "Invalid vc %d for node/XP %d!\n",
817817
vc, node_xp);
818818
return -EINVAL;
819819
}
820820
valid = 1;
821821
}
822822
if (!valid) {
823-
dev_warn(ccn->dev, "Invalid event 0x%x for node/XP %d!\n",
823+
dev_dbg(ccn->dev, "Invalid event 0x%x for node/XP %d!\n",
824824
event_id, node_xp);
825825
return -EINVAL;
826826
}
@@ -1594,4 +1594,4 @@ module_init(arm_ccn_init);
15941594
module_exit(arm_ccn_exit);
15951595

15961596
MODULE_AUTHOR("Pawel Moll <[email protected]>");
1597-
MODULE_LICENSE("GPL");
1597+
MODULE_LICENSE("GPL v2");

drivers/perf/arm_pmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ static irqreturn_t armpmu_dispatch_irq(int irq, void *dev)
339339
return IRQ_NONE;
340340

341341
start_clock = sched_clock();
342-
ret = armpmu->handle_irq(irq, armpmu);
342+
ret = armpmu->handle_irq(armpmu);
343343
finish_clock = sched_clock();
344344

345345
perf_sample_event_took(finish_clock - start_clock);

drivers/perf/arm_spe_pmu.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ static ssize_t arm_spe_pmu_cap_show(struct device *dev,
131131
struct device_attribute *attr,
132132
char *buf)
133133
{
134-
struct platform_device *pdev = to_platform_device(dev);
135-
struct arm_spe_pmu *spe_pmu = platform_get_drvdata(pdev);
134+
struct arm_spe_pmu *spe_pmu = dev_get_drvdata(dev);
136135
struct dev_ext_attribute *ea =
137136
container_of(attr, struct dev_ext_attribute, attr);
138137
int cap = (long)ea->var;
@@ -247,8 +246,7 @@ static ssize_t arm_spe_pmu_get_attr_cpumask(struct device *dev,
247246
struct device_attribute *attr,
248247
char *buf)
249248
{
250-
struct platform_device *pdev = to_platform_device(dev);
251-
struct arm_spe_pmu *spe_pmu = platform_get_drvdata(pdev);
249+
struct arm_spe_pmu *spe_pmu = dev_get_drvdata(dev);
252250

253251
return cpumap_print_to_pagebuf(true, buf, &spe_pmu->supported_cpus);
254252
}

0 commit comments

Comments
 (0)