aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/ibmphp_res.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/hotplug/ibmphp_res.c')
-rw-r--r--drivers/pci/hotplug/ibmphp_res.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/drivers/pci/hotplug/ibmphp_res.c b/drivers/pci/hotplug/ibmphp_res.c
index e2dc289f767c..a265acb2d518 100644
--- a/drivers/pci/hotplug/ibmphp_res.c
+++ b/drivers/pci/hotplug/ibmphp_res.c
@@ -72,7 +72,7 @@ static struct bus_node * __init alloc_error_bus (struct ebda_pci_rsrc * curr, u8
72static struct resource_node * __init alloc_resources (struct ebda_pci_rsrc * curr) 72static struct resource_node * __init alloc_resources (struct ebda_pci_rsrc * curr)
73{ 73{
74 struct resource_node *rs; 74 struct resource_node *rs;
75 75
76 if (!curr) { 76 if (!curr) {
77 err ("NULL passed to allocate\n"); 77 err ("NULL passed to allocate\n");
78 return NULL; 78 return NULL;
@@ -128,7 +128,7 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node
128 } 128 }
129 newrange->start = curr->start_addr; 129 newrange->start = curr->start_addr;
130 newrange->end = curr->end_addr; 130 newrange->end = curr->end_addr;
131 131
132 if (first_bus || (!num_ranges)) 132 if (first_bus || (!num_ranges))
133 newrange->rangeno = 1; 133 newrange->rangeno = 1;
134 else { 134 else {
@@ -162,7 +162,7 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node
162 newbus->rangePFMem = newrange; 162 newbus->rangePFMem = newrange;
163 if (first_bus) 163 if (first_bus)
164 newbus->noPFMemRanges = 1; 164 newbus->noPFMemRanges = 1;
165 else { 165 else {
166 debug ("1st PFMemory Primary on Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 166 debug ("1st PFMemory Primary on Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
167 ++newbus->noPFMemRanges; 167 ++newbus->noPFMemRanges;
168 fix_resources (newbus); 168 fix_resources (newbus);
@@ -190,7 +190,7 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node
190 * This is the Resource Management initialization function. It will go through 190 * This is the Resource Management initialization function. It will go through
191 * the Resource list taken from EBDA and fill in this module's data structures 191 * the Resource list taken from EBDA and fill in this module's data structures
192 * 192 *
193 * THIS IS NOT TAKING INTO CONSIDERATION IO RESTRICTIONS OF PRIMARY BUSES, 193 * THIS IS NOT TAKING INTO CONSIDERATION IO RESTRICTIONS OF PRIMARY BUSES,
194 * SINCE WE'RE GOING TO ASSUME FOR NOW WE DON'T HAVE THOSE ON OUR BUSES FOR NOW 194 * SINCE WE'RE GOING TO ASSUME FOR NOW WE DON'T HAVE THOSE ON OUR BUSES FOR NOW
195 * 195 *
196 * Input: ptr to the head of the resource list from EBDA 196 * Input: ptr to the head of the resource list from EBDA
@@ -382,7 +382,7 @@ int __init ibmphp_rsrc_init (void)
382 * pci devices' resources for the appropriate resource 382 * pci devices' resources for the appropriate resource
383 * 383 *
384 * Input: type of the resource, range to add, current bus 384 * Input: type of the resource, range to add, current bus
385 * Output: 0 or -1, bus and range ptrs 385 * Output: 0 or -1, bus and range ptrs
386 ********************************************************************************/ 386 ********************************************************************************/
387static int add_bus_range (int type, struct range_node *range, struct bus_node *bus_cur) 387static int add_bus_range (int type, struct range_node *range, struct bus_node *bus_cur)
388{ 388{
@@ -466,7 +466,7 @@ static void update_resources (struct bus_node *bus_cur, int type, int rangeno)
466 466
467 switch (type) { 467 switch (type) {
468 case MEM: 468 case MEM:
469 if (bus_cur->firstMem) 469 if (bus_cur->firstMem)
470 res = bus_cur->firstMem; 470 res = bus_cur->firstMem;
471 break; 471 break;
472 case PFMEM: 472 case PFMEM:
@@ -583,7 +583,7 @@ static void fix_resources (struct bus_node *bus_cur)
583} 583}
584 584
585/******************************************************************************* 585/*******************************************************************************
586 * This routine adds a resource to the list of resources to the appropriate bus 586 * This routine adds a resource to the list of resources to the appropriate bus
587 * based on their resource type and sorted by their starting addresses. It assigns 587 * based on their resource type and sorted by their starting addresses. It assigns
588 * the ptrs to next and nextRange if needed. 588 * the ptrs to next and nextRange if needed.
589 * 589 *
@@ -605,11 +605,11 @@ int ibmphp_add_resource (struct resource_node *res)
605 err ("NULL passed to add\n"); 605 err ("NULL passed to add\n");
606 return -ENODEV; 606 return -ENODEV;
607 } 607 }
608 608
609 bus_cur = find_bus_wprev (res->busno, NULL, 0); 609 bus_cur = find_bus_wprev (res->busno, NULL, 0);
610 610
611 if (!bus_cur) { 611 if (!bus_cur) {
612 /* didn't find a bus, smth's wrong!!! */ 612 /* didn't find a bus, something's wrong!!! */
613 debug ("no bus in the system, either pci_dev's wrong or allocation failed\n"); 613 debug ("no bus in the system, either pci_dev's wrong or allocation failed\n");
614 return -ENODEV; 614 return -ENODEV;
615 } 615 }
@@ -648,7 +648,7 @@ int ibmphp_add_resource (struct resource_node *res)
648 if (!range_cur) { 648 if (!range_cur) {
649 switch (res->type) { 649 switch (res->type) {
650 case IO: 650 case IO:
651 ++bus_cur->needIOUpdate; 651 ++bus_cur->needIOUpdate;
652 break; 652 break;
653 case MEM: 653 case MEM:
654 ++bus_cur->needMemUpdate; 654 ++bus_cur->needMemUpdate;
@@ -659,13 +659,13 @@ int ibmphp_add_resource (struct resource_node *res)
659 } 659 }
660 res->rangeno = -1; 660 res->rangeno = -1;
661 } 661 }
662 662
663 debug ("The range is %d\n", res->rangeno); 663 debug ("The range is %d\n", res->rangeno);
664 if (!res_start) { 664 if (!res_start) {
665 /* no first{IO,Mem,Pfmem} on the bus, 1st IO/Mem/Pfmem resource ever */ 665 /* no first{IO,Mem,Pfmem} on the bus, 1st IO/Mem/Pfmem resource ever */
666 switch (res->type) { 666 switch (res->type) {
667 case IO: 667 case IO:
668 bus_cur->firstIO = res; 668 bus_cur->firstIO = res;
669 break; 669 break;
670 case MEM: 670 case MEM:
671 bus_cur->firstMem = res; 671 bus_cur->firstMem = res;
@@ -673,7 +673,7 @@ int ibmphp_add_resource (struct resource_node *res)
673 case PFMEM: 673 case PFMEM:
674 bus_cur->firstPFMem = res; 674 bus_cur->firstPFMem = res;
675 break; 675 break;
676 } 676 }
677 res->next = NULL; 677 res->next = NULL;
678 res->nextRange = NULL; 678 res->nextRange = NULL;
679 } else { 679 } else {
@@ -770,7 +770,7 @@ int ibmphp_add_resource (struct resource_node *res)
770 * This routine will remove the resource from the list of resources 770 * This routine will remove the resource from the list of resources
771 * 771 *
772 * Input: io, mem, and/or pfmem resource to be deleted 772 * Input: io, mem, and/or pfmem resource to be deleted
773 * Ouput: modified resource list 773 * Output: modified resource list
774 * 0 or error code 774 * 0 or error code
775 ****************************************************************************/ 775 ****************************************************************************/
776int ibmphp_remove_resource (struct resource_node *res) 776int ibmphp_remove_resource (struct resource_node *res)
@@ -825,7 +825,7 @@ int ibmphp_remove_resource (struct resource_node *res)
825 825
826 if (!res_cur) { 826 if (!res_cur) {
827 if (res->type == PFMEM) { 827 if (res->type == PFMEM) {
828 /* 828 /*
829 * case where pfmem might be in the PFMemFromMem list 829 * case where pfmem might be in the PFMemFromMem list
830 * so will also need to remove the corresponding mem 830 * so will also need to remove the corresponding mem
831 * entry 831 * entry
@@ -961,12 +961,12 @@ static struct range_node * find_range (struct bus_node *bus_cur, struct resource
961} 961}
962 962
963/***************************************************************************** 963/*****************************************************************************
964 * This routine will check to make sure the io/mem/pfmem->len that the device asked for 964 * This routine will check to make sure the io/mem/pfmem->len that the device asked for
965 * can fit w/i our list of available IO/MEM/PFMEM resources. If cannot, returns -EINVAL, 965 * can fit w/i our list of available IO/MEM/PFMEM resources. If cannot, returns -EINVAL,
966 * otherwise, returns 0 966 * otherwise, returns 0
967 * 967 *
968 * Input: resource 968 * Input: resource
969 * Ouput: the correct start and end address are inputted into the resource node, 969 * Output: the correct start and end address are inputted into the resource node,
970 * 0 or -EINVAL 970 * 0 or -EINVAL
971 *****************************************************************************/ 971 *****************************************************************************/
972int ibmphp_check_resource (struct resource_node *res, u8 bridge) 972int ibmphp_check_resource (struct resource_node *res, u8 bridge)
@@ -996,7 +996,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
996 bus_cur = find_bus_wprev (res->busno, NULL, 0); 996 bus_cur = find_bus_wprev (res->busno, NULL, 0);
997 997
998 if (!bus_cur) { 998 if (!bus_cur) {
999 /* didn't find a bus, smth's wrong!!! */ 999 /* didn't find a bus, something's wrong!!! */
1000 debug ("no bus in the system, either pci_dev's wrong or allocation failed\n"); 1000 debug ("no bus in the system, either pci_dev's wrong or allocation failed\n");
1001 return -EINVAL; 1001 return -EINVAL;
1002 } 1002 }
@@ -1066,7 +1066,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1066 break; 1066 break;
1067 } 1067 }
1068 } 1068 }
1069 1069
1070 if (flag && len_cur == res->len) { 1070 if (flag && len_cur == res->len) {
1071 debug ("but we are not here, right?\n"); 1071 debug ("but we are not here, right?\n");
1072 res->start = start_cur; 1072 res->start = start_cur;
@@ -1118,10 +1118,10 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1118 if (res_prev) { 1118 if (res_prev) {
1119 if (res_prev->rangeno != res_cur->rangeno) { 1119 if (res_prev->rangeno != res_cur->rangeno) {
1120 /* 1st device on this range */ 1120 /* 1st device on this range */
1121 if ((res_cur->start != range->start) && 1121 if ((res_cur->start != range->start) &&
1122 ((len_tmp = res_cur->start - 1 - range->start) >= res->len)) { 1122 ((len_tmp = res_cur->start - 1 - range->start) >= res->len)) {
1123 if ((len_tmp < len_cur) || (len_cur == 0)) { 1123 if ((len_tmp < len_cur) || (len_cur == 0)) {
1124 if ((range->start % tmp_divide) == 0) { 1124 if ((range->start % tmp_divide) == 0) {
1125 /* just perfect, starting address is divisible by length */ 1125 /* just perfect, starting address is divisible by length */
1126 flag = 1; 1126 flag = 1;
1127 len_cur = len_tmp; 1127 len_cur = len_tmp;
@@ -1344,7 +1344,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1344 * This routine is called from remove_card if the card contained PPB. 1344 * This routine is called from remove_card if the card contained PPB.
1345 * It will remove all the resources on the bus as well as the bus itself 1345 * It will remove all the resources on the bus as well as the bus itself
1346 * Input: Bus 1346 * Input: Bus
1347 * Ouput: 0, -ENODEV 1347 * Output: 0, -ENODEV
1348 ********************************************************************************/ 1348 ********************************************************************************/
1349int ibmphp_remove_bus (struct bus_node *bus, u8 parent_busno) 1349int ibmphp_remove_bus (struct bus_node *bus, u8 parent_busno)
1350{ 1350{
@@ -1353,7 +1353,7 @@ int ibmphp_remove_bus (struct bus_node *bus, u8 parent_busno)
1353 struct bus_node *prev_bus; 1353 struct bus_node *prev_bus;
1354 int rc; 1354 int rc;
1355 1355
1356 prev_bus = find_bus_wprev (parent_busno, NULL, 0); 1356 prev_bus = find_bus_wprev (parent_busno, NULL, 0);
1357 1357
1358 if (!prev_bus) { 1358 if (!prev_bus) {
1359 debug ("something terribly wrong. Cannot find parent bus to the one to remove\n"); 1359 debug ("something terribly wrong. Cannot find parent bus to the one to remove\n");
@@ -1424,7 +1424,7 @@ int ibmphp_remove_bus (struct bus_node *bus, u8 parent_busno)
1424} 1424}
1425 1425
1426/****************************************************************************** 1426/******************************************************************************
1427 * This routine deletes the ranges from a given bus, and the entries from the 1427 * This routine deletes the ranges from a given bus, and the entries from the
1428 * parent's bus in the resources 1428 * parent's bus in the resources
1429 * Input: current bus, previous bus 1429 * Input: current bus, previous bus
1430 * Output: 0, -EINVAL 1430 * Output: 0, -EINVAL
@@ -1453,7 +1453,7 @@ static int remove_ranges (struct bus_node *bus_cur, struct bus_node *bus_prev)
1453 if (bus_cur->noMemRanges) { 1453 if (bus_cur->noMemRanges) {
1454 range_cur = bus_cur->rangeMem; 1454 range_cur = bus_cur->rangeMem;
1455 for (i = 0; i < bus_cur->noMemRanges; i++) { 1455 for (i = 0; i < bus_cur->noMemRanges; i++) {
1456 if (ibmphp_find_resource (bus_prev, range_cur->start, &res, MEM) < 0) 1456 if (ibmphp_find_resource (bus_prev, range_cur->start, &res, MEM) < 0)
1457 return -EINVAL; 1457 return -EINVAL;
1458 1458
1459 ibmphp_remove_resource (res); 1459 ibmphp_remove_resource (res);
@@ -1467,7 +1467,7 @@ static int remove_ranges (struct bus_node *bus_cur, struct bus_node *bus_prev)
1467 if (bus_cur->noPFMemRanges) { 1467 if (bus_cur->noPFMemRanges) {
1468 range_cur = bus_cur->rangePFMem; 1468 range_cur = bus_cur->rangePFMem;
1469 for (i = 0; i < bus_cur->noPFMemRanges; i++) { 1469 for (i = 0; i < bus_cur->noPFMemRanges; i++) {
1470 if (ibmphp_find_resource (bus_prev, range_cur->start, &res, PFMEM) < 0) 1470 if (ibmphp_find_resource (bus_prev, range_cur->start, &res, PFMEM) < 0)
1471 return -EINVAL; 1471 return -EINVAL;
1472 1472
1473 ibmphp_remove_resource (res); 1473 ibmphp_remove_resource (res);
@@ -1482,7 +1482,7 @@ static int remove_ranges (struct bus_node *bus_cur, struct bus_node *bus_prev)
1482} 1482}
1483 1483
1484/* 1484/*
1485 * find the resource node in the bus 1485 * find the resource node in the bus
1486 * Input: Resource needed, start address of the resource, type of resource 1486 * Input: Resource needed, start address of the resource, type of resource
1487 */ 1487 */
1488int ibmphp_find_resource (struct bus_node *bus, u32 start_address, struct resource_node **res, int flag) 1488int ibmphp_find_resource (struct bus_node *bus, u32 start_address, struct resource_node **res, int flag)
@@ -1512,7 +1512,7 @@ int ibmphp_find_resource (struct bus_node *bus, u32 start_address, struct resour
1512 err ("wrong type of flag\n"); 1512 err ("wrong type of flag\n");
1513 return -EINVAL; 1513 return -EINVAL;
1514 } 1514 }
1515 1515
1516 while (res_cur) { 1516 while (res_cur) {
1517 if (res_cur->start == start_address) { 1517 if (res_cur->start == start_address) {
1518 *res = res_cur; 1518 *res = res_cur;
@@ -1718,7 +1718,7 @@ static int __init once_over (void)
1718 } /* end for pfmem */ 1718 } /* end for pfmem */
1719 } /* end if */ 1719 } /* end if */
1720 } /* end list_for_each bus */ 1720 } /* end list_for_each bus */
1721 return 0; 1721 return 0;
1722} 1722}
1723 1723
1724int ibmphp_add_pfmem_from_mem (struct resource_node *pfmem) 1724int ibmphp_add_pfmem_from_mem (struct resource_node *pfmem)
@@ -1760,9 +1760,9 @@ static struct bus_node *find_bus_wprev (u8 bus_number, struct bus_node **prev, u
1760 list_for_each (tmp, &gbuses) { 1760 list_for_each (tmp, &gbuses) {
1761 tmp_prev = tmp->prev; 1761 tmp_prev = tmp->prev;
1762 bus_cur = list_entry (tmp, struct bus_node, bus_list); 1762 bus_cur = list_entry (tmp, struct bus_node, bus_list);
1763 if (flag) 1763 if (flag)
1764 *prev = list_entry (tmp_prev, struct bus_node, bus_list); 1764 *prev = list_entry (tmp_prev, struct bus_node, bus_list);
1765 if (bus_cur->busno == bus_number) 1765 if (bus_cur->busno == bus_number)
1766 return bus_cur; 1766 return bus_cur;
1767 } 1767 }
1768 1768
@@ -1776,7 +1776,7 @@ void ibmphp_print_test (void)
1776 struct range_node *range; 1776 struct range_node *range;
1777 struct resource_node *res; 1777 struct resource_node *res;
1778 struct list_head *tmp; 1778 struct list_head *tmp;
1779 1779
1780 debug_pci ("*****************START**********************\n"); 1780 debug_pci ("*****************START**********************\n");
1781 1781
1782 if ((!list_empty(&gbuses)) && flags) { 1782 if ((!list_empty(&gbuses)) && flags) {
@@ -1906,7 +1906,7 @@ static int range_exists_already (struct range_node * range, struct bus_node * bu
1906 return 1; 1906 return 1;
1907 range_cur = range_cur->next; 1907 range_cur = range_cur->next;
1908 } 1908 }
1909 1909
1910 return 0; 1910 return 0;
1911} 1911}
1912 1912
@@ -1920,7 +1920,7 @@ static int range_exists_already (struct range_node * range, struct bus_node * bu
1920 * Returns: none 1920 * Returns: none
1921 * Note: this function doesn't take into account IO restrictions etc, 1921 * Note: this function doesn't take into account IO restrictions etc,
1922 * so will only work for bridges with no video/ISA devices behind them It 1922 * so will only work for bridges with no video/ISA devices behind them It
1923 * also will not work for onboard PPB's that can have more than 1 *bus 1923 * also will not work for onboard PPBs that can have more than 1 *bus
1924 * behind them All these are TO DO. 1924 * behind them All these are TO DO.
1925 * Also need to add more error checkings... (from fnc returns etc) 1925 * Also need to add more error checkings... (from fnc returns etc)
1926 */ 1926 */
@@ -1963,7 +1963,7 @@ static int __init update_bridge_ranges (struct bus_node **bus)
1963 case PCI_HEADER_TYPE_BRIDGE: 1963 case PCI_HEADER_TYPE_BRIDGE:
1964 function = 0x8; 1964 function = 0x8;
1965 case PCI_HEADER_TYPE_MULTIBRIDGE: 1965 case PCI_HEADER_TYPE_MULTIBRIDGE:
1966 /* We assume here that only 1 bus behind the bridge 1966 /* We assume here that only 1 bus behind the bridge
1967 TO DO: add functionality for several: 1967 TO DO: add functionality for several:
1968 temp = secondary; 1968 temp = secondary;
1969 while (temp < subordinate) { 1969 while (temp < subordinate) {
@@ -1972,7 +1972,7 @@ static int __init update_bridge_ranges (struct bus_node **bus)
1972 } 1972 }
1973 */ 1973 */
1974 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_busno); 1974 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_busno);
1975 bus_sec = find_bus_wprev (sec_busno, NULL, 0); 1975 bus_sec = find_bus_wprev (sec_busno, NULL, 0);
1976 /* this bus structure doesn't exist yet, PPB was configured during previous loading of ibmphp */ 1976 /* this bus structure doesn't exist yet, PPB was configured during previous loading of ibmphp */
1977 if (!bus_sec) { 1977 if (!bus_sec) {
1978 bus_sec = alloc_error_bus (NULL, sec_busno, 1); 1978 bus_sec = alloc_error_bus (NULL, sec_busno, 1);
@@ -2028,7 +2028,7 @@ static int __init update_bridge_ranges (struct bus_node **bus)
2028 io->len = io->end - io->start + 1; 2028 io->len = io->end - io->start + 1;
2029 ibmphp_add_resource (io); 2029 ibmphp_add_resource (io);
2030 } 2030 }
2031 } 2031 }
2032 2032
2033 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, &start_mem_address); 2033 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, &start_mem_address);
2034 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, &end_mem_address); 2034 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, &end_mem_address);