From 086fc6d3da8f04f2d9c201eba3a0888e0e1618b5 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 Tested-by: mobile promotions Reviewed-by: mobile promotions --- Makefile | 3 --- drivers/gpu/drm/tegra/fb.c | 30 ++++++++++++------------------ 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 2f77c1c7..4fa23ab3 100644 --- a/Makefile +++ b/Makefile @@ -58,9 +58,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 - # Drop the API for pcie_disable_pcie_error_reporting subdir-ccflags-y += -DNV_PCIE_DIABLE_PCIE_ERROR_REPORTING_DROP 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,