Received: by 10.223.185.116 with SMTP id b49csp2182950wrg; Mon, 12 Feb 2018 05:49:19 -0800 (PST) X-Google-Smtp-Source: AH8x225DQVzzKhl1n9Vhfykt0FiKEuu7PtuXu/9k7M0sVVC89ICCUEAz1NmBjSsLGyUUnAeq2Fux X-Received: by 10.101.71.129 with SMTP id e1mr9368671pgs.430.1518443359697; Mon, 12 Feb 2018 05:49:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518443359; cv=none; d=google.com; s=arc-20160816; b=eZdaKT57vFW3EZhQNZtwrt+q6cnqChc1xcOiEI4bOXhBYWf4GRLiYnTCXgpR9L5ngb zTpqo9TpQjbSFxqrGSOEXTh1rgxyfQS9q51nyXiRfM909asAHDwPOcjF0V+AhjnF2GUe gnd0j8/DeDuwkXro9x9d9+1WKUnkLW518HUYOw4CYMEfCxTBy29rRsVH+EJiSlUCbmnG Lyvn3q7ZNGvfs9zUUtEBkplfutn9fKPRlmcBp9e1WlF8rrzyQm6WXrkP6K6F1l5SQByA OYZ+LpAALVRRGJf7i6B/fx1RQtKMU4vmLnocgrlak+0U7I4pJ6GGooeSxwaA9W2aieIe tBFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=NulMY9hWoB3jYvkgAl3kFsPYRPZBLdYdyz6mjiYUglU=; b=EoEWSD50D50mCa9V5lRBEiP0V2m/iDfVDMyhEUSDeVfnemrToGYB2VTDuZc2SFiLHu nE6ocqbEe93Pttk11ZWN6RPc71RoBmDdFPSAOZPRgqrN91yHGzuh9mxUzpqEtkXT5Fpc 1QoX2KlbYRO9PuweSpYIV2F8kCwgU25XCWzvpN2JKC26SRJNdtteCGqGcItyGzvJH+xo B/hbPpSNX5fhJJiEFkTziYqPtZTSSw9hbF7WnzvE/51HkyrU0tG31ET2FcXDav52N0XM IlBw8u36OldpN+9igfuKWYScVQMheaCiRGHudROcpxBzQSkhQqhwUc73DERG7+I5fOkj MA1A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6-v6si2781735plj.159.2018.02.12.05.49.05; Mon, 12 Feb 2018 05:49:19 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934633AbeBLMj5 (ORCPT + 99 others); Mon, 12 Feb 2018 07:39:57 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:39246 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933358AbeBLMjx (ORCPT ); Mon, 12 Feb 2018 07:39:53 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 46A6627305F From: Sebastian Reichel To: Shawn Guo , Sascha Hauer , Fabio Estevam , Will Deacon , Mark Rutland Cc: Russell King , Ian Ray , Nandor Han , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv4 1/2] ARM: imx53: add secure-reg-access support for PMU Date: Mon, 12 Feb 2018 13:39:44 +0100 Message-Id: <20180212123945.15732-2-sebastian.reichel@collabora.co.uk> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180212123945.15732-1-sebastian.reichel@collabora.co.uk> References: <20180212123945.15732-1-sebastian.reichel@collabora.co.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On i.MX53 it is necessary to set the DBG_EN bit in the platform GPC register to enable access to PMU counters other than the cycle counter. Signed-off-by: Sebastian Reichel --- arch/arm/mach-imx/mach-imx53.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/mach-imx53.c b/arch/arm/mach-imx/mach-imx53.c index 07c2e8dca494..658e28604dca 100644 --- a/arch/arm/mach-imx/mach-imx53.c +++ b/arch/arm/mach-imx/mach-imx53.c @@ -28,10 +28,47 @@ static void __init imx53_init_early(void) mxc_set_cpu_type(MXC_CPU_MX53); } +#define MXC_CORTEXA8_PLAT_GPC 0x63fa0004 +#define GPC_DBG_EN BIT(16) + +/* + * This enables the DBGEN bit in ARM_GPC register, which is + * required for accessing some performance counter features. + * Technically it is only required while perf is used, but to + * keep the source code simple we just enable it all the time + * when the kernel configuration allows using the feature. + */ +static void imx53_pmu_init(void) +{ + void __iomem *gpc_reg; + struct device_node *node; + u32 gpc; + + if (!IS_ENABLED(CONFIG_ARM_PMU)) + return; + + node = of_find_compatible_node(NULL, NULL, "arm,cortex-a8-pmu"); + if (!node) + return; + + if (!of_property_read_bool(node, "secure-reg-access")) + return; + + gpc_reg = ioremap(MXC_CORTEXA8_PLAT_GPC, 4); + if (!gpc_reg) { + pr_warning("unable to map GPC to enable perf\n"); + return; + } + + gpc = readl_relaxed(gpc_reg); + gpc |= GPC_DBG_EN; + writel_relaxed(gpc, gpc_reg); +} + static void __init imx53_dt_init(void) { imx_src_init(); - + imx53_pmu_init(); imx_aips_allow_unprivileged_access("fsl,imx53-aipstz"); } -- 2.15.1