diff options
author | Seshendra Gadagottu <sgadagottu@nvidia.com> | 2012-09-16 23:04:06 -0700 |
---|---|---|
committer | Simone Willett <swillett@nvidia.com> | 2012-10-10 21:05:02 -0700 |
commit | c1be13b9d1895756acb18054a2c14b595bfd6037 (patch) | |
tree | 5f018ba7afb4941ff146f648b06fc9d9f4813492 | |
parent | 7ade16369da3707fd64f2fc7d17357828e3b8760 (diff) |
ARM: tegra: misc: pmureader driver
Adding kernel module to acccess PMU counters from
the user space for CPU performance monitor.
Currently it is enabled for T114 only.
Reviewed-on: http://git-master/r/132953
(cherry picked from commit cdd30d1385c5bc16158e9ef6b835517b6c56cc75)
Change-Id: I27cf6ee2b262b20af34196fb3812413f52680404
Signed-off-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/143106
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>
-rw-r--r-- | drivers/misc/Makefile | 1 | ||||
-rw-r--r-- | drivers/misc/tegra-pmu-userspace.c | 72 |
2 files changed, 73 insertions, 0 deletions
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index f88e3b50bbcd..d23289ea9e9e 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -66,3 +66,4 @@ obj-$(CONFIG_APANIC) += apanic.o obj-$(CONFIG_THERM_EST) += therm_est.o obj-$(CONFIG_TEGRA_THROUGHPUT) += tegra-throughput.o obj-$(CONFIG_SND_SOC_TEGRA_CS42L73) += a2220.o +obj-$(CONFIG_ARCH_TEGRA_11x_SOC) += tegra-pmu-userspace.o diff --git a/drivers/misc/tegra-pmu-userspace.c b/drivers/misc/tegra-pmu-userspace.c new file mode 100644 index 000000000000..683b43f84166 --- /dev/null +++ b/drivers/misc/tegra-pmu-userspace.c @@ -0,0 +1,72 @@ +/* + * drivers/misc/tegra-pmu-userspace.c + * + * Copyright (C) 2012, NVIDIA CORPORATION. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <linux/module.h> +#include <linux/init.h> +#include <linux/smp.h> + +static void __init enable_userspace_access(void *info) +{ + /* Disabling overflow interrupts. This is done to * + * potential kernel blocking from the userspace */ + asm ("mcr p15, 0, %0, c9, c14, 2\n\t" : : "r"(0x8000000f)); + + /* Enabling the userspace access to the performance counters */ + asm ("mcr p15, 0, %0, c9, c14, 0\n\t" : : "r"(1)); + + printk(KERN_INFO "tegrapmu: performance counters access enabled" \ + "on CPU #%d\n", smp_processor_id()); +} + +static void __exit disable_userspace_access(void *info) +{ + /* Disabling the userspace access to the performance counters */ + asm ("mcr p15, 0, %0, c9, c14, 0\n\t" : : "r"(0)); + + printk(KERN_INFO "tegrapmu: performance counters access disabled" \ + "on CPU #%d\n", smp_processor_id()); +} + +static int __init nvlostcycles_init(void) +{ + printk(KERN_INFO "tegrapmu: init\n"); + + /* Enabling performance counters access from userspace on all cores */ + (void) on_each_cpu(enable_userspace_access, NULL, \ + 1 /* wait for execution */); + + return 0; +} + +static void __exit nvlostcycles_exit(void) +{ + printk(KERN_INFO "nvlostcycles: exit\n"); + + /* Disabling performance counters access from userspace on all cores */ + (void) on_each_cpu(disable_userspace_access, NULL, \ + 1 /* wait for execution */); + + return; +} + +module_init(nvlostcycles_init); +module_exit(nvlostcycles_exit); + +MODULE_LICENSE("GPL"); + |