From nobody Mon Feb 9 01:36:19 2026 Received: from out28-173.mail.aliyun.com (out28-173.mail.aliyun.com [115.124.28.173]) (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 10E121C84D9; Thu, 5 Jun 2025 06:59:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.28.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749106782; cv=none; b=iZZXtAkdlADDqI7HA29lbpE8Z8KR5kWbTiW6XvRITlHRfsC1HJNNJPVFv92bQmFBUO+Ok9YE4/Jii2wPqQCUaagqY2B3Ms48KhJ6bXGI0O4F2wNOpoionugcoS4wz6yIDKFz5mSHxhssEGIiJaDuLw/xpNOyTPPbMqDYmWbhUmw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749106782; c=relaxed/simple; bh=4hPtXI/lyb7DqoRkDNQNpa41b8fqt7lcwCiqE+1QotY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HBO7jeTjEj0M4S1gLKA29rorxl3jxWLer8NNyXV/2wgS3Mvyd4c4/O5GPGPQ5Js1X2RCu9XIeqOeMMfme7Q6D+qitA+Yb9+Y01SUwrHHf9nKA+YmjuTLDLMIbxDMu4prCXFBydpCsorlu2qEeRVAZzq8MZ7a0Tc1FcYLQoxMmdk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ttyinfo.com; spf=pass smtp.mailfrom=ttyinfo.com; arc=none smtp.client-ip=115.124.28.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ttyinfo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ttyinfo.com Received: from tzl..(mailfrom:zhoushengqing@ttyinfo.com fp:SMTPD_---.dBaQkKN_1749106759 cluster:ay29) by smtp.aliyun-inc.com; Thu, 05 Jun 2025 14:59:28 +0800 From: Zhou Shengqing To: "Rafael J. Wysocki" , Bjorn Helgaas Cc: Len Brown , linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, zhoushengqing@ttyinfo.com Subject: [PATCH v6 1/2] PCI/ACPI: Add rev 2 check for PRESERVE_BOOT_CONFIG function Date: Thu, 5 Jun 2025 06:58:13 +0000 Message-Id: <20250605065814.41298-2-zhoushengqing@ttyinfo.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250605065814.41298-1-zhoushengqing@ttyinfo.com> References: <20250605065814.41298-1-zhoushengqing@ttyinfo.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Per PCI Firmware Specification Revision 3.3 Table 4-7 _DSM Definitions for PCI. Preserve PCI Boot Configuration Initial Revision ID changed to 2. So add rev2 check and add acpi_check_dsm() for DSM_PCI_PRESERVE_BOOT_CONFIG. Signed-off-by: Zhou Shengqing Reviewed-by: Mario Limonciello (AMD) --- v6:follow Rafael advice, revise code style(use for-loop to check revision). v5:follow Bjorn advice, add acpi_check_dsm for PCI _DSM. v4:Initialize *obj to NULL. v3:try revision id 1 first, then try revision id 2. v2:add Fixes tag. Fixes: 9d7d5db8e78e ("PCI: Move PRESERVE_BOOT_CONFIG _DSM evaluation to pci= _re") --- drivers/pci/pci-acpi.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index b78e0e417324..c49abd03daf0 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -122,22 +122,40 @@ phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle h= andle) =20 bool pci_acpi_preserve_config(struct pci_host_bridge *host_bridge) { - if (ACPI_HANDLE(&host_bridge->dev)) { - union acpi_object *obj; + bool rc =3D false; + u64 rev; + union acpi_object *obj; + + if (!ACPI_HANDLE(&host_bridge->dev)) + return false; + + /* + * Evaluate the "PCI Boot Configuration" _DSM Function. If it + * exists and returns 0, we must preserve any PCI resource + * assignments made by firmware for this host bridge. + * + * Per PCI Firmware r3.2, released Jan 26, 2015, + * DSM_PCI_PRESERVE_BOOT_CONFIG Revision ID is 1. But PCI Firmware r3.3, + * released Jan 20, 2021, changed sec 4.6.5 to say + * "lowest valid Revision ID value: 2". So check rev 1 first, then rev 2. + */ + for (rev =3D 1; rev <=3D 2; rev++) { + if (!acpi_check_dsm(ACPI_HANDLE(&host_bridge->dev), + &pci_acpi_dsm_guid, rev, BIT(DSM_PCI_PRESERVE_BOOT_CONFIG))) + continue; =20 - /* - * Evaluate the "PCI Boot Configuration" _DSM Function. If it - * exists and returns 0, we must preserve any PCI resource - * assignments made by firmware for this host bridge. - */ obj =3D acpi_evaluate_dsm_typed(ACPI_HANDLE(&host_bridge->dev), - &pci_acpi_dsm_guid, - 1, DSM_PCI_PRESERVE_BOOT_CONFIG, - NULL, ACPI_TYPE_INTEGER); + &pci_acpi_dsm_guid, rev, + DSM_PCI_PRESERVE_BOOT_CONFIG, + NULL, ACPI_TYPE_INTEGER); if (obj && obj->integer.value =3D=3D 0) - return true; + rc =3D true; + ACPI_FREE(obj); - } + + if (rc) + return true; + } =20 return false; } --=20 2.39.2 From nobody Mon Feb 9 01:36:19 2026 Received: from out198-16.us.a.mail.aliyun.com (out198-16.us.a.mail.aliyun.com [47.90.198.16]) (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 DAEF91F3FE8; Thu, 5 Jun 2025 06:59:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.90.198.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749106800; cv=none; b=Vt5hH1voogN/xWbR9mmYThtF06Nl/FYOA9ppmMUVgXZudn1UZ14n0rFa/FqeR5PxTEqs31YJSKC4oUTHQPKg6koiu6lPoCGrtXFrQxKsaDb3BBYkIKUdkVoSs0FMl6P8/07OuYHnXSEw3yq9C7khMPi9DE+TKESHYKvTpV3YCWM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749106800; c=relaxed/simple; bh=5azRthlIMduipu4bhlXqqDMNc7jlGc6VSUxKhy2xwXk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=S8QbreuZIdXI++AVShiFoDRk5x1sX5biGLHVH1NDr79rJBo0x5kUN8vgTVYtI/ffpxTn/geq2Qr5eaH8JiRvgU+RAkmGM436heh+ohxqWj4aOKiK7FXQXYjGMM88OlhoGqhb5okP+RJJcl5sTJOa1+F6Qx9fS91TJ0+WCnUqR+s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ttyinfo.com; spf=pass smtp.mailfrom=ttyinfo.com; arc=none smtp.client-ip=47.90.198.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ttyinfo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ttyinfo.com Received: from tzl..(mailfrom:zhoushengqing@ttyinfo.com fp:SMTPD_---.dBaQkh5_1749106768 cluster:ay29) by smtp.aliyun-inc.com; Thu, 05 Jun 2025 14:59:35 +0800 From: Zhou Shengqing To: "Rafael J. Wysocki" , Bjorn Helgaas Cc: Len Brown , linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, zhoushengqing@ttyinfo.com Subject: [PATCH v6 2/2] PCI/ACPI: Add acpi_check_dsm() for PCI _DSM definitions Date: Thu, 5 Jun 2025 06:58:14 +0000 Message-Id: <20250605065814.41298-3-zhoushengqing@ttyinfo.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250605065814.41298-1-zhoushengqing@ttyinfo.com> References: <20250605065814.41298-1-zhoushengqing@ttyinfo.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add acpi_check_dsm() for DSM_PCI_POWER_ON_RESET_DELAY and DSM_PCI_DEVICE_READINESS_DURATIONS. Signed-off-by: Zhou Shengqing Reviewed-by: Mario Limonciello (AMD) --- drivers/pci/pci-acpi.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index c49abd03daf0..e3680448b6a1 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -1240,6 +1240,7 @@ bool acpi_pci_need_resume(struct pci_dev *dev) =20 void acpi_pci_add_bus(struct pci_bus *bus) { + u64 rev; union acpi_object *obj; struct pci_host_bridge *bridge; =20 @@ -1256,7 +1257,12 @@ void acpi_pci_add_bus(struct pci_bus *bus) if (!pci_is_root_bus(bus)) return; =20 - obj =3D acpi_evaluate_dsm_typed(ACPI_HANDLE(bus->bridge), &pci_acpi_dsm_g= uid, 3, + rev =3D 3; + if (!acpi_check_dsm(ACPI_HANDLE(bus->bridge), &pci_acpi_dsm_guid, rev, + BIT(DSM_PCI_POWER_ON_RESET_DELAY))) + return; + + obj =3D acpi_evaluate_dsm_typed(ACPI_HANDLE(bus->bridge), &pci_acpi_dsm_g= uid, rev, DSM_PCI_POWER_ON_RESET_DELAY, NULL, ACPI_TYPE_INTEGER); if (!obj) return; @@ -1412,12 +1418,18 @@ static void pci_acpi_optimize_delay(struct pci_dev = *pdev, { struct pci_host_bridge *bridge =3D pci_find_host_bridge(pdev->bus); int value; + u64 rev; union acpi_object *obj, *elements; =20 if (bridge->ignore_reset_delay) pdev->d3cold_delay =3D 0; =20 - obj =3D acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, 3, + rev =3D 3; + if (!acpi_check_dsm(handle, &pci_acpi_dsm_guid, rev, + BIT(DSM_PCI_DEVICE_READINESS_DURATIONS))) + return; + + obj =3D acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, rev, DSM_PCI_DEVICE_READINESS_DURATIONS, NULL, ACPI_TYPE_PACKAGE); if (!obj) --=20 2.39.2