public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] drm/tyr: gpu: fix GpuInfo::log model/version decoding
@ 2026-02-10 18:38 Onur Özkan
  2026-02-11  7:33 ` 孙科
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Onur Özkan @ 2026-02-10 18:38 UTC (permalink / raw)
  To: daniel.almeida, aliceryhl, dakr, airlied, simona, dri-devel,
	linux-kernel, rust-for-linux
  Cc: Onur Özkan

GpuInfo::log() was decoding GPU_ID like this:

  major = (self.gpu_id >> 16) & 0xff;
  minor = (self.gpu_id >> 8) & 0xff;
  status = self.gpu_id & 0xff;

That does not match the Mali GPU_ID layout and mixes unrelated
fields. Due to that, model detection becomes `mali-unknown` on
rk3588s which is wrong.

We can already get all the version information with a single
GpuId::from call (less code and cleaner), so this patch uses it.

Also renamed `GpuModels` fields from `major/minor` to
`arch_major/prod_major` to reflect their real meaning.

This change was tested on Orange Pi 5 (rk3588s) board and the
results are as follows:

Before this change:

$ dmesg | grep 'tyr'
[   19.698338] tyr fb000000.gpu: mali-unknown id 0xa867 major 0x67 minor 0x0 status 0x5
[   19.699050] tyr fb000000.gpu: Features: L2:0x7120306 Tiler:0x809 Mem:0x301 MMU:0x2830 AS:0xff
[   19.699817] tyr fb000000.gpu: shader_present=0x0000000000050005 l2_present=0x0000000000000001 tiler_present=0x0000000000000001
[   19.702493] tyr fb000000.gpu: Tyr initialized correctly.

After this change:

$ dmesg | grep 'tyr'
[   19.591692] tyr fb000000.gpu: mali-g610 id 0xa867 major 0x0 minor 0x0 status 0x5
[   19.592374] tyr fb000000.gpu: Features: L2:0x7120306 Tiler:0x809 Mem:0x301 MMU:0x2830 AS:0xff
[   19.593141] tyr fb000000.gpu: shader_present=0x0000000000050005 l2_present=0x0000000000000001 tiler_present=0x0000000000000001
[   19.595831] tyr fb000000.gpu: Tyr initialized correctly.

Signed-off-by: Onur Özkan <work@onurozkan.dev>
---
 drivers/gpu/drm/tyr/gpu.rs | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/tyr/gpu.rs b/drivers/gpu/drm/tyr/gpu.rs
index 6c582910dd5d..da97844efbec 100644
--- a/drivers/gpu/drm/tyr/gpu.rs
+++ b/drivers/gpu/drm/tyr/gpu.rs
@@ -99,13 +99,11 @@ pub(crate) fn new(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result<Self> {
     }
 
     pub(crate) fn log(&self, pdev: &platform::Device) {
-        let major = (self.gpu_id >> 16) & 0xff;
-        let minor = (self.gpu_id >> 8) & 0xff;
-        let status = self.gpu_id & 0xff;
+        let gpu_id = GpuId::from(self.gpu_id);
 
         let model_name = if let Some(model) = GPU_MODELS
             .iter()
-            .find(|&f| f.major == major && f.minor == minor)
+            .find(|&f| f.arch_major == gpu_id.arch_major && f.prod_major == gpu_id.prod_major)
         {
             model.name
         } else {
@@ -117,9 +115,9 @@ pub(crate) fn log(&self, pdev: &platform::Device) {
             "mali-{} id 0x{:x} major 0x{:x} minor 0x{:x} status 0x{:x}",
             model_name,
             self.gpu_id >> 16,
-            major,
-            minor,
-            status
+            gpu_id.ver_major,
+            gpu_id.ver_minor,
+            gpu_id.ver_status
         );
 
         dev_info!(
@@ -167,14 +165,14 @@ unsafe impl AsBytes for GpuInfo {}
 
 struct GpuModels {
     name: &'static str,
-    major: u32,
-    minor: u32,
+    arch_major: u32,
+    prod_major: u32,
 }
 
 const GPU_MODELS: [GpuModels; 1] = [GpuModels {
     name: "g610",
-    major: 10,
-    minor: 7,
+    arch_major: 10,
+    prod_major: 7,
 }];
 
 #[allow(dead_code)]
-- 
2.51.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] drm/tyr: gpu: fix GpuInfo::log model/version decoding
  2026-02-10 18:38 [PATCH v1] drm/tyr: gpu: fix GpuInfo::log model/version decoding Onur Özkan
@ 2026-02-11  7:33 ` 孙科
  2026-02-12 12:25 ` Boris Brezillon
  2026-02-24  7:42 ` Alice Ryhl
  2 siblings, 0 replies; 4+ messages in thread
From: 孙科 @ 2026-02-11  7:33 UTC (permalink / raw)
  To: Onur Özkan
  Cc: daniel.almeida, aliceryhl, dakr, airlied, simona, dri-devel,
	linux-kernel, rust-for-linux

Verified on my NanoPi R6C; the GPU model is now correctly detected and
printed as follows:

root@nanopi-r6s:~# dmesg | grep tyr
[    1.894322] tyr fb000000.gpu: supply sram not found, using dummy regulator
[    1.894527] tyr fb000000.gpu: mali-g610 id 0xa867 major 0x0 minor
0x0 status 0x5
[    1.894534] tyr fb000000.gpu: Features: L2:0x7120306 Tiler:0x809
Mem:0x301 MMU:0x2830 AS:0xff
[    1.894539] tyr fb000000.gpu: shader_present=0x0000000000050005
l2_present=0x0000000000000001 tiler_present=0x0000000000000001
[    1.895170] tyr fb000000.gpu: Tyr initialized correctly.

Tested-by: Alvin Sun <sk.alvin.x@gmail.com>

Best regards,
Alvin

On Wed, Feb 11, 2026 at 2:45 AM Onur Özkan <work@onurozkan.dev> wrote:
>
> GpuInfo::log() was decoding GPU_ID like this:
>
>   major = (self.gpu_id >> 16) & 0xff;
>   minor = (self.gpu_id >> 8) & 0xff;
>   status = self.gpu_id & 0xff;
>
> That does not match the Mali GPU_ID layout and mixes unrelated
> fields. Due to that, model detection becomes `mali-unknown` on
> rk3588s which is wrong.
>
> We can already get all the version information with a single
> GpuId::from call (less code and cleaner), so this patch uses it.
>
> Also renamed `GpuModels` fields from `major/minor` to
> `arch_major/prod_major` to reflect their real meaning.
>
> This change was tested on Orange Pi 5 (rk3588s) board and the
> results are as follows:
>
> Before this change:
>
> $ dmesg | grep 'tyr'
> [   19.698338] tyr fb000000.gpu: mali-unknown id 0xa867 major 0x67 minor 0x0 status 0x5
> [   19.699050] tyr fb000000.gpu: Features: L2:0x7120306 Tiler:0x809 Mem:0x301 MMU:0x2830 AS:0xff
> [   19.699817] tyr fb000000.gpu: shader_present=0x0000000000050005 l2_present=0x0000000000000001 tiler_present=0x0000000000000001
> [   19.702493] tyr fb000000.gpu: Tyr initialized correctly.
>
> After this change:
>
> $ dmesg | grep 'tyr'
> [   19.591692] tyr fb000000.gpu: mali-g610 id 0xa867 major 0x0 minor 0x0 status 0x5
> [   19.592374] tyr fb000000.gpu: Features: L2:0x7120306 Tiler:0x809 Mem:0x301 MMU:0x2830 AS:0xff
> [   19.593141] tyr fb000000.gpu: shader_present=0x0000000000050005 l2_present=0x0000000000000001 tiler_present=0x0000000000000001
> [   19.595831] tyr fb000000.gpu: Tyr initialized correctly.
>
> Signed-off-by: Onur Özkan <work@onurozkan.dev>
> ---
>  drivers/gpu/drm/tyr/gpu.rs | 20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/tyr/gpu.rs b/drivers/gpu/drm/tyr/gpu.rs
> index 6c582910dd5d..da97844efbec 100644
> --- a/drivers/gpu/drm/tyr/gpu.rs
> +++ b/drivers/gpu/drm/tyr/gpu.rs
> @@ -99,13 +99,11 @@ pub(crate) fn new(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result<Self> {
>      }
>
>      pub(crate) fn log(&self, pdev: &platform::Device) {
> -        let major = (self.gpu_id >> 16) & 0xff;
> -        let minor = (self.gpu_id >> 8) & 0xff;
> -        let status = self.gpu_id & 0xff;
> +        let gpu_id = GpuId::from(self.gpu_id);
>
>          let model_name = if let Some(model) = GPU_MODELS
>              .iter()
> -            .find(|&f| f.major == major && f.minor == minor)
> +            .find(|&f| f.arch_major == gpu_id.arch_major && f.prod_major == gpu_id.prod_major)
>          {
>              model.name
>          } else {
> @@ -117,9 +115,9 @@ pub(crate) fn log(&self, pdev: &platform::Device) {
>              "mali-{} id 0x{:x} major 0x{:x} minor 0x{:x} status 0x{:x}",
>              model_name,
>              self.gpu_id >> 16,
> -            major,
> -            minor,
> -            status
> +            gpu_id.ver_major,
> +            gpu_id.ver_minor,
> +            gpu_id.ver_status
>          );
>
>          dev_info!(
> @@ -167,14 +165,14 @@ unsafe impl AsBytes for GpuInfo {}
>
>  struct GpuModels {
>      name: &'static str,
> -    major: u32,
> -    minor: u32,
> +    arch_major: u32,
> +    prod_major: u32,
>  }
>
>  const GPU_MODELS: [GpuModels; 1] = [GpuModels {
>      name: "g610",
> -    major: 10,
> -    minor: 7,
> +    arch_major: 10,
> +    prod_major: 7,
>  }];
>
>  #[allow(dead_code)]
> --
> 2.51.2
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] drm/tyr: gpu: fix GpuInfo::log model/version decoding
  2026-02-10 18:38 [PATCH v1] drm/tyr: gpu: fix GpuInfo::log model/version decoding Onur Özkan
  2026-02-11  7:33 ` 孙科
@ 2026-02-12 12:25 ` Boris Brezillon
  2026-02-24  7:42 ` Alice Ryhl
  2 siblings, 0 replies; 4+ messages in thread
From: Boris Brezillon @ 2026-02-12 12:25 UTC (permalink / raw)
  To: Onur Özkan
  Cc: daniel.almeida, aliceryhl, dakr, airlied, simona, dri-devel,
	linux-kernel, rust-for-linux

On Tue, 10 Feb 2026 21:38:12 +0300
Onur Özkan <work@onurozkan.dev> wrote:

> GpuInfo::log() was decoding GPU_ID like this:
> 
>   major = (self.gpu_id >> 16) & 0xff;
>   minor = (self.gpu_id >> 8) & 0xff;
>   status = self.gpu_id & 0xff;
> 
> That does not match the Mali GPU_ID layout and mixes unrelated
> fields. Due to that, model detection becomes `mali-unknown` on
> rk3588s which is wrong.
> 
> We can already get all the version information with a single
> GpuId::from call (less code and cleaner), so this patch uses it.
> 
> Also renamed `GpuModels` fields from `major/minor` to
> `arch_major/prod_major` to reflect their real meaning.
> 
> This change was tested on Orange Pi 5 (rk3588s) board and the
> results are as follows:
> 
> Before this change:
> 
> $ dmesg | grep 'tyr'
> [   19.698338] tyr fb000000.gpu: mali-unknown id 0xa867 major 0x67 minor 0x0 status 0x5
> [   19.699050] tyr fb000000.gpu: Features: L2:0x7120306 Tiler:0x809 Mem:0x301 MMU:0x2830 AS:0xff
> [   19.699817] tyr fb000000.gpu: shader_present=0x0000000000050005 l2_present=0x0000000000000001 tiler_present=0x0000000000000001
> [   19.702493] tyr fb000000.gpu: Tyr initialized correctly.
> 
> After this change:
> 
> $ dmesg | grep 'tyr'
> [   19.591692] tyr fb000000.gpu: mali-g610 id 0xa867 major 0x0 minor 0x0 status 0x5
> [   19.592374] tyr fb000000.gpu: Features: L2:0x7120306 Tiler:0x809 Mem:0x301 MMU:0x2830 AS:0xff
> [   19.593141] tyr fb000000.gpu: shader_present=0x0000000000050005 l2_present=0x0000000000000001 tiler_present=0x0000000000000001
> [   19.595831] tyr fb000000.gpu: Tyr initialized correctly.
> 
> Signed-off-by: Onur Özkan <work@onurozkan.dev>

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

> ---
>  drivers/gpu/drm/tyr/gpu.rs | 20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tyr/gpu.rs b/drivers/gpu/drm/tyr/gpu.rs
> index 6c582910dd5d..da97844efbec 100644
> --- a/drivers/gpu/drm/tyr/gpu.rs
> +++ b/drivers/gpu/drm/tyr/gpu.rs
> @@ -99,13 +99,11 @@ pub(crate) fn new(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result<Self> {
>      }
>  
>      pub(crate) fn log(&self, pdev: &platform::Device) {
> -        let major = (self.gpu_id >> 16) & 0xff;
> -        let minor = (self.gpu_id >> 8) & 0xff;
> -        let status = self.gpu_id & 0xff;
> +        let gpu_id = GpuId::from(self.gpu_id);
>  
>          let model_name = if let Some(model) = GPU_MODELS
>              .iter()
> -            .find(|&f| f.major == major && f.minor == minor)
> +            .find(|&f| f.arch_major == gpu_id.arch_major && f.prod_major == gpu_id.prod_major)
>          {
>              model.name
>          } else {
> @@ -117,9 +115,9 @@ pub(crate) fn log(&self, pdev: &platform::Device) {
>              "mali-{} id 0x{:x} major 0x{:x} minor 0x{:x} status 0x{:x}",
>              model_name,
>              self.gpu_id >> 16,
> -            major,
> -            minor,
> -            status
> +            gpu_id.ver_major,
> +            gpu_id.ver_minor,
> +            gpu_id.ver_status
>          );
>  
>          dev_info!(
> @@ -167,14 +165,14 @@ unsafe impl AsBytes for GpuInfo {}
>  
>  struct GpuModels {
>      name: &'static str,
> -    major: u32,
> -    minor: u32,
> +    arch_major: u32,
> +    prod_major: u32,
>  }
>  
>  const GPU_MODELS: [GpuModels; 1] = [GpuModels {
>      name: "g610",
> -    major: 10,
> -    minor: 7,
> +    arch_major: 10,
> +    prod_major: 7,
>  }];
>  
>  #[allow(dead_code)]


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] drm/tyr: gpu: fix GpuInfo::log model/version decoding
  2026-02-10 18:38 [PATCH v1] drm/tyr: gpu: fix GpuInfo::log model/version decoding Onur Özkan
  2026-02-11  7:33 ` 孙科
  2026-02-12 12:25 ` Boris Brezillon
@ 2026-02-24  7:42 ` Alice Ryhl
  2 siblings, 0 replies; 4+ messages in thread
From: Alice Ryhl @ 2026-02-24  7:42 UTC (permalink / raw)
  To: Onur Özkan
  Cc: daniel.almeida, dakr, airlied, simona, dri-devel, linux-kernel,
	rust-for-linux

On Tue, Feb 10, 2026 at 09:38:12PM +0300, Onur Özkan wrote:
> GpuInfo::log() was decoding GPU_ID like this:
> 
>   major = (self.gpu_id >> 16) & 0xff;
>   minor = (self.gpu_id >> 8) & 0xff;
>   status = self.gpu_id & 0xff;
> 
> That does not match the Mali GPU_ID layout and mixes unrelated
> fields. Due to that, model detection becomes `mali-unknown` on
> rk3588s which is wrong.
> 
> We can already get all the version information with a single
> GpuId::from call (less code and cleaner), so this patch uses it.
> 
> Also renamed `GpuModels` fields from `major/minor` to
> `arch_major/prod_major` to reflect their real meaning.
> 
> This change was tested on Orange Pi 5 (rk3588s) board and the
> results are as follows:
> 
> Before this change:
> 
> $ dmesg | grep 'tyr'
> [   19.698338] tyr fb000000.gpu: mali-unknown id 0xa867 major 0x67 minor 0x0 status 0x5
> [   19.699050] tyr fb000000.gpu: Features: L2:0x7120306 Tiler:0x809 Mem:0x301 MMU:0x2830 AS:0xff
> [   19.699817] tyr fb000000.gpu: shader_present=0x0000000000050005 l2_present=0x0000000000000001 tiler_present=0x0000000000000001
> [   19.702493] tyr fb000000.gpu: Tyr initialized correctly.
> 
> After this change:
> 
> $ dmesg | grep 'tyr'
> [   19.591692] tyr fb000000.gpu: mali-g610 id 0xa867 major 0x0 minor 0x0 status 0x5
> [   19.592374] tyr fb000000.gpu: Features: L2:0x7120306 Tiler:0x809 Mem:0x301 MMU:0x2830 AS:0xff
> [   19.593141] tyr fb000000.gpu: shader_present=0x0000000000050005 l2_present=0x0000000000000001 tiler_present=0x0000000000000001
> [   19.595831] tyr fb000000.gpu: Tyr initialized correctly.
> 
> Signed-off-by: Onur Özkan <work@onurozkan.dev>

Applied to drm-rust-next. Thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-02-24  7:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-10 18:38 [PATCH v1] drm/tyr: gpu: fix GpuInfo::log model/version decoding Onur Özkan
2026-02-11  7:33 ` 孙科
2026-02-12 12:25 ` Boris Brezillon
2026-02-24  7:42 ` Alice Ryhl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox