@@ -256,11 +256,6 @@ static __init int setup_node(int pxm)
*/
unsigned int numa_distance_cnt;
-static inline unsigned int get_numa_distances_cnt(struct acpi_table_slit *slit)
-{
- return slit->locality_count;
-}
-
void __init numa_set_distance(int from, int to, int distance)
{
if ((u8)distance != distance || (from == to && distance != LOCAL_DISTANCE)) {
@@ -283,6 +283,11 @@ acpi_table_print_srat_entry(struct acpi_subtable_header *header)
}
}
+static inline u64 get_numa_distances_cnt(struct acpi_table_slit *slit)
+{
+ return slit->locality_count;
+}
+
/*
* A lot of BIOS fill in 10 (= no distance) everywhere. This messes
* up the NUMA heuristics which wants the local node to have a smaller
@@ -292,7 +297,7 @@ acpi_table_print_srat_entry(struct acpi_subtable_header *header)
static int __init slit_valid(struct acpi_table_slit *slit)
{
int i, j;
- int d = slit->locality_count;
+ u64 d = get_numa_distances_cnt(slit);
for (i = 0; i < d; i++) {
for (j = 0; j < d; j++) {
u8 val = slit->entry[d*i + j];
@@ -337,20 +342,20 @@ static int __init acpi_parse_slit(struct acpi_table_header *table)
return -EINVAL;
}
- for (i = 0; i < slit->locality_count; i++) {
+ for (i = 0; i < get_numa_distances_cnt(slit); i++) {
const int from_node = pxm_to_node(i);
if (from_node == NUMA_NO_NODE)
continue;
- for (j = 0; j < slit->locality_count; j++) {
+ for (j = 0; j < get_numa_distances_cnt(slit); j++) {
const int to_node = pxm_to_node(j);
if (to_node == NUMA_NO_NODE)
continue;
numa_set_distance(from_node, to_node,
- slit->entry[slit->locality_count * i + j]);
+ slit->entry[get_numa_distances_cnt(slit) * i + j]);
}
}
In LoongArch, get_numa_distances_cnt() was not in use, resulting in a compiler warning. Serendipitously, drivers/acpi/numa/srat.c appears to be a more relevant location for this helper function, hence its relocation. This commit not only resolves these immediate concerns but also sets the groundwork for potential future integration of ACPI related logic from other architectures into this driver module. Separately, the locality_count member in struct acpi_table_slit is typed as u64. Adapt the function type to eliminate potential code risks. Fix follow errors with clang-18 when W=1e: arch/loongarch/kernel/acpi.c:259:28: error: unused function 'get_numa_distances_cnt' [-Werror,-Wunused-function] 259 | static inline unsigned int get_numa_distances_cnt(struct acpi_table_slit *slit) | ^~~~~~~~~~~~~~~~~~~~~~ 1 error generated. Signed-off-by: WangYuli <wangyuli@uniontech.com> --- arch/loongarch/kernel/acpi.c | 5 ----- drivers/acpi/numa/srat.c | 13 +++++++++---- 2 files changed, 9 insertions(+), 9 deletions(-)