[Sound-open-firmware] [PATCH] [RFC]platform: calculate the percentage of cpu cycle
Jie, Yang
yang.jie at intel.com
Thu Jun 21 17:11:30 CEST 2018
>-----Original Message-----
>From: sound-open-firmware-bounces at alsa-project.org [mailto:sound-open-
>firmware-bounces at alsa-project.org] On Behalf Of Wu Zhigang
>Sent: Thursday, June 21, 2018 5:57 PM
>To: sound-open-firmware at alsa-project.org
>Cc: Wu Zhigang <zhigang.wu at linux.intel.com>
>Subject: [Sound-open-firmware] [PATCH] [RFC]platform: calculate the
>percentage of cpu cycle
>
>calculate the percentage of cpu cyle based on the CCOUNT register. which can
>tell the percentage of cpu cycle usage.
>
>Signed-off-by: Wu Zhigang <zhigang.wu at linux.intel.com>
>---
> src/audio/dai.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
>diff --git a/src/audio/dai.c b/src/audio/dai.c index 99749d1..7811e38 100644
>--- a/src/audio/dai.c
>+++ b/src/audio/dai.c
>@@ -72,6 +72,21 @@ struct dai_data {
> uint64_t wallclock; /* wall clock at stream start */
> };
>
>+/* for apollolake, it is 400MHz per 1s */
>+#define CPU_CYCLE_PER_MS 400000
>+
>+static void calc_mcps(struct pipeline *p) {
>+ uint32_t cpu_cycle = 0;
>+ uint32_t deta = 0;
>+
>+ __asm__ __volatile__ ("rsr %0, CCOUNT" : "=a" (cpu_cycle) : : "memory");
I think you should use ICOUNT, not CCOUNT.
Thanks,
~Keyon
>+ deta = cpu_cycle - p->cpu_cycle;
>+ p->cpu_cycle = cpu_cycle;
>+ deta = (deta * 100) / CPU_CYCLE_PER_MS;
>+ trace_error_value(deta); /* the percentage of the cpu cycle in 1ms */
>+}
>+
> /* this is called by DMA driver every time descriptor has completed */ static void
>dai_dma_cb(void *data, uint32_t type, struct dma_sg_elem *next) { @@ -81,6
>+96,8 @@ static void dai_dma_cb(void *data, uint32_t type, struct dma_sg_elem
>*next)
>
> tracev_dai("irq");
>
>+ calc_mcps(dev->pipeline);
>+
> /* stop dma copy for pause/stop/xrun */
> if (dev->state != COMP_STATE_ACTIVE || dd->xrun) {
>
>--
>2.17.1
>
>_______________________________________________
>Sound-open-firmware mailing list
>Sound-open-firmware at alsa-project.org
>http://mailman.alsa-project.org/mailman/listinfo/sound-open-firmware
More information about the Sound-open-firmware
mailing list