From patchwork Wed Feb 7 11:02:29 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: 197853 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2148696dyb; Wed, 7 Feb 2024 03:06:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNZ4BzpJLnQ1rzYlrZ/uKN0iNKORChM9LeNy4MGdY7U+tMfJ+Cjbsei9+idWVw79YhMTJF X-Received: by 2002:a17:90b:354c:b0:28d:b5de:91e with SMTP id lt12-20020a17090b354c00b0028db5de091emr2784752pjb.32.1707303982284; Wed, 07 Feb 2024 03:06:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707303982; cv=pass; d=google.com; s=arc-20160816; b=FF45pSXwUf3l7u7e79s8/cIo/glHMZpQp3bKEHQALs2ruLbEffg/n9BT6v/R7lEVAD lXhpOUCQZEhoKAELsGZ6mkSbkm1hodRNpS7KEW/qMitLWxowxm29mH3LXIQOmqs7Yavi gmmd0+NSvP417bjWm9u2iZjEaBI55vpq4wy6DabXKF99E2yd3nG3qYjVYbuBt2Zl8cIR A0ckDvYQLLNevuJhFUpnLSSF1tdvRUIHfxIb5R4SdQDtm0pUM16kJQvJp4sUl0OrCNB8 23gBM/L5ZroLsf7f319PZ6KZ+qHlDDPiWrfM0Mn7eCZNKTH4JIo79wtg9CZFlZBaXjOW gFuQ== 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=H+91b1XqNAFALlb1Najn1v2c7o/wK9zms0vvE0c08CY=; fh=JhYFv/8cQaU6R0NUW6ijt9rcXXSs1ZE3rjsWvmdpxj8=; b=SII5GMqTlR+P7tikHibTKbBy+ThZSyhw5BRhLan80wm7U0E2tJiUnY1zkZQYyD39k9 xc5kca/iquwVozwL+S0KNH9SlJ+0oGUxjWnP38reDUvIezmlbf6+G+3632e1rZpFGxVM r17LpzibzDiryw1KTVT+85/qCGfeBJCvhj+KrN16cd5NkWxZW/pAE2NO/26R/ivxluNW 0cdK/5U2jKYl6Wv19Ge/RKfWzBHBWZuFhE7a+6E4Bjpffftrl19OM5M14eBE+P3wub06 /n2mRTzcjWJQnNXTCpOZ1lhH3dxDhXw1L2J+OLWHkySAlVINB1pbIv0DYCTRR5kX3iNr mbXQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@endlessos.org header.s=google header.b=alpugtYz; 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-56357-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56357-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=endlessos.org X-Forwarded-Encrypted: i=2; AJvYcCVa7X91mFvqQsJqOJfgHCwRyZ8MkWDVdsQmHayAQ0oNaE/YX89kuH2f5oiE+OqcF/aS7nPv9qahbGAmXpLmVvwekxVZjw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id mt4-20020a17090b230400b002966de3616csi1327527pjb.26.2024.02.07.03.06.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 03:06:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56357-ouuuleilei=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=@endlessos.org header.s=google header.b=alpugtYz; 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-56357-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56357-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6B848289834 for ; Wed, 7 Feb 2024 11:06:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E58619470; Wed, 7 Feb 2024 11:06:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=endlessos.org header.i=@endlessos.org header.b="alpugtYz" Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (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 234A517BB4 for ; Wed, 7 Feb 2024 11:06:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707303967; cv=none; b=AP5Z5zIWBQR2JSlFy6ns4YjPbG2Fw3CQqdvMWO3FdmgjmzJq1YxLigrhyUUX2OVl+g6wP8abkiC8uKdG7ygpNCe1bSlBEmUnD2XnB7AqxbunpWWlTf938IWrZ9g6sndh0joVosLvyDYekyyLA8PQkqCXcuDSyqxmLRuneiIvcAM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707303967; c=relaxed/simple; bh=SjX79JlzoG9HgwRP50O7RXEJOgSTsPbHECRNLSXhvhI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=fJb2byWfB2R9sOQQFqrsQjHm7YnfjqgyVDhRbabSy+eankaOX5s61ZvUuVHWwsUzXDObMW5rb7QCPLYdBvEsqq7s9PiQJea4xH9kQx2XZ4Olkibfmv4/nbhtkIt+0hChwKjfh/uEF7kVSQ94FnwFdu3gUfSNZi7Ik3js2WoMdbg= 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=alpugtYz; arc=none smtp.client-ip=209.85.210.50 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-ot1-f50.google.com with SMTP id 46e09a7af769-6dc36e501e1so312897a34.1 for ; Wed, 07 Feb 2024 03:06:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endlessos.org; s=google; t=1707303963; x=1707908763; 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=H+91b1XqNAFALlb1Najn1v2c7o/wK9zms0vvE0c08CY=; b=alpugtYzYj+GtL0xFb4gEXIXCMg4r5jhWqsm70CewTrq3Fqiq0vPKEUJLxmitz6OOh CjptrzFz6EpRDKC7xE0yYqXlpsWbT9Pp10ukkaBfZeRkcMLpC//5Sdnt4bClKfLqzymJ 5N8kxDtTfZdYQRB9kJm6fhjjA2IGdeJa8PevxflXQOcjtRcK5PM+DKgkbbyznj+zlcqL FmrkiHASYyeO0gNOq3aGD34rliLBMujO1IIVCRJQF3+IG6DwkKYXby7MS1O6f+K4P8h4 WAiLs3qmGhkkWkzX4v9/5EbYwgsBv9YyWaevEph04jwaXFlvVY21GADpD5D4PJE6eAaN yQsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707303963; x=1707908763; 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=H+91b1XqNAFALlb1Najn1v2c7o/wK9zms0vvE0c08CY=; b=GUAk3ydPzlASVLMaD7ZF9mw09DkWHA3NxJwLHfutUeG3PpVrzozaQtkNKwaxuKBU8S juSop6TiMcUs4LKKEkPnRqvMFkHgqZnR0ygxP/qaKiCeXaXWXxOzF7lOq3pirijfKnUx G+ZOE9R6vF1IQdX5pq6bC+nGSh/XqZ85uEOAEPFkGmy9vESslYSfz8RSUgKghjZsDVxt ubXufrP2CxUZRl3/7BSKCqT/lQH0CMwMuSCajU49QfK+k3M4EaYNqqYxrynwzqWD9Su/ t499ds2MDoORbSdCUeyJQ5n3NpoFaYeMe77PicB1wfybuKZngnDZDmY285tRDIRKdmoc uoLw== X-Gm-Message-State: AOJu0Ywe7WUVeiUojW+vGCWTb+ufuc3w8MVEUTPU6ylBuLJZCfi5rnkD tg5WyXPrG5KJbN74+Uu04/NYEIg8vPnGSzLnxknYzW7Z7AJusRa5QyGp8UcuDNw= X-Received: by 2002:a05:6358:d390:b0:176:cf18:d0bb with SMTP id mp16-20020a056358d39000b00176cf18d0bbmr3130789rwb.13.1707303963130; Wed, 07 Feb 2024 03:06:03 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWE1jg5D4Q08mRtPkrwIAlKIor83cVkpbALTMa43LCtTq3h09wgMmlQppTtehC5mVHdTfoRjajSqUDFO3l7VysvMOAb8TDy8tnDkgAyUYLl9IQ4+Z2p+ZUykNiBPvN+VXDkR20+BLcfc8S9yno8XmxfH/irG5gL2UpjRGIYkezNbquPLz6I/9AbJWzwlz1GKOoFkKkf2exEBXet2N5+gzaKfYAvlYqF0suoH/R0sQuC65HypSYRp/f+dNvfQD53qsatkmd+XSJ1xOtWFzrIF3WxnW0tZxm98zerq1QnH0lMlstslyZ4FlLEBsqeSybwzlvuZO7yBdBcdl216aSuEwLJMkr0JcTbPYdpNHbyoJQlb2EFa8/7UEc= Received: from starnight.endlessm-sf.com ([123.51.167.56]) by smtp.googlemail.com with ESMTPSA id ff15-20020a056a002f4f00b006e04efcfbc2sm1232068pfb.74.2024.02.07.03.06.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 03:06:02 -0800 (PST) From: Jian-Hong Pan To: Bjorn Helgaas , Johan Hovold , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , David Box Cc: Mika Westerberg , Nirmal Patel , Jonathan Derrick , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux@endlessos.org, Jian-Hong Pan Subject: [PATCH v3 1/3] PCI: vmd: Enable PCI PM's L1 substates of remapped PCIe Root Port and NVMe Date: Wed, 7 Feb 2024 19:02:29 +0800 Message-ID: <20240207110227.575983-3-jhp@endlessos.org> X-Mailer: git-send-email 2.43.0 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: 1790237980438522525 X-GMAIL-MSGID: 1790237980438522525 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 --- 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; }