Skip to contentSkip to conversation

ASoC: Intel: Sklyake - add IPC routines

PATCH Superseded Vinod Koul 2 participants 18 messages Jul 3, 2015 – Jul 9, 2015

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

v2 cover ASoC: Intel: Sklyake - add IPC routines

The SKL aDSP needs to send and receive IPCs to and from aDSP. To aid this we add IPC and aDSP management routines as a library for driver to use. For most of IPC handling we use the common IPC Intel code in place and add the messaging and message parsing bits on top.

First 4 patches are against common IPC code and can be applied independently Last two add IPC handling and aDSP management routines, they are not dependent upon anything and can be applied independently but they are generated against SKL PCM driver series so Makefile updates expect those to be there

v2 folds few fixes seen and make function name consistent

Subhransu S. Prusty (6):
ASoC: Intel: Add helper to poll register for DSP status
ASoC: Intel: Define SKL ADSP IPC and general purpose registers
ASoC: Intel: Reorganize the common dsp structure
ASoC: Intel: Add helper to update register bits with attr RWC
ASoC: Intel: Add Skylake IPC library
ASoC: Intel: Add DSP init and boot up functionality for SKL

 sound/soc/intel/Kconfig               |   1 +
 sound/soc/intel/common/sst-dsp-priv.h |  20 +-
 sound/soc/intel/common/sst-dsp.c      |  51 +++
 sound/soc/intel/common/sst-dsp.h      |   6 +
 sound/soc/intel/skylake/Makefile      |   5 +
 sound/soc/intel/skylake/skl-sst-dsp.c | 337 +++++++++++++++
 sound/soc/intel/skylake/skl-sst-dsp.h | 119 ++++++
 sound/soc/intel/skylake/skl-sst-ipc.c | 752 ++++++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl-sst-ipc.h | 125 ++++++
 9 files changed, 1412 insertions(+), 4 deletions(-)
 create mode 100644 sound/soc/intel/skylake/skl-sst-dsp.c
 create mode 100644 sound/soc/intel/skylake/skl-sst-dsp.h
 create mode 100644 sound/soc/intel/skylake/skl-sst-ipc.c
 create mode 100644 sound/soc/intel/skylake/skl-sst-ipc.h
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v2 1/6 ASoC: Intel: Add helper to poll register for DSP status

From: "Subhransu S. Prusty" <[email protected]>

This patch adds helper to poll register for DSP status.

---
 sound/soc/intel/common/sst-dsp.c | 23 +++++++++++++++++++++++
 sound/soc/intel/common/sst-dsp.h |  2 ++
 2 files changed, 25 insertions(+)
sound/soc/intel/common/sst-dsp.c +23 -0
index 64e94212d2d2..3356792d6933 100644
@@ -20,6 +20,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/delay.h>
 
 #include "sst-dsp.h"
 #include "sst-dsp-priv.h"
@@ -222,6 +223,28 @@ int sst_dsp_shim_update_bits64(struct sst_dsp *sst, u32 offset,
 }
 EXPORT_SYMBOL_GPL(sst_dsp_shim_update_bits64);
 
+int sst_dsp_register_poll(struct sst_dsp *ctx, u32 offset, u32 mask,
+			 u32 expected_value, u32 timeout, char *operation)
+{
+	int time, ret;
+	u32 reg;
+
+	/* check if set state successful */
+	for (time = 0; time < timeout; time++) {
+		if ((sst_dsp_shim_read_unlocked(ctx, offset) & mask) == expected_value)
+			break;
+
+		mdelay(1);
+	}
+	reg = sst_dsp_shim_read_unlocked(ctx, offset);
+	dev_info(ctx->dev, "FW Poll Status: reg=%#x %s %s\n", reg, operation,
+			(time < timeout) ? "successful" : "timedout");
+	ret = time < timeout ? 0 : -ETIME;
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(sst_dsp_register_poll);
+
 void sst_dsp_dump(struct sst_dsp *sst)
 {
 	if (sst->ops->dump)
sound/soc/intel/common/sst-dsp.h +2 -0
index 96aeb2556ad4..cc3197be4cf7 100644
@@ -278,6 +278,8 @@ void sst_dsp_inbox_read(struct sst_dsp *dsp, void *message, size_t bytes);
 void sst_dsp_outbox_write(struct sst_dsp *dsp, void *message, size_t bytes);
 void sst_dsp_outbox_read(struct sst_dsp *dsp, void *message, size_t bytes);
 void sst_dsp_mailbox_dump(struct sst_dsp *dsp, size_t bytes);
+int sst_dsp_register_poll(struct sst_dsp  *dsp, u32 offset, u32 mask,
+		 u32 expected_value, u32 timeout, char *operation);
 
 /* Debug */
 void sst_dsp_dump(struct sst_dsp *sst);
Signature · 1 line
1.9.1
maintainer
#2 lore raw

Re: [PATCH v2 1/6] ASoC: Intel: Add helper to poll register for DSP status

sound/soc/intel/common/sst-dsp.c int sst_dsp_shim_update_bits64(struct sst_dsp *sst, u32 offset, · line 238

Quoted 6 lines · Vinod Koul
sound/soc/intel/common/sst-dsp.c +6 -0
+	for (time = 0; time < timeout; time++) {
+		if ((sst_dsp_shim_read_unlocked(ctx, offset) & mask) == expected_value)
+			break;
+
+		mdelay(1);
+	}

mdelay() not msleep()? If we're waiting for multiple miliseconds that could be lots of busy waiting.

author
#3 lore raw

Re: [PATCH v2 1/6] ASoC: Intel: Add helper to poll register for DSP status

Quoted 11 lines · Mark Brown

sound/soc/intel/common/sst-dsp.c int sst_dsp_shim_update_bits64(struct sst_dsp *sst, u32 offset, · line 238

Quoted 6 lines · Vinod Koul
sound/soc/intel/common/sst-dsp.c +6 -0
+	for (time = 0; time < timeout; time++) {
+		if ((sst_dsp_shim_read_unlocked(ctx, offset) & mask) == expected_value)
+			break;
+
+		mdelay(1);
+	}

mdelay() not msleep()? If we're waiting for multiple miliseconds that could be lots of busy waiting.

Usually this should get reflected in 1st iteration as the register update would get updated farrily quickly. msleep will add up lots of latency to this.

Thanks

Signature · 1 line
~Vinod
maintainer
#4 lore raw

Re: [PATCH v2 1/6] ASoC: Intel: Add helper to poll register for DSP status

Quoted 12 lines · Vinod Koul
Quoted 9 lines · Mark Brown

sound/soc/intel/common/sst-dsp.c int sst_dsp_shim_update_bits64(struct sst_dsp *sst, u32 offset, · line 238

Quoted 6 lines
sound/soc/intel/common/sst-dsp.c +6 -0
+	for (time = 0; time < timeout; time++) {
+		if ((sst_dsp_shim_read_unlocked(ctx, offset) & mask) == expected_value)
+			break;
+
+		mdelay(1);
+	}

mdelay() not msleep()? If we're waiting for multiple miliseconds that could be lots of busy waiting.

Quoted 3 lines

Usually this should get reflected in 1st iteration as the register update would get updated farrily quickly. msleep will add up lots of latency to this.

A common approach for that is to do a busy wait for say the first milisecond (perhaps polling more often too) and then fall back to something sleepy if things are slow.

author
#5 lore raw

Re: [PATCH v2 1/6] ASoC: Intel: Add helper to poll register for DSP status

Quoted 13 lines · Mark Brown
Quoted 11 lines · Vinod Koul
Quoted 9 lines · Mark Brown

sound/soc/intel/common/sst-dsp.c int sst_dsp_shim_update_bits64(struct sst_dsp *sst, u32 offset, · line 238

Quoted 6 lines
sound/soc/intel/common/sst-dsp.c +6 -0
+	for (time = 0; time < timeout; time++) {
+		if ((sst_dsp_shim_read_unlocked(ctx, offset) & mask) == expected_value)
+			break;
+
+		mdelay(1);
+	}

mdelay() not msleep()? If we're waiting for multiple miliseconds that could be lots of busy waiting.

Quoted 7 lines
Quoted 3 lines

Usually this should get reflected in 1st iteration as the register update would get updated farrily quickly. msleep will add up lots of latency to this.

A common approach for that is to do a busy wait for say the first milisecond (perhaps polling more often too) and then fall back to something sleepy if things are slow.

Yes that sounds sensible to me, will add

Thanks

Signature · 1 line
~Vinod
author
#6 lore raw

PATCH v2 2/6 ASoC: Intel: Define SKL ADSP IPC and general purpose registers

In reply to Vinod Koul

From: "Subhransu S. Prusty" <[email protected]>

---
 sound/soc/intel/skylake/skl-sst-dsp.h | 62 +++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 sound/soc/intel/skylake/skl-sst-dsp.h
sound/soc/intel/skylake/skl-sst-dsp.h new file +62 -0
new file mode 100644
index 000000000000..2ac120c18bea
@@ -0,0 +1,62 @@
+/*
+ * Skylake SST DSP Support
+ *
+ * Copyright (C) 2014-15, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#ifndef __SKL_SST_DSP_H__
+#define __SKL_SST_DSP_H__
+
+/* Intel HD Audio General DSP Registers */
+#define SKL_ADSP_GEN_BASE		0x0
+#define SKL_ADSP_REG_ADSPCS		(SKL_ADSP_GEN_BASE + 0x04)
+#define SKL_ADSP_REG_ADSPIC		(SKL_ADSP_GEN_BASE + 0x08)
+#define SKL_ADSP_REG_ADSPIS		(SKL_ADSP_GEN_BASE + 0x0C)
+#define SKL_ADSP_REG_ADSPIC2		(SKL_ADSP_GEN_BASE + 0x10)
+#define SKL_ADSP_REG_ADSPIS2		(SKL_ADSP_GEN_BASE + 0x14)
+
+/* Intel HD Audio Inter-Processor Communication Registers */
+#define SKL_ADSP_IPC_BASE		0x40
+#define SKL_ADSP_REG_HIPCT		(SKL_ADSP_IPC_BASE + 0x00)
+#define SKL_ADSP_REG_HIPCTE		(SKL_ADSP_IPC_BASE + 0x04)
+#define SKL_ADSP_REG_HIPCI		(SKL_ADSP_IPC_BASE + 0x08)
+#define SKL_ADSP_REG_HIPCIE		(SKL_ADSP_IPC_BASE + 0x0C)
+#define SKL_ADSP_REG_HIPCCTL		(SKL_ADSP_IPC_BASE + 0x10)
+
+/*  HIPCI */
+#define SKL_ADSP_REG_HIPCI_BUSY		BIT(31)
+
+/* HIPCIE */
+#define SKL_ADSP_REG_HIPCIE_DONE	BIT(30)
+
+/* HIPCCTL */
+#define SKL_ADSP_REG_HIPCCTL_DONE	BIT(1)
+#define SKL_ADSP_REG_HIPCCTL_BUSY	BIT(0)
+
+/* HIPCT */
+#define SKL_ADSP_REG_HIPCT_BUSY		BIT(31)
+
+/* Intel HD Audio SRAM Window 1 */
+#define SKL_ADSP_SRAM1_BASE		0xA000
+
+#define SKL_ADSP_MMIO_LEN		0x10000
+
+#define SKL_ADSP_W0_STAT_SZ		0x800
+
+#define SKL_ADSP_W0_UP_SZ		0x800
+
+#define SKL_ADSP_W1_SZ			0x1000
+
+#define SKL_ADSPIC_IPC			1
+#define SKL_ADSPIS_IPC			1
+
+#endif /*__SKL_SST_DSP_H__*/
Signature · 1 line
1.9.1
author
#7 lore raw

PATCH v2 3/6 ASoC: Intel: Reorganize the common dsp structure

In reply to Vinod Koul

From: "Subhransu S. Prusty" <[email protected]>

We will add SKL platform data. So organizing common and platform specific data helps.

---
 sound/soc/intel/common/sst-dsp-priv.h | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
sound/soc/intel/common/sst-dsp-priv.h +8 -4
index 396d54510350..50af167b7bc7 100644
@@ -258,6 +258,8 @@ struct sst_mem_block {
  */
 struct sst_dsp {
 
+	/* Shared for all platforms */
+
 	/* runtime */
 	struct sst_dsp_device *sst_dev;
 	spinlock_t spinlock;	/* IPC locking */
@@ -268,10 +270,6 @@ struct sst_dsp {
 	int irq;
 	u32 id;
 
-	/* list of free and used ADSP memory blocks */
-	struct list_head used_block_list;
-	struct list_head free_block_list;
-
 	/* operations */
 	struct sst_ops *ops;
 
@@ -284,6 +282,12 @@ struct sst_dsp {
 	/* mailbox */
 	struct sst_mailbox mailbox;
 
+	/* HSW/Byt data */
+
+	/* list of free and used ADSP memory blocks */
+	struct list_head used_block_list;
+	struct list_head free_block_list;
+
 	/* SST FW files loaded and their modules */
 	struct list_head module_list;
 	struct list_head fw_list;
Signature · 1 line
1.9.1
maintainer
#8 lore raw

Re: [PATCH v2 3/6] ASoC: Intel: Reorganize the common dsp structure

Quoted 13 lines · Vinod Koul

From: "Subhransu S. Prusty" <[email protected]>

We will add SKL platform data. So organizing common and platform specific data helps.

struct sst_dsp {

sound/soc/intel/common/sst-dsp-priv.h +2 -0
+	/* Shared for all platforms */
+
 	/* runtime */
 	struct sst_dsp_device *sst_dev;
 	spinlock_t spinlock;	/* IPC locking */

sound/soc/intel/common/sst-dsp-priv.h struct sst_dsp { · line 274

Quoted 7 lines
sound/soc/intel/common/sst-dsp-priv.h +0 -4
@@ -268,10 +270,6 @@ struct sst_dsp {
 	int irq;
 	u32 id;
 
-	/* list of free and used ADSP memory blocks */
-	struct list_head used_block_list;
-	struct list_head free_block_list;
-

Perhaps a union might start to make sense at some point?

author
#9 lore raw

Re: [PATCH v2 3/6] ASoC: Intel: Reorganize the common dsp structure

Quoted 17 lines · Mark Brown
Quoted 16 lines · Vinod Koul

From: "Subhransu S. Prusty" <[email protected]>

We will add SKL platform data. So organizing common and platform specific data helps.

struct sst_dsp {

sound/soc/intel/common/sst-dsp-priv.h +2 -0
+	/* Shared for all platforms */
+
 	/* runtime */
 	struct sst_dsp_device *sst_dev;
 	spinlock_t spinlock;	/* IPC locking */
@@ -268,10 +270,6 @@ struct sst_dsp {
 	int irq;
 	u32 id;
 
Quoted 6 lines

sound/soc/intel/common/sst-dsp-priv.h struct sst_dsp { · line 274

Quoted 4 lines
sound/soc/intel/common/sst-dsp-priv.h +0 -4
-	/* list of free and used ADSP memory blocks */
-	struct list_head used_block_list;
-	struct list_head free_block_list;
-

Perhaps a union might start to make sense at some point?

Initially we did start with a union but Liam didn't like another indirection. Anyway since not a bunch a members are getting added here, this should be okay

Liam you want to add here...

Signature · 1 line
~Vinod
author
#10 lore raw

PATCH v2 4/6 ASoC: Intel: Add helper to update register bits with attr RWC

In reply to Vinod Koul

From: "Subhransu S. Prusty" <[email protected]>

For SKL IPC, we have some register bits with attribute RWC. So we need to force update them. Add helper to force update this type of registers bits.

---
 sound/soc/intel/common/sst-dsp.c | 28 ++++++++++++++++++++++++++++
 sound/soc/intel/common/sst-dsp.h |  4 ++++
 2 files changed, 32 insertions(+)
sound/soc/intel/common/sst-dsp.c +28 -0
index 3356792d6933..928c3f987a46 100644
@@ -197,6 +197,22 @@ int sst_dsp_shim_update_bits64_unlocked(struct sst_dsp *sst, u32 offset,
 }
 EXPORT_SYMBOL_GPL(sst_dsp_shim_update_bits64_unlocked);
 
+/* This is for registers bits with attribute RWC */
+void sst_dsp_shim_update_bits_forced_unlocked(struct sst_dsp *sst, u32 offset,
+				u32 mask, u32 value)
+{
+	unsigned int old, new;
+	u32 ret;
+
+	ret = sst_dsp_shim_read_unlocked(sst, offset);
+
+	old = ret;
+	new = (old & (~mask)) | (value & mask);
+
+	sst_dsp_shim_write_unlocked(sst, offset, new);
+}
+EXPORT_SYMBOL_GPL(sst_dsp_shim_update_bits_forced_unlocked);
+
 int sst_dsp_shim_update_bits(struct sst_dsp *sst, u32 offset,
 				u32 mask, u32 value)
 {
@@ -223,6 +239,18 @@ int sst_dsp_shim_update_bits64(struct sst_dsp *sst, u32 offset,
 }
 EXPORT_SYMBOL_GPL(sst_dsp_shim_update_bits64);
 
+/* This is for registers bits with attribute RWC */
+void sst_dsp_shim_update_bits_forced(struct sst_dsp *sst, u32 offset,
+				u32 mask, u32 value)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&sst->spinlock, flags);
+	sst_dsp_shim_update_bits_forced_unlocked(sst, offset, mask, value);
+	spin_unlock_irqrestore(&sst->spinlock, flags);
+}
+EXPORT_SYMBOL_GPL(sst_dsp_shim_update_bits_forced);
+
 int sst_dsp_register_poll(struct sst_dsp *ctx, u32 offset, u32 mask,
 			 u32 expected_value, u32 timeout, char *operation)
 {
sound/soc/intel/common/sst-dsp.h +4 -0
index cc3197be4cf7..1f45f18715c0 100644
@@ -230,6 +230,8 @@ void sst_dsp_shim_write64(struct sst_dsp *sst, u32 offset, u64 value);
 u64 sst_dsp_shim_read64(struct sst_dsp *sst, u32 offset);
 int sst_dsp_shim_update_bits64(struct sst_dsp *sst, u32 offset,
 				u64 mask, u64 value);
+void sst_dsp_shim_update_bits_forced(struct sst_dsp *sst, u32 offset,
+				u32 mask, u32 value);
 
 /* SHIM Read / Write Unlocked for callers already holding sst lock */
 void sst_dsp_shim_write_unlocked(struct sst_dsp *sst, u32 offset, u32 value);
@@ -240,6 +242,8 @@ void sst_dsp_shim_write64_unlocked(struct sst_dsp *sst, u32 offset, u64 value);
 u64 sst_dsp_shim_read64_unlocked(struct sst_dsp *sst, u32 offset);
 int sst_dsp_shim_update_bits64_unlocked(struct sst_dsp *sst, u32 offset,
 					u64 mask, u64 value);
+void sst_dsp_shim_update_bits_forced_unlocked(struct sst_dsp *sst, u32 offset,
+				u32 mask, u32 value);
 
 /* Internal generic low-level SST IO functions - can be overidden */
 void sst_shim32_write(void __iomem *addr, u32 offset, u32 value);
Signature · 1 line
1.9.1
maintainer
#11 lore raw

Re: [PATCH v2 4/6] ASoC: Intel: Add helper to update register bits with attr RWC

Quoted 4 lines · Vinod Koul

From: "Subhransu S. Prusty" <[email protected]>

For SKL IPC, we have some register bits with attribute RWC. So we need to force update them. Add helper to force update this type of registers bits.

This doesn't apply, the header already exists.

author
#12 lore raw

Re: [PATCH v2 4/6] ASoC: Intel: Add helper to update register bits with attr RWC

Quoted 7 lines · Mark Brown
Quoted 4 lines · Vinod Koul

From: "Subhransu S. Prusty" <[email protected]>

For SKL IPC, we have some register bits with attribute RWC. So we need to force update them. Add helper to force update this type of registers bits.

This doesn't apply, the header already exists.

I did rebase this on v4.2-rc1 before sending, will check on your next

Signature · 1 line
~Vinod
author
#13 lore raw

PATCH v2 5/6 ASoC: Intel: Add Skylake IPC library

In reply to Vinod Koul

From: "Subhransu S. Prusty" <[email protected]>

This adds base SKL IPC library which uses common SST IPC lib. Here we add definition for IPC types, sending and receiving IPC messages from aDSP, handling interrupt, sending different types of messages etc

---
 sound/soc/intel/Kconfig               |   1 +
 sound/soc/intel/common/sst-dsp-priv.h |   4 +
 sound/soc/intel/skylake/Makefile      |   5 +
 sound/soc/intel/skylake/skl-sst-ipc.c | 752 ++++++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl-sst-ipc.h | 125 ++++++
 5 files changed, 887 insertions(+)
 create mode 100644 sound/soc/intel/skylake/skl-sst-ipc.c
 create mode 100644 sound/soc/intel/skylake/skl-sst-ipc.h
sound/soc/intel/Kconfig +1 -0
index f208023e91bb..b47dddf1889d 100644
@@ -138,6 +138,7 @@ config SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH
 config SND_SOC_INTEL_SKYLAKE
 	tristate
 	select SND_HDA_EXT_CORE
+	select SND_SOC_INTEL_SST
 	help
 	  Say Y here to include support for ASoC Intel "High Definition
 	  Audio" (Skylake) and its compatible devices.
sound/soc/intel/common/sst-dsp-priv.h +4 -0
index 50af167b7bc7..cd6c7ecf6288 100644
@@ -303,6 +303,10 @@ struct sst_dsp {
 	/* DMA FW loading */
 	struct sst_dma *dma;
 	bool fw_use_dma;
+
+	/* SKL data */
+
+	u32 intr_status;
 };
 
 /* Size optimised DRAM/IRAM memcpy */
sound/soc/intel/skylake/Makefile +5 -0
index 734d17cafde7..18fbe647abca 100644
@@ -1,3 +1,8 @@
 snd-soc-skl-objs := skl.o skl-pcm.o
 
 obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o
+
+# Skylake IPC Support
+snd-soc-skl-ipc-objs := skl-sst-ipc.o
+
+obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl-ipc.o
sound/soc/intel/skylake/skl-sst-ipc.c new file +752 -0

752 lines not on this page · raw message

sound/soc/intel/skylake/skl-sst-ipc.h new file +125 -0

125 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer
#14 lore raw

Re: [PATCH v2 5/6] ASoC: Intel: Add Skylake IPC library

On Fri, Jul 03, 2015 at 04:04:06PM +0530, Vinod Koul wrote:

Mostly looks good - a few small things here, nothing too major:

sound/soc/intel/skylake/skl-sst-ipc.c line 290

Quoted 13 lines
sound/soc/intel/skylake/skl-sst-ipc.c new file +13 -0
+static struct ipc_message *skl_ipc_reply_find_msg(struct sst_generic_ipc *ipc,
+		u64 ipc_header)
+{
+	struct ipc_message *msg = NULL;
+	struct skl_ipc_header *header = (struct skl_ipc_header *)(&ipc_header);
+
+	if (list_empty(&ipc->rx_list)) {
+		dev_err(ipc->dev, "ipc: rx list is empty but received 0x%x\n",
+			header->primary);
+		goto out;
+	}
+
+	msg = list_first_entry(&ipc->rx_list, struct ipc_message, list);

This says it finds the message but it appears to just return the head of the list without reference to the supplied header other than casting it to skl_ipc_header and possibly using it in an error print?

sound/soc/intel/skylake/skl-sst-ipc.c line 377

Quoted 12 lines
sound/soc/intel/skylake/skl-sst-ipc.c new file +12 -0
+irqreturn_t skl_dsp_irq_thread_handler(int irq, void *context)
+{
+	struct sst_dsp *dsp = (struct sst_dsp *)context;
+	struct skl_sst *skl = sst_dsp_get_thread_context(dsp);
+	struct sst_generic_ipc *ipc = &skl->ipc;
+	struct skl_ipc_header header = {0};
+	u32 hipcie, hipct, hipcte;
+	int ipc_irq = 0;
+
+	/* Here we handle IPC interrupts only */
+	if (!(dsp->intr_status & SKL_ADSPIS_IPC))
+		return IRQ_HANDLED;

Shouldn't we be returning IRQ_NONE if we didn't handle the interrupt?

sound/soc/intel/skylake/skl-sst-ipc.c line 412

Quoted 7 lines
sound/soc/intel/skylake/skl-sst-ipc.c new file +7 -0
+		if (IPC_GLB_NOTIFY_RSP_TYPE(header.primary)) {
+			/* Handle Immediate reply from DSP Core */
+			skl_ipc_process_reply(ipc, header);
+		} else {
+			trace_printk("IPC irq: Notification from firmware\n");
+			skl_ipc_process_notification(ipc, header);
+		}

Why trace_printk()?

Quoted 7 lines
sound/soc/intel/skylake/skl-sst-ipc.c new file +7 -0
+int skl_ipc_set_dx(struct sst_generic_ipc *ipc, u8 instance_id,
+		u16 module_id, struct skl_ipc_dxstate_info *dx)
+{
+	struct skl_ipc_header header = {0};
+	u64 *ipc_header = (u64 *)(&header);
+	int ret;
+

sound/soc/intel/skylake/skl-sst-ipc.c line 623

Quoted 10 lines
sound/soc/intel/skylake/skl-sst-ipc.c new file +10 -0
+	header.primary = IPC_MSG_TARGET(IPC_MOD_MSG);
+	header.primary |= IPC_MSG_DIR(IPC_MSG_REQUEST);
+	header.primary |= IPC_GLB_TYPE(IPC_MOD_SET_DX);
+	header.primary |= IPC_MOD_INSTANCE_ID(instance_id);
+	header.primary |= IPC_MOD_ID(module_id);
+
+	dev_dbg(ipc->dev, "In %s primary =%x ext=%x\n", __func__,
+			 header.primary, header.extension);
+	ret = sst_ipc_tx_message_wait(ipc, *ipc_header,
+			(void *)dx, sizeof(dx), NULL, 0);

If you need to cast a pointer to void something is wrong... I suspect you just don't need the cast though.

author
#15 lore raw

Re: [PATCH v2 5/6] ASoC: Intel: Add Skylake IPC library

Quoted 13 lines · Mark Brown

On Fri, Jul 03, 2015 at 04:04:06PM +0530, Vinod Koul wrote:

Mostly looks good - a few small things here, nothing too major:

Quoted 9 lines
sound/soc/intel/skylake/skl-sst-ipc.c new file +9 -0
+static struct ipc_message *skl_ipc_reply_find_msg(struct sst_generic_ipc *ipc,
+		u64 ipc_header)
+{
+	struct ipc_message *msg = NULL;
+	struct skl_ipc_header *header = (struct skl_ipc_header *)(&ipc_header);
+
+	if (list_empty(&ipc->rx_list)) {
+		dev_err(ipc->dev, "ipc: rx list is empty but received 0x%x\n",
+			header->primary);
Quoted 8 lines

sound/soc/intel/skylake/skl-sst-ipc.c line 290

Quoted 4 lines
sound/soc/intel/skylake/skl-sst-ipc.c new file +4 -0
+		goto out;
+	}
+
+	msg = list_first_entry(&ipc->rx_list, struct ipc_message, list);

This says it finds the message but it appears to just return the head of the list without reference to the supplied header other than casting it to skl_ipc_header and possibly using it in an error print?

Yes you are right. Actually currently we dont expect to queue up so we never bother looking up. But yes intention to find messages when they are quued, I will add that bit

Quoted 6 lines
Quoted 6 lines
sound/soc/intel/skylake/skl-sst-ipc.c new file +6 -0
+irqreturn_t skl_dsp_irq_thread_handler(int irq, void *context)
+{
+	struct sst_dsp *dsp = (struct sst_dsp *)context;
+	struct skl_sst *skl = sst_dsp_get_thread_context(dsp);
+	struct sst_generic_ipc *ipc = &skl->ipc;
+	struct skl_ipc_header header = {0};
Quoted 8 lines

sound/soc/intel/skylake/skl-sst-ipc.c line 377

Quoted 6 lines
sound/soc/intel/skylake/skl-sst-ipc.c new file +6 -0
+	u32 hipcie, hipct, hipcte;
+	int ipc_irq = 0;
+
+	/* Here we handle IPC interrupts only */
+	if (!(dsp->intr_status & SKL_ADSPIS_IPC))
+		return IRQ_HANDLED;

Shouldn't we be returning IRQ_NONE if we didn't handle the interrupt?

Yes this is wrong, will fix

Quoted 10 lines

sound/soc/intel/skylake/skl-sst-ipc.c line 412

Quoted 8 lines
sound/soc/intel/skylake/skl-sst-ipc.c new file +7 -0
+		if (IPC_GLB_NOTIFY_RSP_TYPE(header.primary)) {
+			/* Handle Immediate reply from DSP Core */
+			skl_ipc_process_reply(ipc, header);
+		} else {
+			trace_printk("IPC irq: Notification from firmware\n");
+			skl_ipc_process_notification(ipc, header);
+		}

Why trace_printk()?

Dont see a reason, this should be a printk, will fix

Quoted 13 lines
Quoted 13 lines
sound/soc/intel/skylake/skl-sst-ipc.c new file +12 -0
+int skl_ipc_set_dx(struct sst_generic_ipc *ipc, u8 instance_id,
+		u16 module_id, struct skl_ipc_dxstate_info *dx)
+{
+	struct skl_ipc_header header = {0};
+	u64 *ipc_header = (u64 *)(&header);
+	int ret;
+
+	header.primary = IPC_MSG_TARGET(IPC_MOD_MSG);
+	header.primary |= IPC_MSG_DIR(IPC_MSG_REQUEST);
+	header.primary |= IPC_GLB_TYPE(IPC_MOD_SET_DX);
+	header.primary |= IPC_MOD_INSTANCE_ID(instance_id);
+	header.primary |= IPC_MOD_ID(module_id);
Quoted 8 lines

sound/soc/intel/skylake/skl-sst-ipc.c line 623

Quoted 5 lines
sound/soc/intel/skylake/skl-sst-ipc.c new file +5 -0
+
+	dev_dbg(ipc->dev, "In %s primary =%x ext=%x\n", __func__,
+			 header.primary, header.extension);
+	ret = sst_ipc_tx_message_wait(ipc, *ipc_header,
+			(void *)dx, sizeof(dx), NULL, 0);

If you need to cast a pointer to void something is wrong... I suspect you just don't need the cast though.

yes i rechecked. The API expects void pointer for buffer for IPC payload and will copy that. We need not cast it though

Thanks for quick review

Signature · 1 line
~Vinod
author
#16 lore raw

Re: [PATCH v2 5/6] ASoC: Intel: Add Skylake IPC library

Quoted 22 lines · Vinod Koul
Quoted 13 lines · Mark Brown

On Fri, Jul 03, 2015 at 04:04:06PM +0530, Vinod Koul wrote:

Mostly looks good - a few small things here, nothing too major:

Quoted 9 lines
sound/soc/intel/skylake/skl-sst-ipc.c new file +9 -0
+static struct ipc_message *skl_ipc_reply_find_msg(struct sst_generic_ipc *ipc,
+		u64 ipc_header)
+{
+	struct ipc_message *msg = NULL;
+	struct skl_ipc_header *header = (struct skl_ipc_header *)(&ipc_header);
+
+	if (list_empty(&ipc->rx_list)) {
+		dev_err(ipc->dev, "ipc: rx list is empty but received 0x%x\n",
+			header->primary);
Quoted 8 lines

sound/soc/intel/skylake/skl-sst-ipc.c line 290

Quoted 4 lines
sound/soc/intel/skylake/skl-sst-ipc.c new file +4 -0
+		goto out;
+	}
+
+	msg = list_first_entry(&ipc->rx_list, struct ipc_message, list);

This says it finds the message but it appears to just return the head of the list without reference to the supplied header other than casting it to skl_ipc_header and possibly using it in an error print?

Quoted 3 lines

Yes you are right. Actually currently we dont expect to queue up so we never bother looking up. But yes intention to find messages when they are quued, I will add that bit

And it doesn't work. The message comparison fails as we don't have a cookie for replies :(

That would be reworked in future with FW. For now I am going to rename this to skl_ipc_reply_get_msg() as it essentially gets first and only message in queue

Signature · 1 line
~Vinod
author
#17 lore raw

PATCH v2 6/6 ASoC: Intel: Add DSP init and boot up functionality for SKL

In reply to Vinod Koul

From: "Subhransu S. Prusty" <[email protected]>

This patch adds code to enable, disable and boot DSP core. Also provide some helpers to reset and power up/down the core.

---
 sound/soc/intel/common/sst-dsp-priv.h |   4 +
 sound/soc/intel/skylake/Makefile      |   2 +-
 sound/soc/intel/skylake/skl-sst-dsp.c | 337 ++++++++++++++++++++++++++++++++++
 sound/soc/intel/skylake/skl-sst-dsp.h |  57 ++++++
 4 files changed, 399 insertions(+), 1 deletion(-)
 create mode 100644 sound/soc/intel/skylake/skl-sst-dsp.c
sound/soc/intel/common/sst-dsp-priv.h +4 -0
index cd6c7ecf6288..dd79648dfb3a 100644
@@ -22,6 +22,8 @@
 #include <linux/interrupt.h>
 #include <linux/firmware.h>
 
+#include "../skylake/skl-sst-dsp.h"
+
 struct sst_mem_block;
 struct sst_module;
 struct sst_fw;
@@ -306,6 +308,8 @@ struct sst_dsp {
 
 	/* SKL data */
 
+	struct skl_dsp_fw_ops fw_ops;
+	int sst_state;
 	u32 intr_status;
 };
 
sound/soc/intel/skylake/Makefile +1 -1
index 18fbe647abca..10c1319f7ed5 100644
@@ -3,6 +3,6 @@ snd-soc-skl-objs := skl.o skl-pcm.o
 obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o
 
 # Skylake IPC Support
-snd-soc-skl-ipc-objs := skl-sst-ipc.o
+snd-soc-skl-ipc-objs := skl-sst-ipc.o skl-sst-dsp.o
 
 obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl-ipc.o
sound/soc/intel/skylake/skl-sst-dsp.c new file +337 -0

337 lines not on this page · raw message

sound/soc/intel/skylake/skl-sst-dsp.h +57 -0

67 lines not on this page · raw message

Signature · 1 line
1.9.1