[Sound-open-firmware] [PATCH 2/5][RFC] APL/CNL: Implement host DMA copy in existed DMA copy API.

yanwang yan.wang at linux.intel.com
Wed Mar 14 07:02:43 CET 2018


On Tue, 2018-03-13 at 10:48 +0000, Liam Girdwood wrote:
> On Tue, 2018-03-13 at 18:16 +0800, yan.wang at linux.intel.com wrote:
> > 
> > From: Yan Wang <yan.wang at linux.intel.com>
> > 
> > Get DMA channel based on stream tag when use host DMA.
> > Need also call different API in dma_copy_to_host_nowait().
> > 
> > Signed-off-by: Yan Wang <yan.wang at linux.intel.com>
> > ---
> >  src/include/reef/dma.h |  4 ++++
> >  src/ipc/dma-copy.c     | 40
> > +++++++++++++++++++++++++++++++++++++++-
> >  2 files changed, 43 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/include/reef/dma.h b/src/include/reef/dma.h
> > index 247bcbf..0f7dbfc 100644
> > --- a/src/include/reef/dma.h
> > +++ b/src/include/reef/dma.h
> > @@ -278,4 +278,8 @@ int dma_copy_to_host(struct dma_copy *dc,
> > struct
> > dma_sg_config *host_sg,
> >  int dma_copy_to_host_nowait(struct dma_copy *dc, struct
> > dma_sg_config
> > *host_sg,
> >  	int32_t host_offset, void *local_ptr, int32_t size);
> >  
> > +#if defined CONFIG_DMA_GW
> > +int dma_set_channel(struct dma_copy *dc, uint32_t stream_tag);
> > +#endif
> > +
> 
> You dont need any #ifdefs around function declarations in headers.
> 
> Please rename this to dma_copy_set_stream_tag()
> 

Sure.

> 
> > 
> >  #endif
> > diff --git a/src/ipc/dma-copy.c b/src/ipc/dma-copy.c
> > index 06f05d5..f11acf1 100644
> > --- a/src/ipc/dma-copy.c
> > +++ b/src/ipc/dma-copy.c
> > @@ -70,6 +70,8 @@ static struct dma_sg_elem *sg_get_elem_at(struct
> > dma_sg_config *host_sg,
> >  	return NULL;
> >  }
> >  
> > +#if !defined CONFIG_DMA_GW
> > +
> >  static void dma_complete(void *data, uint32_t type, struct
> > dma_sg_elem *next)
> >  {
> >  	completion_t *comp = (completion_t *)data;
> > @@ -84,6 +86,8 @@ static void dma_complete(void *data, uint32_t
> > type, struct
> > dma_sg_elem *next)
> >  	next->size = DMA_RELOAD_END;
> >  }
> >  
> > +#endif
> > +
> >  /* Copy DSP memory to host memory.
> >   * copies DSP memory to host in PAGE_SIZE or smaller blocks and
> > waits/sleeps
> >   * between blocks. Can't be used in IRQ context.
> > @@ -172,8 +176,22 @@ int dma_copy_to_host(struct dma_copy *dc,
> > struct
> > dma_sg_config *host_sg,
> >   * Copies DSP memory to host in a single PAGE_SIZE or smaller
> > block. Does not
> >   * waits/sleeps and can be used in IRQ context.
> >   */
> > +#if defined CONFIG_DMA_GW
> > +
> >  int dma_copy_to_host_nowait(struct dma_copy *dc, struct
> > dma_sg_config
> > *host_sg,
> > -	int32_t host_offset, void *local_ptr, int32_t size)
> > +			    int32_t host_offset, void *local_ptr,
> > int32_t
> > size)
> > +{
> > +	/* tell gateway to copy */
> > +	dma_copy(dc->dmac, dc->chan, size);
> 
> Probably want to check any return value here ?

Sure.

> 
> > 
> > +
> > +	/* bytes copied */
> > +	return size;
> > +}
> > +
> > +#else
> > +
> > +int dma_copy_to_host_nowait(struct dma_copy *dc, struct
> > dma_sg_config
> > *host_sg,
> > +			    int32_t host_offset, void *local_ptr,
> > int32_t
> > size)
> >  {
> >  	struct dma_sg_config config;
> >  	struct dma_sg_elem *host_sg_elem;
> > @@ -219,6 +237,8 @@ int dma_copy_to_host_nowait(struct dma_copy
> > *dc, struct
> > dma_sg_config *host_sg,
> >  	return local_sg_elem.size;
> >  }
> >  
> > +#endif
> > +
> >  /* Copy host memory to DSP memory.
> >   * Copies host memory to host in PAGE_SIZE or smaller blocks and
> > waits/sleeps
> >   * between blocks. Cant be used in IRQ context.
> > @@ -359,6 +379,7 @@ int dma_copy_new(struct dma_copy *dc, int dmac)
> >  		return -ENODEV;
> >  	}
> >  
> > +#if !defined CONFIG_DMA_GW
> >  	/* get DMA channel from DMAC0 */
> >  	dc->chan = dma_channel_get(dc->dmac, 0);
> >  	if (dc->chan < 0) {
> > @@ -369,6 +390,23 @@ int dma_copy_new(struct dma_copy *dc, int
> > dmac)
> >  	dc->complete.timeout = 100;	/* wait 100 usecs for
> > DMA to
> > finish */
> >  	dma_set_cb(dc->dmac, dc->chan, DMA_IRQ_TYPE_LLIST,
> > dma_complete,
> >  		&dc->complete);
> > +#endif
> > +
> >  	return 0;
> >  }
> >  
> > +#if defined CONFIG_DMA_GW
> > +
> > +int dma_set_channel(struct dma_copy *dc, uint32_t stream_tag)
> > +{
> > +	/* get DMA channel from DMAC */
> > +	dc->chan = dma_channel_get(dc->dmac, stream_tag - 1);
> > +	if (dc->chan < 0) {
> > +		trace_dma_error("ec1");
> > +		return dc->chan;
> > +	}
> > +
> > +	return 0;
> 
> return -EINVAL; as 0 is a valid channel number.

sure.
> 
> > 
> > +}
> > +
> > +#endif
> ---------------------------------------------------------------------
> Intel Corporation (UK) Limited
> Registered No. 1134945 (England)
> Registered Office: Pipers Way, Swindon SN3 1RJ
> VAT No: 860 2173 47
> 
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
> _______________________________________________
> 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