gpu: host1x: Add conftest support

Instead of relying on kernel version to determine if certain functions
or structure are present in the kernel, use the conftest.sh script to
test which functions, structures, etc are present at compile time. This
is beneficial for working with 3rd party Linux kernels that may have
back-ported upstream changes into their kernel and so the kernel version
checks do not work.

Bug 4119327

Change-Id: I56281fa5d95862338bd8a43d6e22225c27590462
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2984422
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Jon Hunter
2023-09-24 15:40:41 +01:00
committed by mobile promotions
parent 5a26b0ef9d
commit ae64ed46c8
4 changed files with 28 additions and 4 deletions

View File

@@ -5,6 +5,8 @@
* Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
*/
#include <nvidia/conftest.h>
#include <linux/anon_inodes.h>
#include <linux/cdev.h>
#include <linux/file.h>
@@ -415,10 +417,10 @@ static const struct file_operations dev_file_fops = {
.compat_ioctl = dev_file_ioctl,
};
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0))
static char *host1x_fence_devnode(struct device *dev, umode_t *mode)
#else
#if defined(NV_CLASS_STRUCT_DEVNODE_HAS_CONST_DEV_ARG) /* Linux v6.2 */
static char *host1x_fence_devnode(const struct device *dev, umode_t *mode)
#else
static char *host1x_fence_devnode(struct device *dev, umode_t *mode)
#endif
{
*mode = 0666;

View File

@@ -5,6 +5,7 @@
* Copyright (c) 2010-2013, NVIDIA Corporation.
*/
#include <nvidia/conftest.h>
#include <asm/cacheflush.h>
#include <linux/device.h>
@@ -106,7 +107,7 @@ static int host1x_pushbuffer_init(struct push_buffer *pb)
pb->dma = iova_dma_addr(&host1x->iova, alloc);
err = iommu_map(host1x->domain, pb->dma, pb->phys, size,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
#if defined(NV_IOMMU_MAP_HAS_GFP_ARG) /* Linux v6.3 */
IOMMU_READ, GFP_KERNEL);
#else
IOMMU_READ);