]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
misc: tegra-profiler: fix incorrect names
authorIgor Nabirushkin <inabirushkin@nvidia.com>
Sat, 7 Sep 2013 07:36:23 +0000 (11:36 +0400)
committerDan Willemsen <dwillemsen@nvidia.com>
Fri, 27 Sep 2013 02:46:22 +0000 (19:46 -0700)
Tegra Profiler: fix incorrect names of modules.
mmap buffers are created for each core

Bug 1364251
Bug 1312406

Change-Id: Ib60fa45e5418de3acf2afd782c53650f17731976
Signed-off-by: Igor Nabirushkin <inabirushkin@nvidia.com>
Reviewed-on: http://git-master/r/271821
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Tested-by: Maxim Morin <mmorin@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
drivers/misc/tegra-profiler/main.c
drivers/misc/tegra-profiler/mmap.c
drivers/misc/tegra-profiler/mmap.h
drivers/misc/tegra-profiler/version.h

index dc46c6d4f5fab7c31c5659c485646f25ddff3328..7cc07627fa1715dc8633c1809a636ea5f052a4d7 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/err.h>
 
 #include <linux/tegra_profiler.h>
 
@@ -428,9 +429,9 @@ static int __init quadd_module_init(void)
        }
 
        ctx.mmap = quadd_mmap_init(&ctx);
-       if (!ctx.mmap) {
+       if (IS_ERR(ctx.mmap)) {
                pr_err("error: MMAP init failed\n");
-               return -ENODEV;
+               return PTR_ERR(ctx.mmap);
        }
 
        err = quadd_power_clk_init(&ctx);
index a52b11f74cd2a78b03d19afb9a5a7ac35ba03cfb..370508b84f2ba96c5df1ae7559d0d6f79c5066d6 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/crc32.h>
 #include <linux/fs.h>
 #include <linux/slab.h>
+#include <linux/err.h>
 
 #include <linux/tegra_profiler.h>
 
@@ -103,14 +104,16 @@ char *quadd_get_mmap(struct quadd_cpu_context *cpu_ctx,
                     struct pt_regs *regs, struct quadd_mmap_data *sample,
                     unsigned int *extra_length)
 {
+       u32 crc;
+       unsigned long ip;
+       int length, length_aligned;
        struct mm_struct *mm = current->mm;
        struct vm_area_struct *vma;
        struct file *vm_file;
        struct path *path;
        char *file_name = NULL;
-       int length, length_aligned;
-       u32 crc;
-       unsigned long ip;
+       struct quadd_mmap_cpu_ctx *mm_cpu_ctx = this_cpu_ptr(mmap_ctx.cpu_ctx);
+       char *tmp_buf = mm_cpu_ctx->tmp_buf;
 
        if (!mm) {
                *extra_length = 0;
@@ -130,8 +133,10 @@ char *quadd_get_mmap(struct quadd_cpu_context *cpu_ctx,
 
                        path = &vm_file->f_path;
 
-                       file_name = d_path(path, mmap_ctx.tmp_buf, PATH_MAX);
-                       if (file_name) {
+                       file_name = d_path(path, tmp_buf, PATH_MAX);
+                       if (IS_ERR(file_name)) {
+                               file_name = NULL;
+                       } else {
                                sample->addr = vma->vm_start;
                                sample->len = vma->vm_end - vma->vm_start;
                                sample->pgoff =
@@ -184,29 +189,39 @@ char *quadd_get_mmap(struct quadd_cpu_context *cpu_ctx,
 
 struct quadd_mmap_ctx *quadd_mmap_init(struct quadd_ctx *quadd_ctx)
 {
+       int cpu_id;
        u32 *hash;
        char *tmp;
+       struct quadd_mmap_cpu_ctx *cpu_ctx;
 
        mmap_ctx.quadd_ctx = quadd_ctx;
 
        hash = kzalloc(QUADD_MMAP_SIZE_ARRAY * sizeof(unsigned int),
                       GFP_KERNEL);
        if (!hash) {
-               pr_err("Alloc error\n");
-               return NULL;
+               pr_err("Failed to allocate mmap buffer\n");
+               return ERR_PTR(-ENOMEM);
        }
        mmap_ctx.hash_array = hash;
 
        mmap_ctx.nr_hashes = 0;
        spin_lock_init(&mmap_ctx.lock);
 
-       tmp = kzalloc(PATH_MAX + sizeof(unsigned long long),
-                     GFP_KERNEL);
-       if (!tmp) {
-               pr_err("Alloc error\n");
-               return NULL;
+       mmap_ctx.cpu_ctx = alloc_percpu(struct quadd_mmap_cpu_ctx);
+       if (!mmap_ctx.cpu_ctx)
+               return ERR_PTR(-ENOMEM);
+
+       for (cpu_id = 0; cpu_id < nr_cpu_ids; cpu_id++) {
+               cpu_ctx = per_cpu_ptr(mmap_ctx.cpu_ctx, cpu_id);
+
+               tmp = kzalloc(PATH_MAX + sizeof(unsigned long long),
+                             GFP_KERNEL);
+               if (!tmp) {
+                       pr_err("Failed to allocate mmap buffer\n");
+                       return ERR_PTR(-ENOMEM);
+               }
+               cpu_ctx->tmp_buf = tmp;
        }
-       mmap_ctx.tmp_buf = tmp;
 
        return &mmap_ctx;
 }
@@ -222,15 +237,19 @@ void quadd_mmap_reset(void)
 
 void quadd_mmap_deinit(void)
 {
+       int cpu_id;
        unsigned long flags;
+       struct quadd_mmap_cpu_ctx *cpu_ctx;
 
        spin_lock_irqsave(&mmap_ctx.lock, flags);
-
        kfree(mmap_ctx.hash_array);
        mmap_ctx.hash_array = NULL;
 
-       kfree(mmap_ctx.tmp_buf);
-       mmap_ctx.tmp_buf = NULL;
+       for (cpu_id = 0; cpu_id < nr_cpu_ids; cpu_id++) {
+               cpu_ctx = per_cpu_ptr(mmap_ctx.cpu_ctx, cpu_id);
+               kfree(cpu_ctx->tmp_buf);
+       }
+       free_percpu(mmap_ctx.cpu_ctx);
 
        spin_unlock_irqrestore(&mmap_ctx.lock, flags);
 }
index f12ec4d61ed5faa9d7de03a1bc543d0c243436af..dd750f956df96e3d45f8f0656e8d724455d8d8f1 100644 (file)
@@ -25,12 +25,16 @@ struct quadd_mmap_data;
 
 #define QUADD_MMAP_SIZE_ARRAY  4096
 
+struct quadd_mmap_cpu_ctx {
+       char *tmp_buf;
+};
+
 struct quadd_mmap_ctx {
        u32 *hash_array;
        unsigned int nr_hashes;
        spinlock_t lock;
 
-       char *tmp_buf;
+       struct quadd_mmap_cpu_ctx * __percpu cpu_ctx;
 
        struct quadd_ctx *quadd_ctx;
 };
index efaa135d15c956556e2529e8b8e2ac2e02a0e3cd..c24895433449e936f9b1c77895a4cda67dc42043 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef __QUADD_VERSION_H
 #define __QUADD_VERSION_H
 
-#define QUADD_MODULE_VERSION           "1.27"
-#define QUADD_MODULE_BRANCH            "Blackrock2"
+#define QUADD_MODULE_VERSION           "1.28"
+#define QUADD_MODULE_BRANCH            "Dev"
 
 #endif /* __QUADD_VERSION_H */