Received: by 10.213.65.68 with SMTP id h4csp3973684imn; Tue, 10 Apr 2018 07:25:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx49WEEimAaPaTArR061hpEEK+MiFmZhxF+PkuGIqOhvPzp40uTxYDUTKfHiMjBO3FY87NeuJ X-Received: by 10.99.45.2 with SMTP id t2mr476134pgt.356.1523370308673; Tue, 10 Apr 2018 07:25:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523370308; cv=none; d=google.com; s=arc-20160816; b=zTjBP+YIuIOX3J58JJntevDfbA0SfRLpNfmIbHk6J+bZZeWnfZhOGTnSAZBUV5Zl9B ZdiiPuueDruZzlOuFKPz0s8lSxafn+8geogYfFuuV/SlnFkarNaS0Z2D59prGJO+BmaA AvSGF7bFeBKLcfngHm4fArr9IEoUPvY7GpPXSd4ldeVJPWupV/5S2k16mzDDOnCr8/7l v4V2YwCiJWJ2V+dBO/vpv4rvu5vmXbFF88WbS197TluZzcDyjSjTPlPg6gfqGIWoyyje uyrvoL7axvsIbZvZY6FyA4VdeRU5ej/NicACbZNLAi6o5phzK/brYi4zXLydBKZUPFNM fVYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:from:cc:to:subject :content-transfer-encoding:mime-version:references:in-reply-to :user-agent:date:dkim-signature:arc-authentication-results; bh=jTDn2Zco/ceJa/h1bp6KegsM10i+Jv1+zeMMj/Ojmb4=; b=y5Mb7NOwHM7kTE+VxZziX4Px7jB/5EOH51yP1CAe+XTZLrcOlkrQfxK1K/Dl84Zkb0 UH+/ENs7HrhHiY9D9cIWjI97KIEeGJgMhKnyqJGlAvaul3EPyB5/NKfjwxzWhaPDfmtH vBuVtKvX7NFZbHvBvALnCH6/H+v+ipk+KEKJiBegYkL7RgY2XZaOsjkeYbwgHPyYwL99 NcXGkTw9k01URSAO3pVuFFEUI/um0xc6wQNB3GNOlud3HfAge3TcXOMUBpZKg5xzVlE5 WwZ3RmphwM4p1yYfPuQ+3deplOeeIF1Fc5xIh+iKuSklOkh9GhE2L0Gbz8dgWSsegS2T JLcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Qf4ImeZL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j11si1869833pgv.713.2018.04.10.07.24.30; Tue, 10 Apr 2018 07:25:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Qf4ImeZL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753658AbeDJORY (ORCPT + 99 others); Tue, 10 Apr 2018 10:17:24 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:52120 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753206AbeDJORX (ORCPT ); Tue, 10 Apr 2018 10:17:23 -0400 Received: by mail-wm0-f67.google.com with SMTP id u189so26451403wmd.1; Tue, 10 Apr 2018 07:17:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:to:cc:from:message-id; bh=jTDn2Zco/ceJa/h1bp6KegsM10i+Jv1+zeMMj/Ojmb4=; b=Qf4ImeZLk0btnI9RJ/FU0oL2Tpco7bWz3QN8t+9Gv0F3vhcdyjLS6HoP8JAZZPZAn0 Aet2YzBi6h/HqhRzBQNEAy0Kh/+MsC46p9aUJP2KkSpk8Mgey15J//q5uN6UqaEayn4Q GdJ9N0MaxoSxK+d2J0rJbojUH8MvyGFUBxFXkhWS4rtFUlFbhU4d2dpd2PdoWMbV0rRp zCgJ+EOtG9L+SnrPh2I0IttSgdXjKb6M81CxmnhN59IXJp+YoByOe731FBKLLtfq1Ihk 722TjwL5YYiuXORLJesaWOxqfq7azzBxlGwmVJ2S6GvhpL/8dKdbD5pEm//bfQP1d/vT Agxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:to:cc:from :message-id; bh=jTDn2Zco/ceJa/h1bp6KegsM10i+Jv1+zeMMj/Ojmb4=; b=j71Qbaim1pwJMIC9a4Abs+kSiGmJt2Zw5weEtrb8H/M13d/k71v6jdZKV8fpWJoT6l 4B1rQ2aGsFFJQOUBDCb3fZ+9KseAH06qzKDZ8QcN63cOYlKHe5WeOzZCjD9umdFiH3rQ 6th4UIUu/a+WnS6LFHMM1o71aLY3qkbP+55n0i8drcYbVJ/HNBk5PAnokoazii18fyST bAyqzjS6RuRN5nPopvSmvMTLC/voRek2gRYpX/a5ztE28aLe5LjUN9BuLRDR3XgMk2ej p8jsMo0RScH3T1iF/g9/sb4foJoy02mN8d4YpprMxkuIccDnbkWeRfr/4DD1qbGhoMpB Utuw== X-Gm-Message-State: ALQs6tCHIvGmdoqurW+Lrq/6xqqpIos1opgVsnfmh+6Kyfm6Y/zbBTDh 3FXJx91gsKTLU3ttWffJ4d4CnQ== X-Received: by 10.28.237.11 with SMTP id l11mr1834432wmh.124.1523369841499; Tue, 10 Apr 2018 07:17:21 -0700 (PDT) Received: from [192.168.0.164] ([79.143.165.16]) by smtp.gmail.com with ESMTPSA id 71sm2388015wmg.11.2018.04.10.07.17.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Apr 2018 07:17:20 -0700 (PDT) Date: Tue, 10 Apr 2018 16:17:13 +0200 User-Agent: K-9 Mail for Android In-Reply-To: <20180410105841.ne26heazhwwqjx7v@earth.universe> References: <20180410090643.GA26554@thinkpad> <20180410105841.ne26heazhwwqjx7v@earth.universe> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH v1] battery: Add the ThinkPad battery status quirk To: Sebastian Reichel CC: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org From: Ognjen Galic Message-ID: <3A23A2DC-121E-4DA6-863D-EFEAF420A5FB@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On April 10, 2018 12:58:41 PM GMT+02:00, Sebastian Reichel wrote: >Hi, > >On Tue, Apr 10, 2018 at 11:06:43AM +0200, Ognjen Galic wrote: >> The EC/ACPI firmware on Lenovo ThinkPads used to report a status >> of "Unknown" when the battery is between the charge start and charge >> stop thresholds=2E On Windows, it reports "Not Charging" so the quirk >> has been added to fix the "Unknown" state=2E >>=20 >> The chosen new state when the battery is not charging is "Fully >Charged" >> because a status of "Not Charging" breaks almost all applications in >> userspace that depend on upower, because upower in itself can't >handle >> a state of "Not Charging", defaulting to "Unknown"=2E >>=20 >> When we report "Fully Charged" instead of "Unknown", the userspace >handles >> everything just fine, displaying for example: "Fully Charged, 59%" in >Xfce=2E > >This probably breaks dual-battery Thinkpads, that charges batteries >alternating (so one of them is "not charging" without being "fully >charged")=2E The correct fix is to teach upower the "not charging" >state=2E It exists since the existance of the power supply kernel API, >so missing support is a bug in UPower=2E I did write a patch for upower, submitted it and tested it=2E The problem = is the bug report has been open for a month now and nothing major is happen= ing=2E And the userspace is still broken=2E > >-- Sebastian > >> This is a re-write of: https://patchwork=2Ekernel=2Eorg/patch/10205359/ >>=20 >> Signed-off-by: Ognjen Galic >> --- >> drivers/acpi/battery=2Ec | 19 ++++++++++++++++++- >> 1 file changed, 18 insertions(+), 1 deletion(-) >>=20 >> diff --git a/drivers/acpi/battery=2Ec b/drivers/acpi/battery=2Ec >> index bdb24d63=2E=2Ecb4457a7 100644 >> --- a/drivers/acpi/battery=2Ec >> +++ b/drivers/acpi/battery=2Ec >> @@ -74,6 +74,7 @@ static async_cookie_t async_cookie; >> static bool battery_driver_registered; >> static int battery_bix_broken_package; >> static int battery_notification_delay_ms; >> +static int battery_quirk_thinkpad_full; >> static unsigned int cache_time =3D 1000; >> module_param(cache_time, uint, 0644); >> MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); >> @@ -233,7 +234,8 @@ static int acpi_battery_get_property(struct >power_supply *psy, >> val->intval =3D POWER_SUPPLY_STATUS_DISCHARGING; >> else if (battery->state & ACPI_BATTERY_STATE_CHARGING) >> val->intval =3D POWER_SUPPLY_STATUS_CHARGING; >> - else if (acpi_battery_is_charged(battery)) >> + else if (acpi_battery_is_charged(battery) || >> + battery_quirk_thinkpad_full) >> val->intval =3D POWER_SUPPLY_STATUS_FULL; >> else >> val->intval =3D POWER_SUPPLY_STATUS_UNKNOWN; >> @@ -1332,6 +1334,13 @@ battery_notification_delay_quirk(const struct >dmi_system_id *d) >> return 0; >> } >> =20 >> +static int __init >> +battery_thinkpad_full_charged_quirk(const struct dmi_system_id *d) >> +{ >> + battery_quirk_thinkpad_full =3D 1; >> + return 0; >> +} >> + >> static const struct dmi_system_id bat_dmi_table[] __initconst =3D { >> { >> =2Ecallback =3D battery_bix_broken_package_quirk, >> @@ -1349,6 +1358,14 @@ static const struct dmi_system_id >bat_dmi_table[] __initconst =3D { >> DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"), >> }, >> }, >> + { >> + =2Ecallback =3D battery_thinkpad_full_charged_quirk, >> + =2Eident =3D "Lenovo ThinkPad", >> + =2Ematches =3D { >> + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), >> + DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad"), >> + }, >> + }, >> {}, >> }; >> =20 >> --=20 >> 2=2E15=2E1 >>=20 --=20 Sent from my Android device with K-9 Mail=2E Please excuse my brevity=2E