drivers/video/fbdev/pxa3xx-gcu.c
Source file repositories/reference/linux-study-clean/drivers/video/fbdev/pxa3xx-gcu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/fbdev/pxa3xx-gcu.c- Extension
.c- Size
- 16705 bytes
- Lines
- 715
- Domain
- Driver Families
- Bucket
- drivers/video
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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.
- 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/module.hlinux/platform_device.hlinux/dma-mapping.hlinux/miscdevice.hlinux/interrupt.hlinux/spinlock.hlinux/uaccess.hlinux/ioctl.hlinux/delay.hlinux/sched.hlinux/slab.hlinux/clk.hlinux/fs.hlinux/io.hlinux/of.hpxa3xx-gcu.h
Detected Declarations
struct pxa3xx_gcu_batchstruct pxa3xx_gcu_privfunction gc_readlfunction gc_writelfunction pxa3xx_gcu_resetfunction dump_whole_statefunction flush_runningfunction run_readyfunction pxa3xx_gcu_handle_irqfunction pxa3xx_gcu_wait_idlefunction pxa3xx_gcu_wait_freefunction pxa3xx_gcu_openfunction pxa3xx_gcu_writefunction pxa3xx_gcu_ioctlfunction pxa3xx_gcu_mmapfunction pxa3xx_gcu_debug_timedoutfunction pxa3xx_gcu_init_debug_timerfunction pxa3xx_gcu_init_debug_timerfunction pxa3xx_gcu_free_buffersfunction pxa3xx_gcu_probefunction pxa3xx_gcu_remove
Annotated Snippet
static const struct file_operations pxa3xx_gcu_miscdev_fops = {
.owner = THIS_MODULE,
.open = pxa3xx_gcu_open,
.write = pxa3xx_gcu_write,
.unlocked_ioctl = pxa3xx_gcu_ioctl,
.mmap = pxa3xx_gcu_mmap,
};
static int pxa3xx_gcu_probe(struct platform_device *pdev)
{
int i, ret, irq;
struct resource *r;
struct pxa3xx_gcu_priv *priv;
struct device *dev = &pdev->dev;
priv = devm_kzalloc(dev, sizeof(struct pxa3xx_gcu_priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
init_waitqueue_head(&priv->wait_idle);
init_waitqueue_head(&priv->wait_free);
spin_lock_init(&priv->spinlock);
/* we allocate the misc device structure as part of our own allocation,
* so we can get a pointer to our priv structure later on with
* container_of(). This isn't really necessary as we have a fixed minor
* number anyway, but this is to avoid statics. */
priv->misc_dev.minor = PXA3XX_GCU_MINOR;
priv->misc_dev.name = DRV_NAME;
priv->misc_dev.fops = &pxa3xx_gcu_miscdev_fops;
/* handle IO resources */
priv->mmio_base = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
if (IS_ERR(priv->mmio_base))
return PTR_ERR(priv->mmio_base);
/* enable the clock */
priv->clk = devm_clk_get(dev, NULL);
if (IS_ERR(priv->clk))
return dev_err_probe(dev, PTR_ERR(priv->clk), "failed to get clock\n");
/* request the IRQ */
irq = platform_get_irq(pdev, 0);
if (irq < 0)
return irq;
ret = devm_request_irq(dev, irq, pxa3xx_gcu_handle_irq,
0, DRV_NAME, priv);
if (ret < 0) {
dev_err(dev, "request_irq failed\n");
return ret;
}
/* allocate dma memory */
priv->shared = dma_alloc_coherent(dev, SHARED_SIZE,
&priv->shared_phys, GFP_KERNEL);
if (!priv->shared) {
dev_err(dev, "failed to allocate DMA memory\n");
return -ENOMEM;
}
/* register misc device */
ret = misc_register(&priv->misc_dev);
if (ret < 0) {
dev_err(dev, "misc_register() for minor %d failed\n",
PXA3XX_GCU_MINOR);
goto err_free_dma;
}
ret = clk_prepare_enable(priv->clk);
if (ret < 0) {
dev_err(dev, "failed to enable clock\n");
goto err_misc_deregister;
}
for (i = 0; i < 8; i++) {
ret = pxa3xx_gcu_add_buffer(dev, priv);
if (ret) {
pxa3xx_gcu_free_buffers(dev, priv);
dev_err(dev, "failed to allocate DMA memory\n");
goto err_disable_clk;
}
}
platform_set_drvdata(pdev, priv);
priv->resource_mem = r;
priv->dev = dev;
pxa3xx_gcu_reset(priv);
pxa3xx_gcu_init_debug_timer(priv);
Annotation
- Immediate include surface: `linux/module.h`, `linux/platform_device.h`, `linux/dma-mapping.h`, `linux/miscdevice.h`, `linux/interrupt.h`, `linux/spinlock.h`, `linux/uaccess.h`, `linux/ioctl.h`.
- Detected declarations: `struct pxa3xx_gcu_batch`, `struct pxa3xx_gcu_priv`, `function gc_readl`, `function gc_writel`, `function pxa3xx_gcu_reset`, `function dump_whole_state`, `function flush_running`, `function run_ready`, `function pxa3xx_gcu_handle_irq`, `function pxa3xx_gcu_wait_idle`.
- Atlas domain: Driver Families / drivers/video.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.