Skip to content

Commit d8a3f65

Browse files
Radhey Shyam Pandeyvinodkoul
authored andcommitted
dmaengine: xilinx_dma: Pass AXI4-Stream control words to dma client
Read DT property to check if AXI DMA is connected to streaming IP i.e axiethernet. If connected i.e xlnx,axistream-connected property is present in the dma node then pass AXI4-Stream control words to dma client using metadata_ops dmaengine API. If not connected then driver won't support metadata_ops dmaengine API and continue to support all legacy usecases. Signed-off-by: Radhey Shyam Pandey <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent e8cfa38 commit d8a3f65

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

drivers/dma/xilinx/xilinx_dma.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ struct xilinx_dma_config {
493493
* @s2mm_chan_id: DMA s2mm channel identifier
494494
* @mm2s_chan_id: DMA mm2s channel identifier
495495
* @max_buffer_len: Max buffer length
496+
* @has_axistream_connected: AXI DMA connected to AXI Stream IP
496497
*/
497498
struct xilinx_dma_device {
498499
void __iomem *regs;
@@ -511,6 +512,7 @@ struct xilinx_dma_device {
511512
u32 s2mm_chan_id;
512513
u32 mm2s_chan_id;
513514
u32 max_buffer_len;
515+
bool has_axistream_connected;
514516
};
515517

516518
/* Macros */
@@ -623,6 +625,29 @@ static inline void xilinx_aximcdma_buf(struct xilinx_dma_chan *chan,
623625
}
624626
}
625627

628+
/**
629+
* xilinx_dma_get_metadata_ptr- Populate metadata pointer and payload length
630+
* @tx: async transaction descriptor
631+
* @payload_len: metadata payload length
632+
* @max_len: metadata max length
633+
* Return: The app field pointer.
634+
*/
635+
static void *xilinx_dma_get_metadata_ptr(struct dma_async_tx_descriptor *tx,
636+
size_t *payload_len, size_t *max_len)
637+
{
638+
struct xilinx_dma_tx_descriptor *desc = to_dma_tx_descriptor(tx);
639+
struct xilinx_axidma_tx_segment *seg;
640+
641+
*max_len = *payload_len = sizeof(u32) * XILINX_DMA_NUM_APP_WORDS;
642+
seg = list_first_entry(&desc->segments,
643+
struct xilinx_axidma_tx_segment, node);
644+
return seg->hw.app;
645+
}
646+
647+
static struct dma_descriptor_metadata_ops xilinx_dma_metadata_ops = {
648+
.get_ptr = xilinx_dma_get_metadata_ptr,
649+
};
650+
626651
/* -----------------------------------------------------------------------------
627652
* Descriptors and segments alloc and free
628653
*/
@@ -2221,6 +2246,9 @@ static struct dma_async_tx_descriptor *xilinx_dma_prep_slave_sg(
22212246
segment->hw.control |= XILINX_DMA_BD_EOP;
22222247
}
22232248

2249+
if (chan->xdev->has_axistream_connected)
2250+
desc->async_tx.metadata_ops = &xilinx_dma_metadata_ops;
2251+
22242252
return &desc->async_tx;
22252253

22262254
error:
@@ -3067,6 +3095,11 @@ static int xilinx_dma_probe(struct platform_device *pdev)
30673095
}
30683096
}
30693097

3098+
if (xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) {
3099+
xdev->has_axistream_connected =
3100+
of_property_read_bool(node, "xlnx,axistream-connected");
3101+
}
3102+
30703103
if (xdev->dma_config->dmatype == XDMA_TYPE_VDMA) {
30713104
err = of_property_read_u32(node, "xlnx,num-fstores",
30723105
&num_frames);
@@ -3092,6 +3125,10 @@ static int xilinx_dma_probe(struct platform_device *pdev)
30923125
else
30933126
xdev->ext_addr = false;
30943127

3128+
/* Set metadata mode */
3129+
if (xdev->has_axistream_connected)
3130+
xdev->common.desc_metadata_modes = DESC_METADATA_ENGINE;
3131+
30953132
/* Set the dma mask bits */
30963133
err = dma_set_mask_and_coherent(xdev->dev, DMA_BIT_MASK(addr_width));
30973134
if (err < 0) {

0 commit comments

Comments
 (0)