# SPDX-License-Identifier: (GPL-2.0+ OR MIT)

menuconfig AMLOGIC_MEMORY_EXTEND
	bool "AMLOGIC memory extend support"
	depends on AMLOGIC_DRIVER
	depends on AMLOGIC_BREAK_GKI_20
	select SWIOTLB if !AMLOGIC_ZAPPER_CUT
	select DMA_RESTRICTED_POOL if !AMLOGIC_ZAPPER_CUT
	default n
	help
		Amlogic memory extend is drivers which extend for memory management
		functions, can be used for memory debug or other features.

config AMLOGIC_MIX_ZRAM
	tristate "Amlogic mixed zram"
	depends on AMLOGIC_MEMORY_EXTEND
	depends on CRYPTO_ZSTD
	depends on CRYPTO_LZ4
	default n
	help
		Mix compress algorithm of zram. This can get speed benifit of lz4 and
		compress ratio of zstd.

config AMLOGIC_PAGE_TRACE
	tristate "Amlogic trace for page allocate"
	depends on KALLSYMS
	depends on !NUMA_BALANCING
	default n
	help
		Amlogic page trace will record function address of caller for page
		allocate/free, according with allocate flags and order. trace
		information is stored in a pre-allocated memory block. And can be shown
		with allocate page count information of each caller functions from
		/proc/pagetrace

config AMLOGIC_PAGE_TRACE_INLINE
	bool "page trace inline into page flags"
	depends on AMLOGIC_BREAK_GKI
	depends on AMLOGIC_PAGE_TRACE
	depends on 64BIT
	depends on !KASAN_HW_TAGS && !KASAN_SW_TAGS
	default n
	help
		This feature enable to inline page trace into high 32bits of
		page->flags on 64 bit kernel. Because other total page flags
		are less than 32bit, so It can help to save memory when
		use page trace. But it conflict with KASAN tags, so when kasan
		tags enabled, this feature will be auto disabled

config AMLOGIC_CMA
	tristate "Amlogic CMA change"
	depends on CMA
	default n
	help
		Amlogic CMA optimization for cma alloc/free problems
		Including policy change of CMA usage

config AMLOGIC_NO_CMA
	tristate "Amlogic CMA change, add no cma flag"
	depends on CMA
	depends on AMLOGIC_CMA
	default n
	help
		Amlogic CMA optimization for cma alloc/free problems
		Including policy change of CMA usage, add no cma flag
		to avoid page not in cma pool.

config AMLOGIC_CMA_INFO
	tristate "Amlogic CMA change, add debug information"
	depends on CMA
	depends on AMLOGIC_CMA
	default n
	help
		Amlogic CMA optimization for cma alloc/free problems
		Including policy change of CMA usage, add more debug
		information in cma alloc/free flow.

config AMLOGIC_MEM_DEBUG
	tristate "Amlogic debug mem"
	default n
	help
		Memory debug which hacking to kernel mm source.

config AMLOGIC_STACKPROTECTOR
	bool "Amlogic stack protector"
	depends on AMLOGIC_MEMORY_EXTEND
	default n
	help
		This config is used to disable CONFIG_STACKPROTECTOR
		if enabled AMLOGIC_VMAP. CONFIG_STACKPROTECTOR have
		bad effect to save stack usage.

config AMLOGIC_PTR_AUTH_KERNEL
	bool "Amlogic arm64 ptr auth kernel"
	depends on AMLOGIC_MEMORY_EXTEND
	default n
	help
		This config is used to disable CONFIG_ARM64_PTR_AUTH_KERNEL.
		if enabled AMLOGIC_VMAP, CONFIG_ARM64_PTR_AUTH_KERNEL not
		allow to modify stack pointer.

config AMLOGIC_VMAP
	bool "Amlogic kernel stack"
	depends on AMLOGIC_MEMORY_EXTEND
	depends on AMLOGIC_BREAK_GKI
	depends on AMLOGIC_STACKPROTECTOR
	depends on !AMLOGIC_ARM_KASAN
	depends on AMLOGIC_PTR_AUTH_KERNEL || ARM
	default n
	help
		This config is used to enable amlogic kernel stack
		usage optimization with vmalloc. It depends on
		AMLOGIC_MEMORY_EXTEND. This config only opened
		on 64 bit platform.

config AMLOGIC_VMAP_CACHE_PAGE_ORDER
	int "Amlogic kernel stack cache page order"
	depends on AMLOGIC_VMAP
	default "8"
	help
		This config is used to set vmap stack cache
		page order, default order is 8, some projects
		can be modified appropriately.

config AMLOGIC_USER_FAULT
	tristate "Amlogic user fault helper"
	default n
	help
		show more information when catch user fault. Including:
		memory around all registers
		maps with pc/lr
		pfn for all virtual address of registers

config AMLOGIC_ZSTD
	tristate "Amlogic zstd optimize"
	depends on AMLOGIC_BREAK_GKI_20
	depends on AMLOGIC_MEMORY_EXTEND
	default n
	help
		This config is an optimization of zstd,
		in zram, to improve the compression ratio
		and save memory

config AMLOGIC_MEMORY_STAT
	bool "Amlogic stat memory info"
	depends on AMLOGIC_BREAK_GKI
	depends on AMLOGIC_MEMORY_EXTEND
	default n
	help
		This config use to stat memory info,
		include count free pages in migrate
		list, print more memory information.

config AMLOGIC_CMA_DIS
	bool "Amlogic CMA disable change fot gki"
	depends on AMLOGIC_MEMORY_EXTEND
	depends on CMA
	default n
	help
		Amlogic disable CMA optimization for gki needs.

config AMLOGIC_MEMORY_OPT
	bool "Amlogic memory optimization support"
	depends on AMLOGIC_MEMORY_EXTEND
	default n
	help
		Amlogic memory optimization support,
		distinguish from AMLOGIC_MEMORY_EXTEND,
		because of gki requirements, enable in
		aarch32.

config AMLOGIC_PIN_LOCKED_FILE
	bool "Amlogic pin locked file"
	depends on AMLOGIC_BREAK_GKI
	depends on AMLOGIC_MEMORY_EXTEND
	default n
	help
		If we pin a file in android, the whole daa of this
		file will be loaded to DDR, but most of these data
		may not be used, this caused memory waste.
		delay mark mlocked flags for unevictable pages until
		it has been faulted.

config AMLOGIC_PIN_LOCKED_FILE_V2
	bool "Amlogic pin locked file new version"
	depends on AMLOGIC_BREAK_GKI
	depends on AMLOGIC_MEMORY_EXTEND
	default n
	help
		If we pin a file in android, the whole daa of this
		file will be loaded to DDR, but most of these data
		may not be used, this caused memory waste.
		delay mark mlocked flags for unevictable pages until
		it has been faulted.

config AMLOGIC_PCIE_DMA_OPS
	tristate "Amlogic PCIE dma_ops"
	depends on AMLOGIC_MEMORY_EXTEND
	select DMA_DIRECT_REMAP if AMLOGIC_BREAK_GKI
	select SWIOTLB if AMLOGIC_BREAK_GKI
	default n
	help
		custom a dma_ops to limit the memory for PCIE device
		operations to a fixed area

config AMLOGIC_FAKE_SMMU
	tristate "Amlogic fake smmu"
	depends on IOMMU_SUPPORT
	default n
	help
		Register a fake smmu device to replace ops for 64bit

config AMLOGIC_ARM_KASAN
	bool "support arm kasan"
	depends on KASAN
	depends on ARM
	default y
	help
		Support enable kasan on arm32

config AMLOGIC_DTB_NODE_OPT
	bool "remove dtb node optimization"
	default n
	help
		some project to optimize the slab size, remove the
		dtb node under /sys/firmware/devicetree directory.

config AMLOGIC_KALLSYM_OPT
	bool "kallsyms optimization"
	default n
	help
		some project to optimize the kallsyms.

config AMLOGIC_PRINTK_OPT
	bool "printk optimization"
	default n
	help
		some project to optimize the printk, reduce the
		log buffer size.

config AMLOGIC_KHEADERS_OPT
	bool "kheaders optimization"
	default n
	help
		some project to remove the kheaders, reduce the
		kernel image size.

config AMLOGIC_MEMORY_SLAB_LARGE
	tristate "large kmalloc optimization"
	default n
	help
		kmalloc defaults to order alignment, change it
		to page alignment to reduce memory usage.

config AMLOGIC_SWAPD_OPT
	bool "filecache reclaim optimization"
	default n
	help
		for filecache with many references, do not
		recycle them to reduce memory thrashing.

