On Mon, 2018-06-04 at 21:23 -0700, Ranjani Sridharan wrote:
This patch adds a new dma op for retreiving the number of channels in use in a given DMAC. This will be useful in providing basic and primitive QoS while allocating DMAC for various users.
Signed-off-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com
src/drivers/dw-dma.c | 19 +++++++++++++++++++ src/drivers/hda-dma.c | 20 ++++++++++++++++++++ src/include/sof/dma.h | 7 +++++++ 3 files changed, 46 insertions(+)
diff --git a/src/drivers/dw-dma.c b/src/drivers/dw-dma.c index c064330..0ed742f 100644 --- a/src/drivers/dw-dma.c +++ b/src/drivers/dw-dma.c @@ -289,6 +289,24 @@ static inline void dw_update_bits(struct dma *dma, uint32_t reg, uint32_t mask, io_reg_update_bits(dma_base(dma) + reg, mask, value); }
+/* get the number of DMA channels in use */ +static int dw_dma_channel_status(struct dma *dma) +{
struct dma_pdata *p = dma_get_drvdata(dma);
int i, count = 0;
trace_dma("Dct");
for (i = 0; i < DW_MAX_CHAN; i++) {
/* find channels in use */
if (p->chan[i].status != COMP_STATE_INIT)
count++;
}
return count;
+}
Easier and quicker just to store this as data and atomically inc/dec via channel get()/put().
Liam