From 36694ec494fde3d328e716cd5af57c39b47d6527 Mon Sep 17 00:00:00 2001 From: mmel Date: Sun, 4 Dec 2016 16:02:59 +0000 Subject: [PATCH] Clock framework fixes: - The clk_test_freq() (aka CLK_SET_DRYRUN) doesn't change frequency, don't cache it result. - Fix busy condition for clk_set_freq(). MFC after: 3 weeks --- sys/dev/extres/clk/clk.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/dev/extres/clk/clk.c b/sys/dev/extres/clk/clk.c index b3996c53bdc8..c6ba90c7417b 100644 --- a/sys/dev/extres/clk/clk.c +++ b/sys/dev/extres/clk/clk.c @@ -830,9 +830,10 @@ clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, * OR * clock is glitch free and is enabled by calling consumer only */ - if ((clknode->enable_cnt > 1) && - ((clknode->enable_cnt > enablecnt) || - !(clknode->flags & CLK_NODE_GLITCH_FREE))) { + if ((flags & CLK_SET_DRYRUN) == 0 && + clknode->enable_cnt > 1 && + clknode->enable_cnt > enablecnt && + (clknode->flags & CLK_NODE_GLITCH_FREE) == 0) { return (EBUSY); } @@ -856,9 +857,10 @@ clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, if (done) { /* Success - invalidate frequency cache for all children. */ - clknode->freq = freq; - if ((flags & CLK_SET_DRYRUN) == 0) + if ((flags & CLK_SET_DRYRUN) == 0) { + clknode->freq = freq; clknode_refresh_cache(clknode, parent_freq); + } } else if (clknode->parent != NULL) { /* Nothing changed, pass request to parent. */ rv = clknode_set_freq(clknode->parent, freq, flags, enablecnt);