All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Whitcroft <apw@canonical.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: Adrian Fita <adrian.fita@gmail.com>,
	"Rafael J. Wysocki" <rjw@sisk.pl>, Len Brown <lenb@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Matthew Garrett <mjg59@srcf.ucam.org>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	Linux-pm mailing list <linux-pm@lists.linux-foundation.org>,
	Ralf Jung <ralfjung-e@gmx.de>, Paolo Scarabelli <paolo@msw.it>
Subject: Re: [bug?] Battery notifications produce flashing battery icon, syslog spam (Re: [PATCH 11/11] ACPI / Battery: Update information on info notification and resume)
Date: Thu, 3 May 2012 09:54:58 +0100	[thread overview]
Message-ID: <20120503085458.GG3364@shadowen.org> (raw)
In-Reply-To: <20120501191408.GD19143@burratino>

On Tue, May 01, 2012 at 02:14:08PM -0500, Jonathan Nieder wrote:
> (cc-ing Andy)
> Adrian Fita wrote:
> 
> > Also, searching on Google after "upowerd device
> > removed:/org/freedesktop/UPower/devices/battery_BAT0", reveals much
> > more bug reports with the exact issue.
> 
> Thanks.  That confirms the high CPU consumption in upowerd ---
> see [1], for example.
> 
> [1] https://bugs.launchpad.net/ubuntu/+source/linux/+bug/987807

It does seem somewhat heavyweight to be removing and reinstalling all of
the sysfs files every time we get one of these events.  I am assuming
here that some BIOSs are using this interface to tell us the batery
capacity has changed and triggering the constant add/remove of the
devices and associated flickering.

>From the description of the change this is necessary because the
capacity units may change over time?  Can we not use those to avoid this
update?  I presume it is these two we are referring to?

        int capacity_granularity_1;
        int capacity_granularity_2;

If those are unchanged perhaps we can just skip the update?  Something
like the below (completly untested, for discussion).

Thoughts?

-apw

commit d558d0c38e26e2c7eae68d19f4d2fa3ecd8e31f2
Author: Andy Whitcroft <apw@canonical.com>
Date:   Thu May 3 09:52:28 2012 +0100

    battery: only refresh the sysfs files when pertinant information changes
    
    We only need to regenerate the sysfs files when the capacity units
    change, avoid the update otherwise.
    
    Signed-off-by: Andy Whitcroft <apw@canonical.com>

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index eb18c44..f8d37b4 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -643,10 +643,20 @@ static int acpi_battery_update(struct acpi_battery *battery)
 
 static void acpi_battery_refresh(struct acpi_battery *battery)
 {
+	int cg1, cg2;
+
 	if (!battery->bat.dev)
 		return;
 
+	cg1 = battery->capacity_granularity_1;
+	cg2 = battery->capacity_granularity_2;
+
 	acpi_battery_get_info(battery);
+
+	if (cg1 == battery->capacity_granularity_1 &&
+					cg2 == capacity_granularity_2)
+		return;
+
 	/* The battery may have changed its reporting units. */
 	sysfs_remove_battery(battery);
 	sysfs_add_battery(battery);

  parent reply	other threads:[~2012-05-03  8:55 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-06 22:31 [PATCH 0/11] Various ACPI patches for 2.6.38 Rafael J. Wysocki
2011-01-06 22:32 ` [PATCH 1/11] ACPI / ACPICA: Fix global lock acquisition Rafael J. Wysocki
2011-01-06 22:32 ` Rafael J. Wysocki
2011-01-06 22:33 ` [PATCH 2/11] ACPI / PM: Do not enable multiple devices to wake up simultaneously Rafael J. Wysocki
2011-01-06 22:33 ` Rafael J. Wysocki
2011-01-06 22:34 ` [PATCH 3/11] ACPI / PM: Use device wakeup flags for handling ACPI wakeup devices Rafael J. Wysocki
2011-01-06 22:34 ` Rafael J. Wysocki
2011-01-06 22:35 ` [PATCH 4/11] ACPI / PM: Drop special ACPI wakeup flags Rafael J. Wysocki
2011-01-06 22:35 ` Rafael J. Wysocki
2011-01-06 22:36 ` [PATCH 5/11] ACPI / PM: Report wakeup events from buttons Rafael J. Wysocki
2011-01-06 22:36 ` Rafael J. Wysocki
2011-01-06 22:37 ` [PATCH 6/11] ACPI / PM: Blacklist Averatec machine known to require acpi_sleep=nonvs Rafael J. Wysocki
2011-01-06 22:37 ` Rafael J. Wysocki
2011-01-06 22:38 ` [PATCH 7/11] ACPI / PM: Rename acpi_power_off_device() Rafael J. Wysocki
2011-01-06 22:38 ` Rafael J. Wysocki
2011-01-06 22:38 ` [PATCH 8/11] ACPI / PM: Check status of power resources under mutexes Rafael J. Wysocki
2011-01-06 22:38 ` Rafael J. Wysocki
2011-01-06 22:40 ` [PATCH 9/11] ACPI: Always check if _PRW is present before trying to evaluate it Rafael J. Wysocki
2011-01-06 22:40 ` Rafael J. Wysocki
2011-01-06 22:41 ` [PATCH 10/11] ACPI: Drop device flag wake_capable Rafael J. Wysocki
2011-01-06 22:41 ` Rafael J. Wysocki
2011-01-06 23:52   ` [linux-pm] " David Brownell
2011-01-06 23:52     ` David Brownell
2011-01-07  0:22     ` Rafael J. Wysocki
2011-01-07  0:22     ` Rafael J. Wysocki
2011-01-06 23:52   ` David Brownell
2011-01-06 22:42 ` [PATCH 11/11] ACPI / Battery: Update information on info notification and resume Rafael J. Wysocki
2012-05-01 18:47   ` [bug?] Battery notifications produce flashing battery icon, syslog spam (Re: [PATCH 11/11] ACPI / Battery: Update information on info notification and resume) Jonathan Nieder
2012-05-01 19:00     ` Adrian Fita
2012-05-01 19:00       ` Adrian Fita
2012-05-01 19:14       ` Jonathan Nieder
2012-05-01 19:42         ` Ralf Jung
2012-05-02 11:49           ` Paolo Scarabelli
2012-05-03  8:54         ` Andy Whitcroft [this message]
2012-05-03 12:47           ` Matthew Garrett
2012-05-03 13:48             ` [PATCH 1/1] battery: only refresh the sysfs files when pertinant information changes Andy Whitcroft
2012-05-04 13:29               ` Ralf Jung
2012-05-05 10:37                 ` Adrian Fita
2012-05-05 10:37                   ` Adrian Fita
2012-05-08  5:50               ` Len Brown
2011-01-06 22:42 ` [PATCH 11/11] ACPI / Battery: Update information on info notification and resume Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120503085458.GG3364@shadowen.org \
    --to=apw@canonical.com \
    --cc=adrian.fita@gmail.com \
    --cc=jrnieder@gmail.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=paolo@msw.it \
    --cc=ralfjung-e@gmx.de \
    --cc=rjw@sisk.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.