From b5d808a6ffa12692ad5cbff8450b62309d9aaa5f Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Mon, 4 Dec 2023 20:47:27 +0000 Subject: [PATCH] drm/tegra: Avoid kernel version checks Instead of using kernel version checks in the Tegra DRM driver for the tegra_fb_ops structure, just check if the appropriate definition is defined and if so use it. This fixes building the Tegra DRM driver against some 3rd party kernels that include backports from upstream. Note that this also aligns the driver closer to the upstream code by using the same definitions that the upstream driver uses. Bug 4346767 Change-Id: I8cb40899d0bf7cdc233e5f4cee7b6afb6f12d015 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3027832 (cherry picked from commit 086fc6d3da8f04f2d9c201eba3a0888e0e1618b5) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3030330 Reviewed-by: Laxman Dewangan GVS: Gerrit_Virtual_Submit --- Makefile | 3 --- drivers/gpu/drm/tegra/fb.c | 30 ++++++++++++------------------ 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 43cc05b4..ee1bcabb 100644 --- a/Makefile +++ b/Makefile @@ -50,9 +50,6 @@ subdir-ccflags-y += -DNV_V4L2_ASYNC_NF_SUBDEVICE_INIT_RENAME # Deprecate PCIED Error reporting pci_enable_pcie_error_reporting subdir-ccflags-y += -DNV_DROP_PCIE_ERROR_REPORTING -# FB Deferred IO helpers name alignment -subdir-ccflags-y += -DNV_FB_DEFERRED_IO_OPS_RENAME - # Crypto driver has major change in it ops, skip it export CONFIG_SKIP_CRYPTO=y endif diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c index 49d3ffff..65268404 100644 --- a/drivers/gpu/drm/tegra/fb.c +++ b/drivers/gpu/drm/tegra/fb.c @@ -11,10 +11,7 @@ #include #include - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0) #include -#endif #include #include @@ -214,24 +211,21 @@ static int tegra_fb_mmap(struct fb_info *info, struct vm_area_struct *vma) return __tegra_gem_mmap(&bo->gem, vma); } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0) -#if defined(NV_FB_DEFERRED_IO_OPS_RENAME) -FB_GEN_DEFAULT_DEFERRED_IOMEM_OPS(tegra_fb, - drm_fb_helper_damage_range, - drm_fb_helper_damage_area) -#else -FB_GEN_DEFAULT_DEFERRED_IO_OPS(tegra_fb, - drm_fb_helper_damage_range, - drm_fb_helper_damage_area) -#endif -#endif - static const struct fb_ops tegra_fb_ops = { .owner = THIS_MODULE, +#if defined(__FB_DEFAULT_DMAMEM_OPS_RDWR) /* Linux v6.6 */ + __FB_DEFAULT_DMAMEM_OPS_RDWR, +#elif defined(__FB_DEFAULT_SYS_OPS_RDWR) /* Linux v6.5 */ + __FB_DEFAULT_SYS_OPS_RDWR, +#else + .fb_read = drm_fb_helper_sys_read, + .fb_write = drm_fb_helper_sys_write, +#endif DRM_FB_HELPER_DEFAULT_OPS, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0) - __FB_DEFAULT_DEFERRED_OPS_RDWR(tegra_fb), - __FB_DEFAULT_DEFERRED_OPS_DRAW(tegra_fb), +#if defined(__FB_DEFAULT_DMAMEM_OPS_DRAW) /* Linux v6.6 */ + __FB_DEFAULT_DMAMEM_OPS_DRAW, +#elif defined(__FB_DEFAULT_SYS_OPS_DRAW) /* Linux v6.5 */ + __FB_DEFAULT_SYS_OPS_DRAW, #else .fb_fillrect = drm_fb_helper_sys_fillrect, .fb_copyarea = drm_fb_helper_sys_copyarea,