From nobody Sun Dec 26 18:27:15 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4448B190E354; Sun, 26 Dec 2021 18:27:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JMTmM6xG9z3QS8; Sun, 26 Dec 2021 18:27:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CDCB1735C; Sun, 26 Dec 2021 18:27:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BQIRFxA048947; Sun, 26 Dec 2021 18:27:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BQIRFVl048946; Sun, 26 Dec 2021 18:27:15 GMT (envelope-from git) Date: Sun, 26 Dec 2021 18:27:15 GMT Message-Id: <202112261827.1BQIRFVl048946@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Adrian Chadd Subject: git: 9df53d07e6bc - main - clk: add call for nodes to get the programmed/decided frequency passed back List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9df53d07e6bce5d38fca860367da546f6a420a90 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640543236; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LNL7jOu82rMf+LkBZzQkX2UbNL4GcWzVnwTDIgldtYA=; b=oMhozmXo/bgCo/aKiHn8SJWYB7tY4lHwO+lAM/SPyiCh2XlhUyo/mihO2PHAc7ku467jUo haaG8Pu1odSqXCDsi8YPU4NVBuOogDJcp90P6vbQZT6xxs//VW62xipKuarF6FpTBsk4S8 ndNRPMrpHvnndBsnPoMSaoaCZ5MvWJvGFaEmiQi+v998xWVcddm0XUKEOZm5ftPAZMjreB SumD+3zVeVhkAl6UJ28dYiQKqyQbWTppiv3u/ZnHHjQrwcKpkKm0KVWIbVpbRx8OmT3xi+ 388HgcGQprrmeHG54cFplJdZNZ+91tLlCFD5Tw1H0gul3bfr1QQtMP0xTcelOQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640543236; a=rsa-sha256; cv=none; b=UEqkUe60V0Zgja08vvKJ8wMqa7vbjSS4+Of6BEEZEq4P6zwUfOTWfiP5oJYTjsiGXo98E8 BgmkN0LbD8iGKeB+ogX3TswCpoWl1MGjubvmznaDSVGQ0yKZrys4sKdMd2xX+DZVd07wvl HEfs2QxOciz+RaJbbHrsAo0eyeA8Z7AYlhCTUtRK2nuueeXfV2yWgoB82BiDHyObp/QLsZ pietBFyYOCdW03mRO8wh3PBOatMAd9XjkDVrmbJjgtDt0inf77ub/BS78b/zgT2oiPFvK9 q7n7bE0GkHgpzOQt1z9cItdP4dNKEiKHMMcxrK3+p8fYqTgUrdF27gcUl5tThA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=9df53d07e6bce5d38fca860367da546f6a420a90 commit 9df53d07e6bce5d38fca860367da546f6a420a90 Author: Adrian Chadd AuthorDate: 2021-12-14 18:01:08 +0000 Commit: Adrian Chadd CommitDate: 2021-12-26 12:18:53 +0000 clk: add call for nodes to get the programmed/decided frequency passed back Summary: The existing call can only really be used for a node wishing to configure its parent, but as we don't pass in a pointer to the freq, we can't set it to what it would be for a DRY_RUN pass. So for clock nodes that wish to try setting parent frequencies to see which would be the best for its own target frequency, we really do need a way to call in and pass in a flag /and/ a pointer to freq so it can be updated for us as the clock tree is recursed through. Reviewers: manu Approved by: manu Subscribers: imp Differential Revision: https://reviews.freebsd.org/D33445 --- sys/dev/extres/clk/clk.c | 35 +++++++++++++++++++++++++++++------ sys/dev/extres/clk/clk.h | 2 ++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/sys/dev/extres/clk/clk.c b/sys/dev/extres/clk/clk.c index f4284fcd59ba..2be233c465a9 100644 --- a/sys/dev/extres/clk/clk.c +++ b/sys/dev/extres/clk/clk.c @@ -965,8 +965,8 @@ clknode_get_freq(struct clknode *clknode, uint64_t *freq) return (0); } -int -clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, +static int +_clknode_set_freq(struct clknode *clknode, uint64_t *freq, int flags, int enablecnt) { int rv, done; @@ -976,7 +976,7 @@ clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, CLK_TOPO_XASSERT(); /* Check for no change */ - if (clknode->freq == freq) + if (clknode->freq == *freq) return (0); parent_freq = 0; @@ -1003,7 +1003,7 @@ clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, } /* Set frequency for this clock. */ - rv = CLKNODE_SET_FREQ(clknode, parent_freq, &freq, flags, &done); + rv = CLKNODE_SET_FREQ(clknode, parent_freq, freq, flags, &done); if (rv != 0) { printf("Cannot set frequency for clk: %s, error: %d\n", clknode->name, rv); @@ -1015,7 +1015,7 @@ clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, if (done) { /* Success - invalidate frequency cache for all children. */ if ((flags & CLK_SET_DRYRUN) == 0) { - clknode->freq = freq; + clknode->freq = *freq; /* Clock might have reparent during set_freq */ if (clknode->parent_cnt > 0) { rv = clknode_get_freq(clknode->parent, @@ -1028,7 +1028,8 @@ clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, } } else if (clknode->parent != NULL) { /* Nothing changed, pass request to parent. */ - rv = clknode_set_freq(clknode->parent, freq, flags, enablecnt); + rv = _clknode_set_freq(clknode->parent, freq, flags, + enablecnt); } else { /* End of chain without action. */ printf("Cannot set frequency for clk: %s, end of chain\n", @@ -1039,6 +1040,28 @@ clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, return (rv); } +int +clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, + int enablecnt) +{ + + return (_clknode_set_freq(clknode, &freq, flags, enablecnt)); +} + +int +clknode_try_freq(struct clknode *clknode, uint64_t freq, int flags, + int enablecnt, uint64_t *out_freq) +{ + int rv; + + rv = _clknode_set_freq(clknode, &freq, flags | CLK_SET_DRYRUN, + enablecnt); + if (out_freq != NULL) + *out_freq = freq; + + return (rv); +} + int clknode_enable(struct clknode *clknode) { diff --git a/sys/dev/extres/clk/clk.h b/sys/dev/extres/clk/clk.h index 3ddf8fc574de..5daf3c0731ee 100644 --- a/sys/dev/extres/clk/clk.h +++ b/sys/dev/extres/clk/clk.h @@ -115,6 +115,8 @@ struct clknode *clknode_find_by_id(struct clkdom *clkdom, intptr_t id); int clknode_get_freq(struct clknode *clknode, uint64_t *freq); int clknode_set_freq(struct clknode *clknode, uint64_t freq, int flags, int enablecnt); +int clknode_try_freq(struct clknode *clknode, uint64_t freq, int flags, + int enablecnt, uint64_t *out_freq); int clknode_enable(struct clknode *clknode); int clknode_disable(struct clknode *clknode); int clknode_stop(struct clknode *clknode, int depth);