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=1796527465; b=uV5q95KJTfeocumLF/iCfIyzCySzkoa8+lkc5r8CgiDzlQYScdcy4igQVCaMs5z46H9G TObUyshlLrxvZu5SkvqFPSoyZ0jqZL+aUR2QCO9BckHCC/BZUgT6JmYyZt8mdQUN4yUyf /CWsWx5sACrm3N3XKckQJngxiheOsCiUYYHu5OICq9SvwXZeFKM7RtdT8umRWyuxGUC2F Gthrf68MqmNnNhdSOZnJnNJTn5dcp76/83AjtEGeiAPu6MarzCncbNwnXK0rYcD8vaBgW C3I5Ha3GPxtYmOWuQmsrF+JAP98JO0+MaCRIW28uCVI1ZqNSCwkan8tLh2wjGU5IamA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796527465; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=o65m/Ed8k/txt8jQLpgPJXRmVynpry++XyNQCYw+d6U=; b=CgDE2EN7mtSLFjWlKCRv57h0OXaBuTB2tBJLneaiZkb0Z5ipDkmwY4dhurimi1hYJ5vI a1Vrgsx7ZOSKjmLPYPJ4EY8RU+nvK0op5/m/SfPzTNwtMJGqrZNcFJjWDSnaVPoUV21gK /fmSi6KH9Q0x9s1WnYeruFQB2DYyE3X82G2OicHxeP59VrLPh+jYz2Ki1Mb/1uWfmV4Z3 PcU7RAC29RkmUDOZpw0GlhkQtakPqZa15hFB7ozCdtDJVH97meStma8tzWRgBNxQFhN2J 0gjpN5qyFCifT2/ggmjvy0X8XpFXCJhP0g0AzTtod6gnQK+E/+ip10zss0BeU7/0j7Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Cp2Pt+bB; 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 8F741606A31F; Sun, 6 Dec 2026 03:24:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Cp2Pt+bB Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DE5A1F0093B; Sun, 6 Dec 2026 03:24:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796527465; bh=o65m/Ed8k/txt8jQLpgPJXRmVynpry++XyNQCYw+d6U=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Cp2Pt+bBCuIBve85i73KDOBjWKb6OIt8avlaxyZsrHWMlIbeo2qaT3pvIhbR2CRx/ nUE6i6ZmhNMbRkNa+VJu18OTHCICATODA6QR1pVdQIyxAyv1WcJolCgc4cqvoQV426 4aNAvm+UaANDFocaoAFfw1FZa/PWAhEojqqPB7UO1EOzJqSU7t+mb/77+EHSN72Hi5 SEQcAEOVXBOafknmpXO/g38gs27wgEtHPgDlkEkeS3em4j4XlHWeo59IwRwkWW8c3G cosUcMmGzU1heVJUzZE0Gdz07z6PwCwoB2z0d+9PRdI30/IOHgLWc3YaGKTLpLNLYu VSbCnAyLYwvVQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v7 7/9] power: axp20x_battery: Estimate AXP192 capacity from the OCV table Reply-To: sashiko-reviews@lists.linux.dev To: =?utf-8?b?TW9sbsOhciBNw6F0w6k=?= Cc: devicetree@vger.kernel.org, linux-input@vger.kernel.org, mfd@lists.linux.dev, robh@kernel.org, conor+dt@kernel.org, dmitry.torokhov@gmail.com, lee@kernel.org In-Reply-To: <20261206-axp192-v7-7-0200fc77da53@gmail.com> References: <20261206-axp192-v7-0-0200fc77da53@gmail.com> <20261206-axp192-v7-7-0200fc77da53@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 06 Dec 2026 03:24:24 +0000 X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [Medium] power: axp20x_battery: probe race on bat_info and batt in ocv capacity path - [Low] power: axp20x_battery: missing has_fg in axp717_data retains unused bat_info - [Low] power: axp20x_battery: unconditional CURRENT_NOW read in ocv capacity path - [Low] power: axp20x_battery: stray board codename in axp20x_battery_ocv_capacity() - [Low] power: axp20x_battery: axp192_battery_props duplicates axp20x_battery_props -- commit a78f3397c5935dce53f82b239be5baaf83190c73 Author: Moln=C3=A1r M=C3=A1t=C3=A9 power: axp20x_battery: Estimate AXP192 capacity from the OCV table This commit estimates battery capacity from the battery's OCV table on PMICs without a fuel gauge, exposes POWER_SUPPLY_PROP_CAPACITY on AXP192, and keeps the parsed battery info around after probe for those PMICs. > diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply= /axp20x_battery.c > index b55089a81e17d..3c3cf349f9dda 100644 > --- a/drivers/power/supply/axp20x_battery.c > +++ b/drivers/power/supply/axp20x_battery.c [ ... ] > @@ -285,6 +288,50 @@ static int axp717_get_constant_charge_current(struct= axp20x_batt_ps *axp, [ ... ] > + ret =3D axp20x_battery_get_prop(axp20x_batt->batt, > + POWER_SUPPLY_PROP_CURRENT_NOW, &i); > + if (ret) > + return ret; > + > + if (info->factory_internal_resistance_uohm > 0) > + v.intval -=3D div_s64((s64)i.intval * > + info->factory_internal_resistance_uohm, > + 1000000); [Severity: Low] Should the POWER_SUPPLY_PROP_CURRENT_NOW read be moved inside the factory_internal_resistance_uohm check? When factory-internal-resistance-micro-ohms is omitted from devicetree, power_supply_get_battery_info() leaves factory_internal_resistance_uohm at -EINVAL and i.intval is discarded. Reading CURRENT_NOW unconditionally triggers unnecessary volatile I2C reads on every capacity query and fails capacity estimation if the unused current channel returns an error. > + > + /* ponytail: no temperature sensor wired up, assume 20 C */ > + ret =3D power_supply_batinfo_ocv2cap(info, v.intval, 20); [Severity: Low] This isn't a bug, but "ponytail" looks like a leftover out-of-tree board codename in a generic PMIC driver comment. [ ... ] > @@ -955,6 +1006,7 @@ static enum power_supply_property axp192_battery_pro= ps[] =3D { > POWER_SUPPLY_PROP_HEALTH, > POWER_SUPPLY_PROP_VOLTAGE_MAX, > POWER_SUPPLY_PROP_VOLTAGE_MIN, > + POWER_SUPPLY_PROP_CAPACITY, > }; [Severity: Low] With POWER_SUPPLY_PROP_CAPACITY added, axp192_battery_props[] is now identical to axp20x_battery_props[]. Can axp192_batt_ps_desc reuse axp20x_battery_props directly and drop the duplicate array? > @@ -1237,7 +1289,11 @@ static int axp20x_power_probe(struct platform_devi= ce *pdev) > =20 > if (!power_supply_get_battery_info(axp20x_batt->batt, &info)) { > axp20x_batt->data->set_bat_info(pdev, axp20x_batt, info); > - power_supply_put_battery_info(axp20x_batt->batt, info); > + /* Without a fuel gauge the OCV table is used for the capacity */ > + if (axp20x_batt->data->has_fg) > + power_supply_put_battery_info(axp20x_batt->batt, info); [Severity: Low] Does gating power_supply_put_battery_info() on data->has_fg retain an unused battery_info allocation on AXP717? axp717_data omits .has_fg =3D true even though AXP717 has a hardware fuel gauge and axp717_battery_get_prop() reads AXP717_BATT_PERCENT_DATA directly without ever using axp20x_batt->bat_info. > + else > + axp20x_batt->bat_info =3D info; > } [Severity: Medium] Can concurrent sysfs readers race with axp20x_power_probe() on axp20x_batt->bat_info and axp20x_batt->batt? devm_power_supply_register() calls device_add() and sets psy->initialized =3D true before returning, so userspace (such as udev or UPower) can read capacity while probe is still storing axp20x_batt->batt and axp20x_batt->bat_info: CPU0 CPU1 axp20x_power_probe() devm_power_supply_register() device_add() psy->initialized =3D true axp20x_batt->batt =3D psy ... axp20x_batt->bat_info =3D info sysfs read capacity axp20x_battery_ocv_capacity() info =3D axp20x_batt->bat_info axp20x_battery_get_prop( axp20x_batt->batt, ...) <-- NULL deref if reordered Both pointers are written and read with plain accesses and no locking or release/acquire ordering. Early readers before bat_info is stored get spurious -ENODATA, and on weakly-ordered architectures CPU1 can observe a non-NULL bat_info alongside uninitialized *info fields or a stale NULL axp20x_batt->batt, leading to a NULL pointer dereference in power_supply_get_drvdata(). In addition, __power_supply_register() already parses and stores psy->battery_info before device_add() for POWER_SUPPLY_TYPE_BATTERY devices, so keeping bat_info duplicates that allocation. Passing psy from axp20x_battery_get_prop() into axp20x_battery_ocv_capacity() and reading psy->battery_info avoids the probe race, the bat_info field, and the duplicate allocation. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261206-axp192-v7-= 0-0200fc77da53@gmail.com?part=3D7