Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dmaengine: dw: Don't pollute CTL_LO on iDMA 32-bit

Intel iDMA 32-bit doesn't have a concept of bus masters and thus
there is no need to setup any kind of masters in the CTL_LO register.

Moreover, the burst size for memory-to-memory transfer is not what is says,
we need to have a corrected list of possible sizes. Note, that
the size of 8 items, each of that up to 4 bytes, is chosen because of
maximum of 1/2 FIFO, which is 64 bytes on Intel Merrifield.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Andy Shevchenko and committed by
Vinod Koul
934891b0 91f0ff88

+47 -26
+5 -26
drivers/dma/dw/core.c
··· 37 37 * support descriptor writeback. 38 38 */ 39 39 40 - #define DWC_DEFAULT_CTLLO(_chan) ({ \ 41 - struct dw_dma_chan *_dwc = to_dw_dma_chan(_chan); \ 42 - struct dma_slave_config *_sconfig = &_dwc->dma_sconfig; \ 43 - bool _is_slave = is_slave_direction(_dwc->direction); \ 44 - u8 _smsize = _is_slave ? _sconfig->src_maxburst : \ 45 - DW_DMA_MSIZE_16; \ 46 - u8 _dmsize = _is_slave ? _sconfig->dst_maxburst : \ 47 - DW_DMA_MSIZE_16; \ 48 - u8 _dms = (_dwc->direction == DMA_MEM_TO_DEV) ? \ 49 - _dwc->dws.p_master : _dwc->dws.m_master; \ 50 - u8 _sms = (_dwc->direction == DMA_DEV_TO_MEM) ? \ 51 - _dwc->dws.p_master : _dwc->dws.m_master; \ 52 - \ 53 - (DWC_CTLL_DST_MSIZE(_dmsize) \ 54 - | DWC_CTLL_SRC_MSIZE(_smsize) \ 55 - | DWC_CTLL_LLP_D_EN \ 56 - | DWC_CTLL_LLP_S_EN \ 57 - | DWC_CTLL_DMS(_dms) \ 58 - | DWC_CTLL_SMS(_sms)); \ 59 - }) 60 - 61 40 /* The set of bus widths supported by the DMA controller */ 62 41 #define DW_DMA_BUSWIDTHS \ 63 42 BIT(DMA_SLAVE_BUSWIDTH_UNDEFINED) | \ ··· 575 596 576 597 src_width = dst_width = __ffs(data_width | src | dest | len); 577 598 578 - ctllo = DWC_DEFAULT_CTLLO(chan) 599 + ctllo = dw->prepare_ctllo(dwc) 579 600 | DWC_CTLL_DST_WIDTH(dst_width) 580 601 | DWC_CTLL_SRC_WIDTH(src_width) 581 602 | DWC_CTLL_DST_INC ··· 655 676 case DMA_MEM_TO_DEV: 656 677 reg_width = __ffs(sconfig->dst_addr_width); 657 678 reg = sconfig->dst_addr; 658 - ctllo = (DWC_DEFAULT_CTLLO(chan) 679 + ctllo = dw->prepare_ctllo(dwc) 659 680 | DWC_CTLL_DST_WIDTH(reg_width) 660 681 | DWC_CTLL_DST_FIX 661 - | DWC_CTLL_SRC_INC); 682 + | DWC_CTLL_SRC_INC; 662 683 663 684 ctllo |= sconfig->device_fc ? DWC_CTLL_FC(DW_DMA_FC_P_M2P) : 664 685 DWC_CTLL_FC(DW_DMA_FC_D_M2P); ··· 705 726 case DMA_DEV_TO_MEM: 706 727 reg_width = __ffs(sconfig->src_addr_width); 707 728 reg = sconfig->src_addr; 708 - ctllo = (DWC_DEFAULT_CTLLO(chan) 729 + ctllo = dw->prepare_ctllo(dwc) 709 730 | DWC_CTLL_SRC_WIDTH(reg_width) 710 731 | DWC_CTLL_DST_INC 711 - | DWC_CTLL_SRC_FIX); 732 + | DWC_CTLL_SRC_FIX; 712 733 713 734 ctllo |= sconfig->device_fc ? DWC_CTLL_FC(DW_DMA_FC_P_P2M) : 714 735 DWC_CTLL_FC(DW_DMA_FC_D_P2M);
+18
drivers/dma/dw/dw.c
··· 4 4 // Copyright (C) 2013,2018 Intel Corporation 5 5 6 6 #include <linux/bitops.h> 7 + #include <linux/dmaengine.h> 7 8 #include <linux/errno.h> 8 9 #include <linux/slab.h> 9 10 #include <linux/types.h> ··· 64 63 return DWC_CTLH_BLOCK_TS(block) << width; 65 64 } 66 65 66 + static u32 dw_dma_prepare_ctllo(struct dw_dma_chan *dwc) 67 + { 68 + struct dma_slave_config *sconfig = &dwc->dma_sconfig; 69 + bool is_slave = is_slave_direction(dwc->direction); 70 + u8 smsize = is_slave ? sconfig->src_maxburst : DW_DMA_MSIZE_16; 71 + u8 dmsize = is_slave ? sconfig->dst_maxburst : DW_DMA_MSIZE_16; 72 + u8 p_master = dwc->dws.p_master; 73 + u8 m_master = dwc->dws.m_master; 74 + u8 dms = (dwc->direction == DMA_MEM_TO_DEV) ? p_master : m_master; 75 + u8 sms = (dwc->direction == DMA_DEV_TO_MEM) ? p_master : m_master; 76 + 77 + return DWC_CTLL_LLP_D_EN | DWC_CTLL_LLP_S_EN | 78 + DWC_CTLL_DST_MSIZE(dmsize) | DWC_CTLL_SRC_MSIZE(smsize) | 79 + DWC_CTLL_DMS(dms) | DWC_CTLL_SMS(sms); 80 + } 81 + 67 82 static void dw_dma_encode_maxburst(struct dw_dma_chan *dwc, u32 *maxburst) 68 83 { 69 84 /* ··· 116 99 dw->initialize_chan = dw_dma_initialize_chan; 117 100 dw->suspend_chan = dw_dma_suspend_chan; 118 101 dw->resume_chan = dw_dma_resume_chan; 102 + dw->prepare_ctllo = dw_dma_prepare_ctllo; 119 103 dw->encode_maxburst = dw_dma_encode_maxburst; 120 104 dw->bytes2block = dw_dma_bytes2block; 121 105 dw->block2bytes = dw_dma_block2bytes;
+13
drivers/dma/dw/idma32.c
··· 2 2 // Copyright (C) 2013,2018 Intel Corporation 3 3 4 4 #include <linux/bitops.h> 5 + #include <linux/dmaengine.h> 5 6 #include <linux/errno.h> 6 7 #include <linux/slab.h> 7 8 #include <linux/types.h> ··· 70 69 return IDMA32C_CTLH_BLOCK_TS(block); 71 70 } 72 71 72 + static u32 idma32_prepare_ctllo(struct dw_dma_chan *dwc) 73 + { 74 + struct dma_slave_config *sconfig = &dwc->dma_sconfig; 75 + bool is_slave = is_slave_direction(dwc->direction); 76 + u8 smsize = is_slave ? sconfig->src_maxburst : IDMA32_MSIZE_8; 77 + u8 dmsize = is_slave ? sconfig->dst_maxburst : IDMA32_MSIZE_8; 78 + 79 + return DWC_CTLL_LLP_D_EN | DWC_CTLL_LLP_S_EN | 80 + DWC_CTLL_DST_MSIZE(dmsize) | DWC_CTLL_SRC_MSIZE(smsize); 81 + } 82 + 73 83 static void idma32_encode_maxburst(struct dw_dma_chan *dwc, u32 *maxburst) 74 84 { 75 85 *maxburst = *maxburst > 1 ? fls(*maxburst) - 1 : 0; ··· 138 126 dw->initialize_chan = idma32_initialize_chan; 139 127 dw->suspend_chan = idma32_suspend_chan; 140 128 dw->resume_chan = idma32_resume_chan; 129 + dw->prepare_ctllo = idma32_prepare_ctllo; 141 130 dw->encode_maxburst = idma32_encode_maxburst; 142 131 dw->bytes2block = idma32_bytes2block; 143 132 dw->block2bytes = idma32_block2bytes;
+11
drivers/dma/dw/regs.h
··· 222 222 223 223 /* iDMA 32-bit support */ 224 224 225 + /* bursts size */ 226 + enum idma32_msize { 227 + IDMA32_MSIZE_1, 228 + IDMA32_MSIZE_2, 229 + IDMA32_MSIZE_4, 230 + IDMA32_MSIZE_8, 231 + IDMA32_MSIZE_16, 232 + IDMA32_MSIZE_32, 233 + }; 234 + 225 235 /* Bitfields in CTL_HI */ 226 236 #define IDMA32C_CTLH_BLOCK_TS_MASK GENMASK(16, 0) 227 237 #define IDMA32C_CTLH_BLOCK_TS(x) ((x) & IDMA32C_CTLH_BLOCK_TS_MASK) ··· 326 316 void (*initialize_chan)(struct dw_dma_chan *dwc); 327 317 void (*suspend_chan)(struct dw_dma_chan *dwc, bool drain); 328 318 void (*resume_chan)(struct dw_dma_chan *dwc, bool drain); 319 + u32 (*prepare_ctllo)(struct dw_dma_chan *dwc); 329 320 void (*encode_maxburst)(struct dw_dma_chan *dwc, u32 *maxburst); 330 321 u32 (*bytes2block)(struct dw_dma_chan *dwc, size_t bytes, 331 322 unsigned int width, size_t *len);