Exemplo n.º 1
0
static void armv6_pmu_stop(void)
{
	arm11_stop_pmu();
	arm11_release_interrupts(pmu_irqs->irqs, pmu_irqs->num_irqs);
	release_pmu(pmu_irqs);
	pmu_irqs = NULL;
}
Exemplo n.º 2
0
static void em_stop(void)
{
	em_call_function(arm11_stop_pmu);
	arm11_release_interrupts(pmu_irqs->irqs, pmu_irqs->num_irqs);
	scu_stop();
	release_pmu(pmu_irqs);
}
Exemplo n.º 3
0
static int em_start(void)
{
	int ret;

	pmu_irqs = reserve_pmu();
	if (IS_ERR(pmu_irqs)) {
		ret = PTR_ERR(pmu_irqs);
		goto out;
	}

	ret = arm11_request_interrupts(pmu_irqs->irqs, pmu_irqs->num_irqs);
	if (ret == 0) {
		em_call_function(arm11_start_pmu);

		ret = scu_start();
		if (ret) {
			arm11_release_interrupts(pmu_irqs->irqs,
						 pmu_irqs->num_irqs);
		} else {
			release_pmu(pmu_irqs);
			pmu_irqs = NULL;
		}
	}

out:
	return ret;
}
Exemplo n.º 4
0
static void gator_event_sampling_stop(void)
{
#if LINUX_PMU_SUPPORT
	if (event_based_sampling) {
		int i, irq;
		for (i = pmu_device->num_resources - 1; i >= 0; --i) {
			irq = platform_get_irq(pmu_device, i);
			if (irq >= 0)
				free_irq(irq, NULL);
		}
	}
	if (!IS_ERR(pmu_device)) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0)
		release_pmu(pmu_device);
#else
		release_pmu(ARM_PMU_DEVICE_CPU);
#endif
	}
	pmu_device = NULL;
#endif
}
Exemplo n.º 5
0
static int armv6_pmu_start(void)
{
	int ret;

	pmu_irqs = reserve_pmu();
	if (IS_ERR(pmu_irqs)) {
		ret = PTR_ERR(pmu_irqs);
		goto out;
	}

	ret = arm11_request_interrupts(pmu_irqs->irqs, pmu_irqs->num_irqs);
	if (ret >= 0) {
		ret = arm11_start_pmu();
	} else {
		release_pmu(pmu_irqs);
		pmu_irqs = NULL;
	}

out:
	return ret;
}
Exemplo n.º 6
0
static int gator_event_sampling_start(void)
{
	int cnt;

	event_based_sampling = false;
	for (cnt = CCNT; cnt < CNTMAX; cnt++) {
		if (pmnc_count[cnt] > 0) {
			event_based_sampling = true;
			break;
		}
	}

#if LINUX_PMU_SUPPORT
	pmu_device = reserve_pmu(ARM_PMU_DEVICE_CPU);
	if (IS_ERR(pmu_device) && (unsigned int)pmu_device != -ENODEV) {
		pr_err("gator: unable to reserve the pmu\n");
		return -1;
	}

	if (event_based_sampling) {
		int irq, i;

		if (IS_ERR(pmu_device)) {
			pr_err("gator: event based sampling is not supported as the kernel function reserve_pmu() failed\n");
			return -1;
		}

		// init_pmu sets the irq affinity, therefore we do not care if it fails for single core
		if (init_pmu(ARM_PMU_DEVICE_CPU) != 0 && gator_cpu_cores > 1) {
			pr_err("gator: unable to initialize the pmu\n");
			goto out_ebs_start;
		}

		if (pmu_device->num_resources == 0) {
			pr_err("gator: no irqs for PMUs defined\n");
			goto out_ebs_start;
		}

		for (i = 0; i < pmu_device->num_resources; ++i) {
			irq = platform_get_irq(pmu_device, i);
			if (irq < 0)
				continue;

			if (request_irq(irq, armv7_pmnc_interrupt, IRQF_DISABLED | IRQF_NOBALANCING, "armpmu", NULL)) {
				pr_err("gator: unable to request IRQ%d for ARM perf counters\n", irq);
				
				// clean up and exit
				for (i = i - 1; i >= 0; --i) {
					irq = platform_get_irq(pmu_device, i);
					if (irq >= 0)
						free_irq(irq, NULL);
				}
				goto out_ebs_start;
			}
		}
	}
#else
	if (event_based_sampling) {
		pr_err("gator: event based sampling only supported in kernel versions 2.6.35 and higher and CONFIG_CPU_HAS_PMU=y\n");
		return -1;
	}
#endif

	return 0;

#if LINUX_PMU_SUPPORT
out_ebs_start:
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0)
	release_pmu(pmu_device);
#else
	release_pmu(ARM_PMU_DEVICE_CPU);
#endif
	pmu_device = NULL;
	return -1;
#endif
}