drivers/gpu/drm/lima/lima_gp.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/lima/lima_gp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/lima/lima_gp.c- Extension
.c- Size
- 9430 bytes
- Lines
- 389
- 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.
- 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
linux/interrupt.hlinux/iopoll.hlinux/device.hlinux/slab.hdrm/lima_drm.hlima_device.hlima_gp.hlima_regs.hlima_gem.hlima_vm.h
Detected Declarations
function lima_gp_irq_handlerfunction lima_gp_soft_reset_asyncfunction lima_gp_soft_reset_async_waitfunction lima_gp_task_validatefunction lima_gp_task_runfunction lima_gp_bus_stop_pollfunction lima_gp_hard_reset_pollfunction lima_gp_hard_resetfunction lima_gp_task_finifunction lima_gp_task_errorfunction lima_gp_task_mmu_errorfunction lima_gp_task_mask_irqfunction lima_gp_task_recoverfunction lima_gp_print_versionfunction lima_gp_hw_initfunction lima_gp_resumefunction lima_gp_suspendfunction lima_gp_finifunction lima_gp_pipe_initfunction lima_gp_pipe_fini
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0 OR MIT
/* Copyright 2017-2019 Qiang Yu <yuq825@gmail.com> */
#include <linux/interrupt.h>
#include <linux/iopoll.h>
#include <linux/device.h>
#include <linux/slab.h>
#include <drm/lima_drm.h>
#include "lima_device.h"
#include "lima_gp.h"
#include "lima_regs.h"
#include "lima_gem.h"
#include "lima_vm.h"
#define gp_write(reg, data) writel(data, ip->iomem + reg)
#define gp_read(reg) readl(ip->iomem + reg)
static irqreturn_t lima_gp_irq_handler(int irq, void *data)
{
struct lima_ip *ip = data;
struct lima_device *dev = ip->dev;
struct lima_sched_pipe *pipe = dev->pipe + lima_pipe_gp;
struct lima_sched_task *task = pipe->current_task;
u32 state = gp_read(LIMA_GP_INT_STAT);
u32 status = gp_read(LIMA_GP_STATUS);
bool done = false;
/* for shared irq case */
if (!state)
return IRQ_NONE;
if (state & LIMA_GP_IRQ_MASK_ERROR) {
if ((state & LIMA_GP_IRQ_MASK_ERROR) ==
LIMA_GP_IRQ_PLBU_OUT_OF_MEM) {
dev_dbg(dev->dev, "%s out of heap irq status=%x\n",
lima_ip_name(ip), status);
} else {
dev_err(dev->dev, "%s error irq state=%x status=%x\n",
lima_ip_name(ip), state, status);
if (task)
task->recoverable = false;
}
/* mask all interrupts before hard reset */
gp_write(LIMA_GP_INT_MASK, 0);
pipe->error = true;
done = true;
} else {
bool valid = state & (LIMA_GP_IRQ_VS_END_CMD_LST |
LIMA_GP_IRQ_PLBU_END_CMD_LST);
bool active = status & (LIMA_GP_STATUS_VS_ACTIVE |
LIMA_GP_STATUS_PLBU_ACTIVE);
done = valid && !active;
pipe->error = false;
}
gp_write(LIMA_GP_INT_CLEAR, state);
if (done)
lima_sched_pipe_task_done(pipe);
return IRQ_HANDLED;
}
static void lima_gp_soft_reset_async(struct lima_ip *ip)
{
if (ip->data.async_reset)
return;
gp_write(LIMA_GP_INT_MASK, 0);
gp_write(LIMA_GP_INT_CLEAR, LIMA_GP_IRQ_RESET_COMPLETED);
gp_write(LIMA_GP_CMD, LIMA_GP_CMD_SOFT_RESET);
ip->data.async_reset = true;
}
static int lima_gp_soft_reset_async_wait(struct lima_ip *ip)
{
struct lima_device *dev = ip->dev;
int err;
u32 v;
if (!ip->data.async_reset)
return 0;
err = readl_poll_timeout(ip->iomem + LIMA_GP_INT_RAWSTAT, v,
v & LIMA_GP_IRQ_RESET_COMPLETED,
0, 100);
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/iopoll.h`, `linux/device.h`, `linux/slab.h`, `drm/lima_drm.h`, `lima_device.h`, `lima_gp.h`, `lima_regs.h`.
- Detected declarations: `function lima_gp_irq_handler`, `function lima_gp_soft_reset_async`, `function lima_gp_soft_reset_async_wait`, `function lima_gp_task_validate`, `function lima_gp_task_run`, `function lima_gp_bus_stop_poll`, `function lima_gp_hard_reset_poll`, `function lima_gp_hard_reset`, `function lima_gp_task_fini`, `function lima_gp_task_error`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- 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.