]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
accel/qaic: Simplify bootlog line handling
authorTroy Hanson <thanson@qti.qualcomm.com>
Tue, 23 Dec 2025 17:02:26 +0000 (18:02 +0100)
committerJeff Hugo <jeff.hugo@oss.qualcomm.com>
Fri, 27 Mar 2026 17:12:34 +0000 (11:12 -0600)
Instead of storing and emitting bootlogs as individual null-terminated
lines, concatenate them, and later emit them to debugfs in a single call.

Do not insert a null terminator on messages received from the device.
Instead use the message length when subsequently storing the message.

Exclude trailing nulls to normalize AIC100 and AIC200 bootlog lines.

Signed-off-by: Troy Hanson <thanson@qti.qualcomm.com>
Signed-off-by: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com>
Reviewed-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>
Signed-off-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>
Link: https://patch.msgid.link/20251223170226.2275812-1-youssef.abdulrahman@oss.qualcomm.com
drivers/accel/qaic/qaic_debugfs.c

index 5289d33744baf5f711a6eb27928aac9461483fb4..eca0b1fa1c14c8fb3b7c593f0904785ffe617137 100644 (file)
@@ -27,6 +27,8 @@
 struct bootlog_msg {
        /* Buffer for bootlog messages */
        char str[BOOTLOG_MSG_SIZE];
+       /* Length of bootlog message */
+       size_t len;
        /* Root struct of device, used to access device resources */
        struct qaic_device *qdev;
        /* Work struct to schedule work coming on QAIC_LOGGING channel */
@@ -46,18 +48,15 @@ static int bootlog_show(struct seq_file *s, void *unused)
 {
        struct bootlog_page *page;
        struct qaic_device *qdev;
-       void *page_end;
+       size_t len;
        void *log;
 
        qdev = s->private;
        mutex_lock(&qdev->bootlog_mutex);
        list_for_each_entry(page, &qdev->bootlog, node) {
                log = page + 1;
-               page_end = (void *)page + page->offset;
-               while (log < page_end) {
-                       seq_printf(s, "%s", (char *)log);
-                       log += strlen(log) + 1;
-               }
+               len = page->offset - sizeof(*page);
+               seq_write(s, log, len);
        }
        mutex_unlock(&qdev->bootlog_mutex);
 
@@ -182,15 +181,14 @@ static void bootlog_commit(struct qaic_device *qdev, unsigned int size)
 static void bootlog_log(struct work_struct *work)
 {
        struct bootlog_msg *msg = container_of(work, struct bootlog_msg, work);
-       unsigned int len = strlen(msg->str) + 1;
        struct qaic_device *qdev = msg->qdev;
        void *log;
 
        mutex_lock(&qdev->bootlog_mutex);
-       log = bootlog_get_space(qdev, len);
+       log = bootlog_get_space(qdev, msg->len);
        if (log) {
-               memcpy(log, msg, len);
-               bootlog_commit(qdev, len);
+               memcpy(log, msg, msg->len);
+               bootlog_commit(qdev, msg->len);
        }
        mutex_unlock(&qdev->bootlog_mutex);
 
@@ -271,8 +269,11 @@ static void qaic_bootlog_mhi_dl_xfer_cb(struct mhi_device *mhi_dev, struct mhi_r
                return;
        }
 
-       /* Force a null at the end of the transferred string */
-       msg->str[mhi_result->bytes_xferd - 1] = 0;
+       msg->len = mhi_result->bytes_xferd;
+
+       /* Exclude trailing null to normalize AIC100/AIC200 line endings */
+       if (msg->len && msg->str[msg->len - 1] == '\0')
+               msg->len--;
 
        queue_work(qdev->bootlog_wq, &msg->work);
 }