mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Harald Geyer <harald@ccbib.org>
To: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Tejun Heo <tj@kernel.org>,
	Lai Jiangshan <jiangshanlai@gmail.com>
Cc: linux-kernel@vger.kernel.org, Harald Geyer <harald@ccbib.org>
Subject: [PATCH 2/2] regulator: core: Fix race on multiple calls to regulator_disable_deferred()
Date: Wed, 22 Feb 2017 17:41:25 +0000	[thread overview]
Message-ID: <1487785285-3567-2-git-send-email-harald@ccbib.org> (raw)
In-Reply-To: <1487785285-3567-1-git-send-email-harald@ccbib.org>

The old code has two issues:
1) When multiple consumers call regulator_disable_deferred() close in time,
always the delay requested in the first call is used.
2) When a consumer calls regulator_disable_deferred(), but enables and
calls regulator_disable_deferred() again before the timer fires, the timer
isn't reset.

Both issues can cause the regulator to get disabled early.

Signed-off-by: Harald Geyer <harald@ccbib.org>
---
 drivers/regulator/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index cc68604..ce4923b 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2449,8 +2449,8 @@ int regulator_disable_deferred(struct regulator *regulator, int ms)
 	rdev->deferred_disables++;
 	mutex_unlock(&rdev->mutex);
 
-	queue_delayed_work(system_power_efficient_wq, &rdev->disable_work,
-			   msecs_to_jiffies(ms));
+	mod_fwd_delayed_work(system_power_efficient_wq, &rdev->disable_work,
+			     msecs_to_jiffies(ms));
 	return 0;
 }
 EXPORT_SYMBOL_GPL(regulator_disable_deferred);
-- 
2.1.4

  reply	other threads:[~2017-02-22 18:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-22 17:41 [PATCH 1/2] workqueue: Add new function mod_fwd_delayed_work() Harald Geyer
2017-02-22 17:41 ` Harald Geyer [this message]
2017-02-22 18:21 ` Mark Brown
2017-02-22 20:06   ` Harald Geyer
2017-02-23 17:34     ` Mark Brown
2017-02-23 23:22       ` Harald Geyer
2017-02-27 12:54         ` Mark Brown
2017-02-27 19:17           ` Harald Geyer
2017-03-07 12:42             ` Mark Brown
2017-03-10 18:44               ` Harald Geyer
2017-03-06 22:22       ` Tejun Heo
2017-03-07 11:29         ` Harald Geyer
2017-03-07 19:16           ` Tejun Heo
2017-03-07 12:45         ` Mark Brown

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=1487785285-3567-2-git-send-email-harald@ccbib.org \
    --to=harald@ccbib.org \
    --cc=broonie@kernel.org \
    --cc=jiangshanlai@gmail.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@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

Powered by JetHome