summaryrefslogtreecommitdiff
path: root/solutions/f39f86eaa6e8771669e537972f36862a/conflict2
blob: e98917f7f0d7dab995f494f20561675108d90311 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
diff --cc arch/arm/kernel/perf_event_cpu.c
index 0b48a38e,b3ae24f..0000000
--- a/arch/arm/kernel/perf_event_cpu.c
+++ b/arch/arm/kernel/perf_event_cpu.c
@@@ -19,6 -19,7 +19,10 @@@
  #define pr_fmt(fmt) "CPU PMU: " fmt
  
  #include <linux/bitmap.h>
++<<<<<<< HEAD
++=======
+ #include <linux/cpumask.h>
++>>>>>>> tracking-lsk-vexpress-iks
  #include <linux/cpu_pm.h>
  #include <linux/export.h>
  #include <linux/kernel.h>
@@@ -30,23 -34,33 +37,44 @@@
  #include <asm/cputype.h>
  #include <asm/irq_regs.h>
  #include <asm/pmu.h>
+ #include <asm/smp_plat.h>
+ #include <asm/topology.h>
  
++<<<<<<< HEAD
 +/* Set at runtime when we know what CPU type we are. */
 +static DEFINE_PER_CPU(struct arm_pmu *, cpu_pmu);
++=======
+ static LIST_HEAD(cpu_pmus_list);
++>>>>>>> tracking-lsk-vexpress-iks
  
- static DEFINE_PER_CPU(struct perf_event * [ARMPMU_MAX_HWEVENTS], hw_events);
- static DEFINE_PER_CPU(unsigned long [BITS_TO_LONGS(ARMPMU_MAX_HWEVENTS)], used_mask);
- static DEFINE_PER_CPU(struct pmu_hw_events, cpu_hw_events);
+ #define cpu_for_each_pmu(pmu, cpu_pmu, cpu)				\
+ 	for_each_pmu(pmu, &cpu_pmus_list)				\
+ 		if (((cpu_pmu) = per_cpu_ptr((pmu)->cpu_pmus, cpu))->valid)
+ 
+ static struct arm_pmu *__cpu_find_any_pmu(unsigned int cpu)
+ {
+ 	struct arm_pmu *pmu;
+ 	struct arm_cpu_pmu *cpu_pmu;
+ 
+ 	cpu_for_each_pmu(pmu, cpu_pmu, cpu)
+ 		return pmu;
+ 
+ 	return NULL;
+ }
  
 +static DEFINE_PER_CPU(struct cpupmu_regs, cpu_pmu_regs);
 +
  /*
   * Despite the names, these two functions are CPU-specific and are used
   * by the OProfile/perf code.
   */
  const char *perf_pmu_name(void)
  {
++<<<<<<< HEAD
 +	struct arm_pmu *pmu = per_cpu(cpu_pmu, 0);
++=======
+ 	struct arm_pmu *pmu = __cpu_find_any_pmu(0);
++>>>>>>> tracking-lsk-vexpress-iks
  	if (!pmu)
  		return NULL;
  
@@@ -56,7 -70,7 +84,11 @@@ EXPORT_SYMBOL_GPL(perf_pmu_name)
  
  int perf_num_counters(void)
  {
++<<<<<<< HEAD
 +	struct arm_pmu *pmu = per_cpu(cpu_pmu, 0);
++=======
+ 	struct arm_pmu *pmu = __cpu_find_any_pmu(0);
++>>>>>>> tracking-lsk-vexpress-iks
  
  	if (!pmu)
  		return 0;
@@@ -70,48 -84,66 +102,90 @@@ EXPORT_SYMBOL_GPL(perf_num_counters)
  #include "perf_event_v6.c"
  #include "perf_event_v7.c"
  
- static struct pmu_hw_events *cpu_pmu_get_cpu_events(void)
+ static struct pmu_hw_events *cpu_pmu_get_cpu_events(struct arm_pmu *pmu)
  {
- 	return &__get_cpu_var(cpu_hw_events);
+ 	return &this_cpu_ptr(pmu->cpu_pmus)->cpu_hw_events;
  }
  
- static void cpu_pmu_free_irq(struct arm_pmu *cpu_pmu)
+ static int find_logical_cpu(u32 mpidr)
  {
++<<<<<<< HEAD
 +	int i, irq, irqs;
 +	struct platform_device *pmu_device = cpu_pmu->plat_device;
 +	int cpu = -1;
++=======
+ 	int cpu = bL_switcher_get_logical_index(mpidr);
++>>>>>>> tracking-lsk-vexpress-iks
  
- 	irqs = min(pmu_device->num_resources, num_possible_cpus());
+ 	if (cpu != -EUNATCH)
+ 		return cpu;
  
++<<<<<<< HEAD
 +	for (i = 0; i < irqs; ++i) {
 +		cpu = cpumask_next(cpu, &cpu_pmu->valid_cpus);
 +		if (!cpumask_test_and_clear_cpu(cpu, &cpu_pmu->active_irqs))
++=======
+ 	return get_logical_index(mpidr);
+ }
+ 
+ static void cpu_pmu_free_irq(struct arm_pmu *pmu)
+ {
+ 	int i;
+ 	int cpu;
+ 	struct arm_cpu_pmu *cpu_pmu;
+ 
+ 	for_each_possible_cpu(i) {
+ 		if (!(cpu_pmu = per_cpu_ptr(pmu->cpu_pmus, i)))
++>>>>>>> tracking-lsk-vexpress-iks
  			continue;
- 		irq = platform_get_irq(pmu_device, i);
- 		if (irq >= 0)
- 			free_irq(irq, cpu_pmu);
+ 
+ 		if (cpu_pmu->mpidr == -1)
+ 			continue;
+ 
+ 		cpu = find_logical_cpu(cpu_pmu->mpidr);
+ 		if (cpu < 0)
+ 			continue;
+ 
+ 		if (!cpumask_test_and_clear_cpu(cpu, &pmu->active_irqs))
+ 			continue;
+ 		if (cpu_pmu->irq >= 0)
+ 			free_irq(cpu_pmu->irq, pmu);
  	}
  }
  
- static int cpu_pmu_request_irq(struct arm_pmu *cpu_pmu, irq_handler_t handler)
+ static int cpu_pmu_request_irq(struct arm_pmu *pmu, irq_handler_t handler)
  {
  	int i, err, irq, irqs;
++<<<<<<< HEAD
 +	struct platform_device *pmu_device = cpu_pmu->plat_device;
 +	int cpu = -1;
++=======
+ 	int cpu;
+ 	struct arm_cpu_pmu *cpu_pmu;
++>>>>>>> tracking-lsk-vexpress-iks
  
- 	if (!pmu_device)
- 		return -ENODEV;
+ 	irqs = 0;
+ 	for_each_possible_cpu(i)
+ 		if (per_cpu_ptr(pmu->cpu_pmus, i))
+ 			++irqs;
  
- 	irqs = min(pmu_device->num_resources, num_possible_cpus());
  	if (irqs < 1) {
  		pr_err("no irqs for PMUs defined\n");
  		return -ENODEV;
  	}
  
++<<<<<<< HEAD
 +	for (i = 0; i < irqs; ++i) {
 +		err = 0;
 +		cpu = cpumask_next(cpu, &cpu_pmu->valid_cpus);
 +		irq = platform_get_irq(pmu_device, i);
++=======
+ 	for_each_possible_cpu(i) {
+ 		if (!(cpu_pmu = per_cpu_ptr(pmu->cpu_pmus, i)))
+ 			continue;
+ 
+ 		irq = cpu_pmu->irq;
++>>>>>>> tracking-lsk-vexpress-iks
  		if (irq < 0)
  			continue;
  
@@@ -134,29 -173,36 +215,52 @@@
  			return err;
  		}
  
++<<<<<<< HEAD
 +		cpumask_set_cpu(cpu, &cpu_pmu->active_irqs);
++=======
+ 		cpumask_set_cpu(cpu, &pmu->active_irqs);
++>>>>>>> tracking-lsk-vexpress-iks
  	}
  
  	return 0;
  }
  
- static void cpu_pmu_init(struct arm_pmu *cpu_pmu)
+ static void cpu_pmu_init(struct arm_pmu *pmu)
  {
  	int cpu;
++<<<<<<< HEAD
 +	for_each_cpu_mask(cpu, cpu_pmu->valid_cpus) {
 +		struct pmu_hw_events *events = &per_cpu(cpu_hw_events, cpu);
 +		events->events = per_cpu(hw_events, cpu);
 +		events->used_mask = per_cpu(used_mask, cpu);
++=======
+ 	for_each_cpu_mask(cpu, pmu->valid_cpus) {
+ 		struct arm_cpu_pmu *cpu_pmu = per_cpu_ptr(pmu->cpu_pmus, cpu);
+ 		struct pmu_hw_events *events = &cpu_pmu->cpu_hw_events;
+ 
+ 		events->events = cpu_pmu->hw_events;
+ 		events->used_mask = cpu_pmu->used_mask;
++>>>>>>> tracking-lsk-vexpress-iks
  		raw_spin_lock_init(&events->pmu_lock);
+ 
+ 		if (pmu->cpu_init)
+ 			pmu->cpu_init(pmu, cpu_pmu);
+ 
+ 		cpu_pmu->valid = true;
  	}
  
- 	cpu_pmu->get_hw_events	= cpu_pmu_get_cpu_events;
- 	cpu_pmu->request_irq	= cpu_pmu_request_irq;
- 	cpu_pmu->free_irq	= cpu_pmu_free_irq;
+ 	pmu->get_hw_events	= cpu_pmu_get_cpu_events;
+ 	pmu->request_irq	= cpu_pmu_request_irq;
+ 	pmu->free_irq		= cpu_pmu_free_irq;
  
  	/* Ensure the PMU has sane values out of reset. */
++<<<<<<< HEAD
 +	if (cpu_pmu->reset)
 +		on_each_cpu_mask(&cpu_pmu->valid_cpus, cpu_pmu->reset, cpu_pmu, 1);
++=======
+ 	if (pmu->reset)
+ 		on_each_cpu_mask(&pmu->valid_cpus, pmu->reset, pmu, 1);
++>>>>>>> tracking-lsk-vexpress-iks
  }
  
  /*
@@@ -168,38 -214,44 +272,74 @@@
  static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
  				    unsigned long action, void *hcpu)
  {
++<<<<<<< HEAD
 +	struct arm_pmu *pmu = per_cpu(cpu_pmu, (long)hcpu);
++=======
+ 	struct arm_pmu *pmu;
+ 	struct arm_cpu_pmu *cpu_pmu;
+ 	int ret = NOTIFY_DONE;
++>>>>>>> tracking-lsk-vexpress-iks
  
  	if ((action & ~CPU_TASKS_FROZEN) != CPU_STARTING)
  		return NOTIFY_DONE;
  
++<<<<<<< HEAD
 +	if (pmu && pmu->reset)
 +		pmu->reset(pmu);
 +	else
 +		return NOTIFY_DONE;
++=======
+ 	cpu_for_each_pmu(pmu, cpu_pmu, (unsigned int)hcpu)
+ 		if (pmu->reset) {
+ 			pmu->reset(pmu);
+ 			ret = NOTIFY_OK;
+ 		}
++>>>>>>> tracking-lsk-vexpress-iks
  
- 	return NOTIFY_OK;
+ 	return ret;
+ }
+ 
+ static int cpu_pmu_pm_notify(struct notifier_block *b,
+ 				    unsigned long action, void *hcpu)
+ {
+ 	int cpu = smp_processor_id();
+ 	struct arm_pmu *pmu;
+ 	struct arm_cpu_pmu *cpu_pmu;
+ 	int ret = NOTIFY_DONE;
+ 
+ 	cpu_for_each_pmu(pmu, cpu_pmu, cpu) {
+ 		struct cpupmu_regs *pmuregs = &cpu_pmu->cpu_pmu_regs;
+ 
+ 		if (action == CPU_PM_ENTER && pmu->save_regs)
+ 			pmu->save_regs(pmu, pmuregs);
+ 		else if (action == CPU_PM_EXIT && pmu->restore_regs)
+ 			pmu->restore_regs(pmu, pmuregs);
+ 
+ 		ret = NOTIFY_OK;
+ 	}
+ 
+ 	return ret;
  }
  
 +static int cpu_pmu_pm_notify(struct notifier_block *b,
 +				    unsigned long action, void *hcpu)
 +{
 +	int cpu = smp_processor_id();
 +	struct arm_pmu *pmu = per_cpu(cpu_pmu, cpu);
 +	struct cpupmu_regs *pmuregs = &per_cpu(cpu_pmu_regs, cpu);
 +
 +	if (!pmu)
 +		return NOTIFY_DONE;
 +
 +	if (action == CPU_PM_ENTER && pmu->save_regs) {
 +		pmu->save_regs(pmu, pmuregs);
 +	} else if (action == CPU_PM_EXIT && pmu->restore_regs) {
 +		pmu->restore_regs(pmu, pmuregs);
 +	}
 +
 +	return NOTIFY_OK;
 +}
 +
  static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
  	.notifier_call = cpu_pmu_notify,
  };
@@@ -291,20 -414,24 +502,32 @@@ static int cpu_pmu_device_probe(struct 
  	const struct of_device_id *of_id;
  	struct device_node *node = pdev->dev.of_node;
  	struct arm_pmu *pmu;
++<<<<<<< HEAD
 +	int ret = 0;
 +	int cpu;
++=======
+ 	struct arm_cpu_pmu __percpu *cpu_pmus;
+ 	int ret = 0;
++>>>>>>> tracking-lsk-vexpress-iks
  
  	pmu = kzalloc(sizeof(struct arm_pmu), GFP_KERNEL);
- 	if (!pmu) {
- 		pr_info("failed to allocate PMU device!");
- 		return -ENOMEM;
- 	}
+ 	if (!pmu)
+ 		goto error_nomem;
+ 
+ 	pmu->cpu_pmus = cpu_pmus = alloc_percpu(struct arm_cpu_pmu);
+ 	if (!cpu_pmus)
+ 		goto error_nomem;
  
  	if (node && (of_id = of_match_node(cpu_pmu_of_device_ids, pdev->dev.of_node))) {
  		smp_call_func_t init_fn = (smp_call_func_t)of_id->data;
  		struct device_node *ncluster;
  		int cluster = -1;
  		cpumask_t sibling_mask;
++<<<<<<< HEAD
++=======
+ 		cpumask_t phys_sibling_mask;
+ 		unsigned int i;
++>>>>>>> tracking-lsk-vexpress-iks
  
  		ncluster = of_parse_phandle(node, "cluster", 0);
  		if (ncluster) {
@@@ -315,11 -442,59 +538,67 @@@
  				cluster = be32_to_cpup(hwid);
  		}
  		/* set sibling mask to all cpu mask if socket is not specified */
++<<<<<<< HEAD
 +		if (cluster == -1 ||
 +			cluster_to_logical_mask(cluster, &sibling_mask))
 +			cpumask_setall(&sibling_mask);
 +
 +		smp_call_function_any(&sibling_mask, init_fn, pmu, 1);
++=======
+ 		/*
+ 		 * In a switcher kernel, we affine all PMUs to CPUs and
+ 		 * abstract the runtime presence/absence of PMUs at a lower
+ 		 * level.
+ 		 */
+ 		if (cluster == -1 || IS_ENABLED(CONFIG_BL_SWITCHER) ||
+ 			cluster_to_logical_mask(cluster, &sibling_mask))
+ 			cpumask_copy(&sibling_mask, cpu_possible_mask);
+ 
+ 		if (bL_switcher_get_enabled())
+ 			/*
+ 			 * The switcher initialises late now, so it should not
+ 			 * have initialised yet:
+ 			 */
+ 			BUG();
+ 
+ 		cpumask_copy(&phys_sibling_mask, cpu_possible_mask);
+ 
+ 		/*
+ 		 * HACK: Deduce how the switcher will modify the topology
+ 		 * in order to fill in PMU<->CPU combinations which don't
+ 		 * make sense when the switcher is disabled.  Ideally, this
+ 		 * knowledge should come from the swithcer somehow.
+ 		 */
+ 		for_each_possible_cpu(i) {
+ 			int cpu = i;
+ 
+ 			per_cpu_ptr(cpu_pmus, i)->mpidr = -1;
+ 			per_cpu_ptr(cpu_pmus, i)->irq = -1;
+ 
+ 			if (cpu_topology[i].socket_id != cluster) {
+ 				cpumask_clear_cpu(i, &phys_sibling_mask);
+ 				cpu = bL_get_partner(i, cluster);
+ 			}
+ 
+ 			if (cpu == -1)
+ 				cpumask_clear_cpu(i, &sibling_mask);
+ 			else {
+ 				int irq = find_irq(pdev, node, ncluster,
+ 						   cpu_logical_map(cpu));
+ 				per_cpu_ptr(cpu_pmus, i)->mpidr =
+ 					cpu_logical_map(cpu);
+ 				per_cpu_ptr(cpu_pmus, i)->irq = irq;
+ 			}
+ 		}
+ 
+ 		/*
+ 		 * This relies on an MP view of the system to choose the right
+ 		 * CPU to run init_fn:
+ 		 */
+ 		smp_call_function_any(&phys_sibling_mask, init_fn, pmu, 1);
+ 
+ 		bL_switcher_put_enabled();
++>>>>>>> tracking-lsk-vexpress-iks
  
  		/* now set the valid_cpus after init */
  		cpumask_copy(&pmu->valid_cpus, &sibling_mask);
@@@ -327,14 -502,9 +606,15 @@@
  		ret = probe_current_pmu(pmu);
  	}
  
- 	if (ret) {
- 		pr_info("failed to probe PMU!");
- 		goto out_free;
- 	}
+ 	if (ret)
+ 		goto error;
  
++<<<<<<< HEAD
 +	for_each_cpu_mask(cpu, pmu->valid_cpus)
 +		per_cpu(cpu_pmu, cpu) = pmu;
 +
++=======
++>>>>>>> tracking-lsk-vexpress-iks
  	pmu->plat_device = pdev;
  	cpu_pmu_init(pmu);
  	ret = armpmu_register(pmu, -1);