Skip to contentSkip to conversation

drm/msm/disp: fix endian bug in debugfs code

PATCH In review Dan Carpenter 3 participants 4 messages Oct 4, 2021 – Oct 5, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/msm/disp: fix endian bug in debugfs code

The "vbif->features" is type unsigned long but the debugfs file is treating it as a u32 type. This will work in little endian systems, but the correct thing is to change the debugfs to use an unsigned long.

Fixes 25fdd5933e4c ("drm/msm: Add SDM845 DPU support")

---
You might wonder why this code has so many casts. It's required because this data is const. Which is fine because the file is read only.

 drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c +2 -2
index 21d20373eb8b..e645a886e3c6 100644
@@ -305,8 +305,8 @@ void dpu_debugfs_vbif_init(struct dpu_kms *dpu_kms, struct dentry *debugfs_root)
 
 		debugfs_vbif = debugfs_create_dir(vbif_name, entry);
 
-		debugfs_create_u32("features", 0600, debugfs_vbif,
-			(u32 *)&vbif->features);
+		debugfs_create_ulong("features", 0600, debugfs_vbif,
+				     (unsigned long *)&vbif->features);
 
 		debugfs_create_u32("xin_halt_timeout", 0400, debugfs_vbif,
 			(u32 *)&vbif->xin_halt_timeout);
Signature · 1 line
2.20.1
#1 lore raw
Quoted 19 lines · Dan Carpenter

The "vbif->features" is type unsigned long but the debugfs file is treating it as a u32 type. This will work in little endian systems, but the correct thing is to change the debugfs to use an unsigned long.

Fixes 25fdd5933e4c ("drm/msm: Add SDM845 DPU support")

---
You might wonder why this code has so many casts. It's required because this data is const. Which is fine because the file is read only.

  drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c +0 -0
index 21d20373eb8b..e645a886e3c6 100644

drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c void dpu_debugfs_vbif_init(struct dpu_kms *dpu_kms, struct dentry *debugfs_root) · line 309

Quoted 7 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c +2 -2
@@ -305,8 +305,8 @@ void dpu_debugfs_vbif_init(struct dpu_kms *dpu_kms, struct dentry *debugfs_root)
 
  		debugfs_vbif = debugfs_create_dir(vbif_name, entry);
 
-		debugfs_create_u32("features", 0600, debugfs_vbif,
-			(u32 *)&vbif->features);
+		debugfs_create_ulong("features", 0600, debugfs_vbif,
+				     (unsigned long *)&vbif->features);

As you are converting this to the ulong file, could you please also remove the now-unnecessary type cast?

Quoted 4 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c +0 -0
  		debugfs_create_u32("xin_halt_timeout", 0400, debugfs_vbif,
  			(u32 *)&vbif->xin_halt_timeout);
 
Signature · 2 lines
With best wishes
Dmitry
#2 lore raw
Quoted 11 lines · Dmitry Baryshkov
Quoted 10 lines · Dan Carpenter

The "vbif->features" is type unsigned long but the debugfs file is treating it as a u32 type. This will work in little endian systems, but the correct thing is to change the debugfs to use an unsigned long.

Fixes 25fdd5933e4c ("drm/msm: Add SDM845 DPU support")

---
You might wonder why this code has so many casts. It's required because this data is const. Which is fine because the file is read only.

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 4 lines
Quoted 4 lines
  drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 13 lines

drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c void dpu_debugfs_vbif_init(struct dpu_kms *dpu_kms, struct dentry *debugfs_root) · line 307

Quoted 10 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c +2 -2
index 21d20373eb8b..e645a886e3c6 100644
@@ -305,8 +305,8 @@ void dpu_debugfs_vbif_init(struct dpu_kms *dpu_kms, struct dentry *debugfs_root)
  		debugfs_vbif = debugfs_create_dir(vbif_name, entry);
-		debugfs_create_u32("features", 0600, debugfs_vbif,
-			(u32 *)&vbif->features);
+		debugfs_create_ulong("features", 0600, debugfs_vbif,
+				     (unsigned long *)&vbif->features);

As you are converting this to the ulong file, could you please also remove the now-unnecessary type cast?

I wanted to remove all the casting but they are required because of the const.

regards,
dan carpenter

Reviewed-by on v1 1/1
#3 lore raw
In reply to Dan Carpenter
Quoted 7 lines · Dan Carpenter

The "vbif->features" is type unsigned long but the debugfs file is treating it as a u32 type. This will work in little endian systems, but the correct thing is to change the debugfs to use an unsigned long.

Fixes 25fdd5933e4c ("drm/msm: Add SDM845 DPU support")
Quoted 24 lines

---
You might wonder why this code has so many casts. It's required because this data is const. Which is fine because the file is read only.

 drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c +2 -2
index 21d20373eb8b..e645a886e3c6 100644
@@ -305,8 +305,8 @@ void dpu_debugfs_vbif_init(struct dpu_kms
 *dpu_kms, struct dentry *debugfs_root)
 
 		debugfs_vbif = debugfs_create_dir(vbif_name, entry);
 
-		debugfs_create_u32("features", 0600, debugfs_vbif,
-			(u32 *)&vbif->features);
+		debugfs_create_ulong("features", 0600, debugfs_vbif,
+				     (unsigned long *)&vbif->features);
 
 		debugfs_create_u32("xin_halt_timeout", 0400, debugfs_vbif,

(u32 *)&vbif->xin_halt_timeout);