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

dmaengine: xilinx_dma: Fix usage of xilinx_aximcdma_tx_segment

Several code sections incorrectly use struct xilinx_axidma_tx_segment
instead of struct xilinx_aximcdma_tx_segment when operating as
Multichannel DMA. As their structures are similar, this just works.

Fixes: 6ccd692bfb7f ("dmaengine: xilinx_dma: Add Xilinx AXI MCDMA Engine driver support")
Signed-off-by: Matthew Murrian <matthew.murrian@goctsi.com>
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
Link: https://lore.kernel.org/r/1604473206-32573-3-git-send-email-radhey.shyam.pandey@xilinx.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Matthew Murrian and committed by
Vinod Koul
c8ae7932 0ba2df09

+24 -5
+24 -5
drivers/dma/xilinx/xilinx_dma.c
··· 948 948 { 949 949 struct xilinx_cdma_tx_segment *cdma_seg; 950 950 struct xilinx_axidma_tx_segment *axidma_seg; 951 + struct xilinx_aximcdma_tx_segment *aximcdma_seg; 951 952 struct xilinx_cdma_desc_hw *cdma_hw; 952 953 struct xilinx_axidma_desc_hw *axidma_hw; 954 + struct xilinx_aximcdma_desc_hw *aximcdma_hw; 953 955 struct list_head *entry; 954 956 u32 residue = 0; 955 957 ··· 963 961 cdma_hw = &cdma_seg->hw; 964 962 residue += (cdma_hw->control - cdma_hw->status) & 965 963 chan->xdev->max_buffer_len; 966 - } else { 964 + } else if (chan->xdev->dma_config->dmatype == 965 + XDMA_TYPE_AXIDMA) { 967 966 axidma_seg = list_entry(entry, 968 967 struct xilinx_axidma_tx_segment, 969 968 node); 970 969 axidma_hw = &axidma_seg->hw; 971 970 residue += (axidma_hw->control - axidma_hw->status) & 972 971 chan->xdev->max_buffer_len; 972 + } else { 973 + aximcdma_seg = 974 + list_entry(entry, 975 + struct xilinx_aximcdma_tx_segment, 976 + node); 977 + aximcdma_hw = &aximcdma_seg->hw; 978 + residue += 979 + (aximcdma_hw->control - aximcdma_hw->status) & 980 + chan->xdev->max_buffer_len; 973 981 } 974 982 } 975 983 ··· 1147 1135 upper_32_bits(chan->seg_p + sizeof(*chan->seg_mv) * 1148 1136 ((i + 1) % XILINX_DMA_NUM_DESCS)); 1149 1137 chan->seg_mv[i].phys = chan->seg_p + 1150 - sizeof(*chan->seg_v) * i; 1138 + sizeof(*chan->seg_mv) * i; 1151 1139 list_add_tail(&chan->seg_mv[i].node, 1152 1140 &chan->free_seg_list); 1153 1141 } ··· 1572 1560 static void xilinx_mcdma_start_transfer(struct xilinx_dma_chan *chan) 1573 1561 { 1574 1562 struct xilinx_dma_tx_descriptor *head_desc, *tail_desc; 1575 - struct xilinx_axidma_tx_segment *tail_segment; 1563 + struct xilinx_aximcdma_tx_segment *tail_segment; 1576 1564 u32 reg; 1577 1565 1578 1566 /* ··· 1594 1582 tail_desc = list_last_entry(&chan->pending_list, 1595 1583 struct xilinx_dma_tx_descriptor, node); 1596 1584 tail_segment = list_last_entry(&tail_desc->segments, 1597 - struct xilinx_axidma_tx_segment, node); 1585 + struct xilinx_aximcdma_tx_segment, node); 1598 1586 1599 1587 reg = dma_ctrl_read(chan, XILINX_MCDMA_CHAN_CR_OFFSET(chan->tdest)); 1600 1588 ··· 1876 1864 struct xilinx_vdma_tx_segment *tail_segment; 1877 1865 struct xilinx_dma_tx_descriptor *tail_desc; 1878 1866 struct xilinx_axidma_tx_segment *axidma_tail_segment; 1867 + struct xilinx_aximcdma_tx_segment *aximcdma_tail_segment; 1879 1868 struct xilinx_cdma_tx_segment *cdma_tail_segment; 1880 1869 1881 1870 if (list_empty(&chan->pending_list)) ··· 1898 1885 struct xilinx_cdma_tx_segment, 1899 1886 node); 1900 1887 cdma_tail_segment->hw.next_desc = (u32)desc->async_tx.phys; 1901 - } else { 1888 + } else if (chan->xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) { 1902 1889 axidma_tail_segment = list_last_entry(&tail_desc->segments, 1903 1890 struct xilinx_axidma_tx_segment, 1904 1891 node); 1905 1892 axidma_tail_segment->hw.next_desc = (u32)desc->async_tx.phys; 1893 + } else { 1894 + aximcdma_tail_segment = 1895 + list_last_entry(&tail_desc->segments, 1896 + struct xilinx_aximcdma_tx_segment, 1897 + node); 1898 + aximcdma_tail_segment->hw.next_desc = (u32)desc->async_tx.phys; 1906 1899 } 1907 1900 1908 1901 /*