Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp635309rdb; Tue, 23 Jan 2024 09:54:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdGbl0D588CchPwBBxUNGzRRHP1edoYEqp7QcY0zGMvB+82fJRatNLs3MdyKBmmSZL2CwF X-Received: by 2002:a05:620a:41:b0:783:8d0f:d760 with SMTP id t1-20020a05620a004100b007838d0fd760mr5363139qkt.5.1706032449133; Tue, 23 Jan 2024 09:54:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706032449; cv=pass; d=google.com; s=arc-20160816; b=tA6f3T7IBa6HvY8zV7IHrapVCllOtBdkG/FvyLFCRAi06EOIpL4WDmJFKt5EnV+JWd EA0E6Jqdy76pnbcqMXA2onNrpcVQtO1McJYgAuAKotcOkY8XjQc0012KiM/bxaQPkBZ7 P+oK7Z4nl1GXIDuuX16q5rYO5p2iogSyaJcH/A13UZvP7p4eT86MHaUGjZapm8mrz9fm 7HH/ot4OSVsvNcjT1xmYkAR5TGm37eQZCZgycR8CoHUrFX7uKWzWi89LHLMPzME62t6s 5F5YzvwDx+gEwgrkw5ECtUJ68hpGoZTL+DdvOeRBQnRUTrjc3vJcd0JZe+SV94/F/5Uj 0trg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=Imf394kL4Iql2UnZew/bvNix8nVGsR4OQhBljRFX9lY=; fh=S30qyEgRQnTUc6eJXSYTPWDg4bSPCmA3z1vIm3vMM8M=; b=j/ys6jp0T4dC76BmeHEwonmgd4ByN2IreQwmoE03qEFiz0l8Ib3CPdt5LMpD7lbe+B A9KzxMtrp9tFkbjQ8JyhEOXa+cG/SGygOVQ513uqFxKJC2s+NTfG2b32Rd3hU3vOBdZs ZFJXJW7aw5XaAYy5vcS8VL+yFncinx5hSPvRneg/md6mVXLOjuB8VQ7cm3mdTkx8Ic5H xDR92S9kDxSdlE1n9KymUtB72wiKU19Q4u2S5haV959j8vp2dC1SCulErGQzFuT6HEqz c1D4zwpd/VlizEHfxEks7pt60RnO1ZoOtekA8i5/lZW/wfzxvGDLGniTst6iPk1CoQiA fuIQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rHAuPwn5; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-35824-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35824-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id f4-20020a37ad04000000b0078394bdfc78si7242250qkm.44.2024.01.23.09.54.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 09:54:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35824-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rHAuPwn5; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-35824-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35824-linux.lists.archive=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 DF7771C21E51 for ; Tue, 23 Jan 2024 17:54:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A855811ED; Tue, 23 Jan 2024 17:53:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="rHAuPwn5" Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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 CB1368005F for ; Tue, 23 Jan 2024 17:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706032433; cv=none; b=daZgnRZFtN16bugutmc8bfti89ltr70kMK2RFaCPX6kR72EkANLE2rilBJqTDVIEO1N48/FK0c+s6VXXS6K1iVsjyBMgSFp6ySKO2prEv1Zo/Py3AnnBM9jhIaLjX74tNZ4DQslktXQs47UZ3hgoslwi2exGHmsInmaUJCn55Ro= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706032433; c=relaxed/simple; bh=wVl9haQVCPWB5lzRPA2n7zxH/Rd+6wdBvfdx8WKhjak=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eIY6kBM5VH1RudlCc+VmGjTv8vdjb8Nz9Gn5OLD4CRu3mex7OwEckJywEp5k+YV5oM3TRyQkV/rP34zySHXR8xcrH+7+1iyvbsAl4R5n7hTjgl9VtBx5MCyVNJFN8uDH00R1j/zri1iZL9eCFrIC/rETKhaiNFQs4E110m8emdo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=rHAuPwn5; arc=none smtp.client-ip=209.85.167.44 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-f44.google.com with SMTP id 2adb3069b0e04-5100c3f7df1so692850e87.0 for ; Tue, 23 Jan 2024 09:53:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706032430; x=1706637230; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Imf394kL4Iql2UnZew/bvNix8nVGsR4OQhBljRFX9lY=; b=rHAuPwn5keRFL8donQq8pdtoArJ8fORsMAgqzxDMHzPIb3JratuJRj+bXCX6aJ0yMp 1sSCjwnN/SNUa1OarpOsiVnYy2i4b5nbgt1yq9yiwpWUxjYvgM659VXwNO/wM9nKr6N5 qtLN/6SDUKzDkLRJiuIPvNIa92kgj0QcXDucX2RQdagdxlt35kd9tQxFXnt0zIkbIoTn gy5ntwSMXRlpVQIzWgDbt1Mw3ljvEnbqbxR+s0HwX5XV8PZQxc04WuT2LFiUR9VJMc3l FmXQ/juP6fPUzpLq0KVjJf0vsR4BsAMoilS7HrQKsg9aZO2hzYFhcD4xi1BAes+KOlU1 PYzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706032430; x=1706637230; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Imf394kL4Iql2UnZew/bvNix8nVGsR4OQhBljRFX9lY=; b=TY3N4mQ7+rabQepAc1z5xtIIchUtiRV14Nw30B5c4w0YM8KEY3/nKiSXQoF5NRSL3r pQy3r4Ju7eO4a+cb/KiJDPGmUWnb07f1rkdcq4wgvrkH2IUQpzVzB8ygm40ZWz8urI/e iaNvclKwBkj2ifdAa766pims2cmljX7GRJE97jphchAvzELE9tV9Uvyfwjc14Q3ZsTUh L+oQdbbsuYdNC8QpexMCEFpbUzMhv/6HGaud8pQuACW4hJJ8KoBBMrq06WATHoKh1ml7 3UPWMsbo8Ta7UByVLJbT/S/ZqmjCsofuE4qf6DQAOzbiMZNBSb2eomsguOBJnTl+q3ZH OOfg== X-Gm-Message-State: AOJu0YwYbADH3BmYf/5xHBA1eNZUG1XtmmN0T4azdlsY32XMHf6/GfwC TSWf5AtfDP7CAGUTbk/Ux6EQkfy2cC9NhmwkCVyZY/ExNr8Cw5ATz7iRsZksNSSlm4WtOUo2+Gd m X-Received: by 2002:a05:6512:1082:b0:50e:c845:5be6 with SMTP id j2-20020a056512108200b0050ec8455be6mr3479727lfg.107.1706032429896; Tue, 23 Jan 2024 09:53:49 -0800 (PST) Received: from [172.30.205.123] (UNUSED.212-182-62-129.lubman.net.pl. [212.182.62.129]) by smtp.gmail.com with ESMTPSA id j6-20020ac253a6000000b005100c529020sm100704lfh.6.2024.01.23.09.53.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Jan 2024 09:53:49 -0800 (PST) Message-ID: Date: Tue, 23 Jan 2024 18:53:46 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] power: supply: qcom_battmgr: Ignore notifications before initialization Content-Language: en-US To: Johan Hovold Cc: Bjorn Andersson , Sebastian Reichel , Marijn Suijten , Sebastian Reichel , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Xilin Wu References: <20240103-topic-battmgr2-v2-1-c07b9206a2a5@linaro.org> From: Konrad Dybcio In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/23/24 16:59, Johan Hovold wrote: > On Wed, Jan 03, 2024 at 01:36:08PM +0100, Konrad Dybcio wrote: >> 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. > > So this clearly was not tested properly as the offending commit breaks > both the Lenovo ThinkPad X13s and the SC8280XP CRD. > > I spent some time this afternoon tracking down and considering the best > way to address this before I checked lore and found this proposed fix > (why was I not CCed?). I didn't give the offending commit a spin on the laptops, as I simply assumed the interface is generic enough to behave similarly across the platforms. With this, I didn't imagine the DSP firmwares aren't unloaded on these.. [...] > >> + if (!battmgr->bat_psy) >> + return; > > This is not a proper fix. You register 3-4 class devices and only check > one. Even if your checked the last one, there's no locking or barriers > in place to prevent this from breaking. > > Deferred registration of the class devices also risks missing > notifications as you'll be spending time on registration after the > service has gone live. > > I'm sure all of this can be handled but as it is non-trivial and the > motivation for the offending commit is questionable to begin with, I > suggest reverting for now. > > I'll send a revert for Sebastian to consider. What you're saying is valid, but a "battery" device is always expected to be present. If devm_power_supply_register fails, things would go very south very fast anyway. I personally don't see this being a terribly bad fix, but I'm open to different propositions. Konrad