From nobody Thu Jan 20 10:17:42 2022 X-Original-To: dev-commits-src-branches@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 D7785196ABFF; Thu, 20 Jan 2022 10:17:42 +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 4Jfdjy5gwKz4ZQL; Thu, 20 Jan 2022 10:17:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642673862; 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=5YMpwwUQEe0KKBn/eD8lnY7Ps5EMWwBN5XsWyDPzNhc=; b=OwngqkSIR084jXqMjTje6y7qWdLg0oNZv3zaokn8l6dcCEM1opqQF43phUowZ85jJUkRbZ 9tkRliDMqHOeYHCnofdEXEVAllphTxTioBoQ9LP17iyE3XI+JsyYQoD06j3MELLEEv6Y7J YqE6tdB9KXZ2Zmth9bUXOS/Yf09ABpxROmlutYUOkbz+fkrc+Y/XDjU9ZZVnyQhnFUfDp0 5Q5K6bSFEHgv7agjY34yTOu/Xv1MCdUU6niQAHBpsD6QFkrQbcq1YHMRjEYm2bxZJGI5fA zc6Xvy1t3/AZtoOSSkJYvXe8/9PqiD/7aWVRYir7Mus825Hvq7h2n/0s48qhog== 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 A3614264EF; Thu, 20 Jan 2022 10:17:42 +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 20KAHgMu005260; Thu, 20 Jan 2022 10:17:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20KAHgOW005259; Thu, 20 Jan 2022 10:17:42 GMT (envelope-from git) Date: Thu, 20 Jan 2022 10:17:42 GMT Message-Id: <202201201017.20KAHgOW005259@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michal Meloun Subject: git: 3d4b9e5fa16a - stable/13 - extres/clk: Improve sysctl dump of clocks. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 3d4b9e5fa16a7e7e72fb2573affb6365e5ba251e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642673862; 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=5YMpwwUQEe0KKBn/eD8lnY7Ps5EMWwBN5XsWyDPzNhc=; b=bLr3IW5IcoyEPCiqmlRY+Ytn5QofDqMfM+q4eDdxoBuf08H3YjpbdbTLTg2B0W5BAp4BNz NtCu7bpFehuH+Z6BpWDFIJZMDX+0i8J+ODqDJoIwbWSepingH1l/Q9oFL1kXUMI2G6TYmc eCjI1CZSP9DUND0xLfOEwB0tbMNFhvkBwHjHy7xJ7XOeXy3QbaRge3hMsXNo6f26XPVBeO Qje3vbRJICga8KhdHCzBeJAh11fq7JF1MzwnhwnUGpMPcDdJ6xk0Yp93qKRcuzE3tmagNs NPyb8tT7OBFW+WV1zXZYjMjHabESXQ3q6jil7k76dP6+9g/qWbltULH3WybjVQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642673862; a=rsa-sha256; cv=none; b=GcM1/Fi9g/kpZPqatqO7IX1BkO5saKx87xYPaDTHkI0KvMSfnXinfLQNH9NaU1RZl2tHHx FQP2x9Tyz3bXkzzKwLRFyxz8G0vsDIFWtccfEhMIXTINZhpLhkqLvaRdB7QSfFGySqrarZ 2UucFve+kVbkLFCv0UhW7QICKSIxh7gHkgFp0qZ8WJmuwCHkz22kmRsg7Smfp8S3f2LlTS CXcAoEHjEFbNj6TCSGiWPI+PB2Jm1zGuYZE6TdhtcC8X5n3Gn7aC1GgzJdOOxCl1xXqdve 8skszI9h4B9EzqtfOklzBcHQTv4vybh6DpUuBlU9S8C9CAQNIygk4Hz77n2IlA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mmel: URL: https://cgit.FreeBSD.org/src/commit/?id=3d4b9e5fa16a7e7e72fb2573affb6365e5ba251e commit 3d4b9e5fa16a7e7e72fb2573affb6365e5ba251e Author: Michal Meloun AuthorDate: 2021-12-24 07:38:32 +0000 Commit: Michal Meloun CommitDate: 2022-01-20 10:14:04 +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 (cherry picked from commit 72a2f3b5e28ada60de01f08b28888f70eec0baed) --- 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();