Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ACPI / PPTT: Add acpi_pptt_cache_v1_full to use pptt cache as one structure

In actbl2.h, acpi_pptt_cache describes the fields in the original
Cache Type Structure. In PPTT table version 3 a new field was added at the
end, cache_id. This is described in acpi_pptt_cache_v1 but rather than
including all v1 fields it just includes this one.

In lieu of this being fixed in acpica, introduce acpi_pptt_cache_v1_full to
contain all the fields of the Cache Type Structure . Update the existing
code to use this new struct. This simplifies the code and removes a
non-standard use of ACPI_ADD_PTR.

Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Reviewed-by: Fenghua Yu <fenghuay@nvidia.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Reviewed-by: Hanjun Guo <guohanjun@huawei.com>
Reviewed-by: Jeremy Linton <jeremy.linton@arm.com>
Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Tested-by: Hanjun Guo <guohanjun@huawei.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by

Ben Horgan and committed by
Catalin Marinas
cfc085af eeec7845

+36 -9
+36 -9
drivers/acpi/pptt.c
··· 21 21 #include <linux/cacheinfo.h> 22 22 #include <acpi/processor.h> 23 23 24 + /* 25 + * The acpi_pptt_cache_v1 in actbl2.h, which is imported from acpica, 26 + * only contains the cache_id field rather than all the fields of the 27 + * Cache Type Structure. Use this alternative structure until it is 28 + * resolved in acpica. 29 + */ 30 + struct acpi_pptt_cache_v1_full { 31 + struct acpi_subtable_header header; 32 + u16 reserved; 33 + u32 flags; 34 + u32 next_level_of_cache; 35 + u32 size; 36 + u32 number_of_sets; 37 + u8 associativity; 38 + u8 attributes; 39 + u16 line_size; 40 + u32 cache_id; 41 + } __packed; 42 + 24 43 static struct acpi_subtable_header *fetch_pptt_subtable(struct acpi_table_header *table_hdr, 25 44 u32 pptt_ref) 26 45 { ··· 73 54 u32 pptt_ref) 74 55 { 75 56 return (struct acpi_pptt_cache *)fetch_pptt_subtable(table_hdr, pptt_ref); 57 + } 58 + 59 + static struct acpi_pptt_cache_v1_full *upgrade_pptt_cache(struct acpi_pptt_cache *cache) 60 + { 61 + if (cache->header.length < sizeof(struct acpi_pptt_cache_v1_full)) 62 + return NULL; 63 + 64 + /* No use for v1 if the only additional field is invalid */ 65 + if (!(cache->flags & ACPI_PPTT_CACHE_ID_VALID)) 66 + return NULL; 67 + 68 + return (struct acpi_pptt_cache_v1_full *)cache; 76 69 } 77 70 78 71 static struct acpi_subtable_header *acpi_get_pptt_resource(struct acpi_table_header *table_hdr, ··· 386 355 * @this_leaf: Kernel cache info structure being updated 387 356 * @found_cache: The PPTT node describing this cache instance 388 357 * @cpu_node: A unique reference to describe this cache instance 389 - * @revision: The revision of the PPTT table 390 358 * 391 359 * The ACPI spec implies that the fields in the cache structures are used to 392 360 * extend and correct the information probed from the hardware. Lets only ··· 395 365 */ 396 366 static void update_cache_properties(struct cacheinfo *this_leaf, 397 367 struct acpi_pptt_cache *found_cache, 398 - struct acpi_pptt_processor *cpu_node, 399 - u8 revision) 368 + struct acpi_pptt_processor *cpu_node) 400 369 { 401 - struct acpi_pptt_cache_v1* found_cache_v1; 370 + struct acpi_pptt_cache_v1_full *found_cache_v1; 402 371 403 372 this_leaf->fw_token = cpu_node; 404 373 if (found_cache->flags & ACPI_PPTT_SIZE_PROPERTY_VALID) ··· 447 418 found_cache->flags & ACPI_PPTT_CACHE_TYPE_VALID) 448 419 this_leaf->type = CACHE_TYPE_UNIFIED; 449 420 450 - if (revision >= 3 && (found_cache->flags & ACPI_PPTT_CACHE_ID_VALID)) { 451 - found_cache_v1 = ACPI_ADD_PTR(struct acpi_pptt_cache_v1, 452 - found_cache, sizeof(struct acpi_pptt_cache)); 421 + found_cache_v1 = upgrade_pptt_cache(found_cache); 422 + if (found_cache_v1) { 453 423 this_leaf->id = found_cache_v1->cache_id; 454 424 this_leaf->attributes |= CACHE_ID; 455 425 } ··· 473 445 pr_debug("found = %p %p\n", found_cache, cpu_node); 474 446 if (found_cache) 475 447 update_cache_properties(this_leaf, found_cache, 476 - ACPI_TO_POINTER(ACPI_PTR_DIFF(cpu_node, table)), 477 - table->revision); 448 + ACPI_TO_POINTER(ACPI_PTR_DIFF(cpu_node, table))); 478 449 479 450 index++; 480 451 }