drivers/gpu/drm/msm/msm_kms.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/msm/msm_kms.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/msm/msm_kms.c- Extension
.c- Size
- 9317 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.
- 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/aperture.hlinux/kthread.hlinux/sched/mm.huapi/linux/sched/types.hdrm/drm_drv.hdrm/drm_mode_config.hdrm/drm_vblank.hdrm/clients/drm_client_setup.hdisp/msm_disp_snapshot.hmsm_drv.hmsm_gem.hmsm_kms.hmsm_mmu.h
Detected Declarations
struct msm_vblank_workfunction msm_irqfunction msm_irq_preinstallfunction msm_irq_postinstallfunction msm_irq_installfunction msm_irq_uninstallfunction vblank_ctrl_workerfunction vblank_ctrl_queue_workfunction msm_crtc_enable_vblankfunction msm_crtc_disable_vblankfunction msm_kms_fault_handlerfunction msm_drm_kms_unregisterfunction msm_drm_kms_uninitfunction msm_drm_kms_initfunction drm_for_each_crtcfunction msm_kms_pm_preparefunction msm_kms_pm_completefunction msm_kms_shutdownfunction msm_drm_kms_post_init
Annotated Snippet
struct msm_vblank_work {
struct work_struct work;
struct drm_crtc *crtc;
bool enable;
struct msm_drm_private *priv;
};
static void vblank_ctrl_worker(struct work_struct *work)
{
struct msm_vblank_work *vbl_work = container_of(work,
struct msm_vblank_work, work);
struct msm_drm_private *priv = vbl_work->priv;
struct msm_kms *kms = priv->kms;
if (vbl_work->enable)
kms->funcs->enable_vblank(kms, vbl_work->crtc);
else
kms->funcs->disable_vblank(kms, vbl_work->crtc);
kfree(vbl_work);
}
static int vblank_ctrl_queue_work(struct msm_drm_private *priv,
struct drm_crtc *crtc, bool enable)
{
struct msm_vblank_work *vbl_work;
vbl_work = kzalloc_obj(*vbl_work, GFP_ATOMIC);
if (!vbl_work)
return -ENOMEM;
INIT_WORK(&vbl_work->work, vblank_ctrl_worker);
vbl_work->crtc = crtc;
vbl_work->enable = enable;
vbl_work->priv = priv;
queue_work(priv->kms->wq, &vbl_work->work);
return 0;
}
int msm_crtc_enable_vblank(struct drm_crtc *crtc)
{
struct drm_device *dev = crtc->dev;
struct msm_drm_private *priv = dev->dev_private;
struct msm_kms *kms = priv->kms;
if (!kms)
return -ENXIO;
drm_dbg_vbl(dev, "crtc=%u\n", crtc->base.id);
return vblank_ctrl_queue_work(priv, crtc, true);
}
void msm_crtc_disable_vblank(struct drm_crtc *crtc)
{
struct drm_device *dev = crtc->dev;
struct msm_drm_private *priv = dev->dev_private;
struct msm_kms *kms = priv->kms;
if (!kms)
return;
drm_dbg_vbl(dev, "crtc=%u\n", crtc->base.id);
vblank_ctrl_queue_work(priv, crtc, false);
}
static int msm_kms_fault_handler(void *arg, unsigned long iova, int flags, void *data)
{
struct msm_kms *kms = arg;
if (atomic_read(&kms->fault_snapshot_capture) == 0) {
msm_disp_snapshot_state(kms->dev);
atomic_inc(&kms->fault_snapshot_capture);
}
return -ENOSYS;
}
struct drm_gpuvm *msm_kms_init_vm(struct drm_device *dev, struct device *mdss_dev)
{
struct drm_gpuvm *vm;
struct msm_mmu *mmu;
struct device *mdp_dev = dev->dev;
struct msm_drm_private *priv = dev->dev_private;
struct msm_kms *kms = priv->kms;
struct device *iommu_dev;
/*
* IOMMUs can be a part of MDSS device tree binding, or the
* MDP/DPU device.
*/
if (device_iommu_mapped(mdp_dev))
Annotation
- Immediate include surface: `linux/aperture.h`, `linux/kthread.h`, `linux/sched/mm.h`, `uapi/linux/sched/types.h`, `drm/drm_drv.h`, `drm/drm_mode_config.h`, `drm/drm_vblank.h`, `drm/clients/drm_client_setup.h`.
- Detected declarations: `struct msm_vblank_work`, `function msm_irq`, `function msm_irq_preinstall`, `function msm_irq_postinstall`, `function msm_irq_install`, `function msm_irq_uninstall`, `function vblank_ctrl_worker`, `function vblank_ctrl_queue_work`, `function msm_crtc_enable_vblank`, `function msm_crtc_disable_vblank`.
- 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.