From patchwork Thu Jan 5 12:37:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: maddy X-Patchwork-Id: 711378 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tvS0l3Zr9z9sQw for ; Thu, 5 Jan 2017 23:39:03 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3tvS0l2mMpzDqT6 for ; Thu, 5 Jan 2017 23:39:03 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3tvRzd0DRrzDqP7 for ; Thu, 5 Jan 2017 23:38:04 +1100 (AEDT) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id v05CYKVU006587 for ; Thu, 5 Jan 2017 07:38:02 -0500 Received: from e23smtp02.au.ibm.com (e23smtp02.au.ibm.com [202.81.31.144]) by mx0a-001b2d01.pphosted.com with ESMTP id 27sg761xdm-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 05 Jan 2017 07:38:02 -0500 Received: from localhost by e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Jan 2017 22:37:59 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp02.au.ibm.com (202.81.31.208) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 5 Jan 2017 22:37:58 +1000 Received: from d23relay07.au.ibm.com (d23relay07.au.ibm.com [9.190.26.37]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 15CF53578057 for ; Thu, 5 Jan 2017 23:37:58 +1100 (EST) Received: from d23av06.au.ibm.com (d23av06.au.ibm.com [9.190.235.151]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v05CbwVA23330878 for ; Thu, 5 Jan 2017 23:37:58 +1100 Received: from d23av06.au.ibm.com (localhost [127.0.0.1]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v05CbvSJ016548 for ; Thu, 5 Jan 2017 23:37:57 +1100 Received: from SrihariSrinidhi.in.ibm.com (sriharisrinidhi.in.ibm.com [9.121.0.140]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v05CbtNp016460; Thu, 5 Jan 2017 23:37:56 +1100 From: Madhavan Srinivasan To: mpe@ellerman.id.au Subject: [PATCH v2 1/2] powerpc/perf: Factor out bhrb functions Date: Thu, 5 Jan 2017 18:07:52 +0530 X-Mailer: git-send-email 2.7.4 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17010512-0004-0000-0000-000001D081D9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17010512-0005-0000-0000-0000096F53A6 Message-Id: <1483619873-13899-1-git-send-email-maddy@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-01-05_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1701050199 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Madhavan Srinivasan , linuxppc-dev@lists.ozlabs.org, khandual@linux.vnet.ibm.com Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Factor out the bhrb functions to "isa207-common.c" to share with power9 DD1. Only code movement and no logic change Signed-off-by: Madhavan Srinivasan --- Changelog v1: 1)Updates to commit messages arch/powerpc/perf/isa207-common.c | 41 ++++++++++++++++++++++++++++++++ arch/powerpc/perf/isa207-common.h | 9 +++++++ arch/powerpc/perf/power8-pmu.c | 49 ++------------------------------------- arch/powerpc/perf/power9-pmu.c | 4 ++-- 4 files changed, 54 insertions(+), 49 deletions(-) diff --git a/arch/powerpc/perf/isa207-common.c b/arch/powerpc/perf/isa207-common.c index 50e598cf644b..ee4e3e89c04c 100644 --- a/arch/powerpc/perf/isa207-common.c +++ b/arch/powerpc/perf/isa207-common.c @@ -338,3 +338,44 @@ void isa207_disable_pmc(unsigned int pmc, unsigned long mmcr[]) if (pmc <= 3) mmcr[1] &= ~(0xffUL << MMCR1_PMCSEL_SHIFT(pmc + 1)); } + +u64 isa207_bhrb_filter_map(u64 branch_sample_type) +{ + u64 pmu_bhrb_filter = 0; + + /* BHRB and regular PMU events share the same privilege state + * filter configuration. BHRB is always recorded along with a + * regular PMU event. As the privilege state filter is handled + * in the basic PMC configuration of the accompanying regular + * PMU event, we ignore any separate BHRB specific request. + */ + + /* No branch filter requested */ + if (branch_sample_type & PERF_SAMPLE_BRANCH_ANY) + return pmu_bhrb_filter; + + /* Invalid branch filter options - HW does not support */ + if (branch_sample_type & PERF_SAMPLE_BRANCH_ANY_RETURN) + return -1; + + if (branch_sample_type & PERF_SAMPLE_BRANCH_IND_CALL) + return -1; + + if (branch_sample_type & PERF_SAMPLE_BRANCH_CALL) + return -1; + + if (branch_sample_type & PERF_SAMPLE_BRANCH_ANY_CALL) { + pmu_bhrb_filter |= MMCRA_IFM1; + return pmu_bhrb_filter; + } + + /* Every thing else is unsupported */ + return -1; +} + +void isa207_config_bhrb(u64 pmu_bhrb_filter) +{ + /* Enable BHRB filter in PMU */ + mtspr(SPRN_MMCRA, (mfspr(SPRN_MMCRA) | pmu_bhrb_filter)); +} + diff --git a/arch/powerpc/perf/isa207-common.h b/arch/powerpc/perf/isa207-common.h index 90495f1580c7..e5e4182731da 100644 --- a/arch/powerpc/perf/isa207-common.h +++ b/arch/powerpc/perf/isa207-common.h @@ -244,6 +244,12 @@ #define MMCRA_SDAR_MODE_TLB (1ull << MMCRA_SDAR_MODE_SHIFT) #define MMCRA_IFM_SHIFT 30 +/* MMCRA IFM bits */ +#define MMCRA_IFM1 0x0000000040000000UL +#define MMCRA_IFM2 0x0000000080000000UL +#define MMCRA_IFM3 0x00000000C0000000UL + + /* MMCR1 Threshold Compare bit constant for power9 */ #define p9_MMCRA_THR_CMP_SHIFT 45 @@ -261,4 +267,7 @@ int isa207_compute_mmcr(u64 event[], int n_ev, struct perf_event *pevents[]); void isa207_disable_pmc(unsigned int pmc, unsigned long mmcr[]); +u64 isa207_bhrb_filter_map(u64 branch_sample_type); +void isa207_config_bhrb(u64 pmu_bhrb_filter); + #endif diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c index d07186382f3a..91120bec4173 100644 --- a/arch/powerpc/perf/power8-pmu.c +++ b/arch/powerpc/perf/power8-pmu.c @@ -25,11 +25,6 @@ enum { #undef EVENT -/* MMCRA IFM bits - POWER8 */ -#define POWER8_MMCRA_IFM1 0x0000000040000000UL -#define POWER8_MMCRA_IFM2 0x0000000080000000UL -#define POWER8_MMCRA_IFM3 0x00000000C0000000UL - /* PowerISA v2.07 format attribute structure*/ extern struct attribute_group isa207_pmu_format_group; @@ -195,46 +190,6 @@ static int power8_generic_events[] = { [PERF_COUNT_HW_CACHE_MISSES] = PM_LD_MISS_L1, }; -static u64 power8_bhrb_filter_map(u64 branch_sample_type) -{ - u64 pmu_bhrb_filter = 0; - - /* BHRB and regular PMU events share the same privilege state - * filter configuration. BHRB is always recorded along with a - * regular PMU event. As the privilege state filter is handled - * in the basic PMC configuration of the accompanying regular - * PMU event, we ignore any separate BHRB specific request. - */ - - /* No branch filter requested */ - if (branch_sample_type & PERF_SAMPLE_BRANCH_ANY) - return pmu_bhrb_filter; - - /* Invalid branch filter options - HW does not support */ - if (branch_sample_type & PERF_SAMPLE_BRANCH_ANY_RETURN) - return -1; - - if (branch_sample_type & PERF_SAMPLE_BRANCH_IND_CALL) - return -1; - - if (branch_sample_type & PERF_SAMPLE_BRANCH_CALL) - return -1; - - if (branch_sample_type & PERF_SAMPLE_BRANCH_ANY_CALL) { - pmu_bhrb_filter |= POWER8_MMCRA_IFM1; - return pmu_bhrb_filter; - } - - /* Every thing else is unsupported */ - return -1; -} - -static void power8_config_bhrb(u64 pmu_bhrb_filter) -{ - /* Enable BHRB filter in PMU */ - mtspr(SPRN_MMCRA, (mfspr(SPRN_MMCRA) | pmu_bhrb_filter)); -} - #define C(x) PERF_COUNT_HW_CACHE_##x /* @@ -352,8 +307,8 @@ static struct power_pmu power8_pmu = { .add_fields = ISA207_ADD_FIELDS, .test_adder = ISA207_TEST_ADDER, .compute_mmcr = isa207_compute_mmcr, - .config_bhrb = power8_config_bhrb, - .bhrb_filter_map = power8_bhrb_filter_map, + .config_bhrb = isa207_config_bhrb, + .bhrb_filter_map = isa207_bhrb_filter_map, .get_constraint = isa207_get_constraint, .get_alternatives = power8_get_alternatives, .disable_pmc = isa207_disable_pmc, diff --git a/arch/powerpc/perf/power9-pmu.c b/arch/powerpc/perf/power9-pmu.c index 346010e8d463..56ad09801fff 100644 --- a/arch/powerpc/perf/power9-pmu.c +++ b/arch/powerpc/perf/power9-pmu.c @@ -380,8 +380,8 @@ static struct power_pmu power9_isa207_pmu = { .add_fields = ISA207_ADD_FIELDS, .test_adder = ISA207_TEST_ADDER, .compute_mmcr = isa207_compute_mmcr, - .config_bhrb = power9_config_bhrb, - .bhrb_filter_map = power9_bhrb_filter_map, + .config_bhrb = isa207_config_bhrb, + .bhrb_filter_map = isa207_bhrb_filter_map, .get_constraint = isa207_get_constraint, .disable_pmc = isa207_disable_pmc, .flags = PPMU_HAS_SIER | PPMU_ARCH_207S,