Skip to content

Commit ec00fe8

Browse files
committed
audio: rate-limit "no bytes to copy" messages
When tearing down streams, when some of the pipelines have already been deleted and some are still active, the remaining active pipelines might experience no-data conditions. Currently this is logged on every LL-scheduler period, i.e. every millisecond. This isn't adding any useful information and in fact can create a flood of outgoing IPC notifications, eventually blocking valid IPC replies and leading to IPC timeouts. Rate-limit these logging entries to fix the problem and relax the log. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 2b4d0ea commit ec00fe8

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/audio/host-zephyr.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,9 @@ static void host_dma_cb(struct comp_dev *dev, size_t bytes)
359359
host_common_one_shot(hd, bytes);
360360
}
361361

362+
/* Minimum time between 2 consecutive "no bytes to copy" messages in milliseconds */
363+
#define SOF_MIN_NO_BYTES_INTERVAL_MS 20
364+
362365
/**
363366
* Calculates bytes to be copied in normal mode.
364367
* @param dev Host component device.
@@ -403,9 +406,22 @@ static uint32_t host_get_copy_bytes_normal(struct host_data *hd, struct comp_dev
403406
if (!(hd->ipc_host.feature_mask & BIT(IPC4_COPIER_FAST_MODE)))
404407
dma_copy_bytes = MIN(hd->period_bytes, dma_copy_bytes);
405408

406-
if (!dma_copy_bytes)
407-
comp_info(dev, "no bytes to copy, available samples: %d, free_samples: %d",
408-
avail_samples, free_samples);
409+
if (!dma_copy_bytes) {
410+
static uint64_t nobytes_last_logged;
411+
static unsigned int n_skipped;
412+
uint64_t now = k_uptime_get();
413+
uint64_t delta = now - nobytes_last_logged;
414+
415+
if (delta > SOF_MIN_NO_BYTES_INTERVAL_MS) {
416+
nobytes_last_logged = now;
417+
comp_info(dev,
418+
"no bytes to copy, %u such events in last %llu ms, available samples: %d, free_samples: %d",
419+
n_skipped, delta, avail_samples, free_samples);
420+
n_skipped = 0;
421+
} else {
422+
n_skipped++;
423+
}
424+
}
409425

410426
/* dma_copy_bytes should be aligned to minimum possible chunk of
411427
* data to be copied by dma.

0 commit comments

Comments
 (0)