git: 1fbd603533ce - stable/13 - arm64: allwinner: clk: Test with the current parent freq first

Emmanuel Vadot manu at FreeBSD.org
Thu Jul 22 17:23:32 UTC 2021


The branch stable/13 has been updated by manu:

URL: https://cgit.FreeBSD.org/src/commit/?id=1fbd603533cebc65076aca39e76c4c8aab972fe3

commit 1fbd603533cebc65076aca39e76c4c8aab972fe3
Author:     Emmanuel Vadot <manu at FreeBSD.org>
AuthorDate: 2021-05-31 12:06:20 +0000
Commit:     Emmanuel Vadot <manu at FreeBSD.org>
CommitDate: 2021-07-22 17:23:06 +0000

    arm64: allwinner: clk: Test with the current parent freq first
    
    Even if the clock is flagged with AW_CLK_SET_PARENT the current parent
    freq might be enough to get a correct divisor.
    So test first if we can get the expected freq before changing the parent
    freq.
    
    (cherry picked from commit ac1d7397bf33acf8955fc0871ff124550bf50d1f)
---
 sys/arm/allwinner/clkng/aw_clk_m.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/sys/arm/allwinner/clkng/aw_clk_m.c b/sys/arm/allwinner/clkng/aw_clk_m.c
index 4f8189d48299..9f2dea6722bc 100644
--- a/sys/arm/allwinner/clkng/aw_clk_m.c
+++ b/sys/arm/allwinner/clkng/aw_clk_m.c
@@ -175,7 +175,9 @@ aw_clk_m_set_freq(struct clknode *clk, uint64_t fparent, uint64_t *fout,
 
 	best = cur = 0;
 
-	if ((sc->flags & AW_CLK_SET_PARENT) != 0) {
+	best = aw_clk_m_find_best(sc, fparent, fout,
+	    &best_m);
+	if ((best != *fout) && ((sc->flags & AW_CLK_SET_PARENT) != 0)) {
 		p_clk = clknode_get_parent(clk);
 		if (p_clk == NULL) {
 			printf("%s: Cannot get parent for clock %s\n",
@@ -187,9 +189,6 @@ aw_clk_m_set_freq(struct clknode *clk, uint64_t fparent, uint64_t *fout,
 		clknode_get_freq(p_clk, &fparent);
 		best = aw_clk_m_find_best(sc, fparent, fout,
 		    &best_m);
-	} else {
-		best = aw_clk_m_find_best(sc, fparent, fout,
-		    &best_m);
 	}
 
 	if ((flags & CLK_SET_DRYRUN) != 0) {


More information about the dev-commits-src-all mailing list