drivers/gpu/drm/i915/i915_syncmap.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/i915_syncmap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/i915_syncmap.c- Extension
.c- Size
- 11205 bytes
- Lines
- 409
- 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.
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/slab.hi915_syncmap.hi915_gem.hi915_selftest.hselftests/i915_syncmap.c
Detected Declarations
struct i915_syncmapfunction i915_syncmap_initfunction __sync_branch_idxfunction __sync_leaf_idxfunction __sync_branch_prefixfunction __sync_leaf_prefixfunction seqno_laterfunction i915_syncmap_is_laterfunction __sync_alloc_leaffunction __sync_set_seqnofunction __sync_set_childfunction __sync_setfunction i915_syncmap_setfunction is_laterfunction __sync_freefunction i915_syncmap_free
Annotated Snippet
struct i915_syncmap {
u64 prefix;
unsigned int height;
unsigned int bitmap;
struct i915_syncmap *parent;
union {
DECLARE_FLEX_ARRAY(u32, seqno);
DECLARE_FLEX_ARRAY(struct i915_syncmap *, child);
};
};
/**
* i915_syncmap_init -- initialise the #i915_syncmap
* @root: pointer to the #i915_syncmap
*/
void i915_syncmap_init(struct i915_syncmap **root)
{
BUILD_BUG_ON_NOT_POWER_OF_2(KSYNCMAP);
BUILD_BUG_ON_NOT_POWER_OF_2(SHIFT);
BUILD_BUG_ON(KSYNCMAP > BITS_PER_TYPE((*root)->bitmap));
*root = NULL;
}
static inline u32 *__sync_seqno(struct i915_syncmap *p)
{
GEM_BUG_ON(p->height);
return p->seqno;
}
static inline struct i915_syncmap **__sync_child(struct i915_syncmap *p)
{
GEM_BUG_ON(!p->height);
return p->child;
}
static inline unsigned int
__sync_branch_idx(const struct i915_syncmap *p, u64 id)
{
return (id >> p->height) & MASK;
}
static inline unsigned int
__sync_leaf_idx(const struct i915_syncmap *p, u64 id)
{
GEM_BUG_ON(p->height);
return id & MASK;
}
static inline u64 __sync_branch_prefix(const struct i915_syncmap *p, u64 id)
{
return id >> p->height >> SHIFT;
}
static inline u64 __sync_leaf_prefix(const struct i915_syncmap *p, u64 id)
{
GEM_BUG_ON(p->height);
return id >> SHIFT;
}
static inline bool seqno_later(u32 a, u32 b)
{
return (s32)(a - b) >= 0;
}
/**
* i915_syncmap_is_later -- compare against the last know sync point
* @root: pointer to the #i915_syncmap
* @id: the context id (other timeline) we are synchronising to
* @seqno: the sequence number along the other timeline
*
* If we have already synchronised this @root timeline with another (@id) then
* we can omit any repeated or earlier synchronisation requests. If the two
* timelines are already coupled, we can also omit the dependency between the
* two as that is already known via the timeline.
*
* Returns true if the two timelines are already synchronised wrt to @seqno,
* false if not and the synchronisation must be emitted.
*/
bool i915_syncmap_is_later(struct i915_syncmap **root, u64 id, u32 seqno)
{
struct i915_syncmap *p;
unsigned int idx;
p = *root;
if (!p)
return false;
if (likely(__sync_leaf_prefix(p, id) == p->prefix))
goto found;
Annotation
- Immediate include surface: `linux/slab.h`, `i915_syncmap.h`, `i915_gem.h`, `i915_selftest.h`, `selftests/i915_syncmap.c`.
- Detected declarations: `struct i915_syncmap`, `function i915_syncmap_init`, `function __sync_branch_idx`, `function __sync_leaf_idx`, `function __sync_branch_prefix`, `function __sync_leaf_prefix`, `function seqno_later`, `function i915_syncmap_is_later`, `function __sync_alloc_leaf`, `function __sync_set_seqno`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.