mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 1/7] parisc: perf: swap the PCX-U and PCX-W RDR tables
Date: Fri, 27 Nov 2026 00:02:54 -0500	[thread overview]
Message-ID: <20261127-parisc-perf-pa8800-v1-1-4f3f077010ce@gmail.com> (raw)
In-Reply-To: <20261127-parisc-perf-pa8800-v1-0-4f3f077010ce@gmail.com>

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@gmail.com>
---
 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


  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 ` Matt Turner [this message]
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 ` [PATCH 3/7] parisc: perf: add PA-8800/PA-8900 RDR and DR2 access Matt Turner
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-1-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®