diff --git a/drivers/gpu/nvgpu/Kconfig b/drivers/gpu/nvgpu/Kconfig index ca1db973e..ac0fa2614 100644 --- a/drivers/gpu/nvgpu/Kconfig +++ b/drivers/gpu/nvgpu/Kconfig @@ -135,3 +135,14 @@ config NVGPU_SUPPORT_CDE default y help Enable support for extraction of comptags for CDE. + +config NVGPU_USE_TEGRA_ALLOC_FD + bool "Use tegra_alloc_fd() for allocating dma_buf fds for vidmem" + depends on GK20A && GK20A_VIDMEM + default y + help + Use tegra_alloc_fd() for allocating dma_buf fds. This allocates + the fds above 1024 which exempts them from counting against process + fd limit. + + It is only available in Tegra kernel. diff --git a/drivers/gpu/nvgpu/common/linux/vidmem.c b/drivers/gpu/nvgpu/common/linux/vidmem.c index 684262baa..136d4a102 100644 --- a/drivers/gpu/nvgpu/common/linux/vidmem.c +++ b/drivers/gpu/nvgpu/common/linux/vidmem.c @@ -17,7 +17,9 @@ #include #include +#ifdef CONFIG_NVGPU_USE_TEGRA_ALLOC_FD #include +#endif #include #include @@ -195,7 +197,11 @@ int nvgpu_vidmem_export_linux(struct gk20a *g, size_t bytes) buf->priv = priv; +#ifdef CONFIG_NVGPU_USE_TEGRA_ALLOC_FD fd = tegra_alloc_fd(current->files, 1024, O_RDWR); +#else + fd = get_unused_fd_flags(O_RDWR); +#endif if (fd < 0) { /* ->release frees what we have done */ dma_buf_put(priv->dmabuf);