[PATCH] tty/vt: add error logging to detect mysterious issue with RPL crashes

Andrzej Hajda andrzej.hajda at intel.com
Thu Apr 28 07:46:10 UTC 2022


See https://gitlab.freedesktop.org/drm/intel/-/issues/5329

Signed-off-by: Andrzej Hajda <andrzej.hajda at intel.com>
---
 drivers/tty/vt/vt.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index f8c87c4d739955..430d9639d9fd20 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -3627,6 +3627,8 @@ int __init vty_init(const struct file_operations *console_fops)
 
 static struct class *vtconsole_class;
 
+#define ERR(__err) ({ void *err = ERR_PTR(__err); pr_err("%s:%d: err=%pe\n", __func__, __LINE__, err); PTR_ERR(err); })
+
 static int do_bind_con_driver(const struct consw *csw, int first, int last,
 			   int deflt)
 {
@@ -3636,7 +3638,7 @@ static int do_bind_con_driver(const struct consw *csw, int first, int last,
 	int i, j = -1, k = -1, retval = -ENODEV;
 
 	if (!try_module_get(owner))
-		return -ENODEV;
+		return ERR(-ENODEV);
 
 	WARN_CONSOLE_UNLOCKED();
 
@@ -3651,7 +3653,7 @@ static int do_bind_con_driver(const struct consw *csw, int first, int last,
 		}
 	}
 
-	if (retval)
+	if (retval && ERR(retval))
 		goto err;
 
 	if (!(con_driver->flag & CON_DRIVER_FLAG_INIT)) {
@@ -4111,21 +4113,21 @@ static int do_register_con_driver(const struct consw *csw, int first, int last)
 	WARN_CONSOLE_UNLOCKED();
 
 	if (!try_module_get(owner))
-		return -ENODEV;
+		return ERR(-ENODEV);
 
 	for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
 		con_driver = &registered_con_driver[i];
 
 		/* already registered */
 		if (con_driver->con == csw) {
-			retval = -EBUSY;
+			retval = ERR(-EBUSY);
 			goto err;
 		}
 	}
 
 	desc = csw->con_startup();
 	if (!desc) {
-		retval = -ENODEV;
+		retval = ERR(-ENODEV);
 		goto err;
 	}
 
@@ -4148,7 +4150,7 @@ static int do_register_con_driver(const struct consw *csw, int first, int last)
 		}
 	}
 
-	if (retval)
+	if (retval && ERR(retval))
 		goto err;
 
 	con_driver->dev =
-- 
2.25.1



More information about the Intel-gfx-trybot mailing list