From 1dc806cb9111754925aeea00a7fcc987b39b2ca8 Mon Sep 17 00:00:00 2001 From: Jian-Min Liu Date: Tue, 30 Jan 2024 09:34:13 -0800 Subject: [PATCH] Kleaf: add kernel modules in nvidia-oot 1. Add BUILD.bazel file. 2. Add build target of kernel module and required include folder srctree.* in Makefile to fix the build issue 3. The tr (a build tool defined by kleaf in the sandbox) which supported by toybox will cause the conversion of header files to file_define to fail. Fixed it by separating with two tr commands. Bug 4344670 Change-Id: I56dcc148960f3b7703335943281589f42caa9af7 Signed-off-by: Jian-Min Liu Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3066225 Reviewed-by: Laxman Dewangan GVS: Gerrit_Virtual_Submit --- BUILD.bazel | 178 ++++++++++++++++++++++++++++++ Makefile | 4 + Makefile.kleaf | 23 ++++ scripts/conftest/BUILD.bazel | 14 +++ scripts/conftest/conftest.sh | 2 +- sound/soc/tegra-virt-alt/Makefile | 6 + 6 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 BUILD.bazel create mode 100644 Makefile.kleaf create mode 100644 scripts/conftest/BUILD.bazel diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 00000000..93b15ca3 --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,178 @@ +# SPDX-License-Identifier: GPL-2.0-only +# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + +load("//build/kernel/kleaf:kernel.bzl", "kernel_module") + +package( + default_visibility = [ + "//visibility:public", + ], +) + +filegroup( + name = "oot.includes", + srcs = glob([ + "include/**/*.h", + ]), +) + +filegroup( + name = "host1x.includes", + srcs = glob([ + "drivers/gpu/host1x/include/**/*.h", + ]), +) + +filegroup( + name = "nvmap.includes", + srcs = glob([ + "drivers/video/tegra/nvmap/include/**/*.h", + ]), +) + +kernel_module( + name = "nvoot", + srcs = glob( + ["**"], + exclude = [ + ".*", + ".*/**", + "*.bazel", + "**/*.bzl", + ], + ) + [ + "//hwpm:hwpm_headers", + "//nvidia-oot/scripts/conftest:conftest_headers", + ], + outs = [ + "drivers/block/tegra_oops_virt_storage/tegra_hv_vblk_oops.ko", + "drivers/block/tegra_virt_storage/tegra_vblk.ko", + "drivers/bmi088/bmi088.ko", + "drivers/cpuidle/cpuidle-debugfs.ko", + "drivers/cpuidle/cpuidle-tegra-auto.ko", + "drivers/crypto/tegra-hv-vse-safety.ko", + "drivers/crypto/tegra-nvvse-cryptodev.ko", + "drivers/crypto/tegra-se-nvrng.ko", + "drivers/crypto/tegra/tegra-se.ko", + "drivers/devfreq/governor_pod_scaling.ko", + "drivers/firmware/tegra/ivc_ext.ko", + "drivers/firmware/tegra/tegra_bpmp.ko", + "drivers/gpio/gpio-max77851.ko", + "drivers/gpu/drm/tegra/tegra-drm.ko", + "drivers/gpu/host1x-fence/host1x-fence.ko", + "drivers/gpu/host1x/host1x.ko", + "drivers/gpu/host1x-nvhost/host1x-nvhost.ko", + "drivers/hwmon/f75308.ko", + "drivers/i2c/busses/i2c-nvvrs11.ko", + "drivers/media/i2c/max9295.ko", + "drivers/media/i2c/max9296.ko", + "drivers/media/platform/tegra/cam_fsync/cam_fsync.ko", + "drivers/media/platform/tegra/cdi/cdi_dev.ko", + "drivers/media/platform/tegra/cdi/cdi_gpio.ko", + "drivers/media/platform/tegra/cdi/cdi_mgr.ko", + "drivers/media/platform/tegra/cdi/cdi_pwm.ko", + "drivers/media/platform/tegra/isc/isc_dev.ko", + "drivers/media/platform/tegra/isc/isc_gpio.ko", + "drivers/media/platform/tegra/isc/isc_mgr.ko", + "drivers/media/platform/tegra/isc/isc_pwm.ko", + "drivers/mfd/max77851.ko", + "drivers/mfd/nvidia-vrs-pseq.ko", + "drivers/misc/bluedroid_pm.ko", + "drivers/misc/ioctl_example.ko", + "drivers/misc/nvscic2c-pcie/nvscic2c-pcie-epc.ko", + "drivers/misc/nvscic2c-pcie/nvscic2c-pcie-epf.ko", + "drivers/misc/nvsciipc/nvsciipc.ko", + "drivers/misc/tegra-pcie-dma-test.ko", + "drivers/mtd/devices/tegra_hv_mtd.ko", + "drivers/net/can/mttcan/mttcan.ko", + "drivers/net/ethernet/marvell/oak/oak_pci.ko", + "drivers/net/ethernet/microchip/lan743x.ko", + "drivers/net/ethernet/nvidia/nvethernet/nvethernet.ko", + "drivers/net/ethernet/nvidia/pcie/tegra_vnet.ko", + "drivers/net/ethernet/realtek/r8168.ko", + "drivers/nv-p2p/nvidia-p2p.ko", + "drivers/nvpmodel/nvpmodel-clk-cap.ko", + "drivers/nvpps/nvpps.ko", + "drivers/nv-virtio/nv-virtio-console-poc.ko", + "drivers/pci/controller/pcie-tegra-vf.ko", + "drivers/pci/controller/tegra-pcie-edma.ko", + "drivers/pci/endpoint/functions/pci-epf-dma-test.ko", + "drivers/pinctrl/pinctrl-max77851.ko", + "drivers/pinctrl/pinctrl-tegra194-pexclk-padctrl.ko", + "drivers/pinctrl/pinctrl-tegra234-dpaux.ko", + "drivers/platform/tegra/aon/tegra234-aon.ko", + "drivers/platform/tegra/aon/tegra-aon-ivc-echo.ko", + "drivers/platform/tegra/dce/tegra-dce.ko", + "drivers/platform/tegra/mce/tegra-mce.ko", + "drivers/platform/tegra/mc-hwpm.ko", + "drivers/platform/tegra/mc-utils/mc-utils.ko", + "drivers/platform/tegra/nvadsp/nvadsp.ko", + "drivers/platform/tegra/psc/tegra23x_psc.ko", + "drivers/platform/tegra/tegra-bootloader-debug.ko", + "drivers/platform/tegra/tegra-cactmon-mc-all.ko", + "drivers/platform/tegra/tegra-fsicom.ko", + "drivers/platform/tegra/tegra-uss-io-proxy.ko", + "drivers/platform/tegra/uncore_pmu/tegra23x_perf_uncore.ko", + "drivers/power/reset/max77851-poweroff.ko", + "drivers/pwm/pwm-tegra-tachometer.ko", + "drivers/ras/arm64-ras.ko", + "drivers/regulator/max77851-regulator.ko", + "drivers/rtc/nvvrs-pseq-rtc.ko", + "drivers/rtc/rtc-max77851.ko", + "drivers/scsi/ufs/ufs-tegra.ko", + "drivers/scsi/ufs/ufs-tegra-provision.ko", + "drivers/soc/tegra/fuse/kfuse.ko", + "drivers/spi/spi-aurix-tegra.ko", + "drivers/spi/spi-tegra124-slave.ko", + "drivers/spi/spi-tegra210-quad.ko", + "drivers/staging/platform/tegra/gte/tegra194_gte.ko", + "drivers/staging/platform/tegra/gte_test/tegra194_gte_test.ko", + "drivers/thermal/max77851_thermal.ko", + "drivers/tty/serial/wch_35x/wch.ko", + "drivers/usb/typec/fusb301.ko", + "drivers/video/tegra/camera/tegra_camera_platform.ko", + "drivers/video/tegra/dc/bridge/maxim_gmsl_dp_serializer.ko", + "drivers/video/tegra/dc/bridge/maxim_gmsl_hdmi_serializer.ko", + "drivers/video/tegra/dc/bridge/ti_fpdlink_dp_serializer.ko", + "drivers/video/tegra/host/capture/nvhost-capture.ko", + "drivers/video/tegra/host/nvcsi/nvhost-nvcsi.ko", + "drivers/video/tegra/host/nvdla/nvhost-nvdla.ko", + "drivers/video/tegra/nvmap/nvmap.ko", + "drivers/video/tegra/tsec/tsecriscv.ko", + "drivers/video/tegra/virt/tegra_gr_comm.ko", + "drivers/virt/tegra/hvc_sysfs.ko", + "drivers/virt/tegra/ivc-cdev.ko", + "drivers/virt/tegra/tegra_hv.ko", + "drivers/virt/tegra/tegra_hv_pm_ctl.ko", + "drivers/virt/tegra/tegra_hv_vcpu_yield.ko", + "drivers/virt/tegra/userspace_ivc_mempool.ko", + "drivers/watchdog/max77851_wdt.ko", + "drivers/watchdog/softdog-platform.ko", + "drivers/watchdog/watchdog-tegra-t18x.ko", + "sound/soc/tegra/snd-soc-tegra186-arad-oot.ko", + "sound/soc/tegra/snd-soc-tegra186-asrc-oot.ko", + "sound/soc/tegra/snd-soc-tegra186-dspk-oot.ko", + "sound/soc/tegra/snd-soc-tegra210-admaif-oot.ko", + "sound/soc/tegra/snd-soc-tegra210-adx-oot.ko", + "sound/soc/tegra/snd-soc-tegra210-afc-oot.ko", + "sound/soc/tegra/snd-soc-tegra210-ahub-oot.ko", + "sound/soc/tegra/snd-soc-tegra210-amx-oot.ko", + "sound/soc/tegra/snd-soc-tegra210-dmic-oot.ko", + "sound/soc/tegra/snd-soc-tegra210-i2s-oot.ko", + "sound/soc/tegra/snd-soc-tegra210-iqc-oot.ko", + "sound/soc/tegra/snd-soc-tegra210-mixer-oot.ko", + "sound/soc/tegra/snd-soc-tegra210-mvc-oot.ko", + "sound/soc/tegra/snd-soc-tegra210-ope-oot.ko", + "sound/soc/tegra/snd-soc-tegra210-sfc-oot.ko", + "sound/soc/tegra/snd-soc-tegra-controls.ko", + "sound/soc/tegra/snd-soc-tegra-machine-driver-oot.ko", + "sound/soc/tegra/snd-soc-tegra-utils-oot.ko", + "sound/soc/tegra-virt-alt/snd-soc-tegra210-virt-alt-admaif.ko", + "sound/soc/tegra-virt-alt/snd-soc-tegra-virt-t210ref-pcm.ko", + "sound/tegra-safety-audio/safety-i2s.ko", + ], + kernel_build = "//android-common-kernel/6.1/kernel-source:tegra_android", + deps = [ + "//hwpm/drivers/tegra/hwpm:hwpm", + ], +) diff --git a/Makefile b/Makefile index 089ea2b2..7ed698cf 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,10 @@ # SPDX-License-Identifier: GPL-2.0 # Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved. +ifeq ($(CONFIG_TEGRA_KLEAF_BUILD),y) +include $(abspath $(shell dirname $(lastword $(MAKEFILE_LIST))))/Makefile.kleaf +endif + LINUXINCLUDE += -I$(srctree.nvconftest) LINUXINCLUDE += -I$(srctree.nvidia-oot)/include diff --git a/Makefile.kleaf b/Makefile.kleaf new file mode 100644 index 00000000..c381b1f6 --- /dev/null +++ b/Makefile.kleaf @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: GPL-2.0-only +# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + +ifeq ($(origin srctree.nvconftest), undefined) +srctree.nvconftest := $(abspath $(NV_BUILD_KERNEL_NVCONFTEST_OUT)) +endif + +ifeq ($(origin srctree.nvidia-oot), undefined) +export srctree.nvidia-oot := $(abspath $(shell dirname $(lastword $(MAKEFILE_LIST)))) +endif + +ifeq ($(origin srctree.hwpm), undefined) +export srctree.hwpm := $(KERNEL_SRC)/../../../hwpm +endif + +EXTRA_SYMBOLS += $(O)/../../../hwpm/drivers/tegra/hwpm/Module.symvers + +KERNEL_SRC ?= /lib/modules/$(shell uname -r)/build +M ?= $(shell pwd) + +modules modules_install clean: + $(MAKE) -C $(KERNEL_SRC) M=$(M) \ + srctree.nvidia-oot=$$PWD KBUILD_EXTRA_SYMBOLS="$(EXTRA_SYMBOLS)" $(@) diff --git a/scripts/conftest/BUILD.bazel b/scripts/conftest/BUILD.bazel new file mode 100644 index 00000000..bd9860d5 --- /dev/null +++ b/scripts/conftest/BUILD.bazel @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0-only +# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + +package( + default_visibility = [ + "//visibility:public", + ], +) +filegroup( + name = "conftest_headers", + srcs = glob(["**"], + allow_empty = False, + ), +) diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index e519c821..af06a843 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -66,7 +66,7 @@ test_header_presence() { TEST_CFLAGS="-E -M $CFLAGS" file="$1" - file_define=NV_`echo $file | tr '/.\-a-z' '___A-Z'`_PRESENT + file_define=NV_`echo $file | tr '/.-' '___' | tr 'a-z' 'A-Z'`_PRESENT CODE="#include <$file>" diff --git a/sound/soc/tegra-virt-alt/Makefile b/sound/soc/tegra-virt-alt/Makefile index 77bad808..7c80d2f4 100644 --- a/sound/soc/tegra-virt-alt/Makefile +++ b/sound/soc/tegra-virt-alt/Makefile @@ -4,8 +4,14 @@ GCOV_PROFILE := y subdir-ccflags-y += -Werror + +ifndef CONFIG_TEGRA_SYSTEM_TYPE_ACK ccflags-y += -I$(overlay)/$(src)/../tegra-virt-alt/include/ ccflags-y += -I$(overlay)/$(src)/../codecs +else +ccflags-y += -I$(srctree.nvidia-oot)/sound/soc/tegra-virt-alt/include/ +endif + ccflags-y += -I$(srctree.nvidia-oot)/sound/soc/tegra-virt-alt/nvaudio_ivc/ # Tegra platform Support