From 93aad8293e2af84db49e5a1ff9fb1eda2063396b Mon Sep 17 00:00:00 2001
From: Myron Stowe <mstowe@redhat.com>
Date: Tue, 25 Mar 2025 12:15:08 -0600
Subject: [PATCH] PCI/ASPM: Fix L1SS saving
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

JIRA: https://issues.redhat.com/browse/RHEL-83611
Upstream Status: 7507eb3e7bfac7c3baef8dd377fdf5871eefd42b

commit 7507eb3e7bfac7c3baef8dd377fdf5871eefd42b
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Fri Jan 31 17:29:13 2025 +0200

    PCI/ASPM: Fix L1SS saving

    Commit 1db806ec06b7 ("PCI/ASPM: Save parent L1SS config in
    pci_save_aspm_l1ss_state()") aimed to perform L1SS config save for both the
    Upstream Port and its upstream bridge when handling an Upstream Port, which
    matches what the L1SS restore side does. However, parent->state_saved can
    be set true at an earlier time when the upstream bridge saved other parts
    of its state. Then later when attempting to save the L1SS config while
    handling the Upstream Port, parent->state_saved is true in
    pci_save_aspm_l1ss_state() resulting in early return and skipping saving
    bridge's L1SS config because it is assumed to be already saved. Later on
    restore, junk is written into L1SS config which causes issues with some
    devices.

    Remove parent->state_saved check and unconditionally save L1SS config also
    for the upstream bridge from an Upstream Port which ought to be harmless
    from correctness point of view. With the Upstream Port check now present,
    saving the L1SS config more than once for the bridge is no longer a problem
    (unlike when the parent->state_saved check got introduced into the fix
    during its development).

    Link: https://lore.kernel.org/r/20250131152913.2507-1-ilpo.jarvinen@linux.intel.com
    Fixes: 1db806ec06b7 ("PCI/ASPM: Save parent L1SS config in pci_save_aspm_l1ss_state()")
    Closes: https://bugzilla.kernel.org/show_bug.cgi?id=219731
    Reported-by: Niklāvs Koļesņikovs <pinkflames.linux@gmail.com>
    Reported by: Rafael J. Wysocki <rafael@kernel.org>
    Closes: https://lore.kernel.org/r/CAJZ5v0iKmynOQ5vKSQbg1J_FmavwZE-nRONovOZ0mpMVauheWg@mail.gmail.com
    Reported-by: Paul Menzel <pmenzel@molgen.mpg.de>
    Closes: https://lore.kernel.org/r/d7246feb-4f3f-4d0c-bb64-89566b170671@molgen.mpg.de
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Tested-by: Niklāvs Koļesņikovs <pinkflames.linux@gmail.com>
    Tested-by: Paul Menzel <pmenzel@molgen.mpg.de> # Dell XPS 13 9360

Signed-off-by: Myron Stowe <mstowe@redhat.com>
---
 drivers/pci/pcie/aspm.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index e0bc90597dcad..da3e7edcf49d9 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -108,9 +108,6 @@ void pci_save_aspm_l1ss_state(struct pci_dev *pdev)
 	pci_read_config_dword(pdev, pdev->l1ss + PCI_L1SS_CTL2, cap++);
 	pci_read_config_dword(pdev, pdev->l1ss + PCI_L1SS_CTL1, cap++);
 
-	if (parent->state_saved)
-		return;
-
 	/*
 	 * Save parent's L1 substate configuration so we have it for
 	 * pci_restore_aspm_l1ss_state(pdev) to restore.
-- 
GitLab