IOMMU path in sysfs is renamed

IOMMU path in sysfs was amd_iommu. After implementing multiple devices
support, the path is replaced with amd_iommu_<index>. Current Thunk spec
is not clear about how to support multiple instances in one block. There
is no products having multiple IOMMUs yet at this point. This patch
changes the path to support both amd_iommu and amd_iommu_0 for Carizo.

Change-Id: I3beea2fc78d96296232226191501a02ccf20d6b1
Signed-off-by: Amber Lin <Amber.Lin@amd.com>


[ROCm/ROCR-Runtime commit: 369902bf5b]
Este commit está contenido en:
Amber Lin
2017-08-18 10:15:21 -04:00
padre a885ad3724
commit 9ab8250fbc
Se han modificado 2 ficheros con 19 adiciones y 6 borrados
+9 -2
Ver fichero
@@ -365,9 +365,16 @@ static unsigned int get_perf_event_type(enum perf_block_id block_id)
FILE *file = NULL;
unsigned int type = 0;
if (block_id == PERFCOUNTER_BLOCKID__IOMMUV2)
file = fopen("/sys/bus/event_source/devices/amd_iommu/type",
if (block_id == PERFCOUNTER_BLOCKID__IOMMUV2) {
/* Starting from kernel 4.12, amd_iommu_0 is used */
file = fopen("/sys/bus/event_source/devices/amd_iommu_0/type",
"r");
if (!file)
file = fopen(/* kernel 4.11 and older */
"/sys/bus/event_source/devices/amd_iommu/type",
"r");
}
if (!file)
return 0;
+10 -4
Ver fichero
@@ -1601,8 +1601,8 @@ 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/events";
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.
*/
@@ -1619,8 +1619,14 @@ static HSAKMT_STATUS alloc_pmc_blocks_iommu(void)
memset(block, 0, sizeof(struct perf_counter_block));
dir = opendir(sysfs_amdiommu_event_path);
if (!dir)
goto out;
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))) {