Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757246AbdLQDEH (ORCPT ); Sat, 16 Dec 2017 22:04:07 -0500 Received: from mail-ua0-f194.google.com ([209.85.217.194]:35499 "EHLO mail-ua0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757022AbdLQDEE (ORCPT ); Sat, 16 Dec 2017 22:04:04 -0500 X-Google-Smtp-Source: ACJfBou4WGMyrz2MZtdKBoz1nVvpYb3BXc7h4ENn4MmA7mAroMQLaDj17vvmqzuztBF34Kk9Yto9qrBKOxiNEQzb8sg= MIME-Version: 1.0 In-Reply-To: <1513148261-21097-2-git-send-email-ego@linux.vnet.ibm.com> References: <1513148261-21097-1-git-send-email-ego@linux.vnet.ibm.com> <1513148261-21097-2-git-send-email-ego@linux.vnet.ibm.com> From: Balbir Singh Date: Sun, 17 Dec 2017 14:04:03 +1100 Message-ID: Subject: Re: [v3 PATCH 1/3] powernv-cpufreq: Add helper to extract pstate from PMSR To: "Gautham R. Shenoy" Cc: Shilpasri G Bhat , Viresh Kumar , "Rafael J. Wysocki" , huntbag@linux.vnet.ibm.com, Akshay Adiga , Michael Ellerman , Vaidyanathan Srinivasan , linux-pm@vger.kernel.org, "linux-kernel@vger.kernel.org" , "open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1608 Lines: 39 On Wed, Dec 13, 2017 at 5:57 PM, Gautham R. Shenoy wrote: > From: "Gautham R. Shenoy" > > On POWERNV platform, the fields for pstates in the Power Management > Status Register (PMSR) and the Power Management Control Register > (PMCR) are 8-bits wide. On POWER8 the pstates are negatively numbered > while on POWER9 they are positively numbered. > > The device-tree exports pstates as 32-bit entries. The device-tree > implementation sign-extends the 8-bit pstate values to obtain the > corresponding 32-bit entry. > > Eg: On POWER8, a pstate value 0x82 [-126] is represented in the > device-tree as 0xfffffff82 while on POWER9, the same value 0x82 [130] > is represented in the device-tree as 0x00000082. > > The powernv-cpufreq driver implementation represents pstates using the > integer type. In multiple places in the driver, the code interprets > the pstates extracted from the PMSR as a signed byte and assigns it to > a integer variable to get the sign-extention. > > On POWER9 platforms which have greater than 128 pstates, this results > in the driver performing incorrect sign-extention, and thereby > treating a legitimate pstate (say 130) as an invalid pstates (since it > is interpreted as -126). > > This patch fixes the issue by implementing a helper function to > extract Pstates from PMSR register, and correctly sign-extend it to be > consistent with the values provided by the device-tree. > > Signed-off-by: Gautham R. Shenoy > --- This looks better Acked-by: Balbir Singh Balbir Singh