PMC counters not working (was: oprofile not working)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PMC counters not working (was: oprofile not working)

1,520 Views
MarkoPanger
Contributor III

Hi all,

I've already posted a similar post in the i.MX53 group. It was about oprofile not generating events other than CPU CYCLES (i.e no CACHE MISS,...) To summarize my problem was that oprofile was not working for me. After following a tutorial (http://imxcommunity.org/group/imx53quickstartboard/forum/attachment/download?id=4103961%3AUploadedFi...) to add the PMU (ARM Performance Monutor Unit) device to the linux kernel I still wasn't able to get any reading from the PMU counters. The only exception was the "CPU CYCLES" counter.

According to the Cortex-A8 Technical Reference Manual (http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0344...) the performance counters are enabled if DBGEN signal is set to 1 (see table 3.99). Now, this signal is SOC (Freescale in this case) specific.

I've searched the i.MX53 Reference Manual and on p.624 found the ARM_GPC register which contains the DBGEN enable bit. I've set this bit via the 'linux/arch/arm/mach-mx5/cpu.c' cpu file:

    #define CORTEXA8_PLAT_GPC    0x04

    arm_plat_base = ioremap(MX53_BASE_ADDR(ARM_BASE_ADDR), SZ_4K);
   
    reg = __raw_readl(arm_plat_base + CORTEXA8_PLAT_GPC);
    printk(KERN_DEBUG "CORTEXA8_PLAT_GPC: %u\n", reg);
    reg |= (1 16); //set DBGEN to 1
    __raw_writel(reg, arm_plat_base + CORTEXA8_PLAT_GPC);

    reg = __raw_readl(arm_plat_base + CORTEXA8_PLAT_GPC);
    printk(KERN_DEBUG "CORTEXA8_PLAT_GPC: %u\n", reg);

However after this modification I'm still unable to get any performance counter reading out of PMC. To eliminate the oprofile factor (could have a bug on this platform) I wrote few line to manually access the PMC. The resoult is always the same. I'm able to get cycle counter but no performace couter reading.

A similar bug was reported here:

https://bugs.launchpad.net/linaro-landing-team-freescale/+bug/893694

Any ideas ? Maybe someone from Freescale could take a look ?

Thanks, Marko

Tags (1)
0 Kudos
5 Replies

809 Views
MaartenBlomme
Contributor I

You're code is correct, but it also did not work for me until I enabled JTAG: add 'jtag=on' to the kernel boot params (see mxc_jtag_enabled in linux-2.6.38 code).

0 Kudos

809 Views
MarkoPanger
Contributor III

Hi, nobody is using the Performance Counters Unit for benchmarking ? I was hoping someone from Freescale could take a look ? Seems this is SOC implementation specific.

Thanks, Marko

0 Kudos

809 Views
weidong_sun
NXP TechSupport
NXP TechSupport

PMU device can't be supported in mx5x PSP file, you can add it in linux_top/arch/arm/mach-mx5x/devices.c, please refer to the following steps and try :

(1)open devices.c and and add :

static struct resource mx5_pmu_resources[] = {

[0] = {

        .start = MXC_INT_PMU,

        .end = MXC_INT_PMU,

        .flags = IORESOURCE_IRQ,

  },

};

struct platform_device mx5_pmu_device = {

.name = "arm-pmu",

.id = 0,

.num_resources = ARRAY_SIZE(mx5_pmu_resources),

.resource = mx5_pmu_resources,

};

(2) open BSP file (should be mx53_loco.c or mx53_smd.c or mx53_ard.c), register PMU device to linux

static void __init mx_board_init(void)

{

........

mxc_register_device(&mx5_pmu_device,NULL);

.......

}

(3)Selecting PMU drivers when configuring linux kernel by using "make menuconfig"

PMU driver is in path : linux_top/arch/arm/kernel/pmu.c

According to Kconfig and Makefile ,you can know where the menu item is , Select it ,please !

After re-compiling linux kernel, PMU device will be supported, then try your application.

0 Kudos

809 Views
weidong_sun
NXP TechSupport
NXP TechSupport


Correction:

I re-checked path "linux_top/arch/arm/kernel/", no Kconfig file is here, We can adjust linux_top/.config, open it and find if "CONFIG_CPU_HAS_PMU=y" exists, if not, set "CONFIG_CPU_HAS_PMU=y", then PMU driver can be loaded correctly.

0 Kudos

809 Views
LeonardoSandova
Specialist I

Hi Weidong,

Aalso we need to export the new structure, so a 4 step is needed:

diff --git a/arch/arm/mach-mx5/devices.h b/arch/arm/mach-mx5/devices.h

index 407a658..ad11869 100644

--- a/arch/arm/mach-mx5/devices.h

+++ b/arch/arm/mach-mx5/devices.h

@@ -92,5 +92,6 @@ extern struct platform_device fixed_volt_reg_device;

extern struct platform_device mxc_zq_calib_device;

extern struct platform_device mxc_asrc_device;

extern struct platform_device mxc_perfmon;

+extern struct platform_device mx5_pmu_device;

extern struct mxs_platform_perfmon_data mxc_perfmon_data;

extern struct mxc_gpu_platform_data gpu_data;

0 Kudos