drivers/gpu/drm/xe/xe_pci_rebar.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_pci_rebar.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/xe/xe_pci_rebar.c
Extension
.c
Size
3010 bytes
Lines
107
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

if (!pci_rebar_size_supported(pdev, LMEM_BAR, rebar_size)) {
			xe_info(xe, "Requested size %lluMiB is not supported by rebar sizes: 0x%llx. Leaving default: %lluMiB\n",
				(u64)pci_rebar_size_to_bytes(rebar_size) >> ilog2(SZ_1M),
				pci_rebar_get_possible_sizes(pdev, LMEM_BAR),
				(u64)current_size >> ilog2(SZ_1M));
			return;
		}

		rebar_size = pci_rebar_size_to_bytes(rebar_size);
		if (rebar_size == current_size)
			return;
	} else {
		max_size = pci_rebar_get_max_size(pdev, LMEM_BAR);
		if (max_size < 0)
			return;
		rebar_size = pci_rebar_size_to_bytes(max_size);

		/* only resize if larger than current */
		if (rebar_size <= current_size)
			return;
	}

	xe_info(xe, "Attempting to resize bar from %lluMiB -> %lluMiB\n",
		(u64)current_size >> ilog2(SZ_1M), (u64)rebar_size >> ilog2(SZ_1M));

	while (root->parent)
		root = root->parent;

	pci_bus_for_each_resource(root, root_res, i) {
		if (root_res && root_res->flags & (IORESOURCE_MEM | IORESOURCE_MEM_64) &&
		    (u64)root_res->start > 0x100000000ul)
			break;
	}

	if (!root_res) {
		xe_info(xe, "Can't resize VRAM BAR - platform support is missing. Consider enabling 'Resizable BAR' support in your BIOS\n");
		return;
	}

	pci_read_config_dword(pdev, PCI_COMMAND, &pci_cmd);
	pci_write_config_dword(pdev, PCI_COMMAND, pci_cmd & ~PCI_COMMAND_MEMORY);

	resize_bar(xe, LMEM_BAR, rebar_size);

	pci_assign_unassigned_bus_resources(pdev->bus);
	pci_write_config_dword(pdev, PCI_COMMAND, pci_cmd);
}

Annotation

Implementation Notes