From: Troy Hanson Date: Tue, 23 Dec 2025 17:02:26 +0000 (+0100) Subject: accel/qaic: Simplify bootlog line handling X-Git-Tag: v7.2-rc1~141^2~26^2~189 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=92f210c019ac29e72006070f75860448f91d9ddc;p=thirdparty%2Fkernel%2Flinux.git accel/qaic: Simplify bootlog line handling 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 Signed-off-by: Youssef Samir Reviewed-by: Jeff Hugo Signed-off-by: Jeff Hugo Link: https://patch.msgid.link/20251223170226.2275812-1-youssef.abdulrahman@oss.qualcomm.com --- diff --git a/drivers/accel/qaic/qaic_debugfs.c b/drivers/accel/qaic/qaic_debugfs.c index 5289d33744baf..eca0b1fa1c14c 100644 --- a/drivers/accel/qaic/qaic_debugfs.c +++ b/drivers/accel/qaic/qaic_debugfs.c @@ -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); }