From owner-svn-src-all@freebsd.org Sun Jan 12 04:07:05 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 014E322277B; Sun, 12 Jan 2020 04:07:05 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47wNTN5W4hz3QS6; Sun, 12 Jan 2020 04:07:04 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 859B1DE4A; Sun, 12 Jan 2020 04:07:04 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00C473Zj078053; Sun, 12 Jan 2020 04:07:03 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00C473ea078052; Sun, 12 Jan 2020 04:07:03 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202001120407.00C473ea078052@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 12 Jan 2020 04:07:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356649 - head/sys/dev/extres/regulator X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/sys/dev/extres/regulator X-SVN-Commit-Revision: 356649 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 04:07:05 -0000 Author: kevans Date: Sun Jan 12 04:07:03 2020 New Revision: 356649 URL: https://svnweb.freebsd.org/changeset/base/356649 Log: regulator: small enhancements to regulator_shutdown Highlights: - Exit early if we're not disabling unused regulators; there's no need to take the regulator topology lock and re-evaluate this every iteration, as it's not going to change. - Don't emit a notice that we're shutting down a regulator if it's not enabled, to reduce noise. - Mention the outcome of the shutdown, to aide debugging and easily let developer/user collect list of regulators we actually shutdown to determine problematic one. Reviewed by: manu MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D22213 Modified: head/sys/dev/extres/regulator/regulator.c Modified: head/sys/dev/extres/regulator/regulator.c ============================================================================== --- head/sys/dev/extres/regulator/regulator.c Sun Jan 12 04:05:18 2020 (r356648) +++ head/sys/dev/extres/regulator/regulator.c Sun Jan 12 04:07:03 2020 (r356649) @@ -191,16 +191,36 @@ regulator_shutdown(void *dummy) int status, ret; int disable = 1; - REG_TOPO_SLOCK(); TUNABLE_INT_FETCH("hw.regulator.disable_unused", &disable); + if (!disable) + return; + REG_TOPO_SLOCK(); + + if (bootverbose) + printf("regulator: shutting down unused regulators\n"); TAILQ_FOREACH(entry, ®node_list, reglist_link) { - if (!entry->std_param.always_on && disable) { - if (bootverbose) - printf("regulator: shutting down %s\n", - entry->name); + if (!entry->std_param.always_on) { ret = regnode_status(entry, &status); - if (ret == 0 && status == REGULATOR_STATUS_ENABLED) - regnode_stop(entry, 0); + if (ret == 0 && status == REGULATOR_STATUS_ENABLED) { + if (bootverbose) + printf("regulator: shutting down %s... ", + entry->name); + ret = regnode_stop(entry, 0); + if (bootverbose) { + /* + * Call out busy in particular, here, + * because it's not unexpected to fail + * shutdown if the regulator is simply + * in-use. + */ + if (ret == EBUSY) + printf("busy\n"); + else if (ret != 0) + printf("error (%d)\n", ret); + else + printf("ok\n"); + } + } } } REG_TOPO_UNLOCK();