]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
drivers: cma: add dma_contiguous_stats()
authorVandana Salve <vsalve@nvidia.com>
Fri, 8 Nov 2013 19:15:58 +0000 (00:45 +0530)
committerKrishna Reddy <vdumpa@nvidia.com>
Wed, 13 Nov 2013 23:57:12 +0000 (15:57 -0800)
Added the dma_contiguous_stats() to get CMA
stats such as base and size from the given dev

bug 1279160

Change-Id: I066e35e7fda140f8613a3d4364464587d3bd251d
Signed-off-by: Vandana Salve <vsalve@nvidia.com>
Reviewed-on: http://git-master/r/328412
GVS: Gerrit_Virtual_Submit
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
Tested-by: Krishna Reddy <vdumpa@nvidia.com>
drivers/base/dma-contiguous.c
include/linux/dma-contiguous.h

index 0ca54421ce977b7f82055644a08d8ea0ae3ca406..5e3bf5607746fe23329b0d0f1778fedb6224eafd 100644 (file)
@@ -388,3 +388,23 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages,
 
        return true;
 }
+
+int dma_get_contiguous_stats(struct device *dev,
+                       struct dma_contiguous_stats *stats)
+{
+       struct cma *cma = NULL;
+
+       if ((!dev) || !stats)
+               return -EINVAL;
+
+       if (dev->cma_area)
+               cma = dev->cma_area;
+
+       if (!cma)
+               return -EINVAL;
+
+       stats->size = (cma->count) << PAGE_SHIFT;
+       stats->base = (cma->base_pfn) << PAGE_SHIFT;
+
+       return 0;
+}
index 01b5c84be8284fef2f721e26c1b3fb3d95a72bbf..0d411813bf55ad1f14b2366a718fd7e59c12e766 100644 (file)
@@ -59,6 +59,11 @@ struct device;
 
 #ifdef CONFIG_CMA
 
+struct dma_contiguous_stats {
+       phys_addr_t base;
+       size_t size;
+};
+
 /*
  * There is always at least global CMA area and a few optional device
  * private areas configured in kernel .config.
@@ -75,6 +80,8 @@ struct page *dma_alloc_from_contiguous(struct device *dev, int count,
                                       unsigned int order);
 bool dma_release_from_contiguous(struct device *dev, struct page *pages,
                                 int count);
+int dma_get_contiguous_stats(struct device *dev,
+                       struct dma_contiguous_stats *stats);
 
 #else
 
@@ -103,6 +110,12 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages,
        return false;
 }
 
+static inline
+int dma_get_contiguous_stats(struct device *dev,
+                       struct dma_contiguous_stats *stats)
+{
+       return -ENOSYS;
+}
 #endif
 
 #endif