From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794591625; b=vvkm72wUPsmASParqF9HzHO4nWuqkCREg1VrOhEH+SXg0BgPxU63nfQj9VkjGID1Hs7W RPpJHLVUVVwo/gHp1EKSpuwNZDrTQlZ5yoweBorolcwiJxdTmb8sP4aKD69M7fyDG0/eM WRwODgFpO7hagX5nO0i7b39QokPJ7lqnEvPG2k1aP2RuU9vIf3SaIQyDwBC/Fp37m3KCH x/63MztSEmmy5YlYOZDeN9lSOnsmQl2+UWyPxAz8P6YPfZbnHSi34kO4KUaMPgRRhy7/5 mz0dg+G4I3tryZ3KMW+QaUIlYG9zv1d4q4YfCuzKEPwk+vIVypqTRKMEaqU4iYNMoTg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794591625; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=huApMIKZVNQOxuyxT5TSusyIahpxflVBSPm5qzZNV7w=; b=SjKiRISc1A5uzSzpsGdKwZ+nhaXSEe9G9LZSaTzocdbpH/iLGWV+E5BveiA9Uiql1ZOK upQitd7MLzsToJ1Vqjlc64p55Encb7kSH9IhmqbOrTnqTe8eLBvOqLIGxchVgNhI8G2BE bUKtDo5zpO0LcWnmnj9zXrcdtEc67aU9HH7lKHOoTznALmwHTHmvR5CM1VEh9XuPdNmKT 5g9nLezKSu+CKSNVNm+NQrc16vF/BKa5FCL15IDjZio/vHUR2awx89/iVr1Kn++HhagfI 0bXjdnvzBNN7DoNOi8zrv/iClhWBXocAUXAOKj5anAiJP5vJHGblZ5IMoLgvG41rXHQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=lsYvsYjB; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C42A606B478; Fri, 13 Nov 2026 17:40:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=lsYvsYjB Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08F821F000C5; Fri, 13 Nov 2026 17:40:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794591625; bh=huApMIKZVNQOxuyxT5TSusyIahpxflVBSPm5qzZNV7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lsYvsYjBwKyn94j0M4Q5w2+g2I9SjAurzBVQSraQ6UyZinAskv+OMkNfI7uW90ahS OJv7yCIcCOba6ut7G6p+wWoVQjZtXRx/zvKvXH4/Zu3Xv0ow1GqtD/OzLvaQLAESj9 3rvMT2YhKyf4VrSvtQUra/pcf10Wq9SYwKZGnMks= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Brandon Williams , Sebastian Reichel , Sasha Levin Subject: [PATCH 6.12 665/670] power: supply: qcom_battmgr: Notify charger supplies of online changes Date: Fri, 13 Nov 2026 10:53:49 -0500 Message-ID: <20261113153834.428934932@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261113153811.177190860@linuxfoundation.org> References: <20261113153811.177190860@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Brandon Williams [ Upstream commit 87fd20da8ca8bacdaa9bff5860167f208077dc51 ] On SC8280XP and X1E80100 the AC, USB and wireless supplies take their online state from the charging source in the battery status response. The firmware sends no notification for those supplies when the charging source changes, and the driver only announces the battery, so userspace never learns that the charger was plugged in or out. UPower keeps the state it read at startup: a laptop booted on the charger never goes on battery. Call power_supply_changed() for a supply whose online state changes when a status response is parsed. A supply that is not registered yet, when the battery is read during probe, reports its state when it registers. Tested on a Microsoft Surface Pro 11 (X1E80100): after restarting UPower on the charger, unplugging now sets OnBattery, and plugging in clears it. Fixes: 29e8142b5623 ("power: supply: Introduce Qualcomm PMIC GLINK power supply") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Brandon Williams Link: https://patch.msgid.link/20261013-upstream-battmgr-charger-online-v1-1-731973e133a0@gmail.com Signed-off-by: Sebastian Reichel [ sashal: Adjusted context to account for the missing battery-percentage calculation after charger-state updates. ] Signed-off-by: Sasha Levin --- drivers/power/supply/qcom_battmgr.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c index d559825538631..3674afb0d49d0 100644 --- a/drivers/power/supply/qcom_battmgr.c +++ b/drivers/power/supply/qcom_battmgr.c @@ -998,6 +998,23 @@ static unsigned int qcom_battmgr_sc8280xp_convert_temp(unsigned int temperature) return DIV_ROUND_CLOSEST(temperature, 10); } +/* + * The charger supplies' online state comes from the battery status response, + * and the firmware sends no notification of its own when it changes, so + * announce the change here. A supply that is not registered yet announces its + * state when it is. + */ +static void qcom_battmgr_sc8280xp_set_online(struct power_supply *psy, + bool *online, bool value) +{ + if (*online == value) + return; + + *online = value; + if (psy) + power_supply_changed(psy); +} + static void qcom_battmgr_sc8280xp_callback(struct qcom_battmgr *battmgr, const struct qcom_battmgr_message *resp, size_t len) @@ -1067,9 +1084,12 @@ static void qcom_battmgr_sc8280xp_callback(struct qcom_battmgr *battmgr, battmgr->status.temperature = qcom_battmgr_sc8280xp_convert_temp(le32_to_cpu(resp->status.temperature)); source = le32_to_cpu(resp->status.charging_source); - battmgr->ac.online = source == BATTMGR_CHARGING_SOURCE_AC; - battmgr->usb.online = source == BATTMGR_CHARGING_SOURCE_USB; - battmgr->wireless.online = source == BATTMGR_CHARGING_SOURCE_WIRELESS; + qcom_battmgr_sc8280xp_set_online(battmgr->ac_psy, &battmgr->ac.online, + source == BATTMGR_CHARGING_SOURCE_AC); + qcom_battmgr_sc8280xp_set_online(battmgr->usb_psy, &battmgr->usb.online, + source == BATTMGR_CHARGING_SOURCE_USB); + qcom_battmgr_sc8280xp_set_online(battmgr->wls_psy, &battmgr->wireless.online, + source == BATTMGR_CHARGING_SOURCE_WIRELESS); break; case BATTMGR_BAT_DISCHARGE_TIME: battmgr->status.discharge_time = le32_to_cpu(resp->time); -- 2.53.0