setup-bus.c (be768912a49b10b68e96fbd8fa3cab0adfbd3091) | setup-bus.c (2bbc6942273b5b3097bd265d82227bdd84b351b2) |
---|---|
1/* 2 * drivers/pci/setup-bus.c 3 * 4 * Extruded from code written by 5 * Dave Rusling (david.rusling@reo.mts.dec.com) 6 * David Mosberger (davidm@cs.arizona.edu) 7 * David Miller (davem@redhat.com) 8 * --- 20 unchanged lines hidden (view full) --- 29 30struct resource_list_x { 31 struct resource_list_x *next; 32 struct resource *res; 33 struct pci_dev *dev; 34 resource_size_t start; 35 resource_size_t end; 36 resource_size_t add_size; | 1/* 2 * drivers/pci/setup-bus.c 3 * 4 * Extruded from code written by 5 * Dave Rusling (david.rusling@reo.mts.dec.com) 6 * David Mosberger (davidm@cs.arizona.edu) 7 * David Miller (davem@redhat.com) 8 * --- 20 unchanged lines hidden (view full) --- 29 30struct resource_list_x { 31 struct resource_list_x *next; 32 struct resource *res; 33 struct pci_dev *dev; 34 resource_size_t start; 35 resource_size_t end; 36 resource_size_t add_size; |
37 resource_size_t min_align; |
|
37 unsigned long flags; 38}; 39 40#define free_list(type, head) do { \ 41 struct type *list, *tmp; \ 42 for (list = (head)->next; list;) { \ 43 tmp = list; \ 44 list = list->next; \ --- 15 unchanged lines hidden (view full) --- 60 * @dev: device corresponding to which the resource 61 * belongs 62 * @res: The resource to be tracked 63 * @add_size: additional size to be optionally added 64 * to the resource 65 */ 66static void add_to_list(struct resource_list_x *head, 67 struct pci_dev *dev, struct resource *res, | 38 unsigned long flags; 39}; 40 41#define free_list(type, head) do { \ 42 struct type *list, *tmp; \ 43 for (list = (head)->next; list;) { \ 44 tmp = list; \ 45 list = list->next; \ --- 15 unchanged lines hidden (view full) --- 61 * @dev: device corresponding to which the resource 62 * belongs 63 * @res: The resource to be tracked 64 * @add_size: additional size to be optionally added 65 * to the resource 66 */ 67static void add_to_list(struct resource_list_x *head, 68 struct pci_dev *dev, struct resource *res, |
68 resource_size_t add_size) | 69 resource_size_t add_size, resource_size_t min_align) |
69{ 70 struct resource_list_x *list = head; 71 struct resource_list_x *ln = list->next; 72 struct resource_list_x *tmp; 73 74 tmp = kmalloc(sizeof(*tmp), GFP_KERNEL); 75 if (!tmp) { 76 pr_warning("add_to_list: kmalloc() failed!\n"); 77 return; 78 } 79 80 tmp->next = ln; 81 tmp->res = res; 82 tmp->dev = dev; 83 tmp->start = res->start; 84 tmp->end = res->end; 85 tmp->flags = res->flags; 86 tmp->add_size = add_size; | 70{ 71 struct resource_list_x *list = head; 72 struct resource_list_x *ln = list->next; 73 struct resource_list_x *tmp; 74 75 tmp = kmalloc(sizeof(*tmp), GFP_KERNEL); 76 if (!tmp) { 77 pr_warning("add_to_list: kmalloc() failed!\n"); 78 return; 79 } 80 81 tmp->next = ln; 82 tmp->res = res; 83 tmp->dev = dev; 84 tmp->start = res->start; 85 tmp->end = res->end; 86 tmp->flags = res->flags; 87 tmp->add_size = add_size; |
88 tmp->min_align = min_align; |
|
87 list->next = tmp; 88} 89 90static void add_to_failed_list(struct resource_list_x *head, 91 struct pci_dev *dev, struct resource *res) 92{ | 89 list->next = tmp; 90} 91 92static void add_to_failed_list(struct resource_list_x *head, 93 struct pci_dev *dev, struct resource *res) 94{ |
93 add_to_list(head, dev, res, 0); | 95 add_to_list(head, dev, res, 96 0 /* dont care */, 97 0 /* dont care */); |
94} 95 96static void __dev_sort_resources(struct pci_dev *dev, 97 struct resource_list *head) 98{ 99 u16 class = dev->class >> 8; 100 101 /* Don't touch classless devices or host bridges or ioapics. */ --- 52 unchanged lines hidden (view full) --- 154 if (!hlist) { /* just skip */ 155 prev = list; 156 list = list->next; 157 continue; 158 } 159 160 idx = res - &list->dev->resource[0]; 161 add_size=list->add_size; | 98} 99 100static void __dev_sort_resources(struct pci_dev *dev, 101 struct resource_list *head) 102{ 103 u16 class = dev->class >> 8; 104 105 /* Don't touch classless devices or host bridges or ioapics. */ --- 52 unchanged lines hidden (view full) --- 158 if (!hlist) { /* just skip */ 159 prev = list; 160 list = list->next; 161 continue; 162 } 163 164 idx = res - &list->dev->resource[0]; 165 add_size=list->add_size; |
162 if (!resource_size(res) && add_size) { 163 res->end = res->start + add_size - 1; 164 if(pci_assign_resource(list->dev, idx)) | 166 if (!resource_size(res)) { 167 res->end = res->start + add_size - 1; 168 if(pci_assign_resource(list->dev, idx)) |
165 reset_resource(res); | 169 reset_resource(res); |
166 } else if (add_size) { 167 adjust_resource(res, res->start, 168 resource_size(res) + add_size); | 170 } else { 171 resource_size_t align = list->min_align; 172 res->flags |= list->flags & (IORESOURCE_STARTALIGN|IORESOURCE_SIZEALIGN); 173 if (pci_reassign_resource(list->dev, idx, add_size, align)) 174 dev_printk(KERN_DEBUG, &list->dev->dev, "failed to add optional resources res=%pR\n", 175 res); |
169 } 170out: 171 tmp = list; 172 prev->next = list = list->next; 173 kfree(tmp); 174 } 175} 176 --- 437 unchanged lines hidden (view full) --- 614 b_res->flags = 0; 615 return; 616 } 617 /* Alignment of the IO window is always 4K */ 618 b_res->start = 4096; 619 b_res->end = b_res->start + size0 - 1; 620 b_res->flags |= IORESOURCE_STARTALIGN; 621 if (size1 > size0 && add_head) | 176 } 177out: 178 tmp = list; 179 prev->next = list = list->next; 180 kfree(tmp); 181 } 182} 183 --- 437 unchanged lines hidden (view full) --- 621 b_res->flags = 0; 622 return; 623 } 624 /* Alignment of the IO window is always 4K */ 625 b_res->start = 4096; 626 b_res->end = b_res->start + size0 - 1; 627 b_res->flags |= IORESOURCE_STARTALIGN; 628 if (size1 > size0 && add_head) |
622 add_to_list(add_head, bus->self, b_res, size1-size0); | 629 add_to_list(add_head, bus->self, b_res, size1-size0, 4096); |
623} 624 625/** 626 * pbus_size_mem() - size the memory window of a given bus 627 * 628 * @bus : the bus 629 * @min_size : the minimum memory window that must to be allocated 630 * @add_size : additional optional memory window --- 86 unchanged lines hidden (view full) --- 717 bus->secondary, bus->subordinate); 718 b_res->flags = 0; 719 return 1; 720 } 721 b_res->start = min_align; 722 b_res->end = size0 + min_align - 1; 723 b_res->flags |= IORESOURCE_STARTALIGN | mem64_mask; 724 if (size1 > size0 && add_head) | 630} 631 632/** 633 * pbus_size_mem() - size the memory window of a given bus 634 * 635 * @bus : the bus 636 * @min_size : the minimum memory window that must to be allocated 637 * @add_size : additional optional memory window --- 86 unchanged lines hidden (view full) --- 724 bus->secondary, bus->subordinate); 725 b_res->flags = 0; 726 return 1; 727 } 728 b_res->start = min_align; 729 b_res->end = size0 + min_align - 1; 730 b_res->flags |= IORESOURCE_STARTALIGN | mem64_mask; 731 if (size1 > size0 && add_head) |
725 add_to_list(add_head, bus->self, b_res, size1-size0); | 732 add_to_list(add_head, bus->self, b_res, size1-size0, min_align); |
726 return 1; 727} 728 729static void pci_bus_size_cardbus(struct pci_bus *bus) 730{ 731 struct pci_dev *bridge = bus->self; 732 struct resource *b_res = &bridge->resource[PCI_BRIDGE_RESOURCES]; 733 u16 ctrl; --- 496 unchanged lines hidden --- | 733 return 1; 734} 735 736static void pci_bus_size_cardbus(struct pci_bus *bus) 737{ 738 struct pci_dev *bridge = bus->self; 739 struct resource *b_res = &bridge->resource[PCI_BRIDGE_RESOURCES]; 740 u16 ctrl; --- 496 unchanged lines hidden --- |