From patchwork Wed Apr 6 07:44:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 8759021 Return-Path: X-Original-To: patchwork-linux-hwmon@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 87966C0553 for ; Wed, 6 Apr 2016 07:59:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 427BD20149 for ; Wed, 6 Apr 2016 07:59:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3288B2013A for ; Wed, 6 Apr 2016 07:59:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754146AbcDFH7m (ORCPT ); Wed, 6 Apr 2016 03:59:42 -0400 Received: from mail-bn1on0091.outbound.protection.outlook.com ([157.56.110.91]:6756 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753843AbcDFH7l (ORCPT ); Wed, 6 Apr 2016 03:59:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=pUHxNk2YKnhD5OlFDO/+Dp4jTYxAai0lF5NybnZbO/A=; b=tmg36fusA60JhTVGyOZtm1hqUlmd9m8YGBspL2RPmvEUcG4xCI28rOkIDxGZ6zjE379yYBfwnp2bqH5FgcYub1OyvdOh3QCio9/UX4xfEYQOOalGGk8ovVunyJw/tm9arRjJ66zjlKwus+ciIs/FCngjNILxnIko/pd2fbxnKAs= Received: from BN1PR12CA0042.namprd12.prod.outlook.com (10.160.77.52) by CY1PR12MB0714.namprd12.prod.outlook.com (10.163.238.20) with Microsoft SMTP Server (TLS) id 15.1.447.15; Wed, 6 Apr 2016 07:44:03 +0000 Received: from DM3NAM03FT027.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::202) by BN1PR12CA0042.outlook.office365.com (2a01:111:e400:49::52) with Microsoft SMTP Server (TLS) id 15.1.447.15 via Frontend Transport; Wed, 6 Apr 2016 07:44:03 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.222) smtp.mailfrom=amd.com; alien8.de; dkim=none (message not signed) header.d=none; alien8.de; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from atltwp02.amd.com (165.204.84.222) by DM3NAM03FT027.mail.protection.outlook.com (10.152.82.190) with Microsoft SMTP Server id 15.1.453.6 via Frontend Transport; Wed, 6 Apr 2016 07:44:02 +0000 X-WSS-ID: 0O57C59-08-2GG-02 X-M-MSG: Received: from satlvexedge02.amd.com (satlvexedge02.amd.com [10.177.96.29]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by atltwp02.amd.com (Axway MailGate 5.3.1) with ESMTPS id 24FF2D1601A; Wed, 6 Apr 2016 03:43:56 -0400 (EDT) Received: from SATLEXDAG06.amd.com (10.181.40.13) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 6 Apr 2016 02:44:33 -0500 Received: from SCYBEXDAG03.amd.com (10.34.11.13) by satlexdag06.amd.com (10.181.40.13) with Microsoft SMTP Server (TLS) id 14.3.266.1; Wed, 6 Apr 2016 03:43:58 -0400 Received: from hr-ub.amd.com (10.237.74.43) by SCYBEXDAG03.amd.com (10.34.11.13) with Microsoft SMTP Server id 14.3.266.1; Wed, 6 Apr 2016 15:43:52 +0800 From: Huang Rui To: Guenter Roeck , Jean Delvare CC: , , "Borislav Petkov" , Sherry Hurwitz , Huang Rui Subject: [PATCH v6 5/6] hwmon: (fam15h_power) Add documentation for TDP and accumulated power algorithm Date: Wed, 6 Apr 2016 15:44:14 +0800 Message-ID: <1459928655-6071-6-git-send-email-ray.huang@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1459928655-6071-1-git-send-email-ray.huang@amd.com> References: <1459928655-6071-1-git-send-email-ray.huang@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.222; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(428002)(199003)(189002)(5001770100001)(50226001)(586003)(50466002)(81166005)(1220700001)(36756003)(105586002)(2906002)(77096005)(48376002)(19580405001)(4326007)(53416004)(19580395003)(5003940100001)(2950100001)(1096002)(87936001)(86362001)(11100500001)(229853001)(101416001)(92566002)(76176999)(189998001)(5008740100001)(50986999)(5003600100002)(106466001)(33646002)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0714; H:atltwp02.amd.com; FPR:; SPF:None; MLV:sfv; A:1; MX:1; LANG:en; X-MS-Office365-Filtering-Correlation-Id: f4a18605-e67b-444a-36c3-08d35def3958 X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0714; 2:0L6taTHoGn0toREEAXY5sB9oj6ZaHPoedlvtYl7wnKD/WOPEIsIrG1CaABk1oNQl2pVUX1WwXCiCt/ysNC0ERTTsuuCyYRK0lnI44tqq3F8IEVn5fvMKpEZ8joc9Va/sDtsaCOzzGSN+bH8gEIMccwwCpmrCLpX75R+Pgt65P6HMNReqRn4ns2ZGpaBqi/AA; 3:iKqUmEVUh7Bat7d0Xib6V6BreiagNZvx7I1N6JhWBeMU5ik8/vSRBpkgw0vKMBQMzdrMrugOWP73V8qo33BwbIwd1fc7PS8uNktiCCjHePR/vvRfn8FLNldykrv2NKtTN0g8m7o/c8kCBUBZNZbVm4i+1Nk08jC76iB0cx+m16gqrPVNdg2ZzeKAvosxUgzyDLsXRrkVQXwgYVnoDp+HwuB8X6tmybENuv9/MKkaIoI= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR12MB0714; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0714; 25:MAsscuvVwONiYKGwgVjKBhbqZnAhe9Sg+gn7xI+j0fEVuye67jKg9rVBc1jEBAJtfIsMizXnyDgepdj0rPsuSB2gCKmg6r72bSy2SIM6VrEwVcnhJQ55l/QwH48LPyoSckpeghz7EiXpZFzP7aDArjT8rnzEWU1WUh2FQW9LR+hca7mKR1wnyqBdvufFoo1LGFGyM0EG/RujkBwk0o34FQQrmMj0ZPXsPcVcpsP/krGMGRdtUnWw0ilH/RqFy4nuZjQcHzEOsCU4A5eRJYgAAflMD7diVfK7KKsVtxQ3QouEQ0KOOxxK/LQz9JE7SPtWaQJz2wlavbbkSnzxonIdrP/AIsz0dtYOVqKvX7A8P0i9w99WlqulEOxdOwzh/pSCHcovbIF5GX5F7jV8bVzY3OlQQ0gb2ctVkC6iXWJ95AggiSHGMUQpQr8XXZUnxVn6uX59qOK+VMTtEXn4K69k3x0wH9fvHMqa/5IOQ8HWcA3N/cX2eIIC+UYkxrxYBsldO9oL8vVjTOWC0AuhXP9fE32ZZJjvNimkL/5Rh9hTOKh/704leQ1hfsn4JyFSENz/ictvJSYPQPhdf2U6BkzsQlM15GxK3r22Pk31C8f3k5i87v70uDRAZh7WD8iBIq/h X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0714; 20:deka2tReNog2gLzV2x6lT29WW8F/dQGZKKiUOpKFLYetecB86pwHxej+MDYAOCG3shSo6yRMFHldP8lDffGi/MxPbSpGR5tow+Qwf8Vf9YxFaUyvycxPUqmlc4tfp63cb3xkgrDMXXRyU1AY/lSFmgh9hqrsPYcJJZM+nYJPE8kvKkw0IlH8sdhjO7QHtHbh9akl75hXMXXTMII5vxeFx5Xc4vfu49R/T3mxIwhaTwjzet+89+Ocp5d5mXoXvJg4/mg710XRd0GCiMfc15BFNMXjLs/AneyzO9Fro+bhy725RYaUoCHDzp9E8HnwsxnEvxOjky5tyVCe+BwskKBQ7TRFCPz1zdNu96XmSlYEnTDvPgSFgJ1BMXBY52C2zP0YQyBvFdw6t9JXf26QqmNeVrKkc69dUVaQwdJN+zzssGL6HC811y+yVFHvdGFkwn1VcUZiipjM1gGw4ax0QoK5pvs1e44AcTyQFIdH/KRMpLmoBpLUEE3mLbOR+3MBcjpy X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13017025)(8121501046)(13024025)(13015025)(13023025)(5005006)(13018025)(10201501046)(3002001); SRVR:CY1PR12MB0714; BCL:0; PCL:0; RULEID:; SRVR:CY1PR12MB0714; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0714; 4:0/7ztThf0kkqk3uVSnkd/xwRYxvHvAn2yF+Bg9mASesqG4M/9FlMKDl3pcUKJLp6wcTVCU5rkO2YSoF1yB/n7fqjZU71k1lmZ+0hP6cKOJ8FpwGyRnEAQdHOpKfNLN/Fb0huv+iiGFJH6yMC+s+bAa08LSKXGY60/poMJ4bOPB4YoC5uZmDwqJqE8kcpPrFEmuCQGyP3fzc6M5jCykOSArzgglQsB8cY+dV6Sb5kRzfXT1OBZS9KI3JhEjcfcTxSPNpT/Wwbzez/GGkgqvGZ4UyWZ0e8xER2SsSk3VeGDBn7Lz9FyYzgnJxGqTC7QKfrXzJTzgRqAH1WMj3LtAdPo8WajQaSPv89SE0M/dgc717LCUyvsl4T7oKLWgT2JVDpbGHAk0uuy8an1VLXOuF2+ODJkIMh35KtvBsJD6caLILEjVHjt9BEq3sgzPqmhzrDcrt421VluIOjWVaL+wqQ4g== X-Forefront-PRVS: 0904004ECB X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR12MB0714; 23:lG0WVlE5lTgcu0AxiNySOuY6TpP0vXXvdzS+Md0D5?= =?us-ascii?Q?ebmlTfk0+OWX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S?= =?us-ascii?Q?/InuPSgUmXavft7iY2Gr6z4v/0jBUe74k422hcNH6Vq4Wg1UYAK6Cbg+APPi?= =?us-ascii?Q?rItJuiqw/CEwSeWvfLAAbD7?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0714; 5:UMgPK1JuLY7qTenxg/IhYenKOnnDfxwhzKJ6a0DOEHcXe3QUq81fjUrk6WKLZBBfVgv5iQtS9JGmqCq+HDc/YvseevtHBAitgzGtvl+ZgFWDJy0A94xBR9ao9LXY0UVZIvQx+z/UbFsEGN03hghUFw==; 24:onRLRVJ3KT1MKahADvlzas5Ft88KyHmo4yB5qwVWsXswaau7arl4Xhecs+RpPFRg5ni/Z0KjbjE34TSRaI5rfIlm2BnITlcAOF+XJ+iLYV8=; 20:DwVSQtQbVfKK0e7KQLp1UFpEF9UtRNZtGleMLJ/QAjrH+JEIwGmwXQ6liV2PUuA8id7/4XDoU+wm4wHrsuzkmuS51ZOF5pHfsdi6kFArVmTtWgekhqw8RYY/FpOWrAGFLXFQlxmG0lEmSDZLNkahgPRkW4jIQhHF1fxGDO+AIneKZLkt8YmCdJJD5k/588EQhtxdq5NZtHE8vBS3PQjCUzRZIJR3TfNQYaRWEQ4bv9YoFAUIFINnHUWkikgN9FRu SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2016 07:44:02.5333 (UTC) X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.222]; Helo=[atltwp02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0714 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds the description to explain the TDP reporting mechanism and accumulated power algorithm. Signed-off-by: Huang Rui Cc: Borislav Petkov --- Documentation/hwmon/fam15h_power | 65 +++++++++++++++++++++++++++++++++++++++- drivers/hwmon/fam15h_power.c | 2 +- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/Documentation/hwmon/fam15h_power b/Documentation/hwmon/fam15h_power index e2b1b69..fb594c2 100644 --- a/Documentation/hwmon/fam15h_power +++ b/Documentation/hwmon/fam15h_power @@ -10,14 +10,22 @@ Supported chips: Datasheets: BIOS and Kernel Developer's Guide (BKDG) For AMD Family 15h Processors BIOS and Kernel Developer's Guide (BKDG) For AMD Family 16h Processors + AMD64 Architecture Programmer's Manual Volume 2: System Programming Author: Andreas Herrmann Description ----------- +1) Processor TDP (Thermal design power) + +Given a fixed frequency and voltage, the power consumption of a +processor varies based on the workload being executed. Derated power +is the power consumed when running a specific application. Thermal +design power (TDP) is an example of derated power. + This driver permits reading of registers providing power information -of AMD Family 15h and 16h processors. +of AMD Family 15h and 16h processors via TDP algorithm. For AMD Family 15h and 16h processors the following power values can be calculated using different processor northbridge function @@ -37,3 +45,58 @@ This driver provides ProcessorPwrWatts and CurrPwrWatts: On multi-node processors the calculated value is for the entire package and not for a single node. Thus the driver creates sysfs attributes only for internal node0 of a multi-node processor. + +2) Accumulated Power Mechanism + +This driver also introduces an algorithm that should be used to +calculate the average power consumed by a processor during a +measurement interval Tm. The feature of accumulated power mechanism is +indicated by CPUID Fn8000_0007_EDX[12]. + +* Tsample: compute unit power accumulator sample period +* Tref: the PTSC counter period +* PTSC: performance timestamp counter +* N: the ratio of compute unit power accumulator sample period to the + PTSC period +* Jmax: max compute unit accumulated power which is indicated by + MaxCpuSwPwrAcc MSR C001007b +* Jx/Jy: compute unit accumulated power which is indicated by + CpuSwPwrAcc MSR C001007a +* Tx/Ty: the value of performance timestamp counter which is indicated + by CU_PTSC MSR C0010280 +* PwrCPUave: CPU average power + +i. Determine the ratio of Tsample to Tref by executing CPUID Fn8000_0007. + N = value of CPUID Fn8000_0007_ECX[CpuPwrSampleTimeRatio[15:0]]. + +ii. Read the full range of the cumulative energy value from the new +MSR MaxCpuSwPwrAcc. + Jmax = value returned. +iii. At time x, SW reads CpuSwPwrAcc MSR and samples the PTSC. + Jx = value read from CpuSwPwrAcc and Tx = value read from +PTSC. + +iv. At time y, SW reads CpuSwPwrAcc MSR and samples the PTSC. + Jy = value read from CpuSwPwrAcc and Ty = value read from +PTSC. + +v. Calculate the average power consumption for a compute unit over +time period (y-x). Unit of result is uWatt. + if (Jy < Jx) // Rollover has occurred + Jdelta = (Jy + Jmax) - Jx + else + Jdelta = Jy - Jx + PwrCPUave = N * Jdelta * 1000 / (Ty - Tx) + +This driver provides PwrCPUave and interval(default is 10 millisecond +and maximum is 1 second): +* power1_average (PwrCPUave) +* power1_average_interval (Interval) + +The power1_average_interval can be updated at /etc/sensors3.conf file +as below: + +chip "fam15h_power-*" + set power1_average_interval 0.01 + +Then save it with "sensors -s". diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c index 5abbfa8..7d9d697 100644 --- a/drivers/hwmon/fam15h_power.c +++ b/drivers/hwmon/fam15h_power.c @@ -1,7 +1,7 @@ /* * fam15h_power.c - AMD Family 15h processor power monitoring * - * Copyright (c) 2011 Advanced Micro Devices, Inc. + * Copyright (c) 2011-2016 Advanced Micro Devices, Inc. * Author: Andreas Herrmann * *