[PATCH 1/7] parisc: perf: swap the PCX-U and PCX-W RDR tables
From: Matt Turner
Date: Fri Nov 27 2026 - 00:03:07 EST
perf_rdr_tbl_W holds the PCX-U (PA-8000/PA-8200) RDR widths and
perf_rdr_tbl_U holds the PCX-W (PA-8500/PA-8600) widths, and it has been
that way since the driver was added. The driver's own code and data
show it:
- The CUDA (PCX-W) counter read takes four 32-bit counters, two
doublewords, from RDR15. perf_rdr_tbl_W says RDR15 is 8 bits wide;
perf_rdr_tbl_U says 128.
- The ONYX (PCX-U) counter read takes the counters from bits 1398 to
1529 of RDR16, which needs RDR16 to be 1530 bits wide as in
perf_rdr_tbl_W. perf_rdr_tbl_U says 1494.
- perf_rdr_shift_in_W does nothing for RDR3, RDR7, RDR8, RDR9, RDR12
and RDR19, which are absent in perf_rdr_tbl_U. perf_rdr_tbl_W gives
RDR3, RDR7, RDR9 and RDR12 non-zero widths.
- The ONYX images write RDR7, which is absent in perf_rdr_tbl_U, and the
CUDA images write RDR15, which is 8 bits in perf_rdr_tbl_W.
- The images are laid out for the swapped tables. RDR data is
left-justified, so the bits past each RDR's width are zero. Read
with perf_rdr_tbl_U, none of the 22 cuda_images sets a bit past the
width of any RDR; read with perf_rdr_tbl_W, every image does in about
two thirds of its RDRs. The same holds the other way round for the 44
onyx_images. With the swapped tables both image families end in the
same 9 Runway doublewords, and the CUDA images' Runway STATUS word
then carries bits inside the 0x0013000000000000 mask that
perf_write_image() applies.
- The PA-8500/PA-8600 PDC firmware (from HP-UX 11.11 patch PHSS_25983)
has an RDR description table whose widths equal perf_rdr_tbl_U in
every entry.
As a result every CUDA image write shifts each RDR by the wrong amount
and loads RDR16 one doubleword early, the CUDA counter read returns 8
bits, and on PCX-U RDR7 is never written and the counters are taken
from a misaligned RDR16.
Swap the two tables' names, and correct the RDR20/21 and RDR22/23 widths
in the perf_bitmasks comments. The RDR20/21 mask already covers 158
bits.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Matt Turner <mattst88@xxxxxxxxx>
---
arch/parisc/kernel/perf.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/parisc/kernel/perf.c b/arch/parisc/kernel/perf.c
index 5e10f98ce7b5..8f9ae67270bd 100644
--- a/arch/parisc/kernel/perf.c
+++ b/arch/parisc/kernel/perf.c
@@ -67,8 +67,8 @@ static const int perf_rdrs_W[] =
static const int perf_rdrs_U[] =
{ 0, 1, 4, 5, 6, 7, 16, 17, 18, 20, 21, 22, 23, 24, 25, -1 };
-/* RDR register descriptions for PCX-W */
-static const struct rdr_tbl_ent perf_rdr_tbl_W[] = {
+/* RDR register descriptions for PCX-U */
+static const struct rdr_tbl_ent perf_rdr_tbl_U[] = {
{ 19, 1, 8 }, /* RDR 0 */
{ 16, 1, 16 }, /* RDR 1 */
{ 72, 2, 0 }, /* RDR 2 */
@@ -103,8 +103,8 @@ static const struct rdr_tbl_ent perf_rdr_tbl_W[] = {
{ 16, 1, 0 }, /* RDR 31 */
};
-/* RDR register descriptions for PCX-U */
-static const struct rdr_tbl_ent perf_rdr_tbl_U[] = {
+/* RDR register descriptions for PCX-W */
+static const struct rdr_tbl_ent perf_rdr_tbl_W[] = {
{ 19, 1, 8 }, /* RDR 0 */
{ 32, 1, 16 }, /* RDR 1 */
{ 20, 1, 0 }, /* RDR 2 */
@@ -147,10 +147,10 @@ static const uint64_t perf_bitmasks[] = {
0x0000000000000000ul, /* first dbl word must be zero */
0xfdffe00000000000ul, /* RDR0 bitmask */
0x003f000000000000ul, /* RDR1 bitmask */
- 0x00fffffffffffffful, /* RDR20-RDR21 bitmask (152 bits) */
+ 0x00fffffffffffffful, /* RDR20-RDR21 bitmask (158 bits) */
0xfffffffffffffffful,
0xfffffffc00000000ul,
- 0xfffffffffffffffful, /* RDR22-RDR23 bitmask (233 bits) */
+ 0xfffffffffffffffful, /* RDR22-RDR23 bitmask (194 bits) */
0xfffffffffffffffful,
0xfffffffffffffffcul,
0xff00000000000000ul
--
2.56.1