Skip to content

Commit ff209ec

Browse files
committed
Revert "PCI/ASPM: Refactor L1 PM Substates Control Register programming"
This reverts commit 5e85eba. Thomas Witt reported that 5e85eba ("PCI/ASPM: Refactor L1 PM Substates Control Register programming") broke suspend/resume on a Tuxedo Infinitybook S 14 v5, which seems to use a Clevo L140CU Mainboard. The main symptom is: iwlwifi 0000:02:00.0: Unable to change power state from D3hot to D0, device inaccessible nvme 0000:03:00.0: Unable to change power state from D3hot to D0, device inaccessible and the machine is only partially usable after resume. It can't run dmesg and can't do a clean reboot. This happens on every suspend/resume cycle. Revert 5e85eba until we can figure out the root cause. Fixes: 5e85eba ("PCI/ASPM: Refactor L1 PM Substates Control Register programming") Link: https://bugzilla.kernel.org/show_bug.cgi?id=216877 Reported-by: Thomas Witt <[email protected]> Tested-by: Thomas Witt <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Cc: [email protected] # v6.1+ Cc: Vidya Sagar <[email protected]>
1 parent a7152be commit ff209ec

File tree

1 file changed

+34
-40
lines changed

1 file changed

+34
-40
lines changed

drivers/pci/pcie/aspm.c

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -470,31 +470,6 @@ static void pci_clear_and_set_dword(struct pci_dev *pdev, int pos,
470470
pci_write_config_dword(pdev, pos, val);
471471
}
472472

473-
static void aspm_program_l1ss(struct pci_dev *dev, u32 ctl1, u32 ctl2)
474-
{
475-
u16 l1ss = dev->l1ss;
476-
u32 l1_2_enable;
477-
478-
/*
479-
* Per PCIe r6.0, sec 5.5.4, T_POWER_ON in PCI_L1SS_CTL2 must be
480-
* programmed prior to setting the L1.2 enable bits in PCI_L1SS_CTL1.
481-
*/
482-
pci_write_config_dword(dev, l1ss + PCI_L1SS_CTL2, ctl2);
483-
484-
/*
485-
* In addition, Common_Mode_Restore_Time and LTR_L1.2_THRESHOLD in
486-
* PCI_L1SS_CTL1 must be programmed *before* setting the L1.2
487-
* enable bits, even though they're all in PCI_L1SS_CTL1.
488-
*/
489-
l1_2_enable = ctl1 & PCI_L1SS_CTL1_L1_2_MASK;
490-
ctl1 &= ~PCI_L1SS_CTL1_L1_2_MASK;
491-
492-
pci_write_config_dword(dev, l1ss + PCI_L1SS_CTL1, ctl1);
493-
if (l1_2_enable)
494-
pci_write_config_dword(dev, l1ss + PCI_L1SS_CTL1,
495-
ctl1 | l1_2_enable);
496-
}
497-
498473
/* Calculate L1.2 PM substate timing parameters */
499474
static void aspm_calc_l1ss_info(struct pcie_link_state *link,
500475
u32 parent_l1ss_cap, u32 child_l1ss_cap)
@@ -504,6 +479,7 @@ static void aspm_calc_l1ss_info(struct pcie_link_state *link,
504479
u32 t_common_mode, t_power_on, l1_2_threshold, scale, value;
505480
u32 ctl1 = 0, ctl2 = 0;
506481
u32 pctl1, pctl2, cctl1, cctl2;
482+
u32 pl1_2_enables, cl1_2_enables;
507483

508484
if (!(link->aspm_support & ASPM_STATE_L1_2_MASK))
509485
return;
@@ -552,21 +528,39 @@ static void aspm_calc_l1ss_info(struct pcie_link_state *link,
552528
ctl2 == pctl2 && ctl2 == cctl2)
553529
return;
554530

555-
pctl1 &= ~(PCI_L1SS_CTL1_CM_RESTORE_TIME |
556-
PCI_L1SS_CTL1_LTR_L12_TH_VALUE |
557-
PCI_L1SS_CTL1_LTR_L12_TH_SCALE);
558-
pctl1 |= (ctl1 & (PCI_L1SS_CTL1_CM_RESTORE_TIME |
559-
PCI_L1SS_CTL1_LTR_L12_TH_VALUE |
560-
PCI_L1SS_CTL1_LTR_L12_TH_SCALE));
561-
aspm_program_l1ss(parent, pctl1, ctl2);
562-
563-
cctl1 &= ~(PCI_L1SS_CTL1_CM_RESTORE_TIME |
564-
PCI_L1SS_CTL1_LTR_L12_TH_VALUE |
565-
PCI_L1SS_CTL1_LTR_L12_TH_SCALE);
566-
cctl1 |= (ctl1 & (PCI_L1SS_CTL1_CM_RESTORE_TIME |
567-
PCI_L1SS_CTL1_LTR_L12_TH_VALUE |
568-
PCI_L1SS_CTL1_LTR_L12_TH_SCALE));
569-
aspm_program_l1ss(child, cctl1, ctl2);
531+
/* Disable L1.2 while updating. See PCIe r5.0, sec 5.5.4, 7.8.3.3 */
532+
pl1_2_enables = pctl1 & PCI_L1SS_CTL1_L1_2_MASK;
533+
cl1_2_enables = cctl1 & PCI_L1SS_CTL1_L1_2_MASK;
534+
535+
if (pl1_2_enables || cl1_2_enables) {
536+
pci_clear_and_set_dword(child, child->l1ss + PCI_L1SS_CTL1,
537+
PCI_L1SS_CTL1_L1_2_MASK, 0);
538+
pci_clear_and_set_dword(parent, parent->l1ss + PCI_L1SS_CTL1,
539+
PCI_L1SS_CTL1_L1_2_MASK, 0);
540+
}
541+
542+
/* Program T_POWER_ON times in both ports */
543+
pci_write_config_dword(parent, parent->l1ss + PCI_L1SS_CTL2, ctl2);
544+
pci_write_config_dword(child, child->l1ss + PCI_L1SS_CTL2, ctl2);
545+
546+
/* Program Common_Mode_Restore_Time in upstream device */
547+
pci_clear_and_set_dword(parent, parent->l1ss + PCI_L1SS_CTL1,
548+
PCI_L1SS_CTL1_CM_RESTORE_TIME, ctl1);
549+
550+
/* Program LTR_L1.2_THRESHOLD time in both ports */
551+
pci_clear_and_set_dword(parent, parent->l1ss + PCI_L1SS_CTL1,
552+
PCI_L1SS_CTL1_LTR_L12_TH_VALUE |
553+
PCI_L1SS_CTL1_LTR_L12_TH_SCALE, ctl1);
554+
pci_clear_and_set_dword(child, child->l1ss + PCI_L1SS_CTL1,
555+
PCI_L1SS_CTL1_LTR_L12_TH_VALUE |
556+
PCI_L1SS_CTL1_LTR_L12_TH_SCALE, ctl1);
557+
558+
if (pl1_2_enables || cl1_2_enables) {
559+
pci_clear_and_set_dword(parent, parent->l1ss + PCI_L1SS_CTL1, 0,
560+
pl1_2_enables);
561+
pci_clear_and_set_dword(child, child->l1ss + PCI_L1SS_CTL1, 0,
562+
cl1_2_enables);
563+
}
570564
}
571565

572566
static void aspm_l1ss_init(struct pcie_link_state *link)

0 commit comments

Comments
 (0)