mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jocelyn Falempe <jfalempe@redhat.com>
To: peder.bergan@gmail.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: Re: [PATCH 2/3] drm/panic: Apply the QR mask while drawing data modules
Date: Fri, 27 Nov 2026 13:42:04 +0100	[thread overview]
Message-ID: <4ccdd654-f8af-4e51-a8ac-ae7f68f0db07@redhat.com> (raw)
In-Reply-To: <20261126-perf-drm-panic-qr-v1-2-51856937dc4d@gmail.com>

On 11/26/26 17:53, Peder Bergan via B4 Relay wrote:
> From: Peder Bergan <peder.bergan@gmail.com>
> 
> After placing data and remainder modules, apply_mask() scans the whole
> image to invert the unreserved modules covered by checkerboard mask 0.
> Data placement already visits every unreserved module once.
> 
> Apply mask 0 while drawing each data module and each zero-valued
> remainder module. This removes the separate image pass and its buffer
> read-modify-write operations. The format information still advertises
> mask 0.
> 
Thanks for your contribution.
This code is executed only once when a panic occurs, so optimizations 
are clearly not a priority.
But this series looks good, and keeps the code simple.

Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>

> Signed-off-by: Peder Bergan <peder.bergan@gmail.com>
> ---
>   drivers/gpu/drm/drm_panic_helper_qr.rs | 35 +++++++++++-----------------------
>   1 file changed, 11 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_panic_helper_qr.rs b/drivers/gpu/drm/drm_panic_helper_qr.rs
> index c6ed395c05bd2..1d96ae855052a 100644
> --- a/drivers/gpu/drm/drm_panic_helper_qr.rs
> +++ b/drivers/gpu/drm/drm_panic_helper_qr.rs
> @@ -691,12 +691,6 @@ fn set(&mut self, x: u8, y: u8) {
>           self.data[off] = v;
>       }
>   
> -    /// Invert a module color.
> -    fn xor(&mut self, x: u8, y: u8) {
> -        let off = y as usize * self.stride as usize + x as usize / 8;
> -        self.data[off] ^= 0x80 >> (x % 8);
> -    }
> -
>       /// Draw a light square at (x, y) top left corner.
>       fn draw_square(&mut self, x: u8, y: u8, size: u8) {
>           for k in 0..size {
> @@ -864,37 +858,31 @@ fn next_available(&self, x: u8, y: u8) -> (u8, u8) {
>           (x, y)
>       }
>   
> +    /// Draw an unreserved module with checkerboard mask 0.
> +    fn draw_data_module(&mut self, x: u8, y: u8, bit: bool) {
> +        let invert = (x ^ y) % 2 == 0;
> +        if !(bit ^ invert) {
> +            self.set(x, y);
> +        }
> +    }
> +
>       fn draw_data(&mut self, data: impl Iterator<Item = u8>) {
>           let (mut x, mut y) = (self.width - 1, self.width - 1);
>           for byte in data {
>               for s in 0..8 {
> -                if byte & (0x80 >> s) == 0 {
> -                    self.set(x, y);
> -                }
> +                self.draw_data_module(x, y, byte & (0x80 >> s) != 0);
>                   (x, y) = self.next_available(x, y);
>               }
>           }
> -        // Set the remaining modules (0, 3 or 7 depending on version).
> -        // because 0 correspond to a light module.
> +        // The remaining modules encode zero before masking.
>           while !self.is_last(x, y) {
>               if !self.is_reserved(x, y) {
> -                self.set(x, y);
> +                self.draw_data_module(x, y, false);
>               }
>               (x, y) = self.next(x, y);
>           }
>       }
>   
> -    /// Apply checkerboard mask to all non-reserved modules.
> -    fn apply_mask(&mut self) {
> -        for x in 0..self.width {
> -            for y in 0..self.width {
> -                if (x ^ y) % 2 == 0 && !self.is_reserved(x, y) {
> -                    self.xor(x, y);
> -                }
> -            }
> -        }
> -    }
> -
>       /// Draw the QR code with the provided data iterator.
>       fn draw_all(&mut self, data: impl Iterator<Item = u8>) {
>           // First clear the table, as it may have already some data.
> @@ -905,7 +893,6 @@ fn draw_all(&mut self, data: impl Iterator<Item = u8>) {
>           self.draw_version_info();
>           self.draw_data(data);
>           self.draw_maskinfo();
> -        self.apply_mask();
>       }
>   }
>   
> 


  reply	other threads:[~2026-11-27 12:42 UTC|newest]

Thread overview: 7+ 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-27 12:41   ` Jocelyn Falempe
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-27 12:42   ` Jocelyn Falempe [this message]
2026-11-26 16:53 ` [PATCH 3/3] drm/panic: Simplify QR error correction exponent reduction Peder Bergan via B4 Relay
2026-11-27 12:42   ` Jocelyn Falempe

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=4ccdd654-f8af-4e51-a8ac-ae7f68f0db07@redhat.com \
    --to=jfalempe@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@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®