From patchwork Wed Jan 3 12:32:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 184729 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4988537dyb; Wed, 3 Jan 2024 04:32:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGVF92CBY//DsJ/b/InFhrRBMmK44Ubm2XZMjX6i/22zwrO+NMfNsjsp2lsqOR4q/Ev282l X-Received: by 2002:ad4:5c68:0:b0:67f:6103:b037 with SMTP id i8-20020ad45c68000000b0067f6103b037mr31206971qvh.11.1704285150564; Wed, 03 Jan 2024 04:32:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704285150; cv=none; d=google.com; s=arc-20160816; b=LVvuyxOm3EY7UY6u4Tsc7MIebA3pamjLb54ucYwS0F+zwa81DMqh5hFQoSD0+P3rIl 6MVvbdd4ZudqKpyvMby8LJgtfEGsRUhY9M5IjMYWJ8QYBWJ9BWpZH10MU6A38sY9sH1u mR3vAw7xyB0QQzCJtcjQzNh18RE3iS4I8G1rgLXhbRJqd9T9J9TM0/iehC+2ky8nWIBY usuKWIv42P1b/Xjj1gp9r0cgdCNh8ZdytE5YRIRfwc2Y5EHDICwhaH8Dkr/3wCE7L+In SFoH3f4jJ0PSqgEcnJgteyN0p9RJYNtaF0GieLbABrDYbDubnziYoxo8Dz/IkJwhbPNv 3Rbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:message-id:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:date :from:dkim-signature; bh=Isr8l5KeQNsDkqIvfhsrUdtZNLieOnww9+PkA4tJY9g=; fh=bhBZriho463BUOT5TXFafyaHf6mqm6OPI2v0OHXmwlY=; b=HahFZoU3C08dGQrwXmOmoarOWpPjnSKrptIkGqNxLmn+RyR3In6CTn/EAaQ6US35pa fzH/CVMscS7o4hUqhcsX+D+tDJhU0Ci/HWZtU8dVISwMiqP27c0HEsuCcYrSRM6sjjpJ vXEXXOEZwUuBCqrWEdBqHfgpuwyzpf7LJNUbnD6XrIDVVkZ9jS0PCQ/QZ+suhiyxxNCA 5RQfMKNjMMbQ0XlrwkWO8fMiPb9qbOTxYV0wcuk4KH/RrgWEVjheBrOEGG10NaX494tL exTMMmH9W3IV1UPK03HA7NM0NANQFkcPhQEoppu+NAo8fgEK6o5rrZgOrerK352w+CtF ogjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FmjLysQX; spf=pass (google.com: domain of linux-kernel+bounces-15517-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15517-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u2-20020a0cf1c2000000b0067a8bf10affsi29462251qvl.220.2024.01.03.04.32.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 04:32:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15517-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FmjLysQX; spf=pass (google.com: domain of linux-kernel+bounces-15517-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15517-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5CB5A1C23345 for ; Wed, 3 Jan 2024 12:32:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB4011946B; Wed, 3 Jan 2024 12:32:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="FmjLysQX" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99FD61944B for ; Wed, 3 Jan 2024 12:32:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-50e7e55c0f6so7177525e87.0 for ; Wed, 03 Jan 2024 04:32:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704285128; x=1704889928; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=Isr8l5KeQNsDkqIvfhsrUdtZNLieOnww9+PkA4tJY9g=; b=FmjLysQXaP9c9qKbLTxD4hQM+ZuAU35sbWAtPaXoch0+YA18iXC720+jZNDzqEfYaS Ptolke2jZVuvru7O1q5tca83+WC4aKFdjPwHW7JjjrUzRGAW2XmIiBKVtZjhVTqB160y SKtYFwU1Z9owx12RVKnmIVjMBvPEBi+TJYS4cwCGz+Fz5hYFCvQ6z1oV/1/PopuNbRzr 8Mb2TQknL5uFMtU0BxFCFoMN5BIZBlu2au+GCyXRWP1dKzFC21u2lGqhbVgxciFstfY0 RavuHIWBI51J4TntHeBOin8cDW5qfSrmlel3XAJmbh1B8gujVTE1mlfeegHbSDed7Wac X4pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704285128; x=1704889928; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Isr8l5KeQNsDkqIvfhsrUdtZNLieOnww9+PkA4tJY9g=; b=q8IuptW9xArh8MxJTKg29Lb3BX3SPdYVH7yVGrrixNjWr98ZiUDuN3wRyhDQUbs1Um jdNsG0NN2AyXbl324uzcwGqgxuSZ4GAJtjNQSlal/3GpqoxEbvIpwoJQf8lmS8KV8vX6 Px6gYF2m/3ptoSiGYdB81lgZSD3hQ6vWDCiGICbuF4uUFdRJ9EaHeXgguZQnrlvQBo+g LarU2ypxTLXtslSiIq4+uZT0MkAU9zWLoZwYSPETAfXbnTnKYMWDa4OBm5BLPULX5CEK v4VA7WBUsxusdS5ZpcHKSDVQjo//zWOmizgceZoq8A1JSpG1xnrJGiZlj67tu7BPgCvb D8dg== X-Gm-Message-State: AOJu0YxU3yNp6keJGHRsodr8qM2Ee2wYR/pCSxcDP2TjoFhFTOlNJdWk yxb9B7TZq50LS8NZJMmrRK8DEPc9HrQUIQ== X-Received: by 2002:a05:6512:400d:b0:50e:64b4:a266 with SMTP id br13-20020a056512400d00b0050e64b4a266mr5315689lfb.201.1704285128631; Wed, 03 Jan 2024 04:32:08 -0800 (PST) Received: from [10.167.154.1] (178235179036.dynamic-4-waw-k-1-3-0.vectranet.pl. [178.235.179.36]) by smtp.gmail.com with ESMTPSA id p2-20020a056402044200b005553a8bb61dsm10390243edw.87.2024.01.03.04.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 04:32:08 -0800 (PST) From: Konrad Dybcio Date: Wed, 03 Jan 2024 13:32:01 +0100 Subject: [PATCH] power: supply: qcom_battmgr: Register the power supplies after PDR is up Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240103-topic-battmgr2-v1-1-f89ca7234626@linaro.org> X-B4-Tracking: v=1; b=H4sIAMBTlWUC/x2N0QqDMAwAf0XyvEBbdYP9ythDGqMGXJW0joH47 5Y93sFxB2QxlQzP5gCTr2ZdUwV/a4BnSpOgDpUhuNA571os66aMkUr5TBbQ9+wfI/F9aHuoUaQ sGI0SzzVL+7JUuZmM+vtfXu/zvACY1f4ddQAAAA== To: Bjorn Andersson , Sebastian Reichel Cc: Marijn Suijten , Sebastian Reichel , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Xilin Wu , Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1704285127; l=1734; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=mDzb7tCs+TFmiHTgNCTIUfHSQ1l5BJtGwAobaPMNGes=; b=EnG5b3T9ZY9kuPFzQtu6fNj80IeCLktwOJtey+YvtPMjmsCPeP6zxpi7IW3NmrmDUxmVxm58f +7CPLKKm5D3DzPAosGJ1rVSyZYc7Kf0tWsEjcsgoKMVCGlECbtkF8fr X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787072506154858857 X-GMAIL-MSGID: 1787072506154858857 Commit b43f7ddc2b7a ("power: supply: qcom_battmgr: Register the power supplies after PDR is up") moved the devm_power_supply_register() calls so that the power supply devices are not registered before we go through the entire initialization sequence (power up the ADSP remote processor, wait for it to come online, coordinate with userspace..). Some firmware versions (e.g. on SM8550) seem to leave battmgr at least partly initialized when exiting the bootloader and loading Linux. Check if the power supply devices are registered before consuming the battmgr notifications. Fixes: b43f7ddc2b7a ("power: supply: qcom_battmgr: Register the power supplies after PDR is up") Reported-by: Xilin Wu Signed-off-by: Konrad Dybcio --- drivers/power/supply/qcom_battmgr.c | 4 ++++ 1 file changed, 4 insertions(+) --- base-commit: 0fef202ac2f8e6d9ad21aead648278f1226b9053 change-id: 20240103-topic-battmgr2-15c17fac6d35 Best regards, diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c index a12e2a66d516..7d85292eb839 100644 --- a/drivers/power/supply/qcom_battmgr.c +++ b/drivers/power/supply/qcom_battmgr.c @@ -1271,6 +1271,10 @@ static void qcom_battmgr_callback(const void *data, size_t len, void *priv) struct qcom_battmgr *battmgr = priv; unsigned int opcode = le32_to_cpu(hdr->opcode); + /* Ignore the pings that come before Linux cleanly initializes the battmgr stack */ + if (!battmgr->bat_psy) + return; + if (opcode == BATTMGR_NOTIFICATION) qcom_battmgr_notification(battmgr, data, len); else if (battmgr->variant == QCOM_BATTMGR_SC8280XP)