[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <202509101620.yI0HZ5gT-lkp@intel.com>
Date: Wed, 10 Sep 2025 14:47:43 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: oe-kbuild@...ts.linux.dev, GuangFei Luo <luogf2025@....com>,
"Rafael J . Wysocki" <rafael@...nel.org>
Cc: lkp@...el.com, oe-kbuild-all@...ts.linux.dev,
Len Brown <lenb@...nel.org>, linux-acpi@...r.kernel.org,
linux-kernel@...r.kernel.org, stable@...r.kernel.org,
luogf2025@....com
Subject: Re: [PATCH] ACPI: battery: prevent sysfs_add_battery re-entry on
rapid events
Hi GuangFei,
kernel test robot noticed the following build warnings:
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/GuangFei-Luo/ACPI-battery-prevent-sysfs_add_battery-re-entry-on-rapid-events/20250907-115505
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link: https://lore.kernel.org/r/20250907035154.223983-1-luogf2025%40163.com
patch subject: [PATCH] ACPI: battery: prevent sysfs_add_battery re-entry on rapid events
config: x86_64-randconfig-161-20250909 (https://download.01.org/0day-ci/archive/20250910/202509101620.yI0HZ5gT-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@...el.com>
| Reported-by: Dan Carpenter <dan.carpenter@...aro.org>
| Closes: https://lore.kernel.org/r/202509101620.yI0HZ5gT-lkp@intel.com/
smatch warnings:
drivers/acpi/battery.c:1046 acpi_battery_update() warn: inconsistent returns '&battery->sysfs_lock'.
vim +1046 drivers/acpi/battery.c
9e50bc14a7f58b5 Lan Tianyu 2014-05-04 1001 static int acpi_battery_update(struct acpi_battery *battery, bool resume)
508df92d1f8d192 Andrey Borzenkov 2007-10-28 1002 {
82f2d30570b7ecd Lucas Rangit Magasweran 2018-07-14 1003 int result = acpi_battery_get_status(battery);
82f2d30570b7ecd Lucas Rangit Magasweran 2018-07-14 1004
508df92d1f8d192 Andrey Borzenkov 2007-10-28 1005 if (result)
508df92d1f8d192 Andrey Borzenkov 2007-10-28 1006 return result;
82f2d30570b7ecd Lucas Rangit Magasweran 2018-07-14 1007
508df92d1f8d192 Andrey Borzenkov 2007-10-28 1008 if (!acpi_battery_present(battery)) {
508df92d1f8d192 Andrey Borzenkov 2007-10-28 1009 sysfs_remove_battery(battery);
97749cd9adbb298 Alexey Starikovskiy 2008-01-01 1010 battery->update_time = 0;
508df92d1f8d192 Andrey Borzenkov 2007-10-28 1011 return 0;
508df92d1f8d192 Andrey Borzenkov 2007-10-28 1012 }
9e50bc14a7f58b5 Lan Tianyu 2014-05-04 1013
9e50bc14a7f58b5 Lan Tianyu 2014-05-04 1014 if (resume)
9e50bc14a7f58b5 Lan Tianyu 2014-05-04 1015 return 0;
9e50bc14a7f58b5 Lan Tianyu 2014-05-04 1016
82f2d30570b7ecd Lucas Rangit Magasweran 2018-07-14 1017 if (!battery->update_time) {
97749cd9adbb298 Alexey Starikovskiy 2008-01-01 1018 result = acpi_battery_get_info(battery);
97749cd9adbb298 Alexey Starikovskiy 2008-01-01 1019 if (result)
97749cd9adbb298 Alexey Starikovskiy 2008-01-01 1020 return result;
97749cd9adbb298 Alexey Starikovskiy 2008-01-01 1021 acpi_battery_init_alarm(battery);
97749cd9adbb298 Alexey Starikovskiy 2008-01-01 1022 }
12c78ca2ab5e64b Carlos Garnacho 2016-08-10 1023
12c78ca2ab5e64b Carlos Garnacho 2016-08-10 1024 result = acpi_battery_get_state(battery);
12c78ca2ab5e64b Carlos Garnacho 2016-08-10 1025 if (result)
12c78ca2ab5e64b Carlos Garnacho 2016-08-10 1026 return result;
12c78ca2ab5e64b Carlos Garnacho 2016-08-10 1027 acpi_battery_quirks(battery);
12c78ca2ab5e64b Carlos Garnacho 2016-08-10 1028
ce5e61beaad5c5a GuangFei Luo 2025-09-07 1029 mutex_lock(&battery->sysfs_lock);
297d716f6260cc9 Krzysztof Kozlowski 2015-03-12 1030 if (!battery->bat) {
eb03cb02b74df6d Stefan Hajnoczi 2011-07-12 1031 result = sysfs_add_battery(battery);
eb03cb02b74df6d Stefan Hajnoczi 2011-07-12 1032 if (result)
eb03cb02b74df6d Stefan Hajnoczi 2011-07-12 1033 return result;
mutex_unlock(&battery->sysfs_lock) before returning.
eb03cb02b74df6d Stefan Hajnoczi 2011-07-12 1034 }
ce5e61beaad5c5a GuangFei Luo 2025-09-07 1035 mutex_unlock(&battery->sysfs_lock);
e0d1f09e311fafa Zhang Rui 2014-05-28 1036
e0d1f09e311fafa Zhang Rui 2014-05-28 1037 /*
e0d1f09e311fafa Zhang Rui 2014-05-28 1038 * Wakeup the system if battery is critical low
e0d1f09e311fafa Zhang Rui 2014-05-28 1039 * or lower than the alarm level
e0d1f09e311fafa Zhang Rui 2014-05-28 1040 */
e0d1f09e311fafa Zhang Rui 2014-05-28 1041 if ((battery->state & ACPI_BATTERY_STATE_CRITICAL) ||
e0d1f09e311fafa Zhang Rui 2014-05-28 1042 (test_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags) &&
e0d1f09e311fafa Zhang Rui 2014-05-28 1043 (battery->capacity_now <= battery->alarm)))
33e4f80ee69b516 Rafael J. Wysocki 2017-06-12 1044 acpi_pm_wakeup_event(&battery->device->dev);
e0d1f09e311fafa Zhang Rui 2014-05-28 1045
557d58687dcdee6 Zhang Rui 2010-10-22 @1046 return result;
4bd35cdb1e2d1a1 Vladimir Lebedev 2007-02-10 1047 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Powered by blists - more mailing lists