13d0407baSopenharmony_ci# SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
23d0407baSopenharmony_ci#
33d0407baSopenharmony_ci# (C) COPYRIGHT 2012-2021 ARM Limited. All rights reserved.
43d0407baSopenharmony_ci#
53d0407baSopenharmony_ci# This program is free software and is provided to you under the terms of the
63d0407baSopenharmony_ci# GNU General Public License version 2 as published by the Free Software
73d0407baSopenharmony_ci# Foundation, and any use by you of this program is subject to the terms
83d0407baSopenharmony_ci# of such GNU license.
93d0407baSopenharmony_ci#
103d0407baSopenharmony_ci# This program is distributed in the hope that it will be useful,
113d0407baSopenharmony_ci# but WITHOUT ANY WARRANTY; without even the implied warranty of
123d0407baSopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
133d0407baSopenharmony_ci# GNU General Public License for more details.
143d0407baSopenharmony_ci#
153d0407baSopenharmony_ci# You should have received a copy of the GNU General Public License
163d0407baSopenharmony_ci# along with this program; if not, you can access it online at
173d0407baSopenharmony_ci# http://www.gnu.org/licenses/gpl-2.0.html.
183d0407baSopenharmony_ci#
193d0407baSopenharmony_ci#
203d0407baSopenharmony_ci
213d0407baSopenharmony_cimenuconfig MALI_BIFROST
223d0407baSopenharmony_ci	bool "Mali Midgard series support"
233d0407baSopenharmony_ci	default y
243d0407baSopenharmony_ci	help
253d0407baSopenharmony_ci	  Enable this option to build support for a ARM Mali Midgard GPU.
263d0407baSopenharmony_ci
273d0407baSopenharmony_ci	  To compile this driver as a module, choose M here:
283d0407baSopenharmony_ci	  this will generate a single module, called mali_kbase.
293d0407baSopenharmony_ci
303d0407baSopenharmony_ciconfig MALI_PLATFORM_NAME
313d0407baSopenharmony_ci	depends on MALI_BIFROST
323d0407baSopenharmony_ci	string "Platform name"
333d0407baSopenharmony_ci	default "hisilicon" if PLATFORM_HIKEY960
343d0407baSopenharmony_ci	default "hisilicon" if PLATFORM_HIKEY970
353d0407baSopenharmony_ci	default "devicetree"
363d0407baSopenharmony_ci	help
373d0407baSopenharmony_ci	  Enter the name of the desired platform configuration directory to
383d0407baSopenharmony_ci	  include in the build. 'platform/$(MALI_PLATFORM_NAME)/Kbuild' must
393d0407baSopenharmony_ci	  exist.
403d0407baSopenharmony_ci
413d0407baSopenharmony_ci	  When PLATFORM_CUSTOM is set, this needs to be set manually to
423d0407baSopenharmony_ci	  pick up the desired platform files.
433d0407baSopenharmony_ci
443d0407baSopenharmony_ciconfig MALI_REAL_HW
453d0407baSopenharmony_ci	bool
463d0407baSopenharmony_ci	depends on MALI_BIFROST
473d0407baSopenharmony_ci	default y
483d0407baSopenharmony_ci	default n if NO_MALI
493d0407baSopenharmony_ci
503d0407baSopenharmony_ciconfig MALI_CSF_SUPPORT
513d0407baSopenharmony_ci	bool "Enable Mali CSF based GPU support"
523d0407baSopenharmony_ci	depends on MALI_BIFROST
533d0407baSopenharmony_ci	default y if GPU_HAS_CSF
543d0407baSopenharmony_ci	help
553d0407baSopenharmony_ci	  Enables support for CSF based GPUs.
563d0407baSopenharmony_ci
573d0407baSopenharmony_ciconfig MALI_BIFROST_DEVFREQ
583d0407baSopenharmony_ci	bool "Enable devfreq support for Mali"
593d0407baSopenharmony_ci	depends on MALI_BIFROST
603d0407baSopenharmony_ci	default y if PLATFORM_JUNO
613d0407baSopenharmony_ci	default y if PLATFORM_CUSTOM
623d0407baSopenharmony_ci	help
633d0407baSopenharmony_ci	  Support devfreq for Mali.
643d0407baSopenharmony_ci
653d0407baSopenharmony_ci	  Using the devfreq framework and, by default, the simple on-demand
663d0407baSopenharmony_ci	  governor, the frequency of Mali will be dynamically selected from the
673d0407baSopenharmony_ci	  available OPPs.
683d0407baSopenharmony_ci
693d0407baSopenharmony_ciconfig MALI_BIFROST_DVFS
703d0407baSopenharmony_ci	bool "Enable legacy DVFS"
713d0407baSopenharmony_ci	depends on MALI_BIFROST && !MALI_BIFROST_DEVFREQ
723d0407baSopenharmony_ci	default n
733d0407baSopenharmony_ci	help
743d0407baSopenharmony_ci	  Choose this option to enable legacy DVFS in the Mali Midgard DDK.
753d0407baSopenharmony_ci
763d0407baSopenharmony_ciconfig MALI_BIFROST_GATOR_SUPPORT
773d0407baSopenharmony_ci	bool "Enable Streamline tracing support"
783d0407baSopenharmony_ci	depends on MALI_BIFROST && !BACKEND_USER
793d0407baSopenharmony_ci	default y
803d0407baSopenharmony_ci	help
813d0407baSopenharmony_ci	  Enables kbase tracing used by the Arm Streamline Performance Analyzer.
823d0407baSopenharmony_ci	  The tracepoints are used to derive GPU activity charts in Streamline.
833d0407baSopenharmony_ci
843d0407baSopenharmony_ciconfig MALI_BIFROST_ENABLE_TRACE
853d0407baSopenharmony_ci	bool "Enable kbase tracing"
863d0407baSopenharmony_ci	depends on MALI_BIFROST
873d0407baSopenharmony_ci	default y if MALI_BIFROST_DEBUG
883d0407baSopenharmony_ci	default n
893d0407baSopenharmony_ci	help
903d0407baSopenharmony_ci	  Enables tracing in kbase. Trace log available through
913d0407baSopenharmony_ci	  the "mali_trace" debugfs file, when the CONFIG_DEBUG_FS is enabled
923d0407baSopenharmony_ci
933d0407baSopenharmony_ciconfig MALI_BIFROST_DMA_FENCE
943d0407baSopenharmony_ci	bool "Enable DMA_BUF fence support for Mali"
953d0407baSopenharmony_ci	depends on MALI_BIFROST
963d0407baSopenharmony_ci	default n
973d0407baSopenharmony_ci	help
983d0407baSopenharmony_ci	  Support DMA_BUF fences for Mali.
993d0407baSopenharmony_ci
1003d0407baSopenharmony_ci	  This option should only be enabled if the Linux Kernel has built in
1013d0407baSopenharmony_ci	  support for DMA_BUF fences.
1023d0407baSopenharmony_ci
1033d0407baSopenharmony_ciconfig MALI_ARBITER_SUPPORT
1043d0407baSopenharmony_ci	bool "Enable arbiter support for Mali"
1053d0407baSopenharmony_ci	depends on MALI_BIFROST && !MALI_CSF_SUPPORT
1063d0407baSopenharmony_ci	default n
1073d0407baSopenharmony_ci	help
1083d0407baSopenharmony_ci	  Enable support for the arbiter interface in the driver.
1093d0407baSopenharmony_ci	  This allows an external arbiter to manage driver access
1103d0407baSopenharmony_ci	  to GPU hardware in a virtualized environment
1113d0407baSopenharmony_ci
1123d0407baSopenharmony_ci	  If unsure, say N.
1133d0407baSopenharmony_ci
1143d0407baSopenharmony_ciconfig DMA_BUF_SYNC_IOCTL_SUPPORTED
1153d0407baSopenharmony_ci	bool "Enable Kernel DMA buffers support DMA_BUF_IOCTL_SYNC"
1163d0407baSopenharmony_ci	depends on MALI_BIFROST && BACKEND_KERNEL
1173d0407baSopenharmony_ci	default y
1183d0407baSopenharmony_ci
1193d0407baSopenharmony_ciconfig MALI_DMA_BUF_MAP_ON_DEMAND
1203d0407baSopenharmony_ci	bool "Enable map imported dma-bufs on demand"
1213d0407baSopenharmony_ci	depends on MALI_BIFROST
1223d0407baSopenharmony_ci	default n
1233d0407baSopenharmony_ci	default y if !DMA_BUF_SYNC_IOCTL_SUPPORTED
1243d0407baSopenharmony_ci	help
1253d0407baSopenharmony_ci	  This option caused kbase to set up the GPU mapping of imported
1263d0407baSopenharmony_ci	  dma-buf when needed to run atoms. This is the legacy behavior.
1273d0407baSopenharmony_ci
1283d0407baSopenharmony_ci	  This is intended for testing and the option will get removed in the
1293d0407baSopenharmony_ci	  future.
1303d0407baSopenharmony_ci
1313d0407baSopenharmony_ciconfig MALI_DMA_BUF_LEGACY_COMPAT
1323d0407baSopenharmony_ci	bool "Enable legacy compatibility cache flush on dma-buf map"
1333d0407baSopenharmony_ci	depends on MALI_BIFROST && !MALI_DMA_BUF_MAP_ON_DEMAND
1343d0407baSopenharmony_ci	default n
1353d0407baSopenharmony_ci	help
1363d0407baSopenharmony_ci	  This option enables compatibility with legacy dma-buf mapping
1373d0407baSopenharmony_ci	  behavior, then the dma-buf is mapped on import, by adding cache
1383d0407baSopenharmony_ci	  maintenance where MALI_DMA_BUF_MAP_ON_DEMAND would do the mapping,
1393d0407baSopenharmony_ci	  including a cache flush.
1403d0407baSopenharmony_ci
1413d0407baSopenharmony_ci	  This option might work-around issues related to missing cache
1423d0407baSopenharmony_ci	  flushes in other drivers. This only has an effect for clients using
1433d0407baSopenharmony_ci	  UK 11.18 or older. For later UK versions it is not possible.
1443d0407baSopenharmony_ci
1453d0407baSopenharmony_cimenuconfig MALI_BIFROST_EXPERT
1463d0407baSopenharmony_ci	depends on MALI_BIFROST
1473d0407baSopenharmony_ci	bool "Enable Expert Settings"
1483d0407baSopenharmony_ci	default y
1493d0407baSopenharmony_ci	help
1503d0407baSopenharmony_ci	  Enabling this option and modifying the default settings may produce
1513d0407baSopenharmony_ci	  a driver with performance or other limitations.
1523d0407baSopenharmony_ci
1533d0407baSopenharmony_ciconfig MALI_2MB_ALLOC
1543d0407baSopenharmony_ci	bool "Attempt to allocate 2MB pages"
1553d0407baSopenharmony_ci	depends on MALI_BIFROST && MALI_BIFROST_EXPERT
1563d0407baSopenharmony_ci	default n
1573d0407baSopenharmony_ci	help
1583d0407baSopenharmony_ci	  Rather than allocating all GPU memory page-by-page, attempt to
1593d0407baSopenharmony_ci	  allocate 2MB pages from the kernel. This reduces TLB pressure and
1603d0407baSopenharmony_ci	  helps to prevent memory fragmentation.
1613d0407baSopenharmony_ci
1623d0407baSopenharmony_ci	  If in doubt, say N
1633d0407baSopenharmony_ci
1643d0407baSopenharmony_ciconfig MALI_MEMORY_FULLY_BACKED
1653d0407baSopenharmony_ci	bool "Enable memory fully physically-backed"
1663d0407baSopenharmony_ci	depends on MALI_BIFROST && MALI_BIFROST_EXPERT
1673d0407baSopenharmony_ci	default n
1683d0407baSopenharmony_ci	help
1693d0407baSopenharmony_ci	  This option enables full physical backing of all virtual
1703d0407baSopenharmony_ci	  memory allocations in the kernel. Notice that this build
1713d0407baSopenharmony_ci	  option only affects allocations of grow-on-GPU-page-fault
1723d0407baSopenharmony_ci	  memory.
1733d0407baSopenharmony_ci
1743d0407baSopenharmony_ciconfig MALI_CORESTACK
1753d0407baSopenharmony_ci	bool "Enable support of GPU core stack power control"
1763d0407baSopenharmony_ci	depends on MALI_BIFROST && MALI_BIFROST_EXPERT
1773d0407baSopenharmony_ci	default n
1783d0407baSopenharmony_ci	help
1793d0407baSopenharmony_ci	  Enabling this feature on supported GPUs will let the driver powering
1803d0407baSopenharmony_ci	  on/off the GPU core stack independently without involving the Power
1813d0407baSopenharmony_ci	  Domain Controller. This should only be enabled on platforms which
1823d0407baSopenharmony_ci	  integration of the PDC to the Mali GPU is known to be problematic.
1833d0407baSopenharmony_ci	  This feature is currently only supported on t-Six and t-HEx GPUs.
1843d0407baSopenharmony_ci
1853d0407baSopenharmony_ci	  If unsure, say N.
1863d0407baSopenharmony_ci
1873d0407baSopenharmony_cichoice
1883d0407baSopenharmony_ci	prompt "Error injection level"
1893d0407baSopenharmony_ci	depends on MALI_BIFROST && MALI_BIFROST_EXPERT
1903d0407baSopenharmony_ci	default MALI_ERROR_INJECT_NONE
1913d0407baSopenharmony_ci	help
1923d0407baSopenharmony_ci	  Enables insertion of errors to test module failure and recovery mechanisms.
1933d0407baSopenharmony_ci
1943d0407baSopenharmony_ciconfig MALI_ERROR_INJECT_NONE
1953d0407baSopenharmony_ci	bool "disabled"
1963d0407baSopenharmony_ci	depends on MALI_BIFROST && MALI_BIFROST_EXPERT
1973d0407baSopenharmony_ci	help
1983d0407baSopenharmony_ci	  Error injection is disabled.
1993d0407baSopenharmony_ci
2003d0407baSopenharmony_ciconfig MALI_ERROR_INJECT_TRACK_LIST
2013d0407baSopenharmony_ci	bool "error track list"
2023d0407baSopenharmony_ci	depends on MALI_BIFROST && MALI_BIFROST_EXPERT && NO_MALI
2033d0407baSopenharmony_ci	help
2043d0407baSopenharmony_ci	  Errors to inject are pre-configured by the user.
2053d0407baSopenharmony_ci
2063d0407baSopenharmony_ciconfig MALI_ERROR_INJECT_RANDOM
2073d0407baSopenharmony_ci	bool "random error injection"
2083d0407baSopenharmony_ci	depends on MALI_BIFROST && MALI_BIFROST_EXPERT && NO_MALI
2093d0407baSopenharmony_ci	help
2103d0407baSopenharmony_ci	  Injected errors are random, rather than user-driven.
2113d0407baSopenharmony_ci
2123d0407baSopenharmony_ciendchoice
2133d0407baSopenharmony_ci
2143d0407baSopenharmony_ciconfig MALI_ERROR_INJECT_ON
2153d0407baSopenharmony_ci	string
2163d0407baSopenharmony_ci	depends on MALI_BIFROST && MALI_BIFROST_EXPERT
2173d0407baSopenharmony_ci	default "0" if MALI_ERROR_INJECT_NONE
2183d0407baSopenharmony_ci	default "1" if MALI_ERROR_INJECT_TRACK_LIST
2193d0407baSopenharmony_ci	default "2" if MALI_ERROR_INJECT_RANDOM
2203d0407baSopenharmony_ci
2213d0407baSopenharmony_ciconfig MALI_BIFROST_ERROR_INJECT
2223d0407baSopenharmony_ci	bool
2233d0407baSopenharmony_ci	depends on MALI_BIFROST && MALI_BIFROST_EXPERT
2243d0407baSopenharmony_ci	default y if !MALI_ERROR_INJECT_NONE
2253d0407baSopenharmony_ci
2263d0407baSopenharmony_ciconfig MALI_GEM5_BUILD
2273d0407baSopenharmony_ci	bool "Enable build of Mali kernel driver for GEM5"
2283d0407baSopenharmony_ci	depends on MALI_BIFROST && MALI_BIFROST_EXPERT
2293d0407baSopenharmony_ci	default n
2303d0407baSopenharmony_ci	help
2313d0407baSopenharmony_ci	  This option is to do a Mali GEM5 build.
2323d0407baSopenharmony_ci	  If unsure, say N.
2333d0407baSopenharmony_ci
2343d0407baSopenharmony_ciconfig MALI_BIFROST_DEBUG
2353d0407baSopenharmony_ci	bool "Enable debug build"
2363d0407baSopenharmony_ci	depends on MALI_BIFROST && MALI_BIFROST_EXPERT
2373d0407baSopenharmony_ci	default y if DEBUG
2383d0407baSopenharmony_ci	default n
2393d0407baSopenharmony_ci	help
2403d0407baSopenharmony_ci	  Select this option for increased checking and reporting of errors.
2413d0407baSopenharmony_ci
2423d0407baSopenharmony_ciconfig MALI_BIFROST_FENCE_DEBUG
2433d0407baSopenharmony_ci	bool "Enable debug sync fence usage"
2443d0407baSopenharmony_ci	depends on MALI_BIFROST && MALI_BIFROST_EXPERT
2453d0407baSopenharmony_ci	default y if MALI_BIFROST_DEBUG
2463d0407baSopenharmony_ci	help
2473d0407baSopenharmony_ci	  Select this option to enable additional checking and reporting on the
2483d0407baSopenharmony_ci	  use of sync fences in the Mali driver.
2493d0407baSopenharmony_ci
2503d0407baSopenharmony_ci	  This will add a 3s timeout to all sync fence waits in the Mali
2513d0407baSopenharmony_ci	  driver, so that when work for Mali has been waiting on a sync fence
2523d0407baSopenharmony_ci	  for a long time a debug message will be printed, detailing what fence
2533d0407baSopenharmony_ci	  is causing the block, and which dependent Mali atoms are blocked as a
2543d0407baSopenharmony_ci	  result of this.
2553d0407baSopenharmony_ci
2563d0407baSopenharmony_ci	  The timeout can be changed at runtime through the js_soft_timeout
2573d0407baSopenharmony_ci	  device attribute, where the timeout is specified in milliseconds.
2583d0407baSopenharmony_ci
2593d0407baSopenharmony_ciconfig MALI_BIFROST_SYSTEM_TRACE
2603d0407baSopenharmony_ci	bool "Enable system event tracing support"
2613d0407baSopenharmony_ci	depends on MALI_BIFROST && MALI_BIFROST_EXPERT
2623d0407baSopenharmony_ci	default y if MALI_BIFROST_DEBUG
2633d0407baSopenharmony_ci	default n
2643d0407baSopenharmony_ci	help
2653d0407baSopenharmony_ci	  Choose this option to enable system trace events for each
2663d0407baSopenharmony_ci	  kbase event. This is typically used for debugging but has
2673d0407baSopenharmony_ci	  minimal overhead when not in use. Enable only if you know what
2683d0407baSopenharmony_ci	  you are doing.
2693d0407baSopenharmony_ci
2703d0407baSopenharmony_ci# Instrumentation options.
2713d0407baSopenharmony_ci
2723d0407baSopenharmony_ci# config MALI_PRFCNT_SET_PRIMARY exists in the Kernel Kconfig but is configured using CINSTR_PRIMARY_HWC in Mconfig.
2733d0407baSopenharmony_ci# config MALI_BIFROST_PRFCNT_SET_SECONDARY exists in the Kernel Kconfig but is configured using CINSTR_SECONDARY_HWC in Mconfig.
2743d0407baSopenharmony_ci# config MALI_PRFCNT_SET_TERTIARY exists in the Kernel Kconfig but is configured using CINSTR_TERTIARY_HWC in Mconfig.
2753d0407baSopenharmony_ci# config MALI_PRFCNT_SET_SELECT_VIA_DEBUG_FS exists in the Kernel Kconfig but is configured using CINSTR_HWC_SET_SELECT_VIA_DEBUG_FS in Mconfig.
2763d0407baSopenharmony_ci
2773d0407baSopenharmony_ciconfig MALI_JOB_DUMP
2783d0407baSopenharmony_ci	bool "Enable system level support needed for job dumping"
2793d0407baSopenharmony_ci	depends on MALI_BIFROST && MALI_BIFROST_EXPERT
2803d0407baSopenharmony_ci	default n
2813d0407baSopenharmony_ci	help
2823d0407baSopenharmony_ci	  Choose this option to enable system level support needed for
2833d0407baSopenharmony_ci	  job dumping. This is typically used for instrumentation but has
2843d0407baSopenharmony_ci	  minimal overhead when not in use. Enable only if you know what
2853d0407baSopenharmony_ci	  you are doing.
2863d0407baSopenharmony_ci
2873d0407baSopenharmony_ciconfig MALI_PWRSOFT_765
2883d0407baSopenharmony_ci	bool "Enable workaround for PWRSOFT-765"
2893d0407baSopenharmony_ci	depends on MALI_BIFROST && MALI_BIFROST_EXPERT
2903d0407baSopenharmony_ci	default n
2913d0407baSopenharmony_ci	help
2923d0407baSopenharmony_ci	  PWRSOFT-765 fixes devfreq cooling devices issues. The fix was merged
2933d0407baSopenharmony_ci	  in kernel v4.10, however if backported into the kernel then this
2943d0407baSopenharmony_ci	  option must be manually selected.
2953d0407baSopenharmony_ci
2963d0407baSopenharmony_ci	  If using kernel >= v4.10 then say N, otherwise if devfreq cooling
2973d0407baSopenharmony_ci	  changes have been backported say Y to avoid compilation errors.
2983d0407baSopenharmony_ci
2993d0407baSopenharmony_ci
3003d0407baSopenharmony_ciconfig MALI_HW_ERRATA_1485982_NOT_AFFECTED
3013d0407baSopenharmony_ci	bool "Disable workaround for BASE_HW_ISSUE_GPU2017_1336"
3023d0407baSopenharmony_ci	depends on MALI_BIFROST && MALI_BIFROST_EXPERT
3033d0407baSopenharmony_ci	default n
3043d0407baSopenharmony_ci	default y if PLATFORM_JUNO
3053d0407baSopenharmony_ci	help
3063d0407baSopenharmony_ci	  This option disables the default workaround for GPU2017-1336. The
3073d0407baSopenharmony_ci	  workaround keeps the L2 cache powered up except for powerdown and reset.
3083d0407baSopenharmony_ci
3093d0407baSopenharmony_ci	  The workaround introduces a limitation that will prevent the running of
3103d0407baSopenharmony_ci	  protected mode content on fully coherent platforms, as the switch to IO
3113d0407baSopenharmony_ci	  coherency mode requires the L2 to be turned off.
3123d0407baSopenharmony_ci
3133d0407baSopenharmony_ciconfig MALI_HW_ERRATA_1485982_USE_CLOCK_ALTERNATIVE
3143d0407baSopenharmony_ci	bool "Use alternative workaround for BASE_HW_ISSUE_GPU2017_1336"
3153d0407baSopenharmony_ci	depends on MALI_BIFROST && MALI_BIFROST_EXPERT && !MALI_HW_ERRATA_1485982_NOT_AFFECTED
3163d0407baSopenharmony_ci	default n
3173d0407baSopenharmony_ci	help
3183d0407baSopenharmony_ci	  This option uses an alternative workaround for GPU2017-1336. Lowering
3193d0407baSopenharmony_ci	  the GPU clock to a, platform specific, known good frequeuncy before
3203d0407baSopenharmony_ci	  powering down the L2 cache. The clock can be specified in the device
3213d0407baSopenharmony_ci	  tree using the property, opp-mali-errata-1485982. Otherwise the
3223d0407baSopenharmony_ci	  slowest clock will be selected.
3233d0407baSopenharmony_ci
3243d0407baSopenharmony_ci
3253d0407baSopenharmony_cisource "kernel/drivers/gpu/arm/midgard/arbitration/Mconfig"
3263d0407baSopenharmony_cisource "kernel/drivers/gpu/arm/midgard/tests/Mconfig"
327