From nobody Fri Dec 24 18:44:24 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 523571901BDF; Fri, 24 Dec 2021 18:44:25 +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 4JLGF50Nf5z3Fx6; Fri, 24 Dec 2021 18:44:25 +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 E143110B4; Fri, 24 Dec 2021 18:44:24 +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 1BOIiOPT031507; Fri, 24 Dec 2021 18:44:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BOIiOgU031506; Fri, 24 Dec 2021 18:44:24 GMT (envelope-from git) Date: Fri, 24 Dec 2021 18:44:24 GMT Message-Id: <202112241844.1BOIiOgU031506@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michal Meloun Subject: git: 72a2f3b5e28a - main - extres/clk: Improve sysctl dump of clocks. 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: mmel X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 72a2f3b5e28ada60de01f08b28888f70eec0baed Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640371465; 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=Ht632aVhsI5tGzYpJg5wMieoW8XF/Rlh1OnP0oMkYg0=; b=xptQNWjTCJ8SSOEMDzl8irWMyfbXek2fK5d5LQw1R+I4hPMDMS1W1BneEJ/ZAMDYpWSoCu KxOylwogkWpsprzBxLbkYIAocgyavMjtsAq/1eCYmMf0siiMvxvE+IOWhZi+lMZeUZmyQL a0KdEcmyqSKriXfDSTFNsssRHOmFziRhyN73/RlZoAkZ2FCuagKUb07aqeN/B7X3aCPaqp 7dLmPC7Bsrtw6HJv8k63el4Ts52bb7Wtn1zWjE+YUDUnO8LrZUqzPxsV1Y6/mf5f7ADC9a piO1BjKs5onyfOjwp6nl1I4AF+T06Q8A1xOXv61RJzNcqf79PvMbWQSVFXFmFw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640371465; a=rsa-sha256; cv=none; b=CabKW0Bf8aunIshSUzO0klGuvNZGrKOeDGRdXJZKIHFaJR7SvHtqB769ekej1OhYt9/+14 uJ/HwBmAfwKbZbXxQKJGdOfiUxaRqgMx4p6j4D82U5E4rNGDJJKF4v0Ejs/qyRmP1wfPCr QA3aBe3TSRw2ov91fU8GBp91oSvS7OK2OjiicE0BIrQpXnOlUykBTwZIM/7kBsbJKlw5U4 FNKWdx4Dxev19ltVUlneTeY/eG4U4AaxC7geL3kNB9PlaWZr354rCux/Mn1OBHqRpj3tb0 bEW0iIZFfdwum8x9qRhSj6TA8tOPy1G5faZTK/5TsHS4UPC+ZPY6A0+6OihkVg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mmel: URL: https://cgit.FreeBSD.org/src/commit/?id=72a2f3b5e28ada60de01f08b28888f70eec0baed commit 72a2f3b5e28ada60de01f08b28888f70eec0baed Author: Michal Meloun AuthorDate: 2021-12-24 07:38:32 +0000 Commit: Michal Meloun CommitDate: 2021-12-24 18:42:01 +0000 extres/clk: Improve sysctl dump of clocks. Always recalculate the frequency, the cache is lazily initialized so it is not always up to date. While I'm in mark sysctl as MPSAFE. Discussed with: manu, adrian MFC after: 1 week --- sys/dev/extres/clk/clk.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/sys/dev/extres/clk/clk.c b/sys/dev/extres/clk/clk.c index b1522eb1d4c2..839f0f842a78 100644 --- a/sys/dev/extres/clk/clk.c +++ b/sys/dev/extres/clk/clk.c @@ -185,6 +185,7 @@ enum clknode_sysctl_type { CLKNODE_SYSCTL_PARENT, CLKNODE_SYSCTL_PARENTS_LIST, CLKNODE_SYSCTL_CHILDREN_LIST, + CLKNODE_SYSCTL_FREQUENCY, }; static int clknode_sysctl(SYSCTL_HANDLER_ARGS); @@ -403,7 +404,7 @@ clkdom_create(device_t dev) SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "clocks", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, clkdom, 0, clkdom_sysctl, "A", "Clock list for the domain"); @@ -624,7 +625,7 @@ clknode_create(struct clkdom * clkdom, clknode_class_t clknode_class, clknode->parent_idx = CLKNODE_IDX_NONE; if (replaced) - return (clknode); + return (clknode); sysctl_ctx_init(&clknode->sysctl_ctx); clknode_oid = SYSCTL_ADD_NODE(&clknode->sysctl_ctx, @@ -632,28 +633,31 @@ clknode_create(struct clkdom * clkdom, clknode_class_t clknode_class, OID_AUTO, clknode->name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "A clock node"); - SYSCTL_ADD_U64(&clknode->sysctl_ctx, + SYSCTL_ADD_PROC(&clknode->sysctl_ctx, SYSCTL_CHILDREN(clknode_oid), OID_AUTO, "frequency", - CTLFLAG_RD, &clknode->freq, 0, "The clock frequency"); + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, + clknode, CLKNODE_SYSCTL_FREQUENCY, clknode_sysctl, + "A", + "The clock frequency"); SYSCTL_ADD_PROC(&clknode->sysctl_ctx, SYSCTL_CHILDREN(clknode_oid), OID_AUTO, "parent", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, clknode, CLKNODE_SYSCTL_PARENT, clknode_sysctl, "A", "The clock parent"); SYSCTL_ADD_PROC(&clknode->sysctl_ctx, SYSCTL_CHILDREN(clknode_oid), OID_AUTO, "parents", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, clknode, CLKNODE_SYSCTL_PARENTS_LIST, clknode_sysctl, "A", "The clock parents list"); SYSCTL_ADD_PROC(&clknode->sysctl_ctx, SYSCTL_CHILDREN(clknode_oid), OID_AUTO, "childrens", - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, clknode, CLKNODE_SYSCTL_CHILDREN_LIST, clknode_sysctl, "A", "The clock childrens list"); @@ -1612,6 +1616,7 @@ clknode_sysctl(SYSCTL_HANDLER_ARGS) enum clknode_sysctl_type type = arg2; struct sbuf *sb; const char **parent_names; + uint64_t freq; int ret, i; clknode = arg1; @@ -1635,6 +1640,13 @@ clknode_sysctl(SYSCTL_HANDLER_ARGS) sbuf_printf(sb, "%s ", children->name); } break; + case CLKNODE_SYSCTL_FREQUENCY: + ret = clknode_get_freq(clknode, &freq); + if (ret == 0) + sbuf_printf(sb, "%ju ", (uintmax_t)freq); + else + sbuf_printf(sb, "Error: %d ", ret); + break; } CLK_TOPO_UNLOCK();