From 7f53d7ba3e009b7f0f7e6a2e733910215b7847b7 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Wed, 11 Oct 2023 13:45:05 +0100 Subject: [PATCH] nvidia-oot: Add options to disable drivers In Linux v6.2, the Tegra IVC driver was updated to support iosys-map and this breaks building some of the out-of-tree drivers for Linux v6.2+ kernels. In Linux v6.3, the GPIO OF APIs were removed and this breaks building some of the out-of-tree drivers that use these legacy APIs. For now the broken drivers are not built for these corresponding kernels. Instead of checking the kernel version in the Makefile for the corresponding broken driver, move the kernel version checking to the top-level Makefile and add CONFIG definitions that can be used the various Makefiles. This is also needed for working with 3rd party Linux kernels that may have upstream backports and need to set these CONFIG variables for their Linux kernel. Bug 4221847 Change-Id: I35ee59bccdcdb1be56e4680c453279b421692c6a Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2996215 Tested-by: mobile promotions Reviewed-by: mobile promotions --- Makefile | 16 ++++++++++++++++ drivers/firmware/tegra/Makefile | 6 +----- drivers/media/platform/tegra/cdi/Makefile | 6 +----- drivers/media/platform/tegra/isc/Makefile | 3 +-- drivers/misc/Makefile | 8 +++----- drivers/platform/tegra/rtcpu/Makefile | 6 +----- include/linux/tegra-capture-ivc.h | 4 ++-- 7 files changed, 25 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index f427f758..fdb4b095 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,22 @@ LINUXINCLUDE += -I$(srctree.nvidia-oot)/include subdir-ccflags-y += -Werror +LINUX_VERSION := $(shell expr $(VERSION) \* 256 + $(PATCHLEVEL)) +LINUX_VERSION_6_2 := $(shell expr 6 \* 256 + 2) +LINUX_VERSION_6_3 := $(shell expr 6 \* 256 + 3) + +# The Tegra IVC driver was updated to support iosys-map in Linux v6.2. +# For Linux v6.2 kernels, don't build any drivers that requires this. +ifeq ($(shell test $(LINUX_VERSION) -ge $(LINUX_VERSION_6_2); echo $$?),0) +export CONFIG_TEGRA_IVC_LEGACY_DISABLE=y +subdir-ccflags-y += -DCONFIG_TEGRA_IVC_LEGACY_DISABLE +endif + +# Legacy GPIO support is removed in Linux v6.3 +ifeq ($(shell test $(LINUX_VERSION) -ge $(LINUX_VERSION_6_3); echo $$?),0) +export CONFIG_TEGRA_GPIO_LEGACY_DISABLE=y +endif + ifeq ($(CONFIG_TEGRA_VIRTUALIZATION),y) subdir-ccflags-y += -DCONFIG_TEGRA_VIRTUALIZATION endif diff --git a/drivers/firmware/tegra/Makefile b/drivers/firmware/tegra/Makefile index 4c88b620..5d8e8ac3 100644 --- a/drivers/firmware/tegra/Makefile +++ b/drivers/firmware/tegra/Makefile @@ -5,11 +5,8 @@ # Makefile for Extended IVC Driver and BPMP driver # -LINUX_VERSION := $(shell expr $(VERSION) \* 256 + $(PATCHLEVEL)) -LINUX_VERSION_6_2 := $(shell expr 6 \* 256 + 2) - obj-m += ivc_ext.o -ifeq ($(shell test $(LINUX_VERSION) -lt $(LINUX_VERSION_6_2); echo $$?),0) +ifneq ($(CONFIG_TEGRA_IVC_LEGACY_DISABLE),y) tegra_bpmp-y += ../../clk/tegra/clk-bpmp.o tegra_bpmp-y += ../../reset/tegra/reset-bpmp.o tegra_bpmp-y += ../../soc/tegra/powergate-bpmp.o @@ -17,4 +14,3 @@ tegra_bpmp-$(CONFIG_DEBUG_FS) += bpmp-debugfs.o tegra_bpmp-y += bpmp-tegra186-hv.o obj-m += tegra_bpmp.o endif - diff --git a/drivers/media/platform/tegra/cdi/Makefile b/drivers/media/platform/tegra/cdi/Makefile index 97754f7a..4ad6a758 100644 --- a/drivers/media/platform/tegra/cdi/Makefile +++ b/drivers/media/platform/tegra/cdi/Makefile @@ -1,11 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only # Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. -LINUX_VERSION := $(shell expr $(VERSION) \* 256 + $(PATCHLEVEL)) -LINUX_VERSION_6_3 := $(shell expr 6 \* 256 + 3) - -# cdi_gpio/mgr is currently broken for Linux v6.3 and so skip for Linux v6.3+ -ifeq ($(shell test $(LINUX_VERSION) -lt $(LINUX_VERSION_6_3); echo $$?),0) +ifneq ($(CONFIG_TEGRA_GPIO_LEGACY_DISABLE),y) obj-m += cdi_gpio.o obj-m += cdi_mgr.o endif diff --git a/drivers/media/platform/tegra/isc/Makefile b/drivers/media/platform/tegra/isc/Makefile index 15882841..f1e02bdc 100644 --- a/drivers/media/platform/tegra/isc/Makefile +++ b/drivers/media/platform/tegra/isc/Makefile @@ -6,8 +6,7 @@ GCOV_PROFILE := y LINUX_VERSION := $(shell expr $(VERSION) \* 256 + $(PATCHLEVEL)) LINUX_VERSION_6_3 := $(shell expr 6 \* 256 + 3) -# isc_gpio/mgr is currently broken for Linux v6.3 and so skip for Linux v6.3+ -ifeq ($(shell test $(LINUX_VERSION) -lt $(LINUX_VERSION_6_3); echo $$?),0) +ifneq ($(CONFIG_TEGRA_GPIO_LEGACY_DISABLE),y) obj-m += isc_gpio.o obj-m += isc_mgr.o endif diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 28fc021e..45fbff25 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -1,18 +1,16 @@ # SPDX-License-Identifier: GPL-2.0 # Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved. -LINUX_VERSION := $(shell expr $(VERSION) \* 256 + $(PATCHLEVEL)) -LINUX_VERSION_6_3 := $(shell expr 6 \* 256 + 3) - ifeq ($(findstring ack_src,$(NV_BUILD_KERNEL_OPTIONS)),) +ifneq ($(CONFIG_TEGRA_IVC_LEGACY_DISABLE),y) obj-m += mods/ endif +endif obj-m += nvsciipc/ ifdef CONFIG_PCI obj-m += tegra-pcie-dma-test.o endif -# bluedroid_pm is currently broken for Linux v6.3 and so skip for Linux v6.3+ -ifeq ($(shell test $(LINUX_VERSION) -lt $(LINUX_VERSION_6_3); echo $$?),0) +ifneq ($(CONFIG_TEGRA_GPIO_LEGACY_DISABLE),y) obj-m += bluedroid_pm.o endif obj-m += nvscic2c-pcie/ diff --git a/drivers/platform/tegra/rtcpu/Makefile b/drivers/platform/tegra/rtcpu/Makefile index 562a32d6..c5e74184 100644 --- a/drivers/platform/tegra/rtcpu/Makefile +++ b/drivers/platform/tegra/rtcpu/Makefile @@ -1,13 +1,9 @@ # SPDX-License-Identifier: GPL-2.0-only # Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. -LINUX_VERSION := $(shell expr $(VERSION) \* 256 + $(PATCHLEVEL)) -LINUX_VERSION_6_2 := $(shell expr 6 \* 256 + 2) - ccflags-y += -Wframe-larger-than=2048 -# capture-ivc is currently broken for Linux v6.2 and so skip for Linux v6.2+ -ifeq ($(shell test $(LINUX_VERSION) -lt $(LINUX_VERSION_6_2); echo $$?),0) +ifneq ($(CONFIG_TEGRA_IVC_LEGACY_DISABLE),y) obj-m += capture-ivc.o endif obj-m += ivc-bus.o diff --git a/include/linux/tegra-capture-ivc.h b/include/linux/tegra-capture-ivc.h index 1c76c582..a9dfc4ca 100644 --- a/include/linux/tegra-capture-ivc.h +++ b/include/linux/tegra-capture-ivc.h @@ -9,7 +9,7 @@ #include #include -#if (KERNEL_VERSION(6, 2, 0) > LINUX_VERSION_CODE) +#if !defined(CONFIG_TEGRA_IVC_LEGACY_DISABLE) /** * @brief Submit the control message binary blob to capture-IVC driver, * which is to be transferred over control IVC channel to RTCPU. @@ -187,6 +187,6 @@ static inline int tegra_capture_ivc_unregister_capture_cb( { return -ENOTSUPP; }; -#endif /* (KERNEL_VERSION(6, 2, 0) > LINUX_VERSION_CODE) */ +#endif /* !defined(CONFIG_TEGRA_IVC_LEGACY_DISABLE) */ #endif /* INCLUDE_CAPTURE_IVC_H */