Lines Matching +full:cache +full:- +full:unified

1 // SPDX-License-Identifier: GPL-2.0
3 * pptt.c - parsing of Processor Properties Topology Table (PPTT)
8 * which is optionally used to describe the processor and cache topology.
14 * the caches available at that level. Each cache structure optionally
15 * contains properties describing the cache at a given level which can be
33 if (pptt_ref + sizeof(struct acpi_subtable_header) > table_hdr->length) in fetch_pptt_subtable()
38 if (entry->length == 0) in fetch_pptt_subtable()
41 if (pptt_ref + entry->length > table_hdr->length) in fetch_pptt_subtable()
65 if (resource >= node->number_of_priv_resources) in acpi_get_pptt_resource()
81 * acpi_pptt_walk_cache() - Attempt to find the requested acpi_pptt_cache
83 * @local_level: passed res reflects this cache level
84 * @res: cache resource in the PPTT we want to walk
86 * @level: the requested cache level
87 * @type: the requested cache type
89 * Attempt to find a given cache level, while counting the max number
90 * of cache levels for the cache node.
92 * Given a pptt resource, verify that it is a cache node, then walk
94 * as well as checking the cache type (icache, dcache, unified). If a
96 * Once the entire cache branch has been walked return its max
99 * Return: The cache structure and the level we terminated with.
107 struct acpi_pptt_cache *cache; in acpi_pptt_walk_cache() local
109 if (res->type != ACPI_PPTT_TYPE_CACHE) in acpi_pptt_walk_cache()
112 cache = (struct acpi_pptt_cache *) res; in acpi_pptt_walk_cache()
113 while (cache) { in acpi_pptt_walk_cache()
117 cache->flags & ACPI_PPTT_CACHE_TYPE_VALID && in acpi_pptt_walk_cache()
118 acpi_pptt_match_type(cache->attributes, type)) { in acpi_pptt_walk_cache()
119 if (*found != NULL && cache != *found) in acpi_pptt_walk_cache()
120 pr_warn("Found duplicate cache level/type unable to determine uniqueness\n"); in acpi_pptt_walk_cache()
122 pr_debug("Found cache @ level %u\n", level); in acpi_pptt_walk_cache()
123 *found = cache; in acpi_pptt_walk_cache()
127 * cache node. in acpi_pptt_walk_cache()
130 cache = fetch_pptt_cache(table_hdr, cache->next_level_of_cache); in acpi_pptt_walk_cache()
168 * acpi_count_levels() - Given a PPTT table, and a CPU node, count the caches
175 * caches that exist across packages). Count the number of cache levels that
187 cpu_node = fetch_pptt_node(table_hdr, cpu_node->parent); in acpi_count_levels()
194 * acpi_pptt_leaf_node() - Given a processor node, determine if its a leaf
213 if (table_hdr->revision > 1) in acpi_pptt_leaf_node()
214 return (node->flags & ACPI_PPTT_ACPI_LEAF_NODE); in acpi_pptt_leaf_node()
216 table_end = (unsigned long)table_hdr + table_hdr->length; in acpi_pptt_leaf_node()
224 if (entry->type == ACPI_PPTT_TYPE_PROCESSOR && in acpi_pptt_leaf_node()
225 cpu_node->parent == node_entry) in acpi_pptt_leaf_node()
227 if (entry->length == 0) in acpi_pptt_leaf_node()
230 entry->length); in acpi_pptt_leaf_node()
237 * acpi_find_processor_node() - Given a PPTT table find the requested processor
258 table_end = (unsigned long)table_hdr + table_hdr->length; in acpi_find_processor_node()
267 if (entry->length == 0) { in acpi_find_processor_node()
271 if (entry->type == ACPI_PPTT_TYPE_PROCESSOR && in acpi_find_processor_node()
272 acpi_cpu_id == cpu_node->acpi_processor_id && in acpi_find_processor_node()
278 entry->length); in acpi_find_processor_node()
301 pr_debug("Looking for data cache\n"); in acpi_cache_type()
304 pr_debug("Looking for instruction cache\n"); in acpi_cache_type()
308 pr_debug("Looking for unified cache\n"); in acpi_cache_type()
312 * ACPI unified bit patterns because we use it later in acpi_cache_type()
330 pr_debug("Looking for CPU %d's level %u cache type %d\n", in acpi_find_cache_node()
339 cpu_node = fetch_pptt_node(table_hdr, cpu_node->parent); in acpi_find_cache_node()
346 * update_cache_properties() - Update cacheinfo for the given processor
347 * @this_leaf: Kernel cache info structure being updated
348 * @found_cache: The PPTT node describing this cache instance
349 * @cpu_node: A unique reference to describe this cache instance
351 * The ACPI spec implies that the fields in the cache structures are used to
361 this_leaf->fw_token = cpu_node; in update_cache_properties()
362 if (found_cache->flags & ACPI_PPTT_SIZE_PROPERTY_VALID) in update_cache_properties()
363 this_leaf->size = found_cache->size; in update_cache_properties()
364 if (found_cache->flags & ACPI_PPTT_LINE_SIZE_VALID) in update_cache_properties()
365 this_leaf->coherency_line_size = found_cache->line_size; in update_cache_properties()
366 if (found_cache->flags & ACPI_PPTT_NUMBER_OF_SETS_VALID) in update_cache_properties()
367 this_leaf->number_of_sets = found_cache->number_of_sets; in update_cache_properties()
368 if (found_cache->flags & ACPI_PPTT_ASSOCIATIVITY_VALID) in update_cache_properties()
369 this_leaf->ways_of_associativity = found_cache->associativity; in update_cache_properties()
370 if (found_cache->flags & ACPI_PPTT_WRITE_POLICY_VALID) { in update_cache_properties()
371 switch (found_cache->attributes & ACPI_PPTT_MASK_WRITE_POLICY) { in update_cache_properties()
373 this_leaf->attributes = CACHE_WRITE_THROUGH; in update_cache_properties()
376 this_leaf->attributes = CACHE_WRITE_BACK; in update_cache_properties()
380 if (found_cache->flags & ACPI_PPTT_ALLOCATION_TYPE_VALID) { in update_cache_properties()
381 switch (found_cache->attributes & ACPI_PPTT_MASK_ALLOCATION_TYPE) { in update_cache_properties()
383 this_leaf->attributes |= CACHE_READ_ALLOCATE; in update_cache_properties()
386 this_leaf->attributes |= CACHE_WRITE_ALLOCATE; in update_cache_properties()
390 this_leaf->attributes |= in update_cache_properties()
396 * If cache type is NOCACHE, then the cache hasn't been specified in update_cache_properties()
397 * via other mechanisms. Update the type if a cache type has been in update_cache_properties()
400 * Note, we assume such caches are unified based on conventional system in update_cache_properties()
405 if (this_leaf->type == CACHE_TYPE_NOCACHE && in update_cache_properties()
406 found_cache->flags & ACPI_PPTT_CACHE_TYPE_VALID) in update_cache_properties()
407 this_leaf->type = CACHE_TYPE_UNIFIED; in update_cache_properties()
420 while (index < get_cpu_cacheinfo(cpu)->num_leaves) { in cache_setup_acpi_cpu()
421 this_leaf = this_cpu_ci->info_list + index; in cache_setup_acpi_cpu()
423 this_leaf->type, in cache_setup_acpi_cpu()
424 this_leaf->level, in cache_setup_acpi_cpu()
442 if (table_hdr->revision < 2) in flag_identical()
446 if (cpu->flags & ACPI_PPTT_ACPI_IDENTICAL) { in flag_identical()
447 next = fetch_pptt_node(table_hdr, cpu->parent); in flag_identical()
448 if (!(next && next->flags & ACPI_PPTT_ACPI_IDENTICAL)) in flag_identical()
469 } else if (cpu->flags & flag) in acpi_find_processor_tag()
472 prev_node = fetch_pptt_node(table_hdr, cpu->parent); in acpi_find_processor_tag()
476 level--; in acpi_find_processor_tag()
483 pr_warn_once("No PPTT table found, CPU and cache topology may be inaccurate\n"); in acpi_pptt_warn_missing()
487 * topology_get_acpi_cpu_tag() - Find a unique topology value for a feature
497 * Return: Unique value, or -ENOENT if unable to locate CPU
516 cpu_node->flags & ACPI_PPTT_ACPI_PROCESSOR_ID_VALID) in topology_get_acpi_cpu_tag()
517 return cpu_node->acpi_processor_id; in topology_get_acpi_cpu_tag()
522 return -ENOENT; in topology_get_acpi_cpu_tag()
534 return -ENOENT; in find_acpi_cpu_topology_tag()
545 * check_acpi_cpu_flag() - Determine if CPU node has a flag set
552 * Return: -ENOENT if the PPTT doesn't exist, the CPU cannot be found or
563 int ret = -ENOENT; in check_acpi_cpu_flag()
571 if (table->revision >= rev) in check_acpi_cpu_flag()
575 ret = (cpu_node->flags & flag) != 0; in check_acpi_cpu_flag()
583 * acpi_find_last_cache_level() - Determines the number of cache levels for a PE
586 * Given a logical CPU number, returns the number of levels of cache represented
588 * indicating we didn't find any cache levels.
590 * Return: Cache levels visible to this core.
599 pr_debug("Cache Setup find last level CPU=%d\n", cpu); in acpi_find_last_cache_level()
609 pr_debug("Cache Setup find last level level=%d\n", number_of_levels); in acpi_find_last_cache_level()
615 * cache_setup_acpi() - Override CPU cache topology with data from the PPTT
618 * Updates the global cache info provided by cpu_get_cacheinfo()
621 * cache levels have any valid flags set. Further, a unique value is
622 * associated with each known CPU cache entry. This unique value
625 * Return: -ENOENT on failure to find table, or 0 on success
632 pr_debug("Cache Setup ACPI CPU %d\n", cpu); in cache_setup_acpi()
637 return -ENOENT; in cache_setup_acpi()
647 * acpi_pptt_cpu_is_thread() - Determine if CPU is a thread
652 * -ENOENT ,if the PPTT doesn't exist, the CPU cannot be found or
661 * find_acpi_cpu_topology() - Determine a unique topology value for a given CPU
675 * Return: -ENOENT if the PPTT doesn't exist, or the CPU cannot be found.
684 * find_acpi_cpu_cache_topology() - Determine a unique cache topology value
686 * @level: The cache level for which we would like a unique ID
688 * Determine a unique ID for each unified cache in the system
690 * Return: -ENOENT if the PPTT doesn't exist, or the CPU cannot be found.
700 int ret = -1; in find_acpi_cpu_cache_topology()
705 return -ENOENT; in find_acpi_cpu_cache_topology()
721 * find_acpi_cpu_topology_package() - Determine a unique CPU package value
730 * Return: -ENOENT if the PPTT doesn't exist, or the CPU cannot be found.
740 * find_acpi_cpu_topology_hetero_id() - Get a core architecture tag
755 * Return: -ENOENT if the PPTT doesn't exist, or the CPU cannot be found.