Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2489481pxj; Mon, 10 May 2021 04:20:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPa/DeMFO1XW39zDK2yU66FS94CII7ficQx9B0yL1wGSnen9nen1dbPmUN1jslwqYsGCPm X-Received: by 2002:a5d:8b09:: with SMTP id k9mr17268563ion.185.1620645640726; Mon, 10 May 2021 04:20:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620645640; cv=none; d=google.com; s=arc-20160816; b=DuY5gO5as1fXhY2ECTiJn6yHLGYwA7Xwtwgsk2KL6ZkoLFAYpgqcOV86yrTG/ptBcT ulYAh3R1v90TeBFORIdgsc215y106679wCcb396Gqj38bjxtFX5L5r/JqSUIOJ5/Rt/5 9fjFCM6ugNt1b0F7NLGwM83eyDvhiPl/hJd3TEkykcoC4EktyJNfg4emaaWYshhkLq4P ehvnEkY0wEOOwE6c1QUtWRpeAFLPGGdOXzZ4+KsNXomTiGc56CeDAeSwOjNCwgjLLybS hI8NfqRQ3zh53U1QkhrBkSrR7QX/xFDsxCQF8YXa5Yu5Yq/Za5Bnunw9KjSxVbw2h9he 90Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XloDghYCdmz33CoGEGnljrON8kgIp7js5GQGs5Iv1DQ=; b=kReTyIuXbDe+RyUbisAbLjvURC6PvXFXzohFnBW2Kd7EVriP/4ZC59jVbbSoEAoKp8 jKVhfA7Ll7bHDJQXAKGNpXLNvkw/H2XX3h4QAM2dx+IT6U9LECwjfHSPVR4S/lOZyszw 52gfnyZNBG1C6GSRnockB+SEmuomBjNe1tDSbsGQEMHh6/XCIz299d+8LjYioU/Nbc7A 7RaNcQJFu+DRZUk/1ylwfbf8JlTlPl9Y3Gvm+wYTLAEd4NxB38oZ8WNQVVRVVay7fnLu cey/OSTKEU2WxYzRdvHjillGFcoLSJufFLl2ukWQnozp8jhEjZxWxpn82ZjEKJQdMY2X LWGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pCSfpDBm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o7si12146520ill.156.2021.05.10.04.20.27; Mon, 10 May 2021 04:20:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pCSfpDBm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237486AbhEJLPO (ORCPT + 99 others); Mon, 10 May 2021 07:15:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:33618 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233720AbhEJKuc (ORCPT ); Mon, 10 May 2021 06:50:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8C1B261959; Mon, 10 May 2021 10:40:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643205; bh=C6LzDeT77xCN7lbU3u03G5Ls4LwvgmbO3cY/DTI8pvE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pCSfpDBm2s+OJdDhuBhQWdPfpr7XVWCMwZ7JVGr8yMATYiNVAQ4XckHj9yxvzP7EG MNhilyjJIa5QEOUdQl6wz3me07vyBoJuIhwbYiG/4bfqe08SfGnAUjOszJr/sfVh9Y bOs1FMUa/N1TirWZqEcsC5LU3PVYIm+cY1G2kS5c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, youling257 , Kurt Garloff , Bingsong Si , "Artem S. Tashkinov" , Bas Nieuwenhuizen , Chen Yu , Len Brown , Salvatore Bonaccorso , Terry Bowman Subject: [PATCH 5.10 220/299] tools/power/turbostat: Fix turbostat for AMD Zen CPUs Date: Mon, 10 May 2021 12:20:17 +0200 Message-Id: <20210510102012.205604433@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bas Nieuwenhuizen commit 301b1d3a9104f4f3a8ab4171cf88d0f55d632b41 upstream. It was reported that on Zen+ system turbostat started exiting, which was tracked down to the MSR_PKG_ENERGY_STAT read failing because offset_to_idx wasn't returning a non-negative index. This patch combined the modification from Bingsong Si and Bas Nieuwenhuizen and addd the MSR to the index system as alternative for MSR_PKG_ENERGY_STATUS. Fixes: 9972d5d84d76 ("tools/power turbostat: Enable accumulate RAPL display") Reported-by: youling257 Tested-by: youling257 Tested-by: Kurt Garloff Tested-by: Bingsong Si Tested-by: Artem S. Tashkinov Co-developed-by: Bingsong Si Co-developed-by: Terry Bowman Signed-off-by: Bas Nieuwenhuizen Reviewed-by: Chen Yu Signed-off-by: Len Brown Cc: Salvatore Bonaccorso Signed-off-by: Greg Kroah-Hartman --- tools/power/x86/turbostat/turbostat.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -297,7 +297,10 @@ int idx_to_offset(int idx) switch (idx) { case IDX_PKG_ENERGY: - offset = MSR_PKG_ENERGY_STATUS; + if (do_rapl & RAPL_AMD_F17H) + offset = MSR_PKG_ENERGY_STAT; + else + offset = MSR_PKG_ENERGY_STATUS; break; case IDX_DRAM_ENERGY: offset = MSR_DRAM_ENERGY_STATUS; @@ -326,6 +329,7 @@ int offset_to_idx(int offset) switch (offset) { case MSR_PKG_ENERGY_STATUS: + case MSR_PKG_ENERGY_STAT: idx = IDX_PKG_ENERGY; break; case MSR_DRAM_ENERGY_STATUS: @@ -353,7 +357,7 @@ int idx_valid(int idx) { switch (idx) { case IDX_PKG_ENERGY: - return do_rapl & RAPL_PKG; + return do_rapl & (RAPL_PKG | RAPL_AMD_F17H); case IDX_DRAM_ENERGY: return do_rapl & RAPL_DRAM; case IDX_PP0_ENERGY: