diff --git a/drivers/Kconfig b/drivers/Kconfig deleted file mode 100644 index d9c76e760..000000000 --- a/drivers/Kconfig +++ /dev/null @@ -1,5 +0,0 @@ -append_menu "Device Drivers" - -source "drivers/gpu/nvgpu/Kconfig" - -endmenu diff --git a/drivers/gpu/Makefile b/drivers/gpu/Makefile index af71a62a0..1a13b0983 100644 --- a/drivers/gpu/Makefile +++ b/drivers/gpu/Makefile @@ -1 +1,2 @@ -obj-$(CONFIG_GK20A) += nvgpu/ +# Choose this option if you have an SoC with integrated Nvidia GPU IP. +obj-m += nvgpu/ diff --git a/drivers/gpu/nvgpu/Kconfig b/drivers/gpu/nvgpu/Kconfig deleted file mode 100644 index fe6c7985b..000000000 --- a/drivers/gpu/nvgpu/Kconfig +++ /dev/null @@ -1,260 +0,0 @@ -config GK20A - tristate "Nvidia GK20A GPU support" - default n - help - Choose this option if you have an SoC with integrated - Nvidia GPU IP. - -config GK20A_PMU - bool "Support GK20A PMU" - depends on GK20A - default n - help - Say Y here to enable GK20A PMU features. - -choice - depends on GK20A - prompt "Enable GK20A frequency scaling" - default GK20A_DEVFREQ - optional - help - Select this entry to enable gk20a scaling - -config GK20A_DEVFREQ - depends on COMMON_CLK && PM_DEVFREQ - bool "Use Devfreq" - help - Select this to use devfreq based scaling. - Devfreq is a common framework that allows using - variety of different governors and changing - between governors on the fly. By default, no - governor is selected. - -endchoice - -config GK20A_PM_QOS - depends on GK20A_DEVFREQ - bool "Use PM_QOS constraints for devfreq based scaling" - default y - help - Enable support to pass PM_QOS constraints to devfreq based - scaling. - -config NVGPU_TRACK_MEM_USAGE - bool "Track the usage of system memory in nvgpu" - depends on GK20A - default n - help - Say Y here to allow nvgpu to track and keep statistics on - the system memory used by the driver. This does recreate - some of the kmem_leak tracking but this is also applicable - to other OSes which do not have Linux' kmem_leak. - - -config NVGPU_CYCLESTATS - bool "Support GPU CYCLE STATS" - depends on GK20A - default y - help - Say Y here to enable the cycle stats debugging features. - -config NVGPU_FECS_TRACE - bool "Support NVGPU FECS Context Switch tracing" - depends on GK20A - default y - help - Enable support for the NVGPU Context Switch Tracing. In this mode, - FECS collects timestamps for contexts loaded on GR engine. This - allows tracking context switches on GR engine, as well as - identifying processes that submitted work. - -config TEGRA_GK20A_NVHOST - bool "Support interfacing with nvhost hardware" - depends on TEGRA_GRHOST - depends on GK20A - default y - help - Enable support in GK20A for the nvhost (host1x) dma engine hardware - that includes things like hardware syncpts. This requires - TEGRA_GRHOST. - -config TEGRA_GK20A - bool "Enable the GK20A GPU on Tegra" - depends on GK20A - default y - help - Enable support for the GK20A graphics engine on Tegra - by adding a Tegra platfrom interface to the GK20A driver. - -config TEGRA_ACR - bool "Enable HS bin support on GM20B GPU on Tegra" - depends on GK20A && GK20A_PMU - default n - help - Enable Support for Loading High Secure binary, and using - Write Protected Regions (WPR) for storing ucodes, and bootstrap - PMU, FECS and GPCCS in Low Secure mode. - -config TEGRA_USE_NA_GPCPLL - bool "Enable noise aware mode of GM20B GPCPLL on Tegra" - depends on GK20A - depends on COMMON_CLK - default n - help - Enable noise aware (NA) mode of GM20b GPCPLL. In this mode PLL output - frequency is automatically adjusted when GM20b voltage is fluctuating - because of transient PMIC or power distribution tree noise. - -config GK20A_PCI - bool "Support PCIe NVIDIA GPUs on nvgpu" - depends on PCI && GK20A - default y - help - Enable support for GPUs on PCIe bus. - -config GK20A_TRACE_PRINTK - bool "Support trace_printk debugging" - depends on GK20A && TRACING - default n - help - Enable nvgpu debug facility to redirect debug spew to ftrace. This - affects kernel memory use, so should not be enabled by default. - -config NVGPU_USE_TEGRA_ALLOC_FD - bool "Use tegra_alloc_fd() for allocating dma_buf fds for vidmem" - depends on GK20A - depends on NV_TEGRA_MC - default y - help - Use tegra_alloc_fd() for allocating dma_buf fds. This allocates - the fds above 1024 which exempts them from counting against process - fd limit. - - It is only available in Tegra kernel. - -config NVGPU_SUPPORT_TURING - bool "Turing family GPU" - depends on GK20A && ARCH_TEGRA_19x_SOC - default y - help - Support for NVIDIA Turing family of GPU - -config NVGPU_DEBUGGER - bool "Support debugger APIs" - depends on GK20A - default y - help - Support for debugger APIs - -config NVGPU_LS_PMU - bool "LS PMU support" - depends on GK20A - default y - help - Support for iGPU LS PMU enable/disable - -config NVGPU_LOGGING - bool "NVGPU logging" - depends on GK20A - default y - help - Enable/Disable NVGPU logging - -config NVGPU_HAL_NON_FUSA - bool "Support non-functionally safe HALs" - depends on GK20A - default y - help - Enable/Disable the support of HALs from chips that do not have functional - safety certification - -config NVGPU_RECOVERY - bool "Recovery support" - depends on GK20A - default y - help - Support recovery on failure (which may involve engine reset) - -config NVGPU_NVLINK - bool "Nvlink support" - depends on TEGRA_NVLINK - default y - help - Support Nvlink - -config NVGPU_GR_VIRTUALIZATION - bool "NVGPU Virtualization Support" - depends on TEGRA_GR_VIRTUALIZATION - default y - help - Support NVGPU Virtualization - -config NVGPU_COMPRESSION - bool "Compression support" - depends on GK20A - default y - help - Support for compression - -config NVGPU_SUPPORT_CDE - bool "Support extraction of comptags for CDE" - depends on GK20A - depends on NVGPU_COMPRESSION - default n - help - Enable support for extraction of comptags for CDE. - -config NVGPU_DGPU - bool "NVGPU DGPU support" - depends on GK20A - depends on GK20A_PCI - default y - help - Support for NVGPU DGPU - -config NVGPU_VPR - bool "NVGPU VPR support" - depends on GK20A && TEGRA_VPR - default y - help - Support for NVGPU VPR - -config NVGPU_TEGRA_FUSE - bool "Tegra fuse Support" - depends on GK20A && TEGRA_KFUSE - default y - help - Support Tegra fuse - -choice - prompt "Supported sync fence backend" - default NVGPU_SYNCFD_ANDROID - depends on GK20A - help - GPU job synchronization (fences before and after submits) can use raw - syncpoints if available and sync fds if chosen. Without syncpoints, - nvgpu also provides semaphore-backed sync fds to userspace. - - Select which kernel-provided API is used for sync fds. Matching - support is required for the userspace drivers too. - -config NVGPU_SYNCFD_STABLE - bool "Upstream stabilized SYNC_FILE" - depends on SYNC_FILE - help - Select CONFIG_SYNC_FILE, the cross-driver "Explicit Synchronization - Framework" stabilized upstream from the Android sync since v4.9. - -config NVGPU_SYNCFD_ANDROID - bool "Android SYNC" - depends on SYNC - help - Select CONFIG_SYNC, the legacy synchronization framework provided by - Android (and deprecated in Linux 4.9+ in favor of dma fences and the - stabilized SYNC_FILE). - -config NVGPU_SYNCFD_NONE - bool "Nothing" - help - Do not build in support for sync fences. -endchoice diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile index f3a0054f5..c62f674d1 100644 --- a/drivers/gpu/nvgpu/Makefile +++ b/drivers/gpu/nvgpu/Makefile @@ -17,6 +17,12 @@ endif # Turn off when this is fixed upstream, if ever. ccflags-y += -D__NVGPU_PREVENT_UNTRUSTED_SPECULATION +ifneq ($(srctree.nvgpu),) +include $(srctree.nvgpu)/drivers/gpu/nvgpu/Makefile.linux.configs +else +include Makefile.linux.configs +endif + ifeq ($(CONFIG_NVGPU_DEBUGGER),y) ccflags-y += -DCONFIG_NVGPU_DEBUGGER ccflags-y += -DCONFIG_NVGPU_ENGINE_RESET diff --git a/drivers/gpu/nvgpu/Makefile.linux.configs b/drivers/gpu/nvgpu/Makefile.linux.configs new file mode 100644 index 000000000..9d9eb8a87 --- /dev/null +++ b/drivers/gpu/nvgpu/Makefile.linux.configs @@ -0,0 +1,243 @@ +# Turn off all other configs, if CONFIG_GK20A is not set +CONFIG_GK20A := m + +# Enable GK20A PMU features. +CONFIG_GK20A_PMU := y + +# Enable support for the GK20A graphics engine on Tegra +# by adding a Tegra platfrom interface to the GK20A driver. +CONFIG_TEGRA_GK20A := y + +# Enable Support for Loading High Secure binary, and using +# Write Protected Regions (WPR) for storing ucodes, and bootstrap +# PMU, FECS and GPCCS in Low Secure mode. +CONFIG_TEGRA_ACR := y + +# Support for debugger APIs +CONFIG_NVGPU_DEBUGGER := y + +# Support for iGPU LS PMU enable/disable +CONFIG_NVGPU_LS_PMU := y + +# Enable/Disable NVGPU logging +CONFIG_NVGPU_LOGGING := y + +# Enable/Disable the support of HALs from chips that do not have functional +# safety certification +CONFIG_NVGPU_HAL_NON_FUSA := y + +# Support recovery on failure (which may involve engine reset) +CONFIG_NVGPU_RECOVERY := y + +# Support for compression +CONFIG_NVGPU_COMPRESSION := y + +# Enable support for extraction of comptags for CDE. +ifeq ($(CONFIG_NVGPU_COMPRESSION),y) +CONFIG_NVGPU_SUPPORT_CDE := y +endif + +ifeq ($(CONFIG_COMMON_CLK),y) +ifeq ($(CONFIG_TEGRA_KFUSE),y) +# Enable noise aware (NA) mode of GM20b GPCPLL. In this mode PLL output +# frequency is automatically adjusted when GM20b voltage is fluctuating +# because of transient PMIC or power distribution tree noise. +CONFIG_TEGRA_USE_NA_GPCPLL := y +endif +endif + +ifeq ($(CONFIG_COMMON_CLK),y) +ifeq ($(CONFIG_PM_DEVFREQ),y) +# Select this entry to enable gk20a scaling +CONFIG_GK20A_DEVFREQ := y + +# Enable support to pass PM_QOS constraints to devfreq based scaling. +CONFIG_GK20A_PM_QOS := y + +endif +endif + +# Say Y here to allow nvgpu to track and keep statistics on +# the system memory used by the driver. This does recreate +# some of the kmem_leak tracking but this is also applicable +# to other OSes which do not have Linux' kmem_leak. +#CONFIG_NVGPU_TRACK_MEM_USAGE := n + +# Enable the cycle stats debugging features. +CONFIG_NVGPU_CYCLESTATS := y + +# Enable support for the NVGPU Context Switch Tracing. In this mode, +# FECS collects timestamps for contexts loaded on GR engine. This +# allows tracking context switches on GR engine, as well as +# identifying processes that submitted work. +CONFIG_NVGPU_FECS_TRACE := y + +# Enable support in GK20A for the nvhost (host1x) dma engine hardware +# that includes things like hardware syncpts. This requires +# TEGRA_GRHOST +ifeq ($(CONFIG_TEGRA_GRHOST),y) +CONFIG_TEGRA_GK20A_NVHOST := y +endif + +# Enable support for GPUs on PCIe bus. +ifeq ($(CONFIG_PCI),y) +CONFIG_GK20A_PCI := y + +# Support for NVGPU DGPU +CONFIG_NVGPU_DGPU := y +endif + +# Enable nvgpu debug facility to redirect debug spew to ftrace. This +# affects kernel memory use, so should not be enabled by default. +ifeq ($(CONFIG_TRACING),y) +#CONFIG_GK20A_TRACE_PRINTK := y +endif + +# Use tegra_alloc_fd() for allocating dma_buf fds. This allocates +# the fds above 1024 which exempts them from counting against process +# fd limit. +ifeq ($(CONFIG_NV_TEGRA_MC),y) +CONFIG_NVGPU_USE_TEGRA_ALLOC_FD := y +endif + +# Support for NVIDIA Turing family of GPU +ifeq ($(CONFIG_ARCH_TEGRA_19x_SOC),y) +CONFIG_NVGPU_SUPPORT_TURING := y +endif + +# Support Nvlink +ifeq ($(CONFIG_TEGRA_NVLINK),y) +CONFIG_NVGPU_NVLINK := y +endif + +# Support NVGPU Virtualization +ifeq ($(CONFIG_TEGRA_GR_VIRTUALIZATION),y) +CONFIG_NVGPU_GR_VIRTUALIZATION := y +endif + +# Support for NVGPU VPR +ifeq ($(CONFIG_TEGRA_VPR),y) +CONFIG_NVGPU_VPR := y +endif + +# Support Tegra fuse +ifeq ($(CONFIG_TEGRA_KFUSE),y) +CONFIG_NVGPU_TEGRA_FUSE := y +endif + +# GPU job synchronization (fences before and after submits) can use raw +# syncpoints if available and sync fds if chosen. Without syncpoints, +# nvgpu also provides semaphore-backed sync fds to userspace. +# +# Select which kernel-provided API is used for sync fds. Matching +# support is required for the userspace drivers too. +ifeq ($(CONFIG_SYNC),y) +CONFIG_NVGPU_SYNCFD_ANDROID := y +else ifeq ($(CONFIG_SYNC_FILE), y) +CONFIG_NVGPU_SYNCFD_STABLE := y +else +CONFIG_NVGPU_SYNCFD_NONE := y +endif + +# Below check indicates the build is invoked from Nvidia's +# internal build system. +ifneq ($(NV_BUILD_KERNEL_OPTIONS),) + +# Disable the below configs for kstable +ifneq ($(findstring stable,$(NV_BUILD_KERNEL_OPTIONS)),) +CONFIG_GK20A_DEVFREQ := n +CONFIG_GK20A_PM_QOS := n +else ifneq ($(findstring 5.9,$(NV_BUILD_KERNEL_OPTIONS)),) +CONFIG_GK20A_DEVFREQ := n +CONFIG_GK20A_PM_QOS := n +endif + +endif + +ifeq ($(CONFIG_GK20A_PMU),y) +ccflags-y += -DCONFIG_GK20A_PMU +endif +ifeq ($(CONFIG_TEGRA_GK20A),y) +ccflags-y += -DCONFIG_TEGRA_GK20A +endif +ifeq ($(CONFIG_TEGRA_ACR),y) +ccflags-y += -DCONFIG_TEGRA_ACR +endif +ifeq ($(CONFIG_NVGPU_DEBUGGER),y) +ccflags-y += -DCONFIG_NVGPU_DEBUGGER +endif +ifeq ($(CONFIG_NVGPU_LS_PMU),y) +ccflags-y += -DCONFIG_NVGPU_LS_PMU +endif +ifeq ($(CONFIG_NVGPU_LOGGING),y) +ccflags-y += -DCONFIG_NVGPU_LOGGING +endif +ifeq ($(CONFIG_NVGPU_HAL_NON_FUSA),y) +ccflags-y += -DCONFIG_NVGPU_HAL_NON_FUSA +endif +ifeq ($(CONFIG_NVGPU_RECOVERY),y) +ccflags-y += -DCONFIG_NVGPU_RECOVERY +endif +ifeq ($(CONFIG_NVGPU_COMPRESSION),y) +ccflags-y += -DCONFIG_NVGPU_COMPRESSION +endif +ifeq ($(CONFIG_NVGPU_SUPPORT_CDE),y) +ccflags-y += -DCONFIG_NVGPU_SUPPORT_CDE +endif +ifeq ($(CONFIG_TEGRA_USE_NA_GPCPLL),y) +ccflags-y += -DCONFIG_TEGRA_USE_NA_GPCPLL +endif +ifeq ($(CONFIG_GK20A_DEVFREQ),y) +ccflags-y += -DCONFIG_GK20A_DEVFREQ +endif +ifeq ($(CONFIG_GK20A_PM_QOS),y) +ccflags-y += -DCONFIG_GK20A_PM_QOS +endif +ifeq ($(CONFIG_NVGPU_TRACK_MEM_USAGE),y) +ccflags-y += -DCONFIG_NVGPU_TRACK_MEM_USAGE +endif +ifeq ($(CONFIG_NVGPU_CYCLESTATS),y) +ccflags-y += -DCONFIG_NVGPU_CYCLESTATS +endif +ifeq ($(CONFIG_NVGPU_FECS_TRACE),y) +ccflags-y += -DCONFIG_NVGPU_FECS_TRACE +endif +ifeq ($(CONFIG_TEGRA_GK20A_NVHOST),y) +ccflags-y += -DCONFIG_TEGRA_GK20A_NVHOST +endif +ifeq ($(CONFIG_GK20A_PCI),y) +ccflags-y += -DCONFIG_GK20A_PCI +endif +ifeq ($(CONFIG_NVGPU_DGPU),y) +ccflags-y += -DCONFIG_NVGPU_DGPU +endif +ifeq ($(CONFIG_GK20A_TRACE_PRINTK),y) +ccflags-y += -DCONFIG_GK20A_TRACE_PRINTK +endif +ifeq ($(CONFIG_NVGPU_USE_TEGRA_ALLOC_FD),y) +ccflags-y += -DCONFIG_NVGPU_USE_TEGRA_ALLOC_FD +endif +ifeq ($(CONFIG_NVGPU_SUPPORT_TURING),y) +ccflags-y += -DCONFIG_NVGPU_SUPPORT_TURING +endif +ifeq ($(CONFIG_NVGPU_NVLINK),y) +ccflags-y += -DCONFIG_NVGPU_NVLINK +endif +ifeq ($(CONFIG_NVGPU_GR_VIRTUALIZATION),y) +ccflags-y += -DCONFIG_NVGPU_GR_VIRTUALIZATION +endif +ifeq ($(CONFIG_NVGPU_VPR),y) +ccflags-y += -DCONFIG_NVGPU_VPR +endif +ifeq ($(CONFIG_NVGPU_TEGRA_FUSE),y) +ccflags-y += -DCONFIG_NVGPU_TEGRA_FUSE +endif +ifeq ($(CONFIG_NVGPU_SYNCFD_ANDROID),y) +ccflags-y += -DCONFIG_NVGPU_SYNCFD_ANDROID +endif +ifeq ($(CONFIG_NVGPU_SYNCFD_STABLE),y) +ccflags-y += -DCONFIG_NVGPU_SYNCFD_STABLE +endif +ifeq ($(CONFIG_NVGPU_SYNCFD_NONE),y) +ccflags-y += -DCONFIG_NVGPU_SYNCFD_NONE +endif \ No newline at end of file diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c index b95b47f69..c45eb7e51 100644 --- a/drivers/gpu/nvgpu/os/linux/module.c +++ b/drivers/gpu/nvgpu/os/linux/module.c @@ -1151,7 +1151,9 @@ static int gk20a_pm_unrailgate(struct device *dev) { struct gk20a_platform *platform = dev_get_drvdata(dev); int ret = 0; +#ifdef CONFIG_DEBUG_FS struct gk20a *g = get_gk20a(dev); +#endif /* return early if platform didn't implement unrailgate */ if (!platform->unrailgate)