kernel-fxtec-pro1x/include/linux/memblock.h
Srinivasarao P 18ffdaaa38 Merge android-4.19-stable.113 (2b82910d) into msm-4.19
* refs/heads/tmp-2b82910d:
  Reverting incrementalfs, power,usb and scheduler changes
  ANDROID: Incremental fs: Fix four resource bugs
  ANDROID: Bulk update the ABI xml based on the referenced bugs.
  ANDROID: GKI: block: resolve ABI diff when CONFIG_BLK_DEV_BSG is unset
  ANDROID: GKI: bfq-iosched: update struct elevator_mq_ops ABI
  ANDROID: GKI: locking/rwsem: add vendor field to struct rw_semaphore
  ANDROID: GKI: fs: add umount_end() function to struct super_operations
  ANDROID: GKI: perf: Add fields for CPU hotplug feature
  ANDROID: GKI: perf: Add field for struct perf_event
  ANDROID: GKI: cpuset: add field for task affinity for cpusets
  UPSTREAM: ubifs: wire up FS_IOC_GET_ENCRYPTION_NONCE
  UPSTREAM: f2fs: wire up FS_IOC_GET_ENCRYPTION_NONCE
  UPSTREAM: ext4: wire up FS_IOC_GET_ENCRYPTION_NONCE
  UPSTREAM: fscrypt: add FS_IOC_GET_ENCRYPTION_NONCE ioctl
  UPSTREAM: usb: raw_gadget: fix compilation warnings in uapi headers
  BACKPORT: usb: gadget: add raw-gadget interface
  UPSTREAM: usb: gadget: move choice ... endchoice to legacy/Kconfig
  UPSTREAM: ipv6: ndisc: add support for 'PREF64' dns64 prefix identifier
  ANDROID: GKI: Removed cuttlefish configs
  ANDROID: GKI: Removed cuttlefish configs
  ANDROID: clang: update to 10.0.5
  FROMLIST: arm64: define __alloc_zeroed_user_highpage
  ANDROID: Incremental fs: Add INCFS_IOC_GET_FILLED_BLOCKS
  ANDROID: Incremental fs: Fix two typos
  ANDROID: GKI: Update ABI
  ANDROID: GKI: power_supply: add more soc properties
  ANDROID: GKI: Update ABI
  ANDROID: GKI: google_battery: return string type for serial_number property
  ANDROID: GKI: power: supply: Add APSD based power-supply properties
  ANDROID: GKI: power: supply: Remove "Wipower" PSY type
  ANDROID: GKI: power: supply: Add support for HVDCP_3P5
  ANDROID: GKI: power_supply: Define Debug Accessory Mode
  ANDROID: GKI: power: supply: Add POWER_SUPPLY_PROP_AICL_*
  ANDROID: GKI: power: supply: Add POWER_SUPPLY_PROP_ALIGNMENT
  ANDROID: GKI: power_supply: Add CP_ISNS_SLAVE power supply property
  ANDROID: GKI: power_supply: add properties to report parallel connection topology
  ANDROID: GKI: power_supply: add POWER_SUPPLY_PROP_IRQ_STATUS property
  ANDROID: GKI: power: supply: add CHARGE_CHARGER_STATE property
  ANDROID: GKI: power: supply: Add POWER_SUPPLY_PROP_PTMC_ID
  ANDROID: GKI: power: supply: Add POWER_SUPPLY_PROP_OTG_FASTROLESWAP
  ANDROID: GKI: power: supply: Add VOLTAGE_STEP property
  ANDROID: GKI: power: supply: Add AICL_DONE parameter
  ANDROID: GKI: power_supply: Add operating frequency property
  ANDROID: GKI: power: supply: Add POWER_SUPPLY_PROP_CC_UAH
  ANDROID: GKI: power: supply: Add POWER_SUPPLY_PROP_VOLTAGE_FIFO
  ANDROID: GKI: power: supply: Add capacity and resistance estimates
  ANDROID: GKI: power_supply: Add vendor specific dead battery property
  ANDROID: GKI: power-supply: add ADAPTER_DETAILS power supply property
  ANDROID: GKI: power: supply: Add POWER_SUPPLY_PROP_CHARGE_DISABLE
  ANDROID: GKI: power: power_supply: Add property to display skin thermal status
  ANDROID: GKI: power_supply: Add properties to support PPS constant current(CC) mode
  ANDROID: GKI: power: power_supply: Add REAL_CAPACITY property
  ANDROID: GKI: power_supply: Add VOLTAGE_MAX_LIMIT power supply property
  ANDROID: GKI: power_supply: Add DC_RESET power-supply property
  ANDROID: GKI: power_supply: Add "THERM_ICL_LIMIT" property
  ANDROID: GKI: power_supply: add CHIP_VERSION property
  ANDROID: GKI: power-supply: Add VOLTAGE_VPH power supply property
  ANDROID: GKI: power_supply: Add SCALE_MODE_EN power-supply property
  ANDROID: GKI: power_supply: Add local extensions of string property names properly
  ANDROID: GKI: power_supply: add batt_age_level property
  ANDROID: GKI: power-supply: Add CC_SOC power supply property
  ANDROID: GKI: power_supply: add property to disable QC userspace optimizations
  ANDROID: GKI: power: power_supply: Add FG_RESET power supply property
  ANDROID: GKI: power_supply: Add power supply type "Charge Pump"
  ANDROID: GKI: power: supply: Add snapshot of power supply framework files
  ANDROID: GKI: power: power_supply: Add property CHARGE_COUNTER_EXT and 64-bit precision properties
  ANDROID: GKI: power: power_supply: add POWER_SUPPLY_PROP_CHARGE_ENABLED
  ANDROID: GKI: power: power_supply: add POWER_SUPPLY_PROP_USB_OTG
  ANDROID: GKI: power: power_supply: Add custom property for USB High Current mode
  UPSTREAM: coresight: Potential uninitialized variable in probe()
  ANDROID: GKI: Update ABI.
  ANDROID: GKI: Add API to create pagetable mappings.
  ANDROID: GKI: drivers: usb: Add functions usb_func_ep_queue/usb_func_wakeup
  ANDROID: GKI: Add API usb_ep_autoconfig_by_name
  ANDROID: GKI: usb: core: Add helper function to return controller id
  ANDROID: dm-bow: Fix free_show value is incorrect
  ANDROID: GKI: update ABI after fixing cfg80211_chan_def diff
  BACKPORT: nl80211: Add support for EDMG channels
  FROMGIT: sched/rt: cpupri_find: Trigger a full search as fallback
  FROMGIT: sched/rt: Remove unnecessary push for unfit tasks
  BACKPORT: FROMGIT: sched/rt: Allow pulling unfitting task
  FROMGIT: sched/rt: Optimize cpupri_find() on non-heterogenous systems
  FROMGIT: sched/rt: Re-instate old behavior in select_task_rq_rt()
  BACKPORT: FROMGIT: sched/rt: cpupri_find: Implement fallback mechanism for !fit case
  ANDROID: GKI: re-enable LTO, CFI and SCS

 Conflicts:
	arch/arm64/mm/mmu.c
	drivers/net/wireless/ath/wil6210/cfg80211.c
	drivers/usb/gadget/Kconfig
	include/linux/memblock.h
	include/linux/perf_event.h
	include/linux/rwsem.h
	include/uapi/linux/nl80211.h

Change-Id: I7aa8a1712c323fc5a2eced52a07bfb6df6996ba0
Signed-off-by: Srinivasarao P <spathi@codeaurora.org>
2020-07-16 20:55:24 +05:30

461 lines
15 KiB
C

#ifndef _LINUX_MEMBLOCK_H
#define _LINUX_MEMBLOCK_H
#ifdef __KERNEL__
#ifdef CONFIG_HAVE_MEMBLOCK
/*
* Logical memory blocks.
*
* Copyright (C) 2001 Peter Bergner, IBM Corp.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#include <linux/init.h>
#include <linux/mm.h>
#define INIT_MEMBLOCK_REGIONS 128
#define INIT_PHYSMEM_REGIONS 4
/**
* enum memblock_flags - definition of memory region attributes
* @MEMBLOCK_NONE: no special request
* @MEMBLOCK_HOTPLUG: hotpluggable region
* @MEMBLOCK_MIRROR: mirrored region
* @MEMBLOCK_NOMAP: don't add to kernel direct mapping
*/
enum memblock_flags {
MEMBLOCK_NONE = 0x0, /* No special request */
MEMBLOCK_HOTPLUG = 0x1, /* hotpluggable region */
MEMBLOCK_MIRROR = 0x2, /* mirrored region */
MEMBLOCK_NOMAP = 0x4, /* don't add to kernel direct mapping */
};
/**
* struct memblock_region - represents a memory region
* @base: physical address of the region
* @size: size of the region
* @flags: memory region attributes
* @nid: NUMA node id
*/
struct memblock_region {
phys_addr_t base;
phys_addr_t size;
enum memblock_flags flags;
#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
int nid;
#endif
};
/**
* struct memblock_type - collection of memory regions of certain type
* @cnt: number of regions
* @max: size of the allocated array
* @total_size: size of all regions
* @regions: array of regions
* @name: the memory type symbolic name
*/
struct memblock_type {
unsigned long cnt;
unsigned long max;
phys_addr_t total_size;
struct memblock_region *regions;
char *name;
};
/**
* struct memblock - memblock allocator metadata
* @bottom_up: is bottom up direction?
* @current_limit: physical address of the current allocation limit
* @memory: usabe memory regions
* @reserved: reserved memory regions
* @physmem: all physical memory
*/
struct memblock {
bool bottom_up; /* is bottom up direction? */
phys_addr_t current_limit;
struct memblock_type memory;
struct memblock_type reserved;
#ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP
struct memblock_type physmem;
#endif
};
extern struct memblock memblock;
extern int memblock_debug;
#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
#define __init_memblock __meminit
#define __initdata_memblock __meminitdata
void memblock_discard(void);
#else
#define __init_memblock
#define __initdata_memblock
#endif
#define memblock_dbg(fmt, ...) \
if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
phys_addr_t memblock_find_in_range_node(phys_addr_t size, phys_addr_t align,
phys_addr_t start, phys_addr_t end,
int nid, enum memblock_flags flags);
phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end,
phys_addr_t size, phys_addr_t align);
void memblock_allow_resize(void);
int memblock_add_node(phys_addr_t base, phys_addr_t size, int nid);
int memblock_add(phys_addr_t base, phys_addr_t size);
int memblock_remove(phys_addr_t base, phys_addr_t size);
int memblock_free(phys_addr_t base, phys_addr_t size);
int memblock_reserve(phys_addr_t base, phys_addr_t size);
void memblock_trim_memory(phys_addr_t align);
bool memblock_overlaps_region(struct memblock_type *type,
phys_addr_t base, phys_addr_t size);
int memblock_mark_hotplug(phys_addr_t base, phys_addr_t size);
int memblock_clear_hotplug(phys_addr_t base, phys_addr_t size);
int memblock_mark_mirror(phys_addr_t base, phys_addr_t size);
int memblock_mark_nomap(phys_addr_t base, phys_addr_t size);
int memblock_clear_nomap(phys_addr_t base, phys_addr_t size);
enum memblock_flags choose_memblock_flags(void);
/* Low level functions */
int memblock_add_range(struct memblock_type *type,
phys_addr_t base, phys_addr_t size,
int nid, enum memblock_flags flags);
void __next_mem_range(u64 *idx, int nid, enum memblock_flags flags,
struct memblock_type *type_a,
struct memblock_type *type_b, phys_addr_t *out_start,
phys_addr_t *out_end, int *out_nid);
void __next_mem_range_rev(u64 *idx, int nid, enum memblock_flags flags,
struct memblock_type *type_a,
struct memblock_type *type_b, phys_addr_t *out_start,
phys_addr_t *out_end, int *out_nid);
void __next_reserved_mem_region(u64 *idx, phys_addr_t *out_start,
phys_addr_t *out_end);
void __memblock_free_early(phys_addr_t base, phys_addr_t size);
void __memblock_free_late(phys_addr_t base, phys_addr_t size);
void create_pgtable_mapping(phys_addr_t start, phys_addr_t end);
/**
* for_each_mem_range - iterate through memblock areas from type_a and not
* included in type_b. Or just type_a if type_b is NULL.
* @i: u64 used as loop variable
* @type_a: ptr to memblock_type to iterate
* @type_b: ptr to memblock_type which excludes from the iteration
* @nid: node selector, %NUMA_NO_NODE for all nodes
* @flags: pick from blocks based on memory attributes
* @p_start: ptr to phys_addr_t for start address of the range, can be %NULL
* @p_end: ptr to phys_addr_t for end address of the range, can be %NULL
* @p_nid: ptr to int for nid of the range, can be %NULL
*/
#define for_each_mem_range(i, type_a, type_b, nid, flags, \
p_start, p_end, p_nid) \
for (i = 0, __next_mem_range(&i, nid, flags, type_a, type_b, \
p_start, p_end, p_nid); \
i != (u64)ULLONG_MAX; \
__next_mem_range(&i, nid, flags, type_a, type_b, \
p_start, p_end, p_nid))
/**
* for_each_mem_range_rev - reverse iterate through memblock areas from
* type_a and not included in type_b. Or just type_a if type_b is NULL.
* @i: u64 used as loop variable
* @type_a: ptr to memblock_type to iterate
* @type_b: ptr to memblock_type which excludes from the iteration
* @nid: node selector, %NUMA_NO_NODE for all nodes
* @flags: pick from blocks based on memory attributes
* @p_start: ptr to phys_addr_t for start address of the range, can be %NULL
* @p_end: ptr to phys_addr_t for end address of the range, can be %NULL
* @p_nid: ptr to int for nid of the range, can be %NULL
*/
#define for_each_mem_range_rev(i, type_a, type_b, nid, flags, \
p_start, p_end, p_nid) \
for (i = (u64)ULLONG_MAX, \
__next_mem_range_rev(&i, nid, flags, type_a, type_b,\
p_start, p_end, p_nid); \
i != (u64)ULLONG_MAX; \
__next_mem_range_rev(&i, nid, flags, type_a, type_b, \
p_start, p_end, p_nid))
/**
* for_each_reserved_mem_region - iterate over all reserved memblock areas
* @i: u64 used as loop variable
* @p_start: ptr to phys_addr_t for start address of the range, can be %NULL
* @p_end: ptr to phys_addr_t for end address of the range, can be %NULL
*
* Walks over reserved areas of memblock. Available as soon as memblock
* is initialized.
*/
#define for_each_reserved_mem_region(i, p_start, p_end) \
for (i = 0UL, __next_reserved_mem_region(&i, p_start, p_end); \
i != (u64)ULLONG_MAX; \
__next_reserved_mem_region(&i, p_start, p_end))
static inline bool memblock_is_hotpluggable(struct memblock_region *m)
{
return m->flags & MEMBLOCK_HOTPLUG;
}
static inline bool memblock_is_mirror(struct memblock_region *m)
{
return m->flags & MEMBLOCK_MIRROR;
}
static inline bool memblock_is_nomap(struct memblock_region *m)
{
return m->flags & MEMBLOCK_NOMAP;
}
#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
int memblock_search_pfn_nid(unsigned long pfn, unsigned long *start_pfn,
unsigned long *end_pfn);
void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn,
unsigned long *out_end_pfn, int *out_nid);
/**
* for_each_mem_pfn_range - early memory pfn range iterator
* @i: an integer used as loop variable
* @nid: node selector, %MAX_NUMNODES for all nodes
* @p_start: ptr to ulong for start pfn of the range, can be %NULL
* @p_end: ptr to ulong for end pfn of the range, can be %NULL
* @p_nid: ptr to int for nid of the range, can be %NULL
*
* Walks over configured memory ranges.
*/
#define for_each_mem_pfn_range(i, nid, p_start, p_end, p_nid) \
for (i = -1, __next_mem_pfn_range(&i, nid, p_start, p_end, p_nid); \
i >= 0; __next_mem_pfn_range(&i, nid, p_start, p_end, p_nid))
#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
/**
* for_each_free_mem_range - iterate through free memblock areas
* @i: u64 used as loop variable
* @nid: node selector, %NUMA_NO_NODE for all nodes
* @flags: pick from blocks based on memory attributes
* @p_start: ptr to phys_addr_t for start address of the range, can be %NULL
* @p_end: ptr to phys_addr_t for end address of the range, can be %NULL
* @p_nid: ptr to int for nid of the range, can be %NULL
*
* Walks over free (memory && !reserved) areas of memblock. Available as
* soon as memblock is initialized.
*/
#define for_each_free_mem_range(i, nid, flags, p_start, p_end, p_nid) \
for_each_mem_range(i, &memblock.memory, &memblock.reserved, \
nid, flags, p_start, p_end, p_nid)
/**
* for_each_free_mem_range_reverse - rev-iterate through free memblock areas
* @i: u64 used as loop variable
* @nid: node selector, %NUMA_NO_NODE for all nodes
* @flags: pick from blocks based on memory attributes
* @p_start: ptr to phys_addr_t for start address of the range, can be %NULL
* @p_end: ptr to phys_addr_t for end address of the range, can be %NULL
* @p_nid: ptr to int for nid of the range, can be %NULL
*
* Walks over free (memory && !reserved) areas of memblock in reverse
* order. Available as soon as memblock is initialized.
*/
#define for_each_free_mem_range_reverse(i, nid, flags, p_start, p_end, \
p_nid) \
for_each_mem_range_rev(i, &memblock.memory, &memblock.reserved, \
nid, flags, p_start, p_end, p_nid)
static inline void memblock_set_region_flags(struct memblock_region *r,
enum memblock_flags flags)
{
r->flags |= flags;
}
static inline void memblock_clear_region_flags(struct memblock_region *r,
enum memblock_flags flags)
{
r->flags &= ~flags;
}
#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
int memblock_set_node(phys_addr_t base, phys_addr_t size,
struct memblock_type *type, int nid);
static inline void memblock_set_region_node(struct memblock_region *r, int nid)
{
r->nid = nid;
}
static inline int memblock_get_region_node(const struct memblock_region *r)
{
return r->nid;
}
#else
static inline void memblock_set_region_node(struct memblock_region *r, int nid)
{
}
static inline int memblock_get_region_node(const struct memblock_region *r)
{
return 0;
}
#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
phys_addr_t memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int nid);
phys_addr_t memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid);
phys_addr_t memblock_alloc(phys_addr_t size, phys_addr_t align);
/*
* Set the allocation direction to bottom-up or top-down.
*/
static inline void __init memblock_set_bottom_up(bool enable)
{
memblock.bottom_up = enable;
}
/*
* Check if the allocation direction is bottom-up or not.
* if this is true, that said, memblock will allocate memory
* in bottom-up direction.
*/
static inline bool memblock_bottom_up(void)
{
return memblock.bottom_up;
}
/* Flags for memblock_alloc_base() amd __memblock_alloc_base() */
#define MEMBLOCK_ALLOC_ANYWHERE (~(phys_addr_t)0)
#define MEMBLOCK_ALLOC_ACCESSIBLE 0
#define MEMBLOCK_ALLOC_KASAN 1
phys_addr_t __init memblock_alloc_range(phys_addr_t size, phys_addr_t align,
phys_addr_t start, phys_addr_t end,
enum memblock_flags flags);
phys_addr_t memblock_alloc_base_nid(phys_addr_t size,
phys_addr_t align, phys_addr_t max_addr,
int nid, enum memblock_flags flags);
phys_addr_t memblock_alloc_base(phys_addr_t size, phys_addr_t align,
phys_addr_t max_addr);
phys_addr_t __memblock_alloc_base(phys_addr_t size, phys_addr_t align,
phys_addr_t max_addr);
phys_addr_t memblock_phys_mem_size(void);
phys_addr_t memblock_reserved_size(void);
phys_addr_t memblock_mem_size(unsigned long limit_pfn);
phys_addr_t memblock_start_of_DRAM(void);
phys_addr_t memblock_end_of_DRAM(void);
phys_addr_t memblock_max_addr(phys_addr_t limit);
void memblock_enforce_memory_limit(phys_addr_t memory_limit);
void memblock_cap_memory_range(phys_addr_t base, phys_addr_t size);
void memblock_mem_limit_remove_map(phys_addr_t limit);
bool memblock_is_memory(phys_addr_t addr);
bool memblock_is_map_memory(phys_addr_t addr);
bool memblock_is_region_memory(phys_addr_t base, phys_addr_t size);
bool memblock_is_reserved(phys_addr_t addr);
bool memblock_is_region_reserved(phys_addr_t base, phys_addr_t size);
bool memblock_overlaps_memory(phys_addr_t base, phys_addr_t size);
extern void __memblock_dump_all(void);
static inline void memblock_dump_all(void)
{
if (memblock_debug)
__memblock_dump_all();
}
/**
* memblock_set_current_limit - Set the current allocation limit to allow
* limiting allocations to what is currently
* accessible during boot
* @limit: New limit value (physical address)
*/
void memblock_set_current_limit(phys_addr_t limit);
phys_addr_t memblock_get_current_limit(void);
/*
* pfn conversion functions
*
* While the memory MEMBLOCKs should always be page aligned, the reserved
* MEMBLOCKs may not be. This accessor attempt to provide a very clear
* idea of what they return for such non aligned MEMBLOCKs.
*/
/**
* memblock_region_memory_base_pfn - get the lowest pfn of the memory region
* @reg: memblock_region structure
*
* Return: the lowest pfn intersecting with the memory region
*/
static inline unsigned long memblock_region_memory_base_pfn(const struct memblock_region *reg)
{
return PFN_UP(reg->base);
}
/**
* memblock_region_memory_end_pfn - get the end pfn of the memory region
* @reg: memblock_region structure
*
* Return: the end_pfn of the reserved region
*/
static inline unsigned long memblock_region_memory_end_pfn(const struct memblock_region *reg)
{
return PFN_DOWN(reg->base + reg->size);
}
/**
* memblock_region_reserved_base_pfn - get the lowest pfn of the reserved region
* @reg: memblock_region structure
*
* Return: the lowest pfn intersecting with the reserved region
*/
static inline unsigned long memblock_region_reserved_base_pfn(const struct memblock_region *reg)
{
return PFN_DOWN(reg->base);
}
/**
* memblock_region_reserved_end_pfn - get the end pfn of the reserved region
* @reg: memblock_region structure
*
* Return: the end_pfn of the reserved region
*/
static inline unsigned long memblock_region_reserved_end_pfn(const struct memblock_region *reg)
{
return PFN_UP(reg->base + reg->size);
}
#define for_each_memblock(memblock_type, region) \
for (region = memblock.memblock_type.regions; \
region < (memblock.memblock_type.regions + memblock.memblock_type.cnt); \
region++)
#define for_each_memblock_type(i, memblock_type, rgn) \
for (i = 0, rgn = &memblock_type->regions[0]; \
i < memblock_type->cnt; \
i++, rgn = &memblock_type->regions[i])
#define for_each_memblock_rev(memblock_type, region) \
for (region = memblock.memblock_type.regions + \
memblock.memblock_type.cnt - 1; \
region >= memblock.memblock_type.regions; \
region--)
#ifdef CONFIG_MEMTEST
extern void early_memtest(phys_addr_t start, phys_addr_t end);
#else
static inline void early_memtest(phys_addr_t start, phys_addr_t end)
{
}
#endif
#else
static inline phys_addr_t memblock_alloc(phys_addr_t size, phys_addr_t align)
{
return 0;
}
#endif /* CONFIG_HAVE_MEMBLOCK */
#endif /* __KERNEL__ */
#endif /* _LINUX_MEMBLOCK_H */