From: Armin Wolf <W_Armin@gmx.de>
To: sre@kernel.org, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com
Cc: linux-pm@vger.kernel.org, platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] platform/x86: dell-ddv: Fix taking the psy->extensions_sem lock twice
Date: Fri, 27 Jun 2025 22:51:24 +0200 [thread overview]
Message-ID: <20250627205124.250433-3-W_Armin@gmx.de> (raw)
In-Reply-To: <20250627205124.250433-1-W_Armin@gmx.de>
Calling power_supply_get_property() inside
dell_wmi_ddv_battery_translate() can cause a deadlock since this
function is also being called from the power supply extension code,
in which case psy->extensions_sem is already being held.
Fix this by using the new power_supply_get_property_direct() function
to ignore any power supply extensions when retrieving the battery
serial number.
Tested on a Dell Inspiron 3505.
Reported-by: Hans de Goede <hansg@kernel.org>
Fixes: 058de163a376 ("platform/x86: dell-ddv: Implement the battery matching algorithm")
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
drivers/platform/x86/dell/dell-wmi-ddv.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/dell/dell-wmi-ddv.c b/drivers/platform/x86/dell/dell-wmi-ddv.c
index 67f3d7158403..62e3d060f038 100644
--- a/drivers/platform/x86/dell/dell-wmi-ddv.c
+++ b/drivers/platform/x86/dell/dell-wmi-ddv.c
@@ -689,9 +689,13 @@ static int dell_wmi_ddv_battery_translate(struct dell_wmi_ddv_data *data,
dev_dbg(&data->wdev->dev, "Translation cache miss\n");
- /* Perform a translation between a ACPI battery and a battery index */
-
- ret = power_supply_get_property(battery, POWER_SUPPLY_PROP_SERIAL_NUMBER, &val);
+ /*
+ * Perform a translation between a ACPI battery and a battery index.
+ * We have to use power_supply_get_property_direct() here because this
+ * function will also get called from the callbacks of the power supply
+ * extension.
+ */
+ ret = power_supply_get_property_direct(battery, POWER_SUPPLY_PROP_SERIAL_NUMBER, &val);
if (ret < 0)
return ret;
--
2.39.5
next prev parent reply other threads:[~2025-06-27 20:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-27 20:51 [PATCH 1/3] power: supply: core: Add power_supply_get/set_property_direct() Armin Wolf
2025-06-27 20:51 ` [PATCH 2/3] power: supply: test-power: Test access to extended power supply Armin Wolf
2025-07-06 23:13 ` Sebastian Reichel
2025-06-27 20:51 ` Armin Wolf [this message]
2025-06-28 9:25 ` [PATCH 1/3] power: supply: core: Add power_supply_get/set_property_direct() Hans de Goede
2025-06-28 21:34 ` Armin Wolf
2025-06-30 8:58 ` Ilpo Järvinen
2025-07-06 23:14 ` Sebastian Reichel
2025-07-06 23:11 ` Sebastian Reichel
2025-07-07 13:00 ` Ilpo Järvinen
2025-06-27 20:53 Armin Wolf
2025-06-27 20:53 ` [PATCH 3/3] platform/x86: dell-ddv: Fix taking the psy->extensions_sem lock twice Armin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250627205124.250433-3-W_Armin@gmx.de \
--to=w_armin@gmx.de \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=sre@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®