drivers/gpu/drm/xe/xe_gen_wa_oob.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_gen_wa_oob.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/xe/xe_gen_wa_oob.c
Extension
.c
Size
4136 bytes
Lines
214
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (line[0] == '\0' || line[0] == '#' || line[0] == '\n') {
			lineno++;
			continue;
		}

		linelen = strlen(line);
		if (linelen == MAX_LINE_LEN) {
			print_parse_error("line too long", line, lineno);
			return -EINVAL;
		}

		is_continuation = isspace(line[0]);
		name = strip(line, linelen);

		if (!is_continuation) {
			name = strtok(name, " \t");
			rules = strtok(NULL, "");
		} else {
			if (!prev_name) {
				print_parse_error("invalid rule continuation",
						  line, lineno);
				return -EINVAL;
			}

			rules = name;
			name = NULL;
		}

		if (rules[0] == '\0') {
			print_parse_error("invalid empty rule\n", line, lineno);
			return -EINVAL;
		}

		if (name) {
			fprintf(cheader, "\t%s_%s = %u,\n", prefix, name, idx);

			/* Close previous entry before starting a new one */
			if (idx)
				fprintf(csource, ") },\n");

			fprintf(csource, "{ XE_RTP_NAME(\"%s\"),\n  XE_RTP_RULES(%s",
				name, rules);
			idx++;
		} else {
			fprintf(csource, ", OR,\n\t%s", rules);
		}

		lineno++;
		if (!is_continuation)
			prev_name = name;
	}

	/* Close last entry */
	if (idx)
		fprintf(csource, ") },\n");

	fprintf(cheader, "\t_%s_COUNT = %u\n", prefix, idx);

	return 0;
}

/* Avoid GNU vs POSIX basename() discrepancy, just use our own */
static const char *xbasename(const char *s)
{
	const char *p = strrchr(s, '/');

	return p ? p + 1 : s;
}

static int fn_to_prefix(const char *fn, char *prefix, size_t size)
{
	size_t len;

	fn = xbasename(fn);
	len = strlen(fn);

	if (len > size - 1)
		return -ENAMETOOLONG;

	memcpy(prefix, fn, len + 1);

	for (char *p = prefix; *p; p++) {
		switch (*p) {
		case '.':
			*p = '\0';
			return 0;
		default:
			*p = toupper(*p);
			break;
		}

Annotation

Implementation Notes