Skip to content

Commit 57368e1

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 57368e1

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

src/audio/host-zephyr.c

Lines changed: 13 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,16 @@ 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+
uint64_t now = k_uptime_get();
412+
413+
if (now - nobytes_last_logged > SOF_MIN_NO_BYTES_INTERVAL_MS) {
414+
nobytes_last_logged = now;
415+
comp_info(dev, "no bytes to copy, available samples: %d, free_samples: %d",
416+
avail_samples, free_samples);
417+
}
418+
}
409419

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

0 commit comments

Comments
 (0)