Skip to content

Commit c8ae793

Browse files
Matthew Murrianvinodkoul
authored andcommitted
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: 6ccd692 ("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>
1 parent 0ba2df0 commit c8ae793

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

drivers/dma/xilinx/xilinx_dma.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,10 @@ static u32 xilinx_dma_get_residue(struct xilinx_dma_chan *chan,
948948
{
949949
struct xilinx_cdma_tx_segment *cdma_seg;
950950
struct xilinx_axidma_tx_segment *axidma_seg;
951+
struct xilinx_aximcdma_tx_segment *aximcdma_seg;
951952
struct xilinx_cdma_desc_hw *cdma_hw;
952953
struct xilinx_axidma_desc_hw *axidma_hw;
954+
struct xilinx_aximcdma_desc_hw *aximcdma_hw;
953955
struct list_head *entry;
954956
u32 residue = 0;
955957

@@ -961,13 +963,23 @@ static u32 xilinx_dma_get_residue(struct xilinx_dma_chan *chan,
961963
cdma_hw = &cdma_seg->hw;
962964
residue += (cdma_hw->control - cdma_hw->status) &
963965
chan->xdev->max_buffer_len;
964-
} else {
966+
} else if (chan->xdev->dma_config->dmatype ==
967+
XDMA_TYPE_AXIDMA) {
965968
axidma_seg = list_entry(entry,
966969
struct xilinx_axidma_tx_segment,
967970
node);
968971
axidma_hw = &axidma_seg->hw;
969972
residue += (axidma_hw->control - axidma_hw->status) &
970973
chan->xdev->max_buffer_len;
974+
} else {
975+
aximcdma_seg =
976+
list_entry(entry,
977+
struct xilinx_aximcdma_tx_segment,
978+
node);
979+
aximcdma_hw = &aximcdma_seg->hw;
980+
residue +=
981+
(aximcdma_hw->control - aximcdma_hw->status) &
982+
chan->xdev->max_buffer_len;
971983
}
972984
}
973985

@@ -1135,7 +1147,7 @@ static int xilinx_dma_alloc_chan_resources(struct dma_chan *dchan)
11351147
upper_32_bits(chan->seg_p + sizeof(*chan->seg_mv) *
11361148
((i + 1) % XILINX_DMA_NUM_DESCS));
11371149
chan->seg_mv[i].phys = chan->seg_p +
1138-
sizeof(*chan->seg_v) * i;
1150+
sizeof(*chan->seg_mv) * i;
11391151
list_add_tail(&chan->seg_mv[i].node,
11401152
&chan->free_seg_list);
11411153
}
@@ -1560,7 +1572,7 @@ static void xilinx_dma_start_transfer(struct xilinx_dma_chan *chan)
15601572
static void xilinx_mcdma_start_transfer(struct xilinx_dma_chan *chan)
15611573
{
15621574
struct xilinx_dma_tx_descriptor *head_desc, *tail_desc;
1563-
struct xilinx_axidma_tx_segment *tail_segment;
1575+
struct xilinx_aximcdma_tx_segment *tail_segment;
15641576
u32 reg;
15651577

15661578
/*
@@ -1582,7 +1594,7 @@ static void xilinx_mcdma_start_transfer(struct xilinx_dma_chan *chan)
15821594
tail_desc = list_last_entry(&chan->pending_list,
15831595
struct xilinx_dma_tx_descriptor, node);
15841596
tail_segment = list_last_entry(&tail_desc->segments,
1585-
struct xilinx_axidma_tx_segment, node);
1597+
struct xilinx_aximcdma_tx_segment, node);
15861598

15871599
reg = dma_ctrl_read(chan, XILINX_MCDMA_CHAN_CR_OFFSET(chan->tdest));
15881600

@@ -1864,6 +1876,7 @@ static void append_desc_queue(struct xilinx_dma_chan *chan,
18641876
struct xilinx_vdma_tx_segment *tail_segment;
18651877
struct xilinx_dma_tx_descriptor *tail_desc;
18661878
struct xilinx_axidma_tx_segment *axidma_tail_segment;
1879+
struct xilinx_aximcdma_tx_segment *aximcdma_tail_segment;
18671880
struct xilinx_cdma_tx_segment *cdma_tail_segment;
18681881

18691882
if (list_empty(&chan->pending_list))
@@ -1885,11 +1898,17 @@ static void append_desc_queue(struct xilinx_dma_chan *chan,
18851898
struct xilinx_cdma_tx_segment,
18861899
node);
18871900
cdma_tail_segment->hw.next_desc = (u32)desc->async_tx.phys;
1888-
} else {
1901+
} else if (chan->xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) {
18891902
axidma_tail_segment = list_last_entry(&tail_desc->segments,
18901903
struct xilinx_axidma_tx_segment,
18911904
node);
18921905
axidma_tail_segment->hw.next_desc = (u32)desc->async_tx.phys;
1906+
} else {
1907+
aximcdma_tail_segment =
1908+
list_last_entry(&tail_desc->segments,
1909+
struct xilinx_aximcdma_tx_segment,
1910+
node);
1911+
aximcdma_tail_segment->hw.next_desc = (u32)desc->async_tx.phys;
18931912
}
18941913

18951914
/*

0 commit comments

Comments
 (0)