arch/loongarch/pci/acpi.c

Source file repositories/reference/linux-study-clean/arch/loongarch/pci/acpi.c

File Facts

System
Linux kernel
Corpus path
arch/loongarch/pci/acpi.c
Extension
.c
Size
6472 bytes
Lines
263
Domain
Architecture Layer
Bucket
arch/loongarch
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

struct pci_root_info {
	struct acpi_pci_root_info common;
	struct pci_config_window *cfg;
};

void pcibios_add_bus(struct pci_bus *bus)
{
	acpi_pci_add_bus(bus);
}

int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
{
	struct acpi_device *adev = NULL;
	struct device *bus_dev = &bridge->bus->dev;
	struct pci_config_window *cfg = bridge->bus->sysdata;

	if (!acpi_disabled)
		adev = to_acpi_device(cfg->parent);

	ACPI_COMPANION_SET(&bridge->dev, adev);
	set_dev_node(bus_dev, pa_to_nid(cfg->res.start));

	return 0;
}

int acpi_pci_bus_find_domain_nr(struct pci_bus *bus)
{
	struct pci_config_window *cfg = bus->sysdata;
	struct acpi_device *adev = to_acpi_device(cfg->parent);
	struct acpi_pci_root *root = acpi_driver_data(adev);

	return root->segment;
}

static void acpi_release_root_info(struct acpi_pci_root_info *ci)
{
	struct pci_root_info *info;

	info = container_of(ci, struct pci_root_info, common);
	pci_ecam_free(info->cfg);
	kfree(ci->ops);
	kfree(info);
}

static int acpi_prepare_root_resources(struct acpi_pci_root_info *ci)
{
	int status;
	unsigned long long pci_h = 0;
	struct resource_entry *entry, *tmp;
	struct acpi_device *device = ci->bridge;

	status = acpi_pci_probe_root_resources(ci);
	if (status > 0) {
		acpi_evaluate_integer(device->handle, "PCIH", NULL, &pci_h);
		if (pci_h)
			return status;

		resource_list_for_each_entry_safe(entry, tmp, &ci->resources) {
			if (entry->res->flags & IORESOURCE_MEM) {
				entry->offset = ci->root->mcfg_addr & GENMASK_ULL(63, 40);
				entry->res->start |= entry->offset;
				entry->res->end   |= entry->offset;
			}
		}
		return status;
	}

	resource_list_for_each_entry_safe(entry, tmp, &ci->resources) {
		dev_dbg(&device->dev,
			   "host bridge window %pR (ignored)\n", entry->res);
		resource_list_destroy_entry(entry);
	}

	return 0;
}

/*
 * Create a PCI config space window
 *  - reserve mem region
 *  - alloc struct pci_config_window with space for all mappings
 *  - ioremap the config space
 */
static struct pci_config_window *arch_pci_ecam_create(struct device *dev,
		struct resource *cfgres, struct resource *busr, const struct pci_ecam_ops *ops)
{
	int bsz, bus_range, err;
	struct resource *conflict;
	struct pci_config_window *cfg;

	if (busr->start > busr->end)

Annotation

Implementation Notes