File: intel_wa.c

package info (click to toggle)
intel-gpu-tools 2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 63,368 kB
  • sloc: xml: 781,458; ansic: 360,567; python: 8,336; yacc: 2,781; perl: 1,196; sh: 1,177; lex: 487; asm: 227; lisp: 35; makefile: 30
file content (54 lines) | stat: -rw-r--r-- 1,002 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// SPDX-License-Identifier: MIT
/*
 * Copyright © 2025 Intel Corporation
 */

#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>

#include "igt_debugfs.h"
#include "igt_sysfs.h"
#include "intel_wa.h"
#include "xe/xe_query.h"

/**
 * igt_has_intel_wa:
 * @drm_fd:	A drm file descriptor
 * @check_wa:	Workaround to be checked
 *
 * Returns:	0 if no WA, 1 if WA present, -1 on error
 */
int igt_has_intel_wa(int drm_fd, const char *check_wa)
{
	int ret = 0;
	int debugfs_fd;
	unsigned int xe;
	char name[256];
	char *debugfs_dump, *has_wa;

	debugfs_fd = igt_debugfs_dir(drm_fd);
	if (debugfs_fd == -1)
		return -1;

	xe_for_each_gt(drm_fd, xe) {
		sprintf(name, "gt%d/workarounds", xe);
		if (!igt_debugfs_exists(drm_fd, name, O_RDONLY)) {
			ret = -1;
			break;
		}

		debugfs_dump = igt_sysfs_get(debugfs_fd, name);
		if (debugfs_dump) {
			has_wa = strstr(debugfs_dump, check_wa);
			free(debugfs_dump);
			if (has_wa) {
				ret = 1;
				break;
			}
		}
	}

	close(debugfs_fd);
	return ret;
}