drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c- Extension
.c- Size
- 11916 bytes
- Lines
- 515
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/dma-fence-chain.hamdgpu.hamdgpu_trace.hamdgpu_amdkfd.h
Detected Declarations
struct amdgpu_sync_entryfunction amdgpu_sync_createfunction amdgpu_sync_same_devfunction amdgpu_sync_keep_laterfunction amdgpu_sync_add_laterfunction hash_for_each_possiblefunction amdgpu_sync_fencefunction amdgpu_sync_test_fencefunction amdgpu_sync_resvfunction dma_fence_chain_for_eachfunction amdgpu_sync_kfdfunction amdgpu_sync_entry_freefunction hash_for_each_safefunction hash_for_each_safefunction amdgpu_sync_clonefunction hash_for_each_safefunction amdgpu_sync_movefunction amdgpu_sync_push_to_jobfunction hash_for_each_safefunction amdgpu_sync_waitfunction hash_for_each_safefunction amdgpu_sync_freefunction amdgpu_sync_initfunction amdgpu_sync_fini
Annotated Snippet
struct amdgpu_sync_entry {
struct hlist_node node;
struct dma_fence *fence;
};
static struct kmem_cache *amdgpu_sync_slab;
/**
* amdgpu_sync_create - zero init sync object
*
* @sync: sync object to initialize
*
* Just clear the sync object for now.
*/
void amdgpu_sync_create(struct amdgpu_sync *sync)
{
hash_init(sync->fences);
}
/**
* amdgpu_sync_same_dev - test if fence belong to us
*
* @adev: amdgpu device to use for the test
* @f: fence to test
*
* Test if the fence was issued by us.
*/
static bool amdgpu_sync_same_dev(struct amdgpu_device *adev,
struct dma_fence *f)
{
struct drm_sched_fence *s_fence = to_drm_sched_fence(f);
if (s_fence) {
struct amdgpu_ring *ring;
ring = container_of(s_fence->sched, struct amdgpu_ring, sched);
return ring->adev == adev;
}
return false;
}
/**
* amdgpu_sync_get_owner - extract the owner of a fence
*
* @f: fence get the owner from
*
* Extract who originally created the fence.
*/
static void *amdgpu_sync_get_owner(struct dma_fence *f)
{
struct drm_sched_fence *s_fence;
struct amdgpu_amdkfd_fence *kfd_fence;
if (!f)
return AMDGPU_FENCE_OWNER_UNDEFINED;
s_fence = to_drm_sched_fence(f);
if (s_fence)
return s_fence->owner;
kfd_fence = to_amdgpu_amdkfd_fence(f);
if (kfd_fence)
return AMDGPU_FENCE_OWNER_KFD;
return AMDGPU_FENCE_OWNER_UNDEFINED;
}
/**
* amdgpu_sync_keep_later - Keep the later fence
*
* @keep: existing fence to test
* @fence: new fence
*
* Either keep the existing fence or the new one, depending which one is later.
*/
static void amdgpu_sync_keep_later(struct dma_fence **keep,
struct dma_fence *fence)
{
if (*keep && dma_fence_is_later(*keep, fence))
return;
dma_fence_put(*keep);
*keep = dma_fence_get(fence);
}
/**
* amdgpu_sync_add_later - add the fence to the hash
*
* @sync: sync object to add the fence to
Annotation
- Immediate include surface: `linux/dma-fence-chain.h`, `amdgpu.h`, `amdgpu_trace.h`, `amdgpu_amdkfd.h`.
- Detected declarations: `struct amdgpu_sync_entry`, `function amdgpu_sync_create`, `function amdgpu_sync_same_dev`, `function amdgpu_sync_keep_later`, `function amdgpu_sync_add_later`, `function hash_for_each_possible`, `function amdgpu_sync_fence`, `function amdgpu_sync_test_fence`, `function amdgpu_sync_resv`, `function dma_fence_chain_for_each`.
- 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.