From owner-svn-src-all@freebsd.org Fri Jan 19 21:58:49 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E85F8ECADCD; Fri, 19 Jan 2018 21:58:49 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C3BE677DA7; Fri, 19 Jan 2018 21:58:49 +0000 (UTC) (envelope-from landonf@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 0FFBA133A6; Fri, 19 Jan 2018 21:58:49 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0JLwmUv030946; Fri, 19 Jan 2018 21:58:48 GMT (envelope-from landonf@FreeBSD.org) Received: (from landonf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0JLwmgL030944; Fri, 19 Jan 2018 21:58:48 GMT (envelope-from landonf@FreeBSD.org) Message-Id: <201801192158.w0JLwmgL030944@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: landonf set sender to landonf@FreeBSD.org using -f From: "Landon J. Fuller" Date: Fri, 19 Jan 2018 21:58:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328176 - in head/sys/dev/bhnd: cores/chipc/pwrctl siba X-SVN-Group: head X-SVN-Commit-Author: landonf X-SVN-Commit-Paths: in head/sys/dev/bhnd: cores/chipc/pwrctl siba X-SVN-Commit-Revision: 328176 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.25 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: Fri, 19 Jan 2018 21:58:50 -0000 Author: landonf Date: Fri Jan 19 21:58:48 2018 New Revision: 328176 URL: https://svnweb.freebsd.org/changeset/base/328176 Log: bhnd(4): fix a few bugs in pwrctl/fixed-clock device support. - Do not panic on siba(4) detach when the bhnd(4) bus calls bhnd_get_pmu_info() on a PMU-less device. - Fix bhnd_pwrctl attach/detach on fixed-clock devices: - Treat bhnd_pwrctl_updateclk() as a no-op on fixed-clock devices. - Use bhnd_pwrctl_updateclk() to perform the appropriate clock transition on detach. Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl.c head/sys/dev/bhnd/siba/siba.c Modified: head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl.c ============================================================================== --- head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl.c Fri Jan 19 21:56:22 2018 (r328175) +++ head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl.c Fri Jan 19 21:58:48 2018 (r328176) @@ -209,13 +209,13 @@ bhnd_pwrctl_detach(device_t dev) if ((error = bhnd_deregister_provider(dev, BHND_SERVICE_ANY))) return (error); + /* Update clock state */ PWRCTL_LOCK(sc); - - if ((error = bhnd_pwrctl_setclk(sc, BHND_CLOCK_DYN))) + error = bhnd_pwrctl_updateclk(sc, BHND_PWRCTL_WAR_DOWN); + PWRCTL_UNLOCK(sc); + if (error) return (error); - PWRCTL_UNLOCK(sc); - STAILQ_FOREACH_SAFE(clkres, &sc->clkres_list, cr_link, crnext) free(clkres, M_DEVBUF); @@ -343,6 +343,10 @@ bhnd_pwrctl_updateclk(struct bhnd_pwrctl_softc *sc, bh bhnd_clock clock; PWRCTL_LOCK_ASSERT(sc, MA_OWNED); + + /* Nothing to update on fixed clock devices */ + if (PWRCTL_QUIRK(sc, FIXED_CLK)) + return (0); /* Default clock target */ clock = BHND_CLOCK_DYN; Modified: head/sys/dev/bhnd/siba/siba.c ============================================================================== --- head/sys/dev/bhnd/siba/siba.c Fri Jan 19 21:56:22 2018 (r328175) +++ head/sys/dev/bhnd/siba/siba.c Fri Jan 19 21:58:48 2018 (r328176) @@ -170,9 +170,9 @@ siba_read_ivar(device_t dev, device_t child, int index case SIBA_PMU_PWRCTL: case SIBA_PMU_FIXED: - panic("bhnd_get_pmu_info() called with siba PMU state " - "%d", dinfo->pmu_state); - return (ENXIO); + *result = (uintptr_t)NULL; + SIBA_UNLOCK(sc); + return (0); } panic("invalid PMU state: %d", dinfo->pmu_state);