diff options
author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2014-02-28 07:40:56 -0500 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2014-03-19 17:56:06 -0400 |
commit | 843bad8361bb0d7e5ed6254c84abd8d2ec61b6a4 (patch) | |
tree | 19deac13af981d1c2a5d969351518a22f7920a9f /Documentation/clk.txt | |
parent | 78761147987b2750b6a848c9719967df0c5eff73 (diff) |
Documentation: clk: Add locking documentation
Briefly document the common clock framework locking scheme from a clock
driver point of view.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'Documentation/clk.txt')
-rw-r--r-- | Documentation/clk.txt | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Documentation/clk.txt b/Documentation/clk.txt index 699ef2a323b1..c9c399af7c08 100644 --- a/Documentation/clk.txt +++ b/Documentation/clk.txt | |||
@@ -255,3 +255,37 @@ are sorted out. | |||
255 | 255 | ||
256 | To bypass this disabling, include "clk_ignore_unused" in the bootargs to the | 256 | To bypass this disabling, include "clk_ignore_unused" in the bootargs to the |
257 | kernel. | 257 | kernel. |
258 | |||
259 | Part 7 - Locking | ||
260 | |||
261 | The common clock framework uses two global locks, the prepare lock and the | ||
262 | enable lock. | ||
263 | |||
264 | The enable lock is a spinlock and is held across calls to the .enable, | ||
265 | .disable and .is_enabled operations. Those operations are thus not allowed to | ||
266 | sleep, and calls to the clk_enable(), clk_disable() and clk_is_enabled() API | ||
267 | functions are allowed in atomic context. | ||
268 | |||
269 | The prepare lock is a mutex and is held across calls to all other operations. | ||
270 | All those operations are allowed to sleep, and calls to the corresponding API | ||
271 | functions are not allowed in atomic context. | ||
272 | |||
273 | This effectively divides operations in two groups from a locking perspective. | ||
274 | |||
275 | Drivers don't need to manually protect resources shared between the operations | ||
276 | of one group, regardless of whether those resources are shared by multiple | ||
277 | clocks or not. However, access to resources that are shared between operations | ||
278 | of the two groups needs to be protected by the drivers. An example of such a | ||
279 | resource would be a register that controls both the clock rate and the clock | ||
280 | enable/disable state. | ||
281 | |||
282 | The clock framework is reentrant, in that a driver is allowed to call clock | ||
283 | framework functions from within its implementation of clock operations. This | ||
284 | can for instance cause a .set_rate operation of one clock being called from | ||
285 | within the .set_rate operation of another clock. This case must be considered | ||
286 | in the driver implementations, but the code flow is usually controlled by the | ||
287 | driver in that case. | ||
288 | |||
289 | Note that locking must also be considered when code outside of the common | ||
290 | clock framework needs to access resources used by the clock operations. This | ||
291 | is considered out of scope of this document. | ||