Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sparc/PCI: get rid of device resource fixups

Tell the PCI core about host bridge address translation so it can take
care of bus-to-resource conversion for us.

N.B. Leon apparently never uses initial BAR values, so it didn't matter
that we never fixed up the I/O resources from bus address to CPU addresses.

Other sparc uses pci_of_scan_bus(), which sets device resources directly
to CPU addresses, not bus addresses, so it didn't need pcibios_fixup_bus()
either. But by telling the core about the offsets, we can nuke
pcibios_resource_to_bus().

CC: "David S. Miller" <davem@davemloft.net>
CC: sparclinux@vger.kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

+13 -96
+1 -7
arch/sparc/include/asm/pci_32.h
··· 52 52 * 64Kbytes by the Host controller. 53 53 */ 54 54 55 - extern void 56 - pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 57 - struct resource *res); 58 - 59 - extern void 60 - pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 61 - struct pci_bus_region *region); 55 + #define ARCH_HAS_GENERIC_PCI_OFFSETS 62 56 63 57 static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) 64 58 {
+1 -7
arch/sparc/include/asm/pci_64.h
··· 73 73 enum pci_mmap_state mmap_state, 74 74 int write_combine); 75 75 76 - extern void 77 - pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 78 - struct resource *res); 79 - 80 - extern void 81 - pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 82 - struct pci_bus_region *region); 76 + #define ARCH_HAS_GENERIC_PCI_OFFSETS 83 77 84 78 static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) 85 79 {
+7 -40
arch/sparc/kernel/leon_pci.c
··· 15 15 16 16 /* The LEON architecture does not rely on a BIOS or bootloader to setup 17 17 * PCI for us. The Linux generic routines are used to setup resources, 18 - * reset values of confuration-space registers settings ae preseved. 18 + * reset values of configuration-space register settings are preserved. 19 + * 20 + * PCI Memory and Prefetchable Memory is direct-mapped. However I/O Space is 21 + * accessed through a Window which is translated to low 64KB in PCI space, the 22 + * first 4KB is not used so 60KB is available. 19 23 */ 20 24 void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info) 21 25 { 22 26 LIST_HEAD(resources); 23 27 struct pci_bus *root_bus; 24 28 25 - pci_add_resource(&resources, &info->io_space); 29 + pci_add_resource_offset(&resources, &info->io_space, 30 + info->io_space.start - 0x1000); 26 31 pci_add_resource(&resources, &info->mem_space); 27 32 28 33 root_bus = pci_scan_root_bus(&ofdev->dev, 0, info->ops, info, ··· 42 37 pci_free_resource_list(&resources); 43 38 } 44 39 } 45 - 46 - /* PCI Memory and Prefetchable Memory is direct-mapped. However I/O Space is 47 - * accessed through a Window which is translated to low 64KB in PCI space, the 48 - * first 4KB is not used so 60KB is available. 49 - * 50 - * This function is used by generic code to translate resource addresses into 51 - * PCI addresses. 52 - */ 53 - void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 54 - struct resource *res) 55 - { 56 - struct leon_pci_info *info = dev->bus->sysdata; 57 - 58 - region->start = res->start; 59 - region->end = res->end; 60 - 61 - if (res->flags & IORESOURCE_IO) { 62 - region->start -= (info->io_space.start - 0x1000); 63 - region->end -= (info->io_space.start - 0x1000); 64 - } 65 - } 66 - EXPORT_SYMBOL(pcibios_resource_to_bus); 67 - 68 - /* see pcibios_resource_to_bus() comment */ 69 - void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, 70 - struct pci_bus_region *region) 71 - { 72 - struct leon_pci_info *info = dev->bus->sysdata; 73 - 74 - res->start = region->start; 75 - res->end = region->end; 76 - 77 - if (res->flags & IORESOURCE_IO) { 78 - res->start += (info->io_space.start - 0x1000); 79 - res->end += (info->io_space.start - 0x1000); 80 - } 81 - } 82 - EXPORT_SYMBOL(pcibios_bus_to_resource); 83 40 84 41 void __devinit pcibios_fixup_bus(struct pci_bus *pbus) 85 42 {
+4 -42
arch/sparc/kernel/pci.c
··· 691 691 692 692 printk("PCI: Scanning PBM %s\n", node->full_name); 693 693 694 - pci_add_resource(&resources, &pbm->io_space); 695 - pci_add_resource(&resources, &pbm->mem_space); 694 + pci_add_resource_offset(&resources, &pbm->io_space, 695 + pbm->io_space.start); 696 + pci_add_resource_offset(&resources, &pbm->mem_space, 697 + pbm->mem_space.start); 696 698 bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops, 697 699 pbm, &resources); 698 700 if (!bus) { ··· 756 754 } 757 755 return 0; 758 756 } 759 - 760 - void pcibios_resource_to_bus(struct pci_dev *pdev, struct pci_bus_region *region, 761 - struct resource *res) 762 - { 763 - struct pci_pbm_info *pbm = pdev->bus->sysdata; 764 - struct resource zero_res, *root; 765 - 766 - zero_res.start = 0; 767 - zero_res.end = 0; 768 - zero_res.flags = res->flags; 769 - 770 - if (res->flags & IORESOURCE_IO) 771 - root = &pbm->io_space; 772 - else 773 - root = &pbm->mem_space; 774 - 775 - pci_resource_adjust(&zero_res, root); 776 - 777 - region->start = res->start - zero_res.start; 778 - region->end = res->end - zero_res.start; 779 - } 780 - EXPORT_SYMBOL(pcibios_resource_to_bus); 781 - 782 - void pcibios_bus_to_resource(struct pci_dev *pdev, struct resource *res, 783 - struct pci_bus_region *region) 784 - { 785 - struct pci_pbm_info *pbm = pdev->bus->sysdata; 786 - struct resource *root; 787 - 788 - res->start = region->start; 789 - res->end = region->end; 790 - 791 - if (res->flags & IORESOURCE_IO) 792 - root = &pbm->io_space; 793 - else 794 - root = &pbm->mem_space; 795 - 796 - pci_resource_adjust(res, root); 797 - } 798 - EXPORT_SYMBOL(pcibios_bus_to_resource); 799 757 800 758 char * __devinit pcibios_setup(char *str) 801 759 {