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 <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
This commit is contained in:
Troy Hanson 2025-12-23 18:02:26 +01:00 committed by Jeff Hugo
parent 140d5d411a
commit 92f210c019

View 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);
}