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.

Dependency Surface

Detected Declarations

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

Implementation Notes