From patchwork Fri Feb 16 06:24:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jian-Hong Pan X-Patchwork-Id: 201937 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp329563dyb; Thu, 15 Feb 2024 22:26:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV/Fk2wYbBJezJ4CD/hOiF2oarSFOc9v6gZbLISNExXsZnP28Aafxrmbj5YSoU6nVn1scODpGunAjuOGaqG6gTah5FzLg== X-Google-Smtp-Source: AGHT+IHWGoo5rI5RlwmXNJl0OgnwDe4ShGiZwzlJnmL18Oe6A3kqmRNE1lxP/6RSX8KUBi4WWllz X-Received: by 2002:a05:6a00:1892:b0:6db:e366:53a8 with SMTP id x18-20020a056a00189200b006dbe36653a8mr4896868pfh.12.1708064777625; Thu, 15 Feb 2024 22:26:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708064777; cv=pass; d=google.com; s=arc-20160816; b=QUWFzqh1LL16P86FNEP7kyIjwExNzvh8375CdKWiTpAPDqDAORCzetMge4q3e1D87w 7UpSC28lUiV+IYcEXLclAW2WZX4l4a2zKUjadE1Bq+NtCsJxV6cwu2lJssSI7DGMeiHp sIDpu5oIkZd5956GEb/M0uFdTmOb06AnK1ErRap4aicjBCWTvk8Gh6AnYbUBSbEsUX7x GAPL6PcUgKzpuFdXq3uEyCwCWO0x75dDvDmvVNCr33egQTaBl0Fx5PE/SoVKWwPsuqbE evD7FIzF9u1Rj6qsFVZDUawjXs6wINyK1kuj4BIiJgOaSrVlki4lhH4CYH63lwER0i98 0COQ== ARC-Message-Signature: i=2; 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:message-id:date:subject:cc:to :from:dkim-signature; bh=go9pnzcnTe/ILY9pnIwCtci+zv9qwK5zq4OGjkRdcEg=; fh=9fwneiqokegWFzOtF297jflc1IM4cb3zolaI7r8jRys=; b=09JIO9B6BBPg5zvi2wykVgSLlfnyTYz8Mr6lCgP9t7cipwQou1BPb/XzDzVLJgt38G 6EaAXdqF0sGuBu4ozPDq88q3r9XjkM17stE7RkL8ilsPerZ68PiViVPnhQoE6bKHYMSh 2P4t5mvTynzbx7ar6GLdcbHMm25AUrRjMZBF9LcqJufJSOOhbzIqZ+93jc5COIBCL+zi Yg/99oMN5IjWlERZE2CAPClo/x755/6zhiUu9Ed4nl8WsAmPHNV9dLjq9vi0XMWJZSNw MVJiE7N49oyaQ3JNYrNN9gZEqom8l85+Z8A7ZgI4bRIivXQe2TF75/AhM8xYUMFiUBcu xQEQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@endlessos.org header.s=google header.b=KjyM5UKr; arc=pass (i=1 spf=pass spfdomain=endlessos.org dkim=pass dkdomain=endlessos.org dmarc=pass fromdomain=endlessos.org); spf=pass (google.com: domain of linux-kernel+bounces-68101-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68101-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=endlessos.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id cm12-20020a056a020a0c00b005dbcb1780dfsi2581373pgb.813.2024.02.15.22.26.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 22:26:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68101-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@endlessos.org header.s=google header.b=KjyM5UKr; arc=pass (i=1 spf=pass spfdomain=endlessos.org dkim=pass dkdomain=endlessos.org dmarc=pass fromdomain=endlessos.org); spf=pass (google.com: domain of linux-kernel+bounces-68101-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68101-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=endlessos.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 45770B218C5 for ; Fri, 16 Feb 2024 06:26:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E5FF156C2; Fri, 16 Feb 2024 06:25:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=endlessos.org header.i=@endlessos.org header.b="KjyM5UKr" Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7829914285 for ; Fri, 16 Feb 2024 06:25:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708064756; cv=none; b=rUUf9rECn8w96HGkc1p7jvILEjuY9iWVby48f8uKUKMj5k1iaeE5PA62HWveUJAS6nQzRaaq4lsjPoCl8JEKg9kWmdlyguhPIOr41ou/PiIM+0Pg+0d3fIKo4M//TO18I7ptDgQ4ZkWBmciyxGaBd3fegpB9NLFw6HL90cCKsB4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708064756; c=relaxed/simple; bh=KivuariFpPolApka+H/P0dLLds23Rk9TayxJQuSEfUA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=nSrk+YLoIuZjw92J8BfE4AxiQlEzm3a4cISqABUSuoTCdNzqi1NeAFzk0tAueqYPPaCuSHfSRbXCKv4hgvCi/ZqqE7LI3BCjryaIUkexvAXgi7hTtJfnRIPIr+CTEcLoScwgWA7VUQCMa2LhNeLsPCffuV0cwzSPmAPUU7b4/HI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=endlessos.org; spf=pass smtp.mailfrom=endlessos.org; dkim=pass (2048-bit key) header.d=endlessos.org header.i=@endlessos.org header.b=KjyM5UKr; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=endlessos.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=endlessos.org Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1d73066880eso16131485ad.3 for ; Thu, 15 Feb 2024 22:25:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endlessos.org; s=google; t=1708064754; x=1708669554; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=go9pnzcnTe/ILY9pnIwCtci+zv9qwK5zq4OGjkRdcEg=; b=KjyM5UKrCBnBUsAhPJf5Qq1h/eDoGCJdjpJveuH8aW0mNYx0SNyaQHbJoSXLhVNq+0 Yfa9AWpWtC5n0cs2pJhRYeVMwNHq1X3DRbzYLXc2/oVkVGaPgRAEze0oGxaSAEjblFpA 1CimS/2Ldj/K6VIBBvL0ynaNYRSrNTVlNJ43bRYnWT5Pjr3mQ8B4IaJTzB85EsnsXr2e 0aotyhvG/5OZWWmSl3UxpflJpcyuX7G4Ve0CARJsChC188jJRTaIqtXoKeXRUKRRRsxO JBz4OQQ7ZlfdtBGPr46YREVjYeqgCJ2vPocNn/9dJCRglxRTtomqSiUJKG9CQnisFHoP AX+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708064754; x=1708669554; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=go9pnzcnTe/ILY9pnIwCtci+zv9qwK5zq4OGjkRdcEg=; b=Bv/p1iIEN45tVeXmJIufDURWY3JodQE7OFeWZ2V9LtoJLWvXWewlba7JCdLndHPDbL 4Re5WylHq8hUTVrFbE8neozc7+ybzEfj0Rf+Rhtm7syLxdXbCGJ00Mdi4vHDjcyUvYS/ 3DTLPDbLUZ2Nt+6fAfX/lsg2MZntFsAFIrlV3nb/5SNrkWMpHS9QnB82Il1xprJNH9HZ GZz9dK93xib4QIsZ1fTq+92gmjuZtoxRBX+gqtc5xnpMj5sw3vPm6bMQBV3qMTn6eOJC u1XixAxqTj67e0JAFu//fYzBT+MKYR8LPIkkB83shUGjn45zsN/EUXYnvgw5MwYmmLAu NcoQ== X-Forwarded-Encrypted: i=1; AJvYcCUvlcFAe/KtJy4f15fSpqOK/m5Qk6jZUCiaWMtTVUQtHPrsWGPiUuiTD2lCwQ+5gyI29hElhQVMi5flnbpZw3tsaKwZOsnr0a0zWK8C X-Gm-Message-State: AOJu0YzmleIuZ4u04gNYT98/mZ7Mqd78sI/fmsyRv4xaainDb9yR7MP0 UL6M1rhMqmrIp0YwaybhKuBP3yaIiY/Qs2miM1VHHNNbcIMKv9rViqQ84V5D8O4= X-Received: by 2002:a17:90a:fb48:b0:299:3e78:91f6 with SMTP id iq8-20020a17090afb4800b002993e7891f6mr113505pjb.23.1708064753743; Thu, 15 Feb 2024 22:25:53 -0800 (PST) Received: from starnight.endlessm-sf.com ([123.51.167.56]) by smtp.googlemail.com with ESMTPSA id sh18-20020a17090b525200b00298d8804ba8sm4398089pjb.46.2024.02.15.22.25.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 22:25:53 -0800 (PST) From: Jian-Hong Pan To: Bjorn Helgaas , Johan Hovold , David Box , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Kuppuswamy Sathyanarayanan Cc: Mika Westerberg , Damien Le Moal , Nirmal Patel , Jonathan Derrick , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux@endlessos.org, Jian-Hong Pan Subject: [PATCH v4 1/3] PCI: vmd: Enable PCI PM's L1 substates of remapped PCIe Root Port and NVMe Date: Fri, 16 Feb 2024 14:24:14 +0800 Message-ID: <20240216062412.247052-3-jhp@endlessos.org> X-Mailer: git-send-email 2.43.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791035732295500485 X-GMAIL-MSGID: 1791035732295500485 The remapped PCIe Root Port and NVMe have PCI PM L1 substates capability, but they are disabled originally. Here is a failed example on ASUS B1400CEAE: Capabilities: [900 v1] L1 PM Substates L1SubCap: PCI-PM_L1.2+ PCI-PM_L1.1- ASPM_L1.2+ ASPM_L1.1- L1_PM_Substates+ PortCommonModeRestoreTime=32us PortTPowerOnTime=10us L1SubCtl1: PCI-PM_L1.2- PCI-PM_L1.1- ASPM_L1.2+ ASPM_L1.1- T_CommonMode=0us LTR1.2_Threshold=0ns L1SubCtl2: T_PwrOn=10us Power on all of the VMD remapped PCI devices before enable PCI-PM L1 PM Substates by following PCI Express Base Specification Revision 6.0, section 5.5.4. Link: https://bugzilla.kernel.org/show_bug.cgi?id=218394 Signed-off-by: Jian-Hong Pan Reviewed-by: Kuppuswamy Sathyanarayanan --- v2: - Power on the VMD remapped devices with pci_set_power_state_locked() - Prepare the PCIe LTR parameters before enable L1 Substates - Add note into the comments of both pci_enable_link_state() and pci_enable_link_state_locked() for kernel-doc. - The original patch set can be split as individual patches. v3: - Re-send for the missed version information. - Split drivers/pci/pcie/aspm.c modification into following patches. - Fix the comment for enasuring the PCI devices in D0. v4: - The same drivers/pci/controller/vmd.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c index 87b7856f375a..6aca3f77724c 100644 --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -751,11 +751,9 @@ static int vmd_pm_enable_quirk(struct pci_dev *pdev, void *userdata) if (!(features & VMD_FEAT_BIOS_PM_QUIRK)) return 0; - pci_enable_link_state_locked(pdev, PCIE_LINK_STATE_ALL); - pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_LTR); if (!pos) - return 0; + goto out_enable_link_state; /* * Skip if the max snoop LTR is non-zero, indicating BIOS has set it @@ -763,7 +761,7 @@ static int vmd_pm_enable_quirk(struct pci_dev *pdev, void *userdata) */ pci_read_config_dword(pdev, pos + PCI_LTR_MAX_SNOOP_LAT, <r_reg); if (!!(ltr_reg & (PCI_LTR_VALUE_MASK | PCI_LTR_SCALE_MASK))) - return 0; + goto out_enable_link_state; /* * Set the default values to the maximum required by the platform to @@ -775,6 +773,13 @@ static int vmd_pm_enable_quirk(struct pci_dev *pdev, void *userdata) pci_write_config_dword(pdev, pos + PCI_LTR_MAX_SNOOP_LAT, ltr_reg); pci_info(pdev, "VMD: Default LTR value set by driver\n"); +out_enable_link_state: + /* + * Ensure devices are in D0 before enabling PCI-PM L1 PM Substates, per + * PCIe r6.0, sec 5.5.4. + */ + pci_set_power_state_locked(pdev, PCI_D0); + pci_enable_link_state_locked(pdev, PCIE_LINK_STATE_ALL); return 0; } From patchwork Fri Feb 16 06:26:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jian-Hong Pan X-Patchwork-Id: 201938 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp329754dyb; Thu, 15 Feb 2024 22:27:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWFWCeq0ji36kfbquBzMAM1NsA2LGHhZoJx9CykxWL+tck5kaJamdTrWxQVmUrTIz5ultRHU0XgSEgvTRAMLvtNTVA/bA== X-Google-Smtp-Source: AGHT+IG9ANgWhk3v4yy+XcRXMW9JTUWWbfW+ZmtGSP9BwTKgfqwHUfIXFM2wbVFZKXvmBS69Ez5r X-Received: by 2002:ac2:4466:0:b0:511:8691:6537 with SMTP id y6-20020ac24466000000b0051186916537mr2461212lfl.69.1708064821689; Thu, 15 Feb 2024 22:27:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708064821; cv=pass; d=google.com; s=arc-20160816; b=Jqj9pAn5Xkr/kUDzqnmXqcShyQzeHkf3p0uqEuNiqUZ6SjcyMyJnjdXlw2GKm/x6NP UB9g9egDuK4AoYrNI66+Arn5ACSx+zpUCiorhQqNl3ox1MDkWp7YIdPmND0wy9m44gg0 gPH9BoHnIYRboWCrSd9gRZJgQOMXubIOknfElvTJ/vdmRcK6lPRFLDw1BV/2315YpBPt yXk3BvyCxsQV15Uj5NIqUu9nkDfqPEzwZnYbLzAIvSP+Ga4fP3IR4imVmQ45J2IpkTva MdGDX9EXMb9jOmXDri/7bc+wFge0m/UWETPOaNT9vJXDWLto+USPZJ370FAuHkbbpqSs WpyQ== ARC-Message-Signature: i=2; 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:message-id:date:subject:cc:to :from:dkim-signature; bh=nSz0QdC1Wat/mJPngx8k1JqTxF0mKLTeVX1uUrMHgiQ=; fh=muNEoejyFXYdn0lRl/jR9jmGvH89HtP+e7MVHZ1aLSE=; b=W+32PrTIxKtBaQ0zojY6xZFCv/dazIMVxNF5lSjf+YKF4rLovvzGjGn0zJlZ0hIWbD +azARmeDeQZUuc/lVxMyWAYmji/mZI6fgZgIkkvbdlPySl7y4T0gQqG7xHmkPg83D6su HYm4JwnfexzMY5NjhMfWJNNds7TR6OYeyjM3U59xokRWYXA+cnleqbu3h+jPLKSUQ2oB UqPReHTzvcaGtcxwhI1AbKwxxK/cevzSLaxM3yNOs1x9Di0jIoA5EiguRnRkAzhj0dk/ hmH7ahCoqdMbhMW+//xxp/EUpF+WPPO4iX+yR9tWwM4h2tLOVb/P1t68Oiq+jHbyXM6y dZBQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@endlessos.org header.s=google header.b=WkGAnwRt; arc=pass (i=1 spf=pass spfdomain=endlessos.org dkim=pass dkdomain=endlessos.org dmarc=pass fromdomain=endlessos.org); spf=pass (google.com: domain of linux-kernel+bounces-68102-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68102-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=endlessos.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id j26-20020a170906279a00b00a3ced40d3c4si1363170ejc.605.2024.02.15.22.27.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 22:27:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68102-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@endlessos.org header.s=google header.b=WkGAnwRt; arc=pass (i=1 spf=pass spfdomain=endlessos.org dkim=pass dkdomain=endlessos.org dmarc=pass fromdomain=endlessos.org); spf=pass (google.com: domain of linux-kernel+bounces-68102-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68102-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=endlessos.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 00DCF1F25B01 for ; Fri, 16 Feb 2024 06:26:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3285914A8D; Fri, 16 Feb 2024 06:26:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=endlessos.org header.i=@endlessos.org header.b="WkGAnwRt" Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B18413FF5 for ; Fri, 16 Feb 2024 06:26:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708064797; cv=none; b=Cxzl/crdMVW37UrCM2FAQyM8gTvVt2Sl7Fdky7W3KodZ3SDJsLwiZM8ZoRMOV+Tsn1ztwzy2oiE76S6E2lk5HjD4uvfIVMh/ErCjwnY0DsEtaH9Q28KfB2BBXFDaha0POLGho4gCnyVSrFEGENBx/ZHhQq0ridwYCE3raaoVYng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708064797; c=relaxed/simple; bh=jklpYMPLXKpsCG7Ee0MeNNjpe+TTYfkDLz/jt2LOqb4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PCKJBcyOQ2x6K/kiWZc2yIZxc9MsrpPTBpvionuOGR9d33yMdZvFl+jFhorLX5XW6+bVqGYGV+bcaJ0trZHk71VjmMKWxPuzVWO9/VyJRnxO8OxPot/UogTKSVGRkKM1Ynv4sjvd/hcAyqj5bobob9IN40Zez2ByKivcIbgR6vY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=endlessos.org; spf=pass smtp.mailfrom=endlessos.org; dkim=pass (2048-bit key) header.d=endlessos.org header.i=@endlessos.org header.b=WkGAnwRt; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=endlessos.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=endlessos.org Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-6e09493eb8eso2210838b3a.1 for ; Thu, 15 Feb 2024 22:26:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endlessos.org; s=google; t=1708064795; x=1708669595; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nSz0QdC1Wat/mJPngx8k1JqTxF0mKLTeVX1uUrMHgiQ=; b=WkGAnwRtaoaZD3T8E970pyEm36Rz0wyBbkY88sNNvmEU0ZTeyyvHmuZoU/N+ofVgNl BMbR1BZ2GgYiwk4+xYHAWTU6Oydcfmzsld+A8VSeq/HBzyaZ6Zln996J/HOv7w/j9Sy+ 5gDnNfjKuHlIFtHUhMy7JKsjM8keVxlElqcfbh6mmNzY8ZeevGuZKtQtd3w2u8JActVg p+YLVsnl6uTTDoYfgy8f8E7DiWkYQLulDbjBf6Xev82rwabJxJj7ZJsC4u9yFapeJRpl pV4tlY/FeqZHTdj4qGtLPrwBjXBsVxrmCGxT5Rkr4QHzb4i4niLNX4OLUxngQAI6tFEI YepQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708064795; x=1708669595; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nSz0QdC1Wat/mJPngx8k1JqTxF0mKLTeVX1uUrMHgiQ=; b=kliVVSundXZJ1poyakxC6So8ZTCAGVzMwkAUaM+0JJbLekJ1XOOn6aDwlBY6Qh2tQe EUQy2+Ko0efcV2mqPjr7rAzWksZiiNcHCkol21hfrNvzjoaOuxXOrDlMGsHVXq1kNCNw 0wQZl2gtJA+rtzJGm5JK/D7xFTVotpt/isbFJ5SDl/sx/xst7hb/0bLK2i/buO15s2Vt jdNq32L6hCIXl4tSKZn5u7J4ly36hEm7eSS6zzUp2kj7lHMrrEFPndXn50s0IjLL8clq hchkTqGUv67vO583u30LThXKQxBgPNTJrxtbe4WV9ErGqLGuBpnn/HwIhcrBZNx1+DAn xO2Q== X-Forwarded-Encrypted: i=1; AJvYcCWTUQbvNFPa6gd9DUSlrkbpSjF/6pqWz/0gsIv0QWBh1Ctxlzb8nZNf5drS6CXkshGrnxFg3C1c2+MS3cOegsdkRdgBTgRZ0T8YP5nV X-Gm-Message-State: AOJu0YxmeOB3f6RACr9U94pNCDuCvfHaIAGBtiZrSjFGgS3el2VzlnOb KIkI/LWAubULZnOtPtOZtSUlPbhtkSnUiNMSRegrO40z+dAv181ALIhJIVG+dNc= X-Received: by 2002:a05:6a20:94c6:b0:19e:8866:9e56 with SMTP id ht6-20020a056a2094c600b0019e88669e56mr10979990pzb.11.1708064795526; Thu, 15 Feb 2024 22:26:35 -0800 (PST) Received: from starnight.endlessm-sf.com ([123.51.167.56]) by smtp.googlemail.com with ESMTPSA id h63-20020a638342000000b005d8b2f04eb7sm2387041pge.62.2024.02.15.22.26.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 22:26:35 -0800 (PST) From: Jian-Hong Pan To: Bjorn Helgaas , Johan Hovold , David Box , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Kuppuswamy Sathyanarayanan Cc: Mika Westerberg , Damien Le Moal , Nirmal Patel , Jonathan Derrick , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux@endlessos.org, Jian-Hong Pan Subject: [PATCH v4 2/3] PCI/ASPM: Add notes about enabling PCI-PM L1SS to pci_enable_link_state(_locked) Date: Fri, 16 Feb 2024 14:26:01 +0800 Message-ID: <20240216062559.247479-3-jhp@endlessos.org> X-Mailer: git-send-email 2.43.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791035778338141453 X-GMAIL-MSGID: 1791035778338141453 According to PCI Express Base Specification Revision 6.0, Section 5.5.4: "If setting either or both of the enable bits for PCI-PM L1 PM Substates, both ports must be configured as described in this section while in D0." Add notes into pci_enable_link_state(_locked) for kernel-doc. Hope these notify callers ensuring the devices in D0, if PCI-PM L1 PM Substates are going to be enabled. Signed-off-by: Jian-Hong Pan Acked-by: Bjorn Helgaas Reviewed-by: Kuppuswamy Sathyanarayanan --- v3: - Fix as readable comments v4: - The same drivers/pci/pcie/aspm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 7f1d674ff171..a39d2ee744cb 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1416,6 +1416,9 @@ static int __pci_enable_link_state(struct pci_dev *pdev, int state, bool locked) * touch the LNKCTL register. Also note that this does not enable states * disabled by pci_disable_link_state(). Return 0 or a negative errno. * + * Note: Ensure devices are in D0 before enabling PCI-PM L1 PM Substates, per + * PCIe r6.0, sec 5.5.4. + * * @pdev: PCI device * @state: Mask of ASPM link states to enable */ @@ -1432,6 +1435,9 @@ EXPORT_SYMBOL(pci_enable_link_state); * can't touch the LNKCTL register. Also note that this does not enable states * disabled by pci_disable_link_state(). Return 0 or a negative errno. * + * Note: Ensure devices are in D0 before enabling PCI-PM L1 PM Substates, per + * PCIe r6.0, sec 5.5.4. + * * @pdev: PCI device * @state: Mask of ASPM link states to enable * From patchwork Fri Feb 16 06:26:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jian-Hong Pan X-Patchwork-Id: 201939 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp330110dyb; Thu, 15 Feb 2024 22:28:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW8vmRNlxjP3+JJ0B0DrOsuC+9zYnIUA0+ysAHRijOpLUd9jbDTAGwtfTaWZvkJrtl0CbBpR6Sqk+IM+zQ253GjA5FusQ== X-Google-Smtp-Source: AGHT+IEqb634zlQue4HSmcxGUmULOTkVUgR8QVW62SgfxC0nqbgggWPqgY0SydB3dja0ztBpVWmG X-Received: by 2002:a50:fc12:0:b0:55d:30b2:983e with SMTP id i18-20020a50fc12000000b0055d30b2983emr2974592edr.4.1708064894773; Thu, 15 Feb 2024 22:28:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708064894; cv=pass; d=google.com; s=arc-20160816; b=YS+Eskhwfa8uNyxyw69r0IAK2dYsTuschUN95l6dMgQdSExbyCWnLmMvKAH88MRs0W LEzCtU6wFPymTCv9JW7ThaJjEbiVNjMHc6o0tdHyvBa4EUVc+p4cEc2AAObrdUivSWDJ ZWD7TgLl5ty2RSN/jGh+7tr65oAxkakrMs7AfOosSqb9hrhw69zWkr22m220A57V0wFZ tFnwxaNL91d7uSlPM+jEWpPOUB8/iiJaNoNci+t+1Hqe9otJLQsV/k3AVV1ibhdwC8c6 0c5cOAPMKatt+sHBdmUEZM4zkMRcGd3tUWT4WWeIiUQ9A6HghNvVqdufqWnpOU8TNP7S VYdQ== ARC-Message-Signature: i=2; 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:message-id:date:subject:cc:to :from:dkim-signature; bh=ygsa5jjvYZCtN9/8lPWOoYcNc8mXbDA6UyU77zh7EZg=; fh=+JXSMgMqrEfxgL/KCLducIzRPIqQ8zT4ZNiVAhxYlMI=; b=aGpvSR9MVeHjYvP5tgTEc5H8klQIdTA0JOCV5VUFww5AJMRDHmKko/t2Q9R4oDq4dI sxLK1v9XL+F3F68Fw+mEVl2tVkHky75yiQ+496zlOKYkXiuGkly9bP/4xcqV1LHvFcWo Q6KQOotKj+qdVAyS8izRScw6r6qenPOhtH56OO8MnGfptaIxBNOg9hS1gEYJ8ARp6fN7 AkZsPIRKssdXafi+JOO45UIC/8RQabw4cptWPffvzZe8U7oYaDhRqXodwxc/awLs3D2T AUwNPU0EYpgqgxBYkRt4CxNc6g3IbnEi1nEJ9kYFH+jSDOydkqNfvYAb8iWIvjWHfFUA 1GHw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@endlessos.org header.s=google header.b=C89MbVuj; arc=pass (i=1 spf=pass spfdomain=endlessos.org dkim=pass dkdomain=endlessos.org dmarc=pass fromdomain=endlessos.org); spf=pass (google.com: domain of linux-kernel+bounces-68103-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68103-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=endlessos.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h5-20020aa7de05000000b00563ef097b77si268833edv.379.2024.02.15.22.28.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 22:28:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68103-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@endlessos.org header.s=google header.b=C89MbVuj; arc=pass (i=1 spf=pass spfdomain=endlessos.org dkim=pass dkdomain=endlessos.org dmarc=pass fromdomain=endlessos.org); spf=pass (google.com: domain of linux-kernel+bounces-68103-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68103-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=endlessos.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 165541F23F82 for ; Fri, 16 Feb 2024 06:28:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD49114A89; Fri, 16 Feb 2024 06:28:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=endlessos.org header.i=@endlessos.org header.b="C89MbVuj" Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D7B210979 for ; Fri, 16 Feb 2024 06:27:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708064878; cv=none; b=OqurB02LmUHGIzQC9yJTPAxbxgOLMfICbEV9ErYOq3xsjiKmC/kXkDbqSklyXyrPioKLXUhNI+pZzL/ed7JKBX2WZ8eBb2n3hlKv8TfCdwZAjY6GjMzNL0+AqHmAJj9mHrgoi0Cyyuv9FZdvDV9UnG8YPigLsBe8TYOQpwbBs/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708064878; c=relaxed/simple; bh=V4uNwt9Wc1n7D0gczdUV5IjXzUJ6aFgDu2+Y0zcFv/s=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=rpG53ZPGcDQXiMY+MxaX0+SeaYSoVk3mujCsPgMc9vJ2mmgiZeqUBW68R8906xptxt2rZ+tXMRlLzL+/LiqKTKTAv0faHZEHqH3JJbqqR4/S5bOax26rX9NvwdzNBhunP1MkN0Xx5D27t+Hxoi+cgVVjwfv9mbu6xG2FXu2xZSM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=endlessos.org; spf=pass smtp.mailfrom=endlessos.org; dkim=pass (2048-bit key) header.d=endlessos.org header.i=@endlessos.org header.b=C89MbVuj; arc=none smtp.client-ip=209.85.216.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=endlessos.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=endlessos.org Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-290d59df3f0so1351371a91.2 for ; Thu, 15 Feb 2024 22:27:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endlessos.org; s=google; t=1708064876; x=1708669676; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ygsa5jjvYZCtN9/8lPWOoYcNc8mXbDA6UyU77zh7EZg=; b=C89MbVujuQy1A2tc96ZJ8Htq+MnRxUkQZEwF7VWotHImUlGAas64QT/9Gr/vEtXSnG 7OTyJZjiDuUpWUnJ4ugwgVzt4Ix8F6wGBtXi6K0zdMB+bGRNffWPuGyoD+tcCibbT1Y9 XdDr+rzzFCXmhX352j6LceW67ZDqH531rSP1Ex/549u6KHeaC0WDBXmWpgccsWtL+l+b 7l0KbhEeo2x2wvnwM8JXMkTbfT6xtzKhcuTf/K1YbaLO8zZ4mU4/T83dqJhBIwi7tlwk YG7iPXsvZ5lwWidS1T0xh4EFg1tcq+f608fBrauApyeKxXQvXdtQCA7Upv+D+O3PbxSv wsKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708064876; x=1708669676; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ygsa5jjvYZCtN9/8lPWOoYcNc8mXbDA6UyU77zh7EZg=; b=tJsOQfzY9HEsRwFU83pSPBOhiO9Xsz3FcXN2o5CKOD6sOjdzxJA5iCQ9BGvllFqHAm 8sEuItQdyYtMDfFBrdSwNy+NHiBGlAX+N2jRtnsvbATXy3vwhQMDCJpB0C4OiZWtcTN2 7cSzuNBbXF+xUsj/6YOkGhwnPuWZ8kUiK3181YI1u5vZNspx71eUgrzFr10OasYr1G8m /+7KrjGRHPweE63vYV4jfQqrFjTbmNy2WmTaa80z+LkFDN+Tg1RM54HDTueViNKh6fVj c9ZaQ5zw7NOvvVvYW/ZKUUwv0upkwyeEKAj0GiETaKBevgTBuTQzarIHVqm2cSmsoBq0 lgwQ== X-Forwarded-Encrypted: i=1; AJvYcCX5sIQekLPUxGERoD1JwErKplGNqv0Qj9qevHyJO1yEDcIhyeNoq3yBqRfpqEBhtTdxmFXEvbcsKhhTdY4bhwTQnOej/7Tz5xGCu1A6 X-Gm-Message-State: AOJu0Yyf/t9yJhmheQNTbH+OU/vFX1VeVkUvgq2Um5b7+hE4zCsmCHx/ bToUOwMebS0wcoM30IxzhE20awr161H1aj/xiIue02NeHsuExcOB76g3D9qmVTM= X-Received: by 2002:a17:90b:23ce:b0:299:262b:554b with SMTP id md14-20020a17090b23ce00b00299262b554bmr2445542pjb.44.1708064876555; Thu, 15 Feb 2024 22:27:56 -0800 (PST) Received: from starnight.endlessm-sf.com ([123.51.167.56]) by smtp.googlemail.com with ESMTPSA id sw16-20020a17090b2c9000b00296a23e407csm4572827pjb.7.2024.02.15.22.27.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 22:27:56 -0800 (PST) From: Jian-Hong Pan To: Bjorn Helgaas , Johan Hovold , David Box , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Kuppuswamy Sathyanarayanan Cc: Mika Westerberg , Damien Le Moal , Nirmal Patel , Jonathan Derrick , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux@endlessos.org, Jian-Hong Pan Subject: [PATCH v4 3/3] PCI/ASPM: Fix L1.2 parameters when enable link state Date: Fri, 16 Feb 2024 14:26:44 +0800 Message-ID: <20240216062642.247504-3-jhp@endlessos.org> X-Mailer: git-send-email 2.43.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791035854898271887 X-GMAIL-MSGID: 1791035854898271887 Currently, when enable link's L1.2 features with __pci_enable_link_state(), it configs the link directly without ensuring related L1.2 parameters, such as T_POWER_ON, Common_Mode_Restore_Time, and LTR_L1.2_THRESHOLD have been programmed. This leads VMD enabled systems' L1.2 of the link between VMD remapped PCIe Root Port and NVMe gets wrong configs when a caller tries to enabled it. Here is a failed example on ASUS B1400CEAE with enabled VMD: 10000:e0:06.0 PCI bridge: Intel Corporation 11th Gen Core Processor PCIe Controller (rev 01) (prog-if 00 [Normal decode]) ... Capabilities: [200 v1] L1 PM Substates L1SubCap: PCI-PM_L1.2+ PCI-PM_L1.1+ ASPM_L1.2+ ASPM_L1.1+ L1_PM_Substates+ PortCommonModeRestoreTime=45us PortTPowerOnTime=50us L1SubCtl1: PCI-PM_L1.2- PCI-PM_L1.1- ASPM_L1.2+ ASPM_L1.1- T_CommonMode=45us LTR1.2_Threshold=101376ns L1SubCtl2: T_PwrOn=50us 10000:e1:00.0 Non-Volatile memory controller: Sandisk Corp WD Blue SN550 NVMe SSD (rev 01) (prog-if 02 [NVM Express]) ... Capabilities: [900 v1] L1 PM Substates L1SubCap: PCI-PM_L1.2+ PCI-PM_L1.1- ASPM_L1.2+ ASPM_L1.1- L1_PM_Substates+ PortCommonModeRestoreTime=32us PortTPowerOnTime=10us L1SubCtl1: PCI-PM_L1.2- PCI-PM_L1.1- ASPM_L1.2+ ASPM_L1.1- T_CommonMode=0us LTR1.2_Threshold=0ns L1SubCtl2: T_PwrOn=10us According to PCI Express Base Specification Revision 6.0, Section 5.5.4, before enable ASPM L1.2 on the PCIe Root Port and the NVMe, they should be programmed with the same LTR1.2_Threshold value. However, they have different values in this case. This patch invokes aspm_calc_l12_info() to program the L1.2 parameters properly before enable L1.2 bits of L1 PM Substates Control Register in __pci_enable_link_state(). Also, introduces aspm_get_l1ss_cap() shared into aspm_l1ss_init() and __pci_enable_link_state() to get the PCIe devices' L1SS capability for aspm_calc_l12_info(). Link: https://bugzilla.kernel.org/show_bug.cgi?id=218394 Signed-off-by: Jian-Hong Pan --- v2: - Prepare the PCIe LTR parameters before enable L1 Substates v3: - Only enable supported features for the L1 Substates part v4: - Focus on fixing L1.2 parameters, instead of re-initializing whole L1SS drivers/pci/pcie/aspm.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index a39d2ee744cb..42a8c4c194c1 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -588,6 +588,18 @@ static void pcie_aspm_check_latency(struct pci_dev *endpoint) } } +static u32 aspm_get_l1ss_cap(struct pci_dev *pdev) +{ + u32 l1ss_cap; + + pci_read_config_dword(pdev, pdev->l1ss + PCI_L1SS_CAP, &l1ss_cap); + + if (!(l1ss_cap & PCI_L1SS_CAP_L1_PM_SS)) + l1ss_cap = 0; + + return l1ss_cap; +} + /* Calculate L1.2 PM substate timing parameters */ static void aspm_calc_l12_info(struct pcie_link_state *link, u32 parent_l1ss_cap, u32 child_l1ss_cap) @@ -698,15 +710,8 @@ static void aspm_l1ss_init(struct pcie_link_state *link) return; /* Setup L1 substate */ - pci_read_config_dword(parent, parent->l1ss + PCI_L1SS_CAP, - &parent_l1ss_cap); - pci_read_config_dword(child, child->l1ss + PCI_L1SS_CAP, - &child_l1ss_cap); - - if (!(parent_l1ss_cap & PCI_L1SS_CAP_L1_PM_SS)) - parent_l1ss_cap = 0; - if (!(child_l1ss_cap & PCI_L1SS_CAP_L1_PM_SS)) - child_l1ss_cap = 0; + parent_l1ss_cap = aspm_get_l1ss_cap(parent); + child_l1ss_cap = aspm_get_l1ss_cap(child); /* * If we don't have LTR for the entire path from the Root Complex @@ -1367,6 +1372,8 @@ EXPORT_SYMBOL(pci_disable_link_state); static int __pci_enable_link_state(struct pci_dev *pdev, int state, bool locked) { struct pcie_link_state *link = pcie_aspm_get_link(pdev); + struct pci_dev *child = link->downstream, *parent = link->pdev; + u32 parent_l1ss_cap, child_l1ss_cap; if (!link) return -EINVAL; @@ -1398,6 +1405,16 @@ static int __pci_enable_link_state(struct pci_dev *pdev, int state, bool locked) link->aspm_default |= ASPM_STATE_L1_1_PCIPM | ASPM_STATE_L1; if (state & PCIE_LINK_STATE_L1_2_PCIPM) link->aspm_default |= ASPM_STATE_L1_2_PCIPM | ASPM_STATE_L1; + /* + * Ensure L1.2 paramters: Common_Mode_Restore_Times, T_POWER_ON and + * LTR_L1.2_THRESHOLD are programmed properly before enable bits for + * L1.2, per PCIe r6.0, sec 5.5.4. + */ + if (state & link->aspm_capable & ASPM_STATE_L1_2_MASK) { + parent_l1ss_cap = aspm_get_l1ss_cap(parent); + child_l1ss_cap = aspm_get_l1ss_cap(child); + aspm_calc_l12_info(link, parent_l1ss_cap, child_l1ss_cap); + } pcie_config_aspm_link(link, policy_to_aspm_state(link)); link->clkpm_default = (state & PCIE_LINK_STATE_CLKPM) ? 1 : 0;