Skip to content

Commit

Permalink
dmaengine: sh: don't use dynamic static allocation
Browse files Browse the repository at this point in the history
dynamic stack allocation in kernel is considered bad as kernel stack is low and
we get warns on few archs as reported by kbuild test robot

>> drivers/dma/sh/shdma-base.c:671:32: sparse: Variable length array is used.
>> drivers/dma/sh/shdma-base.c:701:1: warning: 'shdma_prep_dma_cyclic' uses
>> dynamic stack allocation [enabled by default]

Fix this by making a static array of 32 which should be sufficient for
shdma_prep_dma_cyclic which only user in kernel is audio and 32 periods for
audio seems quite sufficient atm

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
  • Loading branch information
Vinod Koul committed Jun 3, 2014
1 parent 9d9f71a commit 877d842
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/dma/sh/shdma-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,8 @@ static struct dma_async_tx_descriptor *shdma_prep_slave_sg(
direction, flags, false);
}

#define SHDMA_MAX_SG_LEN 32

static struct dma_async_tx_descriptor *shdma_prep_dma_cyclic(
struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
size_t period_len, enum dma_transfer_direction direction,
Expand All @@ -668,14 +670,20 @@ static struct dma_async_tx_descriptor *shdma_prep_dma_cyclic(
unsigned int sg_len = buf_len / period_len;
int slave_id = schan->slave_id;
dma_addr_t slave_addr;
struct scatterlist sgl[sg_len];
struct scatterlist sgl[SHDMA_MAX_SG_LEN];
int i;

if (!chan)
return NULL;

BUG_ON(!schan->desc_num);

if (sg_len > SHDMA_MAX_SG_LEN) {
dev_err(schan->dev, "sg length %d exceds limit %d",
sg_len, SHDMA_MAX_SG_LEN);
return NULL;
}

/* Someone calling slave DMA on a generic channel? */
if (slave_id < 0 || (buf_len < period_len)) {
dev_warn(schan->dev,
Expand Down

0 comments on commit 877d842

Please sign in to comment.