All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ACPI / battery: use callback for setting up quirks
@ 2014-06-03 19:01 Alexander Mezin
  2014-06-03 19:01 ` [PATCH 2/2] ACPI / battery: add quirk for Acer Aspire V5-573G Alexander Mezin
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Alexander Mezin @ 2014-06-03 19:01 UTC (permalink / raw)
  To: linux-acpi; +Cc: Alexander Mezin

Use callback for setting up quirk instead of checking return code
of dmi_check_system(). This change will allow using bat_dmi_table
for other quirks.

Signed-off-by: Alexander Mezin <mezin.alexander@gmail.com>
---
 drivers/acpi/battery.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 6e7b2a1..f17bc7e 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -1058,8 +1058,15 @@ static int battery_notify(struct notifier_block *nb,
 	return 0;
 }
 
+static int battery_bix_broken_package_quirk(const struct dmi_system_id *d)
+{
+	battery_bix_broken_package = 1;
+	return 0;
+}
+
 static struct dmi_system_id bat_dmi_table[] = {
 	{
+		.callback = battery_bix_broken_package_quirk,
 		.ident = "NEC LZ750/LS",
 		.matches = {
 			DMI_MATCH(DMI_SYS_VENDOR, "NEC"),
@@ -1176,8 +1183,7 @@ static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie)
 	if (acpi_disabled)
 		return;
 
-	if (dmi_check_system(bat_dmi_table))
-		battery_bix_broken_package = 1;
+	dmi_check_system(bat_dmi_table);
 	
 #ifdef CONFIG_ACPI_PROCFS_POWER
 	acpi_battery_dir = acpi_lock_battery_dir();
-- 
2.0.0


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

* [PATCH 2/2] ACPI / battery: add quirk for Acer Aspire V5-573G
  2014-06-03 19:01 [PATCH 1/2] ACPI / battery: use callback for setting up quirks Alexander Mezin
@ 2014-06-03 19:01 ` Alexander Mezin
  2014-06-10  2:15   ` Lan Tianyu
  2014-06-10  2:13 ` [PATCH 1/2] ACPI / battery: use callback for setting up quirks Lan Tianyu
  2014-06-19  0:08 ` Rafael J. Wysocki
  2 siblings, 1 reply; 6+ messages in thread
From: Alexander Mezin @ 2014-06-03 19:01 UTC (permalink / raw)
  To: linux-acpi; +Cc: Alexander Mezin

On Acer Aspire V5-573G battery notifications are sometimes
triggered too early. For example, when AC is unplugged and
notification is triggered, battery state is still reported as
"Full", and changes to "Discharging" only after short delay,
without any notification.

This patch solves the problem by adding 1 second sleep.
Similar quirk is already implemented in AC driver for other laptop.

Signed-off-by: Alexander Mezin <mezin.alexander@gmail.com>
---
 drivers/acpi/battery.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index f17bc7e..87d26c3 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -32,6 +32,7 @@
 #include <linux/jiffies.h>
 #include <linux/async.h>
 #include <linux/dmi.h>
+#include <linux/delay.h>
 #include <linux/slab.h>
 #include <linux/suspend.h>
 #include <asm/unaligned.h>
@@ -66,6 +67,7 @@ MODULE_DESCRIPTION("ACPI Battery Driver");
 MODULE_LICENSE("GPL");
 
 static int battery_bix_broken_package;
+static int battery_notification_delay_ms;
 static unsigned int cache_time = 1000;
 module_param(cache_time, uint, 0644);
 MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
@@ -1028,6 +1030,14 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event)
 	if (!battery)
 		return;
 	old = battery->bat.dev;
+	/*
+	* On Acer Aspire V5-573G notifications are sometimes triggered too
+	* early. For example, when AC is unplugged and notification is
+	* triggered, battery state is still reported as "Full", and changes to
+	* "Discharging" only after short delay, without any notification.
+	*/
+	if (battery_notification_delay_ms > 0)
+		msleep(battery_notification_delay_ms);
 	if (event == ACPI_BATTERY_NOTIFY_INFO)
 		acpi_battery_refresh(battery);
 	acpi_battery_update(battery);
@@ -1064,6 +1074,12 @@ static int battery_bix_broken_package_quirk(const struct dmi_system_id *d)
 	return 0;
 }
 
+static int battery_notification_delay_quirk(const struct dmi_system_id *d)
+{
+	battery_notification_delay_ms = 1000;
+	return 0;
+}
+
 static struct dmi_system_id bat_dmi_table[] = {
 	{
 		.callback = battery_bix_broken_package_quirk,
@@ -1073,6 +1089,14 @@ static struct dmi_system_id bat_dmi_table[] = {
 			DMI_MATCH(DMI_PRODUCT_NAME, "PC-LZ750LS"),
 		},
 	},
+	{
+		.callback = battery_notification_delay_quirk,
+		.ident = "Acer Aspire V5-573G",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"),
+		},
+	},
 	{},
 };
 
-- 
2.0.0


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

* Re: [PATCH 1/2] ACPI / battery: use callback for setting up quirks
  2014-06-03 19:01 [PATCH 1/2] ACPI / battery: use callback for setting up quirks Alexander Mezin
  2014-06-03 19:01 ` [PATCH 2/2] ACPI / battery: add quirk for Acer Aspire V5-573G Alexander Mezin
@ 2014-06-10  2:13 ` Lan Tianyu
  2014-06-19  0:08 ` Rafael J. Wysocki
  2 siblings, 0 replies; 6+ messages in thread
From: Lan Tianyu @ 2014-06-10  2:13 UTC (permalink / raw)
  To: Alexander Mezin; +Cc: linux-acpi

2014-06-04 3:01 GMT+08:00 Alexander Mezin <mezin.alexander@gmail.com>:
> Use callback for setting up quirk instead of checking return code
> of dmi_check_system(). This change will allow using bat_dmi_table
> for other quirks.
>

Acked-by: Lan Tianyu <tianyu.lan@intel.com>

> Signed-off-by: Alexander Mezin <mezin.alexander@gmail.com>
> ---
>  drivers/acpi/battery.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index 6e7b2a1..f17bc7e 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -1058,8 +1058,15 @@ static int battery_notify(struct notifier_block *nb,
>         return 0;
>  }
>
> +static int battery_bix_broken_package_quirk(const struct dmi_system_id *d)
> +{
> +       battery_bix_broken_package = 1;
> +       return 0;
> +}
> +
>  static struct dmi_system_id bat_dmi_table[] = {
>         {
> +               .callback = battery_bix_broken_package_quirk,
>                 .ident = "NEC LZ750/LS",
>                 .matches = {
>                         DMI_MATCH(DMI_SYS_VENDOR, "NEC"),
> @@ -1176,8 +1183,7 @@ static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie)
>         if (acpi_disabled)
>                 return;
>
> -       if (dmi_check_system(bat_dmi_table))
> -               battery_bix_broken_package = 1;
> +       dmi_check_system(bat_dmi_table);
>
>  #ifdef CONFIG_ACPI_PROCFS_POWER
>         acpi_battery_dir = acpi_lock_battery_dir();
> --
> 2.0.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Best regards
Tianyu Lan

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

* Re: [PATCH 2/2] ACPI / battery: add quirk for Acer Aspire V5-573G
  2014-06-03 19:01 ` [PATCH 2/2] ACPI / battery: add quirk for Acer Aspire V5-573G Alexander Mezin
@ 2014-06-10  2:15   ` Lan Tianyu
       [not found]     ` <CADnvcf+L+OAv=2i7Zj1Sc0sEFmWJVy_g8jSs1ZPLhALO4XDmCw@mail.gmail.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Lan Tianyu @ 2014-06-10  2:15 UTC (permalink / raw)
  To: Alexander Mezin; +Cc: linux-acpi

2014-06-04 3:01 GMT+08:00 Alexander Mezin <mezin.alexander@gmail.com>:
> On Acer Aspire V5-573G battery notifications are sometimes
> triggered too early. For example, when AC is unplugged and
> notification is triggered, battery state is still reported as
> "Full", and changes to "Discharging" only after short delay,
> without any notification.
>
> This patch solves the problem by adding 1 second sleep.
> Similar quirk is already implemented in AC driver for other laptop.

Could you provide the output of acpidump?

>
> Signed-off-by: Alexander Mezin <mezin.alexander@gmail.com>
> ---
>  drivers/acpi/battery.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index f17bc7e..87d26c3 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -32,6 +32,7 @@
>  #include <linux/jiffies.h>
>  #include <linux/async.h>
>  #include <linux/dmi.h>
> +#include <linux/delay.h>
>  #include <linux/slab.h>
>  #include <linux/suspend.h>
>  #include <asm/unaligned.h>
> @@ -66,6 +67,7 @@ MODULE_DESCRIPTION("ACPI Battery Driver");
>  MODULE_LICENSE("GPL");
>
>  static int battery_bix_broken_package;
> +static int battery_notification_delay_ms;
>  static unsigned int cache_time = 1000;
>  module_param(cache_time, uint, 0644);
>  MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
> @@ -1028,6 +1030,14 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event)
>         if (!battery)
>                 return;
>         old = battery->bat.dev;
> +       /*
> +       * On Acer Aspire V5-573G notifications are sometimes triggered too
> +       * early. For example, when AC is unplugged and notification is
> +       * triggered, battery state is still reported as "Full", and changes to
> +       * "Discharging" only after short delay, without any notification.
> +       */
> +       if (battery_notification_delay_ms > 0)
> +               msleep(battery_notification_delay_ms);
>         if (event == ACPI_BATTERY_NOTIFY_INFO)
>                 acpi_battery_refresh(battery);
>         acpi_battery_update(battery);
> @@ -1064,6 +1074,12 @@ static int battery_bix_broken_package_quirk(const struct dmi_system_id *d)
>         return 0;
>  }
>
> +static int battery_notification_delay_quirk(const struct dmi_system_id *d)
> +{
> +       battery_notification_delay_ms = 1000;
> +       return 0;
> +}
> +
>  static struct dmi_system_id bat_dmi_table[] = {
>         {
>                 .callback = battery_bix_broken_package_quirk,
> @@ -1073,6 +1089,14 @@ static struct dmi_system_id bat_dmi_table[] = {
>                         DMI_MATCH(DMI_PRODUCT_NAME, "PC-LZ750LS"),
>                 },
>         },
> +       {
> +               .callback = battery_notification_delay_quirk,
> +               .ident = "Acer Aspire V5-573G",
> +               .matches = {
> +                       DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
> +                       DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"),
> +               },
> +       },
>         {},
>  };
>
> --
> 2.0.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Best regards
Tianyu Lan

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

* Re: [PATCH 2/2] ACPI / battery: add quirk for Acer Aspire V5-573G
       [not found]     ` <CADnvcf+L+OAv=2i7Zj1Sc0sEFmWJVy_g8jSs1ZPLhALO4XDmCw@mail.gmail.com>
@ 2014-06-13  8:46       ` Lan Tianyu
  0 siblings, 0 replies; 6+ messages in thread
From: Lan Tianyu @ 2014-06-13  8:46 UTC (permalink / raw)
  To: Alexander Mezin; +Cc: linux-acpi

2014-06-10 22:38 GMT+08:00 Alexander Mezin <mezin.alexander@gmail.com>:
> 2014-06-10 9:15 GMT+07:00 Lan Tianyu <lantianyu1986@gmail.com>:
>> 2014-06-04 3:01 GMT+08:00 Alexander Mezin <mezin.alexander@gmail.com>:
>>> On Acer Aspire V5-573G battery notifications are sometimes
>>> triggered too early. For example, when AC is unplugged and
>>> notification is triggered, battery state is still reported as
>>> "Full", and changes to "Discharging" only after short delay,
>>> without any notification.
>>>
>>> This patch solves the problem by adding 1 second sleep.
>>> Similar quirk is already implemented in AC driver for other laptop.
>>

>From the ACPI table, battery status is read from EC and the notification is
also triggered from EC Query event. The status should be updated at that
point but ... Have no better idea.

Acked-by: Lan Tianyu <tianyu.lan@intel.com>

>> Could you provide the output of acpidump?
> Attached
>>
>>>
>>> Signed-off-by: Alexander Mezin <mezin.alexander@gmail.com>
>>> ---
>>>  drivers/acpi/battery.c | 24 ++++++++++++++++++++++++
>>>  1 file changed, 24 insertions(+)
>>>
>>> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
>>> index f17bc7e..87d26c3 100644
>>> --- a/drivers/acpi/battery.c
>>> +++ b/drivers/acpi/battery.c
>>> @@ -32,6 +32,7 @@
>>>  #include <linux/jiffies.h>
>>>  #include <linux/async.h>
>>>  #include <linux/dmi.h>
>>> +#include <linux/delay.h>
>>>  #include <linux/slab.h>
>>>  #include <linux/suspend.h>
>>>  #include <asm/unaligned.h>
>>> @@ -66,6 +67,7 @@ MODULE_DESCRIPTION("ACPI Battery Driver");
>>>  MODULE_LICENSE("GPL");
>>>
>>>  static int battery_bix_broken_package;
>>> +static int battery_notification_delay_ms;
>>>  static unsigned int cache_time = 1000;
>>>  module_param(cache_time, uint, 0644);
>>>  MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
>>> @@ -1028,6 +1030,14 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event)
>>>         if (!battery)
>>>                 return;
>>>         old = battery->bat.dev;
>>> +       /*
>>> +       * On Acer Aspire V5-573G notifications are sometimes triggered too
>>> +       * early. For example, when AC is unplugged and notification is
>>> +       * triggered, battery state is still reported as "Full", and changes to
>>> +       * "Discharging" only after short delay, without any notification.
>>> +       */
>>> +       if (battery_notification_delay_ms > 0)
>>> +               msleep(battery_notification_delay_ms);
>>>         if (event == ACPI_BATTERY_NOTIFY_INFO)
>>>                 acpi_battery_refresh(battery);
>>>         acpi_battery_update(battery);
>>> @@ -1064,6 +1074,12 @@ static int battery_bix_broken_package_quirk(const struct dmi_system_id *d)
>>>         return 0;
>>>  }
>>>
>>> +static int battery_notification_delay_quirk(const struct dmi_system_id *d)
>>> +{
>>> +       battery_notification_delay_ms = 1000;
>>> +       return 0;
>>> +}
>>> +
>>>  static struct dmi_system_id bat_dmi_table[] = {
>>>         {
>>>                 .callback = battery_bix_broken_package_quirk,
>>> @@ -1073,6 +1089,14 @@ static struct dmi_system_id bat_dmi_table[] = {
>>>                         DMI_MATCH(DMI_PRODUCT_NAME, "PC-LZ750LS"),
>>>                 },
>>>         },
>>> +       {
>>> +               .callback = battery_notification_delay_quirk,
>>> +               .ident = "Acer Aspire V5-573G",
>>> +               .matches = {
>>> +                       DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
>>> +                       DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"),
>>> +               },
>>> +       },
>>>         {},
>>>  };
>>>
>>> --
>>> 2.0.0
>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>>
>>
>> --
>> Best regards
>> Tianyu Lan



-- 
Best regards
Tianyu Lan

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

* Re: [PATCH 1/2] ACPI / battery: use callback for setting up quirks
  2014-06-03 19:01 [PATCH 1/2] ACPI / battery: use callback for setting up quirks Alexander Mezin
  2014-06-03 19:01 ` [PATCH 2/2] ACPI / battery: add quirk for Acer Aspire V5-573G Alexander Mezin
  2014-06-10  2:13 ` [PATCH 1/2] ACPI / battery: use callback for setting up quirks Lan Tianyu
@ 2014-06-19  0:08 ` Rafael J. Wysocki
  2 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2014-06-19  0:08 UTC (permalink / raw)
  To: Alexander Mezin; +Cc: linux-acpi, Lan Tianyu

On Wednesday, June 04, 2014 02:01:22 AM Alexander Mezin wrote:
> Use callback for setting up quirk instead of checking return code
> of dmi_check_system(). This change will allow using bat_dmi_table
> for other quirks.
> 
> Signed-off-by: Alexander Mezin <mezin.alexander@gmail.com>

Both [1-2/2] applied, thanks!

> ---
>  drivers/acpi/battery.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index 6e7b2a1..f17bc7e 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -1058,8 +1058,15 @@ static int battery_notify(struct notifier_block *nb,
>  	return 0;
>  }
>  
> +static int battery_bix_broken_package_quirk(const struct dmi_system_id *d)
> +{
> +	battery_bix_broken_package = 1;
> +	return 0;
> +}
> +
>  static struct dmi_system_id bat_dmi_table[] = {
>  	{
> +		.callback = battery_bix_broken_package_quirk,
>  		.ident = "NEC LZ750/LS",
>  		.matches = {
>  			DMI_MATCH(DMI_SYS_VENDOR, "NEC"),
> @@ -1176,8 +1183,7 @@ static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie)
>  	if (acpi_disabled)
>  		return;
>  
> -	if (dmi_check_system(bat_dmi_table))
> -		battery_bix_broken_package = 1;
> +	dmi_check_system(bat_dmi_table);
>  	
>  #ifdef CONFIG_ACPI_PROCFS_POWER
>  	acpi_battery_dir = acpi_lock_battery_dir();
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

end of thread, other threads:[~2014-06-18 23:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-03 19:01 [PATCH 1/2] ACPI / battery: use callback for setting up quirks Alexander Mezin
2014-06-03 19:01 ` [PATCH 2/2] ACPI / battery: add quirk for Acer Aspire V5-573G Alexander Mezin
2014-06-10  2:15   ` Lan Tianyu
     [not found]     ` <CADnvcf+L+OAv=2i7Zj1Sc0sEFmWJVy_g8jSs1ZPLhALO4XDmCw@mail.gmail.com>
2014-06-13  8:46       ` Lan Tianyu
2014-06-10  2:13 ` [PATCH 1/2] ACPI / battery: use callback for setting up quirks Lan Tianyu
2014-06-19  0:08 ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.