drivers/gpu/drm/i915/selftests/i915_syncmap.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/selftests/i915_syncmap.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/i915/selftests/i915_syncmap.c
Extension
.c
Size
14608 bytes
Lines
617
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

for_each_set_bit(i, (unsigned long *)&p->bitmap, KSYNCMAP) {
			len = scnprintf(buf, *sz, " %x:%x,",
					i, __sync_seqno(p)[i]);
			buf += len;
			*sz -= len;
		}
		buf -= 1;
		*sz += 1;
	}

	len = scnprintf(buf, *sz, "\n");
	buf += len;
	*sz -= len;

	if (p->height) {
		for_each_set_bit(i, (unsigned long *)&p->bitmap, KSYNCMAP) {
			buf = __sync_print(__sync_child(p)[i], buf, sz,
					   depth + 1,
					   last << 1 | ((p->bitmap >> (i + 1)) ? 1 : 0),
					   i);
		}
	}

	return buf;
}

static bool
i915_syncmap_print_to_buf(struct i915_syncmap *p, char *buf, unsigned long sz)
{
	if (!p)
		return false;

	while (p->parent)
		p = p->parent;

	__sync_print(p, buf, &sz, 0, 1, 0);
	return true;
}

static int check_syncmap_free(struct i915_syncmap **sync)
{
	i915_syncmap_free(sync);
	if (*sync) {
		pr_err("sync not cleared after free\n");
		return -EINVAL;
	}

	return 0;
}

static int dump_syncmap(struct i915_syncmap *sync, int err)
{
	char *buf;

	if (!err)
		return check_syncmap_free(&sync);

	buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
	if (!buf)
		goto skip;

	if (i915_syncmap_print_to_buf(sync, buf, PAGE_SIZE))
		pr_err("%s", buf);

	kfree(buf);

skip:
	i915_syncmap_free(&sync);
	return err;
}

static int igt_syncmap_init(void *arg)
{
	struct i915_syncmap *sync = (void *)~0ul;

	/*
	 * Cursory check that we can initialise a random pointer and transform
	 * it into the root pointer of a syncmap.
	 */

	i915_syncmap_init(&sync);
	return check_syncmap_free(&sync);
}

static int check_seqno(struct i915_syncmap *leaf, unsigned int idx, u32 seqno)
{
	if (leaf->height) {
		pr_err("%s: not a leaf, height is %d\n",
		       __func__, leaf->height);
		return -EINVAL;

Annotation

Implementation Notes