Skip to content

Commit 6f63af7

Browse files
committed
clk: Don't hold prepare_lock when calling kref_put()
We don't need to hold the prepare_lock when dropping a ref on a struct clk_core. The release function is only freeing memory and any code with a pointer reference has already unlinked anything pointing to the clk_core. This reduces the holding area of the prepare_lock a bit. Note that we also don't call free_clk() with the prepare_lock held. There isn't any reason to do that. Reviewed-by: Douglas Anderson <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 8358a76 commit 6f63af7

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

drivers/clk/clk.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4470,7 +4470,8 @@ void clk_unregister(struct clk *clk)
44704470
if (ops == &clk_nodrv_ops) {
44714471
pr_err("%s: unregistered clock: %s\n", __func__,
44724472
clk->core->name);
4473-
goto unlock;
4473+
clk_prepare_unlock();
4474+
return;
44744475
}
44754476
/*
44764477
* Assign empty clock ops for consumers that might still hold
@@ -4504,11 +4505,10 @@ void clk_unregister(struct clk *clk)
45044505
if (clk->core->protect_count)
45054506
pr_warn("%s: unregistering protected clock: %s\n",
45064507
__func__, clk->core->name);
4508+
clk_prepare_unlock();
45074509

45084510
kref_put(&clk->core->ref, __clk_release);
45094511
free_clk(clk);
4510-
unlock:
4511-
clk_prepare_unlock();
45124512
}
45134513
EXPORT_SYMBOL_GPL(clk_unregister);
45144514

@@ -4667,13 +4667,11 @@ void __clk_put(struct clk *clk)
46674667
if (clk->min_rate > 0 || clk->max_rate < ULONG_MAX)
46684668
clk_set_rate_range_nolock(clk, 0, ULONG_MAX);
46694669

4670-
owner = clk->core->owner;
4671-
kref_put(&clk->core->ref, __clk_release);
4672-
46734670
clk_prepare_unlock();
46744671

4672+
owner = clk->core->owner;
4673+
kref_put(&clk->core->ref, __clk_release);
46754674
module_put(owner);
4676-
46774675
free_clk(clk);
46784676
}
46794677

0 commit comments

Comments
 (0)