Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6829489rdb; Tue, 2 Jan 2024 15:26:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IE8PS9VO3tWyjWjIfrWq7awQhXrQ6x43csKlZVyVAXO/HyXsIbtqfhUMTAuzyAb7WkMymV7 X-Received: by 2002:aa7:9e8e:0:b0:6d9:ac65:3d9f with SMTP id p14-20020aa79e8e000000b006d9ac653d9fmr15282157pfq.68.1704237974925; Tue, 02 Jan 2024 15:26:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704237974; cv=none; d=google.com; s=arc-20160816; b=o8LRTVhut0QoBYE/0jkJTSNMlYRh0Zv5e4DJrg8uzMFhGNaDK2hA7fSRmqXLPGiQQX aCxmiPJhOmiE2aB94qaxj7VtVG8Vru7aI4k9oWBc0fccJNP47lRfKgvFEBHLtDWY0d2m J7a4Z0Uyk8WrxGlOnk4MkT3xRO1JZRf4z1fcOS3llGOPBfeIOMjQBXRkQm5kJ8aaefZ7 +/K4JJnhZZuvmg46J18O335LEppXoVrX/4QAdzI6JfcYwfkzXRSAI+516GCChHI+Q++0 2zvAGM8vdhiFQTZAeGe6m705rJ3LWmTnJiFD+iPw1lV1Ru9xTzbbXyEZ5j2Xo3UZfd7A ZQ8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=EuAWQuAppjI6uOb5aF4kIw2dzwHbycNbelF0KTOnqB8=; fh=HOPy/uIijwEwp05jXKXlSR63+6zhic1WdSw4HVgRMyY=; b=o1BCTV1IYwh0U6PisGvpM0h6z6EDkhhy/JSpB/dljnzmFV/n+aK11qxnjh4L19Nt5n H7tAp74cUu+rfPGFVGYmCMfJPQnCAvDWfTUKlZHphqbGHMlbwCmXgeAxMcedQm7EfsPA JG8hlY8gpirWzlxbNzIpJmibOfLuVXcSk5tR7t8svPztekLxi434X5XpZuROFj0AuAwR 7hbCBr8X/du/NACp3mjeuUD4TtQ3VRS/47dV0MPUOUFnmGMWqfvJKfreZI0UiHVbCzYp 1PLrgTgURnB2EBfvLs9eUzaJc0asqcOGDE26NDBa+ljZk0xky2dTpykwHiVLMaKrsema QmsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jfpOimGx; spf=pass (google.com: domain of linux-kernel+bounces-14969-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14969-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p20-20020a056a000b5400b006d9c8c29904si13806361pfo.184.2024.01.02.15.26.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 15:26:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14969-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jfpOimGx; spf=pass (google.com: domain of linux-kernel+bounces-14969-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14969-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3E00A28498D for ; Tue, 2 Jan 2024 23:26:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2ECE917757; Tue, 2 Jan 2024 23:26:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jfpOimGx" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57C6B1773F; Tue, 2 Jan 2024 23:26:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6451C433C8; Tue, 2 Jan 2024 23:26:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704237964; bh=WuAwk7zWQxqNeWy+iKLUu2zXubSzzN/H4OfczTv4nxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jfpOimGxKcd/lNdyF4JmHXBCA1H8M/3p9i1QnRTrwe0kkmqKuIwpjYOTp1+4UmaWd ZVhSaYSVnLrRLosMrPA1y9wgPKDppB/zXajSlvvyn2xz/hVrEJG5oum60EeDXiOsTv eh64lEOr8RehlCK97W7ZeIdrfAMQLGZBD2afvie6VcsMdnyrcKuu7TwW19Oj7tTYnD X4s2UPmmqHEr5ZoclapmYC8KO3ZXVQLBu1h+Y6ULCI+9K+DVKMidEfVzMRW2LMgs0N MpME5ecw+0mNBUBaFmW6nUWy5uYiSsyIl3dJHbLW7aSomdhWK+EyabwyOZWejRIkFY 8pod8hJoC5aZQ== From: Bjorn Helgaas To: Michael Schaller , Kai-Heng Feng Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, regressions@lists.linux.dev, "Maciej W . Rozycki" , Ajay Agarwal , Kuppuswamy Sathyanarayanan , Greg Kroah-Hartman , Heiner Kallweit , Johan Hovold , Bjorn Helgaas , stable@vger.kernel.org Subject: [PATCH] Revert "PCI/ASPM: Remove pcie_aspm_pm_state_change()" Date: Tue, 2 Jan 2024 17:25:50 -0600 Message-Id: <20240102232550.1751655-1-helgaas@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <76c61361-b8b4-435f-a9f1-32b716763d62@5challer.de> References: <76c61361-b8b4-435f-a9f1-32b716763d62@5challer.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Bjorn Helgaas This reverts commit 08d0cc5f34265d1a1e3031f319f594bd1970976c. Michael reported that when attempting to resume from suspend to RAM on ASUS mini PC PN51-BB757MDE1 (DMI model: MINIPC PN51-E1), 08d0cc5f3426 ("PCI/ASPM: Remove pcie_aspm_pm_state_change()") caused a 12-second delay with no output, followed by a reboot. Workarounds include: - Reverting 08d0cc5f3426 ("PCI/ASPM: Remove pcie_aspm_pm_state_change()") - Booting with "pcie_aspm=off" - Booting with "pcie_aspm.policy=performance" - "echo 0 | sudo tee /sys/bus/pci/devices/0000:03:00.0/link/l1_aspm" before suspending - Connecting a USB flash drive Fixes: 08d0cc5f3426 ("PCI/ASPM: Remove pcie_aspm_pm_state_change()") Reported-by: Michael Schaller Link: https://lore.kernel.org/r/76c61361-b8b4-435f-a9f1-32b716763d62@5challer.de Signed-off-by: Bjorn Helgaas Cc: --- drivers/pci/pci.c | 6 ++++++ drivers/pci/pci.h | 2 ++ drivers/pci/pcie/aspm.c | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 55bc3576a985..bdbf8a94b4d0 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1335,6 +1335,9 @@ static int pci_set_full_power_state(struct pci_dev *dev) pci_restore_bars(dev); } + if (dev->bus->self) + pcie_aspm_pm_state_change(dev->bus->self); + return 0; } @@ -1429,6 +1432,9 @@ static int pci_set_low_power_state(struct pci_dev *dev, pci_power_t state) pci_power_name(dev->current_state), pci_power_name(state)); + if (dev->bus->self) + pcie_aspm_pm_state_change(dev->bus->self); + return 0; } diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 5ecbcf041179..f43873049d52 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -569,10 +569,12 @@ int pcie_retrain_link(struct pci_dev *pdev, bool use_lt); #ifdef CONFIG_PCIEASPM void pcie_aspm_init_link_state(struct pci_dev *pdev); void pcie_aspm_exit_link_state(struct pci_dev *pdev); +void pcie_aspm_pm_state_change(struct pci_dev *pdev); void pcie_aspm_powersave_config_link(struct pci_dev *pdev); #else static inline void pcie_aspm_init_link_state(struct pci_dev *pdev) { } static inline void pcie_aspm_exit_link_state(struct pci_dev *pdev) { } +static inline void pcie_aspm_pm_state_change(struct pci_dev *pdev) { } static inline void pcie_aspm_powersave_config_link(struct pci_dev *pdev) { } #endif diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 50b04ae5c394..8715e951c491 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1008,6 +1008,25 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev) up_read(&pci_bus_sem); } +/* @pdev: the root port or switch downstream port */ +void pcie_aspm_pm_state_change(struct pci_dev *pdev) +{ + struct pcie_link_state *link = pdev->link_state; + + if (aspm_disabled || !link) + return; + /* + * Devices changed PM state, we should recheck if latency + * meets all functions' requirement + */ + down_read(&pci_bus_sem); + mutex_lock(&aspm_lock); + pcie_update_aspm_capable(link->root); + pcie_config_aspm_path(link); + mutex_unlock(&aspm_lock); + up_read(&pci_bus_sem); +} + void pcie_aspm_powersave_config_link(struct pci_dev *pdev) { struct pcie_link_state *link = pdev->link_state; -- 2.34.1