linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: Pavel Machek <pavel@ucw.cz>
Cc: Sebastian Reichel <sre@kernel.org>,
	linux-pm@vger.kernel.org, linux-omap@vger.kernel.org,
	Merlijn Wajer <merlijn@wizzup.org>
Subject: Re: [PATCH 1/2] power: supply: cpcap-battery: Check voltage before orderly_poweroff
Date: Tue, 15 Oct 2019 10:26:27 -0700	[thread overview]
Message-ID: <20191015172627.GA5610@atomide.com> (raw)
In-Reply-To: <20191013112810.GB5653@amd>

* Pavel Machek <pavel@ucw.cz> [191013 11:28]:
> On Wed 2019-10-09 13:52:51, Tony Lindgren wrote:
> > We can get the low voltage interrupt trigger sometimes way too early,
> > maybe because of CPU load spikes. This causes orderly_poweroff() be
> > called too easily.
> > 
> > Let's check the voltage before orderly_poweroff in case it was not
> > yet a permanent condition. We will be getting more interrupts anyways
> > if the condition persists.
> > 
> > Let's also show the measured voltages for low battery and battery
> > empty warnings since we have them.
> 
> > +++ b/drivers/power/supply/cpcap-battery.c
> > @@ -562,12 +562,15 @@ static irqreturn_t cpcap_battery_irq_thread(int irq, void *data)
> >  	switch (d->action) {
> >  	case CPCAP_BATTERY_IRQ_ACTION_BATTERY_LOW:
> >  		if (latest->current_ua >= 0)
> > -			dev_warn(ddata->dev, "Battery low at 3.3V!\n");
> > +			dev_warn(ddata->dev, "Battery low at %imV!\n",
> > +				latest->voltage / 1000);
> >  		break;
> >  	case CPCAP_BATTERY_IRQ_ACTION_POWEROFF:
> > -		if (latest->current_ua >= 0) {
> > +		if (latest->current_ua >= 0 && latest->voltage >= 0 &&
> > +		    latest->voltage <= 3100000) {
> >  			dev_emerg(ddata->dev,
> > -				  "Battery empty at 3.1V, powering off\n");
> > +				  "Battery empty at %imV, powering off\n",
> > +				  latest->voltage / 1000);
> >  			orderly_poweroff(true);
> >  		}
> 
> Hmm.
> 
> So if latest->voltage is < 0, I'd preffer to shut down the machine,
> too.

Hmm I need to recheck if that is needed or not when booting without
a battery on a power supply.

> Actually, if we got POWEROFF irq, and voltage is close to 3.1V (like
> maybe < 3.2V), maybe it would be good to shutdown anyway?

No, this is some spurious interrupt issue that I've seen triggering
at way higher voltages than it should be happening at.

Regards,

Tony


  reply	other threads:[~2019-10-15 17:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-09 20:52 [PATCHv2 0/2] cpcap charger and battery fixes Tony Lindgren
2019-10-09 20:52 ` [PATCH 1/2] power: supply: cpcap-battery: Check voltage before orderly_poweroff Tony Lindgren
2019-10-13 11:28   ` Pavel Machek
2019-10-15 17:26     ` Tony Lindgren [this message]
2019-10-09 20:52 ` [PATCH 2/2] power: supply: cpcap-charger: Improve battery detection Tony Lindgren
2019-10-16 22:30 [PATCHv2 0/2] cpcap charger and battery fixes Tony Lindgren
2019-10-16 22:30 ` [PATCH 1/2] power: supply: cpcap-battery: Check voltage before orderly_poweroff Tony Lindgren

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=20191015172627.GA5610@atomide.com \
    --to=tony@atomide.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=merlijn@wizzup.org \
    --cc=pavel@ucw.cz \
    --cc=sre@kernel.org \
    /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 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).