2 * PCIEHPRM ACPI: PHP Resource Manager for ACPI platform
4 * Copyright (C) 2003-2004 Intel Corporation
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or (at
11 * your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
16 * NON INFRINGEMENT. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * Send feedback to <dely.l.sy@intel.com>
27 #include <linux/config.h>
28 #include <linux/module.h>
29 #include <linux/kernel.h>
30 #include <linux/types.h>
31 #include <linux/pci.h>
32 #include <linux/init.h>
33 #include <linux/acpi.h>
34 #include <linux/efi.h>
35 #include <asm/uaccess.h>
36 #include <asm/system.h>
38 #include <asm/iosapic.h>
40 #include <acpi/acpi.h>
41 #include <acpi/acpi_bus.h>
42 #include <acpi/actypes.h>
46 #define PCI_MAX_BUS 0x100
47 #define ACPI_STA_DEVICE_PRESENT 0x01
49 #define METHOD_NAME__SUN "_SUN"
50 #define METHOD_NAME__HPP "_HPP"
51 #define METHOD_NAME_OSHP "OSHP"
53 #define PHP_RES_BUS 0xA0
54 #define PHP_RES_IO 0xA1
55 #define PHP_RES_MEM 0xA2
56 #define PHP_RES_PMEM 0xA3
58 #define BRIDGE_TYPE_P2P 0x00
59 #define BRIDGE_TYPE_HOST 0x01
61 /* this should go to drivers/acpi/include/ */
69 struct acpi_php_slot {
70 struct acpi_php_slot *next;
71 struct acpi_bridge *bridge;
78 struct pci_resource *mem_head;
79 struct pci_resource *p_mem_head;
80 struct pci_resource *io_head;
81 struct pci_resource *bus_head;
82 void *slot_ops; /* _STA, _EJx, etc */
87 struct acpi_bridge *parent;
88 struct acpi_bridge *next;
89 struct acpi_bridge *child;
92 int pbus; /* pdev->bus->number */
93 int pdevice; /* PCI_SLOT(pdev->devfn) */
94 int pfunction; /* PCI_DEVFN(pdev->devfn) */
95 int bus; /* pdev->subordinate->number */
96 struct acpi__hpp *_hpp;
97 struct acpi_php_slot *slots;
98 struct pci_resource *tmem_head; /* total from crs */
99 struct pci_resource *tp_mem_head; /* total from crs */
100 struct pci_resource *tio_head; /* total from crs */
101 struct pci_resource *tbus_head; /* total from crs */
102 struct pci_resource *mem_head; /* available */
103 struct pci_resource *p_mem_head; /* available */
104 struct pci_resource *io_head; /* available */
105 struct pci_resource *bus_head; /* available */
110 static struct acpi_bridge *acpi_bridges_head;
112 static u8 * acpi_path_name( acpi_handle handle)
115 static u8 path_name[ACPI_PATHNAME_MAX];
116 struct acpi_buffer ret_buf = { ACPI_PATHNAME_MAX, path_name };
118 memset(path_name, 0, sizeof (path_name));
119 status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &ret_buf);
121 if (ACPI_FAILURE(status))
127 static void acpi_get__hpp ( struct acpi_bridge *ab);
128 static void acpi_run_oshp ( struct acpi_bridge *ab);
130 static int acpi_add_slot_to_php_slots(
131 struct acpi_bridge *ab,
138 struct acpi_php_slot *aps;
139 static long samesun = -1;
141 aps = (struct acpi_php_slot *) kmalloc (sizeof(struct acpi_php_slot), GFP_KERNEL);
143 err ("acpi_pciehprm: alloc for aps fail\n");
146 memset(aps, 0, sizeof(struct acpi_php_slot));
148 aps->handle = handle;
150 aps->dev = (adr >> 16) & 0xffff;
151 aps->fun = adr & 0xffff;
154 aps->next = ab->slots; /* cling to the bridge */
164 if (sun != samesun) {
165 info("acpi_pciehprm: Slot sun(%x) at s:b:d:f=0x%02x:%02x:%02x:%02x\n",
166 aps->sun, ab->seg, aps->bus, aps->dev, aps->fun);
172 static void acpi_get__hpp ( struct acpi_bridge *ab)
176 struct acpi_buffer ret_buf = { 0, NULL};
177 union acpi_object *ext_obj, *package;
178 u8 *path_name = acpi_path_name(ab->handle);
182 status = acpi_evaluate_object(ab->handle, METHOD_NAME__HPP, NULL, &ret_buf);
184 case AE_BUFFER_OVERFLOW:
185 ret_buf.pointer = kmalloc (ret_buf.length, GFP_KERNEL);
186 if (!ret_buf.pointer) {
187 err ("acpi_pciehprm:%s alloc for _HPP fail\n", path_name);
190 status = acpi_evaluate_object(ab->handle, METHOD_NAME__HPP, NULL, &ret_buf);
191 if (ACPI_SUCCESS(status))
194 if (ACPI_FAILURE(status)) {
195 err("acpi_pciehprm:%s _HPP fail=0x%x\n", path_name, status);
200 ext_obj = (union acpi_object *) ret_buf.pointer;
201 if (ext_obj->type != ACPI_TYPE_PACKAGE) {
202 err ("acpi_pciehprm:%s _HPP obj not a package\n", path_name);
203 goto free_and_return;
206 len = ext_obj->package.count;
207 package = (union acpi_object *) ret_buf.pointer;
208 for ( i = 0; (i < len) || (i < 4); i++) {
209 ext_obj = (union acpi_object *) &package->package.elements[i];
210 switch (ext_obj->type) {
211 case ACPI_TYPE_INTEGER:
212 nui[i] = (u8)ext_obj->integer.value;
215 err ("acpi_pciehprm:%s _HPP obj type incorrect\n", path_name);
216 goto free_and_return;
220 ab->_hpp = kmalloc (sizeof (struct acpi__hpp), GFP_KERNEL);
221 memset(ab->_hpp, 0, sizeof(struct acpi__hpp));
223 ab->_hpp->cache_line_size = nui[0];
224 ab->_hpp->latency_timer = nui[1];
225 ab->_hpp->enable_serr = nui[2];
226 ab->_hpp->enable_perr = nui[3];
228 dbg(" _HPP: cache_line_size=0x%x\n", ab->_hpp->cache_line_size);
229 dbg(" _HPP: latency timer =0x%x\n", ab->_hpp->latency_timer);
230 dbg(" _HPP: enable SERR =0x%x\n", ab->_hpp->enable_serr);
231 dbg(" _HPP: enable PERR =0x%x\n", ab->_hpp->enable_perr);
234 kfree(ret_buf.pointer);
237 static void acpi_run_oshp ( struct acpi_bridge *ab)
240 u8 *path_name = acpi_path_name(ab->handle);
241 struct acpi_buffer ret_buf = { 0, NULL};
244 status = acpi_evaluate_object(ab->handle, METHOD_NAME_OSHP, NULL, &ret_buf);
245 if (ACPI_FAILURE(status)) {
246 err("acpi_pciehprm:%s OSHP fails=0x%x\n", path_name, status);
248 dbg("acpi_pciehprm:%s OSHP passes =0x%x\n", path_name, status);
252 static acpi_status acpi_evaluate_crs(
254 struct acpi_resource **retbuf
258 struct acpi_buffer crsbuf;
259 u8 *path_name = acpi_path_name(handle);
262 crsbuf.pointer = NULL;
264 status = acpi_get_current_resources (handle, &crsbuf);
267 case AE_BUFFER_OVERFLOW:
270 dbg("acpi_pciehprm:%s _CRS not found\n", path_name);
273 err ("acpi_pciehprm:%s _CRS fail=0x%x\n", path_name, status);
277 crsbuf.pointer = kmalloc (crsbuf.length, GFP_KERNEL);
278 if (!crsbuf.pointer) {
279 err ("acpi_pciehprm: alloc %ld bytes for %s _CRS fail\n", (ulong)crsbuf.length, path_name);
283 status = acpi_get_current_resources (handle, &crsbuf);
284 if (ACPI_FAILURE(status)) {
285 err("acpi_pciehprm: %s _CRS fail=0x%x.\n", path_name, status);
286 kfree(crsbuf.pointer);
290 *retbuf = crsbuf.pointer;
295 static void free_pci_resource ( struct pci_resource *aprh)
297 struct pci_resource *res, *next;
299 for (res = aprh; res; res = next) {
305 static void print_pci_resource ( struct pci_resource *aprh)
307 struct pci_resource *res;
309 for (res = aprh; res; res = res->next)
310 dbg(" base= 0x%x length= 0x%x\n", res->base, res->length);
313 static void print_slot_resources( struct acpi_php_slot *aps)
316 dbg(" BUS Resources:\n");
317 print_pci_resource (aps->bus_head);
321 dbg(" IO Resources:\n");
322 print_pci_resource (aps->io_head);
326 dbg(" MEM Resources:\n");
327 print_pci_resource (aps->mem_head);
330 if (aps->p_mem_head) {
331 dbg(" PMEM Resources:\n");
332 print_pci_resource (aps->p_mem_head);
336 static void print_pci_resources( struct acpi_bridge *ab)
339 dbg(" Total BUS Resources:\n");
340 print_pci_resource (ab->tbus_head);
343 dbg(" BUS Resources:\n");
344 print_pci_resource (ab->bus_head);
348 dbg(" Total IO Resources:\n");
349 print_pci_resource (ab->tio_head);
352 dbg(" IO Resources:\n");
353 print_pci_resource (ab->io_head);
357 dbg(" Total MEM Resources:\n");
358 print_pci_resource (ab->tmem_head);
361 dbg(" MEM Resources:\n");
362 print_pci_resource (ab->mem_head);
365 if (ab->tp_mem_head) {
366 dbg(" Total PMEM Resources:\n");
367 print_pci_resource (ab->tp_mem_head);
369 if (ab->p_mem_head) {
370 dbg(" PMEM Resources:\n");
371 print_pci_resource (ab->p_mem_head);
374 dbg(" _HPP: cache_line_size=0x%x\n", ab->_hpp->cache_line_size);
375 dbg(" _HPP: latency timer =0x%x\n", ab->_hpp->latency_timer);
376 dbg(" _HPP: enable SERR =0x%x\n", ab->_hpp->enable_serr);
377 dbg(" _HPP: enable PERR =0x%x\n", ab->_hpp->enable_perr);
381 static int pciehprm_delete_resource(
382 struct pci_resource **aprh,
386 struct pci_resource *res;
387 struct pci_resource *prevnode;
388 struct pci_resource *split_node;
391 pciehp_resource_sort_and_combine(aprh);
393 for (res = *aprh; res; res = res->next) {
394 if (res->base > base)
397 if ((res->base + res->length) < (base + size))
400 if (res->base < base) {
403 if ((res->length - (tbase - res->base)) < size)
406 split_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
410 split_node->base = res->base;
411 split_node->length = tbase - res->base;
413 res->length -= split_node->length;
415 split_node->next = res->next;
416 res->next = split_node;
419 if (res->length >= size) {
420 split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
424 split_node->base = res->base + size;
425 split_node->length = res->length - size;
428 split_node->next = res->next;
429 res->next = split_node;
436 while (prevnode->next != res)
437 prevnode = prevnode->next;
439 prevnode->next = res->next;
449 static int pciehprm_delete_resources(
450 struct pci_resource **aprh,
451 struct pci_resource *this
454 struct pci_resource *res;
456 for (res = this; res; res = res->next)
457 pciehprm_delete_resource(aprh, res->base, res->length);
462 static int pciehprm_add_resource(
463 struct pci_resource **aprh,
467 struct pci_resource *res;
469 for (res = *aprh; res; res = res->next) {
470 if ((res->base + res->length) == base) {
475 if (res->next == *aprh)
480 res = kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
482 err ("acpi_pciehprm: alloc for res fail\n");
485 memset(res, 0, sizeof (struct pci_resource));
496 static int pciehprm_add_resources(
497 struct pci_resource **aprh,
498 struct pci_resource *this
501 struct pci_resource *res;
504 for (res = this; res && !rc; res = res->next)
505 rc = pciehprm_add_resource(aprh, res->base, res->length);
510 static void acpi_parse_io (
511 struct acpi_bridge *ab,
512 union acpi_resource_data *data
515 struct acpi_resource_io *dataio;
516 dataio = (struct acpi_resource_io *) data;
518 dbg("Io Resource\n");
519 dbg(" %d bit decode\n", ACPI_DECODE_16 == dataio->io_decode ? 16:10);
520 dbg(" Range minimum base: %08X\n", dataio->min_base_address);
521 dbg(" Range maximum base: %08X\n", dataio->max_base_address);
522 dbg(" Alignment: %08X\n", dataio->alignment);
523 dbg(" Range Length: %08X\n", dataio->range_length);
526 static void acpi_parse_fixed_io (
527 struct acpi_bridge *ab,
528 union acpi_resource_data *data
531 struct acpi_resource_fixed_io *datafio;
532 datafio = (struct acpi_resource_fixed_io *) data;
534 dbg("Fixed Io Resource\n");
535 dbg(" Range base address: %08X", datafio->base_address);
536 dbg(" Range length: %08X", datafio->range_length);
539 static void acpi_parse_address16_32 (
540 struct acpi_bridge *ab,
541 union acpi_resource_data *data,
542 acpi_resource_type id
546 * acpi_resource_address16 == acpi_resource_address32
547 * acpi_resource_address16 *data16 = (acpi_resource_address16 *) data;
549 struct acpi_resource_address32 *data32 = (struct acpi_resource_address32 *) data;
550 struct pci_resource **aprh, **tprh;
552 if (id == ACPI_RSTYPE_ADDRESS16)
553 dbg("acpi_pciehprm:16-Bit Address Space Resource\n");
555 dbg("acpi_pciehprm:32-Bit Address Space Resource\n");
557 switch (data32->resource_type) {
558 case ACPI_MEMORY_RANGE:
559 dbg(" Resource Type: Memory Range\n");
560 aprh = &ab->mem_head;
561 tprh = &ab->tmem_head;
563 switch (data32->attribute.memory.cache_attribute) {
564 case ACPI_NON_CACHEABLE_MEMORY:
565 dbg(" Type Specific: Noncacheable memory\n");
567 case ACPI_CACHABLE_MEMORY:
568 dbg(" Type Specific: Cacheable memory\n");
570 case ACPI_WRITE_COMBINING_MEMORY:
571 dbg(" Type Specific: Write-combining memory\n");
573 case ACPI_PREFETCHABLE_MEMORY:
574 aprh = &ab->p_mem_head;
575 dbg(" Type Specific: Prefetchable memory\n");
578 dbg(" Type Specific: Invalid cache attribute\n");
582 dbg(" Type Specific: Read%s\n", ACPI_READ_WRITE_MEMORY == data32->attribute.memory.read_write_attribute ? "/Write":" Only");
586 dbg(" Resource Type: I/O Range\n");
588 tprh = &ab->tio_head;
590 switch (data32->attribute.io.range_attribute) {
591 case ACPI_NON_ISA_ONLY_RANGES:
592 dbg(" Type Specific: Non-ISA Io Addresses\n");
594 case ACPI_ISA_ONLY_RANGES:
595 dbg(" Type Specific: ISA Io Addresses\n");
597 case ACPI_ENTIRE_RANGE:
598 dbg(" Type Specific: ISA and non-ISA Io Addresses\n");
601 dbg(" Type Specific: Invalid range attribute\n");
606 case ACPI_BUS_NUMBER_RANGE:
607 dbg(" Resource Type: Bus Number Range(fixed)\n");
608 /* fixup to be compatible with the rest of php driver */
609 data32->min_address_range++;
610 data32->address_length--;
611 aprh = &ab->bus_head;
612 tprh = &ab->tbus_head;
615 dbg(" Resource Type: Invalid resource type. Exiting.\n");
619 dbg(" Resource %s\n", ACPI_CONSUMER == data32->producer_consumer ? "Consumer":"Producer");
620 dbg(" %s decode\n", ACPI_SUB_DECODE == data32->decode ? "Subtractive":"Positive");
621 dbg(" Min address is %s fixed\n", ACPI_ADDRESS_FIXED == data32->min_address_fixed ? "":"not");
622 dbg(" Max address is %s fixed\n", ACPI_ADDRESS_FIXED == data32->max_address_fixed ? "":"not");
623 dbg(" Granularity: %08X\n", data32->granularity);
624 dbg(" Address range min: %08X\n", data32->min_address_range);
625 dbg(" Address range max: %08X\n", data32->max_address_range);
626 dbg(" Address translation offset: %08X\n", data32->address_translation_offset);
627 dbg(" Address Length: %08X\n", data32->address_length);
629 if (0xFF != data32->resource_source.index) {
630 dbg(" Resource Source Index: %X\n", data32->resource_source.index);
631 /* dbg(" Resource Source: %s\n", data32->resource_source.string_ptr); */
634 pciehprm_add_resource(aprh, data32->min_address_range, data32->address_length);
637 static acpi_status acpi_parse_crs(
638 struct acpi_bridge *ab,
639 struct acpi_resource *crsbuf
642 acpi_status status = AE_OK;
643 struct acpi_resource *resource = crsbuf;
648 dbg("acpi_pciehprm: PCI bus 0x%x Resource structure %x.\n", ab->bus, count++);
649 switch (resource->id) {
650 case ACPI_RSTYPE_IRQ:
651 dbg("Irq -------- Resource\n");
653 case ACPI_RSTYPE_DMA:
654 dbg("DMA -------- Resource\n");
656 case ACPI_RSTYPE_START_DPF:
657 dbg("Start DPF -------- Resource\n");
659 case ACPI_RSTYPE_END_DPF:
660 dbg("End DPF -------- Resource\n");
663 acpi_parse_io (ab, &resource->data);
665 case ACPI_RSTYPE_FIXED_IO:
666 acpi_parse_fixed_io (ab, &resource->data);
668 case ACPI_RSTYPE_VENDOR:
669 dbg("Vendor -------- Resource\n");
671 case ACPI_RSTYPE_END_TAG:
672 dbg("End_tag -------- Resource\n");
675 case ACPI_RSTYPE_MEM24:
676 dbg("Mem24 -------- Resource\n");
678 case ACPI_RSTYPE_MEM32:
679 dbg("Mem32 -------- Resource\n");
681 case ACPI_RSTYPE_FIXED_MEM32:
682 dbg("Fixed Mem32 -------- Resource\n");
684 case ACPI_RSTYPE_ADDRESS16:
685 acpi_parse_address16_32(ab, &resource->data, ACPI_RSTYPE_ADDRESS16);
687 case ACPI_RSTYPE_ADDRESS32:
688 acpi_parse_address16_32(ab, &resource->data, ACPI_RSTYPE_ADDRESS32);
690 case ACPI_RSTYPE_ADDRESS64:
691 info("Address64 -------- Resource unparsed\n");
693 case ACPI_RSTYPE_EXT_IRQ:
694 dbg("Ext Irq -------- Resource\n");
697 dbg("Invalid -------- resource type 0x%x\n", resource->id);
701 resource = (struct acpi_resource *) ((char *)resource + resource->length);
707 static acpi_status acpi_get_crs( struct acpi_bridge *ab)
710 struct acpi_resource *crsbuf;
712 status = acpi_evaluate_crs(ab->handle, &crsbuf);
713 if (ACPI_SUCCESS(status)) {
714 status = acpi_parse_crs(ab, crsbuf);
717 pciehp_resource_sort_and_combine(&ab->bus_head);
718 pciehp_resource_sort_and_combine(&ab->io_head);
719 pciehp_resource_sort_and_combine(&ab->mem_head);
720 pciehp_resource_sort_and_combine(&ab->p_mem_head);
722 pciehprm_add_resources (&ab->tbus_head, ab->bus_head);
723 pciehprm_add_resources (&ab->tio_head, ab->io_head);
724 pciehprm_add_resources (&ab->tmem_head, ab->mem_head);
725 pciehprm_add_resources (&ab->tp_mem_head, ab->p_mem_head);
731 /* find acpi_bridge downword from ab. */
732 static struct acpi_bridge *
733 find_acpi_bridge_by_bus(
734 struct acpi_bridge *ab,
736 int bus /* pdev->subordinate->number */
739 struct acpi_bridge *lab = NULL;
744 if ((ab->bus == bus) && (ab->seg == seg))
748 lab = find_acpi_bridge_by_bus(ab->child, seg, bus);
752 lab = find_acpi_bridge_by_bus(ab->next, seg, bus);
758 * Build a device tree of ACPI PCI Bridges
760 static void pciehprm_acpi_register_a_bridge (
761 struct acpi_bridge **head,
762 struct acpi_bridge *pab, /* parent bridge to which child bridge is added */
763 struct acpi_bridge *cab /* child bridge to add */
766 struct acpi_bridge *lpab;
767 struct acpi_bridge *lcab;
769 lpab = find_acpi_bridge_by_bus(*head, pab->seg, pab->bus);
771 if (!(pab->type & BRIDGE_TYPE_HOST))
772 warn("PCI parent bridge s:b(%x:%x) not in list.\n", pab->seg, pab->bus);
778 if ((cab->type & BRIDGE_TYPE_HOST) && (pab == cab))
781 lcab = find_acpi_bridge_by_bus(*head, cab->seg, cab->bus);
783 if ((pab->bus != lcab->parent->bus) || (lcab->bus != cab->bus))
784 err("PCI child bridge s:b(%x:%x) in list with diff parent.\n", cab->seg, cab->bus);
790 lcab->next = lpab->child;
794 static acpi_status pciehprm_acpi_build_php_slots_callback(
805 acpi_handle phandle = NULL;
806 struct acpi_bridge *pab = (struct acpi_bridge *)context;
807 struct acpi_bridge *lab;
809 u8 *path_name = acpi_path_name(handle);
812 status = acpi_evaluate_integer(handle, METHOD_NAME__SUN, NULL, &sun);
817 if (ACPI_FAILURE(status)) {
818 err("acpi_pciehprm:%s _SUN fail=0x%x\n", path_name, status);
823 /* get _ADR. _ADR must exist if _SUN exists */
824 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr);
825 if (ACPI_FAILURE(status)) {
826 err("acpi_pciehprm:%s _ADR fail=0x%x\n", path_name, status);
830 dbg("acpi_pciehprm:%s sun=0x%08x adr=0x%08x\n", path_name, (u32)sun, (u32)adr);
832 status = acpi_get_parent(handle, &phandle);
833 if (ACPI_FAILURE(status)) {
834 err("acpi_pciehprm:%s get_parent fail=0x%x\n", path_name, status);
841 if (pab->bus == bus_num) {
844 dbg("WARN: pab is not parent\n");
845 lab = find_acpi_bridge_by_bus(pab, seg_num, bus_num);
847 dbg("acpi_pciehprm: alloc new P2P bridge(%x) for sun(%08x)\n", (u32)bus_num, (u32)sun);
848 lab = (struct acpi_bridge *)kmalloc(sizeof(struct acpi_bridge), GFP_KERNEL);
850 err("acpi_pciehprm: alloc for ab fail\n");
853 memset(lab, 0, sizeof(struct acpi_bridge));
855 lab->handle = phandle;
856 lab->pbus = pab->bus;
857 lab->pdevice = (int)(padr >> 16) & 0xffff;
858 lab->pfunction = (int)(padr & 0xffff);
859 lab->bus = (int)bus_num;
861 lab->type = BRIDGE_TYPE_P2P;
863 pciehprm_acpi_register_a_bridge (&acpi_bridges_head, pab, lab);
865 dbg("acpi_pciehprm: found P2P bridge(%x) for sun(%08x)\n", (u32)bus_num, (u32)sun);
868 acpi_add_slot_to_php_slots(lab, (int)bus_num, handle, (u32)adr, (u32)sun);
873 static int pciehprm_acpi_build_php_slots(
874 struct acpi_bridge *ab,
879 u8 *path_name = acpi_path_name(ab->handle);
881 /* Walk down this pci bridge to get _SUNs if any behind P2P */
882 status = acpi_walk_namespace ( ACPI_TYPE_DEVICE,
885 pciehprm_acpi_build_php_slots_callback,
888 if (ACPI_FAILURE(status)) {
889 dbg("acpi_pciehprm:%s walk for _SUN on pci bridge seg:bus(%x:%x) fail=0x%x\n", path_name, ab->seg, ab->bus, status);
896 static void build_a_bridge(
897 struct acpi_bridge *pab,
898 struct acpi_bridge *ab
901 u8 *path_name = acpi_path_name(ab->handle);
903 pciehprm_acpi_register_a_bridge (&acpi_bridges_head, pab, ab);
906 case BRIDGE_TYPE_HOST:
907 dbg("acpi_pciehprm: Registered PCI HOST Bridge(%02x) on s:b:d:f(%02x:%02x:%02x:%02x) [%s]\n",
908 ab->bus, ab->seg, ab->pbus, ab->pdevice, ab->pfunction, path_name);
910 case BRIDGE_TYPE_P2P:
911 dbg("acpi_pciehprm: Registered PCI P2P Bridge(%02x-%02x) on s:b:d:f(%02x:%02x:%02x:%02x) [%s]\n",
912 ab->pbus, ab->bus, ab->seg, ab->pbus, ab->pdevice, ab->pfunction, path_name);
916 /* build any immediate PHP slots under this pci bridge */
917 pciehprm_acpi_build_php_slots(ab, 1);
920 static struct acpi_bridge * add_p2p_bridge(
922 struct acpi_bridge *pab, /* parent */
926 struct acpi_bridge *ab;
927 struct pci_dev *pdev;
928 ulong devnum, funcnum;
929 u8 *path_name = acpi_path_name(handle);
931 ab = (struct acpi_bridge *) kmalloc (sizeof(struct acpi_bridge), GFP_KERNEL);
933 err("acpi_pciehprm: alloc for ab fail\n");
936 memset(ab, 0, sizeof(struct acpi_bridge));
938 devnum = (adr >> 16) & 0xffff;
939 funcnum = adr & 0xffff;
941 pdev = pci_find_slot(pab->bus, PCI_DEVFN(devnum, funcnum));
942 if (!pdev || !pdev->subordinate) {
943 err("acpi_pciehprm:%s is not a P2P Bridge\n", path_name);
950 ab->pbus = pab->bus; /* or pdev->bus->number */
951 ab->pdevice = devnum; /* or PCI_SLOT(pdev->devfn) */
952 ab->pfunction = funcnum; /* or PCI_FUNC(pdev->devfn) */
953 ab->bus = pdev->subordinate->number;
955 ab->type = BRIDGE_TYPE_P2P;
957 dbg("acpi_pciehprm: P2P(%x-%x) on pci=b:d:f(%x:%x:%x) acpi=b:d:f(%x:%x:%x) [%s]\n",
958 pab->bus, ab->bus, pdev->bus->number, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
959 pab->bus, (u32)devnum, (u32)funcnum, path_name);
961 build_a_bridge(pab, ab);
966 static acpi_status scan_p2p_bridge(
973 struct acpi_bridge *pab = (struct acpi_bridge *)context;
974 struct acpi_bridge *ab;
977 u8 *path_name = acpi_path_name(handle);
978 ulong devnum, funcnum;
979 struct pci_dev *pdev;
981 /* get device, function */
982 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr);
983 if (ACPI_FAILURE(status)) {
984 if (status != AE_NOT_FOUND)
985 err("acpi_pciehprm:%s _ADR fail=0x%x\n", path_name, status);
989 devnum = (adr >> 16) & 0xffff;
990 funcnum = adr & 0xffff;
992 pdev = pci_find_slot(pab->bus, PCI_DEVFN(devnum, funcnum));
995 if (!pdev->subordinate)
998 ab = add_p2p_bridge(handle, pab, adr);
1000 status = acpi_walk_namespace ( ACPI_TYPE_DEVICE,
1006 if (ACPI_FAILURE(status))
1007 dbg("acpi_pciehprm:%s find_p2p fail=0x%x\n", path_name, status);
1013 static struct acpi_bridge * add_host_bridge(
1021 struct acpi_bridge *ab;
1022 u8 *path_name = acpi_path_name(handle);
1024 /* get device, function: host br adr is always 0000 though. */
1025 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr);
1026 if (ACPI_FAILURE(status)) {
1027 err("acpi_pciehprm:%s _ADR fail=0x%x\n", path_name, status);
1030 dbg("acpi_pciehprm: ROOT PCI seg(0x%x)bus(0x%x)dev(0x%x)func(0x%x) [%s]\n", (u32)segnum,
1031 (u32)busnum, (u32)(adr >> 16) & 0xffff, (u32)adr & 0xffff, path_name);
1033 ab = (struct acpi_bridge *) kmalloc (sizeof(struct acpi_bridge), GFP_KERNEL);
1035 err("acpi_pciehprm: alloc for ab fail\n");
1038 memset(ab, 0, sizeof(struct acpi_bridge));
1040 ab->handle = handle;
1041 ab->seg = (int)segnum;
1042 ab->bus = ab->pbus = (int)busnum;
1043 ab->pdevice = (int)(adr >> 16) & 0xffff;
1044 ab->pfunction = (int)(adr & 0xffff);
1046 ab->type = BRIDGE_TYPE_HOST;
1048 /* get root pci bridge's current resources */
1049 status = acpi_get_crs(ab);
1050 if (ACPI_FAILURE(status)) {
1051 err("acpi_pciehprm:%s evaluate _CRS fail=0x%x\n", path_name, status);
1055 build_a_bridge(ab, ab);
1060 static acpi_status acpi_scan_from_root_pci_callback (
1070 struct acpi_bridge *ab;
1071 u8 *path_name = acpi_path_name(handle);
1073 /* get bus number of this pci root bridge */
1074 status = acpi_evaluate_integer(handle, METHOD_NAME__SEG, NULL, &segnum);
1075 if (ACPI_FAILURE(status)) {
1076 if (status != AE_NOT_FOUND) {
1077 err("acpi_pciehprm:%s evaluate _SEG fail=0x%x\n", path_name, status);
1083 /* get bus number of this pci root bridge */
1084 status = acpi_evaluate_integer(handle, METHOD_NAME__BBN, NULL, &busnum);
1085 if (ACPI_FAILURE(status)) {
1086 err("acpi_pciehprm:%s evaluate _BBN fail=0x%x\n", path_name, status);
1090 ab = add_host_bridge(handle, segnum, busnum);
1092 status = acpi_walk_namespace ( ACPI_TYPE_DEVICE,
1098 if (ACPI_FAILURE(status))
1099 dbg("acpi_pciehprm:%s find_p2p fail=0x%x\n", path_name, status);
1105 static int pciehprm_acpi_scan_pci (void)
1110 * TBD: traverse LDM device tree with the help of
1111 * unified ACPI augmented for php device population.
1113 status = acpi_get_devices ( PCI_ROOT_HID_STRING,
1114 acpi_scan_from_root_pci_callback,
1117 if (ACPI_FAILURE(status)) {
1118 err("acpi_pciehprm:get_device PCI ROOT HID fail=0x%x\n", status);
1125 int pciehprm_init(enum php_ctlr_type ctlr_type)
1129 if (ctlr_type != PCI)
1132 dbg("pciehprm ACPI init <enter>\n");
1133 acpi_bridges_head = NULL;
1135 /* construct PCI bus:device tree of acpi_handles */
1136 rc = pciehprm_acpi_scan_pci();
1140 dbg("pciehprm ACPI init %s\n", (rc)?"fail":"success");
1144 static void free_a_slot(struct acpi_php_slot *aps)
1146 dbg(" free a php func of slot(0x%02x) on PCI b:d:f=0x%02x:%02x:%02x\n", aps->sun, aps->bus, aps->dev, aps->fun);
1148 free_pci_resource (aps->io_head);
1149 free_pci_resource (aps->bus_head);
1150 free_pci_resource (aps->mem_head);
1151 free_pci_resource (aps->p_mem_head);
1156 static void free_a_bridge( struct acpi_bridge *ab)
1158 struct acpi_php_slot *aps, *next;
1161 case BRIDGE_TYPE_HOST:
1162 dbg("Free ACPI PCI HOST Bridge(%x) [%s] on s:b:d:f(%x:%x:%x:%x)\n",
1163 ab->bus, acpi_path_name(ab->handle), ab->seg, ab->pbus, ab->pdevice, ab->pfunction);
1165 case BRIDGE_TYPE_P2P:
1166 dbg("Free ACPI PCI P2P Bridge(%x-%x) [%s] on s:b:d:f(%x:%x:%x:%x)\n",
1167 ab->pbus, ab->bus, acpi_path_name(ab->handle), ab->seg, ab->pbus, ab->pdevice, ab->pfunction);
1171 /* free slots first */
1172 for (aps = ab->slots; aps; aps = next) {
1177 free_pci_resource (ab->io_head);
1178 free_pci_resource (ab->tio_head);
1179 free_pci_resource (ab->bus_head);
1180 free_pci_resource (ab->tbus_head);
1181 free_pci_resource (ab->mem_head);
1182 free_pci_resource (ab->tmem_head);
1183 free_pci_resource (ab->p_mem_head);
1184 free_pci_resource (ab->tp_mem_head);
1189 static void pciehprm_free_bridges ( struct acpi_bridge *ab)
1195 pciehprm_free_bridges (ab->child);
1198 pciehprm_free_bridges (ab->next);
1203 void pciehprm_cleanup(void)
1205 pciehprm_free_bridges (acpi_bridges_head);
1208 static int get_number_of_slots (
1209 struct acpi_bridge *ab,
1213 struct acpi_php_slot *aps;
1217 for ( aps = ab->slots; aps; aps = aps->next)
1218 if (aps->dev != prev_slot) {
1219 prev_slot = aps->dev;
1224 slot_num += get_number_of_slots (ab->child, 0);
1230 slot_num += get_number_of_slots (ab->next, 0);
1235 static int print_acpi_resources (struct acpi_bridge *ab)
1237 struct acpi_php_slot *aps;
1241 case BRIDGE_TYPE_HOST:
1242 dbg("PCI HOST Bridge (%x) [%s]\n", ab->bus, acpi_path_name(ab->handle));
1244 case BRIDGE_TYPE_P2P:
1245 dbg("PCI P2P Bridge (%x-%x) [%s]\n", ab->pbus, ab->bus, acpi_path_name(ab->handle));
1249 print_pci_resources (ab);
1251 for ( i = -1, aps = ab->slots; aps; aps = aps->next) {
1254 dbg(" Slot sun(%x) s:b:d:f(%02x:%02x:%02x:%02x)\n", aps->sun, aps->seg, aps->bus, aps->dev, aps->fun);
1255 print_slot_resources(aps);
1260 print_acpi_resources (ab->child);
1263 print_acpi_resources (ab->next);
1268 int pciehprm_print_pirt(void)
1270 dbg("PCIEHPRM ACPI Slots\n");
1271 if (acpi_bridges_head)
1272 print_acpi_resources (acpi_bridges_head);
1277 static struct acpi_php_slot * get_acpi_slot (
1278 struct acpi_bridge *ab,
1282 struct acpi_php_slot *aps = NULL;
1284 for ( aps = ab->slots; aps; aps = aps->next)
1285 if (aps->sun == sun)
1288 if (!aps && ab->child) {
1289 aps = (struct acpi_php_slot *)get_acpi_slot (ab->child, sun);
1294 if (!aps && ab->next) {
1295 aps = (struct acpi_php_slot *)get_acpi_slot (ab->next, sun);
1305 void * pciehprm_get_slot(struct slot *slot)
1307 struct acpi_bridge *ab = acpi_bridges_head;
1308 struct acpi_php_slot *aps = get_acpi_slot (ab, slot->number);
1312 dbg("Got acpi slot sun(%x): s:b:d:f(%x:%x:%x:%x)\n", aps->sun, aps->seg, aps->bus, aps->dev, aps->fun);
1318 static void pciehprm_dump_func_res( struct pci_func *fun)
1320 struct pci_func *func = fun;
1322 if (func->bus_head) {
1323 dbg(": BUS Resources:\n");
1324 print_pci_resource (func->bus_head);
1326 if (func->io_head) {
1327 dbg(": IO Resources:\n");
1328 print_pci_resource (func->io_head);
1330 if (func->mem_head) {
1331 dbg(": MEM Resources:\n");
1332 print_pci_resource (func->mem_head);
1334 if (func->p_mem_head) {
1335 dbg(": PMEM Resources:\n");
1336 print_pci_resource (func->p_mem_head);
1340 static void pciehprm_dump_ctrl_res( struct controller *ctlr)
1342 struct controller *ctrl = ctlr;
1344 if (ctrl->bus_head) {
1345 dbg(": BUS Resources:\n");
1346 print_pci_resource (ctrl->bus_head);
1348 if (ctrl->io_head) {
1349 dbg(": IO Resources:\n");
1350 print_pci_resource (ctrl->io_head);
1352 if (ctrl->mem_head) {
1353 dbg(": MEM Resources:\n");
1354 print_pci_resource (ctrl->mem_head);
1356 if (ctrl->p_mem_head) {
1357 dbg(": PMEM Resources:\n");
1358 print_pci_resource (ctrl->p_mem_head);
1362 static int pciehprm_get_used_resources (
1363 struct controller *ctrl,
1364 struct pci_func *func
1367 return pciehp_save_used_resources (ctrl, func, !DISABLE_CARD);
1370 static int configure_existing_function(
1371 struct controller *ctrl,
1372 struct pci_func *func
1377 /* see how much resources the func has used. */
1378 rc = pciehprm_get_used_resources (ctrl, func);
1381 /* subtract the resources used by the func from ctrl resources */
1382 rc = pciehprm_delete_resources (&ctrl->bus_head, func->bus_head);
1383 rc |= pciehprm_delete_resources (&ctrl->io_head, func->io_head);
1384 rc |= pciehprm_delete_resources (&ctrl->mem_head, func->mem_head);
1385 rc |= pciehprm_delete_resources (&ctrl->p_mem_head, func->p_mem_head);
1387 warn("aCEF: cannot del used resources\n");
1389 err("aCEF: cannot get used resources\n");
1394 static int bind_pci_resources_to_slots ( struct controller *ctrl)
1396 struct pci_func *func;
1397 int busn = ctrl->slot_bus;
1401 for (devn = 0; devn < 32; devn++) {
1402 for (funn = 0; funn < 8; funn++) {
1404 if (devn == ctrl->device && funn == ctrl->function)
1407 /* find out if this entry is for an occupied slot */
1409 pci_bus_read_config_dword(ctrl->pci_dev->subordinate, PCI_DEVFN(devn, funn), PCI_VENDOR_ID, &vid);
1411 if (vid != 0xFFFFFFFF) {
1412 dbg("%s: vid = %x\n", __FUNCTION__, vid);
1413 func = pciehp_slot_find(busn, devn, funn);
1416 configure_existing_function(ctrl, func);
1417 dbg("aCCF:existing PCI 0x%x Func ResourceDump\n", ctrl->bus);
1418 pciehprm_dump_func_res(func);
1426 static int bind_pci_resources(
1427 struct controller *ctrl,
1428 struct acpi_bridge *ab
1434 dbg("bapr: BUS Resources add on PCI 0x%x\n", ab->bus);
1435 status = pciehprm_add_resources (&ctrl->bus_head, ab->bus_head);
1436 if (pciehprm_delete_resources (&ab->bus_head, ctrl->bus_head))
1437 warn("bapr: cannot sub BUS Resource on PCI 0x%x\n", ab->bus);
1439 err("bapr: BUS Resource add on PCI 0x%x: fail=0x%x\n", ab->bus, status);
1443 info("bapr: No BUS Resource on PCI 0x%x.\n", ab->bus);
1446 dbg("bapr: IO Resources add on PCI 0x%x\n", ab->bus);
1447 status = pciehprm_add_resources (&ctrl->io_head, ab->io_head);
1448 if (pciehprm_delete_resources (&ab->io_head, ctrl->io_head))
1449 warn("bapr: cannot sub IO Resource on PCI 0x%x\n", ab->bus);
1451 err("bapr: IO Resource add on PCI 0x%x: fail=0x%x\n", ab->bus, status);
1455 info("bapr: No IO Resource on PCI 0x%x.\n", ab->bus);
1458 dbg("bapr: MEM Resources add on PCI 0x%x\n", ab->bus);
1459 status = pciehprm_add_resources (&ctrl->mem_head, ab->mem_head);
1460 if (pciehprm_delete_resources (&ab->mem_head, ctrl->mem_head))
1461 warn("bapr: cannot sub MEM Resource on PCI 0x%x\n", ab->bus);
1463 err("bapr: MEM Resource add on PCI 0x%x: fail=0x%x\n", ab->bus, status);
1467 info("bapr: No MEM Resource on PCI 0x%x.\n", ab->bus);
1469 if (ab->p_mem_head) {
1470 dbg("bapr: PMEM Resources add on PCI 0x%x\n", ab->bus);
1471 status = pciehprm_add_resources (&ctrl->p_mem_head, ab->p_mem_head);
1472 if (pciehprm_delete_resources (&ab->p_mem_head, ctrl->p_mem_head))
1473 warn("bapr: cannot sub PMEM Resource on PCI 0x%x\n", ab->bus);
1475 err("bapr: PMEM Resource add on PCI 0x%x: fail=0x%x\n", ab->bus, status);
1479 info("bapr: No PMEM Resource on PCI 0x%x.\n", ab->bus);
1484 static int no_pci_resources( struct acpi_bridge *ab)
1486 return !(ab->p_mem_head || ab->mem_head || ab->io_head || ab->bus_head);
1489 static int find_pci_bridge_resources (
1490 struct controller *ctrl,
1491 struct acpi_bridge *ab
1495 struct pci_func func;
1497 memset(&func, 0, sizeof(struct pci_func));
1499 func.bus = ab->pbus;
1500 func.device = ab->pdevice;
1501 func.function = ab->pfunction;
1502 func.is_a_board = 1;
1504 /* Get used resources for this PCI bridge */
1505 rc = pciehp_save_used_resources (ctrl, &func, !DISABLE_CARD);
1507 ab->io_head = func.io_head;
1508 ab->mem_head = func.mem_head;
1509 ab->p_mem_head = func.p_mem_head;
1510 ab->bus_head = func.bus_head;
1512 pciehprm_delete_resource(&ab->bus_head, ctrl->pci_dev->subordinate->number, 1);
1517 static int get_pci_resources_from_bridge(
1518 struct controller *ctrl,
1519 struct acpi_bridge *ab
1524 dbg("grfb: Get Resources for PCI 0x%x from actual PCI bridge 0x%x.\n", ctrl->bus, ab->bus);
1526 rc = find_pci_bridge_resources (ctrl, ab);
1528 pciehp_resource_sort_and_combine(&ab->bus_head);
1529 pciehp_resource_sort_and_combine(&ab->io_head);
1530 pciehp_resource_sort_and_combine(&ab->mem_head);
1531 pciehp_resource_sort_and_combine(&ab->p_mem_head);
1533 pciehprm_add_resources (&ab->tbus_head, ab->bus_head);
1534 pciehprm_add_resources (&ab->tio_head, ab->io_head);
1535 pciehprm_add_resources (&ab->tmem_head, ab->mem_head);
1536 pciehprm_add_resources (&ab->tp_mem_head, ab->p_mem_head);
1541 static int get_pci_resources(
1542 struct controller *ctrl,
1543 struct acpi_bridge *ab
1548 if (no_pci_resources(ab)) {
1549 dbg("spbr:PCI 0x%x has no resources. Get parent resources.\n", ab->bus);
1550 rc = get_pci_resources_from_bridge(ctrl, ab);
1557 * Get resources for this ctrl.
1558 * 1. get total resources from ACPI _CRS or bridge (this ctrl)
1559 * 2. find used resources of existing adapters
1560 * 3. subtract used resources from total resources
1562 int pciehprm_find_available_resources( struct controller *ctrl)
1565 struct acpi_bridge *ab;
1567 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->pci_dev->subordinate->number);
1569 err("pfar:cannot locate acpi bridge of PCI 0x%x.\n", ctrl->pci_dev->subordinate->number);
1572 if (no_pci_resources(ab)) {
1573 rc = get_pci_resources(ctrl, ab);
1575 err("pfar:cannot get pci resources of PCI 0x%x.\n", ctrl->pci_dev->subordinate->number);
1580 rc = bind_pci_resources(ctrl, ab);
1581 dbg("pfar:pre-Bind PCI 0x%x Ctrl Resource Dump\n", ctrl->pci_dev->subordinate->number);
1582 pciehprm_dump_ctrl_res(ctrl);
1584 bind_pci_resources_to_slots (ctrl);
1586 dbg("pfar:post-Bind PCI 0x%x Ctrl Resource Dump\n", ctrl->pci_dev->subordinate->number);
1587 pciehprm_dump_ctrl_res(ctrl);
1592 int pciehprm_set_hpp(
1593 struct controller *ctrl,
1594 struct pci_func *func,
1598 struct acpi_bridge *ab;
1599 struct pci_bus lpci_bus, *pci_bus;
1602 u8 cls= 0x08; /* default cache line size */
1603 u8 lt = 0x40; /* default latency timer */
1607 memcpy(&lpci_bus, ctrl->pci_bus, sizeof(lpci_bus));
1608 pci_bus = &lpci_bus;
1609 pci_bus->number = func->bus;
1610 devfn = PCI_DEVFN(func->device, func->function);
1612 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->bus);
1616 lt = (u8)ab->_hpp->latency_timer;
1617 cls = (u8)ab->_hpp->cache_line_size;
1618 ep = (u8)ab->_hpp->enable_perr;
1619 es = (u8)ab->_hpp->enable_serr;
1621 dbg("_hpp: no _hpp for B/D/F=%#x/%#x/%#x. use default value\n", func->bus, func->device, func->function);
1623 dbg("_hpp: no acpi bridge for B/D/F = %#x/%#x/%#x. use default value\n", func->bus, func->device, func->function);
1626 if (card_type == PCI_HEADER_TYPE_BRIDGE) {
1627 /* set subordinate Latency Timer */
1628 rc |= pci_bus_write_config_byte(pci_bus, devfn, PCI_SEC_LATENCY_TIMER, lt);
1631 /* set base Latency Timer */
1632 rc |= pci_bus_write_config_byte(pci_bus, devfn, PCI_LATENCY_TIMER, lt);
1633 dbg(" set latency timer =0x%02x: %x\n", lt, rc);
1635 rc |= pci_bus_write_config_byte(pci_bus, devfn, PCI_CACHE_LINE_SIZE, cls);
1636 dbg(" set cache_line_size=0x%02x: %x\n", cls, rc);
1641 void pciehprm_enable_card(
1642 struct controller *ctrl,
1643 struct pci_func *func,
1646 u16 command, cmd, bcommand, bcmd;
1647 struct pci_bus lpci_bus, *pci_bus;
1648 struct acpi_bridge *ab;
1652 memcpy(&lpci_bus, ctrl->pci_bus, sizeof(lpci_bus));
1653 pci_bus = &lpci_bus;
1654 pci_bus->number = func->bus;
1655 devfn = PCI_DEVFN(func->device, func->function);
1657 rc = pci_bus_read_config_word(pci_bus, devfn, PCI_COMMAND, &command);
1659 if (card_type == PCI_HEADER_TYPE_BRIDGE) {
1660 rc = pci_bus_read_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, &bcommand);
1663 cmd = command = command | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE
1664 | PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
1665 bcmd = bcommand = bcommand | PCI_BRIDGE_CTL_NO_ISA;
1667 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->bus);
1670 if (ab->_hpp->enable_perr) {
1671 command |= PCI_COMMAND_PARITY;
1672 bcommand |= PCI_BRIDGE_CTL_PARITY;
1674 command &= ~PCI_COMMAND_PARITY;
1675 bcommand &= ~PCI_BRIDGE_CTL_PARITY;
1677 if (ab->_hpp->enable_serr) {
1678 command |= PCI_COMMAND_SERR;
1679 bcommand |= PCI_BRIDGE_CTL_SERR;
1681 command &= ~PCI_COMMAND_SERR;
1682 bcommand &= ~PCI_BRIDGE_CTL_SERR;
1685 dbg("no _hpp for B/D/F = %#x/%#x/%#x.\n", func->bus, func->device, func->function);
1687 dbg("no acpi bridge for B/D/F = %#x/%#x/%#x.\n", func->bus, func->device, func->function);
1689 if (command != cmd) {
1690 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_COMMAND, command);
1692 if ((card_type == PCI_HEADER_TYPE_BRIDGE) && (bcommand != bcmd)) {
1693 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, bcommand);