[PATCH 0/4] drm/panic: Add a qr_code panic screen

Jocelyn Falempe posted 4 patches 1 year, 7 months ago
There is a newer version of this series
drivers/gpu/drm/Kconfig         |  29 +
drivers/gpu/drm/Makefile        |   1 +
drivers/gpu/drm/drm_drv.c       |   3 +
drivers/gpu/drm/drm_panic.c     | 338 +++++++++--
drivers/gpu/drm/drm_panic_qr.rs | 989 ++++++++++++++++++++++++++++++++
include/drm/drm_panic.h         |   4 +
include/drm/drm_rect.h          |  15 +
7 files changed, 1340 insertions(+), 39 deletions(-)
create mode 100644 drivers/gpu/drm/drm_panic_qr.rs
[PATCH 0/4] drm/panic: Add a qr_code panic screen
Posted by Jocelyn Falempe 1 year, 7 months ago
This series adds a new panic screen, with the kmsg data embedded in a QR-code.

The main advantage of QR-code, is that you can copy/paste the debug data to a bug report.

The QR-code encoder is written in rust, and is very specific to drm_panic.
The reason is that it is called in a panic handler, and thus can't allocate memory, or use locking.
The rust code uses a few rust core API, and provides only two C entry points.
There is no particular reason to do it in rust, I just wanted to learn rust, and see if it can work in the kernel.

If you want to see what it looks like, I've put a few screenshots here:
https://github.com/kdj0c/panic_report/issues/1

-- 

Jocelyn


Jocelyn Falempe (4):
  drm/panic: Add integer scaling to blit()
  drm/rect: add drm_rect_overlap()
  drm/panic: simplify logo handling
  drm/panic: Add a qr_code panic screen

 drivers/gpu/drm/Kconfig         |  29 +
 drivers/gpu/drm/Makefile        |   1 +
 drivers/gpu/drm/drm_drv.c       |   3 +
 drivers/gpu/drm/drm_panic.c     | 338 +++++++++--
 drivers/gpu/drm/drm_panic_qr.rs | 989 ++++++++++++++++++++++++++++++++
 include/drm/drm_panic.h         |   4 +
 include/drm/drm_rect.h          |  15 +
 7 files changed, 1340 insertions(+), 39 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_panic_qr.rs


base-commit: 3f5ea7ed705e8effe9cfabf912e769ccb6b7d389
-- 
2.45.2
Re: [PATCH 0/4] drm/panic: Add a qr_code panic screen
Posted by Alice Ryhl 1 year, 7 months ago
On Wed, Jul 3, 2024 at 5:44 PM Jocelyn Falempe <jfalempe@redhat.com> wrote:
>
> This series adds a new panic screen, with the kmsg data embedded in a QR-code.
>
> The main advantage of QR-code, is that you can copy/paste the debug data to a bug report.
>
> The QR-code encoder is written in rust, and is very specific to drm_panic.
> The reason is that it is called in a panic handler, and thus can't allocate memory, or use locking.
> The rust code uses a few rust core API, and provides only two C entry points.
> There is no particular reason to do it in rust, I just wanted to learn rust, and see if it can work in the kernel.
>
> If you want to see what it looks like, I've put a few screenshots here:
> https://github.com/kdj0c/panic_report/issues/1
>
> --
>
> Jocelyn
>
>
> Jocelyn Falempe (4):
>   drm/panic: Add integer scaling to blit()
>   drm/rect: add drm_rect_overlap()
>   drm/panic: simplify logo handling
>   drm/panic: Add a qr_code panic screen
>
>  drivers/gpu/drm/Kconfig         |  29 +
>  drivers/gpu/drm/Makefile        |   1 +
>  drivers/gpu/drm/drm_drv.c       |   3 +
>  drivers/gpu/drm/drm_panic.c     | 338 +++++++++--
>  drivers/gpu/drm/drm_panic_qr.rs | 989 ++++++++++++++++++++++++++++++++
>  include/drm/drm_panic.h         |   4 +
>  include/drm/drm_rect.h          |  15 +
>  7 files changed, 1340 insertions(+), 39 deletions(-)
>  create mode 100644 drivers/gpu/drm/drm_panic_qr.rs
>
>
> base-commit: 3f5ea7ed705e8effe9cfabf912e769ccb6b7d389

I tried to apply this patch, but I can't find this commit, nor could I
find any tag that it applies on.

Alice
Re: [PATCH 0/4] drm/panic: Add a qr_code panic screen
Posted by Jocelyn Falempe 1 year, 7 months ago

On 04/07/2024 11:18, Alice Ryhl wrote:
> On Wed, Jul 3, 2024 at 5:44 PM Jocelyn Falempe <jfalempe@redhat.com> wrote:
>>
>> This series adds a new panic screen, with the kmsg data embedded in a QR-code.
>>
>> The main advantage of QR-code, is that you can copy/paste the debug data to a bug report.
>>
>> The QR-code encoder is written in rust, and is very specific to drm_panic.
>> The reason is that it is called in a panic handler, and thus can't allocate memory, or use locking.
>> The rust code uses a few rust core API, and provides only two C entry points.
>> There is no particular reason to do it in rust, I just wanted to learn rust, and see if it can work in the kernel.
>>
>> If you want to see what it looks like, I've put a few screenshots here:
>> https://github.com/kdj0c/panic_report/issues/1
>>
>> --
>>
>> Jocelyn
>>
>>
>> Jocelyn Falempe (4):
>>    drm/panic: Add integer scaling to blit()
>>    drm/rect: add drm_rect_overlap()
>>    drm/panic: simplify logo handling
>>    drm/panic: Add a qr_code panic screen
>>
>>   drivers/gpu/drm/Kconfig         |  29 +
>>   drivers/gpu/drm/Makefile        |   1 +
>>   drivers/gpu/drm/drm_drv.c       |   3 +
>>   drivers/gpu/drm/drm_panic.c     | 338 +++++++++--
>>   drivers/gpu/drm/drm_panic_qr.rs | 989 ++++++++++++++++++++++++++++++++
>>   include/drm/drm_panic.h         |   4 +
>>   include/drm/drm_rect.h          |  15 +
>>   7 files changed, 1340 insertions(+), 39 deletions(-)
>>   create mode 100644 drivers/gpu/drm/drm_panic_qr.rs
>>
>>
>> base-commit: 3f5ea7ed705e8effe9cfabf912e769ccb6b7d389
> 
> I tried to apply this patch, but I can't find this commit, nor could I
> find any tag that it applies on.

Sorry, it's the drm-misc-next branch of 
git@gitlab.freedesktop.org:drm/misc/kernel.git

> 
> Alice
> 

Re: [PATCH 0/4] drm/panic: Add a qr_code panic screen
Posted by Greg KH 1 year, 7 months ago
On Wed, Jul 03, 2024 at 05:33:57PM +0200, Jocelyn Falempe wrote:
> This series adds a new panic screen, with the kmsg data embedded in a QR-code.
> 
> The main advantage of QR-code, is that you can copy/paste the debug data to a bug report.
> 
> The QR-code encoder is written in rust, and is very specific to drm_panic.
> The reason is that it is called in a panic handler, and thus can't allocate memory, or use locking.
> The rust code uses a few rust core API, and provides only two C entry points.
> There is no particular reason to do it in rust, I just wanted to learn rust, and see if it can work in the kernel.
> 
> If you want to see what it looks like, I've put a few screenshots here:
> https://github.com/kdj0c/panic_report/issues/1

Cool, this idea has been floating around for decades, here's the last
attempt at this back in 2014:
	https://lore.kernel.org/all/1395093587-2583-1-git-send-email-teobaluta@gmail.com/

> 
> -- 
> 
> Jocelyn
> 
> 
> Jocelyn Falempe (4):
>   drm/panic: Add integer scaling to blit()
>   drm/rect: add drm_rect_overlap()
>   drm/panic: simplify logo handling
>   drm/panic: Add a qr_code panic screen
> 
>  drivers/gpu/drm/Kconfig         |  29 +
>  drivers/gpu/drm/Makefile        |   1 +
>  drivers/gpu/drm/drm_drv.c       |   3 +
>  drivers/gpu/drm/drm_panic.c     | 338 +++++++++--
>  drivers/gpu/drm/drm_panic_qr.rs | 989 ++++++++++++++++++++++++++++++++

Wait, we can put .rs files in any directory now?  I didn't think that
worked properly yet.

thanks,

greg k-h
Re: [PATCH 0/4] drm/panic: Add a qr_code panic screen
Posted by Alice Ryhl 1 year, 7 months ago
On Thu, Jul 4, 2024 at 7:03 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Wed, Jul 03, 2024 at 05:33:57PM +0200, Jocelyn Falempe wrote:
> > Jocelyn Falempe (4):
> >   drm/panic: Add integer scaling to blit()
> >   drm/rect: add drm_rect_overlap()
> >   drm/panic: simplify logo handling
> >   drm/panic: Add a qr_code panic screen
> >
> >  drivers/gpu/drm/Kconfig         |  29 +
> >  drivers/gpu/drm/Makefile        |   1 +
> >  drivers/gpu/drm/drm_drv.c       |   3 +
> >  drivers/gpu/drm/drm_panic.c     | 338 +++++++++--
> >  drivers/gpu/drm/drm_panic_qr.rs | 989 ++++++++++++++++++++++++++++++++
>
> Wait, we can put .rs files in any directory now?  I didn't think that
> worked properly yet.

Yes, but Rust code outside of rust/ cannot expose a Rust API that Rust
code elsewhere can use. Only C apis can be exposed.

Alice
Re: [PATCH 0/4] drm/panic: Add a qr_code panic screen
Posted by Jocelyn Falempe 1 year, 7 months ago

On 04/07/2024 07:03, Greg KH wrote:
> On Wed, Jul 03, 2024 at 05:33:57PM +0200, Jocelyn Falempe wrote:
>> This series adds a new panic screen, with the kmsg data embedded in a QR-code.
>>
>> The main advantage of QR-code, is that you can copy/paste the debug data to a bug report.
>>
>> The QR-code encoder is written in rust, and is very specific to drm_panic.
>> The reason is that it is called in a panic handler, and thus can't allocate memory, or use locking.
>> The rust code uses a few rust core API, and provides only two C entry points.
>> There is no particular reason to do it in rust, I just wanted to learn rust, and see if it can work in the kernel.
>>
>> If you want to see what it looks like, I've put a few screenshots here:
>> https://github.com/kdj0c/panic_report/issues/1
> 
> Cool, this idea has been floating around for decades, here's the last
> attempt at this back in 2014:
> 	https://lore.kernel.org/all/1395093587-2583-1-git-send-email-teobaluta@gmail.com/
> 
Yes, I've looked at this, but drawing a QR-code in the middle of fbcon 
was a bit complex. Now with drm panic, there is a proper infrastructure 
to display the QR code, and make sure it won't be overwritten.

>>
>> -- 
>>
>> Jocelyn
>>
>>
>> Jocelyn Falempe (4):
>>    drm/panic: Add integer scaling to blit()
>>    drm/rect: add drm_rect_overlap()
>>    drm/panic: simplify logo handling
>>    drm/panic: Add a qr_code panic screen
>>
>>   drivers/gpu/drm/Kconfig         |  29 +
>>   drivers/gpu/drm/Makefile        |   1 +
>>   drivers/gpu/drm/drm_drv.c       |   3 +
>>   drivers/gpu/drm/drm_panic.c     | 338 +++++++++--
>>   drivers/gpu/drm/drm_panic_qr.rs | 989 ++++++++++++++++++++++++++++++++
> 
> Wait, we can put .rs files in any directory now?  I didn't think that
> worked properly yet.

Yes, thanks to the work of the rust-for-linux team. When I started to 
work on this, I needed a few workarounds to make my rust code compile. 
But since 6.10-rc1, I was able to drop them all. Also for this simple 
case, I don't use bindgen, because there are only 2 Rust functions, that 
I need to call from C.

> 
> thanks,
> 
> greg k-h
> 

-- 

Jocelyn
Re: [PATCH 0/4] drm/panic: Add a qr_code panic screen
Posted by Miguel Ojeda 1 year, 7 months ago
On Thu, Jul 4, 2024 at 7:03 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> Wait, we can put .rs files in any directory now?  I didn't think that
> worked properly yet.

We can put leaves of the crate graph (e.g. in-tree we have the samples
and the PHY driver), but not the rest of the graph. The former fits
just fine in Kbuild (which is why it was good enough for what we did
so far), the other part is what requires a rework of how things will
work.

Cheers,
Miguel