@@ -554,13 +554,65 @@ static void aspm_calc_l1ss_info(struct pcie_link_state *link,
554
554
aspm_program_l1ss (child , cctl1 , ctl2 );
555
555
}
556
556
557
+ static void aspm_l1ss_init (struct pcie_link_state * link )
558
+ {
559
+ struct pci_dev * child = link -> downstream , * parent = link -> pdev ;
560
+ u32 parent_l1ss_cap , child_l1ss_cap ;
561
+ u32 parent_l1ss_ctl1 = 0 , child_l1ss_ctl1 = 0 ;
562
+
563
+ /* Setup L1 substate */
564
+ pci_read_config_dword (parent , parent -> l1ss + PCI_L1SS_CAP ,
565
+ & parent_l1ss_cap );
566
+ pci_read_config_dword (child , child -> l1ss + PCI_L1SS_CAP ,
567
+ & child_l1ss_cap );
568
+
569
+ if (!(parent_l1ss_cap & PCI_L1SS_CAP_L1_PM_SS ))
570
+ parent_l1ss_cap = 0 ;
571
+ if (!(child_l1ss_cap & PCI_L1SS_CAP_L1_PM_SS ))
572
+ child_l1ss_cap = 0 ;
573
+
574
+ /*
575
+ * If we don't have LTR for the entire path from the Root Complex
576
+ * to this device, we can't use ASPM L1.2 because it relies on the
577
+ * LTR_L1.2_THRESHOLD. See PCIe r4.0, secs 5.5.4, 6.18.
578
+ */
579
+ if (!child -> ltr_path )
580
+ child_l1ss_cap &= ~PCI_L1SS_CAP_ASPM_L1_2 ;
581
+
582
+ if (parent_l1ss_cap & child_l1ss_cap & PCI_L1SS_CAP_ASPM_L1_1 )
583
+ link -> aspm_support |= ASPM_STATE_L1_1 ;
584
+ if (parent_l1ss_cap & child_l1ss_cap & PCI_L1SS_CAP_ASPM_L1_2 )
585
+ link -> aspm_support |= ASPM_STATE_L1_2 ;
586
+ if (parent_l1ss_cap & child_l1ss_cap & PCI_L1SS_CAP_PCIPM_L1_1 )
587
+ link -> aspm_support |= ASPM_STATE_L1_1_PCIPM ;
588
+ if (parent_l1ss_cap & child_l1ss_cap & PCI_L1SS_CAP_PCIPM_L1_2 )
589
+ link -> aspm_support |= ASPM_STATE_L1_2_PCIPM ;
590
+
591
+ if (parent_l1ss_cap )
592
+ pci_read_config_dword (parent , parent -> l1ss + PCI_L1SS_CTL1 ,
593
+ & parent_l1ss_ctl1 );
594
+ if (child_l1ss_cap )
595
+ pci_read_config_dword (child , child -> l1ss + PCI_L1SS_CTL1 ,
596
+ & child_l1ss_ctl1 );
597
+
598
+ if (parent_l1ss_ctl1 & child_l1ss_ctl1 & PCI_L1SS_CTL1_ASPM_L1_1 )
599
+ link -> aspm_enabled |= ASPM_STATE_L1_1 ;
600
+ if (parent_l1ss_ctl1 & child_l1ss_ctl1 & PCI_L1SS_CTL1_ASPM_L1_2 )
601
+ link -> aspm_enabled |= ASPM_STATE_L1_2 ;
602
+ if (parent_l1ss_ctl1 & child_l1ss_ctl1 & PCI_L1SS_CTL1_PCIPM_L1_1 )
603
+ link -> aspm_enabled |= ASPM_STATE_L1_1_PCIPM ;
604
+ if (parent_l1ss_ctl1 & child_l1ss_ctl1 & PCI_L1SS_CTL1_PCIPM_L1_2 )
605
+ link -> aspm_enabled |= ASPM_STATE_L1_2_PCIPM ;
606
+
607
+ if (link -> aspm_support & ASPM_STATE_L1SS )
608
+ aspm_calc_l1ss_info (link , parent_l1ss_cap , child_l1ss_cap );
609
+ }
610
+
557
611
static void pcie_aspm_cap_init (struct pcie_link_state * link , int blacklist )
558
612
{
559
613
struct pci_dev * child = link -> downstream , * parent = link -> pdev ;
560
614
u32 parent_lnkcap , child_lnkcap ;
561
615
u16 parent_lnkctl , child_lnkctl ;
562
- u32 parent_l1ss_cap , child_l1ss_cap ;
563
- u32 parent_l1ss_ctl1 = 0 , child_l1ss_ctl1 = 0 ;
564
616
struct pci_bus * linkbus = parent -> subordinate ;
565
617
566
618
if (blacklist ) {
@@ -615,52 +667,7 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
615
667
if (parent_lnkctl & child_lnkctl & PCI_EXP_LNKCTL_ASPM_L1 )
616
668
link -> aspm_enabled |= ASPM_STATE_L1 ;
617
669
618
- /* Setup L1 substate */
619
- pci_read_config_dword (parent , parent -> l1ss + PCI_L1SS_CAP ,
620
- & parent_l1ss_cap );
621
- pci_read_config_dword (child , child -> l1ss + PCI_L1SS_CAP ,
622
- & child_l1ss_cap );
623
-
624
- if (!(parent_l1ss_cap & PCI_L1SS_CAP_L1_PM_SS ))
625
- parent_l1ss_cap = 0 ;
626
- if (!(child_l1ss_cap & PCI_L1SS_CAP_L1_PM_SS ))
627
- child_l1ss_cap = 0 ;
628
-
629
- /*
630
- * If we don't have LTR for the entire path from the Root Complex
631
- * to this device, we can't use ASPM L1.2 because it relies on the
632
- * LTR_L1.2_THRESHOLD. See PCIe r4.0, secs 5.5.4, 6.18.
633
- */
634
- if (!child -> ltr_path )
635
- child_l1ss_cap &= ~PCI_L1SS_CAP_ASPM_L1_2 ;
636
-
637
- if (parent_l1ss_cap & child_l1ss_cap & PCI_L1SS_CAP_ASPM_L1_1 )
638
- link -> aspm_support |= ASPM_STATE_L1_1 ;
639
- if (parent_l1ss_cap & child_l1ss_cap & PCI_L1SS_CAP_ASPM_L1_2 )
640
- link -> aspm_support |= ASPM_STATE_L1_2 ;
641
- if (parent_l1ss_cap & child_l1ss_cap & PCI_L1SS_CAP_PCIPM_L1_1 )
642
- link -> aspm_support |= ASPM_STATE_L1_1_PCIPM ;
643
- if (parent_l1ss_cap & child_l1ss_cap & PCI_L1SS_CAP_PCIPM_L1_2 )
644
- link -> aspm_support |= ASPM_STATE_L1_2_PCIPM ;
645
-
646
- if (parent_l1ss_cap )
647
- pci_read_config_dword (parent , parent -> l1ss + PCI_L1SS_CTL1 ,
648
- & parent_l1ss_ctl1 );
649
- if (child_l1ss_cap )
650
- pci_read_config_dword (child , child -> l1ss + PCI_L1SS_CTL1 ,
651
- & child_l1ss_ctl1 );
652
-
653
- if (parent_l1ss_ctl1 & child_l1ss_ctl1 & PCI_L1SS_CTL1_ASPM_L1_1 )
654
- link -> aspm_enabled |= ASPM_STATE_L1_1 ;
655
- if (parent_l1ss_ctl1 & child_l1ss_ctl1 & PCI_L1SS_CTL1_ASPM_L1_2 )
656
- link -> aspm_enabled |= ASPM_STATE_L1_2 ;
657
- if (parent_l1ss_ctl1 & child_l1ss_ctl1 & PCI_L1SS_CTL1_PCIPM_L1_1 )
658
- link -> aspm_enabled |= ASPM_STATE_L1_1_PCIPM ;
659
- if (parent_l1ss_ctl1 & child_l1ss_ctl1 & PCI_L1SS_CTL1_PCIPM_L1_2 )
660
- link -> aspm_enabled |= ASPM_STATE_L1_2_PCIPM ;
661
-
662
- if (link -> aspm_support & ASPM_STATE_L1SS )
663
- aspm_calc_l1ss_info (link , parent_l1ss_cap , child_l1ss_cap );
670
+ aspm_l1ss_init (link );
664
671
665
672
/* Save default state */
666
673
link -> aspm_default = link -> aspm_enabled ;
0 commit comments