drivers/gpu/host1x/cdma.c
Source file repositories/reference/linux-study-clean/drivers/gpu/host1x/cdma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/host1x/cdma.c- Extension
.c- Size
- 16767 bytes
- Lines
- 688
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
asm/cacheflush.hlinux/device.hlinux/dma-mapping.hlinux/host1x.hlinux/interrupt.hlinux/kernel.hlinux/kfifo.hlinux/slab.htrace/events/host1x.hcdma.hchannel.hdev.hdebug.hjob.h
Detected Declarations
function host1x_pushbuffer_destroyfunction host1x_pushbuffer_initfunction host1x_pushbuffer_pushfunction host1x_pushbuffer_popfunction host1x_pushbuffer_spacefunction Sleepfunction Sleepfunction cdma_start_timer_lockedfunction stop_cdma_timer_lockedfunction update_cdma_lockedfunction host1x_cdma_update_sync_queuefunction list_for_each_entryfunction list_for_each_entry_continuefunction cdma_update_workfunction host1x_cdma_initfunction host1x_cdma_deinitfunction host1x_cdma_beginfunction host1x_cdma_pushfunction host1x_cdma_push_widefunction host1x_cdma_endfunction host1x_cdma_update
Annotated Snippet
if (!alloc) {
err = -ENOMEM;
goto iommu_free_mem;
}
pb->dma = iova_dma_addr(&host1x->iova, alloc);
err = iommu_map(host1x->domain, pb->dma, pb->phys, size,
IOMMU_READ, GFP_KERNEL);
if (err)
goto iommu_free_iova;
} else {
pb->mapped = dma_alloc_wc(host1x->dev, size, &pb->phys,
GFP_KERNEL);
if (!pb->mapped)
return -ENOMEM;
pb->dma = pb->phys;
}
pb->alloc_size = size;
host1x_hw_pushbuffer_init(host1x, pb);
return 0;
iommu_free_iova:
__free_iova(&host1x->iova, alloc);
iommu_free_mem:
dma_free_wc(host1x->dev, size, pb->mapped, pb->phys);
return err;
}
/*
* Push two words to the push buffer
* Caller must ensure push buffer is not full
*/
static void host1x_pushbuffer_push(struct push_buffer *pb, u32 op1, u32 op2)
{
u32 *p = (u32 *)((void *)pb->mapped + pb->pos);
WARN_ON(pb->pos == pb->fence);
*(p++) = op1;
*(p++) = op2;
pb->pos += 8;
if (pb->pos >= pb->size)
pb->pos -= pb->size;
}
/*
* Pop a number of two word slots from the push buffer
* Caller must ensure push buffer is not empty
*/
static void host1x_pushbuffer_pop(struct push_buffer *pb, unsigned int slots)
{
/* Advance the next write position */
pb->fence += slots * 8;
if (pb->fence >= pb->size)
pb->fence -= pb->size;
}
/*
* Return the number of two word slots free in the push buffer
*/
static u32 host1x_pushbuffer_space(struct push_buffer *pb)
{
unsigned int fence = pb->fence;
if (pb->fence < pb->pos)
fence += pb->size;
return (fence - pb->pos) / 8;
}
/*
* Sleep (if necessary) until the requested event happens
* - CDMA_EVENT_SYNC_QUEUE_EMPTY : sync queue is completely empty.
* - Returns 1
* - CDMA_EVENT_PUSH_BUFFER_SPACE : there is space in the push buffer
* - Return the amount of space (> 0)
* Must be called with the cdma lock held.
*/
unsigned int host1x_cdma_wait_locked(struct host1x_cdma *cdma,
enum cdma_event event)
{
for (;;) {
struct push_buffer *pb = &cdma->push_buffer;
unsigned int space;
Annotation
- Immediate include surface: `asm/cacheflush.h`, `linux/device.h`, `linux/dma-mapping.h`, `linux/host1x.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/kfifo.h`, `linux/slab.h`.
- Detected declarations: `function host1x_pushbuffer_destroy`, `function host1x_pushbuffer_init`, `function host1x_pushbuffer_push`, `function host1x_pushbuffer_pop`, `function host1x_pushbuffer_space`, `function Sleep`, `function Sleep`, `function cdma_start_timer_locked`, `function stop_cdma_timer_locked`, `function update_cdma_locked`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.