blob: 2334bf8a650a16a35d5849a4b6c309d5f19eb1f1 [file] [log] [blame]
Jamie Iles0f4f0672010-02-02 20:23:15 +01001/*
2 * linux/arch/arm/kernel/pmu.c
3 *
4 * Copyright (C) 2009 picoChip Designs Ltd, Jamie Iles
Will Deacon49c006b2010-04-29 17:13:24 +01005 * Copyright (C) 2010 ARM Ltd, Will Deacon
Jamie Iles0f4f0672010-02-02 20:23:15 +01006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 */
12
Jamie Iles0f4f0672010-02-02 20:23:15 +010013#include <linux/err.h>
Jamie Iles0f4f0672010-02-02 20:23:15 +010014#include <linux/kernel.h>
15#include <linux/module.h>
16
17#include <asm/pmu.h>
18
Will Deaconb0e89592011-07-26 22:10:28 +010019/*
20 * PMU locking to ensure mutual exclusion between different subsystems.
21 */
22static unsigned long pmu_lock[BITS_TO_LONGS(ARM_NUM_PMU_DEVICES)];
Jamie Iles0f4f0672010-02-02 20:23:15 +010023
Will Deaconb0e89592011-07-26 22:10:28 +010024int
Mark Rutland7fdd3c42011-08-12 10:42:48 +010025reserve_pmu(enum arm_pmu_type type)
Will Deacon49c006b2010-04-29 17:13:24 +010026{
Will Deaconb0e89592011-07-26 22:10:28 +010027 return test_and_set_bit_lock(type, pmu_lock) ? -EBUSY : 0;
Jamie Iles0f4f0672010-02-02 20:23:15 +010028}
29EXPORT_SYMBOL_GPL(reserve_pmu);
30
Will Deaconb0e89592011-07-26 22:10:28 +010031void
Mark Rutland7fdd3c42011-08-12 10:42:48 +010032release_pmu(enum arm_pmu_type type)
Jamie Iles0f4f0672010-02-02 20:23:15 +010033{
Will Deaconb0e89592011-07-26 22:10:28 +010034 clear_bit_unlock(type, pmu_lock);
Jamie Iles0f4f0672010-02-02 20:23:15 +010035}
Will Deaconec84d522011-11-14 16:12:52 +000036EXPORT_SYMBOL_GPL(release_pmu);