linux/drivers/base/cacheinfo.c

// SPDX-License-Identifier: GPL-2.0
/*
 * cacheinfo support - processor cache information via sysfs
 *
 * Based on arch/x86/kernel/cpu/intel_cacheinfo.c
 * Author: Sudeep Holla <[email protected]>
 */
#define pr_fmt(fmt)

#include <linux/acpi.h>
#include <linux/bitops.h>
#include <linux/cacheinfo.h>
#include <linux/compiler.h>
#include <linux/cpu.h>
#include <linux/device.h>
#include <linux/init.h>
#include <linux/of.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/smp.h>
#include <linux/sysfs.h>

/* pointer to per cpu cacheinfo */
static DEFINE_PER_CPU(struct cpu_cacheinfo, ci_cpu_cacheinfo);
#define ci_cacheinfo(cpu)
#define cache_leaves(cpu)
#define per_cpu_cacheinfo(cpu)
#define per_cpu_cacheinfo_idx(cpu, idx)

/* Set if no cache information is found in DT/ACPI. */
static bool use_arch_info;

struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu)
{}

static inline bool cache_leaves_are_shared(struct cacheinfo *this_leaf,
					   struct cacheinfo *sib_leaf)
{}

bool last_level_cache_is_valid(unsigned int cpu)
{}

bool last_level_cache_is_shared(unsigned int cpu_x, unsigned int cpu_y)
{}

#ifdef CONFIG_OF

static bool of_check_cache_nodes(struct device_node *np);

/* OF properties to query for a given cache type */
struct cache_type_info {};

static const struct cache_type_info cache_type_info[] =;

static inline int get_cacheinfo_idx(enum cache_type type)
{}

static void cache_size(struct cacheinfo *this_leaf, struct device_node *np)
{}

/* not cache_line_size() because that's a macro in include/linux/cache.h */
static void cache_get_line_size(struct cacheinfo *this_leaf,
				struct device_node *np)
{}

static void cache_nr_sets(struct cacheinfo *this_leaf, struct device_node *np)
{}

static void cache_associativity(struct cacheinfo *this_leaf)
{}

static bool cache_node_is_unified(struct cacheinfo *this_leaf,
				  struct device_node *np)
{}

static void cache_of_set_props(struct cacheinfo *this_leaf,
			       struct device_node *np)
{}

static int cache_setup_of_node(unsigned int cpu)
{}

static bool of_check_cache_nodes(struct device_node *np)
{}

static int of_count_cache_leaves(struct device_node *np)
{}

int init_of_cache_level(unsigned int cpu)
{}

#else
static inline int cache_setup_of_node(unsigned int cpu) { return 0; }
int init_of_cache_level(unsigned int cpu) { return 0; }
#endif

int __weak cache_setup_acpi(unsigned int cpu)
{}

unsigned int coherency_max_size;

static int cache_setup_properties(unsigned int cpu)
{}

static int cache_shared_cpu_map_setup(unsigned int cpu)
{}

static void cache_shared_cpu_map_remove(unsigned int cpu)
{}

static void free_cache_attributes(unsigned int cpu)
{}

int __weak early_cache_level(unsigned int cpu)
{}

int __weak init_cache_level(unsigned int cpu)
{}

int __weak populate_cache_leaves(unsigned int cpu)
{}

static inline
int allocate_cache_info(int cpu)
{}

int fetch_cache_info(unsigned int cpu)
{}

static inline int init_level_allocate_ci(unsigned int cpu)
{}

int detect_cache_attributes(unsigned int cpu)
{}

/* pointer to cpuX/cache device */
static DEFINE_PER_CPU(struct device *, ci_cache_dev);
#define per_cpu_cache_dev(cpu)

static cpumask_t cache_dev_map;

/* pointer to array of devices for cpuX/cache/indexY */
static DEFINE_PER_CPU(struct device **, ci_index_dev);
#define per_cpu_index_dev(cpu)
#define per_cache_index_dev(cpu, idx)

#define show_one(file_name, object)

show_one(id, id);
show_one(level, level);
show_one(coherency_line_size, coherency_line_size);
show_one(number_of_sets, number_of_sets);
show_one(physical_line_partition, physical_line_partition);
show_one(ways_of_associativity, ways_of_associativity);

static ssize_t size_show(struct device *dev,
			 struct device_attribute *attr, char *buf)
{}

static ssize_t shared_cpu_map_show(struct device *dev,
				   struct device_attribute *attr, char *buf)
{}

static ssize_t shared_cpu_list_show(struct device *dev,
				    struct device_attribute *attr, char *buf)
{}

static ssize_t type_show(struct device *dev,
			 struct device_attribute *attr, char *buf)
{}

static ssize_t allocation_policy_show(struct device *dev,
				      struct device_attribute *attr, char *buf)
{}

static ssize_t write_policy_show(struct device *dev,
				 struct device_attribute *attr, char *buf)
{}

static DEVICE_ATTR_RO(id);
static DEVICE_ATTR_RO(level);
static DEVICE_ATTR_RO(type);
static DEVICE_ATTR_RO(coherency_line_size);
static DEVICE_ATTR_RO(ways_of_associativity);
static DEVICE_ATTR_RO(number_of_sets);
static DEVICE_ATTR_RO(size);
static DEVICE_ATTR_RO(allocation_policy);
static DEVICE_ATTR_RO(write_policy);
static DEVICE_ATTR_RO(shared_cpu_map);
static DEVICE_ATTR_RO(shared_cpu_list);
static DEVICE_ATTR_RO(physical_line_partition);

static struct attribute *cache_default_attrs[] =;

static umode_t
cache_default_attrs_is_visible(struct kobject *kobj,
			       struct attribute *attr, int unused)
{}

static const struct attribute_group cache_default_group =;

static const struct attribute_group *cache_default_groups[] =;

static const struct attribute_group *cache_private_groups[] =;

const struct attribute_group *
__weak cache_get_priv_group(struct cacheinfo *this_leaf)
{}

static const struct attribute_group **
cache_get_attribute_groups(struct cacheinfo *this_leaf)
{}

/* Add/Remove cache interface for CPU device */
static void cpu_cache_sysfs_exit(unsigned int cpu)
{}

static int cpu_cache_sysfs_init(unsigned int cpu)
{}

static int cache_add_dev(unsigned int cpu)
{}

static unsigned int cpu_map_shared_cache(bool online, unsigned int cpu,
					 cpumask_t **map)
{}

/*
 * Calculate the size of the per-CPU data cache slice.  This can be
 * used to estimate the size of the data cache slice that can be used
 * by one CPU under ideal circumstances.  UNIFIED caches are counted
 * in addition to DATA caches.  So, please consider code cache usage
 * when use the result.
 *
 * Because the cache inclusive/non-inclusive information isn't
 * available, we just use the size of the per-CPU slice of LLC to make
 * the result more predictable across architectures.
 */
static void update_per_cpu_data_slice_size_cpu(unsigned int cpu)
{}

static void update_per_cpu_data_slice_size(bool cpu_online, unsigned int cpu,
					   cpumask_t *cpu_map)
{}

static int cacheinfo_cpu_online(unsigned int cpu)
{}

static int cacheinfo_cpu_pre_down(unsigned int cpu)
{}

static int __init cacheinfo_sysfs_init(void)
{}
device_initcall(cacheinfo_sysfs_init);