Lines Matching +full:cache +full:- +full:level
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
85 * @found: returns a pointer to the requested level if found
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
93 * down each level of caches, counting how many levels are found
94 * as well as checking the cache type (icache, dcache, unified). If a
95 * level & type match, then we set found, and continue the search.
96 * Once the entire cache branch has been walked return its max
99 * Return: The cache structure and the level we terminated with.
105 unsigned int level, int type) in acpi_pptt_walk_cache() argument
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()
116 if (local_level == level && 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()
138 unsigned int *starting_level, unsigned int level, in acpi_find_cache_level() argument
152 res, &ret, level, type); in acpi_find_cache_level()
168 * acpi_count_levels() - Given a PPTT table, and a CPU node, count the caches
173 * how many levels exist solely for it, and then walk up each level until we hit
174 * the root node (ignore the package level because it may be possible to have
175 * caches that exist across packages). Count the number of cache levels that
176 * exist at each level on the way up.
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()
322 unsigned int level, in acpi_find_cache_node() argument
330 pr_debug("Looking for CPU %d's level %u cache type %d\n", in acpi_find_cache_node()
331 acpi_cpu_id, level, acpi_type); in acpi_find_cache_node()
337 &total_levels, level, acpi_type); 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
352 * The ACPI spec implies that the fields in the cache structures are used to
365 this_leaf->fw_token = cpu_node; in update_cache_properties()
366 if (found_cache->flags & ACPI_PPTT_SIZE_PROPERTY_VALID) in update_cache_properties()
367 this_leaf->size = found_cache->size; in update_cache_properties()
368 if (found_cache->flags & ACPI_PPTT_LINE_SIZE_VALID) in update_cache_properties()
369 this_leaf->coherency_line_size = found_cache->line_size; in update_cache_properties()
370 if (found_cache->flags & ACPI_PPTT_NUMBER_OF_SETS_VALID) in update_cache_properties()
371 this_leaf->number_of_sets = found_cache->number_of_sets; in update_cache_properties()
372 if (found_cache->flags & ACPI_PPTT_ASSOCIATIVITY_VALID) in update_cache_properties()
373 this_leaf->ways_of_associativity = found_cache->associativity; in update_cache_properties()
374 if (found_cache->flags & ACPI_PPTT_WRITE_POLICY_VALID) { in update_cache_properties()
375 switch (found_cache->attributes & ACPI_PPTT_MASK_WRITE_POLICY) { in update_cache_properties()
377 this_leaf->attributes = CACHE_WRITE_THROUGH; in update_cache_properties()
380 this_leaf->attributes = CACHE_WRITE_BACK; in update_cache_properties()
384 if (found_cache->flags & ACPI_PPTT_ALLOCATION_TYPE_VALID) { in update_cache_properties()
385 switch (found_cache->attributes & ACPI_PPTT_MASK_ALLOCATION_TYPE) { in update_cache_properties()
387 this_leaf->attributes |= CACHE_READ_ALLOCATE; in update_cache_properties()
390 this_leaf->attributes |= CACHE_WRITE_ALLOCATE; in update_cache_properties()
394 this_leaf->attributes |= in update_cache_properties()
400 * If cache type is NOCACHE, then the cache hasn't been specified in update_cache_properties()
401 * via other mechanisms. Update the type if a cache type has been in update_cache_properties()
409 if (this_leaf->type == CACHE_TYPE_NOCACHE && in update_cache_properties()
410 found_cache->flags & ACPI_PPTT_CACHE_TYPE_VALID) in update_cache_properties()
411 this_leaf->type = CACHE_TYPE_UNIFIED; in update_cache_properties()
413 if (revision >= 3 && (found_cache->flags & ACPI_PPTT_CACHE_ID_VALID)) { in update_cache_properties()
416 this_leaf->id = found_cache_v1->cache_id; in update_cache_properties()
417 this_leaf->attributes |= CACHE_ID; in update_cache_properties()
431 while (index < get_cpu_cacheinfo(cpu)->num_leaves) { in cache_setup_acpi_cpu()
432 this_leaf = this_cpu_ci->info_list + index; in cache_setup_acpi_cpu()
434 this_leaf->type, in cache_setup_acpi_cpu()
435 this_leaf->level, in cache_setup_acpi_cpu()
440 cpu_node, table->revision); in cache_setup_acpi_cpu()
452 if (table_hdr->revision < 2) in flag_identical()
456 if (cpu->flags & ACPI_PPTT_ACPI_IDENTICAL) { in flag_identical()
457 next = fetch_pptt_node(table_hdr, cpu->parent); in flag_identical()
458 if (!(next && next->flags & ACPI_PPTT_ACPI_IDENTICAL)) in flag_identical()
465 /* Passing level values greater than this will result in search termination */
470 int level, int flag) in acpi_find_processor_tag() argument
474 while (cpu && level) { in acpi_find_processor_tag()
479 } else if (cpu->flags & flag) in acpi_find_processor_tag()
481 pr_debug("level %d\n", level); in acpi_find_processor_tag()
482 prev_node = fetch_pptt_node(table_hdr, cpu->parent); in acpi_find_processor_tag()
486 level--; in acpi_find_processor_tag()
493 pr_warn_once("No PPTT table found, CPU and cache topology may be inaccurate\n"); in acpi_pptt_warn_missing()
497 * topology_get_acpi_cpu_tag() - Find a unique topology value for a feature
500 * @level: A level that terminates the search
503 * Get a unique value given a CPU, and a topology level, that can be
505 * at that level.
507 * Return: Unique value, or -ENOENT if unable to locate CPU
510 unsigned int cpu, int level, int flag) in topology_get_acpi_cpu_tag() argument
518 level, flag); in topology_get_acpi_cpu_tag()
525 if (level == 0 || in topology_get_acpi_cpu_tag()
526 cpu_node->flags & ACPI_PPTT_ACPI_PROCESSOR_ID_VALID) in topology_get_acpi_cpu_tag()
527 return cpu_node->acpi_processor_id; in topology_get_acpi_cpu_tag()
532 return -ENOENT; in topology_get_acpi_cpu_tag()
535 static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag) in find_acpi_cpu_topology_tag() argument
544 return -ENOENT; in find_acpi_cpu_topology_tag()
546 retval = topology_get_acpi_cpu_tag(table, cpu, level, flag); in find_acpi_cpu_topology_tag()
547 pr_debug("Topology Setup ACPI CPU %d, level %d ret = %d\n", in find_acpi_cpu_topology_tag()
548 cpu, level, retval); in find_acpi_cpu_topology_tag()
555 * check_acpi_cpu_flag() - Determine if CPU node has a flag set
562 * Return: -ENOENT if the PPTT doesn't exist, the CPU cannot be found or
573 int ret = -ENOENT; in check_acpi_cpu_flag()
581 if (table->revision >= rev) in check_acpi_cpu_flag()
585 ret = (cpu_node->flags & flag) != 0; in check_acpi_cpu_flag()
593 * acpi_find_last_cache_level() - Determines the number of cache levels for a PE
596 * Given a logical CPU number, returns the number of levels of cache represented
598 * indicating we didn't find any cache levels.
600 * Return: Cache levels visible to this core.
609 pr_debug("Cache Setup find last level CPU=%d\n", cpu); in acpi_find_last_cache_level()
619 pr_debug("Cache Setup find last level level=%d\n", number_of_levels); in acpi_find_last_cache_level()
625 * cache_setup_acpi() - Override CPU cache topology with data from the PPTT
628 * Updates the global cache info provided by cpu_get_cacheinfo()
631 * cache levels have any valid flags set. Further, a unique value is
632 * associated with each known CPU cache entry. This unique value
635 * Return: -ENOENT on failure to find table, or 0 on success
642 pr_debug("Cache Setup ACPI CPU %d\n", cpu); in cache_setup_acpi()
647 return -ENOENT; in cache_setup_acpi()
657 * acpi_pptt_cpu_is_thread() - Determine if CPU is a thread
662 * -ENOENT ,if the PPTT doesn't exist, the CPU cannot be found or
671 * find_acpi_cpu_topology() - Determine a unique topology value for a given CPU
673 * @level: The topological level for which we would like a unique ID
679 * The search terminates when either the requested level is found or
681 * same unique ID. The unique id for level 0 is the acpi processor id. All
685 * Return: -ENOENT if the PPTT doesn't exist, or the CPU cannot be found.
688 int find_acpi_cpu_topology(unsigned int cpu, int level) in find_acpi_cpu_topology() argument
690 return find_acpi_cpu_topology_tag(cpu, level, 0); in find_acpi_cpu_topology()
694 * find_acpi_cpu_cache_topology() - Determine a unique cache topology value
696 * @level: The cache level for which we would like a unique ID
698 * Determine a unique ID for each unified cache in the system
700 * Return: -ENOENT if the PPTT doesn't exist, or the CPU cannot be found.
703 int find_acpi_cpu_cache_topology(unsigned int cpu, int level) in find_acpi_cpu_cache_topology() argument
710 int ret = -1; in find_acpi_cpu_cache_topology()
715 return -ENOENT; in find_acpi_cpu_cache_topology()
720 level, in find_acpi_cpu_cache_topology()
731 * find_acpi_cpu_topology_package() - Determine a unique CPU package value
737 * The search terminates when either a level is found with the PHYSICAL_PACKAGE
740 * Return: -ENOENT if the PPTT doesn't exist, or the CPU cannot be found.
750 * find_acpi_cpu_topology_hetero_id() - Get a core architecture tag
758 * The search terminates when a level is found with the identical implementation
765 * Return: -ENOENT if the PPTT doesn't exist, or the CPU cannot be found.