From nobody Sun Oct 5 14:38:38 2025 Received: from vps-ovh.mhejs.net (vps-ovh.mhejs.net [145.239.82.108]) (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 B26C5173; Sun, 3 Aug 2025 20:04:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=145.239.82.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754251448; cv=none; b=i8QKklzjctomLnQ8cOvaEv076PC0iV1V7yqsnMZOFqVF4dLl+1/mjTZfuktX4zijN3v3y33oSz9eCrcxznAuoWXkmNlvtWw2RMCwTWLAM+PFueS2EkxaFkdSgL3pOKehZC2Wu1Zr8IjOYw88As3S+cOKZ8wZ0TCQaBE+x2iTyz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754251448; c=relaxed/simple; bh=rhGlweNzP000hWH7t8pE2TgvpLoIWDrUYP0Xjk71t78=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DGSLTOZF9HpYh1ol6GbViysk3/v/A3sjTQ5lD6DtNoHpIuRIBGg/PKQNrvdiJ7DHrhPmVtl6HI14UIHPNFLOic88OSjHCVVeZ6tnFftsCWPVeZASYCWSzdZIm2/xXjPlHFtglrF0XUgiw7DD+6Vy9FFfi/VapLUf7qK7GvyaJis= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=maciej.szmigiero.name; spf=pass smtp.mailfrom=vps-ovh.mhejs.net; arc=none smtp.client-ip=145.239.82.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=maciej.szmigiero.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vps-ovh.mhejs.net Received: from MUA by vps-ovh.mhejs.net with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uieDx-00000000Mun-2Im5; Sun, 03 Aug 2025 21:18:25 +0200 From: "Maciej S. Szmigiero" To: "Rafael J. Wysocki" , Len Brown Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/2] ACPI: PM: Add power resource init function Date: Sun, 3 Aug 2025 21:18:11 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: 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 Sender: mhej@vps-ovh.mhejs.net Content-Type: text/plain; charset="utf-8" This way DMI based quirk matching and quirk flag initialization can be done just once - in the newly introduced acpi_power_resources_init() function, which is similar to existing acpi_*_init() functions. Convert the single already existing DMI match-based quirk in this ACPI power resource handler ("leave unused power resources on" quirk) to such one-time initialization in acpi_power_resources_init() function instead of re-running that DMI match each time acpi_turn_off_unused_power_resources() gets called. Signed-off-by: Maciej S. Szmigiero --- drivers/acpi/internal.h | 1 + drivers/acpi/power.c | 10 +++++++++- drivers/acpi/scan.c | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index e2781864fdce..63354972ab0b 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -140,6 +140,7 @@ int __acpi_device_uevent_modalias(const struct acpi_dev= ice *adev, /* -----------------------------------------------------------------------= --- Power Resource -----------------------------------------------------------------------= --- */ +void acpi_power_resources_init(void); void acpi_power_resources_list_free(struct list_head *list); int acpi_extract_power_resources(union acpi_object *package, unsigned int = start, struct list_head *list); diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index b7243d7563b1..cd9380b1f951 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c @@ -63,6 +63,8 @@ struct acpi_power_resource_entry { struct acpi_power_resource *resource; }; =20 +static bool unused_power_resources_quirk; + static LIST_HEAD(acpi_power_resource_list); static DEFINE_MUTEX(power_resource_list_lock); =20 @@ -1046,7 +1048,7 @@ void acpi_turn_off_unused_power_resources(void) { struct acpi_power_resource *resource; =20 - if (dmi_check_system(dmi_leave_unused_power_resources_on)) + if (unused_power_resources_quirk) return; =20 mutex_lock(&power_resource_list_lock); @@ -1065,3 +1067,9 @@ void acpi_turn_off_unused_power_resources(void) =20 mutex_unlock(&power_resource_list_lock); } + +void __init acpi_power_resources_init(void) +{ + unused_power_resources_quirk =3D + dmi_check_system(dmi_leave_unused_power_resources_on); +} diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index fb1fe9f3b1a3..bb74e7834435 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2702,6 +2702,7 @@ void __init acpi_scan_init(void) acpi_memory_hotplug_init(); acpi_watchdog_init(); acpi_pnp_init(); + acpi_power_resources_init(); acpi_int340x_thermal_init(); acpi_init_lpit(); From nobody Sun Oct 5 14:38:38 2025 Received: from vps-ovh.mhejs.net (vps-ovh.mhejs.net [145.239.82.108]) (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 20DD420311; Sun, 3 Aug 2025 19:18:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=145.239.82.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754248715; cv=none; b=Ju7bl4kdiGdXXgIESNQycjimovO7615d33CQQwr7JzwzwjD13Eb4sIuG3ChidzTLpqGQ6JY0grIFJh+t/kMYmQBzM7TVDll0lO9Bb9Vp0F3GGF30JawBt1gOrwLc5zHw4p1jcGTl6IgeC0AMuDJgD2qjs7n74wBYhgrPyrKNing= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754248715; c=relaxed/simple; bh=t4JFnPe9gqwe0MLV9N3+1ndOHzUwYCL+u3GoDH6fu10=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jhKdWczqi2N6Q8cYxBc5L1krjmBufFtHYUz67Mj3DMZlHxc7v38W5sC03AtD01lH748P62hmfF5JE0KccUl9zKsCbi3y85sYGTNFCYSGEqDibGiQhZIB4qLGs1VVwydBkq0QiKy49vOBtU0ho7DmUwQ0DY8TP5//UPejM5/sdLQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=maciej.szmigiero.name; spf=pass smtp.mailfrom=vps-ovh.mhejs.net; arc=none smtp.client-ip=145.239.82.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=maciej.szmigiero.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vps-ovh.mhejs.net Received: from MUA by vps-ovh.mhejs.net with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uieE2-00000000Muu-2ls7; Sun, 03 Aug 2025 21:18:30 +0200 From: "Maciej S. Szmigiero" To: "Rafael J. Wysocki" , Len Brown Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/2] ACPI: PM: Add HP EliteBook 855 G7 WWAN modem power resource quirk Date: Sun, 3 Aug 2025 21:18:12 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: 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 Sender: mhej@vps-ovh.mhejs.net Content-Type: text/plain; charset="utf-8" This laptop (and possibly similar models too) has power resource called "GP12.PXP_" for its Intel XMM7360 WWAN modem. For this power resource to turn ON power for the modem it needs certain internal flag called "ONEN" to be set: Method (_ON, 0, NotSerialized) // _ON_: Power On { If (^^^LPCB.EC0.ECRG) { If ((ONEN =3D=3D Zero)) { Return (Zero) } (..) } } This flag only gets set from this power resource "_OFF" method, while the actual modem power gets turned off during suspend by "GP12.PTS" method called from the global "_PTS" (Prepare To Sleep) method. In fact, this power resource "_OFF" method implementation just sets the aforementioned flag: Method (_OFF, 0, NotSerialized) // _OFF: Power Off { OFEN =3D Zero ONEN =3D One } Upon hibernation finish we try to set this power resource back ON since its "_STA" method returns 0 and the resource is still considered in use as it is declared as required for D0 for both the modem ACPI device (GP12.PWAN) and its parent PCIe port ACPI device (GP12). But the "_ON" method won't do anything since that "ONEN" flag is not set. Overall, this means the modem is dead after hibernation finish until the laptop is rebooted since the modem power has been cut by "_PTS" and its PCI configuration was lost and not able to be restored. The easiest way to workaround this issue is to call this power resource "_OFF" method before calling the "_ON" method to make sure the "ONEN" flag gets properly set. This makes the modem alive once again after hibernation finish - with properly restored PCI configuration space. Since this platform does *not* support S3 the fact that acpi_resume_power_resources() is also called during resume from S3 is not a problem there. Do the DMI based quirk matching and quirk flag initialization just once - in acpi_power_resources_init() function. This way the whole resume path overhead of this change on other systems amounts to simple hp_eb_gp12pxp_quirk flag comparison. Signed-off-by: Maciej S. Szmigiero --- drivers/acpi/power.c | 80 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index cd9380b1f951..361a7721a6a8 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c @@ -23,6 +23,7 @@ =20 #define pr_fmt(fmt) "ACPI: PM: " fmt =20 +#include #include #include #include @@ -63,6 +64,7 @@ struct acpi_power_resource_entry { struct acpi_power_resource *resource; }; =20 +static bool hp_eb_gp12pxp_quirk; static bool unused_power_resources_quirk; =20 static LIST_HEAD(acpi_power_resource_list); @@ -994,6 +996,38 @@ struct acpi_device *acpi_add_power_resource(acpi_handl= e handle) } =20 #ifdef CONFIG_ACPI_SLEEP +static bool resource_is_gp12pxp(acpi_handle handle) +{ + const char *path; + bool ret; + + path =3D acpi_handle_path(handle); + ret =3D path && strcmp(path, "\\_SB_.PCI0.GP12.PXP_") =3D=3D 0; + kfree(path); + + return ret; +} + +static void acpi_resume_on_eb_gp12pxp(struct acpi_power_resource *resource) +{ + acpi_handle_notice(resource->device.handle, + "HP EB quirk - turning OFF then ON\n"); + + __acpi_power_off(resource); + __acpi_power_on(resource); + + /* + * Use the same delay as DSDT uses in modem _RST method. + * + * Otherwise we get "Unable to change power state from unknown to D0, + * device inaccessible" error for the modem PCI device after thaw. + * + * This power resource is normally being enabled only during thaw (once) + * so this wait is not a performance issue. + */ + msleep(200); +} + void acpi_resume_power_resources(void) { struct acpi_power_resource *resource; @@ -1015,8 +1049,14 @@ void acpi_resume_power_resources(void) =20 if (state =3D=3D ACPI_POWER_RESOURCE_STATE_OFF && resource->ref_count) { - acpi_handle_debug(resource->device.handle, "Turning ON\n"); - __acpi_power_on(resource); + if (hp_eb_gp12pxp_quirk && + resource_is_gp12pxp(resource->device.handle)) { + acpi_resume_on_eb_gp12pxp(resource); + } else { + acpi_handle_debug(resource->device.handle, + "Turning ON\n"); + __acpi_power_on(resource); + } } =20 mutex_unlock(&resource->resource_lock); @@ -1026,6 +1066,41 @@ void acpi_resume_power_resources(void) } #endif =20 +static const struct dmi_system_id dmi_hp_elitebook_gp12pxp_quirk[] =3D { +/* + * This laptop (and possibly similar models too) has power resource called + * "GP12.PXP_" for its WWAN modem. + * + * For this power resource to turn ON power for the modem it needs certain + * internal flag called "ONEN" to be set. + * This flag only gets set from this power resource "_OFF" method, while t= he + * actual modem power gets turned off during suspend by "GP12.PTS" method + * called from the global "_PTS" (Prepare To Sleep) method. + * On the other hand, this power resource "_OFF" method implementation just + * sets the aforementioned flag without actually doing anything else (it + * doesn't contain any code to actually turn off power). + * + * The above means that when upon hibernation finish we try to set this + * power resource back ON since its "_STA" method returns 0 (while the res= ource + * is still considered in use) its "_ON" method won't do anything since + * that "ONEN" flag is not set. + * Overall, this means the modem is dead until laptop is rebooted since its + * power has been cut by "_PTS" and its PCI configuration was lost and not= able + * to be restored. + * + * The easiest way to workaround the issue is to call this power resource + * "_OFF" method before calling the "_ON" method to make sure the "ONEN" + * flag gets properly set. + */ + { + .matches =3D { + DMI_MATCH(DMI_SYS_VENDOR, "HP"), + DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook 855 G7 Notebook PC"), + }, + }, + {} +}; + static const struct dmi_system_id dmi_leave_unused_power_resources_on[] = =3D { { /* @@ -1070,6 +1145,7 @@ void acpi_turn_off_unused_power_resources(void) =20 void __init acpi_power_resources_init(void) { + hp_eb_gp12pxp_quirk =3D dmi_check_system(dmi_hp_elitebook_gp12pxp_quirk); unused_power_resources_quirk =3D dmi_check_system(dmi_leave_unused_power_resources_on); }