Lines Matching +full:motherboard +full:- +full:bus
1 // SPDX-License-Identifier: GPL-2.0
3 * mmconfig-shared.c - Low-level direct PCI config space access via
4 * MMCONFIG - common code between i386 and x86-64.
7 * - known chipset handling
8 * - ACPI decoding and validation
10 * Per-architecture code takes care of the mappings and accesses
39 if (cfg->res.parent) in pci_mmconfig_remove()
40 release_resource(&cfg->res); in pci_mmconfig_remove()
41 list_del(&cfg->list); in pci_mmconfig_remove()
58 /* keep list sorted by segment and starting bus number */ in list_add_sorted()
60 if (cfg->segment > new->segment || in list_add_sorted()
61 (cfg->segment == new->segment && in list_add_sorted()
62 cfg->start_bus >= new->start_bus)) { in list_add_sorted()
63 list_add_tail_rcu(&new->list, &cfg->list); in list_add_sorted()
67 list_add_tail_rcu(&new->list, &pci_mmcfg_list); in list_add_sorted()
83 new->address = addr; in pci_mmconfig_alloc()
84 new->segment = segment; in pci_mmconfig_alloc()
85 new->start_bus = start; in pci_mmconfig_alloc()
86 new->end_bus = end; in pci_mmconfig_alloc()
88 res = &new->res; in pci_mmconfig_alloc()
89 res->start = addr + PCI_MMCFG_BUS_OFFSET(start); in pci_mmconfig_alloc()
90 res->end = addr + PCI_MMCFG_BUS_OFFSET(end + 1) - 1; in pci_mmconfig_alloc()
91 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; in pci_mmconfig_alloc()
92 snprintf(new->name, PCI_MMCFG_RESOURCE_NAME_LEN, in pci_mmconfig_alloc()
93 "PCI MMCONFIG %04x [bus %02x-%02x]", segment, start, end); in pci_mmconfig_alloc()
94 res->name = new->name; in pci_mmconfig_alloc()
111 "MMCONFIG for domain %04x [bus %02x-%02x] at %pR " in pci_mmconfig_add()
113 segment, start, end, &new->res, (unsigned long)addr); in pci_mmconfig_add()
119 struct pci_mmcfg_region *pci_mmconfig_lookup(int segment, int bus) in pci_mmconfig_lookup() argument
124 if (cfg->segment == segment && in pci_mmconfig_lookup()
125 cfg->start_bus <= bus && bus <= cfg->end_bus) in pci_mmconfig_lookup()
134 raw_pci_ops->read(0, 0, PCI_DEVFN(0, 0), 0xce, 2, &win); in pci_mmcfg_e7520()
150 raw_pci_ops->read(0, 0, PCI_DEVFN(0, 0), 0x48, 4, &pciexbar); in pci_mmcfg_intel_945()
184 if (pci_mmconfig_add(0, 0, (len >> 20) - 1, pciexbar & mask) == NULL) in pci_mmcfg_intel_945()
218 * only handle bus 0 ? in pci_mmcfg_amd_fam10h()
225 segnbits = busnbits - 8; in pci_mmcfg_amd_fam10h()
229 end_bus = (1 << busnbits) - 1; in pci_mmcfg_amd_fam10h()
243 int bus; in pci_mmcfg_nvidia_mcp55() local
268 for (bus = 0; bus < 256; bus++) { in pci_mmcfg_nvidia_mcp55()
274 raw_pci_ops->read(0, bus, PCI_DEVFN(0, 0), 0, 4, &l); in pci_mmcfg_nvidia_mcp55()
281 raw_pci_ops->read(0, bus, PCI_DEVFN(0, 0), extcfg_regnum, in pci_mmcfg_nvidia_mcp55()
292 end = start + extcfg_sizebus[size_index] - 1; in pci_mmcfg_nvidia_mcp55()
305 u32 bus; member
331 if (cfg->end_bus < cfg->start_bus) in pci_mmcfg_check_end_bus_number()
332 cfg->end_bus = 255; in pci_mmcfg_check_end_bus_number()
335 if (cfg->list.next == &pci_mmcfg_list) in pci_mmcfg_check_end_bus_number()
338 cfgx = list_entry(cfg->list.next, typeof(*cfg), list); in pci_mmcfg_check_end_bus_number()
339 if (cfg->end_bus >= cfgx->start_bus) in pci_mmcfg_check_end_bus_number()
340 cfg->end_bus = cfgx->start_bus - 1; in pci_mmcfg_check_end_bus_number()
347 u32 bus, devfn; in pci_mmcfg_check_hostbridge() local
358 bus = pci_mmcfg_probes[i].bus; in pci_mmcfg_check_hostbridge()
360 raw_pci_ops->read(0, bus, devfn, 0, 4, &l); in pci_mmcfg_check_hostbridge()
385 if (res->type == ACPI_RESOURCE_TYPE_FIXED_MEMORY32) { in check_mcfg_resource()
387 &res->data.fixed_memory32; in check_mcfg_resource()
390 if ((mcfg_res->start >= fixmem32->address) && in check_mcfg_resource()
391 (mcfg_res->end < (fixmem32->address + in check_mcfg_resource()
392 fixmem32->address_length))) { in check_mcfg_resource()
393 mcfg_res->flags = 1; in check_mcfg_resource()
397 if ((res->type != ACPI_RESOURCE_TYPE_ADDRESS32) && in check_mcfg_resource()
398 (res->type != ACPI_RESOURCE_TYPE_ADDRESS64)) in check_mcfg_resource()
407 if ((mcfg_res->start >= address.address.minimum) && in check_mcfg_resource()
408 (mcfg_res->end < (address.address.minimum + address.address.address_length))) { in check_mcfg_resource()
409 mcfg_res->flags = 1; in check_mcfg_resource()
423 if (mcfg_res->flags) in find_mboard_resource()
434 mcfg_res.end = end - 1; in is_acpi_reserved()
453 if (md->type == EFI_MEMORY_MAPPED_IO) { in is_efi_mmio()
454 size = md->num_pages << EFI_PAGE_SHIFT; in is_efi_mmio()
455 mmio_start = md->phys_addr; in is_efi_mmio()
478 u64 addr = cfg->res.start; in is_mmconf_reserved()
479 u64 size = resource_size(&cfg->res); in is_mmconf_reserved()
494 &cfg->res, method); in is_mmconf_reserved()
497 &cfg->res, method); in is_mmconf_reserved()
501 cfg->end_bus = cfg->start_bus + ((size>>20) - 1); in is_mmconf_reserved()
502 num_buses = cfg->end_bus - cfg->start_bus + 1; in is_mmconf_reserved()
503 cfg->res.end = cfg->res.start + in is_mmconf_reserved()
504 PCI_MMCFG_BUS_OFFSET(num_buses) - 1; in is_mmconf_reserved()
505 snprintf(cfg->name, PCI_MMCFG_RESOURCE_NAME_LEN, in is_mmconf_reserved()
506 "PCI MMCONFIG %04x [bus %02x-%02x]", in is_mmconf_reserved()
507 cfg->segment, cfg->start_bus, cfg->end_bus); in is_mmconf_reserved()
513 &cfg->res, (unsigned long) cfg->address); in is_mmconf_reserved()
516 "MMCONFIG for %04x [bus%02x-%02x] " in is_mmconf_reserved()
518 cfg->segment, cfg->start_bus, cfg->end_bus, in is_mmconf_reserved()
519 &cfg->res, (unsigned long) cfg->address); in is_mmconf_reserved()
559 "ACPI motherboard resource")) in pci_mmcfg_check_reserved()
565 "ACPI motherboard resources\n", in pci_mmcfg_check_reserved()
566 &cfg->res); in pci_mmcfg_check_reserved()
570 "ACPI motherboard resources\n", in pci_mmcfg_check_reserved()
571 &cfg->res); in pci_mmcfg_check_reserved()
576 &cfg->res); in pci_mmcfg_check_reserved()
579 &cfg->res, conflict->name, conflict); in pci_mmcfg_check_reserved()
581 pr_info("MMCONFIG %pR reserved to work around lack of ACPI motherboard _CRS\n", in pci_mmcfg_check_reserved()
582 &cfg->res); in pci_mmcfg_check_reserved()
612 if (cfg->address < 0xFFFFFFFF) in acpi_mcfg_check_entry()
615 if (!strncmp(mcfg->header.oem_id, "SGI", 3)) in acpi_mcfg_check_entry()
618 if ((mcfg->header.revision >= 1) && (dmi_get_bios_year() >= 2010)) in acpi_mcfg_check_entry()
621 pr_err(PREFIX "MCFG region for %04x [bus %02x-%02x] at %#llx " in acpi_mcfg_check_entry()
622 "is above 4GB, ignored\n", cfg->pci_segment, in acpi_mcfg_check_entry()
623 cfg->start_bus_number, cfg->end_bus_number, cfg->address); in acpi_mcfg_check_entry()
624 return -EINVAL; in acpi_mcfg_check_entry()
635 return -EINVAL; in pci_parse_mcfg()
642 i = header->length - sizeof(struct acpi_table_mcfg); in pci_parse_mcfg()
645 i -= sizeof(struct acpi_mcfg_allocation); in pci_parse_mcfg()
649 return -ENODEV; in pci_parse_mcfg()
657 return -ENODEV; in pci_parse_mcfg()
660 if (pci_mmconfig_add(cfg->pci_segment, cfg->start_bus_number, in pci_parse_mcfg()
661 cfg->end_bus_number, cfg->address) == NULL) { in pci_parse_mcfg()
664 return -ENOMEM; in pci_parse_mcfg()
685 rc = func(cfg->res.start, resource_size(&cfg->res), data); in pci_mmcfg_for_each_region()
707 if (cfg->segment) in __pci_mmcfg_init()
709 pcibios_last_bus = cfg->end_bus; in __pci_mmcfg_init()
768 if (!cfg->res.parent) in pci_mmcfg_late_insert_resources()
769 insert_resource(&iomem_resource, &cfg->res); in pci_mmcfg_late_insert_resources()
790 return -ENODEV; in pci_mmconfig_insert()
793 return -EINVAL; in pci_mmconfig_insert()
798 if (cfg->end_bus < end) in pci_mmconfig_insert()
801 "domain %04x [bus %02x-%02x] " in pci_mmconfig_insert()
803 cfg->segment, cfg->start_bus, cfg->end_bus); in pci_mmconfig_insert()
805 return -EEXIST; in pci_mmconfig_insert()
810 return -EINVAL; in pci_mmconfig_insert()
813 rc = -EBUSY; in pci_mmconfig_insert()
817 rc = -ENOMEM; in pci_mmconfig_insert()
820 &cfg->res); in pci_mmconfig_insert()
825 &cfg->res); in pci_mmconfig_insert()
831 &cfg->res, tmp->name, tmp); in pci_mmconfig_insert()
834 &cfg->res); in pci_mmconfig_insert()
838 &cfg->res, (unsigned long)addr); in pci_mmconfig_insert()
845 if (cfg->res.parent) in pci_mmconfig_insert()
846 release_resource(&cfg->res); in pci_mmconfig_insert()
862 if (cfg->segment == seg && cfg->start_bus == start && in pci_mmconfig_delete()
863 cfg->end_bus == end) { in pci_mmconfig_delete()
864 list_del_rcu(&cfg->list); in pci_mmconfig_delete()
867 if (cfg->res.parent) in pci_mmconfig_delete()
868 release_resource(&cfg->res); in pci_mmconfig_delete()
875 return -ENOENT; in pci_mmconfig_delete()