drivers/gpu/drm/vc4/vc4_v3d.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vc4/vc4_v3d.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vc4/vc4_v3d.c- Extension
.c- Size
- 13261 bytes
- Lines
- 547
- 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.
- 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/clk.hlinux/component.hlinux/platform_device.hlinux/pm_runtime.hdrm/drm_print.hvc4_drv.hvc4_regs.h
Detected Declarations
function vc4_v3d_debugfs_identfunction pm_runtime_get_syncfunction vc4_v3d_pm_putfunction vc4_v3d_init_hwfunction vc4_v3d_get_bin_slotfunction bin_bo_allocfunction vc4_v3d_bin_bo_getfunction bin_bo_releasefunction vc4_v3d_bin_bo_putfunction vc4_v3d_runtime_suspendfunction vc4_v3d_runtime_resumefunction vc4_v3d_debugfs_initfunction vc4_v3d_bindfunction vc4_v3d_unbindfunction vc4_v3d_dev_probefunction vc4_v3d_dev_remove
Annotated Snippet
if (ret < 0) {
vc4->power_refcount--;
mutex_unlock(&vc4->power_lock);
return ret;
}
}
mutex_unlock(&vc4->power_lock);
return 0;
}
void
vc4_v3d_pm_put(struct vc4_dev *vc4)
{
if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4))
return;
mutex_lock(&vc4->power_lock);
if (--vc4->power_refcount == 0) {
pm_runtime_mark_last_busy(&vc4->v3d->pdev->dev);
pm_runtime_put_autosuspend(&vc4->v3d->pdev->dev);
}
mutex_unlock(&vc4->power_lock);
}
static void vc4_v3d_init_hw(struct drm_device *dev)
{
struct vc4_dev *vc4 = to_vc4_dev(dev);
/* Take all the memory that would have been reserved for user
* QPU programs, since we don't have an interface for running
* them, anyway.
*/
V3D_WRITE(V3D_VPMBASE, 0);
}
int vc4_v3d_get_bin_slot(struct vc4_dev *vc4)
{
struct drm_device *dev = &vc4->base;
unsigned long irqflags;
int slot;
uint64_t seqno = 0;
struct vc4_exec_info *exec;
if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4))
return -ENODEV;
try_again:
spin_lock_irqsave(&vc4->job_lock, irqflags);
slot = ffs(~vc4->bin_alloc_used);
if (slot != 0) {
/* Switch from ffs() bit index to a 0-based index. */
slot--;
vc4->bin_alloc_used |= BIT(slot);
spin_unlock_irqrestore(&vc4->job_lock, irqflags);
return slot;
}
/* Couldn't find an open slot. Wait for render to complete
* and try again.
*/
exec = vc4_last_render_job(vc4);
if (exec)
seqno = exec->seqno;
spin_unlock_irqrestore(&vc4->job_lock, irqflags);
if (seqno) {
int ret = vc4_wait_for_seqno(dev, seqno, ~0ull, true);
if (ret == 0)
goto try_again;
return ret;
}
return -ENOMEM;
}
/*
* bin_bo_alloc() - allocates the memory that will be used for
* tile binning.
*
* The binner has a limitation that the addresses in the tile state
* buffer that point into the tile alloc buffer or binner overflow
* memory only have 28 bits (256MB), and the top 4 on the bus for
* tile alloc references end up coming from the tile state buffer's
* address.
*
* To work around this, we allocate a single large buffer while V3D is
* in use, make sure that it has the top 4 bits constant across its
Annotation
- Immediate include surface: `linux/clk.h`, `linux/component.h`, `linux/platform_device.h`, `linux/pm_runtime.h`, `drm/drm_print.h`, `vc4_drv.h`, `vc4_regs.h`.
- Detected declarations: `function vc4_v3d_debugfs_ident`, `function pm_runtime_get_sync`, `function vc4_v3d_pm_put`, `function vc4_v3d_init_hw`, `function vc4_v3d_get_bin_slot`, `function bin_bo_alloc`, `function vc4_v3d_bin_bo_get`, `function bin_bo_release`, `function vc4_v3d_bin_bo_put`, `function vc4_v3d_runtime_suspend`.
- 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.
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.