Add SKL ipc handling code
cover Add SKL ipc handling code
This series adds support for managing DSP and posting IPC and processing IPC replies.
Subhransu S. Prusty (9):
ASoC: hda: Add helper to read/write to dsp mmio space
ASoC: hda: Add IPC library for SKL platform
ASoC: hda: Add config option for SKL ipc library
ASoC: hda: Add DSP init and boot up functionality
ASoC: hda: Add dsp loader ops
ASoC: hda: Add Code Loader DMA support
ASoC: hda: Add DSP library functions for SKL platform
ASoC: hda: Add for CL DMA interrupt handling
ASoC: hda: Export API to change DSP power state
include/sound/soc-hda-sst-cldma.h | 234 ++++++++ include/sound/soc-hda-sst-dsp.h | 266 +++++++++ include/sound/soc-hda-sst-ipc.h | 134 +++++ sound/soc/hda/Kconfig | 7 + sound/soc/hda/Makefile | 3 + sound/soc/hda/intel/Makefile | 6 + sound/soc/hda/intel/soc-hda-sst-cldma.c | 297 +++++++++ sound/soc/hda/intel/soc-hda-sst-dsp.c | 510 ++++++++++++++++ sound/soc/hda/intel/soc-hda-sst-ipc.c | 963 ++++++++++++++++++++++++++++++ sound/soc/hda/intel/soc-hda-sst-skl-fw.h | 163 +++++ sound/soc/hda/intel/soc-hda-sst-skl.c | 292 +++++++++ 11 files changed, 2875 insertions(+) create mode 100644 include/sound/soc-hda-sst-cldma.h create mode 100644 include/sound/soc-hda-sst-dsp.h create mode 100644 include/sound/soc-hda-sst-ipc.h create mode 100644 sound/soc/hda/intel/Makefile create mode 100644 sound/soc/hda/intel/soc-hda-sst-cldma.c create mode 100644 sound/soc/hda/intel/soc-hda-sst-dsp.c create mode 100644 sound/soc/hda/intel/soc-hda-sst-ipc.c create mode 100644 sound/soc/hda/intel/soc-hda-sst-skl-fw.h create mode 100644 sound/soc/hda/intel/soc-hda-sst-skl.c
Signature · 1 line
1.7.9.5
RFC 1/9 ASoC: hda: Add helper to read/write to dsp mmio space
From: "Subhransu S. Prusty" <[email protected]>
Adding some helper APIs which will be used in the DSP driver and ipc library to read mmio.
--- include/sound/soc-hda-sst-dsp.h | 169 +++++++++++++++++++++++++++++++++ sound/soc/hda/intel/soc-hda-sst-dsp.c | 139 +++++++++++++++++++++++++++ 2 files changed, 308 insertions(+) create mode 100644 include/sound/soc-hda-sst-dsp.h create mode 100644 sound/soc/hda/intel/soc-hda-sst-dsp.c
include/sound/soc-hda-sst-dsp.h new file +169 -0
@@ -0,0 +1,169 @@ +/* +* Intel SST DSP Support +* +* Copyright (C) 2014-15, Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License 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 __HDA_SST_DSP_H__ +#define __HDA_SST_DSP_H__ + +#include <linux/spinlock.h> +#include <sound/memalloc.h> + +#define ssth_writel_andor (ctx, reg, mask_and, mask_or) \ + ssth_writel_traced( \ + ctx, \ + reg, \ + (ssth_readl_traced(ctx, (reg)) & (mask_and) | (mask_or))) + +#define ssth_readb (ctx, reg) \ + ssth_readb_traced(ctx, HDA_ADSP_REG_##reg) +#define ssth_readw (ctx, reg) \ + ssth_readw_traced(ctx, HDA_ADSP_REG_##reg) +#define ssth_readl (ctx, reg) \ + ssth_readl_traced(ctx, HDA_ADSP_REG_##reg) +#define ssth_readl_alt (ctx, reg) \ + ssth_readl_traced(ctx, reg) + +#define ssth_writeb (ctx, reg, value) \ + ssth_writeb_traced(ctx, HDA_ADSP_REG_##reg, (value)) +#define ssth_writew (ctx, reg, value) \ + ssth_writew_traced(ctx, HDA_ADSP_REG_##reg, (value)) +#define ssth_writel (ctx, reg, value) \ + ssth_writel_traced(ctx, HDA_ADSP_REG_##reg, (value)) + +#define ssth_updatel (ctx, reg, mask, value) \ + ssth_updatel_bits(ctx, HDA_ADSP_REG_##reg, reg##_##mask, (value)) + +#define ssth_updatel_locked (ctx, reg, mask, value) \ + ssth_updatel_bits_locked(ctx, HDA_ADSP_REG_##reg, \ + reg##_##mask, (value)) + +/* Intel HD Audio General DSP Registers */ +#define HDA_ADSP_GEN_BASE 0x0 +#define HDA_ADSP_REG_ADSPCS (HDA_ADSP_GEN_BASE + 0x04) +#define HDA_ADSP_REG_ADSPIC (HDA_ADSP_GEN_BASE + 0x08) +#define HDA_ADSP_REG_ADSPIS (HDA_ADSP_GEN_BASE + 0x0C) +#define HDA_ADSP_REG_ADSPIC2 (HDA_ADSP_GEN_BASE + 0x10) +#define HDA_ADSP_REG_ADSPIS2 (HDA_ADSP_GEN_BASE + 0x14) + +/* Intel HD Audio Inter-Processor Communication Registers */ +#define HDA_ADSP_IPC_BASE 0x40 +#define HDA_ADSP_REG_HIPCT (HDA_ADSP_IPC_BASE + 0x00) +#define HDA_ADSP_REG_HIPCTE (HDA_ADSP_IPC_BASE + 0x04) +#define HDA_ADSP_REG_HIPCI (HDA_ADSP_IPC_BASE + 0x08) +#define HDA_ADSP_REG_HIPCIE (HDA_ADSP_IPC_BASE + 0x0C) +#define HDA_ADSP_REG_HIPCCTL (HDA_ADSP_IPC_BASE + 0x10) + +/* HIPCI */ +#define HDA_ADSP_REG_HIPCI_BUSY BIT(31) + +/* HIPCIE */ +#define HDA_ADSP_REG_HIPCIE_DONE BIT(30) + +/* HIPCCTL */ +#define HDA_ADSP_REG_HIPCCTL_DONE BIT(1) +#define HDA_ADSP_REG_HIPCCTL_BUSY BIT(0) + +/* HIPCT */ +#define HDA_ADSP_REG_HIPCT_BUSY BIT(31) + +/* Intel HD Audio Code Loader DMA Registers */ +#define HDA_ADSP_LOADER_BASE 0x80 + +/* Intel HD Audio SRAM Window 1 */ +#define HDA_ADSP_SRAM1_BASE 0xA000 + +/* Intel HD Audio SRAM Window 2 */ +#define HDA_ADSP_SRAM2_BASE 0xC000 + +/* Intel HD Audio SRAM Window 3 */ +#define HDA_ADSP_SRAM3_BASE 0xE000 + +#define HDA_ADSP_MMIO_LEN 0x10000 + +#define WINDOW0_STAT_SIZE 0x800 + +#define WINDOW0_UP_SIZE 0x800 + +#define WINDOW1_SIZE 0x1000 + +#define ADSPIC_IPC 1 +#define ADSPIS_IPC 1 + +struct ssth_window { +void __iomem *w0stat; +void __iomem *w0up; +void __iomem *w1; +size_t w0stat_size; +size_t w0up_size; +size_t w1_size; +}; + +struct ssth_lib { +struct device *dev; +void __iomem *mmio_base; +struct ssth_window window; +int irq; +struct snd_dma_buffer dsp_fw_buf; +int sst_state; +struct mutex sst_lock; +spinlock_t reg_lock; +const struct firmware *fw; +}; + +enum ssth_states { +SST_DSP_RUNNING =1 , +SST_DSP_RESET +}; + +static inline void +ssth_dsp_set_state_locked (struct ssth_lib *ctx,int state) +{ +mutex_lock (&ctx->sst_lock); + ctx->sst_state = state; +mutex_unlock (&ctx->sst_lock); +} + +void ssth_updatel_bits (struct ssth_lib *ctx,u32 offset,u32 mask,u32 value); + +void ssth_mailbox_write (struct ssth_lib *ctx,void *message,size_t bytes); +void ssth_mailbox_read (struct ssth_lib *ctx,void *message,size_t bytes); + +u8 ssth_readb_traced ( +struct ssth_lib *ctx, +u32 offset); + +u16 ssth_readw_traced ( +struct ssth_lib *ctx, +u32 offset); + +u32 ssth_readl_traced ( +struct ssth_lib *ctx, +u32 offset); + +void ssth_writeb_traced ( +struct ssth_lib *ctx, +u32 offset, +u8 val); + +void ssth_writew_traced ( +struct ssth_lib *ctx, +u32 offset,u16 val); + +void ssth_writel_traced ( +struct ssth_lib *ctx, +u32 offset, +u32 val); + +#endif /*__HDA_SST_DSP_H__*/
sound/soc/hda/intel/soc-hda-sst-dsp.c new file +139 -0
139 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Mark Brown
maintainerRe: [RFC 1/9] ASoC: hda: Add helper to read/write to dsp mmio space
sound/soc/hda/intel/soc-hda-sst-dsp.c line 45
Quoted 9 lines · Vinod Koul
sound/soc/hda/intel/soc-hda-sst-dsp.c new file +9
-0+u8 ssth_readb_traced (struct ssth_lib *dsp,u32 offset) +{ +u8 val; + + val =readb ((dsp)->mmio_base + offset); +dev_dbg (dsp->dev,"readb offset=%#x val=%#x\n" , offset, val); + +return val; +}
Much of this looks like a MMIO regmap, there's the memcpy() bits too which aren't but otherwise...
Re: [RFC 1/9] ASoC: hda: Add helper to read/write to dsp mmio space
Quoted 14 lines · Mark Brown
sound/soc/hda/intel/soc-hda-sst-dsp.c line 45
Quoted 9 lines · Vinod Koul
sound/soc/hda/intel/soc-hda-sst-dsp.c new file +9
-0+u8 ssth_readb_traced (struct ssth_lib *dsp,u32 offset) +{ +u8 val; + + val =readb ((dsp)->mmio_base + offset); +dev_dbg (dsp->dev,"readb offset=%#x val=%#x\n" , offset, val); + +return val; +}Much of this looks like a MMIO regmap, there's the
memcpy()bits too which aren't but otherwise...
Yes they are. memcpy bits are to copy the IPC mailbox payload data to aDSP RAM which can range from few bytes to couple of KBs
Thanks
Signature · 1 line
~Vinod
Mark Brown
maintainerRe: [RFC 1/9] ASoC: hda: Add helper to read/write to dsp mmio space
Quoted 7 lines · Vinod Koul
Quoted 2 lines · Mark Brown
Much of this looks like a MMIO regmap, there's the
memcpy()bits too which aren't but otherwise...Yes they are. memcpy bits are to copy the IPC mailbox payload data to aDSP RAM which can range from few bytes to couple of KBs
Seems like we could use the block I/O stuff in regmap for that?
Re: [RFC 1/9] ASoC: hda: Add helper to read/write to dsp mmio space
Quoted 10 lines · Mark Brown
Quoted 7 lines · Vinod Koul
Quoted 2 lines · Mark Brown
Much of this looks like a MMIO regmap, there's the
memcpy()bits too which aren't but otherwise...Yes they are. memcpy bits are to copy the IPC mailbox payload data to aDSP RAM which can range from few bytes to couple of KBs
Seems like we could use the block I/O stuff in regmap for that?
Yes we could, but not sure if we really benefit from using regmap here.
Signature · 1 line
~Vinod
Mark Brown
maintainerRe: [RFC 1/9] ASoC: hda: Add helper to read/write to dsp mmio space
Quoted 5 lines · Vinod Koul
Quoted 1 line · Mark Brown
Seems like we could use the block I/O stuff in regmap for that?
Yes we could, but not sure if we really benefit from using regmap here.
I'd look at it the other way around - what would it cost you given that you're implementing regmap like wrappers already? You do get all the debugging features if you use it...
Re: [RFC 1/9] ASoC: hda: Add helper to read/write to dsp mmio space
Quoted 10 lines · Mark Brown
Quoted 5 lines · Vinod Koul
Quoted 1 line · Mark Brown
Seems like we could use the block I/O stuff in regmap for that?
Yes we could, but not sure if we really benefit from using regmap here.
I'd look at it the other way around - what would it cost you given that you're implementing regmap like wrappers already? You do get all the debugging features if you use it...
it won't cost much :) If we had a register map I would not have questions. Btw HDA codec will sue regmap as core does that
Most used here is a single IPC register for messaging and then 2K memory for payload. Each message has different values. We dont have register interface for DSP :(
Anyway discussed this with Liam as well, we might do something with our common amilbox code which the SKL driver will also use in next series
Thanks
Signature · 1 line
~Vinod
RFC 2/9 ASoC: hda: Add IPC library for SKL platform
In reply to Vinod KoulFrom: "Subhransu S. Prusty" <[email protected]>
This adds APIs for Tx/Rx of IPC to dsp, manager DSP pipeline.
--- include/sound/soc-hda-sst-dsp.h | 4 + include/sound/soc-hda-sst-ipc.h | 134 +++++ sound/soc/hda/intel/Makefile | 5 + sound/soc/hda/intel/soc-hda-sst-ipc.c | 963 +++++++++++++++++++++++++++++++++ 4 files changed, 1106 insertions(+) create mode 100644 include/sound/soc-hda-sst-ipc.h create mode 100644 sound/soc/hda/intel/Makefile create mode 100644 sound/soc/hda/intel/soc-hda-sst-ipc.c
include/sound/soc-hda-sst-dsp.h +4 -0
@@ -112,6 +112,7 @@ struct ssth_window {struct ssth_lib {struct device *dev; +struct ssth_ipc *ipc;void __iomem *mmio_base;struct ssth_window window;int irq;
@@ -120,6 +121,9 @@ struct ssth_lib {struct mutex sst_lock;spinlock_t reg_lock;const struct firmware *fw; + +struct workqueue_struct *intr_wq; +struct work_struct ipc_process_msg_work; };enum ssth_states {
include/sound/soc-hda-sst-ipc.h new file +134 -0
134 lines not on this page · raw message
sound/soc/hda/intel/Makefile new file +5 -0
@@ -0,0 +1,5 @@ + +snd-soc-hda-sst-dsp-objs := soc-hda-sst-ipc.o soc-hda-sst-dsp.o + +# SST DSP Library +obj-$(CONFIG_SND_SOC_HDA_SST_DSP) += snd-soc-hda-sst-dsp.o
sound/soc/hda/intel/soc-hda-sst-ipc.c new file +963 -0
963 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Mark Brown
maintainerRe: [RFC 2/9] ASoC: hda: Add IPC library for SKL platform
include/sound/soc-hda-sst-ipc.h line 52
Quoted 8 lines · Vinod Koul
include/sound/soc-hda-sst-ipc.h new file +8
-0+ +/* IPC data */ +struct ssth_ipc { +struct device *dev; +struct ssth_lib *dsp; + +/* IPC messaging */ +struct list_head tx_list;
Lots of odd indentation of comments in this code (well, several examples I noticed so far anyway).
sound/soc/hda/intel/soc-hda-sst-ipc.c line 320
Quoted 4 lines
sound/soc/hda/intel/soc-hda-sst-ipc.c new file +4
-0+if (ret ==0 ) + ret = -ETIMEDOUT ; +else { +/* copy the data returned from DSP */
Coding style - { } on both sides of the if (and the comments again).
sound/soc/hda/intel/soc-hda-sst-ipc.c line 332
Quoted 12 lines
sound/soc/hda/intel/soc-hda-sst-ipc.c new file +12
-0+if (msg->rx_size) { +if (rx_data) +memcpy (rx_data, msg->rx_data, msg->rx_size); +else +dev_err (ipc->dev,"error: no output buffer" ); + } + ret = msg->errno; + } + +ssth_ipc_msg_put_empty (ipc, msg); + +spin_unlock_irqrestore (&ipc->ipc_lock, irq_flags);
Can we pop the message off the list, release the lock and then copy? That way we can avoid having interrupts disabled while we do the memcpy(). In general there seems to be a lot of interrupts disabled copying going on (which is there for some of the other drivers too) which might be avoidable.
Quoted 4 lines
sound/soc/hda/intel/soc-hda-sst-ipc.c new file +4
-0+static void ssth_ipc_reply_remove (struct ssth_ipc *ipc,struct ssth_ipc_message *msg) +{ +unsigned long irq_flags; +
sound/soc/hda/intel/soc-hda-sst-ipc.c line 478
Quoted 10 lines
sound/soc/hda/intel/soc-hda-sst-ipc.c new file +10
-0+spin_lock_irqsave (&ipc->ipc_lock, irq_flags); +if (list_empty (&ipc->rx_list)) { +dev_dbg (ipc->dev,"empty rx list" ); + goto out; + } +list_del (&msg->list); + +out: +spin_unlock_irqrestore (&ipc->ipc_lock, irq_flags); +}
Are we expecting to not find the message/
Quoted 14 lines
sound/soc/hda/intel/soc-hda-sst-ipc.c new file +14
-0+if (IPC_GLB_NOTIFI_MSG_TYPE (header.primary)) { +switch (IPC_GLB_NOTIFI_TYPE (header.primary)) { +case IPC_GLB_NOTIFCATION_GLITCH : +break ; +case IPC_GLB_NOTIFCATION_OVERRUN : +break ; +case IPC_GLB_NOTIFCATION_UNDERRUN : +dev_dbg (ipc->dev,"FW UNDERRUN\n" ); +break ; +case IPC_GLB_NOTIFCATION_END_STREAM : +break ; +case IPC_GLB_NOTIFCATION_PHRASE_DETECTED : +break ; +case IPC_GLB_NOTIFCATION_RESOURCE_EVENT :
sound/soc/hda/intel/soc-hda-sst-ipc.c line 505
Quoted 10 lines
sound/soc/hda/intel/soc-hda-sst-ipc.c new file +10
-0+dev_dbg (ipc->dev,"MCPS Budget Violation\n" ); +break ; +case IPC_GLB_NOTIFCATION_LOG_BUFFER_STATUS : +break ; +case IPC_GLB_NOTIFCATION_TIMESTAMP_CAPTURED : +break ; +case IPC_GLB_NOTIFCATION_FW_READY : + ipc->boot_complete = true; +wake_up (&ipc->boot_wait); +break ;
More prints perhaps? _PHRASE_DETECTED looks interesting, as does _OVERRUN.
Re: [RFC 2/9] ASoC: hda: Add IPC library for SKL platform
Quoted 14 lines · Mark Brown
include/sound/soc-hda-sst-ipc.h line 52
Quoted 8 lines · Vinod Koul
include/sound/soc-hda-sst-ipc.h new file +8
-0+ +/* IPC data */ +struct ssth_ipc { +struct device *dev; +struct ssth_lib *dsp; + +/* IPC messaging */ +struct list_head tx_list;Lots of odd indentation of comments in this code (well, several examples I noticed so far anyway).
Quoted 6 lines
sound/soc/hda/intel/soc-hda-sst-ipc.c line 320
Quoted 4 lines
sound/soc/hda/intel/soc-hda-sst-ipc.c new file +4
-0+if (ret ==0 ) + ret = -ETIMEDOUT ; +else { +/* copy the data returned from DSP */ Coding style - { } on both sides of the if (and the comments again).
Ah sorry about that, I did try to fix style issues in code but looks like few were missed. I will fix them in the patch series.
Quoted 11 lines
Quoted 11 lines
sound/soc/hda/intel/soc-hda-sst-ipc.c new file +10
-0+if (msg->rx_size) { +if (rx_data) +memcpy (rx_data, msg->rx_data, msg->rx_size); +else +dev_err (ipc->dev,"error: no output buffer" ); + } + ret = msg->errno; + } + +ssth_ipc_msg_put_empty (ipc, msg);
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + spin_unlock_irqrestore(&ipc->ipc_lock, irq_flags);Can we pop the message off the list, release the lock and then copy? That way we can avoid having interrupts disabled while we do the
memcpy(). In general there seems to be a lot of interrupts disabled copying going on (which is there for some of the other drivers too) which might be avoidable.
Thanks for pointing, yes this should be done.
Quoted 17 lines
Quoted 5 lines
sound/soc/hda/intel/soc-hda-sst-ipc.c new file +4
-0+static void ssth_ipc_reply_remove (struct ssth_ipc *ipc,struct ssth_ipc_message *msg) +{ +unsigned long irq_flags; +sound/soc/hda/intel/soc-hda-sst-ipc.c line 478
Quoted 10 lines
sound/soc/hda/intel/soc-hda-sst-ipc.c new file +10
-0+spin_lock_irqsave (&ipc->ipc_lock, irq_flags); +if (list_empty (&ipc->rx_list)) { +dev_dbg (ipc->dev,"empty rx list" ); + goto out; + } +list_del (&msg->list); + +out: +spin_unlock_irqrestore (&ipc->ipc_lock, irq_flags); +}Are we expecting to not find the message/
For reply case, I am not sure. I think if thats true would make sense to complain loudly..
Quoted 20 lines
Quoted 20 lines
sound/soc/hda/intel/soc-hda-sst-ipc.c new file +19
-0+if (IPC_GLB_NOTIFI_MSG_TYPE (header.primary)) { +switch (IPC_GLB_NOTIFI_TYPE (header.primary)) { +case IPC_GLB_NOTIFCATION_GLITCH : +break ; +case IPC_GLB_NOTIFCATION_OVERRUN : +break ; +case IPC_GLB_NOTIFCATION_UNDERRUN : +dev_dbg (ipc->dev,"FW UNDERRUN\n" ); +break ; +case IPC_GLB_NOTIFCATION_END_STREAM : +break ; +case IPC_GLB_NOTIFCATION_PHRASE_DETECTED : +break ; +case IPC_GLB_NOTIFCATION_RESOURCE_EVENT : +dev_dbg (ipc->dev,"MCPS Budget Violation\n" ); +break ; +case IPC_GLB_NOTIFCATION_LOG_BUFFER_STATUS : +break ; +case IPC_GLB_NOTIFCATION_TIMESTAMP_CAPTURED :
Quoted 8 lines
sound/soc/hda/intel/soc-hda-sst-ipc.c line 505
Quoted 5 lines
sound/soc/hda/intel/soc-hda-sst-ipc.c new file +5
-0+break ; +case IPC_GLB_NOTIFCATION_FW_READY : + ipc->boot_complete = true; +wake_up (&ipc->boot_wait); +break ;More prints perhaps?
_PHRASE_DETECTEDlooks interesting, as does_OVERRUN.
Overrun is FW detectiong its pipelines are overunning the buffer, no the ALSA ring buffer though. _PHRASE_DETECTED is for keyword detection which can run on dsp
Thanks
Signature · 1 line
~Vinod
Mark Brown
maintainerRe: [RFC 2/9] ASoC: hda: Add IPC library for SKL platform
Quoted 8 lines · Vinod Koul
Quoted 2 lines · Mark Brown
More prints perhaps?
_PHRASE_DETECTEDlooks interesting, as does_OVERRUN.Overrun is FW detectiong its pipelines are overunning the buffer, no the ALSA ring buffer though.
_PHRASE_DETECTEDis for keyword detection which can run on dsp
Sure, it was fairly clear what the messages were for - it was more that they seemed like things we'd want to do more with than just ignore.
Re: [RFC 2/9] ASoC: hda: Add IPC library for SKL platform
Quoted 6 lines · Mark Brown
Quoted 4 lines · Vinod Koul
Quoted 2 lines · Mark Brown
More prints perhaps?
_PHRASE_DETECTEDlooks interesting, as does_OVERRUN.
Quoted 6 lines
Quoted 3 lines
Overrun is FW detectiong its pipelines are overunning the buffer, no the ALSA ring buffer though.
_PHRASE_DETECTEDis for keyword detection which can run on dspSure, it was fairly clear what the messages were for - it was more that they seemed like things we'd want to do more with than just ignore.
Oh yes, that will be added after base driver is upstreamed. So I will remove as these are unused atm, and adding them when used makes more sense :)
Signature · 1 line
~Vinod
RFC 3/9 ASoC: hda: Add config option for SKL ipc library
In reply to Vinod KoulFrom: "Subhransu S. Prusty" <[email protected]>
--- sound/soc/hda/Kconfig | 7 +++++++ sound/soc/hda/Makefile | 3 +++ 2 files changed, 10 insertions(+)
sound/soc/hda/Kconfig +7 -0
@@ -40,4 +40,11 @@ config SND_SOC_I2S_SKL_MACH Say Y if you have such a device If unsure select "N". + +config SND_SOC_HDA_SST_DSP + tristate "Enable SST DSP Library" + depends on (X86 || COMPILE_TEST) + help + Say Y here to enable the HD-audio SST dsp library. + endmenu
sound/soc/hda/Makefile +3 -0
@@ -4,3 +4,6 @@ obj-$(CONFIG_SND_SOC_HDA_SKL) += snd-soc-hda-skl.o # Machine support obj-$(CONFIG_SND_SOC_HDA_SKL) += boards/ + +# DSP library +obj-$(CONFIG_SND_SOC_HDA_SST_DSP) += intel/
Signature · 1 line
1.7.9.5
RFC 4/9 ASoC: hda: Add DSP init and boot up functionality
In reply to Vinod KoulFrom: "Subhransu S. Prusty" <[email protected]>
--- include/sound/soc-hda-sst-dsp.h | 28 +++ sound/soc/hda/intel/soc-hda-sst-dsp.c | 350 +++++++++++++++++++++++++++++++++ 2 files changed, 378 insertions(+)
include/sound/soc-hda-sst-dsp.h +28 -0
@@ -101,6 +101,34 @@#define ADSPIC_IPC 1#define ADSPIS_IPC 1 +/* ADSPCS - Audio DSP Control & Status */ +#define DSP_CORES 1 +#define DSP_CORE0_MASK 1 +#define DSP_CORES_MASK ((1 << DSP_CORES) - 1) + +/* Core Reset - asserted high */ +#define ADSPCS_CRST_SHIFT 0 +#define ADSPCS_CRST_MASK (DSP_CORES_MASK << ADSPCS_CRST_SHIFT) +#define ADSPCS_CRST (x) ((x << ADSPCS_CRST_SHIFT) & ADSPCS_CRST_MASK) + +/* Core run/stall - when set to '1' core is stalled */ +#define ADSPCS_CSTALL_SHIFT 8 +#define ADSPCS_CSTALL_MASK (DSP_CORES_MASK << ADSPCS_CSTALL_SHIFT) +#define ADSPCS_CSTALL (x) ((x << ADSPCS_CSTALL_SHIFT) & ADSPCS_CSTALL_MASK) + +/* Set Power Active - when set to '1' turn cores on */ +#define ADSPCS_SPA_SHIFT 16 +#define ADSPCS_SPA_MASK (DSP_CORES_MASK << ADSPCS_SPA_SHIFT) +#define ADSPCS_SPA (x) ((x << ADSPCS_SPA_SHIFT) & ADSPCS_SPA_MASK) + +/* Current Power Active - power status of cores, set by hardware */ +#define ADSPCS_CPA_SHIFT 24 +#define ADSPCS_CPA_MASK (DSP_CORES_MASK << ADSPCS_CPA_SHIFT) +#define ADSPCS_CPA (x) ((x << ADSPCS_CPA_SHIFT) & ADSPCS_CPA_MASK) + +#define SST_DSP_POWER_D0 0x0/* full On */ +#define SST_DSP_POWER_D3 0x3/* Off */ +struct ssth_window {void __iomem *w0stat;void __iomem *w0up;
sound/soc/hda/intel/soc-hda-sst-dsp.c +350 -0
361 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Mark Brown
maintainerRe: [RFC 4/9] ASoC: hda: Add DSP init and boot up functionality
sound/soc/hda/intel/soc-hda-sst-dsp.c void ssth_mailbox_read(struct ssth_lib *ctx, void *msg, size_t bytes) · line 435
Quoted 6 lines · Vinod Koul
sound/soc/hda/intel/soc-hda-sst-dsp.c +6
-0+static int ssth_acquire_irq (struct ssth_lib *ctx) +{ +if (request_threaded_irq (ctx->irq, ssth_interrupt, +NULL ,IRQF_SHARED ,KBUILD_MODNAME , ctx)) { +dev_err (ctx->dev,"unable to grab threaded IRQ %d, disabling device\n" , ctx->irq); +return -1 ;
Don't discard the return code, pass it back. I'm pretty sure the error wasn't -EPERM anyway. Though...
sound/soc/hda/intel/soc-hda-sst-dsp.c void ssth_mailbox_read(struct ssth_lib *ctx, void *msg, size_t bytes) · line 455
Quoted 8 lines
sound/soc/hda/intel/soc-hda-sst-dsp.c +8
-0+ +/* initialize IPC */ + ctx->ipc =ssth_ipc_init (ctx->dev, ctx); +if (ctx->ipc ==NULL ) + ret = -ENODEV ; + +/* Now let's request the IRQ */ +ssth_acquire_irq (ctx);
..of course we ignore errors anyway. Why not just inline this?
Quoted 5 lines
sound/soc/hda/intel/soc-hda-sst-dsp.c +5
-0+int ssth_dsp_free0 (struct ssth_lib *dsp) +{ +int ret =0 ; + +dev_dbg (dsp->dev,"In %s\n" , __func__);
sound/soc/hda/intel/soc-hda-sst-dsp.c void ssth_mailbox_read(struct ssth_lib *ctx, void *msg, size_t bytes) · line 474
Quoted 10 lines
sound/soc/hda/intel/soc-hda-sst-dsp.c +10
-0+ +ssth_ipc_int_disable (dsp); + +free_irq (dsp->irq, dsp); +ssth_ipc_free (dsp->ipc); +ssth_disable_dsp_core (dsp); +kfree (dsp); +return ret; +} +EXPORT_SYMBOL_GPL (ssth_dsp_free0);
free0?
sound/soc/hda/intel/soc-hda-sst-dsp.c void ssth_mailbox_read(struct ssth_lib *ctx, void *msg, size_t bytes) · line 482
Quoted 7 lines
sound/soc/hda/intel/soc-hda-sst-dsp.c +7
-0+bool ssth_dsp_is_running (struct ssth_lib *ctx) +{ +bool ret =0 ; + +mutex_lock (&ctx->sst_lock); + ret = (ctx->sst_state ==SST_DSP_RUNNING ) ?1 :0 ; +mutex_unlock (&ctx->sst_lock);
How does this get used? The state could change immediately after returning. Also no need for the ternery operator there, logic operations generate logic results anyway.
Re: [RFC 4/9] ASoC: hda: Add DSP init and boot up functionality
Quoted 11 lines · Mark Brown
sound/soc/hda/intel/soc-hda-sst-dsp.c void ssth_mailbox_read(struct ssth_lib *ctx, void *msg, size_t bytes) · line 435
Quoted 6 lines · Vinod Koul
sound/soc/hda/intel/soc-hda-sst-dsp.c +6
-0+static int ssth_acquire_irq (struct ssth_lib *ctx) +{ +if (request_threaded_irq (ctx->irq, ssth_interrupt, +NULL ,IRQF_SHARED ,KBUILD_MODNAME , ctx)) { +dev_err (ctx->dev,"unable to grab threaded IRQ %d, disabling device\n" , ctx->irq); +return -1 ;Don't discard the return code, pass it back. I'm pretty sure the error wasn't
-EPERManyway. Though...
yes, we will fix it
Quoted 11 lines
sound/soc/hda/intel/soc-hda-sst-dsp.c void ssth_mailbox_read(struct ssth_lib *ctx, void *msg, size_t bytes) · line 455
Quoted 9 lines
sound/soc/hda/intel/soc-hda-sst-dsp.c +8
-0+ +/* initialize IPC */ + ctx->ipc =ssth_ipc_init (ctx->dev, ctx); +if (ctx->ipc ==NULL ) + ret = -ENODEV ; + +/* Now let's request the IRQ */ +ssth_acquire_irq (ctx);..of course we ignore errors anyway. Why not just inline this?
thats not right, we should do that...
Quoted 10 lines
Quoted 10 lines
sound/soc/hda/intel/soc-hda-sst-dsp.c +9
-0+int ssth_dsp_free0 (struct ssth_lib *dsp) +{ +int ret =0 ; + +dev_dbg (dsp->dev,"In %s\n" , __func__); + +ssth_ipc_int_disable (dsp); + +free_irq (dsp->irq, dsp);
Quoted 8 lines
sound/soc/hda/intel/soc-hda-sst-dsp.c void ssth_mailbox_read(struct ssth_lib *ctx, void *msg, size_t bytes) · line 474
Quoted 6 lines
sound/soc/hda/intel/soc-hda-sst-dsp.c +6
-0+ssth_ipc_free (dsp->ipc); +ssth_disable_dsp_core (dsp); +kfree (dsp); +return ret; +} +EXPORT_SYMBOL_GPL (ssth_dsp_free0);free0?
crap, will fix
Quoted 12 lines
sound/soc/hda/intel/soc-hda-sst-dsp.c void ssth_mailbox_read(struct ssth_lib *ctx, void *msg, size_t bytes) · line 482
Quoted 8 lines
sound/soc/hda/intel/soc-hda-sst-dsp.c +7
-0+bool ssth_dsp_is_running (struct ssth_lib *ctx) +{ +bool ret =0 ; + +mutex_lock (&ctx->sst_lock); + ret = (ctx->sst_state ==SST_DSP_RUNNING ) ?1 :0 ; +mutex_unlock (&ctx->sst_lock);How does this get used? The state could change immediately after returning. Also no need for the ternery operator there, logic operations generate logic results anyway.
yes you are right, we should hold the lock and check, will fix this
Thanks
Signature · 1 line
~Vinod
RFC 5/9 ASoC: hda: Add dsp loader ops
In reply to Vinod KoulFrom: "Subhransu S. Prusty" <[email protected]>
This will be assigned with the required bus io ops.
--- include/sound/soc-hda-sst-dsp.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
include/sound/soc-hda-sst-dsp.h +16 -0
@@ -138,12 +138,28 @@ struct ssth_window {size_t w1_size; }; +struct ssth_dsp_loader_ops { +int (*init)(struct device *dev); +int (*prepare)(struct device *dev,unsigned int format, +unsigned int byte_size, +struct snd_dma_buffer *bufp); +void (*trigger)(struct device *dev,bool start); + +void (*cleanup)(struct device *dev, +struct snd_dma_buffer *dmab); +int (*alloc_dma_buf)(struct device *dev, +struct snd_dma_buffer *dmab,u32 size); +int (*free_dma_buf)(struct device *dev, +struct snd_dma_buffer *dmab); +}; +struct ssth_lib {struct device *dev;struct ssth_ipc *ipc;void __iomem *mmio_base;struct ssth_window window;int irq; +struct ssth_dsp_loader_ops dsp_ops;struct snd_dma_buffer dsp_fw_buf;int sst_state;struct mutex sst_lock;
Signature · 1 line
1.7.9.5
RFC 6/9 ASoC: hda: Add Code Loader DMA support
In reply to Vinod KoulFrom: "Subhransu S. Prusty" <[email protected]>
For skylake the code loader dma will be used for fw download, module download, and sending mailbox.
--- include/sound/soc-hda-sst-cldma.h | 234 ++++++++++++++++++++++++ include/sound/soc-hda-sst-dsp.h | 9 + sound/soc/hda/intel/Makefile | 2 +- sound/soc/hda/intel/soc-hda-sst-cldma.c | 297 +++++++++++++++++++++++++++++++ 4 files changed, 541 insertions(+), 1 deletion(-) create mode 100644 include/sound/soc-hda-sst-cldma.h create mode 100644 sound/soc/hda/intel/soc-hda-sst-cldma.c
include/sound/soc-hda-sst-cldma.h new file +234 -0
@@ -0,0 +1,234 @@ +/* +* Intel Code Loader DMA support +* +* Copyright (C) 2015, Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License 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. +* +*/ + +#define FW_CL_STREAM_NUMBER 0xf + +#define DMA_ADDRESS_128_BITS_ALIGNMENT 7 +#define BDL_ALIGN (x) (x >> DMA_ADDRESS_128_BITS_ALIGNMENT) + +#define ADSPIC_CL_DMA 0x2 +#define ADSPIS_CL_DMA 0x2 +#define CL_DMA_SD_INT_DESC_ERR 0x10/* Descriptor error interrupt */ +#define CL_DMA_SD_INT_FIFO_ERR 0x08/* FIFO error interrupt */ +#define CL_DMA_SD_INT_COMPLETE 0x04/* Buffer completion interrupt */ + +/* Code Loader - +* Stream Registers */ +#define HDA_ADSP_REG_CL_SD_CTL (HDA_ADSP_LOADER_BASE + 0x00) +#define HDA_ADSP_REG_CL_SD_STS (HDA_ADSP_LOADER_BASE + 0x03) +#define HDA_ADSP_REG_CL_SD_LPIB (HDA_ADSP_LOADER_BASE + 0x04) +#define HDA_ADSP_REG_CL_SD_CBL (HDA_ADSP_LOADER_BASE + 0x08) +#define HDA_ADSP_REG_CL_SD_LVI (HDA_ADSP_LOADER_BASE + 0x0c) +#define HDA_ADSP_REG_CL_SD_FIFOW (HDA_ADSP_LOADER_BASE + 0x0e) +#define HDA_ADSP_REG_CL_SD_FIFOSIZE (HDA_ADSP_LOADER_BASE + 0x10) +#define HDA_ADSP_REG_CL_SD_FORMAT (HDA_ADSP_LOADER_BASE + 0x12) +#define HDA_ADSP_REG_CL_SD_FIFOL (HDA_ADSP_LOADER_BASE + 0x14) +#define HDA_ADSP_REG_CL_SD_BDLPL (HDA_ADSP_LOADER_BASE + 0x18) +#define HDA_ADSP_REG_CL_SD_BDLPU (HDA_ADSP_LOADER_BASE + 0x1c) + +/* Code Loader - +* Software Position Based FIFO Capability Registers */ +#define HDA_ADSP_REG_CL_SPBFIFO (HDA_ADSP_LOADER_BASE + 0x20) +#define HDA_ADSP_REG_CL_SPBFIFO_SPBFCH (HDA_ADSP_REG_CL_SPBFIFO + 0x0) +#define HDA_ADSP_REG_CL_SPBFIFO_SPBFCCTL (HDA_ADSP_REG_CL_SPBFIFO + 0x4) +#define HDA_ADSP_REG_CL_SPBFIFO_SPIB (HDA_ADSP_REG_CL_SPBFIFO + 0x8) +#define HDA_ADSP_REG_CL_SPBFIFO_MAXFIFOS (HDA_ADSP_REG_CL_SPBFIFO + 0xc) + + +/* Code Loader - +* Stream Descriptor x Control */ +/* Stream Reset */ +#define CL_SD_CTL_SRST_SHIFT 0 +#define CL_SD_CTL_SRST_MASK (1 << CL_SD_CTL_SRST_SHIFT) +#define CL_SD_CTL_SRST (x) \ + ((x << CL_SD_CTL_SRST_SHIFT) & CL_SD_CTL_SRST_MASK) + +/* Stream Run */ +#define CL_SD_CTL_RUN_SHIFT 1 +#define CL_SD_CTL_RUN_MASK (1 << CL_SD_CTL_RUN_SHIFT) +#define CL_SD_CTL_RUN (x) \ + ((x << CL_SD_CTL_RUN_SHIFT) & CL_SD_CTL_RUN_MASK) + +/* Interrupt On Completion Enable */ +#define CL_SD_CTL_IOCE_SHIFT 2 +#define CL_SD_CTL_IOCE_MASK (1 << CL_SD_CTL_IOCE_SHIFT) +#define CL_SD_CTL_IOCE (x) \ + ((x << CL_SD_CTL_IOCE_SHIFT) & CL_SD_CTL_IOCE_MASK) + +/* FIFO Error Interrupt Enable */ +#define CL_SD_CTL_FEIE_SHIFT 3 +#define CL_SD_CTL_FEIE_MASK (1 << CL_SD_CTL_FEIE_SHIFT) +#define CL_SD_CTL_FEIE (x) \ + ((x << CL_SD_CTL_FEIE_SHIFT) & CL_SD_CTL_FEIE_MASK) + +/* Descriptor Error Interrupt Enable */ +#define CL_SD_CTL_DEIE_SHIFT 4 +#define CL_SD_CTL_DEIE_MASK (1 << CL_SD_CTL_DEIE_SHIFT) +#define CL_SD_CTL_DEIE (x) \ + ((x << CL_SD_CTL_DEIE_SHIFT) & CL_SD_CTL_DEIE_MASK) + +/* FIFO Limit Change */ +#define CL_SD_CTL_FIFOLC_SHIFT 5 +#define CL_SD_CTL_FIFOLC_MASK (1 << CL_SD_CTL_FIFOLC_SHIFT) +#define CL_SD_CTL_FIFOLC (x) \ + ((x << CL_SD_CTL_FIFOLC_SHIFT) & CL_SD_CTL_FIFOLC_MASK) + +/* Stripe Control */ +#define CL_SD_CTL_STRIPE_SHIFT 16 +#define CL_SD_CTL_STRIPE_MASK (0x3 << CL_SD_CTL_STRIPE_SHIFT) +#define CL_SD_CTL_STRIPE (x) \ + ((x << CL_SD_CTL_STRIPE_SHIFT) & CL_SD_CTL_STRIPE_MASK) + +/* Traffic Priority */ +#define CL_SD_CTL_TP_SHIFT 18 +#define CL_SD_CTL_TP_MASK (1 << CL_SD_CTL_TP_SHIFT) +#define CL_SD_CTL_TP (x) \ + ((x << CL_SD_CTL_TP_SHIFT) & CL_SD_CTL_TP_MASK) + +/* Bidirectional Direction Control */ +#define CL_SD_CTL_DIR_SHIFT 19 +#define CL_SD_CTL_DIR_MASK (1 << CL_SD_CTL_DIR_SHIFT) +#define CL_SD_CTL_DIR (x) \ + ((x << CL_SD_CTL_DIR_SHIFT) & CL_SD_CTL_DIR_MASK) + +/* Stream Number */ +#define CL_SD_CTL_STRM_SHIFT 20 +#define CL_SD_CTL_STRM_MASK (0xf << CL_SD_CTL_STRM_SHIFT) +#define CL_SD_CTL_STRM (x) \ + ((x << CL_SD_CTL_STRM_SHIFT) & CL_SD_CTL_STRM_MASK) + + +/* Code Loader - +* Stream Descriptor x Status */ +/* Buffer Completion Interrupt Status */ +#define CL_SD_STS_BCIS (x) CL_SD_CTL_IOCE(x) + +/* FIFO Error */ +#define CL_SD_STS_FIFOE (x) CL_SD_CTL_FEIE(x) + +/* Descriptor Error */ +#define CL_SD_STS_DESE (x) CL_SD_CTL_DEIE(x) + +/* FIFO Ready */ +#define CL_SD_STS_FIFORDY (x) CL_SD_CTL_FIFOLC(x) + + +/* Code Loader - +* Stream Descriptor x Last Valid Index */ +#define CL_SD_LVI_SHIFT 0 +#define CL_SD_LVI_MASK (0xff << CL_SD_LVI_SHIFT) +#define CL_SD_LVI (x) ((x << CL_SD_LVI_SHIFT) & CL_SD_LVI_MASK) + + +/* Code Loader - +* Stream Descriptor x FIFO Eviction Watermark */ +#define CL_SD_FIFOW_SHIFT 0 +#define CL_SD_FIFOW_MASK (0x7 << CL_SD_FIFOW_SHIFT) +#define CL_SD_FIFOW (x) ((x << CL_SD_FIFOW_SHIFT) & CL_SD_FIFOW_MASK) + + +/* Code Loader - +* Stream Descriptor x Buffer Descriptor List Pointer Lower Base Address */ +/* Protect */ +#define CL_SD_BDLPLBA_PROT_SHIFT 0 +#define CL_SD_BDLPLBA_PROT_MASK (1 << CL_SD_BDLPLBA_PROT_SHIFT) +#define CL_SD_BDLPLBA_PROT (x) \ + ((x << CL_SD_BDLPLBA_PROT_SHIFT) & CL_SD_BDLPLBA_PROT_MASK) + +/* Buffer Descriptor List Lower Base Address */ +#define CL_SD_BDLPLBA_SHIFT 7 +#define CL_SD_BDLPLBA_MASK (0x1ffffff << CL_SD_BDLPLBA_SHIFT) +#define CL_SD_BDLPLBA (x) \ + ((BDL_ALIGN(lower_32_bits(x)) << CL_SD_BDLPLBA_SHIFT) & CL_SD_BDLPLBA_MASK) + +/* Buffer Descriptor List Upper Base Address */ +#define CL_SD_BDLPUBA_SHIFT 0 +#define CL_SD_BDLPUBA_MASK (0xffffffff << CL_SD_BDLPUBA_SHIFT) +#define CL_SD_BDLPUBA (x) \ + ((upper_32_bits(x) << CL_SD_BDLPUBA_SHIFT) & CL_SD_BDLPUBA_MASK) + +/* Code Loader - Software Position Based FIFO +* Capability Registers x Software Position Based FIFO Header */ + +/* Next Capability Pointer */ +#define CL_SPBFIFO_SPBFCH_PTR_SHIFT 0 +#define CL_SPBFIFO_SPBFCH_PTR_MASK (0xff << CL_SPBFIFO_SPBFCH_PTR_SHIFT) +#define CL_SPBFIFO_SPBFCH_PTR (x) \ + ((x << CL_SPBFIFO_SPBFCH_PTR_SHIFT) & CL_SPBFIFO_SPBFCH_PTR_MASK) + +/* Capability Identifier */ +#define CL_SPBFIFO_SPBFCH_ID_SHIFT 16 +#define CL_SPBFIFO_SPBFCH_ID_MASK (0xfff << CL_SPBFIFO_SPBFCH_ID_SHIFT) +#define CL_SPBFIFO_SPBFCH_ID (x) \ + ((x << CL_SPBFIFO_SPBFCH_ID_SHIFT) & CL_SPBFIFO_SPBFCH_ID_MASK) + +/* Capability Version */ +#define CL_SPBFIFO_SPBFCH_VER_SHIFT 28 +#define CL_SPBFIFO_SPBFCH_VER_MASK (0xf << CL_SPBFIFO_SPBFCH_VER_SHIFT) +#define CL_SPBFIFO_SPBFCH_VER (x) \ + ((x << CL_SPBFIFO_SPBFCH_VER_SHIFT) & CL_SPBFIFO_SPBFCH_VER_MASK) + + +/* Code Loader - +Software Position Based FIFO Control */ +/* Software Position in Buffer Enable */ +#define CL_SPBFIFO_SPBFCCTL_SPIBE_SHIFT 0 +#define CL_SPBFIFO_SPBFCCTL_SPIBE_MASK (1 << CL_SPBFIFO_SPBFCCTL_SPIBE_SHIFT) +#define CL_SPBFIFO_SPBFCCTL_SPIBE (x) \ + ((x << CL_SPBFIFO_SPBFCCTL_SPIBE_SHIFT) & CL_SPBFIFO_SPBFCCTL_SPIBE_MASK) + +#define SSTH_WAIT_TIMEOUT 1000/* 1 sec */ +#define SSTH_MAX_BUFFER_SIZE (4 * PAGE_SIZE) + +enum ssth_cl_dma_wake_states { +SSTH_CL_DMA_STATUS_NONE =0 , +SSTH_CL_DMA_BUF_COMPLETE , +SSTH_CL_DMA_ERR ,/* TODO: Expand the error states */ +}; + +struct ssth_lib ; +struct ssth_cl_dev_ops { +void (*cl_setup_bdle)(struct snd_dma_buffer *dmab_data, +u32 **bdlp,u32 page_count); +void (*cl_setup_controller)(struct ssth_lib *ctx, +struct snd_dma_buffer *dmab_bdl, +unsigned int max_size,u32 page_count); +void (*cl_setup_spb)(struct ssth_lib *ctx,unsigned int size); +void (*cl_cleanup_spb)(struct ssth_lib *ctx); +void (*cl_trigger)(struct ssth_lib *ctx,bool enable); +void (*cl_cleaup_controller)(struct ssth_lib *ctx); +int (*cl_copy_to_bdl)(struct ssth_lib *ctx,const void *bin,u32 size); +}; + +/* Code loader device */ +struct ssth_cl_dev { +/* TODO: Add for synchroinization mechanism */ +struct snd_dma_buffer dmab_data; +struct snd_dma_buffer dmab_bdl; + +unsigned int bufsize;/* Ring buffer size = period_count * period_size */ +unsigned int period_count; +unsigned int period_size; +u32 *curr_pos;/* Current possition in the blob to transferred */ +unsigned int bytes_left;/* Bytes left to be transferred */ +unsigned int curr_spib_pos;/* Current position in ring buffer */ +bool cl_ops; +struct ssth_cl_dev_ops ops; + +wait_queue_head_t wait_queue; +int wake_status; +bool wait_condition; +};
include/sound/soc-hda-sst-dsp.h +9 -0
@@ -19,6 +19,7 @@#include <linux/spinlock.h> #include <sound/memalloc.h> +#include <sound/soc-hda-sst-cldma.h> #define ssth_writel_andor (ctx, reg, mask_and, mask_or) \ ssth_writel_traced( \
@@ -101,6 +102,12 @@#define ADSPIC_IPC 1#define ADSPIS_IPC 1 +#define ADSPIC_CL_DMA 0x2 +#define ADSPIS_CL_DMA 0x2 +#define CL_DMA_SD_INT_DESC_ERR 0x10/* Descriptor error interrupt */ +#define CL_DMA_SD_INT_FIFO_ERR 0x08/* FIFO error interrupt */ +#define CL_DMA_SD_INT_COMPLETE 0x04/* Buffer completion interrupt */ +/* ADSPCS - Audio DSP Control & Status */ #define DSP_CORES 1#define DSP_CORE0_MASK 1
@@ -168,6 +175,8 @@ struct ssth_lib {struct workqueue_struct *intr_wq;struct work_struct ipc_process_msg_work; +struct ssth_cl_dev cl_dev; +struct work_struct cl_dma_process_work; };enum ssth_states {
sound/soc/hda/intel/Makefile +1 -1
@@ -1,5 +1,5 @@ -snd-soc-hda-sst-dsp-objs := soc-hda-sst-ipc.o soc-hda-sst-dsp.o +snd-soc-hda-sst-dsp-objs := soc-hda-sst-ipc.o soc-hda-sst-dsp.o soc-hda-sst-cldma.o # SST DSP Library obj-$(CONFIG_SND_SOC_HDA_SST_DSP) += snd-soc-hda-sst-dsp.o
sound/soc/hda/intel/soc-hda-sst-cldma.c new file +297 -0
297 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Mark Brown
maintainerRe: [RFC 6/9] ASoC: hda: Add Code Loader DMA support
sound/soc/hda/intel/soc-hda-sst-cldma.c line 38
Quoted 10 lines · Vinod Koul
sound/soc/hda/intel/soc-hda-sst-cldma.c new file +10
-0+void ssth_cldma_int_enable (struct ssth_lib *ctx) +{ +ssth_updatel_bits (ctx,HDA_ADSP_REG_ADSPIC , +ADSPIC_CL_DMA ,0x2 ); +} +void ssth_cldma_int_disable (struct ssth_lib *ctx) +{ +ssth_updatel_bits (ctx,HDA_ADSP_REG_ADSPIC , +ADSPIC_CL_DMA ,0 ); +}
Blank lines between functions. Seems to be an Intel coding style thing? :P
sound/soc/hda/intel/soc-hda-sst-cldma.c line 48
Quoted 9 lines
sound/soc/hda/intel/soc-hda-sst-cldma.c new file +9
-0+/* Code loader helper APIs */ +static void ssth_skl_cl_setup_bdle (struct snd_dma_buffer *dmab_data, +u32 **bdlp,u32 count) +{ +u32 *bdl = *bdlp; +int i =0 ; + +for (i =0 ; i < count; i++) { +phys_addr_t addr =virt_to_phys (dmab_data->area + i *PAGE_SIZE );
So this we index by i and...
sound/soc/hda/intel/soc-hda-sst-cldma.c line 55
Quoted 7 lines
sound/soc/hda/intel/soc-hda-sst-cldma.c new file +7
-0+ + bdl[0 ] =cpu_to_le32 (lower_32_bits (addr)); + bdl[1 ] =cpu_to_le32 (upper_32_bits (addr)); + bdl[2 ] =cpu_to_le32 (PAGE_SIZE ); + bdl[3 ] =0 ; + bdl +=4 ; + }
...this we index by stepping through the array with increments in the body of the loop. Consistency would be nice (and more obviously correct).
Review
Quoted 2 lines
(quoted diff) +2
-0+static void ssth_skl_cl_cleaup(struct ssth_lib *ctx) +{
Can't we clean it up instead?
sound/soc/hda/intel/soc-hda-sst-cldma.c line 183
Quoted 12 lines
sound/soc/hda/intel/soc-hda-sst-cldma.c new file +12
-0+if (ctx->cl_dev.bytes_left <= ctx->cl_dev.bufsize && + ctx->cl_dev.bytes_left > ctx->cl_dev.period_size) { + +dev_dbg (ctx->dev,"%s: size less than buffer size: %u\n" , + __func__, ctx->cl_dev.bytes_left); +ssth_cldma_int_disable (ctx); + ctx->cl_dev.curr_spib_pos = ctx->cl_dev.bytes_left; +ssth_cl_dma_fill_buffer (ctx, size, false, false,0 , false, true); +do { +mdelay (5 ); + link_pos =ssth_readl (ctx,CL_SD_LPIB ); + }while (link_pos < size);
Should time out in case the DMA got stuck somehow.
Review
Quoted 2 lines
(quoted diff) +2
-0+ goto cleanup; + }
What if the buffer is just too big? Looks like this would loop for ever.
Re: [RFC 6/9] ASoC: hda: Add Code Loader DMA support
Quoted 15 lines · Mark Brown
sound/soc/hda/intel/soc-hda-sst-cldma.c line 38
Quoted 10 lines · Vinod Koul
sound/soc/hda/intel/soc-hda-sst-cldma.c new file +10
-0+void ssth_cldma_int_enable (struct ssth_lib *ctx) +{ +ssth_updatel_bits (ctx,HDA_ADSP_REG_ADSPIC , +ADSPIC_CL_DMA ,0x2 ); +} +void ssth_cldma_int_disable (struct ssth_lib *ctx) +{ +ssth_updatel_bits (ctx,HDA_ADSP_REG_ADSPIC , +ADSPIC_CL_DMA ,0 ); +}Blank lines between functions. Seems to be an Intel coding style thing? :P
sure seems, will fix
Quoted 13 lines
sound/soc/hda/intel/soc-hda-sst-cldma.c line 48
Quoted 10 lines
sound/soc/hda/intel/soc-hda-sst-cldma.c new file +9
-0+/* Code loader helper APIs */ +static void ssth_skl_cl_setup_bdle (struct snd_dma_buffer *dmab_data, +u32 **bdlp,u32 count) +{ +u32 *bdl = *bdlp; +int i =0 ; + +for (i =0 ; i < count; i++) { +phys_addr_t addr =virt_to_phys (dmab_data->area + i *PAGE_SIZE );So this we index by i and...
Quoted 11 lines
sound/soc/hda/intel/soc-hda-sst-cldma.c line 55
Quoted 7 lines
sound/soc/hda/intel/soc-hda-sst-cldma.c new file +7
-0+ + bdl[0 ] =cpu_to_le32 (lower_32_bits (addr)); + bdl[1 ] =cpu_to_le32 (upper_32_bits (addr)); + bdl[2 ] =cpu_to_le32 (PAGE_SIZE ); + bdl[3 ] =0 ; + bdl +=4 ; + }...this we index by stepping through the array with increments in the body of the loop. Consistency would be nice (and more obviously correct).
ok
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+static void ssth_skl_cl_cleaup(struct ssth_lib *ctx) +{Can't we clean it up instead?
yes should have fixed earlier
Quoted 15 lines
sound/soc/hda/intel/soc-hda-sst-cldma.c line 183
Quoted 13 lines
sound/soc/hda/intel/soc-hda-sst-cldma.c new file +12
-0+if (ctx->cl_dev.bytes_left <= ctx->cl_dev.bufsize && + ctx->cl_dev.bytes_left > ctx->cl_dev.period_size) { + +dev_dbg (ctx->dev,"%s: size less than buffer size: %u\n" , + __func__, ctx->cl_dev.bytes_left); +ssth_cldma_int_disable (ctx); + ctx->cl_dev.curr_spib_pos = ctx->cl_dev.bytes_left; +ssth_cl_dma_fill_buffer (ctx, size, false, false,0 , false, true); +do { +mdelay (5 ); + link_pos =ssth_readl (ctx,CL_SD_LPIB ); + }while (link_pos < size);Should time out in case the DMA got stuck somehow.
yes will add
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ goto cleanup; + }What if the buffer is just too big? Looks like this would loop for ever.
DMA is started, so link_pos get updated and we keep reading it. Since its DMA a big buffer will get done fairly soon.
Thanks
Signature · 1 line
~Vinod
Mark Brown
maintainerRe: [RFC 6/9] ASoC: hda: Add Code Loader DMA support
Quoted 10 lines · Vinod Koul
Quoted 5 lines · Mark Brown
Review
Quoted 2 lines
(quoted diff) +2
-0+ goto cleanup; + }What if the buffer is just too big? Looks like this would loop for ever.
DMA is started, so
link_posget updated and we keep reading it. Since its DMA a big buffer will get done fairly soon.
No, two separate questions there - what if the buffer is bigger than the maximum size (it looked like there was one) and what about error handling (if some clock gets stopped and we don't transfer data for example)?
Re: [RFC 6/9] ASoC: hda: Add Code Loader DMA support
Quoted 9 lines · Mark Brown
Quoted 7 lines · Vinod Koul
Quoted 5 lines · Mark Brown
Review
Quoted 2 lines
(quoted diff) +2
-0+ goto cleanup; + }What if the buffer is just too big? Looks like this would loop for ever.
Quoted 7 lines
Quoted 2 lines
DMA is started, so
link_posget updated and we keep reading it. Since its DMA a big buffer will get done fairly soon.No, two separate questions there - what if the buffer is bigger than the maximum size (it looked like there was one) and what about error handling (if some clock gets stopped and we don't transfer data for example)?
Okay got it. So for former, yes code doesn't handle it, we should split it up in that case or error out, will add that.
On latter one, the error handling in general would be beefed up but specifically since this is memory copy I am not expecting timeout. If clock is gone then whole audio cluster is gone bonkers so even simple read registers will fail.
Thanks
Signature · 1 line
~Vinod
RFC 7/9 ASoC: hda: Add DSP library functions for SKL platform
In reply to Vinod KoulFrom: "Subhransu S. Prusty" <[email protected]>
Adding functionality to parse and load fw and DSP power management in SKL.
--- include/sound/soc-hda-sst-dsp.h | 39 ++++ sound/soc/hda/intel/Makefile | 3 +- sound/soc/hda/intel/soc-hda-sst-skl-fw.h | 163 +++++++++++++++++ sound/soc/hda/intel/soc-hda-sst-skl.c | 292 ++++++++++++++++++++++++++++++ 4 files changed, 496 insertions(+), 1 deletion(-) create mode 100644 sound/soc/hda/intel/soc-hda-sst-skl-fw.h create mode 100644 sound/soc/hda/intel/soc-hda-sst-skl.c
include/sound/soc-hda-sst-dsp.h +39 -0
@@ -99,6 +99,27 @@#define WINDOW1_SIZE 0x1000 +#define FW_STATUS_MASK 0xf + +#define FW_ROM_INIT 0x0 +#define FW_ROM_INIT_DONE 0x1 +#define FW_ROM_MEM_PWR_DONE 0x2 +#define FW_ROM_MANIFEST_LOADED 0X3 +#define FW_ROM_MANIFEST_VERIFIED 0x4 +#define FW_ROM_FEAT_MASK_VERIFIED 0x5 +#define FW_ROM_BASEFW_FOUND 0x6 +#define FW_ROM_BASEFW_BA_VALID 0x7 +#define FW_ROM_BASEFW_TOTAL_PWR 0x8 +#define FW_ROM_BASEFW_TEXT_LOADED 0x9 +#define FW_ROM_BASEFW_TEXT_HASHED 0xa +#define FW_ROM_BASEFW_RODA_LOADED 0xb +#define FW_ROM_BASEFW_LOAD_HASHED 0xc +#define FW_ROM_BASEFW_HASH_VER 0xd +#define FW_ROM_BASEFW_START_FOUND 0xe +#define FW_ROM_BASEFW_ENTERED 0xf + + +#define ADSPIC_IPC 1#define ADSPIS_IPC 1
@@ -160,6 +181,14 @@ struct ssth_dsp_loader_ops { struct snd_dma_buffer *dmab); }; +struct ssth_ops { +int (*load_fw)(struct ssth_lib *ctx); +/* FW module parser/loader */ +int (*parse_fw)(struct ssth_lib *ctx); +int (*set_state_D0)(struct ssth_lib *ctx); +int (*set_state_D3)(struct ssth_lib *ctx); +}; +struct ssth_lib {struct device *dev;struct ssth_ipc *ipc;
@@ -167,6 +196,7 @@ struct ssth_lib {struct ssth_window window;int irq;struct ssth_dsp_loader_ops dsp_ops; +struct ssth_ops ops;struct snd_dma_buffer dsp_fw_buf;int sst_state;struct mutex sst_lock;
@@ -223,4 +253,13 @@ void ssth_writel_traced(u32 offset, u32 val); +int ssth_register_poll (struct ssth_lib *ctx,u32 offset,u32 mask, +u32 expected_value,u32 timeout,char *operation); +int ssth_boot_dsp (struct ssth_lib *ctx); +int ssth_dsp_init (struct ssth_lib *ctx); +int ssth_disable_dsp_core (struct ssth_lib *ctx); +bool ssth_dsp_is_running (struct ssth_lib *ctx); +int ssth_cl_dma_prepare (struct ssth_lib *ctx); +void ssth_process_cl_dma (struct work_struct *work); +#endif /*__HDA_SST_DSP_H__*/
sound/soc/hda/intel/Makefile +2 -1
@@ -1,5 +1,6 @@ -snd-soc-hda-sst-dsp-objs := soc-hda-sst-ipc.o soc-hda-sst-dsp.o soc-hda-sst-cldma.o +snd-soc-hda-sst-dsp-objs := soc-hda-sst-ipc.o soc-hda-sst-dsp.o soc-hda-sst-cldma.o \ + soc-hda-sst-skl.o # SST DSP Library obj-$(CONFIG_SND_SOC_HDA_SST_DSP) += snd-soc-hda-sst-dsp.o
sound/soc/hda/intel/soc-hda-sst-skl-fw.h new file +163 -0
163 lines not on this page · raw message
sound/soc/hda/intel/soc-hda-sst-skl.c new file +292 -0
292 lines not on this page · raw message
Signature · 1 line
1.7.9.5
RFC 8/9 ASoC: hda: Add for CL DMA interrupt handling
In reply to Vinod KoulFrom: "Subhransu S. Prusty" <[email protected]>
DSP handles the Code Loader DMA interrupt.
--- include/sound/soc-hda-sst-dsp.h | 1 + sound/soc/hda/intel/soc-hda-sst-dsp.c | 7 +++++++ 2 files changed, 8 insertions(+)
include/sound/soc-hda-sst-dsp.h +1 -0
@@ -261,5 +261,6 @@ int ssth_disable_dsp_core(struct ssth_lib *ctx);bool ssth_dsp_is_running (struct ssth_lib *ctx);int ssth_cl_dma_prepare (struct ssth_lib *ctx);void ssth_process_cl_dma (struct work_struct *work); +void ssth_cldma_int_disable (struct ssth_lib *ctx);#endif /*__HDA_SST_DSP_H__*/
sound/soc/hda/intel/soc-hda-sst-dsp.c +7 -0
@@ -423,6 +423,13 @@ static irqreturn_t ssth_interrupt(int irq, void *dev_id) result =IRQ_HANDLED ; } +if (val &ADSPIS_CL_DMA ) { +ssth_cldma_int_disable (ctx); +queue_work (ctx->intr_wq, &ctx->cl_dma_process_work); + result =IRQ_HANDLED ; + } + +spin_unlock (&ctx->reg_lock);return result; }
Signature · 1 line
1.7.9.5
Mark Brown
maintainerRe: [RFC 8/9] ASoC: hda: Add for CL DMA interrupt handling
Quoted 3 lines · Vinod Koul
From: "Subhransu S. Prusty" <[email protected]>
DSP handles the Code Loader DMA interrupt.
Could this be squashed in with the thing that adds the work so we see the whole picture at once please?
Re: [RFC 8/9] ASoC: hda: Add for CL DMA interrupt handling
Quoted 7 lines · Mark Brown
Quoted 3 lines · Vinod Koul
From: "Subhransu S. Prusty" <[email protected]>
DSP handles the Code Loader DMA interrupt.
Could this be squashed in with the thing that adds the work so we see the whole picture at once please?
Sure...
Thanks
Signature · 1 line
~Vinod
RFC 9/9 ASoC: hda: Export API to change DSP power state
In reply to Vinod KoulFrom: "Subhransu S. Prusty" <[email protected]>
--- sound/soc/hda/intel/soc-hda-sst-dsp.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
sound/soc/hda/intel/soc-hda-sst-dsp.c +14 -0
@@ -480,6 +480,20 @@ int ssth_dsp_free0(struct ssth_lib *dsp) }EXPORT_SYMBOL_GPL (ssth_dsp_free0); +int ssth_dsp_set_power_state (struct ssth_lib *ctx,int state) +{ +int ret =0 ; + +if (state ==SST_DSP_POWER_D0 ) + ret = ctx->ops.set_state_D0 (ctx); +else if (state ==SST_DSP_POWER_D3 ) + ret = ctx->ops.set_state_D3 (ctx); +else +dev_err (ctx->dev,"Power State=%x not supported" , state); +return ret; +} +EXPORT_SYMBOL_GPL (ssth_dsp_set_power_state); +bool ssth_dsp_is_running (struct ssth_lib *ctx) {bool ret =0 ;
Signature · 1 line
1.7.9.5
Mark Brown
maintainerRe: [RFC 9/9] ASoC: hda: Export API to change DSP power state
sound/soc/hda/intel/soc-hda-sst-dsp.c int ssth_dsp_free0(struct ssth_lib *dsp) · line 492
Quoted 6 lines · Vinod Koul
sound/soc/hda/intel/soc-hda-sst-dsp.c +6
-0+if (state ==SST_DSP_POWER_D0 ) + ret = ctx->ops.set_state_D0 (ctx); +else if (state ==SST_DSP_POWER_D3 ) + ret = ctx->ops.set_state_D3 (ctx); +else +dev_err (ctx->dev,"Power State=%x not supported" , state);
Can we have a switch statement please? I'm a bit unclear why this is being exported as it is, shouldn't things be wrapped up more so that the DSP code owns its own power state.
Mark Brown
maintainerQuoted 2 lines · Vinod Koul
This series adds support for managing DSP and posting IPC and processing IPC replies.
Any dependencies on the generic HDA stuff you've been posting?
Quoted 5 lines · Mark Brown
Quoted 2 lines · Vinod Koul
This series adds support for managing DSP and posting IPC and processing IPC replies.
Any dependencies on the generic HDA stuff you've been posting?
Yes.
So first we need to merge the SKL PCM driver series. Can you please review that [1] one as well. Then this series.
Lastly the SKL aDSP support series [2] which uses the IPC code in this series.
One more would be when toplogy is merged, for supporting the dsp toplogy
Thanks
Signature · 7 lines
~Vinod [1]: [PATCH v2 0/7] ASoC: hda - add ASoC Skylake HD audio driver http://mailman.alsa-project.org/pipermail/alsa-devel/2015-April/090621.html [2]: [RFC 0/7] ASoC: hda - ASoC DSP widget event handlers http://mailman.alsa-project.org/pipermail/alsa-devel/2015-April/090710.html
Quoted 5 lines · Vinod Koul
Quoted 4 lines · Mark Brown
Quoted 2 lines · Vinod Koul
This series adds support for managing DSP and posting IPC and processing IPC replies.
Quoted 9 lines
Quoted 1 line
Any dependencies on the generic HDA stuff you've been posting?
Yes.
So first we need to merge the SKL PCM driver series. Can you please review that [1] one as well. Then this series.
Lastly the SKL aDSP support series [2] which uses the IPC code in this series.One more would be when toplogy is merged, for supporting the dsp toplogy
We also need to port the SKL IPC code to use the converged mailbox code that's now used by BDW and BYT before upstreaming.
Liam
Quoted 13 lines · Liam Girdwood
Quoted 12 lines · Vinod Koul
Quoted 5 lines · Mark Brown
Quoted 2 lines · Vinod Koul
This series adds support for managing DSP and posting IPC and processing IPC replies.
Any dependencies on the generic HDA stuff you've been posting?
Yes.
So first we need to merge the SKL PCM driver series. Can you please review that [1] one as well. Then this series.
Lastly the SKL aDSP support series [2] which uses the IPC code in this series.
Quoted 5 lines
Quoted 2 lines
One more would be when toplogy is merged, for supporting the dsp toplogy
We also need to port the SKL IPC code to use the converged mailbox code that's now used by BDW and BYT before upstreaming.
Yes that wil be done for next patch series. If you guys could give comments on the other tow series, I will spin them and resubmit as well
Signature · 1 line
~Vinod
Mark Brown
maintainerQuoted 7 lines · Vinod Koul
Quoted 2 lines · Liam Girdwood
We also need to port the SKL IPC code to use the converged mailbox code that's now used by BDW and BYT before upstreaming.
Yes that wil be done for next patch series. If you guys could give comments on the other tow series, I will spin them and resubmit as well
I'm not entirely sure which serieses are what at the minute, we're getting a lot of things posted from you guys many of which are just RFCs in various versions and some of which are getting applied or didn't seem relevant (like the HDA ones).