From owner-svn-src-head@freebsd.org Sat Dec 1 21:37:48 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 499D61328940; Sat, 1 Dec 2018 21:37:48 +0000 (UTC) (envelope-from cem@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 E5973757AE; Sat, 1 Dec 2018 21:37:47 +0000 (UTC) (envelope-from cem@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 A872C1D656; Sat, 1 Dec 2018 21:37:47 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wB1LblQr001623; Sat, 1 Dec 2018 21:37:47 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wB1Lbljo001622; Sat, 1 Dec 2018 21:37:47 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201812012137.wB1Lbljo001622@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Sat, 1 Dec 2018 21:37:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r341389 - head/sys/powerpc/cpufreq X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/sys/powerpc/cpufreq X-SVN-Commit-Revision: 341389 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E5973757AE X-Spamd-Result: default: False [0.82 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_SPAM_LONG(0.31)[0.307,0]; NEURAL_SPAM_MEDIUM(0.10)[0.096,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_SPAM_SHORT(0.42)[0.419,0] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Dec 2018 21:37:48 -0000 Author: cem Date: Sat Dec 1 21:37:47 2018 New Revision: 341389 URL: https://svnweb.freebsd.org/changeset/base/341389 Log: pmcr: Fix pstate setting on Power8 Fix p-state setting on Power8 by removing the accidental double-indirection of the pstate_ids table. The pstate_ids table comes from the OF property "ibm,pstate-ids." On Power9, the values happen to be identical to the indices, so the extra indirection was harmless. On Power8, the values were out of the range [0, npstates], so pmcr_set() would fail the spec[0] range check with EINVAL. While here, include both the value and index in the driver-specific register array as spec[0] and spec[1] respectively. They're redundant, but relatively harmless, and it may aid debugging. While here, fix the range check to exclude the index npstates, which is one past the last valid index. PR: 233693 Reported and tested by: sbruno Reviewed by: jhibbits Modified: head/sys/powerpc/cpufreq/pmcr.c Modified: head/sys/powerpc/cpufreq/pmcr.c ============================================================================== --- head/sys/powerpc/cpufreq/pmcr.c Sat Dec 1 21:28:05 2018 (r341388) +++ head/sys/powerpc/cpufreq/pmcr.c Sat Dec 1 21:37:47 2018 (r341389) @@ -174,6 +174,7 @@ pmcr_settings(device_t dev, struct cf_setting *sets, i for (i = 0; i < npstates; i++) { sets[i].freq = pstate_freqs[i]; sets[i].spec[0] = pstate_ids[i]; + sets[i].spec[1] = i; sets[i].dev = dev; } *count = npstates; @@ -189,13 +190,11 @@ pmcr_set(device_t dev, const struct cf_setting *set) if (set == NULL) return (EINVAL); - if (set->spec[0] < 0 || set->spec[0] > npstates) + if (set->spec[1] < 0 || set->spec[1] >= npstates) return (EINVAL); - pmcr = ((long)pstate_ids[set->spec[0]] << PMCR_LOWERPS_SHIFT) & - PMCR_LOWERPS_MASK; - pmcr |= ((long)pstate_ids[set->spec[0]] << PMCR_UPPERPS_SHIFT) & - PMCR_UPPERPS_MASK; + pmcr = ((long)set->spec[0] << PMCR_LOWERPS_SHIFT) & PMCR_LOWERPS_MASK; + pmcr |= ((long)set->spec[0] << PMCR_UPPERPS_SHIFT) & PMCR_UPPERPS_MASK; pmcr |= PMCR_VERSION_1; mtspr(SPR_PMCR, pmcr); @@ -228,6 +227,7 @@ pmcr_get(device_t dev, struct cf_setting *set) return (EINVAL); set->spec[0] = pstate; + set->spec[1] = i; set->freq = pstate_freqs[i]; set->dev = dev;