drivers/gpu/drm/qxl/qxl_drv.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/qxl/qxl_drv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/qxl/qxl_drv.c- Extension
.c- Size
- 8226 bytes
- Lines
- 318
- Domain
- Driver Families
- Bucket
- drivers/gpu
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
qxl_drv.hlinux/aperture.hlinux/module.hlinux/pci.hlinux/vgaarb.hdrm/clients/drm_client_setup.hdrm/drm.hdrm/drm_atomic_helper.hdrm/drm_drv.hdrm/drm_fbdev_ttm.hdrm/drm_file.hdrm/drm_gem_ttm_helper.hdrm/drm_module.hdrm/drm_modeset_helper.hdrm/drm_prime.hdrm/drm_print.hdrm/drm_probe_helper.hqxl_object.h
Detected Declarations
function qxl_pci_probefunction qxl_drm_releasefunction qxl_pci_removefunction qxl_pci_shutdownfunction qxl_drm_freezefunction qxl_drm_resumefunction qxl_pm_suspendfunction qxl_pm_resumefunction qxl_pm_thawfunction qxl_pm_freezefunction qxl_pm_restore
Annotated Snippet
static struct pci_driver qxl_pci_driver;
static int
qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
struct qxl_device *qdev;
int ret;
if (pdev->revision < 4) {
DRM_ERROR("qxl too old, doesn't support client_monitors_config,"
" use xf86-video-qxl in user mode");
return -EINVAL; /* TODO: ENODEV ? */
}
qdev = devm_drm_dev_alloc(&pdev->dev, &qxl_driver,
struct qxl_device, ddev);
if (IS_ERR(qdev)) {
pr_err("Unable to init drm dev");
return -ENOMEM;
}
ret = pci_enable_device(pdev);
if (ret)
return ret;
ret = aperture_remove_conflicting_pci_devices(pdev, qxl_driver.name);
if (ret)
goto disable_pci;
if (pci_is_vga(pdev) && pdev->revision < 5) {
ret = vga_get_interruptible(pdev, VGA_RSRC_LEGACY_IO);
if (ret) {
DRM_ERROR("can't get legacy vga ioports\n");
goto disable_pci;
}
}
ret = qxl_device_init(qdev, pdev);
if (ret)
goto put_vga;
ret = qxl_modeset_init(qdev);
if (ret)
goto unload;
drm_kms_helper_poll_init(&qdev->ddev);
/* Complete initialization. */
ret = drm_dev_register(&qdev->ddev, ent->driver_data);
if (ret)
goto poll_fini;
drm_client_setup(&qdev->ddev, NULL);
return 0;
poll_fini:
drm_kms_helper_poll_fini(&qdev->ddev);
qxl_modeset_fini(qdev);
unload:
qxl_device_fini(qdev);
put_vga:
if (pci_is_vga(pdev) && pdev->revision < 5)
vga_put(pdev, VGA_RSRC_LEGACY_IO);
disable_pci:
pci_disable_device(pdev);
return ret;
}
static void qxl_drm_release(struct drm_device *dev)
{
struct qxl_device *qdev = to_qxl(dev);
/*
* TODO: qxl_device_fini() call should be in qxl_pci_remove(),
* reordering qxl_modeset_fini() + qxl_device_fini() calls is
* non-trivial though.
*/
qxl_modeset_fini(qdev);
qxl_device_fini(qdev);
}
static void
qxl_pci_remove(struct pci_dev *pdev)
{
struct drm_device *dev = pci_get_drvdata(pdev);
drm_kms_helper_poll_fini(dev);
drm_dev_unregister(dev);
drm_atomic_helper_shutdown(dev);
Annotation
- Immediate include surface: `qxl_drv.h`, `linux/aperture.h`, `linux/module.h`, `linux/pci.h`, `linux/vgaarb.h`, `drm/clients/drm_client_setup.h`, `drm/drm.h`, `drm/drm_atomic_helper.h`.
- Detected declarations: `function qxl_pci_probe`, `function qxl_drm_release`, `function qxl_pci_remove`, `function qxl_pci_shutdown`, `function qxl_drm_freeze`, `function qxl_drm_resume`, `function qxl_pm_suspend`, `function qxl_pm_resume`, `function qxl_pm_thaw`, `function qxl_pm_freeze`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: pattern 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.