Received: by 10.192.165.156 with SMTP id m28csp1743961imm; Thu, 12 Apr 2018 02:45:35 -0700 (PDT) X-Google-Smtp-Source: AIpwx4//dDbd2GD3auuWrptpGOIz8hR7/XQSnvOqni6G8YcOp7dxPIbOIr+H/zGOGGFbAbfODcHJ X-Received: by 10.99.178.88 with SMTP id t24mr174599pgo.212.1523526335510; Thu, 12 Apr 2018 02:45:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523526335; cv=none; d=google.com; s=arc-20160816; b=csoO0wQys0ptt2E9wbZZP3Hwn0XtSS2uJN0Ihk7XGDCuTgFsBX/rnkwY4DHlTo2krT YZZrtTwjPctjnykPSxKt6A240Vp3ayjgHMxnd8xANxUEVleeLpCWJF8Qe5s3OFtUUGFp GD/OCvxZ7MY7h1ExEU9AmrSXtP9UKprFF0Vc8QJ4iuIz5ggrKgJAqj/NT34XFHShA6Dh 8j08IJAQSgoBY5i96m0Dz/xaa1/92AwPaozNXxpeetlxmlzP6f0tXaVk4ZAyhR6DpBVF kZFnPTHGlk8zCfJNy2zdRiSL1w/g56VUtHPwIcazJxH4bldVkV7coI0otlj7X9wbubl3 gkiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=2npB8YVU6nevr2q9BnJQnNnjL5zZsFuJhKGa1pEv9jw=; b=p2DlLrj3uvkKVIvZfq7p51KoD6YQI9ZsUw1i+/KxTzjFT68QDsPggM/HbaPhB83UNl hEXSptiZli2HdnlyiBtb4lj7BLZ50vxbYAr+47DEuCEeYz4zu0iQ5QWgQBIg/EUsy+Il OEux3JeOWpw3AfS7USYUQJPSad6w0lFbLha4NW7NYQG4MqLrjWWrOx+H5TMnNgYmiGml QQcTVASJAdmE74ycMAqsoAgxCm4mAF6oFfRW7VjkAt5L5SM9a30+kPKpCc27gEzUygMQ hYAd7J/1h/btL0+B74kgoWjIMRzxrh/Bpf3GUdRWBG/X3BqRJmish5Ypr2QEwHYkXm81 0xpg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u15-v6si2978178plq.392.2018.04.12.02.44.58; Thu, 12 Apr 2018 02:45:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752985AbeDLJkp (ORCPT + 99 others); Thu, 12 Apr 2018 05:40:45 -0400 Received: from 9pmail.ess.barracuda.com ([64.235.154.210]:40182 "EHLO 9pmail.ess.barracuda.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752972AbeDLJko (ORCPT ); Thu, 12 Apr 2018 05:40:44 -0400 Received: from MIPSMAIL01.mipstec.com (mailrelay.mips.com [12.201.5.28]) by mx1412.ess.rzc.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Thu, 12 Apr 2018 09:40:24 +0000 Received: from mredfearn-linux.mipstec.com (192.168.155.41) by MIPSMAIL01.mipstec.com (10.20.43.31) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 12 Apr 2018 02:40:05 -0700 From: Matt Redfearn To: James Hogan , Ralf Baechle , Florian Fainelli CC: , Matt Redfearn , Namhyung Kim , "Maciej W. Rozycki" , Peter Zijlstra , , "Paul Burton" , Ingo Molnar , Jiri Olsa , Alexander Shishkin , Arnaldo Carvalho de Melo Subject: [PATCH v2 6/6] MIPS: perf: Fix BMIPS5000 system mode counting Date: Thu, 12 Apr 2018 10:36:26 +0100 Message-ID: <1523525786-29153-7-git-send-email-matt.redfearn@mips.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523525786-29153-1-git-send-email-matt.redfearn@mips.com> References: <1523525786-29153-1-git-send-email-matt.redfearn@mips.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.155.41] X-BESS-ID: 1523525812-452060-21719-24429-10 X-BESS-VER: 2018.4.1-r1804052329 X-BESS-Apparent-Source-IP: 12.201.5.28 X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.191914 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS59374 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When perf is used in system mode, i.e. specifying a set of CPUs to count (perf -a -C cpu), event->cpu is set to the CPU number on which events should be counted. The current BMIPS500 variation of mipsxx_pmu_enable_event only over sets the counter to count the current CPU, so system mode does not work. Fix this by removing this BMIPS5000 specific path and integrating it with the generic one. Since BMIPS5000 uses specific extensions to the perf control register, different fields must be set up to count the relevant CPU. Signed-off-by: Matt Redfearn --- Changes in v2: New patch to fix BMIPS5000 system mode perf. Florian, I don't have access to a BMIPS5000 board, but from code inspection only I suspect this patch is necessary to have system mode work. If someone could test that would be appreciated. --- arch/mips/include/asm/mipsregs.h | 1 + arch/mips/kernel/perf_event_mipsxx.c | 17 ++++++----------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h index a4baaaa02bc8..3e1fbb7aaa2a 100644 --- a/arch/mips/include/asm/mipsregs.h +++ b/arch/mips/include/asm/mipsregs.h @@ -735,6 +735,7 @@ #define MIPS_PERFCTRL_MT_EN_TC (_ULCAST_(2) << 20) /* PerfCnt control register MT extensions used by BMIPS5000 */ +#define BRCM_PERFCTRL_VPEID(v) (_ULCAST_(1) << (12 + v)) #define BRCM_PERFCTRL_TC (_ULCAST_(1) << 30) /* PerfCnt control register MT extensions used by Netlogic XLR */ diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c index 389e346e9cf3..37cbb93aa521 100644 --- a/arch/mips/kernel/perf_event_mipsxx.c +++ b/arch/mips/kernel/perf_event_mipsxx.c @@ -366,16 +366,7 @@ static void mipsxx_pmu_enable_event(struct hw_perf_event *evt, int idx) /* Make sure interrupt enabled. */ MIPS_PERFCTRL_IE; -#ifdef CONFIG_CPU_BMIPS5000 - { - /* enable the counter for the calling thread */ - unsigned int vpe_id; - - vpe_id = smp_processor_id() & MIPS_CPUID_TO_COUNTER_MASK; - cpuc->saved_ctrl[idx] |= BIT(12 + vpe_id) | BRCM_PERFCTRL_TC; - } -#else -#ifdef CONFIG_MIPS_MT_SMP +#if defined(CONFIG_MIPS_MT_SMP) && !defined(CONFIG_CPU_BMIPS5000) if (range > V) { /* The counter is processor wide. Set it up to count all TCs. */ pr_debug("Enabling perf counter for all TCs\n"); @@ -392,12 +383,16 @@ static void mipsxx_pmu_enable_event(struct hw_perf_event *evt, int idx) */ cpu = (event->cpu >= 0) ? event->cpu : smp_processor_id(); +#if defined(CONFIG_CPU_BMIPS5000) + ctrl = BRCM_PERFCTRL_VPEID(cpu & MIPS_CPUID_TO_COUNTER_MASK); + ctrl |= BRCM_PERFCTRL_TC; +#else ctrl = M_PERFCTL_VPEID(cpu_vpe_id(&cpu_data[cpu])); ctrl |= M_TC_EN_VPE; +#endif cpuc->saved_ctrl[idx] |= ctrl; pr_debug("Enabling perf counter for CPU%d\n", cpu); } -#endif /* CONFIG_CPU_BMIPS5000 */ /* * We do not actually let the counter run. Leave it until start(). */ -- 2.7.4