From: Matt Turner <mattst88@gmail.com>
To: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
Helge Deller <deller@gmx.de>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>
Cc: linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-perf-users@vger.kernel.org,
Matt Turner <mattst88@gmail.com>
Subject: [PATCH 3/7] parisc: perf: add PA-8800/PA-8900 RDR and DR2 access
Date: Fri, 27 Nov 2026 00:02:56 -0500 [thread overview]
Message-ID: <20261127-parisc-perf-pa8800-v1-3-4f3f077010ce@gmail.com> (raw)
In-Reply-To: <20261127-parisc-perf-pa8800-v1-0-4f3f077010ce@gmail.com>
The PA-8800 and PA-8900 (Mako) performance counters are in RDR15 on the
second of two RDR chains, which perf_asm.S cannot reach: its STDIAG and
SFDIAG forms only address chain 0. Chain 1 is shared by the two cores
of a processor, and a core must request it through diagnose register 2
before shifting it.
Add perf_get_dr2() and perf_set_dr2(), and perf_mako_rdr_read() and
perf_mako_rdr_write(), which shift 64 bits out of or into any RDR on
either chain. The access sequences, including which RDRs take a leading
sync and that RDR10 and RDR11 are written together with RDR26 and RDR27,
are the ones the C8000 PDC 2.13 firmware uses (tables at 0x1d6fc0 and
0x1d8000 in the PDC0213 image). Both functions jump into a table of
64-byte entries indexed by rdr + 32 * chain, because the RDR number is
encoded in the DIAG instruction.
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
arch/parisc/kernel/perf_asm.S | 163 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 163 insertions(+)
diff --git a/arch/parisc/kernel/perf_asm.S b/arch/parisc/kernel/perf_asm.S
index 8fceabb1a832..ad240706750e 100644
--- a/arch/parisc/kernel/perf_asm.S
+++ b/arch/parisc/kernel/perf_asm.S
@@ -32,6 +32,169 @@
;
.text
+;
+; Read diagnose register 2
+;
+ENTRY(perf_get_dr2)
+ .proc
+ .callinfo frame=0,NO_CALLS
+ .entry
+ MFDIAG_2 (28)
+ bve (%r2)
+ nop
+ .exit
+ .procend
+ENDPROC(perf_get_dr2)
+
+;
+; Write diagnose register 2
+;
+ENTRY(perf_set_dr2)
+ .proc
+ .callinfo frame=0,NO_CALLS
+ .entry
+ bve (%r2)
+ MTDIAG_2 (26)
+ .exit
+ .procend
+ENDPROC(perf_set_dr2)
+
+;***********************************************************************
+;*
+;* PA-8800/PA-8900 (Mako) RDR access
+;*
+;* Mako has two RDR chains, selected by bit 0x10000 of the STDIAG and
+;* SFDIAG instructions. Chain 0 is private to each core and chain 1 is
+;* shared by the two cores of a processor. The sequences below are the
+;* ones the C8000 PDC 2.13 firmware uses (tables at 0x1d6fc0 and 0x1d8000
+;* in the PDC0213 image), one 64-byte entry per RDR, indexed by
+;* rdr + 32 * chain. The caller must hold the DR2 chain 1 handshake for
+;* chain 1 accesses.
+;*
+;***********************************************************************
+
+#define MAKO_STDIAG(dr, ch) .word 0x14000AA0 + (dr)*0x200000 + (ch)*0x10000
+#define MAKO_SFDIAG(dr, ch) .word 0x14000BA0 + (dr)*0x200000 + (ch)*0x10000
+
+ .macro mako_sfdiag_ent rdr, ch
+ MAKO_SFDIAG(\rdr, \ch)
+ ssm 0,%r0
+ MFDIAG_1 (28)
+ ssm 0,%r0
+ b,n perf_mako_rdr_read_leave
+ .rept 11
+ nop
+ .endr
+ .endm
+
+ .macro mako_stdiag_ent rdr, ch
+ .if (\ch == 0 && (\rdr == 3 || (\rdr >= 7 && \rdr <= 9))) || \
+ (\ch == 1 && (\rdr == 4 || \rdr == 10 || \rdr == 11))
+ ssm 0,%r0 ; no leading sync for these
+ nop
+ nop
+ nop
+ MAKO_STDIAG(\rdr, \ch)
+ .elseif \ch == 0 && (\rdr == 10 || \rdr == 11)
+ sync ; RDR10/11 are written with RDR26/27
+ ssm 0,%r0
+ nop
+ MAKO_STDIAG(\rdr, 0)
+ MAKO_STDIAG(\rdr + 16, 0)
+ .elseif \ch == 0 && (\rdr == 26 || \rdr == 27)
+ sync
+ ssm 0,%r0
+ nop
+ MAKO_STDIAG(\rdr, 0)
+ MAKO_STDIAG(\rdr - 16, 0)
+ .else
+ sync
+ ssm 0,%r0
+ nop
+ nop
+ MAKO_STDIAG(\rdr, \ch)
+ .endif
+ ssm 0,%r0
+ b,n perf_mako_rdr_write_leave
+ .rept 9
+ nop
+ .endr
+ .endm
+
+;
+; uint64_t perf_mako_rdr_read(unsigned long index)
+;
+; Shift the next 64 bits out of RDR (index & 31) on chain (index >> 5)
+; and return them.
+;
+ .align 64
+ENTRY(perf_mako_rdr_read)
+ .proc
+ .callinfo frame=0,NO_CALLS
+ .entry
+ depdi,z 1,DR2_SLOW_RET,1,%r29
+ MFDIAG_2 (24)
+ or %r24,%r29,%r29
+ MTDIAG_2 (29) ; set DR2_SLOW_RET
+ extrd,u arg0,63,6,%r1
+ shladd %r1,3,%r0,%r1 ; 64 bytes per entry
+ .rept 8
+ nop
+ .endr
+ blr %r1,%r0
+ nop
+
+ ; 64-byte aligned here
+ .irp ch, 0, 1
+ .irp rdr, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
+ mako_sfdiag_ent \rdr, \ch
+ .endr
+ .endr
+
+perf_mako_rdr_read_leave:
+ bve (%r2)
+ .exit
+ MTDIAG_2 (24) ; restore DR2
+ .procend
+ENDPROC(perf_mako_rdr_read)
+
+;
+; void perf_mako_rdr_write(unsigned long index, uint64_t value)
+;
+; Shift value into RDR (index & 31) on chain (index >> 5).
+;
+ .align 64
+ENTRY(perf_mako_rdr_write)
+ .proc
+ .callinfo frame=0,NO_CALLS
+ .entry
+ depdi,z 1,DR2_SLOW_RET,1,%r24
+ MFDIAG_2 (23)
+ or %r24,%r23,%r24
+ MTDIAG_2 (24) ; set DR2_SLOW_RET
+ MTDIAG_1 (25) ; data to the staging register
+ extrd,u arg0,63,6,%r1
+ shladd %r1,3,%r0,%r1 ; 64 bytes per entry
+ .rept 7
+ nop
+ .endr
+ blr %r1,%r0
+ nop
+
+ ; 64-byte aligned here
+ .irp ch, 0, 1
+ .irp rdr, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
+ mako_stdiag_ent \rdr, \ch
+ .endr
+ .endr
+
+perf_mako_rdr_write_leave:
+ bve (%r2)
+ .exit
+ MTDIAG_2 (23) ; restore DR2
+ .procend
+ENDPROC(perf_mako_rdr_write)
+
ENTRY(perf_intrigue_enable_perf_counters)
.proc
.callinfo frame=0,NO_CALLS
--
2.56.1
next prev parent reply other threads:[~2026-11-27 5:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 5:02 [PATCH 0/7] parisc: perf: fix the RDR tables and add PA-8800/PA-8900 counters Matt Turner
2026-11-27 5:02 ` [PATCH 1/7] parisc: perf: swap the PCX-U and PCX-W RDR tables Matt Turner
2026-11-27 5:02 ` [PATCH 2/7] parisc: perf: add an RDR table for PCX-W2 (PA-8700) Matt Turner
2026-11-27 5:02 ` Matt Turner [this message]
2026-11-27 5:02 ` [PATCH 4/7] parisc: perf: program the PA-8800/PA-8900 counters Matt Turner
2026-11-27 5:02 ` [PATCH 5/7] parisc: perf: add a perf events PMU for PA-8800/PA-8900 Matt Turner
2026-11-27 5:02 ` [PATCH 6/7] parisc: perf: add PA-8800/PA-8900 event sets and an instruction filter Matt Turner
2026-11-27 5:03 ` [PATCH 7/7] parisc: perf: add PA-8800/PA-8900 memory and branch events Matt Turner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127-parisc-perf-pa8800-v1-3-4f3f077010ce@gmail.com \
--to=mattst88@gmail.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=deller@gmx.de \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®