diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2013-01-17 03:03:01 -0500 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2013-01-20 23:49:21 -0500 |
commit | 5be10f349bc0a2f3dd2ab6417ffe29746403984c (patch) | |
tree | 47da236d7cb05c6a7288313c5c0cfc803119de49 /drivers/dma | |
parent | f8122a82d2eae8ef42de48829deed0ca9d9e1f17 (diff) |
dw_dmac: don't exceed AHB master number in dwc_get_data_width
The driver assumes that hardware has two AHB masters which might not be always
true. In such cases we must not exceed number of the AHB masters present in the
hardware. In the proposed scheme in this patch, we would choose the master with
highest possible number whenever we exceed max AHB masters.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma')
-rw-r--r-- | drivers/dma/dw_dmac.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c index 76301c4ba1ad..635a4a5d31ae 100644 --- a/drivers/dma/dw_dmac.c +++ b/drivers/dma/dw_dmac.c | |||
@@ -47,13 +47,29 @@ static inline unsigned int dwc_get_sms(struct dw_dma_slave *slave) | |||
47 | return slave ? slave->src_master : 1; | 47 | return slave ? slave->src_master : 1; |
48 | } | 48 | } |
49 | 49 | ||
50 | #define SRC_MASTER 0 | ||
51 | #define DST_MASTER 1 | ||
52 | |||
53 | static inline unsigned int dwc_get_master(struct dma_chan *chan, int master) | ||
54 | { | ||
55 | struct dw_dma *dw = to_dw_dma(chan->device); | ||
56 | struct dw_dma_slave *dws = chan->private; | ||
57 | unsigned int m; | ||
58 | |||
59 | if (master == SRC_MASTER) | ||
60 | m = dwc_get_sms(dws); | ||
61 | else | ||
62 | m = dwc_get_dms(dws); | ||
63 | |||
64 | return min_t(unsigned int, dw->nr_masters - 1, m); | ||
65 | } | ||
66 | |||
50 | #define DWC_DEFAULT_CTLLO(_chan) ({ \ | 67 | #define DWC_DEFAULT_CTLLO(_chan) ({ \ |
51 | struct dw_dma_slave *__slave = (_chan->private); \ | ||
52 | struct dw_dma_chan *_dwc = to_dw_dma_chan(_chan); \ | 68 | struct dw_dma_chan *_dwc = to_dw_dma_chan(_chan); \ |
53 | struct dma_slave_config *_sconfig = &_dwc->dma_sconfig; \ | 69 | struct dma_slave_config *_sconfig = &_dwc->dma_sconfig; \ |
54 | bool _is_slave = is_slave_direction(_dwc->direction); \ | 70 | bool _is_slave = is_slave_direction(_dwc->direction); \ |
55 | int _dms = dwc_get_dms(__slave); \ | 71 | int _dms = dwc_get_master(_chan, DST_MASTER); \ |
56 | int _sms = dwc_get_sms(__slave); \ | 72 | int _sms = dwc_get_master(_chan, SRC_MASTER); \ |
57 | u8 _smsize = _is_slave ? _sconfig->src_maxburst : \ | 73 | u8 _smsize = _is_slave ? _sconfig->src_maxburst : \ |
58 | DW_DMA_MSIZE_16; \ | 74 | DW_DMA_MSIZE_16; \ |
59 | u8 _dmsize = _is_slave ? _sconfig->dst_maxburst : \ | 75 | u8 _dmsize = _is_slave ? _sconfig->dst_maxburst : \ |
@@ -74,20 +90,11 @@ static inline unsigned int dwc_get_sms(struct dw_dma_slave *slave) | |||
74 | */ | 90 | */ |
75 | #define NR_DESCS_PER_CHANNEL 64 | 91 | #define NR_DESCS_PER_CHANNEL 64 |
76 | 92 | ||
77 | #define SRC_MASTER 0 | ||
78 | #define DST_MASTER 1 | ||
79 | |||
80 | static inline unsigned int dwc_get_data_width(struct dma_chan *chan, int master) | 93 | static inline unsigned int dwc_get_data_width(struct dma_chan *chan, int master) |
81 | { | 94 | { |
82 | struct dw_dma *dw = to_dw_dma(chan->device); | 95 | struct dw_dma *dw = to_dw_dma(chan->device); |
83 | struct dw_dma_slave *dws = chan->private; | ||
84 | |||
85 | if (master == SRC_MASTER) | ||
86 | return dw->data_width[dwc_get_sms(dws)]; | ||
87 | else if (master == DST_MASTER) | ||
88 | return dw->data_width[dwc_get_dms(dws)]; | ||
89 | 96 | ||
90 | return 0; | 97 | return dw->data_width[dwc_get_master(chan, master)]; |
91 | } | 98 | } |
92 | 99 | ||
93 | /*----------------------------------------------------------------------*/ | 100 | /*----------------------------------------------------------------------*/ |