video: tegra: nvmap: add API to get iovmm used pages
Krishna Reddy [Wed, 19 Jun 2013 18:42:13 +0000 (11:42 -0700)]
Change-Id: Idc33050777122f1bfe1bbbe53fee305a7f1c3c54
Signed-off-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-on: http://git-master/r/240288
(cherry picked from commit 458538daac9b1f36764956f92d64769bd4d3abe2)
Reviewed-on: http://git-master/r/246829
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User

drivers/video/tegra/nvmap/nvmap_dev.c
include/linux/nvmap.h

index f159ed0..4ab500f 100644 (file)
@@ -3,7 +3,7 @@
  *
  * User-space interface to nvmap
  *
- * Copyright (c) 2011-2012, NVIDIA Corporation.
+ * Copyright (c) 2011-2013, 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
@@ -1066,6 +1066,25 @@ static const struct file_operations debug_iovmm_allocations_fops = {
        .release = single_release,
 };
 
+ulong nvmap_iovmm_get_used_pages(void)
+{
+       unsigned long flags;
+       unsigned int total = 0;
+       struct nvmap_client *client;
+       struct nvmap_device *dev = nvmap_dev;
+
+       if (!dev)
+               return 0;
+
+       spin_lock_irqsave(&dev->clients_lock, flags);
+       list_for_each_entry(client, &dev->clients, list) {
+               total += atomic_read(&client->iovm_commit);
+       }
+       spin_unlock_irqrestore(&dev->clients_lock, flags);
+
+       return total >> PAGE_SHIFT;
+}
+
 static void nvmap_deferred_ops_init(struct nvmap_deferred_ops *deferred_ops)
 {
        INIT_LIST_HEAD(&deferred_ops->ops_list);
index 7de9c17..06e9ddd 100644 (file)
@@ -175,6 +175,8 @@ static inline nvmap_page_pool_get_unused_pages(void)
 }
 #endif
 
+ulong nvmap_iovmm_get_used_pages(void);
+
 struct nvmap_platform_carveout {
        const char *name;
        unsigned int usage_mask;