libhsakmt: remove iommu_block which supports IOMMUv2 performance
IOMMUv2 is removed from AMDGPU/KFD. Change-Id: I9fcf20ae9288cb40bb4b696284fc70534fb6484b Signed-off-by: James Zhu <James.Zhu@amd.com>
Esse commit está contido em:
@@ -188,7 +188,6 @@ HSAKMT_STATUS init_counter_props(unsigned int NumNodes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
counter_props_count = NumNodes;
|
counter_props_count = NumNodes;
|
||||||
alloc_pmc_blocks();
|
|
||||||
|
|
||||||
if (init_shared_region() != HSAKMT_STATUS_SUCCESS) {
|
if (init_shared_region() != HSAKMT_STATUS_SUCCESS) {
|
||||||
pr_warn("Profiling of privileged blocks is not available.\n");
|
pr_warn("Profiling of privileged blocks is not available.\n");
|
||||||
@@ -215,7 +214,6 @@ void destroy_counter_props(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(counter_props);
|
free(counter_props);
|
||||||
free_pmc_blocks();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int blockid2uuid(enum perf_block_id block_id, HSA_UUID *uuid)
|
static int blockid2uuid(enum perf_block_id block_id, HSA_UUID *uuid)
|
||||||
|
|||||||
@@ -1958,122 +1958,6 @@ static struct perf_counter_block navi_blocks[PERFCOUNTER_BLOCKID__MAX] = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Current APUs only have one IOMMU. If NUMA is introduced to APUs, we'll need
|
|
||||||
* to expand the struct here to an array.
|
|
||||||
*/
|
|
||||||
static struct perf_counter_block iommu_block;
|
|
||||||
|
|
||||||
static HSAKMT_STATUS alloc_pmc_blocks_iommu(void)
|
|
||||||
{
|
|
||||||
DIR *dir;
|
|
||||||
struct dirent *dent;
|
|
||||||
const char *sysfs_amdiommu_event_path =
|
|
||||||
"/sys/bus/event_source/devices/amd_iommu_0/events";
|
|
||||||
/* Counter source in IOMMU's Counter Bank Addressing register is 8 bits,
|
|
||||||
* so the biggest counter number/id possible is 0xff.
|
|
||||||
*/
|
|
||||||
const int max_counter_id = 0xff;
|
|
||||||
char path[256];
|
|
||||||
const int len = sizeof(path);
|
|
||||||
FILE *file;
|
|
||||||
int num;
|
|
||||||
char counter_id[max_counter_id + 1];
|
|
||||||
HSAKMT_STATUS ret = HSAKMT_STATUS_SUCCESS;
|
|
||||||
uint32_t *ptr;
|
|
||||||
struct perf_counter_block *block = &iommu_block;
|
|
||||||
|
|
||||||
memset(block, 0, sizeof(struct perf_counter_block));
|
|
||||||
|
|
||||||
dir = opendir(sysfs_amdiommu_event_path);
|
|
||||||
if (!dir) {
|
|
||||||
/* Before kernel 4.12, amd_iommu is the path */
|
|
||||||
sysfs_amdiommu_event_path =
|
|
||||||
"/sys/bus/event_source/devices/amd_iommu/events";
|
|
||||||
dir = opendir(sysfs_amdiommu_event_path);
|
|
||||||
if (!dir)
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(counter_id, 0, max_counter_id + 1);
|
|
||||||
while ((dent = readdir(dir))) {
|
|
||||||
if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, ".."))
|
|
||||||
continue;
|
|
||||||
if (snprintf(path, len, "%s/%s", sysfs_amdiommu_event_path,
|
|
||||||
dent->d_name) >= len) {
|
|
||||||
pr_err("Increase path length.\n");
|
|
||||||
ret = HSAKMT_STATUS_NO_MEMORY;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
file = fopen(path, "r");
|
|
||||||
if (!file) {
|
|
||||||
ret = HSAKMT_STATUS_ERROR;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
if (fscanf(file, "csource=0x%x", &num) != 1) {
|
|
||||||
ret = HSAKMT_STATUS_ERROR;
|
|
||||||
fclose(file);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
if (num > max_counter_id)
|
|
||||||
/* This should never happen. If it does, check IOMMU driver. */
|
|
||||||
pr_err("max_counter_id %d is set too small.\n",
|
|
||||||
max_counter_id);
|
|
||||||
else {
|
|
||||||
counter_id[num] = 1;
|
|
||||||
++block->num_of_counters;
|
|
||||||
}
|
|
||||||
fclose(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
block->counter_ids = malloc(sizeof(uint32_t) * block->num_of_counters);
|
|
||||||
if (!block->counter_ids) {
|
|
||||||
ret = HSAKMT_STATUS_NO_MEMORY;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
ptr = block->counter_ids;
|
|
||||||
for (num = 0; num < (max_counter_id + 1); num++) {
|
|
||||||
if (counter_id[num]) {
|
|
||||||
ptr[0] = num;
|
|
||||||
++ptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (snprintf(path, len, "%s/%d/%s",
|
|
||||||
"/sys/devices/virtual/kfd/kfd/topology/nodes",
|
|
||||||
0, /* IOMMU is in node 0. Change this if NUMA is introduced to APU. */
|
|
||||||
"perf/iommu/max_concurrent") >= len) {
|
|
||||||
pr_err("Increase path length\n");
|
|
||||||
ret = HSAKMT_STATUS_NO_MEMORY;
|
|
||||||
goto out;
|
|
||||||
};
|
|
||||||
file = fopen(path, "r");
|
|
||||||
if (!file) {
|
|
||||||
ret = HSAKMT_STATUS_ERROR;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
if (fscanf(file, "%d", &block->num_of_slots) != 1)
|
|
||||||
ret = HSAKMT_STATUS_ERROR;
|
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
out:
|
|
||||||
if (dir)
|
|
||||||
closedir(dir);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
HSAKMT_STATUS alloc_pmc_blocks(void)
|
|
||||||
{
|
|
||||||
return alloc_pmc_blocks_iommu();
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_pmc_blocks(void)
|
|
||||||
{
|
|
||||||
if (iommu_block.counter_ids)
|
|
||||||
free(iommu_block.counter_ids);
|
|
||||||
iommu_block.counter_ids = NULL;
|
|
||||||
iommu_block.num_of_counters = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
HSAKMT_STATUS get_block_properties(uint32_t node_id,
|
HSAKMT_STATUS get_block_properties(uint32_t node_id,
|
||||||
enum perf_block_id block_id,
|
enum perf_block_id block_id,
|
||||||
struct perf_counter_block *block)
|
struct perf_counter_block *block)
|
||||||
|
|||||||
@@ -67,9 +67,6 @@ struct perf_counter_block {
|
|||||||
uint64_t counter_mask;
|
uint64_t counter_mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
HSAKMT_STATUS alloc_pmc_blocks(void);
|
|
||||||
void free_pmc_blocks(void);
|
|
||||||
|
|
||||||
HSAKMT_STATUS get_block_properties(uint32_t node_id,
|
HSAKMT_STATUS get_block_properties(uint32_t node_id,
|
||||||
enum perf_block_id block_id,
|
enum perf_block_id block_id,
|
||||||
struct perf_counter_block *block);
|
struct perf_counter_block *block);
|
||||||
|
|||||||
Referência em uma Nova Issue
Bloquear um usuário