From patchwork Sat Apr 15 18:23:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 673554 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D42CC77B73 for ; Sat, 15 Apr 2023 18:24:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229760AbjDOSYa (ORCPT ); Sat, 15 Apr 2023 14:24:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbjDOSY3 (ORCPT ); Sat, 15 Apr 2023 14:24:29 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F62F1FF7 for ; Sat, 15 Apr 2023 11:23:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681583025; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=2paejZ9FTiHh9qCuyzM6Jd7BdB0qMiCfyvw18AeYSno=; b=JNrN49HMcyXZurSAsYRyTZFXdDiMWslGwon0FrWZNsHC69EJsJuZh4wS+8I3gRoIQE1soa qr7EbeVc1qfiqlHeubAp0ezcu0tANOqlzA3BvN/Hkaw+hvUrDGZlqz0WoHB71JUFk+ezfn V5IYsfOMxSExws8IFP/PQdrj94+3KdQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-427-LZ6PJlhrMjOBorehlaWXkQ-1; Sat, 15 Apr 2023 14:23:43 -0400 X-MC-Unique: LZ6PJlhrMjOBorehlaWXkQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D8505800B35; Sat, 15 Apr 2023 18:23:42 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.192.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB7A3BC88; Sat, 15 Apr 2023 18:23:41 +0000 (UTC) From: Hans de Goede To: Sebastian Reichel , =?utf-8?q?Pali_Roh=C3=A1r?= Cc: Hans de Goede , Marek Vasut , laji Xiao <3252204392abc@gmail.com>, linux-pm@vger.kernel.org Subject: [PATCH v2 00/10] power: supply: bq27xxx/bq25890 status update fixes Date: Sat, 15 Apr 2023 20:23:31 +0200 Message-Id: <20230415182341.86916-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Hi all, Here is v2 if my bq* status update fixes series Changes in v2: - Do not use bq->charger in bq25890_external_power_changed(), because it may not be set yet (avoid NULL ptr deref on race) - Add "power: supply: bq24190: Call power_supply_changed() after updating input current" to the series The main goal of this series is to fix userspace sometimes not getting notified in a timely manner of charging <-> discharging status changes, causing e.g. battery status icons to lag and the lagging of updates also effects power_supply_leds.c . While working on this I noticed a number of races surrounding bq27xxx_battery_update(), so patches 1-4 fix those first. Patches 5-10 take care of the status update lagging issues. Regards, Hans Hans de Goede (10): power: supply: bq27xxx: Fix bq27xxx_battery_update() race condition power: supply: bq27xxx: Fix I2C IRQ race on remove power: supply: bq27xxx: Fix poll_interval handling and races on remove power: supply: bq27xxx: Add cache parameter to bq27xxx_battery_current_and_status() power: supply: bq27xxx: Move bq27xxx_battery_update() down power: supply: bq27xxx: Ensure power_supply_changed() is called on current sign changes power: supply: bq27xxx: After charger plug in/out wait 0.5s for things to stabilize power: supply: bq27xxx: Use mod_delayed_work() instead of cancel() + schedule() power: supply: bq25890: Call power_supply_changed() after updating input current or voltage power: supply: bq24190: Call power_supply_changed() after updating input current drivers/power/supply/bq24190_charger.c | 1 + drivers/power/supply/bq25890_charger.c | 3 + drivers/power/supply/bq27xxx_battery.c | 181 +++++++++++---------- drivers/power/supply/bq27xxx_battery_i2c.c | 3 +- include/linux/power/bq27xxx_battery.h | 4 + 5 files changed, 108 insertions(+), 84 deletions(-)