]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commitdiff
video: tegra: nvmap: fix build errors
authorSri Krishna chowdary <schowdary@nvidia.com>
Tue, 5 Apr 2016 11:28:34 +0000 (16:58 +0530)
committerSri Krishna chowdary <schowdary@nvidia.com>
Tue, 5 Apr 2016 11:43:27 +0000 (17:13 +0530)
Change-Id: I95c389e70d811a99e6e84cfe1b730cf801ebe520
Signed-off-by: Sri Krishna chowdary <schowdary@nvidia.com>
12 files changed:
arch/arm64/include/asm/device.h
drivers/video/Kconfig
drivers/video/Makefile
drivers/video/tegra/nvmap/Kconfig
drivers/video/tegra/nvmap/nvmap_dev.c
drivers/video/tegra/nvmap/nvmap_dmabuf.c
drivers/video/tegra/nvmap/nvmap_heap.c
drivers/video/tegra/nvmap/nvmap_heap.h
drivers/video/tegra/nvmap/nvmap_init.c
drivers/video/tegra/nvmap/nvmap_ioctl.c
include/linux/dma-attrs.h
include/linux/nvmap.h

index 243ef256b8c9e3a33f86ec3c19a8843cc3d1126a..87028b45bcf5ceb14bcb6b46f06f05404b4e4929 100644 (file)
@@ -27,4 +27,10 @@ struct dev_archdata {
 struct pdev_archdata {
 };
 
+#ifdef CONFIG_ARM_DMA_USE_IOMMU
+#define to_dma_iommu_mapping(dev) ((dev)->archdata.mapping)
+#else
+#define to_dma_iommu_mapping(dev) NULL
+#endif
+
 #endif
index 35d239ebf9125cac6a4d75fa97bc3e51262c5d22..d3ad4d228c2c060bd723eadf416a49e408de4d19 100644 (file)
@@ -31,6 +31,8 @@ endmenu
 source "drivers/video/backlight/Kconfig"
 source "drivers/video/adf/Kconfig"
 
+source "drivers/video/tegra/Kconfig"
+
 config VGASTATE
        tristate
        default n
index 1a8c4ced39b29c145bf4c4cfd1fc44cd5ea7d2c7..48b232e4a5908eae95d6f835715af7e5114355c5 100644 (file)
@@ -8,6 +8,8 @@ obj-y                             += backlight/
 
 obj-y                            += fbdev/
 
+obj-y                            += tegra/
+
 obj-$(CONFIG_VIDEOMODE_HELPERS) += display_timing.o videomode.o
 ifeq ($(CONFIG_OF),y)
 obj-$(CONFIG_VIDEOMODE_HELPERS) += of_display_timing.o of_videomode.o
index 753139e9e45890bbfb5a3c1fb98d8513f1f12849..a5585d66bd31a0b7c2c3b804329afb87bf650f05 100644 (file)
@@ -135,4 +135,12 @@ config NVMAP_DEFER_FD_RECYCLE_MAX_FD
          Once last allocated FD reaches this number, allocation of subsequent
          FD's start from NVMAP_START_FD.
 
+config NVMAP_SUPPORTS_RESIZABLE_CMA
+       bool "Support resizable cma heaps"
+       depends on DMA_CMA
+       default n
+       help
+         Support for resizable carveouts is more of an enhancement than a requirement.
+         Select this option when platforms needs resizable CMA carveouts.
+
 endif
index 07c5d5c44e6641a464c59d89845938389756eee9..9948135f133ce41bbfebe790b6195738cf010f92 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include <linux/backing-dev.h>
+#include <linux/backing-dev-defs.h>
 #include <linux/bitmap.h>
 #include <linux/debugfs.h>
 #include <linux/delay.h>
@@ -60,10 +61,13 @@ struct nvmap_stats nvmap_stats;
 
 static struct backing_dev_info nvmap_bdi = {
        .ra_pages       = 0,
-       .capabilities   = (BDI_CAP_NO_ACCT_AND_WRITEBACK |
-                          BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP),
+       .capabilities   = BDI_CAP_NO_ACCT_AND_WRITEBACK,
 };
 
+#ifndef CONFIG_MMU
+static unsigned nvmap_mmap_capabilities(struct file *filp);
+#endif
+
 static struct device_dma_parameters nvmap_dma_parameters = {
        .max_segment_size = UINT_MAX,
 };
@@ -82,6 +86,9 @@ static const struct file_operations nvmap_user_fops = {
        .compat_ioctl = nvmap_ioctl,
 #endif
        .mmap           = nvmap_map,
+#ifndef CONFIG_MMU
+       .mmap_capabilities = nvmap_mmap_capabilities,
+#endif
 };
 
 /*
@@ -487,7 +494,7 @@ static int nvmap_open(struct inode *inode, struct file *filp)
 
        priv->kernel_client = false;
 
-       filp->f_mapping->backing_dev_info = &nvmap_bdi;
+       inode->i_sb->s_bdi = &nvmap_bdi;
 
        filp->private_data = priv;
        return 0;
@@ -548,6 +555,13 @@ static int nvmap_map(struct file *filp, struct vm_area_struct *vma)
        return -EPERM;
 }
 
+#ifndef CONFIG_MMU
+static unsigned nvmap_mmap_capabilities(struct file *filp)
+{
+       return NOMMU_MAP_READ | NOMMU_MAP_WRITE;
+}
+#endif
+
 static long nvmap_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
        int err = 0;
index 773a3ed3c655448822c887431fc3ed23a1a8587a..439b650859bbbc7062ac7a076edac2ea8d206fff 100644 (file)
@@ -605,6 +605,7 @@ struct dma_buf *__nvmap_make_dmabuf(struct nvmap_client *client,
        int err;
        struct dma_buf *dmabuf;
        struct nvmap_handle_info *info;
+       DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
 
        info = kzalloc(sizeof(*info), GFP_KERNEL);
        if (!info) {
@@ -615,8 +616,12 @@ struct dma_buf *__nvmap_make_dmabuf(struct nvmap_client *client,
        INIT_LIST_HEAD(&info->maps);
        mutex_init(&info->maps_lock);
 
-       dmabuf = dma_buf_export(info, &nvmap_dma_buf_ops, handle->size,
-                               O_RDWR, NULL);
+       exp_info.priv = info;
+       exp_info.ops = &nvmap_dma_buf_ops;
+       exp_info.size = handle->size;
+       exp_info.flags = O_RDWR;
+
+       dmabuf = dma_buf_export(&exp_info);
        if (IS_ERR(dmabuf)) {
                err = PTR_ERR(dmabuf);
                goto err_export;
index abe055ca16d9cf47d40f1f86379bb5b1011495ee..32a99d0972b7f4a3af4c1756cc3d1545eb0ed569 100644 (file)
@@ -59,6 +59,7 @@ struct list_block {
        unsigned int mem_prot;
        phys_addr_t orig_addr;
        size_t size;
+       size_t align;
        struct nvmap_heap *heap;
        struct list_head free_list;
 };
@@ -113,6 +114,7 @@ static phys_addr_t nvmap_alloc_mem(struct nvmap_heap *h, size_t len,
 
        dma_set_attr(DMA_ATTR_ALLOC_EXACT_SIZE, &attrs);
 
+#ifdef CONFIG_TEGRA_VIRTUALIZATION
        if (start && h->is_ivm) {
                void *ret;
                pa = h->base + (*start);
@@ -125,7 +127,9 @@ static phys_addr_t nvmap_alloc_mem(struct nvmap_heap *h, size_t len,
                        dev_dbg(dev, "reserved (%pa) len(%zu)\n",
                                &pa, len);
                }
-       } else {
+       } else
+#endif
+       {
                (void)dma_alloc_attrs(dev, len, &pa,
                                DMA_MEMORY_NOMAP, &attrs);
                if (!dma_mapping_error(dev, pa))
@@ -143,9 +147,12 @@ static void nvmap_free_mem(struct nvmap_heap *h, phys_addr_t base,
        DEFINE_DMA_ATTRS(attrs);
 
        dev_dbg(dev, "Free base (%pa) size (%zu)\n", &base, len);
+#ifdef CONFIG_TEGRA_VIRTUALIZATION
        if (h->is_ivm && !h->can_alloc) {
                dma_mark_declared_memory_unoccupied(dev, base, len);
-       } else {
+       } else
+#endif
+       {
                dma_set_attr(DMA_ATTR_ALLOC_EXACT_SIZE, &attrs);
                dma_free_attrs(dev, len,
                                (void *)(uintptr_t)base,
@@ -292,8 +299,7 @@ struct nvmap_heap_block *nvmap_heap_alloc(struct nvmap_heap *h,
        return b;
 }
 
-/* nvmap_heap_free: frees block b*/
-void nvmap_heap_free(struct nvmap_heap_block *b)
+struct nvmap_heap *nvmap_block_to_heap(struct nvmap_heap_block *b)
 {
        struct list_block *lb;
        lb = container_of(b, struct list_block, block);
@@ -333,7 +339,7 @@ struct nvmap_heap *nvmap_heap_create(struct device *parent,
 
        h->dma_dev = co->dma_dev;
        if (co->cma_dev) {
-#ifdef CONFIG_DMA_CMA
+#ifdef CONFIG_NVMAP_SUPPORT_RESIZABLE_CMA
                struct dma_contiguous_stats stats;
 
                if (dma_get_contiguous_stats(co->cma_dev, &stats))
index 182be7285c5eda3906579bd2da8e621dce7589fd..beece9a117bc2a4fc9e5d530710cbf7c4990822b 100644 (file)
@@ -3,7 +3,7 @@
  *
  * GPU heap allocator.
  *
- * Copyright (c) 2010-2015, NVIDIA Corporation. All rights reserved.
+ * Copyright (c) 2010-2016, 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
@@ -30,6 +30,7 @@ struct nvmap_client;
 struct nvmap_heap_block {
        unsigned long   base;
        unsigned int    type;
+       struct nvmap_handle *handle;
 };
 
 struct nvmap_heap *nvmap_heap_create(struct device *parent,
index 9569946216d501cbc2f79e17e91416d8108104c1..3698d5037f046792a026012c0cef739585fa8fe6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2014-2016, 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
@@ -18,7 +18,7 @@
 
 #define pr_fmt(fmt) "%s: " fmt, __func__
 
-#include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_fdt.h>
 #include <linux/of_platform.h>
@@ -26,6 +26,7 @@
 #include <linux/nvmap.h>
 #include <linux/tegra-ivc.h>
 #include <linux/dma-contiguous.h>
+#include <linux/cma.h>
 
 #include <asm/dma-contiguous.h>
 
@@ -33,7 +34,9 @@
 #include "iomap.h"
 #include "board.h"
 #include <linux/platform/tegra/common.h>
+#ifdef CONFIG_TEGRA_VIRTUALIZATION
 #include "../../../drivers/virt/tegra/syscalls.h"
+#endif
 
 phys_addr_t __weak tegra_carveout_start;
 phys_addr_t __weak tegra_carveout_size;
@@ -50,13 +53,15 @@ EXPORT_SYMBOL(tegra_vpr_dev);
 struct device __weak tegra_iram_dev;
 struct device __weak tegra_generic_cma_dev;
 struct device __weak tegra_vpr_cma_dev;
-struct dma_resize_notifier_ops __weak vpr_dev_ops;
 
 static const struct of_device_id nvmap_of_ids[] = {
        { .compatible = "nvidia,carveouts" },
        { }
 };
 
+#ifdef CONFIG_NVMAP_SUPPORT_RESIZABLE_CMA
+struct dma_resize_notifier_ops __weak vpr_dev_ops;
+
 static struct dma_declare_info generic_dma_info = {
        .name = "generic",
        .size = 0,
@@ -68,6 +73,7 @@ static struct dma_declare_info vpr_dma_info = {
        .size = SZ_32M,
        .notifier.ops = &vpr_dev_ops,
 };
+#endif
 
 static struct nvmap_platform_carveout nvmap_carveouts[4] = {
        [0] = {
@@ -85,7 +91,9 @@ static struct nvmap_platform_carveout nvmap_carveouts[4] = {
                .size           = 0,
                .dma_dev        = &tegra_generic_dev,
                .cma_dev        = &tegra_generic_cma_dev,
+#ifdef CONFIG_NVMAP_SUPPORT_RESIZABLE_CMA
                .dma_info       = &generic_dma_info,
+#endif
        },
        [2] = {
                .name           = "vpr",
@@ -94,7 +102,9 @@ static struct nvmap_platform_carveout nvmap_carveouts[4] = {
                .size           = 0,
                .dma_dev        = &tegra_vpr_dev,
                .cma_dev        = &tegra_vpr_cma_dev,
+#ifdef CONFIG_NVMAP_SUPPORT_RESIZABLE_CMA
                .dma_info       = &vpr_dma_info,
+#endif
                .enable_static_dma_map = true,
        },
 };
@@ -252,6 +262,9 @@ static int __init nvmap_co_device_init(struct reserved_mem *rmem,
                                "%s :dma coherent mem declare fail %pa,%zu\n",
                                co->name, &co->base, co->size);
        } else {
+#ifndef CONFIG_NVMAP_SUPPORT_RESIZABLE_CMA
+               return -ENODEV;
+#else
                /*
                 * When vpr memory is reserved, kmemleak tries to scan vpr
                 * memory for pointers. vpr memory should not be accessed
@@ -270,6 +283,7 @@ static int __init nvmap_co_device_init(struct reserved_mem *rmem,
                                     co->name);
                else
                        co->init_done = true;
+#endif
        }
        return err;
 }
index 0b8bcbae22be52d53c0133a93882f2e690726a8b..6b5e93e9e94d5c2cc1a214de45a956f491ed4da4 100644 (file)
@@ -191,7 +191,9 @@ int nvmap_ioctl_vpr_floor_size(struct file *filp, void __user *arg)
        if (copy_from_user(&floor_size, arg, sizeof(floor_size)))
                return -EFAULT;
 
+#ifdef CONFIG_NVMAP_SUPPORT_RESIZABLE_CMA
        err = dma_set_resizable_heap_floor_size(&tegra_vpr_dev, floor_size);
+#endif
        return err;
 }
 
index d23f28f4d29a8c132c90bd24f9005e6b0732ad60..404af4691ea97304b8b7e1523757cc022cd84887 100644 (file)
@@ -18,6 +18,7 @@ enum dma_attr {
        DMA_ATTR_NO_KERNEL_MAPPING,
        DMA_ATTR_SKIP_CPU_SYNC,
        DMA_ATTR_FORCE_CONTIGUOUS,
+       DMA_ATTR_SKIP_IOVA_GAP,
        DMA_ATTR_ALLOC_EXACT_SIZE,
        DMA_ATTR_MAX,
 };
index 7bb6a2d0d2ffa812c5c3271c5b6c30fbe05bd41a..17e248dc5c48e0db10489c63404a23596c9fc228 100644 (file)
@@ -36,6 +36,7 @@
 /* common carveout heaps */
 #define NVMAP_HEAP_CARVEOUT_IRAM    (1ul<<29)
 #define NVMAP_HEAP_CARVEOUT_VPR     (1ul<<28)
+#define NVMAP_HEAP_CARVEOUT_IVM     (1ul<<1)
 #define NVMAP_HEAP_CARVEOUT_GENERIC (1ul<<0)
 
 #define NVMAP_HEAP_CARVEOUT_MASK    (NVMAP_HEAP_IOVMM - 1)
@@ -52,7 +53,6 @@
 
 #define NVMAP_HANDLE_KIND_SPECIFIED  (0x1ul << 3)
 #define NVMAP_HANDLE_COMPR_SPECIFIED (0x1ul << 4)
-#define NVMAP_HANDLE_ZEROED_PAGES    (0x1ul << 5)
 #define NVMAP_HANDLE_PHYS_CONTIG     (0x1ul << 6)
 #define NVMAP_HANDLE_CACHE_SYNC      (0x1ul << 7)
 #define NVMAP_HANDLE_CACHE_SYNC_AT_RESERVE      (0x1ul << 8)
@@ -139,6 +139,15 @@ struct nvmap_alloc_handle {
        __u32 align;            /* min alignment necessary */
 };
 
+struct nvmap_alloc_ivm_handle {
+       __u32 handle;           /* nvmap handle */
+       __u32 heap_mask;        /* heaps to allocate from */
+       __u32 flags;            /* wb/wc/uc/iwb etc. */
+       __u32 align;            /* min alignment necessary */
+       __u32 peer;             /* peer with whom handle must be shared. Used
+                                * only for NVMAP_HEAP_CARVEOUT_IVM
+                                */
+};
 
 struct nvmap_alloc_kind_handle {
        __u32 handle;           /* nvmap handle */
@@ -327,6 +336,11 @@ struct nvmap_debugfs_handles_entry {
 /* Perform reserve operation on a list of handles. */
 #define NVMAP_IOC_RESERVE _IOW(NVMAP_IOC_MAGIC, 18,    \
                                  struct nvmap_cache_op_list)
+
+#define NVMAP_IOC_FROM_IVC_ID _IOWR(NVMAP_IOC_MAGIC, 19, struct nvmap_create_handle)
+#define NVMAP_IOC_GET_IVC_ID _IOWR(NVMAP_IOC_MAGIC, 20, struct nvmap_create_handle)
+#define NVMAP_IOC_GET_IVM_HEAPS _IOR(NVMAP_IOC_MAGIC, 21, unsigned int)
+
 /* START of T124 IOCTLS */
 /* Actually allocates memory for the specified handle, with kind */
 #define NVMAP_IOC_ALLOC_KIND _IOW(NVMAP_IOC_MAGIC, 100, struct nvmap_alloc_kind_handle)