drivers/gpu/drm/radeon/radeon_kms.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/radeon/radeon_kms.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/radeon/radeon_kms.c- Extension
.c- Size
- 24440 bytes
- Lines
- 864
- 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 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.
- 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/pci.hlinux/pm_runtime.hlinux/slab.hlinux/uaccess.hlinux/vga_switcheroo.hdrm/drm_file.hdrm/drm_ioctl.hdrm/radeon_drm.hradeon.hradeon_asic.hradeon_drv.hradeon_kms.h
Detected Declarations
function radeon_has_atpxfunction KMSfunction KMSfunction devicefunction radeon_info_ioctlfunction radeon_driver_open_kmsfunction radeon_driver_postclose_kmsfunction crtcfunction crtcfunction crtc
Annotated Snippet
static inline bool radeon_has_atpx(void) { return false; }
#endif
/**
* radeon_driver_unload_kms - Main unload function for KMS.
*
* @dev: drm dev pointer
*
* This is the main unload function for KMS (all asics).
* It calls radeon_modeset_fini() to tear down the
* displays, and radeon_device_fini() to tear down
* the rest of the device (CP, writeback, etc.).
* Returns 0 on success.
*/
void radeon_driver_unload_kms(struct drm_device *dev)
{
struct radeon_device *rdev = dev->dev_private;
if (rdev == NULL)
return;
if (rdev->rmmio == NULL)
goto done_free;
if (radeon_is_px(dev)) {
pm_runtime_get_sync(dev->dev);
pm_runtime_forbid(dev->dev);
}
radeon_acpi_fini(rdev);
radeon_modeset_fini(rdev);
radeon_device_fini(rdev);
if (rdev->agp)
arch_phys_wc_del(rdev->agp->agp_mtrr);
kfree(rdev->agp);
rdev->agp = NULL;
done_free:
dev->dev_private = NULL;
}
/**
* radeon_driver_load_kms - Main load function for KMS.
*
* @dev: drm dev pointer
* @flags: device flags
*
* This is the main load function for KMS (all asics).
* It calls radeon_device_init() to set up the non-display
* parts of the chip (asic init, CP, writeback, etc.), and
* radeon_modeset_init() to set up the display parts
* (crtcs, encoders, hotplug detect, etc.).
* Returns 0 on success, error on failure.
*/
int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags)
{
struct pci_dev *pdev = to_pci_dev(dev->dev);
struct radeon_device *rdev = dev->dev_private;
int r, acpi_status;
#ifdef __alpha__
rdev->hose = pdev->sysdata;
#endif
if (pci_find_capability(pdev, PCI_CAP_ID_AGP))
rdev->agp = radeon_agp_head_init(dev);
if (rdev->agp) {
rdev->agp->agp_mtrr = arch_phys_wc_add(
rdev->agp->agp_info.aper_base,
rdev->agp->agp_info.aper_size *
1024 * 1024);
}
/* update BUS flag */
if (pci_find_capability(pdev, PCI_CAP_ID_AGP)) {
flags |= RADEON_IS_AGP;
} else if (pci_is_pcie(pdev)) {
flags |= RADEON_IS_PCIE;
} else {
flags |= RADEON_IS_PCI;
}
if ((radeon_runtime_pm != 0) &&
radeon_has_atpx() &&
((flags & RADEON_IS_IGP) == 0) &&
!pci_is_thunderbolt_attached(pdev))
flags |= RADEON_IS_PX;
Annotation
- Immediate include surface: `linux/pci.h`, `linux/pm_runtime.h`, `linux/slab.h`, `linux/uaccess.h`, `linux/vga_switcheroo.h`, `drm/drm_file.h`, `drm/drm_ioctl.h`, `drm/radeon_drm.h`.
- Detected declarations: `function radeon_has_atpx`, `function KMS`, `function KMS`, `function device`, `function radeon_info_ioctl`, `function radeon_driver_open_kms`, `function radeon_driver_postclose_kms`, `function crtc`, `function crtc`, `function crtc`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source 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.
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.