linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI: AC: Quirk GK45 to skip reading _PSR
@ 2021-10-24 22:04 Stefan Schaeckeler
  2021-10-26 13:36 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Schaeckeler @ 2021-10-24 22:04 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown, linux-acpi, linux-kernel; +Cc: Stefan Schaeckeler

Let GK45 not go into BIOS for determining the AC power state. BIOS wrongly
returns 0. Hardcode the power state to 1.

The mini PC GK45 by Besstar Tech Lld. (aka Kodlix) just runs off AC. It
does not include any batteries. Nevertheless BIOS reports AC off:

root@kodlix:/usr/src/linux# cat /sys/class/power_supply/ADP1/online
0

root@kodlix:/usr/src/linux# modprobe acpi_dbg
root@kodlix:/usr/src/linux# tools/power/acpi/acpidbg

- find _PSR
   \_SB.PCI0.SBRG.H_EC.ADP1._PSR Method       000000009283cee8 001 Args 0 Len 001C Aml 00000000f54e5f67

- execute \_SB.PCI0.SBRG.H_EC.ADP1._PSR
Evaluating \_SB.PCI0.SBRG.H_EC.ADP1._PSR
Evaluation of \_SB.PCI0.SBRG.H_EC.ADP1._PSR returned object 00000000dc08c187, external buffer length 18
 [Integer] = 0000000000000000

that should be

 [Integer] = 0000000000000001

Signed-off-by: Stefan Schaeckeler <schaecsn@gmx.net>
---
 drivers/acpi/ac.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index b0cb662233f1..81aff651a0d4 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -61,6 +61,7 @@ static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume);

 static int ac_sleep_before_get_state_ms;
 static int ac_check_pmic = 1;
+static int ac_only;

 static struct acpi_driver acpi_ac_driver = {
 	.name = "ac",
@@ -93,6 +94,11 @@ static int acpi_ac_get_state(struct acpi_ac *ac)
 	if (!ac)
 		return -EINVAL;

+	if (ac_only) {
+		ac->state = 1;
+		return 0;
+	}
+
 	status = acpi_evaluate_integer(ac->device->handle, "_PSR", NULL,
 				       &ac->state);
 	if (ACPI_FAILURE(status)) {
@@ -200,6 +206,12 @@ static int __init ac_do_not_check_pmic_quirk(const struct dmi_system_id *d)
 	return 0;
 }

+static int __init ac_only_quirk(const struct dmi_system_id *d)
+{
+	ac_only = 1;
+	return 0;
+}
+
 /* Please keep this list alphabetically sorted */
 static const struct dmi_system_id ac_dmi_table[]  __initconst = {
 	{
@@ -209,6 +221,13 @@ static const struct dmi_system_id ac_dmi_table[]  __initconst = {
 			DMI_MATCH(DMI_PRODUCT_NAME, "EF20EA"),
 		},
 	},
+	{
+		/* Kodlix GK45 returning incorrect state */
+		.callback = ac_only_quirk,
+		.matches = {
+			DMI_MATCH(DMI_PRODUCT_NAME, "GK45"),
+		},
+	},
 	{
 		/* Lenovo Ideapad Miix 320, AXP288 PMIC, separate fuel-gauge */
 		.callback = ac_do_not_check_pmic_quirk,
--
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ACPI: AC: Quirk GK45 to skip reading _PSR
  2021-10-24 22:04 [PATCH] ACPI: AC: Quirk GK45 to skip reading _PSR Stefan Schaeckeler
@ 2021-10-26 13:36 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2021-10-26 13:36 UTC (permalink / raw)
  To: Stefan Schaeckeler
  Cc: Rafael J. Wysocki, Len Brown, ACPI Devel Maling List,
	Linux Kernel Mailing List

On Mon, Oct 25, 2021 at 12:07 AM Stefan Schaeckeler <schaecsn@gmx.net> wrote:
>
> Let GK45 not go into BIOS for determining the AC power state. BIOS wrongly
> returns 0. Hardcode the power state to 1.
>
> The mini PC GK45 by Besstar Tech Lld. (aka Kodlix) just runs off AC. It
> does not include any batteries. Nevertheless BIOS reports AC off:
>
> root@kodlix:/usr/src/linux# cat /sys/class/power_supply/ADP1/online
> 0
>
> root@kodlix:/usr/src/linux# modprobe acpi_dbg
> root@kodlix:/usr/src/linux# tools/power/acpi/acpidbg
>
> - find _PSR
>    \_SB.PCI0.SBRG.H_EC.ADP1._PSR Method       000000009283cee8 001 Args 0 Len 001C Aml 00000000f54e5f67
>
> - execute \_SB.PCI0.SBRG.H_EC.ADP1._PSR
> Evaluating \_SB.PCI0.SBRG.H_EC.ADP1._PSR
> Evaluation of \_SB.PCI0.SBRG.H_EC.ADP1._PSR returned object 00000000dc08c187, external buffer length 18
>  [Integer] = 0000000000000000
>
> that should be
>
>  [Integer] = 0000000000000001
>
> Signed-off-by: Stefan Schaeckeler <schaecsn@gmx.net>
> ---
>  drivers/acpi/ac.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>
> diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
> index b0cb662233f1..81aff651a0d4 100644
> --- a/drivers/acpi/ac.c
> +++ b/drivers/acpi/ac.c
> @@ -61,6 +61,7 @@ static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume);
>
>  static int ac_sleep_before_get_state_ms;
>  static int ac_check_pmic = 1;
> +static int ac_only;
>
>  static struct acpi_driver acpi_ac_driver = {
>         .name = "ac",
> @@ -93,6 +94,11 @@ static int acpi_ac_get_state(struct acpi_ac *ac)
>         if (!ac)
>                 return -EINVAL;
>
> +       if (ac_only) {
> +               ac->state = 1;
> +               return 0;
> +       }
> +
>         status = acpi_evaluate_integer(ac->device->handle, "_PSR", NULL,
>                                        &ac->state);
>         if (ACPI_FAILURE(status)) {
> @@ -200,6 +206,12 @@ static int __init ac_do_not_check_pmic_quirk(const struct dmi_system_id *d)
>         return 0;
>  }
>
> +static int __init ac_only_quirk(const struct dmi_system_id *d)
> +{
> +       ac_only = 1;
> +       return 0;
> +}
> +
>  /* Please keep this list alphabetically sorted */
>  static const struct dmi_system_id ac_dmi_table[]  __initconst = {
>         {
> @@ -209,6 +221,13 @@ static const struct dmi_system_id ac_dmi_table[]  __initconst = {
>                         DMI_MATCH(DMI_PRODUCT_NAME, "EF20EA"),
>                 },
>         },
> +       {
> +               /* Kodlix GK45 returning incorrect state */
> +               .callback = ac_only_quirk,
> +               .matches = {
> +                       DMI_MATCH(DMI_PRODUCT_NAME, "GK45"),
> +               },
> +       },
>         {
>                 /* Lenovo Ideapad Miix 320, AXP288 PMIC, separate fuel-gauge */
>                 .callback = ac_do_not_check_pmic_quirk,
> --

Applied as 5.16 material with minor edits in the changelog, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-26 13:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-24 22:04 [PATCH] ACPI: AC: Quirk GK45 to skip reading _PSR Stefan Schaeckeler
2021-10-26 13:36 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).