diff options
author | Vinod Koul <vinod.koul@intel.com> | 2014-06-02 00:10:00 -0400 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2014-06-03 02:05:33 -0400 |
commit | 877d8425072b50965f6f04ea3a127928f66db72f (patch) | |
tree | 386a87da4c6631e4b25bab821a31ed370fe114f0 | |
parent | 9d9f71a804314e7d50e2fa9e6e61bc77e2d6ae1c (diff) |
dmaengine: sh: don't use dynamic static allocation
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>
-rw-r--r-- | drivers/dma/sh/shdma-base.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c index 591b9d8cfd7f..b35007e21e6b 100644 --- a/drivers/dma/sh/shdma-base.c +++ b/drivers/dma/sh/shdma-base.c | |||
@@ -657,6 +657,8 @@ static struct dma_async_tx_descriptor *shdma_prep_slave_sg( | |||
657 | direction, flags, false); | 657 | direction, flags, false); |
658 | } | 658 | } |
659 | 659 | ||
660 | #define SHDMA_MAX_SG_LEN 32 | ||
661 | |||
660 | static struct dma_async_tx_descriptor *shdma_prep_dma_cyclic( | 662 | static struct dma_async_tx_descriptor *shdma_prep_dma_cyclic( |
661 | struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len, | 663 | struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len, |
662 | size_t period_len, enum dma_transfer_direction direction, | 664 | size_t period_len, enum dma_transfer_direction direction, |
@@ -668,7 +670,7 @@ static struct dma_async_tx_descriptor *shdma_prep_dma_cyclic( | |||
668 | unsigned int sg_len = buf_len / period_len; | 670 | unsigned int sg_len = buf_len / period_len; |
669 | int slave_id = schan->slave_id; | 671 | int slave_id = schan->slave_id; |
670 | dma_addr_t slave_addr; | 672 | dma_addr_t slave_addr; |
671 | struct scatterlist sgl[sg_len]; | 673 | struct scatterlist sgl[SHDMA_MAX_SG_LEN]; |
672 | int i; | 674 | int i; |
673 | 675 | ||
674 | if (!chan) | 676 | if (!chan) |
@@ -676,6 +678,12 @@ static struct dma_async_tx_descriptor *shdma_prep_dma_cyclic( | |||
676 | 678 | ||
677 | BUG_ON(!schan->desc_num); | 679 | BUG_ON(!schan->desc_num); |
678 | 680 | ||
681 | if (sg_len > SHDMA_MAX_SG_LEN) { | ||
682 | dev_err(schan->dev, "sg length %d exceds limit %d", | ||
683 | sg_len, SHDMA_MAX_SG_LEN); | ||
684 | return NULL; | ||
685 | } | ||
686 | |||
679 | /* Someone calling slave DMA on a generic channel? */ | 687 | /* Someone calling slave DMA on a generic channel? */ |
680 | if (slave_id < 0 || (buf_len < period_len)) { | 688 | if (slave_id < 0 || (buf_len < period_len)) { |
681 | dev_warn(schan->dev, | 689 | dev_warn(schan->dev, |