Skip to content

Commit fc3fb71

Browse files
ozbenhpaulusmack
authored andcommitted
[POWERPC] pci32: Add flags modifying the PCI code behaviour
This adds to the 32 bits PCI code some flags, replacing the old pci_assign_all_busses global, that allow us to control various aspects of the PCI probing, such as whether to re-assign all resources or not, or to not try to assign anything at all. This also adds the flag x86 already has to avoid ISA alignment on bridges that don't have ISA forwarding enabled (no legacy devices on the top level bus) and sets it for PowerMacs. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
1 parent b9baa20 commit fc3fb71

12 files changed

Lines changed: 75 additions & 22 deletions

File tree

‎arch/powerpc/kernel/pci_32.c‎

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ unsigned long isa_io_base = 0;
3535
unsigned long pci_dram_offset = 0;
3636
int pcibios_assign_bus_offset = 1;
3737

38+
/* Default PCI flags is 0 */
39+
unsigned int ppc_pci_flags;
40+
3841
void pcibios_make_OF_bus_map(void);
3942

4043
static void pcibios_fixup_resources(struct pci_dev* dev);
@@ -48,7 +51,7 @@ static u8* pci_to_OF_bus_map;
4851
/* By default, we don't re-assign bus numbers. We do this only on
4952
* some pmacs
5053
*/
51-
int pci_assign_all_buses;
54+
static int pci_assign_all_buses;
5255

5356
LIST_HEAD(hose_list);
5457

@@ -174,6 +177,14 @@ void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
174177
}
175178
EXPORT_SYMBOL(pcibios_bus_to_resource);
176179

180+
static int skip_isa_ioresource_align(struct pci_dev *dev)
181+
{
182+
if ((ppc_pci_flags & PPC_PCI_CAN_SKIP_ISA_ALIGN) &&
183+
!(dev->bus->bridge_ctl & PCI_BRIDGE_CTL_ISA))
184+
return 1;
185+
return 0;
186+
}
187+
177188
/*
178189
* We need to avoid collisions with `mirrored' VGA ports
179190
* and other strange ISA hardware, so we always want the
@@ -195,6 +206,8 @@ void pcibios_align_resource(void *data, struct resource *res,
195206
if (res->flags & IORESOURCE_IO) {
196207
resource_size_t start = res->start;
197208

209+
if (skip_isa_ioresource_align(dev))
210+
return;
198211
if (start & 0x300) {
199212
start = (start + 0x3ff) & ~0x3ff;
200213
res->start = start;
@@ -251,8 +264,13 @@ pcibios_allocate_bus_resources(struct list_head *bus_list)
251264
continue;
252265
if (bus->parent == NULL)
253266
pr = (res->flags & IORESOURCE_IO)?
254-
&ioport_resource: &iomem_resource;
267+
&ioport_resource : &iomem_resource;
255268
else {
269+
/* Don't bother with non-root busses when
270+
* re-assigning all resources.
271+
*/
272+
if (ppc_pci_flags & PPC_PCI_REASSIGN_ALL_RSRC)
273+
continue;
256274
pr = pci_find_parent_resource(bus->self, res);
257275
if (pr == res) {
258276
/* this happens when the generic PCI
@@ -720,6 +738,9 @@ pcibios_init(void)
720738

721739
printk(KERN_INFO "PCI: Probing PCI hardware\n");
722740

741+
if (ppc_pci_flags & PPC_PCI_REASSIGN_ALL_BUS)
742+
pci_assign_all_buses = 1;
743+
723744
/* Scan all of the recorded PCI controllers. */
724745
list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
725746
if (pci_assign_all_buses)
@@ -746,13 +767,18 @@ pcibios_init(void)
746767
if (ppc_md.pcibios_fixup)
747768
ppc_md.pcibios_fixup();
748769

749-
/* Allocate and assign resources */
770+
/* Allocate and assign resources. If we re-assign everything, then
771+
* we skip the allocate phase
772+
*/
750773
pcibios_allocate_bus_resources(&pci_root_buses);
751-
pcibios_allocate_resources(0);
752-
pcibios_allocate_resources(1);
753-
754-
DBG("PCI: Assigning unassigned resouces...\n");
755-
pci_assign_unassigned_resources();
774+
if (!(ppc_pci_flags & PPC_PCI_REASSIGN_ALL_RSRC)) {
775+
pcibios_allocate_resources(0);
776+
pcibios_allocate_resources(1);
777+
}
778+
if (!(ppc_pci_flags & PPC_PCI_PROBE_ONLY)) {
779+
DBG("PCI: Assigning unassigned resouces...\n");
780+
pci_assign_unassigned_resources();
781+
}
756782

757783
/* Call machine dependent post-init code */
758784
if (ppc_md.pcibios_after_init)

‎arch/powerpc/kernel/pci_64.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#endif
4141

4242
unsigned long pci_probe_only = 1;
43-
int pci_assign_all_buses = 0;
4443

4544
static void fixup_resource(struct resource *res, struct pci_dev *dev);
4645
static void do_bus_setup(struct pci_bus *bus);

‎arch/powerpc/kernel/rtas_pci.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,12 @@ void __init find_and_init_phbs(void)
311311
if (prop)
312312
pci_probe_only = *prop;
313313

314+
#ifdef CONFIG_PPC32 /* Will be made generic soon */
314315
prop = of_get_property(of_chosen,
315316
"linux,pci-assign-all-buses", NULL);
316-
if (prop)
317-
pci_assign_all_buses = *prop;
317+
if (prop && *prop)
318+
ppc_pci_flags |= PPC_PCI_REASSIGN_ALL_BUS;
319+
#endif /* CONFIG_PPC32 */
318320
}
319321
}
320322

‎arch/powerpc/platforms/52xx/mpc52xx_pci.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ mpc52xx_add_bridge(struct device_node *node)
363363

364364
pr_debug("Adding MPC52xx PCI host bridge %s\n", node->full_name);
365365

366-
pci_assign_all_buses = 1;
366+
ppc_pci_flags |= PPC_PCI_REASSIGN_ALL_BUS;
367367

368368
if (of_address_to_resource(node, 0, &rsrc) != 0) {
369369
printk(KERN_ERR "Can't get %s resources\n", node->full_name);

‎arch/powerpc/platforms/82xx/pq2.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static void __init pq2_pci_add_bridge(struct device_node *np)
5353
if (of_address_to_resource(np, 0, &r) || r.end - r.start < 0x10b)
5454
goto err;
5555

56-
pci_assign_all_buses = 1;
56+
ppc_pci_flags |= PPC_PCI_REASSIGN_ALL_BUS;
5757

5858
hose = pcibios_alloc_controller(np);
5959
if (!hose)

‎arch/powerpc/platforms/83xx/pci.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ int __init mpc83xx_add_bridge(struct device_node *dev)
5454
" bus 0\n", dev->full_name);
5555
}
5656

57-
pci_assign_all_buses = 1;
57+
ppc_pci_flags |= PPC_PCI_REASSIGN_ALL_BUS;
5858
hose = pcibios_alloc_controller(dev);
5959
if (!hose)
6060
return -ENOMEM;

‎arch/powerpc/platforms/chrp/pci.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ static void __init setup_peg2(struct pci_controller *hose, struct device_node *d
198198
printk ("RTAS supporting Pegasos OF not found, please upgrade"
199199
" your firmware\n");
200200
}
201-
pci_assign_all_buses = 1;
201+
ppc_pci_flags |= PPC_PCI_REASSIGN_ALL_BUS;
202202
/* keep the reference to the root node */
203203
}
204204

‎arch/powerpc/platforms/powermac/pci.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ static void __init setup_bandit(struct pci_controller *hose,
725725
static int __init setup_uninorth(struct pci_controller *hose,
726726
struct resource *addr)
727727
{
728-
pci_assign_all_buses = 1;
728+
ppc_pci_flags |= PPC_PCI_REASSIGN_ALL_BUS;
729729
has_uninorth = 1;
730730
hose->ops = &macrisc_pci_ops;
731731
hose->cfg_addr = ioremap(addr->start + 0x800000, 0x1000);
@@ -994,6 +994,9 @@ void __init pmac_pci_init(void)
994994
struct device_node *np, *root;
995995
struct device_node *ht = NULL;
996996

997+
#ifdef CONFIG_PPC32
998+
ppc_pci_flags = PPC_PCI_CAN_SKIP_ISA_ALIGN;
999+
#endif
9971000
root = of_find_node_by_path("/");
9981001
if (root == NULL) {
9991002
printk(KERN_CRIT "pmac_pci_init: can't find root "
@@ -1051,7 +1054,7 @@ void __init pmac_pci_init(void)
10511054
* some offset between bus number and domains for now when we
10521055
* assign all busses should help for now
10531056
*/
1054-
if (pci_assign_all_buses)
1057+
if (ppc_pci_flags & PPC_PCI_REASSIGN_ALL_BUS)
10551058
pcibios_assign_bus_offset = 0x10;
10561059
#endif
10571060
}

‎arch/powerpc/sysdev/fsl_pci.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ int __init fsl_add_bridge(struct device_node *dev, int is_primary)
202202
printk(KERN_WARNING "Can't get bus-range for %s, assume"
203203
" bus 0\n", dev->full_name);
204204

205-
pci_assign_all_buses = 1;
205+
ppc_pci_flags |= PPC_PCI_REASSIGN_ALL_BUS;
206206
hose = pcibios_alloc_controller(dev);
207207
if (!hose)
208208
return -ENOMEM;

‎arch/powerpc/sysdev/grackle.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void __init setup_grackle(struct pci_controller *hose)
5757
{
5858
setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0);
5959
if (machine_is_compatible("PowerMac1,1"))
60-
pci_assign_all_buses = 1;
60+
ppc_pci_flags |= PPC_PCI_REASSIGN_ALL_BUS;
6161
if (machine_is_compatible("AAPL,PowerBook1998"))
6262
grackle_set_loop_snoop(hose, 1);
6363
#if 0 /* Disabled for now, HW problems ??? */

0 commit comments

Comments
 (0)