drm/nouveau/subdev/bus: Ratelimit logging for fault errors
authorLyude Paul <lyude@redhat.com>
Fri, 29 Apr 2022 19:53:47 +0000 (15:53 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:23:24 +0000 (10:23 +0200)
commit 9887bda0c831df0c044d6de147d002e48024fb4a upstream.

There's plenty of ways to fudge the GPU when developing on nouveau by
mistake, some of which can result in nouveau seriously spamming dmesg with
fault errors. This can be somewhat annoying, as it can quickly overrun the
message buffer (or your terminal emulator's buffer) and get rid of actually
useful feedback from the driver. While working on my new atomic only MST
branch, I ran into this issue a couple of times.

So, let's fix this by adding nvkm_error_ratelimited(), and using it to
ratelimit errors from faults. This should be fine for developers, since
it's nearly always only the first few faults that we care about seeing.
Plus, you can turn off rate limiting in the kernel if you really need to.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Cc: stable@vger.kernel.org
Link: https://patchwork.freedesktop.org/patch/msgid/20220429195350.85620-1-lyude@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h
drivers/gpu/drm/nouveau/nvkm/subdev/bus/gf100.c
drivers/gpu/drm/nouveau/nvkm/subdev/bus/nv31.c
drivers/gpu/drm/nouveau/nvkm/subdev/bus/nv50.c

index 1665738948fb474127ec67d3b9ea64653c94b829..96113c8bee8c5eca479d3fbd9b2345c81c5da8e3 100644 (file)
@@ -62,4 +62,6 @@ void nvkm_subdev_intr(struct nvkm_subdev *);
 #define nvkm_debug(s,f,a...) nvkm_printk((s), DEBUG,   info, f, ##a)
 #define nvkm_trace(s,f,a...) nvkm_printk((s), TRACE,   info, f, ##a)
 #define nvkm_spam(s,f,a...)  nvkm_printk((s),  SPAM,    dbg, f, ##a)
+
+#define nvkm_error_ratelimited(s,f,a...) nvkm_printk((s), ERROR, err_ratelimited, f, ##a)
 #endif
index 53a6651ac22581dc29a2702613a2275dd99cf88f..80b5aaceeaad17f6dde872cdac8c641dec6ce182 100644 (file)
@@ -35,13 +35,13 @@ gf100_bus_intr(struct nvkm_bus *bus)
                u32 addr = nvkm_rd32(device, 0x009084);
                u32 data = nvkm_rd32(device, 0x009088);
 
-               nvkm_error(subdev,
-                          "MMIO %s of %08x FAULT at %06x [ %s%s%s]\n",
-                          (addr & 0x00000002) ? "write" : "read", data,
-                          (addr & 0x00fffffc),
-                          (stat & 0x00000002) ? "!ENGINE " : "",
-                          (stat & 0x00000004) ? "PRIVRING " : "",
-                          (stat & 0x00000008) ? "TIMEOUT " : "");
+               nvkm_error_ratelimited(subdev,
+                                      "MMIO %s of %08x FAULT at %06x [ %s%s%s]\n",
+                                      (addr & 0x00000002) ? "write" : "read", data,
+                                      (addr & 0x00fffffc),
+                                      (stat & 0x00000002) ? "!ENGINE " : "",
+                                      (stat & 0x00000004) ? "PRIVRING " : "",
+                                      (stat & 0x00000008) ? "TIMEOUT " : "");
 
                nvkm_wr32(device, 0x009084, 0x00000000);
                nvkm_wr32(device, 0x001100, (stat & 0x0000000e));
index ad8da523bb22e3e95862cf873126ae1451860394..c75e463f350136c425ae0c78a2c6bbaa6037cfae 100644 (file)
@@ -45,9 +45,9 @@ nv31_bus_intr(struct nvkm_bus *bus)
                u32 addr = nvkm_rd32(device, 0x009084);
                u32 data = nvkm_rd32(device, 0x009088);
 
-               nvkm_error(subdev, "MMIO %s of %08x FAULT at %06x\n",
-                          (addr & 0x00000002) ? "write" : "read", data,
-                          (addr & 0x00fffffc));
+               nvkm_error_ratelimited(subdev, "MMIO %s of %08x FAULT at %06x\n",
+                                      (addr & 0x00000002) ? "write" : "read", data,
+                                      (addr & 0x00fffffc));
 
                stat &= ~0x00000008;
                nvkm_wr32(device, 0x001100, 0x00000008);
index 3a1e45adeedc1c6d36b82eec3477485f29254ace..2055d0b100d3f001cb489ae0054a25270ed07237 100644 (file)
@@ -60,9 +60,9 @@ nv50_bus_intr(struct nvkm_bus *bus)
                u32 addr = nvkm_rd32(device, 0x009084);
                u32 data = nvkm_rd32(device, 0x009088);
 
-               nvkm_error(subdev, "MMIO %s of %08x FAULT at %06x\n",
-                          (addr & 0x00000002) ? "write" : "read", data,
-                          (addr & 0x00fffffc));
+               nvkm_error_ratelimited(subdev, "MMIO %s of %08x FAULT at %06x\n",
+                                      (addr & 0x00000002) ? "write" : "read", data,
+                                      (addr & 0x00fffffc));
 
                stat &= ~0x00000008;
                nvkm_wr32(device, 0x001100, 0x00000008);