From: Saravana Kannan <saravanak@google.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Pavel Machek <pavel@ucw.cz>, Len Brown <len.brown@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>
Cc: Saravana Kannan <saravanak@google.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Marek Vasut <marex@denx.de>,
Bird@google.com, Tim <Tim.Bird@sony.com>,
kernel-team@android.com, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v1 2/5] PM: sleep: Remove unnecessary mutex lock when waiting on parent
Date: Thu, 14 Nov 2024 14:09:16 -0800 [thread overview]
Message-ID: <20241114220921.2529905-3-saravanak@google.com> (raw)
In-Reply-To: <20241114220921.2529905-1-saravanak@google.com>
Locking is not needed to do get_device(dev->parent). We either get a NULL
(if the parent was cleared) or the actual parent. Also, when a device is
deleted (device_del()) and removed from the dpm_list, its completion
variable is also complete_all()-ed. So, we don't have to worry about
waiting indefinitely on a deleted parent device.
Signed-off-by: Saravana Kannan <saravanak@google.com>
---
drivers/base/power/main.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 86e51b9fefab..9b9b6088e56a 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -284,18 +284,9 @@ static bool dpm_wait_for_superior(struct device *dev, bool async)
* counting the parent once more unless the device has been deleted
* already (in which case return right away).
*/
- mutex_lock(&dpm_list_mtx);
-
- if (!device_pm_initialized(dev)) {
- mutex_unlock(&dpm_list_mtx);
- return false;
- }
-
parent = get_device(dev->parent);
-
- mutex_unlock(&dpm_list_mtx);
-
- dpm_wait(parent, async);
+ if (device_pm_initialized(dev))
+ dpm_wait(parent, async);
put_device(parent);
dpm_wait_for_suppliers(dev, async);
--
2.47.0.338.g60cca15819-goog
next prev parent reply other threads:[~2024-11-14 22:09 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-14 22:09 [PATCH v1 0/5] Optimize async device suspend/resume Saravana Kannan
2024-11-14 22:09 ` [PATCH v1 1/5] PM: sleep: Fix runtime PM issue in dpm_resume() Saravana Kannan
2024-11-16 7:43 ` Greg Kroah-Hartman
2024-11-16 21:06 ` Saravana Kannan
2024-12-04 12:53 ` Rafael J. Wysocki
2025-03-11 10:47 ` Rafael J. Wysocki
2025-03-13 1:49 ` Saravana Kannan
2025-03-13 10:58 ` Rafael J. Wysocki
2025-03-14 20:47 ` Pavel Machek
2025-03-14 20:49 ` Saravana Kannan
2024-11-14 22:09 ` Saravana Kannan [this message]
2024-12-02 20:11 ` [PATCH v1 2/5] PM: sleep: Remove unnecessary mutex lock when waiting on parent Rafael J. Wysocki
2024-12-02 20:16 ` Rafael J. Wysocki
2024-12-02 20:46 ` Saravana Kannan
2024-12-02 21:14 ` Rafael J. Wysocki
2024-12-02 23:27 ` Saravana Kannan
2024-12-04 12:21 ` Rafael J. Wysocki
2024-11-14 22:09 ` [PATCH v1 3/5] PM: sleep: Add helper functions to loop through superior/subordinate devs Saravana Kannan
2024-11-14 22:09 ` [PATCH v1 4/5] PM: sleep: Do breadth first suspend/resume for async suspend/resume Saravana Kannan
2025-03-11 11:25 ` Geert Uytterhoeven
2024-11-14 22:09 ` [PATCH v1 5/5] PM: sleep: Spread out async kworker threads during dpm_resume*() phases Saravana Kannan
2024-11-15 5:25 ` Saravana Kannan
2024-11-15 9:25 ` Geert Uytterhoeven
2024-11-15 15:30 ` Vincent Guittot
2024-11-15 16:12 ` Vincent Guittot
2024-11-15 18:33 ` Saravana Kannan
2024-11-17 0:34 ` kernel test robot
2024-11-17 1:17 ` kernel test robot
2024-11-17 13:34 ` kernel test robot
2024-11-18 9:52 ` Christian Loehle
2024-11-18 17:18 ` Saravana Kannan
2024-11-19 4:04 ` [PATCH v1 0/5] Optimize async device suspend/resume Saravana Kannan
2024-11-19 9:51 ` Greg Kroah-Hartman
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=20241114220921.2529905-3-saravanak@google.com \
--to=saravanak@google.com \
--cc=Bird@google.com \
--cc=Tim.Bird@sony.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=juri.lelli@redhat.com \
--cc=kernel-team@android.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=marex@denx.de \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=pavel@ucw.cz \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/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®