Skip to content

Commit

Permalink
plugins/amdgpu - Increase maximum parameter length
Browse files Browse the repository at this point in the history
The topology parsing assumed that all parameter names were
30 characters or fewer, but

recommended_sdma_engine_id_mask

is 31 characters.

Make the maximum length a macro, and set it to 64.

Signed-off-by: David Francis <[email protected]>
  • Loading branch information
fdavid-amd authored and avagin committed Sep 17, 2024
1 parent 412cdd2 commit e451838
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions plugins/amdgpu/amdgpu_plugin_topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "amdgpu_plugin_topology.h"

#define TOPOLOGY_PATH "/sys/class/kfd/kfd/topology/nodes/"
#define MAX_PARAMETER_LEN 64

/* User override options */
/* Skip firmware version check */
Expand Down Expand Up @@ -417,7 +418,9 @@ struct tp_node *sys_add_node(struct tp_system *sys, uint32_t id, uint32_t gpu_id

static bool get_prop(char *line, char *name, uint64_t *value)
{
if (sscanf(line, " %29s %lu", name, value) != 2)
char format[16];
sprintf(format, " %%%ds %%lu", MAX_PARAMETER_LEN);
if (sscanf(line, format, name, value) != 2)
return false;
return true;
}
Expand All @@ -437,7 +440,7 @@ static int parse_topo_node_properties(struct tp_node *dev, const char *dir_path)
}

while (fgets(line, sizeof(line), file)) {
char name[30];
char name[MAX_PARAMETER_LEN + 1];
uint64_t value;

memset(name, 0, sizeof(name));
Expand Down Expand Up @@ -565,7 +568,7 @@ static int parse_topo_node_mem_banks(struct tp_node *node, const char *dir_path)
}

while (fgets(line, sizeof(line), file)) {
char name[30];
char name[MAX_PARAMETER_LEN + 1];
uint64_t value;

memset(name, 0, sizeof(name));
Expand Down Expand Up @@ -654,7 +657,7 @@ static int parse_topo_node_iolinks(struct tp_node *node, const char *dir_path)
}

while (fgets(line, sizeof(line), file)) {
char name[30];
char name[MAX_PARAMETER_LEN + 1];
uint64_t value;

memset(name, 0, sizeof(name));
Expand Down

0 comments on commit e451838

Please sign in to comment.