From patchwork Wed Nov 20 06:17:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: En-Wei Wu X-Patchwork-Id: 2013438 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XtWP65mSJz23j8 for ; Wed, 20 Nov 2024 17:17:29 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1tDe1b-0006vh-5b; Wed, 20 Nov 2024 06:17:15 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1tDe1Z-0006vR-Lb for kernel-team@lists.ubuntu.com; Wed, 20 Nov 2024 06:17:13 +0000 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 56E583F29F for ; Wed, 20 Nov 2024 06:17:13 +0000 (UTC) Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-7edd6662154so4628357a12.0 for ; Tue, 19 Nov 2024 22:17:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732083431; x=1732688231; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YeYv/p5I5vPYKj+TgDH7jKkxLFsRQWKsCepHzYiSVqM=; b=eW7qf6Dlv5qd2FrPd4R9OmwD4GKdm/GGp9hSSzdQD7QDhLwRw6UFPjHyixSRS1EIp7 Dbwxz8BtdacrcmBhROc7N3KjsSShjF+ZdgXxc4T4iz6XbJylM+3VMpKuq6BBX5Jp/+I/ Ph8d5OklWQKS9s+Y95gzvtB6y1QaG3RWrOOt8bZybzKBKkoshGIionZR6f+jh6M3KmW9 1dGdSin5+haJo+6b9LL+36tZ1ACzGrmlFjUkOEXFvUogriZo1xYAZETCcnlB2cSJ7HIX 6Z7lYuFwGEgqv/jY4RivrHQJcHg0dcxTcUAlQd+Y8iFhN2gpxDKK6cdkR+BlDRB9Nk6w AQPQ== X-Gm-Message-State: AOJu0YxI1B51IqNS6/a+yySROwhhpf1HFq4y4TETfWwg1d+FhOiyAaW1 /TFBrPJgoXXQFvrcpic0yXGJlJBshBfG9mmoH8h/j42vbip4+F87IRQ0dZ6ktWIWX3yRmrPg3cs DBZiMsX9Gb1yiprDGG9QgsJNgtsMztHh2z+WG2lP6iqJkKkIU1WTOjEkS1qw0a77/jxOqZOFotG s9B5lVcgCE8A== X-Received: by 2002:a05:6a20:7f8d:b0:1d9:2453:433e with SMTP id adf61e73a8af0-1ddae0fff43mr2737744637.4.1732083430781; Tue, 19 Nov 2024 22:17:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjn4hJ4IdlTIlFk/XOQ5c0L9SCLaApopQu1NoTnn0qEJqAbPjmh8KwSPG5R1wbp/30oiTJtw== X-Received: by 2002:a05:6a20:7f8d:b0:1d9:2453:433e with SMTP id adf61e73a8af0-1ddae0fff43mr2737726637.4.1732083430448; Tue, 19 Nov 2024 22:17:10 -0800 (PST) Received: from rickywu0421-ThinkPad-X1-Carbon-Gen-11.. (118-163-61-247.hinet-ip.hinet.net. [118.163.61.247]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-724bef11eadsm774758b3a.89.2024.11.19.22.17.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 22:17:09 -0800 (PST) From: En-Wei Wu To: kernel-team@lists.ubuntu.com Subject: [SRU][N][PATCH v3 1/2] PCI: vmd: Set devices to D0 before enabling PM Date: Wed, 20 Nov 2024 14:17:02 +0800 Message-ID: <20241120061704.636295-2-en-wei.wu@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241120061704.636295-1-en-wei.wu@canonical.com> References: <20241120061704.636295-1-en-wei.wu@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jian-Hong Pan BugLink: https://bugs.launchpad.net/bugs/2085092 The remapped PCIe Root Port and the child device have 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=101376ns L1SubCtl2: T_PwrOn=50us Enable PCI-PM L1 PM Substates for devices below VMD while they are in D0 (see PCIe r6.0, sec 5.5.4). Link: https://lore.kernel.org/r/20241001083438.10070-4-jhp@endlessos.org Link: https://bugzilla.kernel.org/show_bug.cgi?id=218394 Signed-off-by: Jian-Hong Pan Signed-off-by: Krzysztof Wilczyński Signed-off-by: Bjorn Helgaas Reviewed-by: Kuppuswamy Sathyanarayanan (backported from commit d66041063192497a4a97d21dbf86b79a03a7f4fb linux-next) [En-Wei: We have a Kai-Heng's ASPM SAUCE patch so need to modify the code] Signed-off-by: En-Wei Wu --- drivers/pci/controller/vmd.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c index e33d213a34fb..e5a0c6c57524 100644 --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -757,7 +757,7 @@ static int vmd_pm_enable_quirk(struct pci_dev *pdev, void *userdata) pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_LTR); if (!pos) - return 0; + goto out_state_change; /* * Skip if the max snoop LTR is non-zero, indicating BIOS has set it @@ -765,7 +765,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_state_change; /* * Set the default values to the maximum required by the platform to @@ -777,6 +777,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_state_change: + /* + * 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 Wed Nov 20 06:17:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: En-Wei Wu X-Patchwork-Id: 2013436 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XtWP65Vtmz1xyG for ; Wed, 20 Nov 2024 17:17:29 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1tDe1b-0006vq-Ay; Wed, 20 Nov 2024 06:17:15 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1tDe1a-0006vZ-BL for kernel-team@lists.ubuntu.com; Wed, 20 Nov 2024 06:17:14 +0000 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id E9B6A3F1D3 for ; Wed, 20 Nov 2024 06:17:13 +0000 (UTC) Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-7cbe272efa6so5301911a12.3 for ; Tue, 19 Nov 2024 22:17:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732083432; x=1732688232; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O9/SC132G9YzZqH+0j0QxU9OV2I2TNq/vb8XfNPLbBk=; b=cWkbzC1rb1G7pQRKRON77T2xwsonesEjXcMre2C3ATFmaL/WhY+/gCa4WhW9hwpnJC ARQjX4NkD8Te58dh0BDxRS9lAEKKVjKAx5uz5INx66dh1t7LoZWC5ze7QahVQMZ9lNVw ZILef21R7wWtwEhbZO/8XS2q9Pd7fLy2JYi+tJV4TO9rMWAiXY/1bhyKKypuLQ1f+ViF rY/q/5WQdwjxrBm2Kcni61CHw3I7N6iErob21FgTvNN0jeySGnGCxMzxIi2+fgvMCSG8 LcYNX4BoTkUkIx04pIY/NjjLNnvQRR6cwEGS/3WULr0OWiekq/SfXyEQKznYjoy0t652 Uwnw== X-Gm-Message-State: AOJu0YzHg+0FC3xgvkXTg9aVAMkHRZyiAuDRYehGEMTOqs5F07c3oBcD ZmBqSE9uz7EZ3sVbCYMJIteKUrsB+Gr8aJ+U7Ewe8IVjxun+spHmEzAEgN53KrWfCBCew0Oml/U 3RMy5aAn51MezT4sWO3jMd6Llu5I2TwrB6+iwpJvAGVncN9UYiXMJB7vKFMFmSxFFLBhds6wLs5 1yWgIXVhLoxQ== X-Received: by 2002:a05:6a20:9189:b0:1da:2e7c:e510 with SMTP id adf61e73a8af0-1ddae00a9c3mr2927965637.1.1732083432205; Tue, 19 Nov 2024 22:17:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IEYBbgai6BM2RJXh37JO72TsD7PwHs0XhnBBRkSDZ1VMj97Ubox8rV5w7rN/zcjctdkpFsGFQ== X-Received: by 2002:a05:6a20:9189:b0:1da:2e7c:e510 with SMTP id adf61e73a8af0-1ddae00a9c3mr2927946637.1.1732083431834; Tue, 19 Nov 2024 22:17:11 -0800 (PST) Received: from rickywu0421-ThinkPad-X1-Carbon-Gen-11.. (118-163-61-247.hinet-ip.hinet.net. [118.163.61.247]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-724bef11eadsm774758b3a.89.2024.11.19.22.17.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 22:17:11 -0800 (PST) From: En-Wei Wu To: kernel-team@lists.ubuntu.com Subject: [SRU][N][PATCH v3 2/2] PCI/ASPM: Add notes about enabling PCI-PM L1SS to pci_enable_link_state(_locked) Date: Wed, 20 Nov 2024 14:17:03 +0800 Message-ID: <20241120061704.636295-3-en-wei.wu@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241120061704.636295-1-en-wei.wu@canonical.com> References: <20241120061704.636295-1-en-wei.wu@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jian-Hong Pan BugLink: https://bugs.launchpad.net/bugs/2085092 According to "PCIe r6.0, sec 5.5.4", add note about D0 requirement in pci_enable_link_state() kernel-doc. Link: https://lore.kernel.org/r/20241001083438.10070-6-jhp@endlessos.org Signed-off-by: Jian-Hong Pan Signed-off-by: Krzysztof Wilczyński Reviewed-by: Kuppuswamy Sathyanarayanan Acked-by: Bjorn Helgaas (cherry picked from commit e1714f3b1f4d2af5df26e4a0e4a70ef64b15e3ee linux-next) Signed-off-by: En-Wei Wu --- 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 138ff0efa6dd..182226ce5c4e 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -1450,6 +1450,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 */ @@ -1466,6 +1469,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 *