diff options
author | Paul Mackerras <paulus@samba.org> | 2005-09-05 23:17:54 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2005-09-09 08:11:38 -0400 |
commit | 1635317facea3094ddf34082cd86797efb1d9f7e (patch) | |
tree | 67d5a4d4c7af00ac4be4608092fec99a32683715 /arch/ppc64 | |
parent | b28d2582ce8aafe531d909bb9c4dcf29189e786e (diff) |
[PATCH] Separate pci bits out of struct device_node
This patch pulls the PCI-related junk out of struct device_node and
puts it in a separate structure, struct pci_dn. The device_node now
just has a void * pointer in it, which points to a struct pci_dn for
nodes that represent PCI devices. It could potentially be used in
future for device-specific data for other sorts of devices, such as
virtual I/O devices.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/ppc64')
-rw-r--r-- | arch/ppc64/kernel/eeh.c | 55 | ||||
-rw-r--r-- | arch/ppc64/kernel/iommu.c | 3 | ||||
-rw-r--r-- | arch/ppc64/kernel/maple_pci.c | 4 | ||||
-rw-r--r-- | arch/ppc64/kernel/pSeries_iommu.c | 72 | ||||
-rw-r--r-- | arch/ppc64/kernel/pci.c | 6 | ||||
-rw-r--r-- | arch/ppc64/kernel/pci.h | 1 | ||||
-rw-r--r-- | arch/ppc64/kernel/pci_dn.c | 47 | ||||
-rw-r--r-- | arch/ppc64/kernel/pci_iommu.c | 2 | ||||
-rw-r--r-- | arch/ppc64/kernel/pmac_feature.c | 8 | ||||
-rw-r--r-- | arch/ppc64/kernel/pmac_pci.c | 6 | ||||
-rw-r--r-- | arch/ppc64/kernel/prom.c | 1 | ||||
-rw-r--r-- | arch/ppc64/kernel/rtas_pci.c | 39 | ||||
-rw-r--r-- | arch/ppc64/kernel/sys_ppc32.c | 4 | ||||
-rw-r--r-- | arch/ppc64/kernel/u3_iommu.c | 4 |
14 files changed, 151 insertions, 101 deletions
diff --git a/arch/ppc64/kernel/eeh.c b/arch/ppc64/kernel/eeh.c index 4c857a6516fc..ba93fd731222 100644 --- a/arch/ppc64/kernel/eeh.c +++ b/arch/ppc64/kernel/eeh.c | |||
@@ -254,6 +254,7 @@ pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo, | |||
254 | static void __pci_addr_cache_insert_device(struct pci_dev *dev) | 254 | static void __pci_addr_cache_insert_device(struct pci_dev *dev) |
255 | { | 255 | { |
256 | struct device_node *dn; | 256 | struct device_node *dn; |
257 | struct pci_dn *pdn; | ||
257 | int i; | 258 | int i; |
258 | int inserted = 0; | 259 | int inserted = 0; |
259 | 260 | ||
@@ -265,8 +266,9 @@ static void __pci_addr_cache_insert_device(struct pci_dev *dev) | |||
265 | } | 266 | } |
266 | 267 | ||
267 | /* Skip any devices for which EEH is not enabled. */ | 268 | /* Skip any devices for which EEH is not enabled. */ |
268 | if (!(dn->eeh_mode & EEH_MODE_SUPPORTED) || | 269 | pdn = dn->data; |
269 | dn->eeh_mode & EEH_MODE_NOCHECK) { | 270 | if (!(pdn->eeh_mode & EEH_MODE_SUPPORTED) || |
271 | pdn->eeh_mode & EEH_MODE_NOCHECK) { | ||
270 | #ifdef DEBUG | 272 | #ifdef DEBUG |
271 | printk(KERN_INFO "PCI: skip building address cache for=%s\n", | 273 | printk(KERN_INFO "PCI: skip building address cache for=%s\n", |
272 | pci_name(dev)); | 274 | pci_name(dev)); |
@@ -415,6 +417,7 @@ int eeh_unregister_notifier(struct notifier_block *nb) | |||
415 | static int read_slot_reset_state(struct device_node *dn, int rets[]) | 417 | static int read_slot_reset_state(struct device_node *dn, int rets[]) |
416 | { | 418 | { |
417 | int token, outputs; | 419 | int token, outputs; |
420 | struct pci_dn *pdn = dn->data; | ||
418 | 421 | ||
419 | if (ibm_read_slot_reset_state2 != RTAS_UNKNOWN_SERVICE) { | 422 | if (ibm_read_slot_reset_state2 != RTAS_UNKNOWN_SERVICE) { |
420 | token = ibm_read_slot_reset_state2; | 423 | token = ibm_read_slot_reset_state2; |
@@ -424,8 +427,8 @@ static int read_slot_reset_state(struct device_node *dn, int rets[]) | |||
424 | outputs = 3; | 427 | outputs = 3; |
425 | } | 428 | } |
426 | 429 | ||
427 | return rtas_call(token, 3, outputs, rets, dn->eeh_config_addr, | 430 | return rtas_call(token, 3, outputs, rets, pdn->eeh_config_addr, |
428 | BUID_HI(dn->phb->buid), BUID_LO(dn->phb->buid)); | 431 | BUID_HI(pdn->phb->buid), BUID_LO(pdn->phb->buid)); |
429 | } | 432 | } |
430 | 433 | ||
431 | /** | 434 | /** |
@@ -534,6 +537,7 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) | |||
534 | unsigned long flags; | 537 | unsigned long flags; |
535 | int rc, reset_state; | 538 | int rc, reset_state; |
536 | struct eeh_event *event; | 539 | struct eeh_event *event; |
540 | struct pci_dn *pdn; | ||
537 | 541 | ||
538 | __get_cpu_var(total_mmio_ffs)++; | 542 | __get_cpu_var(total_mmio_ffs)++; |
539 | 543 | ||
@@ -542,14 +546,15 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) | |||
542 | 546 | ||
543 | if (!dn) | 547 | if (!dn) |
544 | return 0; | 548 | return 0; |
549 | pdn = dn->data; | ||
545 | 550 | ||
546 | /* Access to IO BARs might get this far and still not want checking. */ | 551 | /* Access to IO BARs might get this far and still not want checking. */ |
547 | if (!(dn->eeh_mode & EEH_MODE_SUPPORTED) || | 552 | if (!pdn->eeh_capable || !(pdn->eeh_mode & EEH_MODE_SUPPORTED) || |
548 | dn->eeh_mode & EEH_MODE_NOCHECK) { | 553 | pdn->eeh_mode & EEH_MODE_NOCHECK) { |
549 | return 0; | 554 | return 0; |
550 | } | 555 | } |
551 | 556 | ||
552 | if (!dn->eeh_config_addr) { | 557 | if (!pdn->eeh_config_addr) { |
553 | return 0; | 558 | return 0; |
554 | } | 559 | } |
555 | 560 | ||
@@ -557,7 +562,7 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) | |||
557 | * If we already have a pending isolation event for this | 562 | * If we already have a pending isolation event for this |
558 | * slot, we know it's bad already, we don't need to check... | 563 | * slot, we know it's bad already, we don't need to check... |
559 | */ | 564 | */ |
560 | if (dn->eeh_mode & EEH_MODE_ISOLATED) { | 565 | if (pdn->eeh_mode & EEH_MODE_ISOLATED) { |
561 | atomic_inc(&eeh_fail_count); | 566 | atomic_inc(&eeh_fail_count); |
562 | if (atomic_read(&eeh_fail_count) >= EEH_MAX_FAILS) { | 567 | if (atomic_read(&eeh_fail_count) >= EEH_MAX_FAILS) { |
563 | /* re-read the slot reset state */ | 568 | /* re-read the slot reset state */ |
@@ -582,7 +587,7 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) | |||
582 | } | 587 | } |
583 | 588 | ||
584 | /* prevent repeated reports of this failure */ | 589 | /* prevent repeated reports of this failure */ |
585 | dn->eeh_mode |= EEH_MODE_ISOLATED; | 590 | pdn->eeh_mode |= EEH_MODE_ISOLATED; |
586 | 591 | ||
587 | reset_state = rets[0]; | 592 | reset_state = rets[0]; |
588 | 593 | ||
@@ -590,9 +595,9 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) | |||
590 | memset(slot_errbuf, 0, eeh_error_buf_size); | 595 | memset(slot_errbuf, 0, eeh_error_buf_size); |
591 | 596 | ||
592 | rc = rtas_call(ibm_slot_error_detail, | 597 | rc = rtas_call(ibm_slot_error_detail, |
593 | 8, 1, NULL, dn->eeh_config_addr, | 598 | 8, 1, NULL, pdn->eeh_config_addr, |
594 | BUID_HI(dn->phb->buid), | 599 | BUID_HI(pdn->phb->buid), |
595 | BUID_LO(dn->phb->buid), NULL, 0, | 600 | BUID_LO(pdn->phb->buid), NULL, 0, |
596 | virt_to_phys(slot_errbuf), | 601 | virt_to_phys(slot_errbuf), |
597 | eeh_error_buf_size, | 602 | eeh_error_buf_size, |
598 | 1 /* Temporary Error */); | 603 | 1 /* Temporary Error */); |
@@ -679,8 +684,9 @@ static void *early_enable_eeh(struct device_node *dn, void *data) | |||
679 | u32 *device_id = (u32 *)get_property(dn, "device-id", NULL); | 684 | u32 *device_id = (u32 *)get_property(dn, "device-id", NULL); |
680 | u32 *regs; | 685 | u32 *regs; |
681 | int enable; | 686 | int enable; |
687 | struct pci_dn *pdn = dn->data; | ||
682 | 688 | ||
683 | dn->eeh_mode = 0; | 689 | pdn->eeh_mode = 0; |
684 | 690 | ||
685 | if (status && strcmp(status, "ok") != 0) | 691 | if (status && strcmp(status, "ok") != 0) |
686 | return NULL; /* ignore devices with bad status */ | 692 | return NULL; /* ignore devices with bad status */ |
@@ -691,7 +697,7 @@ static void *early_enable_eeh(struct device_node *dn, void *data) | |||
691 | 697 | ||
692 | /* There is nothing to check on PCI to ISA bridges */ | 698 | /* There is nothing to check on PCI to ISA bridges */ |
693 | if (dn->type && !strcmp(dn->type, "isa")) { | 699 | if (dn->type && !strcmp(dn->type, "isa")) { |
694 | dn->eeh_mode |= EEH_MODE_NOCHECK; | 700 | pdn->eeh_mode |= EEH_MODE_NOCHECK; |
695 | return NULL; | 701 | return NULL; |
696 | } | 702 | } |
697 | 703 | ||
@@ -708,7 +714,7 @@ static void *early_enable_eeh(struct device_node *dn, void *data) | |||
708 | enable = 0; | 714 | enable = 0; |
709 | 715 | ||
710 | if (!enable) | 716 | if (!enable) |
711 | dn->eeh_mode |= EEH_MODE_NOCHECK; | 717 | pdn->eeh_mode |= EEH_MODE_NOCHECK; |
712 | 718 | ||
713 | /* Ok... see if this device supports EEH. Some do, some don't, | 719 | /* Ok... see if this device supports EEH. Some do, some don't, |
714 | * and the only way to find out is to check each and every one. */ | 720 | * and the only way to find out is to check each and every one. */ |
@@ -721,8 +727,8 @@ static void *early_enable_eeh(struct device_node *dn, void *data) | |||
721 | EEH_ENABLE); | 727 | EEH_ENABLE); |
722 | if (ret == 0) { | 728 | if (ret == 0) { |
723 | eeh_subsystem_enabled = 1; | 729 | eeh_subsystem_enabled = 1; |
724 | dn->eeh_mode |= EEH_MODE_SUPPORTED; | 730 | pdn->eeh_mode |= EEH_MODE_SUPPORTED; |
725 | dn->eeh_config_addr = regs[0]; | 731 | pdn->eeh_config_addr = regs[0]; |
726 | #ifdef DEBUG | 732 | #ifdef DEBUG |
727 | printk(KERN_DEBUG "EEH: %s: eeh enabled\n", dn->full_name); | 733 | printk(KERN_DEBUG "EEH: %s: eeh enabled\n", dn->full_name); |
728 | #endif | 734 | #endif |
@@ -730,10 +736,11 @@ static void *early_enable_eeh(struct device_node *dn, void *data) | |||
730 | 736 | ||
731 | /* This device doesn't support EEH, but it may have an | 737 | /* This device doesn't support EEH, but it may have an |
732 | * EEH parent, in which case we mark it as supported. */ | 738 | * EEH parent, in which case we mark it as supported. */ |
733 | if (dn->parent && (dn->parent->eeh_mode & EEH_MODE_SUPPORTED)) { | 739 | if (dn->parent && dn->parent->data |
740 | && (PCI_DN(dn->parent)->eeh_mode & EEH_MODE_SUPPORTED)) { | ||
734 | /* Parent supports EEH. */ | 741 | /* Parent supports EEH. */ |
735 | dn->eeh_mode |= EEH_MODE_SUPPORTED; | 742 | pdn->eeh_mode |= EEH_MODE_SUPPORTED; |
736 | dn->eeh_config_addr = dn->parent->eeh_config_addr; | 743 | pdn->eeh_config_addr = PCI_DN(dn->parent)->eeh_config_addr; |
737 | return NULL; | 744 | return NULL; |
738 | } | 745 | } |
739 | } | 746 | } |
@@ -790,11 +797,13 @@ void __init eeh_init(void) | |||
790 | for (phb = of_find_node_by_name(NULL, "pci"); phb; | 797 | for (phb = of_find_node_by_name(NULL, "pci"); phb; |
791 | phb = of_find_node_by_name(phb, "pci")) { | 798 | phb = of_find_node_by_name(phb, "pci")) { |
792 | unsigned long buid; | 799 | unsigned long buid; |
800 | struct pci_dn *pci; | ||
793 | 801 | ||
794 | buid = get_phb_buid(phb); | 802 | buid = get_phb_buid(phb); |
795 | if (buid == 0) | 803 | if (buid == 0 || phb->data == NULL) |
796 | continue; | 804 | continue; |
797 | 805 | ||
806 | pci = phb->data; | ||
798 | info.buid_lo = BUID_LO(buid); | 807 | info.buid_lo = BUID_LO(buid); |
799 | info.buid_hi = BUID_HI(buid); | 808 | info.buid_hi = BUID_HI(buid); |
800 | traverse_pci_devices(phb, early_enable_eeh, &info); | 809 | traverse_pci_devices(phb, early_enable_eeh, &info); |
@@ -823,9 +832,9 @@ void eeh_add_device_early(struct device_node *dn) | |||
823 | struct pci_controller *phb; | 832 | struct pci_controller *phb; |
824 | struct eeh_early_enable_info info; | 833 | struct eeh_early_enable_info info; |
825 | 834 | ||
826 | if (!dn) | 835 | if (!dn || !dn->data) |
827 | return; | 836 | return; |
828 | phb = dn->phb; | 837 | phb = PCI_DN(dn)->phb; |
829 | if (NULL == phb || 0 == phb->buid) { | 838 | if (NULL == phb || 0 == phb->buid) { |
830 | printk(KERN_WARNING "EEH: Expected buid but found none\n"); | 839 | printk(KERN_WARNING "EEH: Expected buid but found none\n"); |
831 | return; | 840 | return; |
diff --git a/arch/ppc64/kernel/iommu.c b/arch/ppc64/kernel/iommu.c index 845eebd1e28d..9032b6bfe036 100644 --- a/arch/ppc64/kernel/iommu.c +++ b/arch/ppc64/kernel/iommu.c | |||
@@ -438,7 +438,8 @@ struct iommu_table *iommu_init_table(struct iommu_table *tbl) | |||
438 | 438 | ||
439 | void iommu_free_table(struct device_node *dn) | 439 | void iommu_free_table(struct device_node *dn) |
440 | { | 440 | { |
441 | struct iommu_table *tbl = dn->iommu_table; | 441 | struct pci_dn *pdn = dn->data; |
442 | struct iommu_table *tbl = pdn->iommu_table; | ||
442 | unsigned long bitmap_sz, i; | 443 | unsigned long bitmap_sz, i; |
443 | unsigned int order; | 444 | unsigned int order; |
444 | 445 | ||
diff --git a/arch/ppc64/kernel/maple_pci.c b/arch/ppc64/kernel/maple_pci.c index 53993999b265..5a8b4d8c2dd6 100644 --- a/arch/ppc64/kernel/maple_pci.c +++ b/arch/ppc64/kernel/maple_pci.c | |||
@@ -447,9 +447,9 @@ void __init maple_pci_init(void) | |||
447 | */ | 447 | */ |
448 | if (u3_agp) { | 448 | if (u3_agp) { |
449 | struct device_node *np = u3_agp->arch_data; | 449 | struct device_node *np = u3_agp->arch_data; |
450 | np->busno = 0xf0; | 450 | PCI_DN(np)->busno = 0xf0; |
451 | for (np = np->child; np; np = np->sibling) | 451 | for (np = np->child; np; np = np->sibling) |
452 | np->busno = 0xf0; | 452 | PCI_DN(np)->busno = 0xf0; |
453 | } | 453 | } |
454 | 454 | ||
455 | /* Tell pci.c to use the common resource allocation mecanism */ | 455 | /* Tell pci.c to use the common resource allocation mecanism */ |
diff --git a/arch/ppc64/kernel/pSeries_iommu.c b/arch/ppc64/kernel/pSeries_iommu.c index 9d5e1e7fc389..f0fd7fbd6531 100644 --- a/arch/ppc64/kernel/pSeries_iommu.c +++ b/arch/ppc64/kernel/pSeries_iommu.c | |||
@@ -295,7 +295,7 @@ static void iommu_table_setparms_lpar(struct pci_controller *phb, | |||
295 | struct iommu_table *tbl, | 295 | struct iommu_table *tbl, |
296 | unsigned int *dma_window) | 296 | unsigned int *dma_window) |
297 | { | 297 | { |
298 | tbl->it_busno = dn->bussubno; | 298 | tbl->it_busno = PCI_DN(dn)->bussubno; |
299 | 299 | ||
300 | /* TODO: Parse field size properties properly. */ | 300 | /* TODO: Parse field size properties properly. */ |
301 | tbl->it_size = (((unsigned long)dma_window[4] << 32) | | 301 | tbl->it_size = (((unsigned long)dma_window[4] << 32) | |
@@ -311,6 +311,7 @@ static void iommu_table_setparms_lpar(struct pci_controller *phb, | |||
311 | static void iommu_bus_setup_pSeries(struct pci_bus *bus) | 311 | static void iommu_bus_setup_pSeries(struct pci_bus *bus) |
312 | { | 312 | { |
313 | struct device_node *dn, *pdn; | 313 | struct device_node *dn, *pdn; |
314 | struct pci_dn *pci; | ||
314 | struct iommu_table *tbl; | 315 | struct iommu_table *tbl; |
315 | 316 | ||
316 | DBG("iommu_bus_setup_pSeries, bus %p, bus->self %p\n", bus, bus->self); | 317 | DBG("iommu_bus_setup_pSeries, bus %p, bus->self %p\n", bus, bus->self); |
@@ -325,6 +326,7 @@ static void iommu_bus_setup_pSeries(struct pci_bus *bus) | |||
325 | */ | 326 | */ |
326 | 327 | ||
327 | dn = pci_bus_to_OF_node(bus); | 328 | dn = pci_bus_to_OF_node(bus); |
329 | pci = dn->data; | ||
328 | 330 | ||
329 | if (!bus->self) { | 331 | if (!bus->self) { |
330 | /* Root bus */ | 332 | /* Root bus */ |
@@ -341,18 +343,18 @@ static void iommu_bus_setup_pSeries(struct pci_bus *bus) | |||
341 | * alltogether. This leaves 768MB for the window. | 343 | * alltogether. This leaves 768MB for the window. |
342 | */ | 344 | */ |
343 | DBG("PHB has io-hole, reserving 256MB\n"); | 345 | DBG("PHB has io-hole, reserving 256MB\n"); |
344 | dn->phb->dma_window_size = 3 << 28; | 346 | pci->phb->dma_window_size = 3 << 28; |
345 | dn->phb->dma_window_base_cur = 1 << 28; | 347 | pci->phb->dma_window_base_cur = 1 << 28; |
346 | } else { | 348 | } else { |
347 | /* 1GB window by default */ | 349 | /* 1GB window by default */ |
348 | dn->phb->dma_window_size = 1 << 30; | 350 | pci->phb->dma_window_size = 1 << 30; |
349 | dn->phb->dma_window_base_cur = 0; | 351 | pci->phb->dma_window_base_cur = 0; |
350 | } | 352 | } |
351 | 353 | ||
352 | tbl = kmalloc(sizeof(struct iommu_table), GFP_KERNEL); | 354 | tbl = kmalloc(sizeof(struct iommu_table), GFP_KERNEL); |
353 | 355 | ||
354 | iommu_table_setparms(dn->phb, dn, tbl); | 356 | iommu_table_setparms(pci->phb, dn, tbl); |
355 | dn->iommu_table = iommu_init_table(tbl); | 357 | pci->iommu_table = iommu_init_table(tbl); |
356 | } else { | 358 | } else { |
357 | /* Do a 128MB table at root. This is used for the IDE | 359 | /* Do a 128MB table at root. This is used for the IDE |
358 | * controller on some SMP-mode POWER4 machines. It | 360 | * controller on some SMP-mode POWER4 machines. It |
@@ -363,16 +365,16 @@ static void iommu_bus_setup_pSeries(struct pci_bus *bus) | |||
363 | * Allocate at offset 128MB to avoid having to deal | 365 | * Allocate at offset 128MB to avoid having to deal |
364 | * with ISA holes; 128MB table for IDE is plenty. | 366 | * with ISA holes; 128MB table for IDE is plenty. |
365 | */ | 367 | */ |
366 | dn->phb->dma_window_size = 1 << 27; | 368 | pci->phb->dma_window_size = 1 << 27; |
367 | dn->phb->dma_window_base_cur = 1 << 27; | 369 | pci->phb->dma_window_base_cur = 1 << 27; |
368 | 370 | ||
369 | tbl = kmalloc(sizeof(struct iommu_table), GFP_KERNEL); | 371 | tbl = kmalloc(sizeof(struct iommu_table), GFP_KERNEL); |
370 | 372 | ||
371 | iommu_table_setparms(dn->phb, dn, tbl); | 373 | iommu_table_setparms(pci->phb, dn, tbl); |
372 | dn->iommu_table = iommu_init_table(tbl); | 374 | pci->iommu_table = iommu_init_table(tbl); |
373 | 375 | ||
374 | /* All child buses have 256MB tables */ | 376 | /* All child buses have 256MB tables */ |
375 | dn->phb->dma_window_size = 1 << 28; | 377 | pci->phb->dma_window_size = 1 << 28; |
376 | } | 378 | } |
377 | } else { | 379 | } else { |
378 | pdn = pci_bus_to_OF_node(bus->parent); | 380 | pdn = pci_bus_to_OF_node(bus->parent); |
@@ -386,12 +388,12 @@ static void iommu_bus_setup_pSeries(struct pci_bus *bus) | |||
386 | 388 | ||
387 | tbl = kmalloc(sizeof(struct iommu_table), GFP_KERNEL); | 389 | tbl = kmalloc(sizeof(struct iommu_table), GFP_KERNEL); |
388 | 390 | ||
389 | iommu_table_setparms(dn->phb, dn, tbl); | 391 | iommu_table_setparms(pci->phb, dn, tbl); |
390 | 392 | ||
391 | dn->iommu_table = iommu_init_table(tbl); | 393 | pci->iommu_table = iommu_init_table(tbl); |
392 | } else { | 394 | } else { |
393 | /* Lower than first child or under python, use parent table */ | 395 | /* Lower than first child or under python, use parent table */ |
394 | dn->iommu_table = pdn->iommu_table; | 396 | pci->iommu_table = PCI_DN(pdn)->iommu_table; |
395 | } | 397 | } |
396 | } | 398 | } |
397 | } | 399 | } |
@@ -401,6 +403,7 @@ static void iommu_bus_setup_pSeriesLP(struct pci_bus *bus) | |||
401 | { | 403 | { |
402 | struct iommu_table *tbl; | 404 | struct iommu_table *tbl; |
403 | struct device_node *dn, *pdn; | 405 | struct device_node *dn, *pdn; |
406 | struct pci_dn *ppci; | ||
404 | unsigned int *dma_window = NULL; | 407 | unsigned int *dma_window = NULL; |
405 | 408 | ||
406 | DBG("iommu_bus_setup_pSeriesLP, bus %p, bus->self %p\n", bus, bus->self); | 409 | DBG("iommu_bus_setup_pSeriesLP, bus %p, bus->self %p\n", bus, bus->self); |
@@ -419,22 +422,24 @@ static void iommu_bus_setup_pSeriesLP(struct pci_bus *bus) | |||
419 | return; | 422 | return; |
420 | } | 423 | } |
421 | 424 | ||
422 | if (!pdn->iommu_table) { | 425 | ppci = pdn->data; |
426 | if (!ppci->iommu_table) { | ||
423 | /* Bussubno hasn't been copied yet. | 427 | /* Bussubno hasn't been copied yet. |
424 | * Do it now because iommu_table_setparms_lpar needs it. | 428 | * Do it now because iommu_table_setparms_lpar needs it. |
425 | */ | 429 | */ |
426 | pdn->bussubno = bus->number; | 430 | |
431 | ppci->bussubno = bus->number; | ||
427 | 432 | ||
428 | tbl = (struct iommu_table *)kmalloc(sizeof(struct iommu_table), | 433 | tbl = (struct iommu_table *)kmalloc(sizeof(struct iommu_table), |
429 | GFP_KERNEL); | 434 | GFP_KERNEL); |
430 | 435 | ||
431 | iommu_table_setparms_lpar(pdn->phb, pdn, tbl, dma_window); | 436 | iommu_table_setparms_lpar(ppci->phb, pdn, tbl, dma_window); |
432 | 437 | ||
433 | pdn->iommu_table = iommu_init_table(tbl); | 438 | ppci->iommu_table = iommu_init_table(tbl); |
434 | } | 439 | } |
435 | 440 | ||
436 | if (pdn != dn) | 441 | if (pdn != dn) |
437 | dn->iommu_table = pdn->iommu_table; | 442 | PCI_DN(dn)->iommu_table = ppci->iommu_table; |
438 | } | 443 | } |
439 | 444 | ||
440 | 445 | ||
@@ -449,11 +454,11 @@ static void iommu_dev_setup_pSeries(struct pci_dev *dev) | |||
449 | */ | 454 | */ |
450 | mydn = dn = pci_device_to_OF_node(dev); | 455 | mydn = dn = pci_device_to_OF_node(dev); |
451 | 456 | ||
452 | while (dn && dn->iommu_table == NULL) | 457 | while (dn && dn->data && PCI_DN(dn)->iommu_table == NULL) |
453 | dn = dn->parent; | 458 | dn = dn->parent; |
454 | 459 | ||
455 | if (dn) { | 460 | if (dn && dn->data) { |
456 | mydn->iommu_table = dn->iommu_table; | 461 | PCI_DN(mydn)->iommu_table = PCI_DN(dn)->iommu_table; |
457 | } else { | 462 | } else { |
458 | DBG("iommu_dev_setup_pSeries, dev %p (%s) has no iommu table\n", dev, dev->pretty_name); | 463 | DBG("iommu_dev_setup_pSeries, dev %p (%s) has no iommu table\n", dev, dev->pretty_name); |
459 | } | 464 | } |
@@ -463,10 +468,11 @@ static int iommu_reconfig_notifier(struct notifier_block *nb, unsigned long acti | |||
463 | { | 468 | { |
464 | int err = NOTIFY_OK; | 469 | int err = NOTIFY_OK; |
465 | struct device_node *np = node; | 470 | struct device_node *np = node; |
471 | struct pci_dn *pci = np->data; | ||
466 | 472 | ||
467 | switch (action) { | 473 | switch (action) { |
468 | case PSERIES_RECONFIG_REMOVE: | 474 | case PSERIES_RECONFIG_REMOVE: |
469 | if (np->iommu_table && | 475 | if (pci->iommu_table && |
470 | get_property(np, "ibm,dma-window", NULL)) | 476 | get_property(np, "ibm,dma-window", NULL)) |
471 | iommu_free_table(np); | 477 | iommu_free_table(np); |
472 | break; | 478 | break; |
@@ -486,6 +492,7 @@ static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev) | |||
486 | struct device_node *pdn, *dn; | 492 | struct device_node *pdn, *dn; |
487 | struct iommu_table *tbl; | 493 | struct iommu_table *tbl; |
488 | int *dma_window = NULL; | 494 | int *dma_window = NULL; |
495 | struct pci_dn *pci; | ||
489 | 496 | ||
490 | DBG("iommu_dev_setup_pSeriesLP, dev %p (%s)\n", dev, dev->pretty_name); | 497 | DBG("iommu_dev_setup_pSeriesLP, dev %p (%s)\n", dev, dev->pretty_name); |
491 | 498 | ||
@@ -497,8 +504,10 @@ static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev) | |||
497 | */ | 504 | */ |
498 | dn = pci_device_to_OF_node(dev); | 505 | dn = pci_device_to_OF_node(dev); |
499 | 506 | ||
500 | for (pdn = dn; pdn && !pdn->iommu_table; pdn = pdn->parent) { | 507 | for (pdn = dn; pdn && pdn->data && !PCI_DN(pdn)->iommu_table; |
501 | dma_window = (unsigned int *)get_property(pdn, "ibm,dma-window", NULL); | 508 | pdn = pdn->parent) { |
509 | dma_window = (unsigned int *) | ||
510 | get_property(pdn, "ibm,dma-window", NULL); | ||
502 | if (dma_window) | 511 | if (dma_window) |
503 | break; | 512 | break; |
504 | } | 513 | } |
@@ -515,20 +524,21 @@ static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev) | |||
515 | DBG("Found DMA window, allocating table\n"); | 524 | DBG("Found DMA window, allocating table\n"); |
516 | } | 525 | } |
517 | 526 | ||
518 | if (!pdn->iommu_table) { | 527 | pci = pdn->data; |
528 | if (!pci->iommu_table) { | ||
519 | /* iommu_table_setparms_lpar needs bussubno. */ | 529 | /* iommu_table_setparms_lpar needs bussubno. */ |
520 | pdn->bussubno = pdn->phb->bus->number; | 530 | pci->bussubno = pci->phb->bus->number; |
521 | 531 | ||
522 | tbl = (struct iommu_table *)kmalloc(sizeof(struct iommu_table), | 532 | tbl = (struct iommu_table *)kmalloc(sizeof(struct iommu_table), |
523 | GFP_KERNEL); | 533 | GFP_KERNEL); |
524 | 534 | ||
525 | iommu_table_setparms_lpar(pdn->phb, pdn, tbl, dma_window); | 535 | iommu_table_setparms_lpar(pci->phb, pdn, tbl, dma_window); |
526 | 536 | ||
527 | pdn->iommu_table = iommu_init_table(tbl); | 537 | pci->iommu_table = iommu_init_table(tbl); |
528 | } | 538 | } |
529 | 539 | ||
530 | if (pdn != dn) | 540 | if (pdn != dn) |
531 | dn->iommu_table = pdn->iommu_table; | 541 | PCI_DN(dn)->iommu_table = pci->iommu_table; |
532 | } | 542 | } |
533 | 543 | ||
534 | static void iommu_bus_setup_null(struct pci_bus *b) { } | 544 | static void iommu_bus_setup_null(struct pci_bus *b) { } |
diff --git a/arch/ppc64/kernel/pci.c b/arch/ppc64/kernel/pci.c index b5ca7d8347e2..446b4654883f 100644 --- a/arch/ppc64/kernel/pci.c +++ b/arch/ppc64/kernel/pci.c | |||
@@ -837,9 +837,11 @@ int pcibios_scan_all_fns(struct pci_bus *bus, int devfn) | |||
837 | * device tree. If they are then we need to scan all the | 837 | * device tree. If they are then we need to scan all the |
838 | * functions of this slot. | 838 | * functions of this slot. |
839 | */ | 839 | */ |
840 | for (dn = busdn->child; dn; dn = dn->sibling) | 840 | for (dn = busdn->child; dn; dn = dn->sibling) { |
841 | if ((dn->devfn >> 3) == (devfn >> 3)) | 841 | struct pci_dn *pdn = dn->data; |
842 | if (pdn && (pdn->devfn >> 3) == (devfn >> 3)) | ||
842 | return 1; | 843 | return 1; |
844 | } | ||
843 | 845 | ||
844 | return 0; | 846 | return 0; |
845 | } | 847 | } |
diff --git a/arch/ppc64/kernel/pci.h b/arch/ppc64/kernel/pci.h index 26be78b13af1..5eb2cc320566 100644 --- a/arch/ppc64/kernel/pci.h +++ b/arch/ppc64/kernel/pci.h | |||
@@ -34,7 +34,6 @@ void *traverse_pci_devices(struct device_node *start, traverse_func pre, | |||
34 | 34 | ||
35 | void pci_devs_phb_init(void); | 35 | void pci_devs_phb_init(void); |
36 | void pci_devs_phb_init_dynamic(struct pci_controller *phb); | 36 | void pci_devs_phb_init_dynamic(struct pci_controller *phb); |
37 | struct device_node *fetch_dev_dn(struct pci_dev *dev); | ||
38 | 37 | ||
39 | /* PCI address cache management routines */ | 38 | /* PCI address cache management routines */ |
40 | void pci_addr_cache_insert_device(struct pci_dev *dev); | 39 | void pci_addr_cache_insert_device(struct pci_dev *dev); |
diff --git a/arch/ppc64/kernel/pci_dn.c b/arch/ppc64/kernel/pci_dn.c index ec345462afc3..a86389d07d57 100644 --- a/arch/ppc64/kernel/pci_dn.c +++ b/arch/ppc64/kernel/pci_dn.c | |||
@@ -23,6 +23,8 @@ | |||
23 | #include <linux/pci.h> | 23 | #include <linux/pci.h> |
24 | #include <linux/string.h> | 24 | #include <linux/string.h> |
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/slab.h> | ||
27 | #include <linux/bootmem.h> | ||
26 | 28 | ||
27 | #include <asm/io.h> | 29 | #include <asm/io.h> |
28 | #include <asm/prom.h> | 30 | #include <asm/prom.h> |
@@ -40,16 +42,26 @@ static void * __devinit update_dn_pci_info(struct device_node *dn, void *data) | |||
40 | struct pci_controller *phb = data; | 42 | struct pci_controller *phb = data; |
41 | int *type = (int *)get_property(dn, "ibm,pci-config-space-type", NULL); | 43 | int *type = (int *)get_property(dn, "ibm,pci-config-space-type", NULL); |
42 | u32 *regs; | 44 | u32 *regs; |
43 | 45 | struct pci_dn *pdn; | |
44 | dn->phb = phb; | 46 | |
47 | if (phb->is_dynamic) | ||
48 | pdn = kmalloc(sizeof(*pdn), GFP_KERNEL); | ||
49 | else | ||
50 | pdn = alloc_bootmem(sizeof(*pdn)); | ||
51 | if (pdn == NULL) | ||
52 | return NULL; | ||
53 | memset(pdn, 0, sizeof(*pdn)); | ||
54 | dn->data = pdn; | ||
55 | pdn->node = dn; | ||
56 | pdn->phb = phb; | ||
45 | regs = (u32 *)get_property(dn, "reg", NULL); | 57 | regs = (u32 *)get_property(dn, "reg", NULL); |
46 | if (regs) { | 58 | if (regs) { |
47 | /* First register entry is addr (00BBSS00) */ | 59 | /* First register entry is addr (00BBSS00) */ |
48 | dn->busno = (regs[0] >> 16) & 0xff; | 60 | pdn->busno = (regs[0] >> 16) & 0xff; |
49 | dn->devfn = (regs[0] >> 8) & 0xff; | 61 | pdn->devfn = (regs[0] >> 8) & 0xff; |
50 | } | 62 | } |
51 | 63 | ||
52 | dn->pci_ext_config_space = (type && *type == 1); | 64 | pdn->pci_ext_config_space = (type && *type == 1); |
53 | return NULL; | 65 | return NULL; |
54 | } | 66 | } |
55 | 67 | ||
@@ -112,10 +124,15 @@ void *traverse_pci_devices(struct device_node *start, traverse_func pre, | |||
112 | void __devinit pci_devs_phb_init_dynamic(struct pci_controller *phb) | 124 | void __devinit pci_devs_phb_init_dynamic(struct pci_controller *phb) |
113 | { | 125 | { |
114 | struct device_node * dn = (struct device_node *) phb->arch_data; | 126 | struct device_node * dn = (struct device_node *) phb->arch_data; |
127 | struct pci_dn *pdn; | ||
115 | 128 | ||
116 | /* PHB nodes themselves must not match */ | 129 | /* PHB nodes themselves must not match */ |
117 | dn->devfn = dn->busno = -1; | 130 | update_dn_pci_info(dn, phb); |
118 | dn->phb = phb; | 131 | pdn = dn->data; |
132 | if (pdn) { | ||
133 | pdn->devfn = pdn->busno = -1; | ||
134 | pdn->phb = phb; | ||
135 | } | ||
119 | 136 | ||
120 | /* Update dn->phb ptrs for new phb and children devices */ | 137 | /* Update dn->phb ptrs for new phb and children devices */ |
121 | traverse_pci_devices(dn, update_dn_pci_info, phb); | 138 | traverse_pci_devices(dn, update_dn_pci_info, phb); |
@@ -123,14 +140,17 @@ void __devinit pci_devs_phb_init_dynamic(struct pci_controller *phb) | |||
123 | 140 | ||
124 | /* | 141 | /* |
125 | * Traversal func that looks for a <busno,devfcn> value. | 142 | * Traversal func that looks for a <busno,devfcn> value. |
126 | * If found, the device_node is returned (thus terminating the traversal). | 143 | * If found, the pci_dn is returned (thus terminating the traversal). |
127 | */ | 144 | */ |
128 | static void *is_devfn_node(struct device_node *dn, void *data) | 145 | static void *is_devfn_node(struct device_node *dn, void *data) |
129 | { | 146 | { |
130 | int busno = ((unsigned long)data >> 8) & 0xff; | 147 | int busno = ((unsigned long)data >> 8) & 0xff; |
131 | int devfn = ((unsigned long)data) & 0xff; | 148 | int devfn = ((unsigned long)data) & 0xff; |
149 | struct pci_dn *pci = dn->data; | ||
132 | 150 | ||
133 | return ((devfn == dn->devfn) && (busno == dn->busno)) ? dn : NULL; | 151 | if (pci && (devfn == pci->devfn) && (busno == pci->busno)) |
152 | return dn; | ||
153 | return NULL; | ||
134 | } | 154 | } |
135 | 155 | ||
136 | /* | 156 | /* |
@@ -149,13 +169,10 @@ static void *is_devfn_node(struct device_node *dn, void *data) | |||
149 | struct device_node *fetch_dev_dn(struct pci_dev *dev) | 169 | struct device_node *fetch_dev_dn(struct pci_dev *dev) |
150 | { | 170 | { |
151 | struct device_node *orig_dn = dev->sysdata; | 171 | struct device_node *orig_dn = dev->sysdata; |
152 | struct pci_controller *phb = orig_dn->phb; /* assume same phb as orig_dn */ | ||
153 | struct device_node *phb_dn; | ||
154 | struct device_node *dn; | 172 | struct device_node *dn; |
155 | unsigned long searchval = (dev->bus->number << 8) | dev->devfn; | 173 | unsigned long searchval = (dev->bus->number << 8) | dev->devfn; |
156 | 174 | ||
157 | phb_dn = phb->arch_data; | 175 | dn = traverse_pci_devices(orig_dn, is_devfn_node, (void *)searchval); |
158 | dn = traverse_pci_devices(phb_dn, is_devfn_node, (void *)searchval); | ||
159 | if (dn) | 176 | if (dn) |
160 | dev->sysdata = dn; | 177 | dev->sysdata = dn; |
161 | return dn; | 178 | return dn; |
@@ -165,11 +182,13 @@ EXPORT_SYMBOL(fetch_dev_dn); | |||
165 | static int pci_dn_reconfig_notifier(struct notifier_block *nb, unsigned long action, void *node) | 182 | static int pci_dn_reconfig_notifier(struct notifier_block *nb, unsigned long action, void *node) |
166 | { | 183 | { |
167 | struct device_node *np = node; | 184 | struct device_node *np = node; |
185 | struct pci_dn *pci; | ||
168 | int err = NOTIFY_OK; | 186 | int err = NOTIFY_OK; |
169 | 187 | ||
170 | switch (action) { | 188 | switch (action) { |
171 | case PSERIES_RECONFIG_ADD: | 189 | case PSERIES_RECONFIG_ADD: |
172 | update_dn_pci_info(np, np->parent->phb); | 190 | pci = np->parent->data; |
191 | update_dn_pci_info(np, pci->phb); | ||
173 | break; | 192 | break; |
174 | default: | 193 | default: |
175 | err = NOTIFY_DONE; | 194 | err = NOTIFY_DONE; |
diff --git a/arch/ppc64/kernel/pci_iommu.c b/arch/ppc64/kernel/pci_iommu.c index ef0a62b916be..14647e09c9cd 100644 --- a/arch/ppc64/kernel/pci_iommu.c +++ b/arch/ppc64/kernel/pci_iommu.c | |||
@@ -66,7 +66,7 @@ static inline struct iommu_table *devnode_table(struct device *dev) | |||
66 | #endif /* CONFIG_PPC_ISERIES */ | 66 | #endif /* CONFIG_PPC_ISERIES */ |
67 | 67 | ||
68 | #ifdef CONFIG_PPC_MULTIPLATFORM | 68 | #ifdef CONFIG_PPC_MULTIPLATFORM |
69 | return PCI_GET_DN(pdev)->iommu_table; | 69 | return PCI_DN(PCI_GET_DN(pdev))->iommu_table; |
70 | #endif /* CONFIG_PPC_MULTIPLATFORM */ | 70 | #endif /* CONFIG_PPC_MULTIPLATFORM */ |
71 | } | 71 | } |
72 | 72 | ||
diff --git a/arch/ppc64/kernel/pmac_feature.c b/arch/ppc64/kernel/pmac_feature.c index 98ed2bccab1a..eb4e6c3f694d 100644 --- a/arch/ppc64/kernel/pmac_feature.c +++ b/arch/ppc64/kernel/pmac_feature.c | |||
@@ -674,6 +674,7 @@ void __init pmac_check_ht_link(void) | |||
674 | #if 0 /* Disabled for now */ | 674 | #if 0 /* Disabled for now */ |
675 | u32 ufreq, freq, ucfg, cfg; | 675 | u32 ufreq, freq, ucfg, cfg; |
676 | struct device_node *pcix_node; | 676 | struct device_node *pcix_node; |
677 | struct pci_dn *pdn; | ||
677 | u8 px_bus, px_devfn; | 678 | u8 px_bus, px_devfn; |
678 | struct pci_controller *px_hose; | 679 | struct pci_controller *px_hose; |
679 | 680 | ||
@@ -687,9 +688,10 @@ void __init pmac_check_ht_link(void) | |||
687 | printk("No PCI-X bridge found\n"); | 688 | printk("No PCI-X bridge found\n"); |
688 | return; | 689 | return; |
689 | } | 690 | } |
690 | px_hose = pcix_node->phb; | 691 | pdn = pcix_node->data; |
691 | px_bus = pcix_node->busno; | 692 | px_hose = pdn->phb; |
692 | px_devfn = pcix_node->devfn; | 693 | px_bus = pdn->busno; |
694 | px_devfn = pdn->devfn; | ||
693 | 695 | ||
694 | early_read_config_dword(px_hose, px_bus, px_devfn, 0xc4, &cfg); | 696 | early_read_config_dword(px_hose, px_bus, px_devfn, 0xc4, &cfg); |
695 | early_read_config_dword(px_hose, px_bus, px_devfn, 0xcc, &freq); | 697 | early_read_config_dword(px_hose, px_bus, px_devfn, 0xcc, &freq); |
diff --git a/arch/ppc64/kernel/pmac_pci.c b/arch/ppc64/kernel/pmac_pci.c index 71fe911ad183..d37bff2d7d40 100644 --- a/arch/ppc64/kernel/pmac_pci.c +++ b/arch/ppc64/kernel/pmac_pci.c | |||
@@ -242,7 +242,7 @@ static int u3_ht_skip_device(struct pci_controller *hose, | |||
242 | else | 242 | else |
243 | busdn = hose->arch_data; | 243 | busdn = hose->arch_data; |
244 | for (dn = busdn->child; dn; dn = dn->sibling) | 244 | for (dn = busdn->child; dn; dn = dn->sibling) |
245 | if (dn->devfn == devfn) | 245 | if (dn->data && PCI_DN(dn)->devfn == devfn) |
246 | break; | 246 | break; |
247 | if (dn == NULL) | 247 | if (dn == NULL) |
248 | return -1; | 248 | return -1; |
@@ -746,9 +746,9 @@ void __init pmac_pci_init(void) | |||
746 | */ | 746 | */ |
747 | if (u3_agp) { | 747 | if (u3_agp) { |
748 | struct device_node *np = u3_agp->arch_data; | 748 | struct device_node *np = u3_agp->arch_data; |
749 | np->busno = 0xf0; | 749 | PCI_DN(np)->busno = 0xf0; |
750 | for (np = np->child; np; np = np->sibling) | 750 | for (np = np->child; np; np = np->sibling) |
751 | np->busno = 0xf0; | 751 | PCI_DN(np)->busno = 0xf0; |
752 | } | 752 | } |
753 | 753 | ||
754 | pmac_check_ht_link(); | 754 | pmac_check_ht_link(); |
diff --git a/arch/ppc64/kernel/prom.c b/arch/ppc64/kernel/prom.c index 6ad5a8467f87..7035deb6de92 100644 --- a/arch/ppc64/kernel/prom.c +++ b/arch/ppc64/kernel/prom.c | |||
@@ -1733,6 +1733,7 @@ static void of_node_release(struct kref *kref) | |||
1733 | kfree(node->intrs); | 1733 | kfree(node->intrs); |
1734 | kfree(node->addrs); | 1734 | kfree(node->addrs); |
1735 | kfree(node->full_name); | 1735 | kfree(node->full_name); |
1736 | kfree(node->data); | ||
1736 | kfree(node); | 1737 | kfree(node); |
1737 | } | 1738 | } |
1738 | 1739 | ||
diff --git a/arch/ppc64/kernel/rtas_pci.c b/arch/ppc64/kernel/rtas_pci.c index 1dccadaddd1d..4a9719b48abe 100644 --- a/arch/ppc64/kernel/rtas_pci.c +++ b/arch/ppc64/kernel/rtas_pci.c | |||
@@ -48,7 +48,7 @@ static int write_pci_config; | |||
48 | static int ibm_read_pci_config; | 48 | static int ibm_read_pci_config; |
49 | static int ibm_write_pci_config; | 49 | static int ibm_write_pci_config; |
50 | 50 | ||
51 | static int config_access_valid(struct device_node *dn, int where) | 51 | static int config_access_valid(struct pci_dn *dn, int where) |
52 | { | 52 | { |
53 | if (where < 256) | 53 | if (where < 256) |
54 | return 1; | 54 | return 1; |
@@ -78,15 +78,17 @@ static int rtas_read_config(struct device_node *dn, int where, int size, u32 *va | |||
78 | int returnval = -1; | 78 | int returnval = -1; |
79 | unsigned long buid, addr; | 79 | unsigned long buid, addr; |
80 | int ret; | 80 | int ret; |
81 | struct pci_dn *pdn; | ||
81 | 82 | ||
82 | if (!dn) | 83 | if (!dn || !dn->data) |
83 | return PCIBIOS_DEVICE_NOT_FOUND; | 84 | return PCIBIOS_DEVICE_NOT_FOUND; |
84 | if (!config_access_valid(dn, where)) | 85 | pdn = dn->data; |
86 | if (!config_access_valid(pdn, where)) | ||
85 | return PCIBIOS_BAD_REGISTER_NUMBER; | 87 | return PCIBIOS_BAD_REGISTER_NUMBER; |
86 | 88 | ||
87 | addr = ((where & 0xf00) << 20) | (dn->busno << 16) | | 89 | addr = ((where & 0xf00) << 20) | (pdn->busno << 16) | |
88 | (dn->devfn << 8) | (where & 0xff); | 90 | (pdn->devfn << 8) | (where & 0xff); |
89 | buid = dn->phb->buid; | 91 | buid = pdn->phb->buid; |
90 | if (buid) { | 92 | if (buid) { |
91 | ret = rtas_call(ibm_read_pci_config, 4, 2, &returnval, | 93 | ret = rtas_call(ibm_read_pci_config, 4, 2, &returnval, |
92 | addr, buid >> 32, buid & 0xffffffff, size); | 94 | addr, buid >> 32, buid & 0xffffffff, size); |
@@ -98,8 +100,8 @@ static int rtas_read_config(struct device_node *dn, int where, int size, u32 *va | |||
98 | if (ret) | 100 | if (ret) |
99 | return PCIBIOS_DEVICE_NOT_FOUND; | 101 | return PCIBIOS_DEVICE_NOT_FOUND; |
100 | 102 | ||
101 | if (returnval == EEH_IO_ERROR_VALUE(size) | 103 | if (returnval == EEH_IO_ERROR_VALUE(size) && |
102 | && eeh_dn_check_failure (dn, NULL)) | 104 | eeh_dn_check_failure (dn, NULL)) |
103 | return PCIBIOS_DEVICE_NOT_FOUND; | 105 | return PCIBIOS_DEVICE_NOT_FOUND; |
104 | 106 | ||
105 | return PCIBIOS_SUCCESSFUL; | 107 | return PCIBIOS_SUCCESSFUL; |
@@ -118,24 +120,28 @@ static int rtas_pci_read_config(struct pci_bus *bus, | |||
118 | 120 | ||
119 | /* Search only direct children of the bus */ | 121 | /* Search only direct children of the bus */ |
120 | for (dn = busdn->child; dn; dn = dn->sibling) | 122 | for (dn = busdn->child; dn; dn = dn->sibling) |
121 | if (dn->devfn == devfn && of_device_available(dn)) | 123 | if (dn->data && PCI_DN(dn)->devfn == devfn |
124 | && of_device_available(dn)) | ||
122 | return rtas_read_config(dn, where, size, val); | 125 | return rtas_read_config(dn, where, size, val); |
126 | |||
123 | return PCIBIOS_DEVICE_NOT_FOUND; | 127 | return PCIBIOS_DEVICE_NOT_FOUND; |
124 | } | 128 | } |
125 | 129 | ||
126 | static int rtas_write_config(struct device_node *dn, int where, int size, u32 val) | 130 | int rtas_write_config(struct device_node *dn, int where, int size, u32 val) |
127 | { | 131 | { |
128 | unsigned long buid, addr; | 132 | unsigned long buid, addr; |
129 | int ret; | 133 | int ret; |
134 | struct pci_dn *pdn; | ||
130 | 135 | ||
131 | if (!dn) | 136 | if (!dn || !dn->data) |
132 | return PCIBIOS_DEVICE_NOT_FOUND; | 137 | return PCIBIOS_DEVICE_NOT_FOUND; |
133 | if (!config_access_valid(dn, where)) | 138 | pdn = dn->data; |
139 | if (!config_access_valid(pdn, where)) | ||
134 | return PCIBIOS_BAD_REGISTER_NUMBER; | 140 | return PCIBIOS_BAD_REGISTER_NUMBER; |
135 | 141 | ||
136 | addr = ((where & 0xf00) << 20) | (dn->busno << 16) | | 142 | addr = ((where & 0xf00) << 20) | (pdn->busno << 16) | |
137 | (dn->devfn << 8) | (where & 0xff); | 143 | (pdn->devfn << 8) | (where & 0xff); |
138 | buid = dn->phb->buid; | 144 | buid = pdn->phb->buid; |
139 | if (buid) { | 145 | if (buid) { |
140 | ret = rtas_call(ibm_write_pci_config, 5, 1, NULL, addr, buid >> 32, buid & 0xffffffff, size, (ulong) val); | 146 | ret = rtas_call(ibm_write_pci_config, 5, 1, NULL, addr, buid >> 32, buid & 0xffffffff, size, (ulong) val); |
141 | } else { | 147 | } else { |
@@ -161,7 +167,8 @@ static int rtas_pci_write_config(struct pci_bus *bus, | |||
161 | 167 | ||
162 | /* Search only direct children of the bus */ | 168 | /* Search only direct children of the bus */ |
163 | for (dn = busdn->child; dn; dn = dn->sibling) | 169 | for (dn = busdn->child; dn; dn = dn->sibling) |
164 | if (dn->devfn == devfn && of_device_available(dn)) | 170 | if (dn->data && PCI_DN(dn)->devfn == devfn |
171 | && of_device_available(dn)) | ||
165 | return rtas_write_config(dn, where, size, val); | 172 | return rtas_write_config(dn, where, size, val); |
166 | return PCIBIOS_DEVICE_NOT_FOUND; | 173 | return PCIBIOS_DEVICE_NOT_FOUND; |
167 | } | 174 | } |
diff --git a/arch/ppc64/kernel/sys_ppc32.c b/arch/ppc64/kernel/sys_ppc32.c index 214914a95a50..57a6db7d7c9c 100644 --- a/arch/ppc64/kernel/sys_ppc32.c +++ b/arch/ppc64/kernel/sys_ppc32.c | |||
@@ -747,8 +747,8 @@ asmlinkage int sys32_pciconfig_iobase(u32 which, u32 in_bus, u32 in_devfn) | |||
747 | if (bus == NULL || bus->sysdata == NULL) | 747 | if (bus == NULL || bus->sysdata == NULL) |
748 | return -ENODEV; | 748 | return -ENODEV; |
749 | 749 | ||
750 | hose_node = (struct device_node *)bus->sysdata; | 750 | hose_node = bus->sysdata; |
751 | hose = hose_node->phb; | 751 | hose = PCI_DN(hose_node)->phb; |
752 | 752 | ||
753 | switch (which) { | 753 | switch (which) { |
754 | case IOBASE_BRIDGE_NUMBER: | 754 | case IOBASE_BRIDGE_NUMBER: |
diff --git a/arch/ppc64/kernel/u3_iommu.c b/arch/ppc64/kernel/u3_iommu.c index b6e3bca4102d..41ea09cb9ac7 100644 --- a/arch/ppc64/kernel/u3_iommu.c +++ b/arch/ppc64/kernel/u3_iommu.c | |||
@@ -276,7 +276,7 @@ static void iommu_dev_setup_u3(struct pci_dev *dev) | |||
276 | dn = pci_device_to_OF_node(dev); | 276 | dn = pci_device_to_OF_node(dev); |
277 | 277 | ||
278 | if (dn) | 278 | if (dn) |
279 | dn->iommu_table = &iommu_table_u3; | 279 | PCI_DN(dn)->iommu_table = &iommu_table_u3; |
280 | } | 280 | } |
281 | 281 | ||
282 | static void iommu_bus_setup_u3(struct pci_bus *bus) | 282 | static void iommu_bus_setup_u3(struct pci_bus *bus) |
@@ -291,7 +291,7 @@ static void iommu_bus_setup_u3(struct pci_bus *bus) | |||
291 | dn = pci_bus_to_OF_node(bus); | 291 | dn = pci_bus_to_OF_node(bus); |
292 | 292 | ||
293 | if (dn) | 293 | if (dn) |
294 | dn->iommu_table = &iommu_table_u3; | 294 | PCI_DN(dn)->iommu_table = &iommu_table_u3; |
295 | } | 295 | } |
296 | 296 | ||
297 | static void iommu_dev_setup_null(struct pci_dev *dev) { } | 297 | static void iommu_dev_setup_null(struct pci_dev *dev) { } |