lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230601-rk817_query_at_resume-v1-1-630b0adefbd9@mweigand.net>
Date:   Wed, 14 Jun 2023 20:10:43 +0200
From:   Maximilian Weigand <mweigand2017@...il.com>
To:     Sebastian Reichel <sre@...nel.org>
Cc:     linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-rockchip@...ts.infradead.org,
        Maximilian Weigand <mweigand@...igand.net>
Subject: [PATCH] power: supply: rk817: query battery properties right after
 resume

From: Maximilian Weigand <mweigand@...igand.net>

The driver reads battery properties every 8 seconds. In order to prevent
problems with wrong property values right after resume, trigger an
update of those properties on resuming the system and restart the
8-second interval from there.

Signed-off-by: Maximilian Weigand <mweigand@...igand.net>
---
An issue with wrongly reported battery charge was encountered on a
Pine64 PineNote right after resume. It turned out the the rk817 driver
queries the rk817 chip in fixed 8-second intervals, and thus in most
cases the reported battery charge right after resume will be wrong until
the driver gets to its next update cycle. For example, upowerd will
query the battery properties right after resume (getting the old
values), while the correct values will only be reported by upowerd after
its next update cycle, which can take 30+ seconds.

Therefore, trigger an update of battery properties right after resume in
the driver.
---
 drivers/power/supply/rk817_charger.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_charger.c
index 1a2143641e66..29ceee2f1905 100644
--- a/drivers/power/supply/rk817_charger.c
+++ b/drivers/power/supply/rk817_charger.c
@@ -1198,11 +1198,24 @@ static int rk817_charger_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static int __maybe_unused rk817_resume(struct device *dev)
+{
+
+	struct rk817_charger *charger = dev_get_drvdata(dev);
+
+	/* force an immediate update */
+	mod_delayed_work(system_wq, &charger->work, 0);
+
+	return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(rk817_charger_pm, NULL, rk817_resume);
 
 static struct platform_driver rk817_charger_driver = {
 	.probe    = rk817_charger_probe,
 	.driver   = {
 		.name  = "rk817-charger",
+		.pm		= &rk817_charger_pm,
 	},
 };
 module_platform_driver(rk817_charger_driver);

---
base-commit: 858fd168a95c5b9669aac8db6c14a9aeab446375
change-id: 20230601-rk817_query_at_resume-143dca87eb4a

Best regards,
-- 
Maximilian Weigand <mweigand@...igand.net>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ