@@ -366,9 +366,9 @@ static void pnv_pci_handle_eeh_config(struct pnv_phb *phb, u32 pe_no)
366
366
spin_unlock_irqrestore (& phb -> lock , flags );
367
367
}
368
368
369
- static void pnv_pci_config_check_eeh (struct pnv_phb * phb ,
370
- struct device_node * dn )
369
+ static void pnv_pci_config_check_eeh (struct pci_dn * pdn )
371
370
{
371
+ struct pnv_phb * phb = pdn -> phb -> private_data ;
372
372
u8 fstate ;
373
373
__be16 pcierr ;
374
374
int pe_no ;
@@ -379,7 +379,7 @@ static void pnv_pci_config_check_eeh(struct pnv_phb *phb,
379
379
* setup that yet. So all ER errors should be mapped to
380
380
* reserved PE.
381
381
*/
382
- pe_no = PCI_DN ( dn ) -> pe_number ;
382
+ pe_no = pdn -> pe_number ;
383
383
if (pe_no == IODA_INVALID_PE ) {
384
384
if (phb -> type == PNV_PHB_P5IOC2 )
385
385
pe_no = 0 ;
@@ -407,8 +407,7 @@ static void pnv_pci_config_check_eeh(struct pnv_phb *phb,
407
407
}
408
408
409
409
cfg_dbg (" -> EEH check, bdfn=%04x PE#%d fstate=%x\n" ,
410
- (PCI_DN (dn )-> busno << 8 ) | (PCI_DN (dn )-> devfn ),
411
- pe_no , fstate );
410
+ (pdn -> busno << 8 ) | (pdn -> devfn ), pe_no , fstate );
412
411
413
412
/* Clear the frozen state if applicable */
414
413
if (fstate == OPAL_EEH_STOPPED_MMIO_FREEZE ||
@@ -425,10 +424,9 @@ static void pnv_pci_config_check_eeh(struct pnv_phb *phb,
425
424
}
426
425
}
427
426
428
- int pnv_pci_cfg_read (struct device_node * dn ,
427
+ int pnv_pci_cfg_read (struct pci_dn * pdn ,
429
428
int where , int size , u32 * val )
430
429
{
431
- struct pci_dn * pdn = PCI_DN (dn );
432
430
struct pnv_phb * phb = pdn -> phb -> private_data ;
433
431
u32 bdfn = (pdn -> busno << 8 ) | pdn -> devfn ;
434
432
s64 rc ;
@@ -462,10 +460,9 @@ int pnv_pci_cfg_read(struct device_node *dn,
462
460
return PCIBIOS_SUCCESSFUL ;
463
461
}
464
462
465
- int pnv_pci_cfg_write (struct device_node * dn ,
463
+ int pnv_pci_cfg_write (struct pci_dn * pdn ,
466
464
int where , int size , u32 val )
467
465
{
468
- struct pci_dn * pdn = PCI_DN (dn );
469
466
struct pnv_phb * phb = pdn -> phb -> private_data ;
470
467
u32 bdfn = (pdn -> busno << 8 ) | pdn -> devfn ;
471
468
@@ -489,18 +486,17 @@ int pnv_pci_cfg_write(struct device_node *dn,
489
486
}
490
487
491
488
#if CONFIG_EEH
492
- static bool pnv_pci_cfg_check (struct pci_controller * hose ,
493
- struct device_node * dn )
489
+ static bool pnv_pci_cfg_check (struct pci_dn * pdn )
494
490
{
495
491
struct eeh_dev * edev = NULL ;
496
- struct pnv_phb * phb = hose -> private_data ;
492
+ struct pnv_phb * phb = pdn -> phb -> private_data ;
497
493
498
494
/* EEH not enabled ? */
499
495
if (!(phb -> flags & PNV_PHB_FLAG_EEH ))
500
496
return true;
501
497
502
498
/* PE reset or device removed ? */
503
- edev = of_node_to_eeh_dev ( dn ) ;
499
+ edev = pdn -> edev ;
504
500
if (edev ) {
505
501
if (edev -> pe &&
506
502
(edev -> pe -> state & EEH_PE_CFG_BLOCKED ))
@@ -513,8 +509,7 @@ static bool pnv_pci_cfg_check(struct pci_controller *hose,
513
509
return true;
514
510
}
515
511
#else
516
- static inline pnv_pci_cfg_check (struct pci_controller * hose ,
517
- struct device_node * dn )
512
+ static inline pnv_pci_cfg_check (struct pci_dn * pdn )
518
513
{
519
514
return true;
520
515
}
@@ -524,32 +519,26 @@ static int pnv_pci_read_config(struct pci_bus *bus,
524
519
unsigned int devfn ,
525
520
int where , int size , u32 * val )
526
521
{
527
- struct device_node * dn , * busdn = pci_bus_to_OF_node (bus );
528
522
struct pci_dn * pdn ;
529
523
struct pnv_phb * phb ;
530
- bool found = false;
531
524
int ret ;
532
525
533
526
* val = 0xFFFFFFFF ;
534
- for (dn = busdn -> child ; dn ; dn = dn -> sibling ) {
535
- pdn = PCI_DN (dn );
536
- if (pdn && pdn -> devfn == devfn ) {
537
- phb = pdn -> phb -> private_data ;
538
- found = true;
539
- break ;
540
- }
541
- }
527
+ pdn = pci_get_pdn_by_devfn (bus , devfn );
528
+ if (!pdn )
529
+ return PCIBIOS_DEVICE_NOT_FOUND ;
542
530
543
- if (!found || ! pnv_pci_cfg_check (pdn -> phb , dn ))
531
+ if (!pnv_pci_cfg_check (pdn ))
544
532
return PCIBIOS_DEVICE_NOT_FOUND ;
545
533
546
- ret = pnv_pci_cfg_read (dn , where , size , val );
547
- if (phb -> flags & PNV_PHB_FLAG_EEH ) {
534
+ ret = pnv_pci_cfg_read (pdn , where , size , val );
535
+ phb = pdn -> phb -> private_data ;
536
+ if (phb -> flags & PNV_PHB_FLAG_EEH && pdn -> edev ) {
548
537
if (* val == EEH_IO_ERROR_VALUE (size ) &&
549
- eeh_dev_check_failure (of_node_to_eeh_dev ( dn ) ))
538
+ eeh_dev_check_failure (pdn -> edev ))
550
539
return PCIBIOS_DEVICE_NOT_FOUND ;
551
540
} else {
552
- pnv_pci_config_check_eeh (phb , dn );
541
+ pnv_pci_config_check_eeh (pdn );
553
542
}
554
543
555
544
return ret ;
@@ -559,27 +548,21 @@ static int pnv_pci_write_config(struct pci_bus *bus,
559
548
unsigned int devfn ,
560
549
int where , int size , u32 val )
561
550
{
562
- struct device_node * dn , * busdn = pci_bus_to_OF_node (bus );
563
551
struct pci_dn * pdn ;
564
552
struct pnv_phb * phb ;
565
- bool found = false;
566
553
int ret ;
567
554
568
- for (dn = busdn -> child ; dn ; dn = dn -> sibling ) {
569
- pdn = PCI_DN (dn );
570
- if (pdn && pdn -> devfn == devfn ) {
571
- phb = pdn -> phb -> private_data ;
572
- found = true;
573
- break ;
574
- }
575
- }
555
+ pdn = pci_get_pdn_by_devfn (bus , devfn );
556
+ if (!pdn )
557
+ return PCIBIOS_DEVICE_NOT_FOUND ;
576
558
577
- if (!found || ! pnv_pci_cfg_check (pdn -> phb , dn ))
559
+ if (!pnv_pci_cfg_check (pdn ))
578
560
return PCIBIOS_DEVICE_NOT_FOUND ;
579
561
580
- ret = pnv_pci_cfg_write (dn , where , size , val );
562
+ ret = pnv_pci_cfg_write (pdn , where , size , val );
563
+ phb = pdn -> phb -> private_data ;
581
564
if (!(phb -> flags & PNV_PHB_FLAG_EEH ))
582
- pnv_pci_config_check_eeh (phb , dn );
565
+ pnv_pci_config_check_eeh (pdn );
583
566
584
567
return ret ;
585
568
}
0 commit comments