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

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

File Facts

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

struct heap_fence {
	struct i915_sw_fence fence;
	union {
		struct kref ref;
		struct rcu_head rcu;
	};
};

static int
heap_fence_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
{
	struct heap_fence *h = container_of(fence, typeof(*h), fence);

	switch (state) {
	case FENCE_COMPLETE:
		break;

	case FENCE_FREE:
		heap_fence_put(&h->fence);
	}

	return NOTIFY_DONE;
}

struct i915_sw_fence *heap_fence_create(gfp_t gfp)
{
	struct heap_fence *h;

	h = kmalloc_obj(*h, gfp);
	if (!h)
		return NULL;

	i915_sw_fence_init(&h->fence, heap_fence_notify);
	refcount_set(&h->ref.refcount, 2);

	return &h->fence;
}

static void heap_fence_release(struct kref *ref)
{
	struct heap_fence *h = container_of(ref, typeof(*h), ref);

	i915_sw_fence_fini(&h->fence);

	kfree_rcu(h, rcu);
}

void heap_fence_put(struct i915_sw_fence *fence)
{
	struct heap_fence *h = container_of(fence, typeof(*h), fence);

	kref_put(&h->ref, heap_fence_release);
}

Annotation

Implementation Notes