From nobody Fri Dec 19 10:35:55 2025 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 E2C6C257448; Thu, 9 Oct 2025 19:27:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760038052; cv=none; b=qdZyZudVfv+WK2krSAmkt2FxwhoMdifXj4hVC0DLgy40GN7u1YXoXrTitNYTRtXC9YIh+GyaY4j9ZtLcXYqbHz4WLPS70B7PCFijHf3ePsJ1bCaBnc2QdNjG7ZxtBfhGvLlXZDI9ahpk+YhHK0TKsAyivV1EppvZ80fzeSHH2Ks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760038052; c=relaxed/simple; bh=UTW2ZGiyy69eDiDpqlp14GE5qGdW3hytlY6efzzvicY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JA9sSKCW+ZxZ2pCcPVrHGjm51vwxEygKH4EdmEAEtVl/vbIMWl94yc5hi94GYRRcuMstqGSq/o8GOuYeS94/5qrCE/8y6PeYDsBgs1KI7tnUFPPdqwCcPj9aiKTG7nVWx4G7WNX+w+Xcw8cVyo/+uShkc9DKeZOXvaQ5XSNKeFo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fyvgJBpx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fyvgJBpx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F933C4CEF8; Thu, 9 Oct 2025 19:27:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760038051; bh=UTW2ZGiyy69eDiDpqlp14GE5qGdW3hytlY6efzzvicY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fyvgJBpxlel4K0G8hQSPenCYoEaIWjFSbfDsvJ7VOJUJPeUEjfjIE9KH0AFg8UpQX KYdWFIpvtSBqpAiKfz+hj5EU7JUbv381HsWV+3c3OUHNEV6tJBNk3aBIkgfgjDNdS0 EMLmRuF2+ef4vpbpvU6w2SNUoGQwGLW5Wt+Or8G8pDb18HIW8ok+GGDBYP0DQWJ4dt H8tg2oDqzYd9t3pKCppREmF37H5xg6LT/4tC2cyKuhmfSnl40IRiQn0yxF6bwQumsv q/6CneJsie18i4SOvXwhPAu/J4atLgHsytTzL03mzc4b6UpLzxrzv2TANpM0B56VFL ZLKDidAyZ7GJA== From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Linux PM , Srinivas Pandruvada , Mario Limonciello Subject: [PATCH v1 3/3] ACPI: PM: s2idle: Only retrieve constraints when needed Date: Thu, 09 Oct 2025 21:27:11 +0200 Message-ID: <3027060.e9J7NaK4W3@rafael.j.wysocki> Organization: Linux Kernel Development In-Reply-To: <4699399.LvFx2qVVIh@rafael.j.wysocki> References: <4699399.LvFx2qVVIh@rafael.j.wysocki> 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" From: Rafael J. Wysocki The evaluation of LPS0 _DSM Function 1 in lps0_device_attach() may be useless if pm_debug_messages_on is never set. For this reason, instead of evaluating it in lps0_device_attach(), do that in a new .begin() callback for s2idle, acpi_s2idle_begin_lps0(), only when pm_debug_messages_on is set at that point. However, never attempt to evaluate LPS0 _DSM Function 1 more than once to avoid recurring failures. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/x86/s2idle.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) --- a/drivers/acpi/x86/s2idle.c +++ b/drivers/acpi/x86/s2idle.c @@ -303,6 +303,9 @@ static void lpi_check_constraints(void) { struct lpi_constraints *entry; =20 + if (IS_ERR_OR_NULL(lpi_constraints_table)) + return; + for_each_lpi_constraint(entry) { struct acpi_device *adev =3D acpi_fetch_acpi_dev(entry->handle); =20 @@ -484,11 +487,6 @@ static int lps0_device_attach(struct acp =20 lps0_device_handle =3D adev->handle; =20 - if (acpi_s2idle_vendor_amd()) - lpi_device_get_constraints_amd(); - else - lpi_device_get_constraints(); - /* * Use suspend-to-idle by default if ACPI_FADT_LOW_POWER_S0 is set in * the FADT and the default suspend mode was not set from the command @@ -515,6 +513,25 @@ static struct acpi_scan_handler lps0_han .attach =3D lps0_device_attach, }; =20 +static int acpi_s2idle_begin_lps0(void) +{ + if (pm_debug_messages_on && !lpi_constraints_table) { + if (acpi_s2idle_vendor_amd()) + lpi_device_get_constraints_amd(); + else + lpi_device_get_constraints(); + + /* + * Try to retrieve the constraints only once because failures + * to do so usually are sticky. + */ + if (!lpi_constraints_table) + lpi_constraints_table =3D ERR_PTR(-ENODATA); + } + + return acpi_s2idle_begin(); +} + static int acpi_s2idle_prepare_late_lps0(void) { struct acpi_s2idle_dev_ops *handler; @@ -612,7 +629,7 @@ static void acpi_s2idle_restore_early_lp } =20 static const struct platform_s2idle_ops acpi_s2idle_ops_lps0 =3D { - .begin =3D acpi_s2idle_begin, + .begin =3D acpi_s2idle_begin_lps0, .prepare =3D acpi_s2idle_prepare, .prepare_late =3D acpi_s2idle_prepare_late_lps0, .check =3D acpi_s2idle_check_lps0,