[PATCH v2] drm/radeon: Prevent multiple debug error lines on suspend

2023-12-13 Thread Woody Suwalski
Fix to avoid multiple debug error lines printed on every suspend by 
Radeon driver's debugfs.


radeon_debugfs_init() calls debugfs_create_file() for every ring.

This results in printing multiple error lines to the screen and dmesg 
similar to this:


[   92.378726] debugfs: File 'radeon_ring_gfx' in directory 
':00:01.0' already present!
[   92.378732] debugfs: File 'radeon_ring_cp1' in directory 
':00:01.0' already present!
[   92.378734] debugfs: File 'radeon_ring_cp2' in directory 
':00:01.0' already present!
[   92.378737] debugfs: File 'radeon_ring_dma1' in directory 
':00:01.0' already present!
[   92.378739] debugfs: File 'radeon_ring_dma2' in directory 
':00:01.0' already present!
[   92.380775] debugfs: File 'radeon_ring_uvd' in directory 
':00:01.0' already present!
[   92.406620] debugfs: File 'radeon_ring_vce1' in directory 
':00:01.0' already present!
[   92.406624] debugfs: File 'radeon_ring_vce2' in directory 
':00:01.0' already present!



Patch v1: The fix was to run lookup() for the file before trying to 
(re)create that debug file.
Patch v2: Call the radeon_debugfs_init() only once when radeon ring is 
initialized (as suggested  by Christian K. - thanks)


Signed-off-by: Woody Suwalski 

diff --git a/drivers/gpu/drm/radeon/radeon_ring.c 
b/drivers/gpu/drm/radeon/radeon_ring.c

index e6534fa9f1fb..38048593bb4a 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -413,6 +413,7 @@ int radeon_ring_init(struct radeon_device *rdev, 
struct radeon_ring *ring, unsig

         dev_err(rdev->dev, "(%d) ring map failed\n", r);
         return r;
     }
+        radeon_debugfs_ring_init(rdev, ring);
 }
 ring->ptr_mask = (ring->ring_size / 4) - 1;
 ring->ring_free_dw = ring->ring_size / 4;
@@ -421,7 +422,6 @@ int radeon_ring_init(struct radeon_device *rdev, 
struct radeon_ring *ring, unsig

     ring->next_rptr_gpu_addr = rdev->wb.gpu_addr + index;
     ring->next_rptr_cpu_addr = >wb.wb[index/4];
 }
-    radeon_debugfs_ring_init(rdev, ring);
 radeon_ring_lockup_update(rdev, ring);
 return 0;
 }



Re: [PATCH] drm/radeon: Prevent multiple error lines on suspend

2023-12-11 Thread Woody Suwalski
Hello, it has been now over 2 weeks and I have not seen any response to 
this patch.

Has it been lost in the cracks of the wide internet ? :-(

Thanks, Woody


Woody Suwalski wrote:
# Fix to avoid multiple error lines printed on every suspend by Radeon 
driver's debugfs.

#
# radeon_debugfs_init() calls debugfs_create_file() for every ring.
#
# This results in printing multiple error lines to the screen and 
dmesg similar to this:
# debugfs: File 'radeon_ring_vce2' in directory ':00:01.0' already 
present!

#
# The fix is to run lookup for the file before trying to (re)create 
that debug file.


# Signed-off-by: Woody Suwalski 

diff --git a/drivers/gpu/drm/radeon/radeon_ring.c 
b/drivers/gpu/drm/radeon/radeon_ring.c

index e6534fa9f1fb..72b1d2d31295 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -549,10 +549,15 @@ static void radeon_debugfs_ring_init(struct 
radeon_device *rdev, struct radeon_r

 #if defined(CONFIG_DEBUG_FS)
     const char *ring_name = radeon_debugfs_ring_idx_to_name(ring->idx);
     struct dentry *root = rdev->ddev->primary->debugfs_root;
-
-    if (ring_name)
-        debugfs_create_file(ring_name, 0444, root, ring,
-                _debugfs_ring_info_fops);
+    struct dentry *lookup;
+
+    if (ring_name) {
+        if ((lookup = debugfs_lookup(ring_name, root)) == NULL)
+            debugfs_create_file(ring_name, 0444, root, ring,
+                    _debugfs_ring_info_fops);
+        else
+            dput(lookup);
+    }

 #endif
 }





[PATCH] drm/radeon: Prevent multiple error lines on suspend

2023-11-23 Thread Woody Suwalski
# Fix to avoid multiple error lines printed on every suspend by Radeon 
driver's debugfs.

#
# radeon_debugfs_init() calls debugfs_create_file() for every ring.
#
# This results in printing multiple error lines to the screen and dmesg 
similar to this:
# debugfs: File 'radeon_ring_vce2' in directory ':00:01.0' already 
present!

#
# The fix is to run lookup for the file before trying to (re)create that 
debug file.


# Signed-off-by: Woody Suwalski 

diff --git a/drivers/gpu/drm/radeon/radeon_ring.c 
b/drivers/gpu/drm/radeon/radeon_ring.c

index e6534fa9f1fb..72b1d2d31295 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -549,10 +549,15 @@ static void radeon_debugfs_ring_init(struct 
radeon_device *rdev, struct radeon_r

 #if defined(CONFIG_DEBUG_FS)
     const char *ring_name = radeon_debugfs_ring_idx_to_name(ring->idx);
     struct dentry *root = rdev->ddev->primary->debugfs_root;
-
-    if (ring_name)
-        debugfs_create_file(ring_name, 0444, root, ring,
-                _debugfs_ring_info_fops);
+    struct dentry *lookup;
+
+    if (ring_name) {
+        if ((lookup = debugfs_lookup(ring_name, root)) == NULL)
+            debugfs_create_file(ring_name, 0444, root, ring,
+                    _debugfs_ring_info_fops);
+        else
+            dput(lookup);
+    }

 #endif
 }

[0.00] Linux version 6.7-pingu (kernel@pingu64builder) (gcc (Debian 
12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #0~rc2 SMP 
PREEMPT_DYNAMIC Sun Nov 19 22:15:18 EST 2023
[0.00] Command line: initrd=\EFI\Pingu\boot\init-6.7-pingu.img quiet 
net.ifnames=0 loop.max_part=7 root=/dev/sda7 resume=swap:/dev/sda6 
log_buf_len=128k SHOWSPLASH=y splash systemd.show-status=0
[0.00] BIOS-provided physical RAM map:
[0.00] BIOS-e820: [mem 0x-0x0006dfff] usable
[0.00] BIOS-e820: [mem 0x0006e000-0x0006] ACPI NVS
[0.00] BIOS-e820: [mem 0x0007-0x00085fff] usable
[0.00] BIOS-e820: [mem 0x00086000-0x000b] reserved
[0.00] BIOS-e820: [mem 0x0010-0x93aecfff] usable
[0.00] BIOS-e820: [mem 0x93aed000-0x942edfff] reserved
[0.00] BIOS-e820: [mem 0x942ee000-0x9e17efff] usable
[0.00] BIOS-e820: [mem 0x9e17f000-0x9f97efff] reserved
[0.00] BIOS-e820: [mem 0x9f97f000-0x9fb7efff] ACPI NVS
[0.00] BIOS-e820: [mem 0x9fb7f000-0x9fbfefff] ACPI data
[0.00] BIOS-e820: [mem 0x9fbff000-0x9fbf] usable
[0.00] BIOS-e820: [mem 0x9fc0-0xdfff] reserved
[0.00] BIOS-e820: [mem 0xf090-0xf09f] reserved
[0.00] BIOS-e820: [mem 0xf800-0xfbff] reserved
[0.00] BIOS-e820: [mem 0xfec0-0xfec01fff] reserved
[0.00] BIOS-e820: [mem 0xfec1-0xfec10fff] reserved
[0.00] BIOS-e820: [mem 0xfed8-0xfed80fff] reserved
[0.00] BIOS-e820: [mem 0xfee0-0xfee00fff] reserved
[0.00] BIOS-e820: [mem 0xff80-0x] reserved
[0.00] BIOS-e820: [mem 0x0001-0x00021eff] usable
[0.00] NX (Execute Disable) protection: active
[0.00] APIC: Static calls initialized
[0.00] e820: update [mem 0x921db018-0x921e9c57] usable ==> usable
[0.00] e820: update [mem 0x921db018-0x921e9c57] usable ==> usable
[0.00] extended physical RAM map:
[0.00] reserve setup_data: [mem 0x-0x0006dfff] 
usable
[0.00] reserve setup_data: [mem 0x0006e000-0x0006] 
ACPI NVS
[0.00] reserve setup_data: [mem 0x0007-0x00085fff] 
usable
[0.00] reserve setup_data: [mem 0x00086000-0x000b] 
reserved
[0.00] reserve setup_data: [mem 0x0010-0x921db017] 
usable
[0.00] reserve setup_data: [mem 0x921db018-0x921e9c57] 
usable
[0.00] reserve setup_data: [mem 0x921e9c58-0x93aecfff] 
usable
[0.00] reserve setup_data: [mem 0x93aed000-0x942edfff] 
reserved
[0.00] reserve setup_data: [mem 0x942ee000-0x9e17efff] 
usable
[0.00] reserve setup_data: [mem 0x9e17f000-0x9f97efff] 
reserved
[0.00] reserve setup_data: [mem 0x9f97f000-0x9fb7efff] 
ACPI NVS
[0.00] reserve setup_data: [mem 0x9fb7f000-0x9fbfefff] 
ACPI data
[0.00] reserve setup_data: [mem 0x9fbff000-0x9fbf] 
usable
[0.00] reserve setup_data: [mem 0x9fc0-0xdfff] 
reserved
[0.00] reserve setup_data: [mem 0xf090-0xf