Lines Matching +full:mem +full:- +full:io

1 // SPDX-License-Identifier: GPL-2.0+
7 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
49 newbus->busno = busno; in alloc_error_bus()
51 newbus->busno = curr->bus_num; in alloc_error_bus()
52 list_add_tail(&newbus->bus_list, &gbuses); in alloc_error_bus()
69 rs->busno = curr->bus_num; in alloc_resources()
70 rs->devfunc = curr->dev_fun; in alloc_resources()
71 rs->start = curr->start_addr; in alloc_resources()
72 rs->end = curr->end_addr; in alloc_resources()
73 rs->len = curr->end_addr - curr->start_addr + 1; in alloc_resources()
86 return -ENOMEM; in alloc_bus_range()
88 newbus->busno = curr->bus_num; in alloc_bus_range()
92 case MEM: in alloc_bus_range()
93 num_ranges = newbus->noMemRanges; in alloc_bus_range()
96 num_ranges = newbus->noPFMemRanges; in alloc_bus_range()
98 case IO: in alloc_bus_range()
99 num_ranges = newbus->noIORanges; in alloc_bus_range()
108 return -ENOMEM; in alloc_bus_range()
110 newrange->start = curr->start_addr; in alloc_bus_range()
111 newrange->end = curr->end_addr; in alloc_bus_range()
114 newrange->rangeno = 1; in alloc_bus_range()
118 …"%d resource Primary Bus inserted on bus %x [%x - %x]\n", flag, newbus->busno, newrange->start, ne… in alloc_bus_range()
122 case MEM: in alloc_bus_range()
123 newbus->rangeMem = newrange; in alloc_bus_range()
125 newbus->noMemRanges = 1; in alloc_bus_range()
127 …debug("First Memory Primary on bus %x, [%x - %x]\n", newbus->busno, newrange->start, newrange->end… in alloc_bus_range()
128 ++newbus->noMemRanges; in alloc_bus_range()
132 case IO: in alloc_bus_range()
133 newbus->rangeIO = newrange; in alloc_bus_range()
135 newbus->noIORanges = 1; in alloc_bus_range()
137 debug("First IO Primary on bus %x, [%x - %x]\n", newbus->busno, newrange->start, newrange->end); in alloc_bus_range()
138 ++newbus->noIORanges; in alloc_bus_range()
143 newbus->rangePFMem = newrange; in alloc_bus_range()
145 newbus->noPFMemRanges = 1; in alloc_bus_range()
147 …debug("1st PFMemory Primary on Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); in alloc_bus_range()
148 ++newbus->noPFMemRanges; in alloc_bus_range()
164 * 2. If cannot allocate out of PFMem range, allocate from Mem ranges. PFmemFromMem
165 * are not sorted. (no need since use mem node). To not change the entire code, we
166 * also add mem node whenever this case happens so as not to change
167 * ibmphp_check_mem_resource etc(and since it really is taking Mem resource)
174 * THIS IS NOT TAKING INTO CONSIDERATION IO RESTRICTIONS OF PRIMARY BUSES,
178 * Output: 0, -1 or error codes
194 if (!(curr->rsrc_type & PCIDEVMASK)) { in ibmphp_rsrc_init()
201 if (curr->rsrc_type & PRIMARYBUSMASK) { in ibmphp_rsrc_init()
203 if ((curr->rsrc_type & RESTYPE) == MMASK) { in ibmphp_rsrc_init()
206 rc = alloc_bus_range(&newbus, &newrange, curr, MEM, 1); in ibmphp_rsrc_init()
209 list_add_tail(&newbus->bus_list, &gbuses); in ibmphp_rsrc_init()
210 …debug("gbuses = NULL, Memory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange in ibmphp_rsrc_init()
212 bus_cur = find_bus_wprev(curr->bus_num, &bus_prev, 1); in ibmphp_rsrc_init()
215 rc = alloc_bus_range(&bus_cur, &newrange, curr, MEM, 0); in ibmphp_rsrc_init()
220 rc = alloc_bus_range(&newbus, &newrange, curr, MEM, 1); in ibmphp_rsrc_init()
224 list_add_tail(&newbus->bus_list, &gbuses); in ibmphp_rsrc_init()
225 …debug("New Bus, Memory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); in ibmphp_rsrc_init()
228 } else if ((curr->rsrc_type & RESTYPE) == PFMASK) { in ibmphp_rsrc_init()
235 list_add_tail(&newbus->bus_list, &gbuses); in ibmphp_rsrc_init()
236 …debug("gbuses = NULL, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newran… in ibmphp_rsrc_init()
238 bus_cur = find_bus_wprev(curr->bus_num, &bus_prev, 1); in ibmphp_rsrc_init()
249 list_add_tail(&newbus->bus_list, &gbuses); in ibmphp_rsrc_init()
250 …debug("1st Bus, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->en… in ibmphp_rsrc_init()
253 } else if ((curr->rsrc_type & RESTYPE) == IOMASK) { in ibmphp_rsrc_init()
254 /* IO */ in ibmphp_rsrc_init()
257 rc = alloc_bus_range(&newbus, &newrange, curr, IO, 1); in ibmphp_rsrc_init()
260 list_add_tail(&newbus->bus_list, &gbuses); in ibmphp_rsrc_init()
261 …debug("gbuses = NULL, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->en… in ibmphp_rsrc_init()
263 bus_cur = find_bus_wprev(curr->bus_num, &bus_prev, 1); in ibmphp_rsrc_init()
265 rc = alloc_bus_range(&bus_cur, &newrange, curr, IO, 0); in ibmphp_rsrc_init()
270 rc = alloc_bus_range(&newbus, &newrange, curr, IO, 1); in ibmphp_rsrc_init()
273 list_add_tail(&newbus->bus_list, &gbuses); in ibmphp_rsrc_init()
274 … debug("1st Bus, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); in ibmphp_rsrc_init()
284 if ((curr->rsrc_type & RESTYPE) == MMASK) { in ibmphp_rsrc_init()
288 return -ENOMEM; in ibmphp_rsrc_init()
289 new_mem->type = MEM; in ibmphp_rsrc_init()
294 * assign a -1 and then update once the range in ibmphp_rsrc_init()
300 return -ENOMEM; in ibmphp_rsrc_init()
301 newbus->firstMem = new_mem; in ibmphp_rsrc_init()
302 ++newbus->needMemUpdate; in ibmphp_rsrc_init()
303 new_mem->rangeno = -1; in ibmphp_rsrc_init()
305 …emory resource for device %x, bus %x, [%x - %x]\n", new_mem->devfunc, new_mem->busno, new_mem->sta… in ibmphp_rsrc_init()
307 } else if ((curr->rsrc_type & RESTYPE) == PFMASK) { in ibmphp_rsrc_init()
311 return -ENOMEM; in ibmphp_rsrc_init()
312 new_pfmem->type = PFMEM; in ibmphp_rsrc_init()
313 new_pfmem->fromMem = 0; in ibmphp_rsrc_init()
317 return -ENOMEM; in ibmphp_rsrc_init()
318 newbus->firstPFMem = new_pfmem; in ibmphp_rsrc_init()
319 ++newbus->needPFMemUpdate; in ibmphp_rsrc_init()
320 new_pfmem->rangeno = -1; in ibmphp_rsrc_init()
323 …y resource for device %x, bus %x, [%x - %x]\n", new_pfmem->devfunc, new_pfmem->busno, new_pfmem->s… in ibmphp_rsrc_init()
324 } else if ((curr->rsrc_type & RESTYPE) == IOMASK) { in ibmphp_rsrc_init()
325 /* IO resource */ in ibmphp_rsrc_init()
328 return -ENOMEM; in ibmphp_rsrc_init()
329 new_io->type = IO; in ibmphp_rsrc_init()
335 * Can assign a -1 and then update once the in ibmphp_rsrc_init()
341 return -ENOMEM; in ibmphp_rsrc_init()
342 newbus->firstIO = new_io; in ibmphp_rsrc_init()
343 ++newbus->needIOUpdate; in ibmphp_rsrc_init()
344 new_io->rangeno = -1; in ibmphp_rsrc_init()
346 …debug("IO resource for device %x, bus %x, [%x - %x]\n", new_io->devfunc, new_io->busno, new_io->st… in ibmphp_rsrc_init()
357 return once_over(); /* This is to align ranges (so no -1) */ in ibmphp_rsrc_init()
366 * Output: 0 or -1, bus and range ptrs
376 case MEM: in add_bus_range()
377 range_cur = bus_cur->rangeMem; in add_bus_range()
378 noRanges = bus_cur->noMemRanges; in add_bus_range()
381 range_cur = bus_cur->rangePFMem; in add_bus_range()
382 noRanges = bus_cur->noPFMemRanges; in add_bus_range()
384 case IO: in add_bus_range()
385 range_cur = bus_cur->rangeIO; in add_bus_range()
386 noRanges = bus_cur->noIORanges; in add_bus_range()
392 if (range->start < range_cur->start) in add_bus_range()
395 range_cur = range_cur->next; in add_bus_range()
401 case MEM: in add_bus_range()
402 bus_cur->rangeMem = range; in add_bus_range()
405 bus_cur->rangePFMem = range; in add_bus_range()
407 case IO: in add_bus_range()
408 bus_cur->rangeIO = range; in add_bus_range()
411 range->next = range_cur; in add_bus_range()
412 range->rangeno = 1; in add_bus_range()
416 range->next = NULL; in add_bus_range()
417 range_prev->next = range; in add_bus_range()
418 range->rangeno = range_prev->rangeno + 1; in add_bus_range()
422 range_prev->next = range; in add_bus_range()
423 range->next = range_cur; in add_bus_range()
424 range->rangeno = range_cur->rangeno; in add_bus_range()
425 i_init = range_prev->rangeno; in add_bus_range()
429 ++range_cur->rangeno; in add_bus_range()
430 range_cur = range_cur->next; in add_bus_range()
449 case MEM: in update_resources()
450 if (bus_cur->firstMem) in update_resources()
451 res = bus_cur->firstMem; in update_resources()
454 if (bus_cur->firstPFMem) in update_resources()
455 res = bus_cur->firstPFMem; in update_resources()
457 case IO: in update_resources()
458 if (bus_cur->firstIO) in update_resources()
459 res = bus_cur->firstIO; in update_resources()
465 if (res->rangeno == rangeno) in update_resources()
467 if (res->next) in update_resources()
468 res = res->next; in update_resources()
469 else if (res->nextRange) in update_resources()
470 res = res->nextRange; in update_resources()
480 ++res->rangeno; in update_resources()
481 res = res->next; in update_resources()
490 switch (res->type) { in fix_me()
491 case IO: in fix_me()
492 str = "io"; in fix_me()
494 case MEM: in fix_me()
495 str = "mem"; in fix_me()
503 if (res->rangeno == -1) { in fix_me()
505 if ((res->start >= range->start) && (res->end <= range->end)) { in fix_me()
506 res->rangeno = range->rangeno; in fix_me()
507 debug("%s->rangeno in fix_resources is %d\n", str, res->rangeno); in fix_me()
508 switch (res->type) { in fix_me()
509 case IO: in fix_me()
510 --bus_cur->needIOUpdate; in fix_me()
512 case MEM: in fix_me()
513 --bus_cur->needMemUpdate; in fix_me()
516 --bus_cur->needPFMemUpdate; in fix_me()
521 range = range->next; in fix_me()
524 if (res->next) in fix_me()
525 res = res->next; in fix_me()
527 res = res->nextRange; in fix_me()
533 * This routine reassigns the range numbers to the resources that had a -1
536 * know the range, we assign -1, and this routine is called after a new range
547 debug("%s - bus_cur->busno = %d\n", __func__, bus_cur->busno); in fix_resources()
549 if (bus_cur->needIOUpdate) { in fix_resources()
550 res = bus_cur->firstIO; in fix_resources()
551 range = bus_cur->rangeIO; in fix_resources()
554 if (bus_cur->needMemUpdate) { in fix_resources()
555 res = bus_cur->firstMem; in fix_resources()
556 range = bus_cur->rangeMem; in fix_resources()
559 if (bus_cur->needPFMemUpdate) { in fix_resources()
560 res = bus_cur->firstPFMem; in fix_resources()
561 range = bus_cur->rangePFMem; in fix_resources()
573 * 0 or -1
583 debug("%s - enter\n", __func__); in ibmphp_add_resource()
587 return -ENODEV; in ibmphp_add_resource()
590 bus_cur = find_bus_wprev(res->busno, NULL, 0); in ibmphp_add_resource()
595 return -ENODEV; in ibmphp_add_resource()
599 switch (res->type) { in ibmphp_add_resource()
600 case IO: in ibmphp_add_resource()
601 range_cur = bus_cur->rangeIO; in ibmphp_add_resource()
602 res_start = bus_cur->firstIO; in ibmphp_add_resource()
604 case MEM: in ibmphp_add_resource()
605 range_cur = bus_cur->rangeMem; in ibmphp_add_resource()
606 res_start = bus_cur->firstMem; in ibmphp_add_resource()
609 range_cur = bus_cur->rangePFMem; in ibmphp_add_resource()
610 res_start = bus_cur->firstPFMem; in ibmphp_add_resource()
614 return -EINVAL; in ibmphp_add_resource()
617 if ((res->start >= range_cur->start) && (res->end <= range_cur->end)) { in ibmphp_add_resource()
618 res->rangeno = range_cur->rangeno; in ibmphp_add_resource()
621 range_cur = range_cur->next; in ibmphp_add_resource()
625 * this is again the case of rangeno = -1 in ibmphp_add_resource()
630 switch (res->type) { in ibmphp_add_resource()
631 case IO: in ibmphp_add_resource()
632 ++bus_cur->needIOUpdate; in ibmphp_add_resource()
634 case MEM: in ibmphp_add_resource()
635 ++bus_cur->needMemUpdate; in ibmphp_add_resource()
638 ++bus_cur->needPFMemUpdate; in ibmphp_add_resource()
641 res->rangeno = -1; in ibmphp_add_resource()
644 debug("The range is %d\n", res->rangeno); in ibmphp_add_resource()
646 /* no first{IO,Mem,Pfmem} on the bus, 1st IO/Mem/Pfmem resource ever */ in ibmphp_add_resource()
647 switch (res->type) { in ibmphp_add_resource()
648 case IO: in ibmphp_add_resource()
649 bus_cur->firstIO = res; in ibmphp_add_resource()
651 case MEM: in ibmphp_add_resource()
652 bus_cur->firstMem = res; in ibmphp_add_resource()
655 bus_cur->firstPFMem = res; in ibmphp_add_resource()
658 res->next = NULL; in ibmphp_add_resource()
659 res->nextRange = NULL; in ibmphp_add_resource()
664 debug("res_cur->rangeno is %d\n", res_cur->rangeno); in ibmphp_add_resource()
667 if (res_cur->rangeno >= res->rangeno) in ibmphp_add_resource()
670 if (res_cur->next) in ibmphp_add_resource()
671 res_cur = res_cur->next; in ibmphp_add_resource()
673 res_cur = res_cur->nextRange; in ibmphp_add_resource()
678 debug("i should be here, [%x - %x]\n", res->start, res->end); in ibmphp_add_resource()
679 res_prev->nextRange = res; in ibmphp_add_resource()
680 res->next = NULL; in ibmphp_add_resource()
681 res->nextRange = NULL; in ibmphp_add_resource()
682 } else if (res_cur->rangeno == res->rangeno) { in ibmphp_add_resource()
685 if (res->start < res_cur->start) in ibmphp_add_resource()
688 res_cur = res_cur->next; in ibmphp_add_resource()
692 res_prev->next = res; in ibmphp_add_resource()
693 res->next = NULL; in ibmphp_add_resource()
694 res->nextRange = res_prev->nextRange; in ibmphp_add_resource()
695 res_prev->nextRange = NULL; in ibmphp_add_resource()
696 } else if (res->start < res_cur->start) { in ibmphp_add_resource()
699 switch (res->type) { in ibmphp_add_resource()
700 case IO: in ibmphp_add_resource()
701 bus_cur->firstIO = res; in ibmphp_add_resource()
703 case MEM: in ibmphp_add_resource()
704 bus_cur->firstMem = res; in ibmphp_add_resource()
707 bus_cur->firstPFMem = res; in ibmphp_add_resource()
710 } else if (res_prev->rangeno == res_cur->rangeno) in ibmphp_add_resource()
711 res_prev->next = res; in ibmphp_add_resource()
713 res_prev->nextRange = res; in ibmphp_add_resource()
715 res->next = res_cur; in ibmphp_add_resource()
716 res->nextRange = NULL; in ibmphp_add_resource()
722 res->next = NULL; in ibmphp_add_resource()
723 switch (res->type) { in ibmphp_add_resource()
724 case IO: in ibmphp_add_resource()
725 res->nextRange = bus_cur->firstIO; in ibmphp_add_resource()
726 bus_cur->firstIO = res; in ibmphp_add_resource()
728 case MEM: in ibmphp_add_resource()
729 res->nextRange = bus_cur->firstMem; in ibmphp_add_resource()
730 bus_cur->firstMem = res; in ibmphp_add_resource()
733 res->nextRange = bus_cur->firstPFMem; in ibmphp_add_resource()
734 bus_cur->firstPFMem = res; in ibmphp_add_resource()
737 } else if (res_cur->rangeno > res->rangeno) { in ibmphp_add_resource()
739 res_prev->nextRange = res; in ibmphp_add_resource()
740 res->next = NULL; in ibmphp_add_resource()
741 res->nextRange = res_cur; in ibmphp_add_resource()
746 debug("%s - exit\n", __func__); in ibmphp_add_resource()
753 * Input: io, mem, and/or pfmem resource to be deleted
767 return -ENODEV; in ibmphp_remove_resource()
770 bus_cur = find_bus_wprev(res->busno, NULL, 0); in ibmphp_remove_resource()
773 err("cannot find corresponding bus of the io resource to remove bailing out...\n"); in ibmphp_remove_resource()
774 return -ENODEV; in ibmphp_remove_resource()
777 switch (res->type) { in ibmphp_remove_resource()
778 case IO: in ibmphp_remove_resource()
779 res_cur = bus_cur->firstIO; in ibmphp_remove_resource()
780 type = "io"; in ibmphp_remove_resource()
782 case MEM: in ibmphp_remove_resource()
783 res_cur = bus_cur->firstMem; in ibmphp_remove_resource()
784 type = "mem"; in ibmphp_remove_resource()
787 res_cur = bus_cur->firstPFMem; in ibmphp_remove_resource()
792 return -EINVAL; in ibmphp_remove_resource()
797 if ((res_cur->start == res->start) && (res_cur->end == res->end)) in ibmphp_remove_resource()
800 if (res_cur->next) in ibmphp_remove_resource()
801 res_cur = res_cur->next; in ibmphp_remove_resource()
803 res_cur = res_cur->nextRange; in ibmphp_remove_resource()
807 if (res->type == PFMEM) { in ibmphp_remove_resource()
810 * so will also need to remove the corresponding mem in ibmphp_remove_resource()
813 res_cur = bus_cur->firstPFMemFromMem; in ibmphp_remove_resource()
817 if ((res_cur->start == res->start) && (res_cur->end == res->end)) { in ibmphp_remove_resource()
818 mem_cur = bus_cur->firstMem; in ibmphp_remove_resource()
820 if ((mem_cur->start == res_cur->start) in ibmphp_remove_resource()
821 && (mem_cur->end == res_cur->end)) in ibmphp_remove_resource()
823 if (mem_cur->next) in ibmphp_remove_resource()
824 mem_cur = mem_cur->next; in ibmphp_remove_resource()
826 mem_cur = mem_cur->nextRange; in ibmphp_remove_resource()
829 err("cannot find corresponding mem node for pfmem...\n"); in ibmphp_remove_resource()
830 return -EINVAL; in ibmphp_remove_resource()
835 bus_cur->firstPFMemFromMem = res_cur->next; in ibmphp_remove_resource()
837 res_prev->next = res_cur->next; in ibmphp_remove_resource()
842 if (res_cur->next) in ibmphp_remove_resource()
843 res_cur = res_cur->next; in ibmphp_remove_resource()
845 res_cur = res_cur->nextRange; in ibmphp_remove_resource()
849 return -EINVAL; in ibmphp_remove_resource()
853 return -EINVAL; in ibmphp_remove_resource()
858 if (res_cur->next) { in ibmphp_remove_resource()
859 switch (res->type) { in ibmphp_remove_resource()
860 case IO: in ibmphp_remove_resource()
861 bus_cur->firstIO = res_cur->next; in ibmphp_remove_resource()
863 case MEM: in ibmphp_remove_resource()
864 bus_cur->firstMem = res_cur->next; in ibmphp_remove_resource()
867 bus_cur->firstPFMem = res_cur->next; in ibmphp_remove_resource()
870 } else if (res_cur->nextRange) { in ibmphp_remove_resource()
871 switch (res->type) { in ibmphp_remove_resource()
872 case IO: in ibmphp_remove_resource()
873 bus_cur->firstIO = res_cur->nextRange; in ibmphp_remove_resource()
875 case MEM: in ibmphp_remove_resource()
876 bus_cur->firstMem = res_cur->nextRange; in ibmphp_remove_resource()
879 bus_cur->firstPFMem = res_cur->nextRange; in ibmphp_remove_resource()
883 switch (res->type) { in ibmphp_remove_resource()
884 case IO: in ibmphp_remove_resource()
885 bus_cur->firstIO = NULL; in ibmphp_remove_resource()
887 case MEM: in ibmphp_remove_resource()
888 bus_cur->firstMem = NULL; in ibmphp_remove_resource()
891 bus_cur->firstPFMem = NULL; in ibmphp_remove_resource()
898 if (res_cur->next) { in ibmphp_remove_resource()
899 if (res_prev->rangeno == res_cur->rangeno) in ibmphp_remove_resource()
900 res_prev->next = res_cur->next; in ibmphp_remove_resource()
902 res_prev->nextRange = res_cur->next; in ibmphp_remove_resource()
903 } else if (res_cur->nextRange) { in ibmphp_remove_resource()
904 res_prev->next = NULL; in ibmphp_remove_resource()
905 res_prev->nextRange = res_cur->nextRange; in ibmphp_remove_resource()
907 res_prev->next = NULL; in ibmphp_remove_resource()
908 res_prev->nextRange = NULL; in ibmphp_remove_resource()
921 switch (res->type) { in find_range()
922 case IO: in find_range()
923 range = bus_cur->rangeIO; in find_range()
925 case MEM: in find_range()
926 range = bus_cur->rangeMem; in find_range()
929 range = bus_cur->rangePFMem; in find_range()
936 if (res->rangeno == range->rangeno) in find_range()
938 range = range->next; in find_range()
944 * This routine will check to make sure the io/mem/pfmem->len that the device asked for
945 * can fit w/i our list of available IO/MEM/PFMEM resources. If cannot, returns -EINVAL,
950 * 0 or -EINVAL
965 return -EINVAL; in ibmphp_check_resource()
968 /* The rules for bridges are different, 4K divisible for IO, 1M for (pf)mem*/ in ibmphp_check_resource()
969 if (res->type == IO) in ibmphp_check_resource()
974 tmp_divide = res->len; in ibmphp_check_resource()
976 bus_cur = find_bus_wprev(res->busno, NULL, 0); in ibmphp_check_resource()
981 return -EINVAL; in ibmphp_check_resource()
984 debug("%s - enter\n", __func__); in ibmphp_check_resource()
985 debug("bus_cur->busno is %d\n", bus_cur->busno); in ibmphp_check_resource()
988 * 2000-2fff, len = 1000, but when we compare, we need it to be fff */ in ibmphp_check_resource()
989 res->len -= 1; in ibmphp_check_resource()
991 switch (res->type) { in ibmphp_check_resource()
992 case IO: in ibmphp_check_resource()
993 res_cur = bus_cur->firstIO; in ibmphp_check_resource()
994 noranges = bus_cur->noIORanges; in ibmphp_check_resource()
996 case MEM: in ibmphp_check_resource()
997 res_cur = bus_cur->firstMem; in ibmphp_check_resource()
998 noranges = bus_cur->noMemRanges; in ibmphp_check_resource()
1001 res_cur = bus_cur->firstPFMem; in ibmphp_check_resource()
1002 noranges = bus_cur->noPFMemRanges; in ibmphp_check_resource()
1006 return -EINVAL; in ibmphp_check_resource()
1012 debug("%s - rangeno = %d\n", __func__, res_cur->rangeno); in ibmphp_check_resource()
1016 return -EINVAL; in ibmphp_check_resource()
1022 len_tmp = res_cur->start - 1 - range->start; in ibmphp_check_resource()
1024 if ((res_cur->start != range->start) && (len_tmp >= res->len)) { in ibmphp_check_resource()
1029 if ((range->start % tmp_divide) == 0) { in ibmphp_check_resource()
1033 start_cur = range->start; in ibmphp_check_resource()
1036 tmp_start = range->start; in ibmphp_check_resource()
1039 while ((len_tmp = res_cur->start - 1 - tmp_start) >= res->len) { in ibmphp_check_resource()
1046 tmp_start += tmp_divide - tmp_start % tmp_divide; in ibmphp_check_resource()
1047 if (tmp_start >= res_cur->start - 1) in ibmphp_check_resource()
1052 if (flag && len_cur == res->len) { in ibmphp_check_resource()
1054 res->start = start_cur; in ibmphp_check_resource()
1055 res->len += 1; /* To restore the balance */ in ibmphp_check_resource()
1056 res->end = res->start + res->len - 1; in ibmphp_check_resource()
1062 if (!res_cur->next) { in ibmphp_check_resource()
1064 len_tmp = range->end - (res_cur->end + 1); in ibmphp_check_resource()
1066 if ((range->end != res_cur->end) && (len_tmp >= res->len)) { in ibmphp_check_resource()
1070 if (((res_cur->end + 1) % tmp_divide) == 0) { in ibmphp_check_resource()
1074 start_cur = res_cur->end + 1; in ibmphp_check_resource()
1077 tmp_start = res_cur->end + 1; in ibmphp_check_resource()
1080 while ((len_tmp = range->end - tmp_start) >= res->len) { in ibmphp_check_resource()
1087 tmp_start += tmp_divide - tmp_start % tmp_divide; in ibmphp_check_resource()
1088 if (tmp_start >= range->end) in ibmphp_check_resource()
1092 if (flag && len_cur == res->len) { in ibmphp_check_resource()
1093 res->start = start_cur; in ibmphp_check_resource()
1094 res->len += 1; /* To restore the balance */ in ibmphp_check_resource()
1095 res->end = res->start + res->len - 1; in ibmphp_check_resource()
1103 if (res_prev->rangeno != res_cur->rangeno) { in ibmphp_check_resource()
1105 len_tmp = res_cur->start - 1 - range->start; in ibmphp_check_resource()
1107 if ((res_cur->start != range->start) && (len_tmp >= res->len)) { in ibmphp_check_resource()
1109 if ((range->start % tmp_divide) == 0) { in ibmphp_check_resource()
1113 start_cur = range->start; in ibmphp_check_resource()
1116 tmp_start = range->start; in ibmphp_check_resource()
1119 while ((len_tmp = res_cur->start - 1 - tmp_start) >= res->len) { in ibmphp_check_resource()
1126 tmp_start += tmp_divide - tmp_start % tmp_divide; in ibmphp_check_resource()
1127 if (tmp_start >= res_cur->start - 1) in ibmphp_check_resource()
1132 if (flag && len_cur == res->len) { in ibmphp_check_resource()
1133 res->start = start_cur; in ibmphp_check_resource()
1134 res->len += 1; /* To restore the balance */ in ibmphp_check_resource()
1135 res->end = res->start + res->len - 1; in ibmphp_check_resource()
1142 len_tmp = res_cur->start - 1 - res_prev->end - 1; in ibmphp_check_resource()
1144 if (len_tmp >= res->len) { in ibmphp_check_resource()
1146 if (((res_prev->end + 1) % tmp_divide) == 0) { in ibmphp_check_resource()
1150 start_cur = res_prev->end + 1; in ibmphp_check_resource()
1153 tmp_start = res_prev->end + 1; in ibmphp_check_resource()
1156 while ((len_tmp = res_cur->start - 1 - tmp_start) >= res->len) { in ibmphp_check_resource()
1163 tmp_start += tmp_divide - tmp_start % tmp_divide; in ibmphp_check_resource()
1164 if (tmp_start >= res_cur->start - 1) in ibmphp_check_resource()
1169 if (flag && len_cur == res->len) { in ibmphp_check_resource()
1170 res->start = start_cur; in ibmphp_check_resource()
1171 res->len += 1; /* To restore the balance */ in ibmphp_check_resource()
1172 res->end = res->start + res->len - 1; in ibmphp_check_resource()
1181 if (res_cur->next) in ibmphp_check_resource()
1182 res_cur = res_cur->next; in ibmphp_check_resource()
1184 res_cur = res_cur->nextRange; in ibmphp_check_resource()
1191 switch (res->type) { in ibmphp_check_resource()
1192 case IO: in ibmphp_check_resource()
1193 range = bus_cur->rangeIO; in ibmphp_check_resource()
1195 case MEM: in ibmphp_check_resource()
1196 range = bus_cur->rangeMem; in ibmphp_check_resource()
1199 range = bus_cur->rangePFMem; in ibmphp_check_resource()
1203 len_tmp = range->end - range->start; in ibmphp_check_resource()
1205 if (len_tmp >= res->len) { in ibmphp_check_resource()
1207 if ((range->start % tmp_divide) == 0) { in ibmphp_check_resource()
1211 start_cur = range->start; in ibmphp_check_resource()
1214 tmp_start = range->start; in ibmphp_check_resource()
1217 while ((len_tmp = range->end - tmp_start) >= res->len) { in ibmphp_check_resource()
1224 tmp_start += tmp_divide - tmp_start % tmp_divide; in ibmphp_check_resource()
1225 if (tmp_start >= range->end) in ibmphp_check_resource()
1230 if (flag && len_cur == res->len) { in ibmphp_check_resource()
1231 res->start = start_cur; in ibmphp_check_resource()
1232 res->len += 1; /* To restore the balance */ in ibmphp_check_resource()
1233 res->end = res->start + res->len - 1; in ibmphp_check_resource()
1238 range = range->next; in ibmphp_check_resource()
1244 return -EINVAL; in ibmphp_check_resource()
1246 res->start = start_cur; in ibmphp_check_resource()
1247 res->len += 1; /* To restore the balance */ in ibmphp_check_resource()
1248 res->end = res->start + res->len - 1; in ibmphp_check_resource()
1254 debug("prev->rangeno = %d, noranges = %d\n", res_prev->rangeno, noranges); in ibmphp_check_resource()
1255 if (res_prev->rangeno < noranges) { in ibmphp_check_resource()
1257 switch (res->type) { in ibmphp_check_resource()
1258 case IO: in ibmphp_check_resource()
1259 range = bus_cur->rangeIO; in ibmphp_check_resource()
1261 case MEM: in ibmphp_check_resource()
1262 range = bus_cur->rangeMem; in ibmphp_check_resource()
1265 range = bus_cur->rangePFMem; in ibmphp_check_resource()
1269 len_tmp = range->end - range->start; in ibmphp_check_resource()
1271 if (len_tmp >= res->len) { in ibmphp_check_resource()
1273 if ((range->start % tmp_divide) == 0) { in ibmphp_check_resource()
1277 start_cur = range->start; in ibmphp_check_resource()
1280 tmp_start = range->start; in ibmphp_check_resource()
1283 while ((len_tmp = range->end - tmp_start) >= res->len) { in ibmphp_check_resource()
1290 tmp_start += tmp_divide - tmp_start % tmp_divide; in ibmphp_check_resource()
1291 if (tmp_start >= range->end) in ibmphp_check_resource()
1296 if (flag && len_cur == res->len) { in ibmphp_check_resource()
1297 res->start = start_cur; in ibmphp_check_resource()
1298 res->len += 1; /* To restore the balance */ in ibmphp_check_resource()
1299 res->end = res->start + res->len - 1; in ibmphp_check_resource()
1304 range = range->next; in ibmphp_check_resource()
1310 return -EINVAL; in ibmphp_check_resource()
1312 res->start = start_cur; in ibmphp_check_resource()
1313 res->len += 1; /* To restore the balance */ in ibmphp_check_resource()
1314 res->end = res->start + res->len - 1; in ibmphp_check_resource()
1320 res->start = start_cur; in ibmphp_check_resource()
1321 res->len += 1; /* To restore the balance */ in ibmphp_check_resource()
1322 res->end = res->start + res->len - 1; in ibmphp_check_resource()
1327 return -EINVAL; in ibmphp_check_resource()
1331 return -EINVAL; in ibmphp_check_resource()
1338 * Output: 0, -ENODEV
1351 return -ENODEV; in ibmphp_remove_bus()
1354 debug("In ibmphp_remove_bus... prev_bus->busno is %x\n", prev_bus->busno); in ibmphp_remove_bus()
1360 if (bus->firstIO) { in ibmphp_remove_bus()
1361 res_cur = bus->firstIO; in ibmphp_remove_bus()
1364 if (res_cur->next) in ibmphp_remove_bus()
1365 res_cur = res_cur->next; in ibmphp_remove_bus()
1367 res_cur = res_cur->nextRange; in ibmphp_remove_bus()
1371 bus->firstIO = NULL; in ibmphp_remove_bus()
1373 if (bus->firstMem) { in ibmphp_remove_bus()
1374 res_cur = bus->firstMem; in ibmphp_remove_bus()
1377 if (res_cur->next) in ibmphp_remove_bus()
1378 res_cur = res_cur->next; in ibmphp_remove_bus()
1380 res_cur = res_cur->nextRange; in ibmphp_remove_bus()
1384 bus->firstMem = NULL; in ibmphp_remove_bus()
1386 if (bus->firstPFMem) { in ibmphp_remove_bus()
1387 res_cur = bus->firstPFMem; in ibmphp_remove_bus()
1390 if (res_cur->next) in ibmphp_remove_bus()
1391 res_cur = res_cur->next; in ibmphp_remove_bus()
1393 res_cur = res_cur->nextRange; in ibmphp_remove_bus()
1397 bus->firstPFMem = NULL; in ibmphp_remove_bus()
1400 if (bus->firstPFMemFromMem) { in ibmphp_remove_bus()
1401 res_cur = bus->firstPFMemFromMem; in ibmphp_remove_bus()
1404 res_cur = res_cur->next; in ibmphp_remove_bus()
1409 bus->firstPFMemFromMem = NULL; in ibmphp_remove_bus()
1412 list_del(&bus->bus_list); in ibmphp_remove_bus()
1421 * Output: 0, -EINVAL
1430 if (bus_cur->noIORanges) { in remove_ranges()
1431 range_cur = bus_cur->rangeIO; in remove_ranges()
1432 for (i = 0; i < bus_cur->noIORanges; i++) { in remove_ranges()
1433 if (ibmphp_find_resource(bus_prev, range_cur->start, &res, IO) < 0) in remove_ranges()
1434 return -EINVAL; in remove_ranges()
1438 range_cur = range_cur->next; in remove_ranges()
1442 bus_cur->rangeIO = NULL; in remove_ranges()
1444 if (bus_cur->noMemRanges) { in remove_ranges()
1445 range_cur = bus_cur->rangeMem; in remove_ranges()
1446 for (i = 0; i < bus_cur->noMemRanges; i++) { in remove_ranges()
1447 if (ibmphp_find_resource(bus_prev, range_cur->start, &res, MEM) < 0) in remove_ranges()
1448 return -EINVAL; in remove_ranges()
1452 range_cur = range_cur->next; in remove_ranges()
1456 bus_cur->rangeMem = NULL; in remove_ranges()
1458 if (bus_cur->noPFMemRanges) { in remove_ranges()
1459 range_cur = bus_cur->rangePFMem; in remove_ranges()
1460 for (i = 0; i < bus_cur->noPFMemRanges; i++) { in remove_ranges()
1461 if (ibmphp_find_resource(bus_prev, range_cur->start, &res, PFMEM) < 0) in remove_ranges()
1462 return -EINVAL; in remove_ranges()
1466 range_cur = range_cur->next; in remove_ranges()
1470 bus_cur->rangePFMem = NULL; in remove_ranges()
1486 return -ENODEV; in ibmphp_find_resource()
1490 case IO: in ibmphp_find_resource()
1491 res_cur = bus->firstIO; in ibmphp_find_resource()
1492 type = "io"; in ibmphp_find_resource()
1494 case MEM: in ibmphp_find_resource()
1495 res_cur = bus->firstMem; in ibmphp_find_resource()
1496 type = "mem"; in ibmphp_find_resource()
1499 res_cur = bus->firstPFMem; in ibmphp_find_resource()
1504 return -EINVAL; in ibmphp_find_resource()
1508 if (res_cur->start == start_address) { in ibmphp_find_resource()
1512 if (res_cur->next) in ibmphp_find_resource()
1513 res_cur = res_cur->next; in ibmphp_find_resource()
1515 res_cur = res_cur->nextRange; in ibmphp_find_resource()
1520 res_cur = bus->firstPFMemFromMem; in ibmphp_find_resource()
1522 if (res_cur->start == start_address) { in ibmphp_find_resource()
1526 res_cur = res_cur->next; in ibmphp_find_resource()
1530 return -EINVAL; in ibmphp_find_resource()
1534 return -EINVAL; in ibmphp_find_resource()
1539 debug("*res->start = %x\n", (*res)->start); in ibmphp_find_resource()
1562 if (bus_cur->noIORanges) { in ibmphp_free_resources()
1563 range_cur = bus_cur->rangeIO; in ibmphp_free_resources()
1564 for (i = 0; i < bus_cur->noIORanges; i++) { in ibmphp_free_resources()
1568 range_cur = range_cur->next; in ibmphp_free_resources()
1573 if (bus_cur->noMemRanges) { in ibmphp_free_resources()
1574 range_cur = bus_cur->rangeMem; in ibmphp_free_resources()
1575 for (i = 0; i < bus_cur->noMemRanges; i++) { in ibmphp_free_resources()
1579 range_cur = range_cur->next; in ibmphp_free_resources()
1584 if (bus_cur->noPFMemRanges) { in ibmphp_free_resources()
1585 range_cur = bus_cur->rangePFMem; in ibmphp_free_resources()
1586 for (i = 0; i < bus_cur->noPFMemRanges; i++) { in ibmphp_free_resources()
1590 range_cur = range_cur->next; in ibmphp_free_resources()
1596 if (bus_cur->firstIO) { in ibmphp_free_resources()
1597 res_cur = bus_cur->firstIO; in ibmphp_free_resources()
1600 if (res_cur->next) in ibmphp_free_resources()
1601 res_cur = res_cur->next; in ibmphp_free_resources()
1603 res_cur = res_cur->nextRange; in ibmphp_free_resources()
1607 bus_cur->firstIO = NULL; in ibmphp_free_resources()
1609 if (bus_cur->firstMem) { in ibmphp_free_resources()
1610 res_cur = bus_cur->firstMem; in ibmphp_free_resources()
1613 if (res_cur->next) in ibmphp_free_resources()
1614 res_cur = res_cur->next; in ibmphp_free_resources()
1616 res_cur = res_cur->nextRange; in ibmphp_free_resources()
1620 bus_cur->firstMem = NULL; in ibmphp_free_resources()
1622 if (bus_cur->firstPFMem) { in ibmphp_free_resources()
1623 res_cur = bus_cur->firstPFMem; in ibmphp_free_resources()
1626 if (res_cur->next) in ibmphp_free_resources()
1627 res_cur = res_cur->next; in ibmphp_free_resources()
1629 res_cur = res_cur->nextRange; in ibmphp_free_resources()
1633 bus_cur->firstPFMem = NULL; in ibmphp_free_resources()
1636 if (bus_cur->firstPFMemFromMem) { in ibmphp_free_resources()
1637 res_cur = bus_cur->firstPFMemFromMem; in ibmphp_free_resources()
1640 res_cur = res_cur->next; in ibmphp_free_resources()
1645 bus_cur->firstPFMemFromMem = NULL; in ibmphp_free_resources()
1649 list_del(&bus_cur->bus_list); in ibmphp_free_resources()
1660 * a new Mem node
1667 struct resource_node *mem; in once_over() local
1671 if ((!bus_cur->rangePFMem) && (bus_cur->firstPFMem)) { in once_over()
1672 …for (pfmem_cur = bus_cur->firstPFMem, pfmem_prev = NULL; pfmem_cur; pfmem_prev = pfmem_cur, pfmem_… in once_over()
1673 pfmem_cur->fromMem = 1; in once_over()
1675 pfmem_prev->next = pfmem_cur->next; in once_over()
1677 bus_cur->firstPFMem = pfmem_cur->next; in once_over()
1679 if (!bus_cur->firstPFMemFromMem) in once_over()
1680 pfmem_cur->next = NULL; in once_over()
1682 /* we don't need to sort PFMemFromMem since we're using mem node for in once_over()
1686 pfmem_cur->next = bus_cur->firstPFMemFromMem; in once_over()
1688 bus_cur->firstPFMemFromMem = pfmem_cur; in once_over()
1690 mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); in once_over()
1691 if (!mem) in once_over()
1692 return -ENOMEM; in once_over()
1694 mem->type = MEM; in once_over()
1695 mem->busno = pfmem_cur->busno; in once_over()
1696 mem->devfunc = pfmem_cur->devfunc; in once_over()
1697 mem->start = pfmem_cur->start; in once_over()
1698 mem->end = pfmem_cur->end; in once_over()
1699 mem->len = pfmem_cur->len; in once_over()
1700 if (ibmphp_add_resource(mem) < 0) in once_over()
1701 …err("Trouble...trouble... EBDA allocated pfmem from mem, but system doesn't display it has this sp… in once_over()
1702 pfmem_cur->rangeno = mem->rangeno; in once_over()
1711 struct bus_node *bus_cur = find_bus_wprev(pfmem->busno, NULL, 0); in ibmphp_add_pfmem_from_mem()
1715 return -ENODEV; in ibmphp_add_pfmem_from_mem()
1718 if (bus_cur->firstPFMemFromMem) in ibmphp_add_pfmem_from_mem()
1719 pfmem->next = bus_cur->firstPFMemFromMem; in ibmphp_add_pfmem_from_mem()
1721 pfmem->next = NULL; in ibmphp_add_pfmem_from_mem()
1723 bus_cur->firstPFMemFromMem = pfmem; in ibmphp_add_pfmem_from_mem()
1746 if (bus_cur->busno == bus_number) in find_bus_wprev()
1768 debug_pci ("This is bus # %d. There are\n", bus_cur->busno); in ibmphp_print_test()
1769 debug_pci ("IORanges = %d\t", bus_cur->noIORanges); in ibmphp_print_test()
1770 debug_pci ("MemRanges = %d\t", bus_cur->noMemRanges); in ibmphp_print_test()
1771 debug_pci ("PFMemRanges = %d\n", bus_cur->noPFMemRanges); in ibmphp_print_test()
1772 debug_pci ("The IO Ranges are as follows:\n"); in ibmphp_print_test()
1773 if (bus_cur->rangeIO) { in ibmphp_print_test()
1774 range = bus_cur->rangeIO; in ibmphp_print_test()
1775 for (i = 0; i < bus_cur->noIORanges; i++) { in ibmphp_print_test()
1776 debug_pci("rangeno is %d\n", range->rangeno); in ibmphp_print_test()
1777 debug_pci("[%x - %x]\n", range->start, range->end); in ibmphp_print_test()
1778 range = range->next; in ibmphp_print_test()
1782 debug_pci("The Mem Ranges are as follows:\n"); in ibmphp_print_test()
1783 if (bus_cur->rangeMem) { in ibmphp_print_test()
1784 range = bus_cur->rangeMem; in ibmphp_print_test()
1785 for (i = 0; i < bus_cur->noMemRanges; i++) { in ibmphp_print_test()
1786 debug_pci("rangeno is %d\n", range->rangeno); in ibmphp_print_test()
1787 debug_pci("[%x - %x]\n", range->start, range->end); in ibmphp_print_test()
1788 range = range->next; in ibmphp_print_test()
1794 if (bus_cur->rangePFMem) { in ibmphp_print_test()
1795 range = bus_cur->rangePFMem; in ibmphp_print_test()
1796 for (i = 0; i < bus_cur->noPFMemRanges; i++) { in ibmphp_print_test()
1797 debug_pci("rangeno is %d\n", range->rangeno); in ibmphp_print_test()
1798 debug_pci("[%x - %x]\n", range->start, range->end); in ibmphp_print_test()
1799 range = range->next; in ibmphp_print_test()
1805 debug_pci("IO...\n"); in ibmphp_print_test()
1806 if (bus_cur->firstIO) { in ibmphp_print_test()
1807 res = bus_cur->firstIO; in ibmphp_print_test()
1809 debug_pci("The range # is %d\n", res->rangeno); in ibmphp_print_test()
1810 debug_pci("The bus, devfnc is %d, %x\n", res->busno, res->devfunc); in ibmphp_print_test()
1811 debug_pci("[%x - %x], len=%x\n", res->start, res->end, res->len); in ibmphp_print_test()
1812 if (res->next) in ibmphp_print_test()
1813 res = res->next; in ibmphp_print_test()
1814 else if (res->nextRange) in ibmphp_print_test()
1815 res = res->nextRange; in ibmphp_print_test()
1820 debug_pci("Mem...\n"); in ibmphp_print_test()
1821 if (bus_cur->firstMem) { in ibmphp_print_test()
1822 res = bus_cur->firstMem; in ibmphp_print_test()
1824 debug_pci("The range # is %d\n", res->rangeno); in ibmphp_print_test()
1825 debug_pci("The bus, devfnc is %d, %x\n", res->busno, res->devfunc); in ibmphp_print_test()
1826 debug_pci("[%x - %x], len=%x\n", res->start, res->end, res->len); in ibmphp_print_test()
1827 if (res->next) in ibmphp_print_test()
1828 res = res->next; in ibmphp_print_test()
1829 else if (res->nextRange) in ibmphp_print_test()
1830 res = res->nextRange; in ibmphp_print_test()
1836 if (bus_cur->firstPFMem) { in ibmphp_print_test()
1837 res = bus_cur->firstPFMem; in ibmphp_print_test()
1839 debug_pci("The range # is %d\n", res->rangeno); in ibmphp_print_test()
1840 debug_pci("The bus, devfnc is %d, %x\n", res->busno, res->devfunc); in ibmphp_print_test()
1841 debug_pci("[%x - %x], len=%x\n", res->start, res->end, res->len); in ibmphp_print_test()
1842 if (res->next) in ibmphp_print_test()
1843 res = res->next; in ibmphp_print_test()
1844 else if (res->nextRange) in ibmphp_print_test()
1845 res = res->nextRange; in ibmphp_print_test()
1852 if (bus_cur->firstPFMemFromMem) { in ibmphp_print_test()
1853 res = bus_cur->firstPFMemFromMem; in ibmphp_print_test()
1855 debug_pci("The range # is %d\n", res->rangeno); in ibmphp_print_test()
1856 debug_pci("The bus, devfnc is %d, %x\n", res->busno, res->devfunc); in ibmphp_print_test()
1857 debug_pci("[%x - %x], len=%x\n", res->start, res->end, res->len); in ibmphp_print_test()
1858 res = res->next; in ibmphp_print_test()
1869 case IO: in range_exists_already()
1870 range_cur = bus_cur->rangeIO; in range_exists_already()
1872 case MEM: in range_exists_already()
1873 range_cur = bus_cur->rangeMem; in range_exists_already()
1876 range_cur = bus_cur->rangePFMem; in range_exists_already()
1880 return -ENODEV; in range_exists_already()
1884 if ((range_cur->start == range->start) && (range_cur->end == range->end)) in range_exists_already()
1886 range_cur = range_cur->next; in range_exists_already()
1900 * Note: this function doesn't take into account IO restrictions etc,
1913 struct resource_node *io; in update_bridge_ranges() local
1914 struct resource_node *mem; in update_bridge_ranges() local
1921 return -ENODEV; in update_bridge_ranges()
1922 ibmphp_pci_bus->number = bus_cur->busno; in update_bridge_ranges()
1925 debug("bus_cur->busno = %x\n", bus_cur->busno); in update_bridge_ranges()
1974 return -ENOMEM; in update_bridge_ranges()
1976 range->start = start_address; in update_bridge_ranges()
1977 range->end = end_address + 0xfff; in update_bridge_ranges()
1979 if (bus_sec->noIORanges > 0) { in update_bridge_ranges()
1980 if (!range_exists_already(range, bus_sec, IO)) { in update_bridge_ranges()
1981 add_bus_range(IO, range, bus_sec); in update_bridge_ranges()
1982 ++bus_sec->noIORanges; in update_bridge_ranges()
1988 /* 1st IO Range on the bus */ in update_bridge_ranges()
1989 range->rangeno = 1; in update_bridge_ranges()
1990 bus_sec->rangeIO = range; in update_bridge_ranges()
1991 ++bus_sec->noIORanges; in update_bridge_ranges()
1995 if (ibmphp_find_resource(bus_cur, start_address, &io, IO)) { in update_bridge_ranges()
1996 io = kzalloc(sizeof(struct resource_node), GFP_KERNEL); in update_bridge_ranges()
1997 if (!io) { in update_bridge_ranges()
1999 return -ENOMEM; in update_bridge_ranges()
2001 io->type = IO; in update_bridge_ranges()
2002 io->busno = bus_cur->busno; in update_bridge_ranges()
2003 io->devfunc = ((device << 3) | (function & 0x7)); in update_bridge_ranges()
2004 io->start = start_address; in update_bridge_ranges()
2005 io->end = end_address + 0xfff; in update_bridge_ranges()
2006 io->len = io->end - io->start + 1; in update_bridge_ranges()
2007 ibmphp_add_resource(io); in update_bridge_ranges()
2021 return -ENOMEM; in update_bridge_ranges()
2023 range->start = start_address; in update_bridge_ranges()
2024 range->end = end_address + 0xfffff; in update_bridge_ranges()
2026 if (bus_sec->noMemRanges > 0) { in update_bridge_ranges()
2027 if (!range_exists_already(range, bus_sec, MEM)) { in update_bridge_ranges()
2028 add_bus_range(MEM, range, bus_sec); in update_bridge_ranges()
2029 ++bus_sec->noMemRanges; in update_bridge_ranges()
2035 /* 1st Mem Range on the bus */ in update_bridge_ranges()
2036 range->rangeno = 1; in update_bridge_ranges()
2037 bus_sec->rangeMem = range; in update_bridge_ranges()
2038 ++bus_sec->noMemRanges; in update_bridge_ranges()
2043 if (ibmphp_find_resource(bus_cur, start_address, &mem, MEM)) { in update_bridge_ranges()
2044 mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); in update_bridge_ranges()
2045 if (!mem) { in update_bridge_ranges()
2047 return -ENOMEM; in update_bridge_ranges()
2049 mem->type = MEM; in update_bridge_ranges()
2050 mem->busno = bus_cur->busno; in update_bridge_ranges()
2051 mem->devfunc = ((device << 3) | (function & 0x7)); in update_bridge_ranges()
2052 mem->start = start_address; in update_bridge_ranges()
2053 mem->end = end_address + 0xfffff; in update_bridge_ranges()
2054 mem->len = mem->end - mem->start + 1; in update_bridge_ranges()
2055 ibmphp_add_resource(mem); in update_bridge_ranges()
2073 return -ENOMEM; in update_bridge_ranges()
2075 range->start = start_address; in update_bridge_ranges()
2076 range->end = end_address + 0xfffff; in update_bridge_ranges()
2078 if (bus_sec->noPFMemRanges > 0) { in update_bridge_ranges()
2081 ++bus_sec->noPFMemRanges; in update_bridge_ranges()
2088 range->rangeno = 1; in update_bridge_ranges()
2089 bus_sec->rangePFMem = range; in update_bridge_ranges()
2090 ++bus_sec->noPFMemRanges; in update_bridge_ranges()
2098 return -ENOMEM; in update_bridge_ranges()
2100 pfmem->type = PFMEM; in update_bridge_ranges()
2101 pfmem->busno = bus_cur->busno; in update_bridge_ranges()
2102 pfmem->devfunc = ((device << 3) | (function & 0x7)); in update_bridge_ranges()
2103 pfmem->start = start_address; in update_bridge_ranges()
2104 pfmem->end = end_address + 0xfffff; in update_bridge_ranges()
2105 pfmem->len = pfmem->end - pfmem->start + 1; in update_bridge_ranges()
2106 pfmem->fromMem = 0; in update_bridge_ranges()