mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peder Bergan via B4 Relay <devnull+peder.bergan.gmail.com@kernel.org>
To: Jocelyn Falempe <jfalempe@redhat.com>,
	 Javier Martinez Canillas <javierm@redhat.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	 Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	 dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org,
	 linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] drm/panic: Simplify QR error correction exponent reduction
Date: Thu, 26 Nov 2026 17:53:17 +0100	[thread overview]
Message-ID: <20261126-perf-drm-panic-qr-v1-3-51856937dc4d@gmail.com> (raw)
In-Reply-To: <20261126-perf-drm-panic-qr-v1-0-51856937dc4d@gmail.com>

From: Peder Bergan <peder.bergan@gmail.com>

Reed-Solomon error correction reduces the sum of two GF(256) exponents
modulo 255 for each generator coefficient. Both exponents are below
255, so the sum needs at most one subtraction.

Use a conditional subtraction for the reduction. In the x86-64
userspace benchmark, this replaces a multiply-and-shift sequence with
a comparison and conditional moves. On top of the first two patches,
the change saved about 32 us per version-40 encode with raw input and
31 us with a URL.

Signed-off-by: Peder Bergan <peder.bergan@gmail.com>
---
 drivers/gpu/drm/drm_panic_helper_qr.rs | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_panic_helper_qr.rs b/drivers/gpu/drm/drm_panic_helper_qr.rs
index 1d96ae855052a..4ba2e3de5a6b6 100644
--- a/drivers/gpu/drm/drm_panic_helper_qr.rs
+++ b/drivers/gpu/drm/drm_panic_helper_qr.rs
@@ -569,7 +569,10 @@ fn error_code_for_blocks(&mut self, offset: usize, size: usize, ec_offset: usize
             }
             let log_lead_coeff = usize::from(LOG_TABLE[lead_coeff]);
             for (u, &v) in tmp[i + 1..].iter_mut().zip(self.poly.iter()) {
-                *u ^= EXP_TABLE[(usize::from(v) + log_lead_coeff) % 255];
+                // Both exponents are below 255, so at most one subtraction is needed.
+                let sum = usize::from(v) + log_lead_coeff;
+                let index = if sum >= 255 { sum - 255 } else { sum };
+                *u ^= EXP_TABLE[index];
             }
         }
         self.data[ec_offset..ec_offset + self.ec_size]

-- 
2.56.1



      parent reply	other threads:[~2026-11-26 16:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 16:53 [PATCH 0/3] drm/panic: Speed up QR code encoding Peder Bergan via B4 Relay
2026-11-26 16:53 ` [PATCH 1/3] drm/panic: Check QR alignment centers one axis at a time Peder Bergan via B4 Relay
2026-11-26 16:53 ` [PATCH 2/3] drm/panic: Apply the QR mask while drawing data modules Peder Bergan via B4 Relay
2026-11-26 16:53 ` Peder Bergan via B4 Relay [this message]

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=20261126-perf-drm-panic-qr-v1-3-51856937dc4d@gmail.com \
    --to=devnull+peder.bergan.gmail.com@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=jfalempe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=peder.bergan@gmail.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tzimmermann@suse.de \
    /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®