Enable HWPMC overflow IRQ on both CPUs in MPIC

This commit enables usage of HWPMC interrupts for the
Marvell SoCs, which use MPIC (Armada38x and ArmadaXP).
Those interrupts require extra unmasking, comparing to
others. Also, in order to process counters per-CPU,
they are masked/unmasked using separate registers' sets
for each core.

Submitted by: Michal Mazur <mkm@semihalf.com>
    	      Marcin Wojtas <mw@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield, Netgate
Differential revision: https://reviews.freebsd.org/D10913
This commit is contained in:
Zbigniew Bodek 2017-06-13 18:55:21 +00:00
parent 6cb40391c4
commit 08d94c6eab
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=319914
2 changed files with 33 additions and 2 deletions

View File

@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mutex.h>
#include <sys/rman.h>
#include <sys/proc.h>
#include <sys/smp.h>
#include <machine/bus.h>
#include <machine/intr.h>
@ -70,6 +71,7 @@ __FBSDID("$FreeBSD$");
#define debugf(fmt, args...)
#endif
#define MPIC_INT_LOCAL 3
#define MPIC_INT_ERR 4
#define MPIC_INT_MSI 96
@ -93,7 +95,9 @@ __FBSDID("$FreeBSD$");
#define MPIC_IIACK 0x44
#define MPIC_ISM 0x48
#define MPIC_ICM 0x4c
#define MPIC_ERR_MASK 0xe50
#define MPIC_ERR_MASK 0x50
#define MPIC_LOCAL_MASK 0x54
#define MPIC_CPU(n) (n) * 0x100
#define MPIC_PPI 32
@ -223,6 +227,7 @@ mv_mpic_attach(device_t dev)
struct mv_mpic_softc *sc;
int error;
uint32_t val;
int cpu;
sc = (struct mv_mpic_softc *)device_get_softc(dev);
@ -283,6 +288,12 @@ mv_mpic_attach(device_t dev)
mpic_unmask_msi();
/* Unmask CPU performance counters overflow irq */
for (cpu = 0; cpu < mp_ncpus; cpu++)
MPIC_CPU_WRITE(mv_mpic_sc, MPIC_CPU(cpu) + MPIC_LOCAL_MASK,
(1 << cpu) | MPIC_CPU_READ(mv_mpic_sc,
MPIC_CPU(cpu) + MPIC_LOCAL_MASK));
return (0);
}
@ -488,6 +499,16 @@ static void
mpic_unmask_irq(uintptr_t nb)
{
#ifdef SMP
int cpu;
if (nb == MPIC_INT_LOCAL) {
for (cpu = 0; cpu < mp_ncpus; cpu++)
MPIC_CPU_WRITE(mv_mpic_sc,
MPIC_CPU(cpu) + MPIC_ICM, nb);
return;
}
#endif
if (mpic_irq_is_percpu(nb))
MPIC_CPU_WRITE(mv_mpic_sc, MPIC_ICM, nb);
else if (nb < ERR_IRQ)
@ -503,6 +524,16 @@ static void
mpic_mask_irq(uintptr_t nb)
{
#ifdef SMP
int cpu;
if (nb == MPIC_INT_LOCAL) {
for (cpu = 0; cpu < mp_ncpus; cpu++)
MPIC_CPU_WRITE(mv_mpic_sc,
MPIC_CPU(cpu) + MPIC_ISM, nb);
return;
}
#endif
if (mpic_irq_is_percpu(nb))
MPIC_CPU_WRITE(mv_mpic_sc, MPIC_ISM, nb);
else if (nb < ERR_IRQ)

View File

@ -419,7 +419,7 @@
mpic: interrupt-controller@20a00 {
compatible = "marvell,mpic";
reg = <0x20a00 0x2d0>, <0x21870 0x58>;
reg = <0x20a00 0x2d0>, <0x21870 0x300>;
#interrupt-cells = <1>;
#size-cells = <1>;
interrupt-controller;