drivers: Add compilation flag for iosys-map.h

Determining whether the header file iosys-map.h is present in the kernel
is currently determine by kernel version. However, for Linux v5.15,
iosys-map.h has been backported in order to support simple-framebuffer
for early display. Therefore, we cannot rely on the kernel version to
indicate whether iosys-map is present. This is also true for 3rd party
Linux kernels that backport changes as well. Fix this by adding a
compile time flag, that will be set accordingly by the conftest script
if this header is present.

Bug 4119327
Bug 4228080

Change-Id: Ibd814285b2a07932ede2fbe9e6dc8fd03039d0c3
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2971954
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Jon Hunter
2023-07-28 14:11:20 +01:00
committed by mobile promotions
parent b3b4cf6f51
commit 214beca091
7 changed files with 39 additions and 27 deletions

View File

@@ -1,6 +1,7 @@
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved. # Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
LINUXINCLUDE += -I$(srctree.nvconftest)
LINUXINCLUDE += -I$(srctree.nvidia-oot)/include LINUXINCLUDE += -I$(srctree.nvidia-oot)/include
subdir-ccflags-y += -Werror subdir-ccflags-y += -Werror

View File

@@ -10,6 +10,8 @@
* Copyright (c) 2011 Samsung Electronics Co., Ltd. * Copyright (c) 2011 Samsung Electronics Co., Ltd.
*/ */
#include <nvidia/conftest.h>
#include <linux/dma-buf.h> #include <linux/dma-buf.h>
#include <linux/iommu.h> #include <linux/iommu.h>
#include <linux/module.h> #include <linux/module.h>
@@ -178,7 +180,7 @@ static void tegra_bo_unpin(struct host1x_bo_mapping *map)
static void *tegra_bo_mmap(struct host1x_bo *bo) static void *tegra_bo_mmap(struct host1x_bo *bo)
{ {
struct tegra_bo *obj = host1x_to_tegra_bo(bo); struct tegra_bo *obj = host1x_to_tegra_bo(bo);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0) #if defined(NV_LINUX_IOSYS_MAP_H_PRESENT)
struct iosys_map map = {0}; struct iosys_map map = {0};
#else #else
struct dma_buf_map map = {0}; struct dma_buf_map map = {0};
@@ -199,7 +201,7 @@ static void *tegra_bo_mmap(struct host1x_bo *bo)
static void tegra_bo_munmap(struct host1x_bo *bo, void *addr) static void tegra_bo_munmap(struct host1x_bo *bo, void *addr)
{ {
struct tegra_bo *obj = host1x_to_tegra_bo(bo); struct tegra_bo *obj = host1x_to_tegra_bo(bo);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0) #if defined(NV_LINUX_IOSYS_MAP_H_PRESENT)
struct iosys_map map = IOSYS_MAP_INIT_VADDR(addr); struct iosys_map map = IOSYS_MAP_INIT_VADDR(addr);
#else #else
struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(addr); struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(addr);
@@ -722,7 +724,7 @@ static int tegra_gem_prime_mmap(struct dma_buf *buf, struct vm_area_struct *vma)
return __tegra_gem_mmap(gem, vma); return __tegra_gem_mmap(gem, vma);
} }
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0) #if defined(NV_LINUX_IOSYS_MAP_H_PRESENT)
static int tegra_gem_prime_vmap(struct dma_buf *buf, struct iosys_map *map) static int tegra_gem_prime_vmap(struct dma_buf *buf, struct iosys_map *map)
{ {
struct drm_gem_object *gem = buf->priv; struct drm_gem_object *gem = buf->priv;

View File

@@ -8,6 +8,8 @@
* platform. * platform.
*/ */
#include <nvidia/conftest.h>
#include <linux/dma-buf.h> #include <linux/dma-buf.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/nospec.h> #include <linux/nospec.h>
@@ -526,10 +528,10 @@ int capture_common_setup_progress_status_notifier(
uint32_t mem_offset) uint32_t mem_offset)
{ {
struct dma_buf *dmabuf; struct dma_buf *dmabuf;
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0) #if defined(NV_LINUX_IOSYS_MAP_H_PRESENT)
struct dma_buf_map map = {0};
#else
struct iosys_map map = {0}; struct iosys_map map = {0};
#else
struct dma_buf_map map = {0};
#endif #endif
void *va; void *va;
int err = 0; int err = 0;
@@ -573,10 +575,10 @@ int capture_common_release_progress_status_notifier(
{ {
struct dma_buf *dmabuf = progress_status_notifier->buf; struct dma_buf *dmabuf = progress_status_notifier->buf;
void *va = progress_status_notifier->va; void *va = progress_status_notifier->va;
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0) #if defined(NV_LINUX_IOSYS_MAP_H_PRESENT)
struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(va);
#else
struct iosys_map map = IOSYS_MAP_INIT_VADDR(va); struct iosys_map map = IOSYS_MAP_INIT_VADDR(va);
#else
struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(va);
#endif #endif
if (dmabuf != NULL) { if (dmabuf != NULL) {
@@ -629,10 +631,10 @@ int capture_common_pin_memory(
struct capture_common_buf *unpin_data) struct capture_common_buf *unpin_data)
{ {
struct dma_buf *buf; struct dma_buf *buf;
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0) #if defined(NV_LINUX_IOSYS_MAP_H_PRESENT)
struct dma_buf_map map = {0};
#else
struct iosys_map map = {0}; struct iosys_map map = {0};
#else
struct dma_buf_map map = {0};
#endif #endif
struct dma_buf_attachment *attach; struct dma_buf_attachment *attach;
struct sg_table *sgt; struct sg_table *sgt;
@@ -682,10 +684,10 @@ EXPORT_SYMBOL_GPL(capture_common_pin_memory);
void capture_common_unpin_memory( void capture_common_unpin_memory(
struct capture_common_buf *unpin_data) struct capture_common_buf *unpin_data)
{ {
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0) #if defined(NV_LINUX_IOSYS_MAP_H_PRESENT)
struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(unpin_data->va);
#else
struct iosys_map map = IOSYS_MAP_INIT_VADDR(unpin_data->va); struct iosys_map map = IOSYS_MAP_INIT_VADDR(unpin_data->va);
#else
struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(unpin_data->va);
#endif #endif
if (unpin_data->va) if (unpin_data->va)

View File

@@ -7,6 +7,8 @@
* @brief ISP channel operations for the T186/T194 Camera RTCPU platform. * @brief ISP channel operations for the T186/T194 Camera RTCPU platform.
*/ */
#include <nvidia/conftest.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/nospec.h> #include <linux/nospec.h>
#include <linux/nvhost.h> #include <linux/nvhost.h>
@@ -341,10 +343,10 @@ static int isp_capture_setup_inputfences(
void *reloc_page_addr = NULL; void *reloc_page_addr = NULL;
struct isp_capture *capture = chan->capture_data; struct isp_capture *capture = chan->capture_data;
void *vmap_base = NULL; void *vmap_base = NULL;
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0) #if defined(NV_LINUX_IOSYS_MAP_H_PRESENT)
struct dma_buf_map map;
#else
struct iosys_map map; struct iosys_map map;
#else
struct dma_buf_map map;
#endif #endif
int i = 0; int i = 0;
int err = 0; int err = 0;
@@ -427,10 +429,10 @@ static int isp_capture_setup_prefences(
void *reloc_page_addr = NULL; void *reloc_page_addr = NULL;
struct isp_capture *capture = chan->capture_data; struct isp_capture *capture = chan->capture_data;
void *vmap_base = NULL; void *vmap_base = NULL;
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0) #if defined(NV_LINUX_IOSYS_MAP_H_PRESENT)
struct dma_buf_map map;
#else
struct iosys_map map; struct iosys_map map;
#else
struct dma_buf_map map;
#endif #endif
/* It is valid not to have prefences for given frame capture */ /* It is valid not to have prefences for given frame capture */

View File

@@ -3,6 +3,8 @@
* Copyright (c) 2020-2023, NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2020-2023, NVIDIA CORPORATION. All rights reserved.
*/ */
#include <nvidia/conftest.h>
#include <asm-generic/errno-base.h> #include <asm-generic/errno-base.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/kernel.h> #include <linux/kernel.h>
@@ -48,7 +50,7 @@
void *pva_dmabuf_vmap(struct dma_buf *dmabuf) void *pva_dmabuf_vmap(struct dma_buf *dmabuf)
{ {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0) #if defined(NV_LINUX_IOSYS_MAP_H_PRESENT)
struct iosys_map map = {0}; struct iosys_map map = {0};
#else #else
struct dma_buf_map map = {0}; struct dma_buf_map map = {0};
@@ -67,7 +69,7 @@ void *pva_dmabuf_vmap(struct dma_buf *dmabuf)
void pva_dmabuf_vunmap(struct dma_buf *dmabuf, void *addr) void pva_dmabuf_vunmap(struct dma_buf *dmabuf, void *addr)
{ {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0) #if defined(NV_LINUX_IOSYS_MAP_H_PRESENT)
struct iosys_map map = IOSYS_MAP_INIT_VADDR(addr); struct iosys_map map = IOSYS_MAP_INIT_VADDR(addr);
#else #else
struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(addr); struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(addr);

View File

@@ -7,6 +7,8 @@
#define pr_fmt(fmt) "nvmap: %s() " fmt, __func__ #define pr_fmt(fmt) "nvmap: %s() " fmt, __func__
#include <nvidia/conftest.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
@@ -22,7 +24,7 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/version.h> #include <linux/version.h>
#include <linux/iommu.h> #include <linux/iommu.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0) #if defined(NV_LINUX_IOSYS_MAP_H_PRESENT)
#include <linux/iosys-map.h> #include <linux/iosys-map.h>
#endif #endif
@@ -499,7 +501,7 @@ static void nvmap_dmabuf_vunmap(struct dma_buf *dmabuf, void *vaddr)
__nvmap_munmap(info->handle, vaddr); __nvmap_munmap(info->handle, vaddr);
} }
#else #else
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0) #if defined(NV_LINUX_IOSYS_MAP_H_PRESENT)
static int nvmap_dmabuf_vmap(struct dma_buf *dmabuf, struct iosys_map *map) static int nvmap_dmabuf_vmap(struct dma_buf *dmabuf, struct iosys_map *map)
#else #else
static int nvmap_dmabuf_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map) static int nvmap_dmabuf_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map)
@@ -526,7 +528,7 @@ static int nvmap_dmabuf_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map)
return ret; return ret;
} }
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0) #if defined(NV_LINUX_IOSYS_MAP_H_PRESENT)
static void nvmap_dmabuf_vunmap(struct dma_buf *dmabuf, struct iosys_map *map) static void nvmap_dmabuf_vunmap(struct dma_buf *dmabuf, struct iosys_map *map)
#else #else
static void nvmap_dmabuf_vunmap(struct dma_buf *dmabuf, struct dma_buf_map *map) static void nvmap_dmabuf_vunmap(struct dma_buf *dmabuf, struct dma_buf_map *map)

View File

@@ -106,7 +106,8 @@ $(obj)/conftest/patches.h: $(NV_CONFTEST_SCRIPT)
# corresponding #define will be generated in conftest/headers.h. # corresponding #define will be generated in conftest/headers.h.
NV_HEADER_PRESENCE_TESTS = \ NV_HEADER_PRESENCE_TESTS = \
generated/autoconf.h \ generated/autoconf.h \
linux/kconfig.h linux/kconfig.h \
linux/iosys-map.h
# Filename to store the define for the header in $(1); this is only consumed by # Filename to store the define for the header in $(1); this is only consumed by
# the rule below that concatenates all of these together. # the rule below that concatenates all of these together.