[Sound-open-firmware] [RFC PATCH v2 14/29] Change macro definition and trace calling for hda-dma.c

yan.wang at linux.intel.com yan.wang at linux.intel.com
Fri May 11 08:35:56 CEST 2018


From: Yan Wang <yan.wang at linux.intel.com>

It will use DMA trace class and global DMA trace API.

Signed-off-by: Yan Wang <yan.wang at linux.intel.com>
---
Test with:
CNL nocodec
SOF master: c1f2682c210201bbbc96fce7b382b25b90d19775
SOF-Tool master: 86fe688a2b4f68a1ce87e0951686be12a00f1a3c
https://github.com/plbossart/sound/tree/topic/sof-v4.14:
d09db67c5a9d6dfc85f700669fa2e43c678c8d51
---
 src/drivers/hda-dma.c | 44 ++++++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/src/drivers/hda-dma.c b/src/drivers/hda-dma.c
index 97ea0ef..f159758 100644
--- a/src/drivers/hda-dma.c
+++ b/src/drivers/hda-dma.c
@@ -46,10 +46,6 @@
 #include <arch/cache.h>
 #include <uapi/ipc.h>
 
-#define trace_host(__e)	trace_event(TRACE_CLASS_HOST, __e)
-#define tracev_host(__e)	tracev_event(TRACE_CLASS_HOST, __e)
-#define trace_host_error(__e)	trace_error(TRACE_CLASS_HOST, __e)
-
 /* Gateway Stream Registers */
 #define DGCS		0x00
 #define DGBBA		0x04
@@ -79,6 +75,18 @@
 
 #define HDA_DMA_MAX_CHANS		9
 
+/* tracing */
+#define trace_dma(__e) \
+	trace_global_event(NORMAL_LEVEL, TRACE_CLASS_DMA, __e)
+#define tracev_dma(__e) \
+	trace_global_event(VERBOSE_LEVEL, TRACE_CLASS_DMA, __e)
+#define trace_dma_error(__e) \
+	trace_global_event(ERROR_LEVEL, TRACE_CLASS_DMA, __e)
+#define trace_dma_value(x) \
+	trace_global_value(NORMAL_LEVEL, x)
+#define trace_dma_error_value(x) \
+	trace_global_value(ERROR_LEVEL, x)
+
 struct hda_chan_data {
 	uint32_t stream_id;
 	uint32_t status;
@@ -114,7 +122,7 @@ static inline void hda_update_bits(struct dma *dma, uint32_t chan,
 /* notify DMA to copy bytes */
 static int hda_dma_copy(struct dma *dma, int channel, int bytes)
 {
-	tracev_host("GwU");
+	tracev_dma("GwU");
 
 	/* reset BSC before start next copy */
 	hda_update_bits(dma, channel, DGCS, DGCS_BSC, DGCS_BSC);
@@ -139,7 +147,7 @@ static int hda_dma_channel_get(struct dma *dma, int channel)
 
 	spin_lock_irq(&dma->lock, flags);
 
-	trace_host("Dgt");
+	trace_dma("Dgt");
 
 	/* use channel if it's free */
 	if (p->chan[channel].status == COMP_STATE_INIT) {
@@ -152,7 +160,7 @@ static int hda_dma_channel_get(struct dma *dma, int channel)
 
 	/* DMAC has no free channels */
 	spin_unlock_irq(&dma->lock, flags);
-	trace_host_error("eG0");
+	trace_dma_error("eG0");
 	return -ENODEV;
 }
 
@@ -184,16 +192,16 @@ static int hda_dma_start(struct dma *dma, int channel)
 
 	spin_lock_irq(&dma->lock, flags);
 
-	trace_host("DEn");
+	trace_dma("DEn");
 
 	/* is channel idle, disabled and ready ? */
 	dgcs = host_dma_reg_read(dma, channel, DGCS);
 	if (p->chan[channel].status != COMP_STATE_PREPARE ||
 	    (dgcs & DGCS_GEN)) {
 		ret = -EBUSY;
-		trace_host_error("eS0");
-		trace_error_value(dgcs);
-		trace_error_value(p->chan[channel].status);
+		trace_dma_error("eS0");
+		trace_dma_error_value(dgcs);
+		trace_dma_error_value(p->chan[channel].status);
 		goto out;
 	}
 
@@ -215,7 +223,7 @@ static int hda_dma_release(struct dma *dma, int channel)
 
 	spin_lock_irq(&dma->lock, flags);
 
-	trace_host("Dpr");
+	trace_dma("Dpr");
 
 	/* resume and reload DMA */
 	p->chan[channel].status = COMP_STATE_ACTIVE;
@@ -231,7 +239,7 @@ static int hda_dma_pause(struct dma *dma, int channel)
 
 	spin_lock_irq(&dma->lock, flags);
 
-	trace_host("Dpa");
+	trace_dma("Dpa");
 
 	if (p->chan[channel].status != COMP_STATE_ACTIVE)
 		goto out;
@@ -251,7 +259,7 @@ static int hda_dma_stop(struct dma *dma, int channel)
 
 	spin_lock_irq(&dma->lock, flags);
 
-	trace_host("DDi");
+	trace_dma("DDi");
 
 	/* disable the channel */
 	hda_update_bits(dma, channel, DGCS, DGCS_GEN | DGCS_FIFORDY, 0);
@@ -293,14 +301,14 @@ static int hda_dma_set_config(struct dma *dma, int channel,
 
 	spin_lock_irq(&dma->lock, flags);
 
-	trace_host("Dsc");
+	trace_dma("Dsc");
 
 	/* get number of SG elems */
 	list_for_item(plist, &config->elem_list)
 		desc_count++;
 
 	if (desc_count == 0) {
-		trace_host_error("eD1");
+		trace_dma_error("eD1");
 		ret = -EINVAL;
 		goto out;
 	}
@@ -320,14 +328,14 @@ static int hda_dma_set_config(struct dma *dma, int channel,
 
 		/* make sure elem is continuous */
 		if (buffer_addr && (buffer_addr + buffer_bytes) != addr) {
-			trace_host_error("eD2");
+			trace_dma_error("eD2");
 			ret = -EINVAL;
 			goto out;
 		}
 
 		/* make sure period_bytes are constant */
 		if (period_bytes && period_bytes != sg_elem->size) {
-			trace_host_error("eD3");
+			trace_dma_error("eD3");
 			ret = -EINVAL;
 			goto out;
 		}
-- 
2.14.3



More information about the Sound-open-firmware mailing list