dma: xilinx: vdma: Configure the hardware when starting the transfer

Set the XILINX_VDMA_REG_HSIZE and XILINX_VDMA_REG_FRMDLY_STRIDE
registers when starting the transfer, not when preparing the request.
This is needed to allow several requests to be prepared and submitted
for execution.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Srikanth Thokala <srikanth.thokala@xilinx.com>
dma: xilinx: vdma: Rename xilinx_vdma_desc_sw to xilinx_vdma_tx_segment

The structure describes one scatter-gather segment from a transaction,
rename it accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
dma: xilinx: vdma: Split xilinx_vdma_free_chan_resources() function

The xilinx_vdma_free_chan_resources() function frees both the
descriptors and the descriptors pool. Split the descriptors freeing code
into a separate function to increase code reuse.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
dma: xilinx: vdma: Simplify interrupt handler

Perform actions directly instead of setting intermediate variables only
to test them right afterwards.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Srikanth Thokala <srikanth.thokala@xilinx.com>
dma: xilinx: vdma: Support queuing multiple transactions

Create a xilinx_vdma_tx_descriptor structure and use it model DMA
transactions. A transaction can contain several segments, and multiple
transactions can be prepared and submitted without waiting for the
previous transactions to complete.

Replace the active descriptors list with an active descriptor pointer,
and add a new complete descriptors list to store complete descriptors
that need to be handed back to the client.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
dma: xilinx: vdma: Replace pr_debug() with dev_err()

Replace the two pr_debug() calls with dev_err() calls, as they indicate
an error condition.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Srikanth Thokala <srikanth.thokala@xilinx.com>
dma: xilinx: vdma: Clean up interrupt handler

Read the status register once only, and only acknowledge interrupts that
have been detected.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
dma: xilinx: vdma: Handle unrecoverable errors in interrupt handler

Make sure unrecoverable errors are properly flagged with an appropriate
error message.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
dma: xilinx: vdma: Poll the status register when starting/stopping

After setting or clearing the run/stop bit in the control register, the
DMA engine run status is reflected by the halted bit in the status
register. Fix the driver to poll the halted bit instead of polling the
run/stop bit.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
dma: xilinx: vdma: Clear error flag when resetting the DMA engine

Resetting the DMA engine clears the hardware error conditions. Clear the
software error flag as well.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Srikanth Thokala <srikanth.thokala@xilinx.com>
dma: xilinx: vdma: Change returning error codes

Change returning error codes to -ENXIO for xilinx_vdma_reset() failure.

Signed-off-by: Hyun Kwon <hyunk@xilinx.com>
dma: xilinx: vdma: Don't disable interrupts at runtime

Enable interrupts when a channel is probed, and disable interrupts
only when a channel is removed. Re-enable interrupts
when a channel gets reset.

Signed-off-by: Hyun Kwon <hyunk@xilinx.com>
dma: xilinx: vdma: Add xilinx_vdma_chan_reset() function

As interrupts are enabled in xilinx_vdma_chan_probe(),
interrupts should be re-enabled anytime when a vdma channle gets reset.
Add xilinx_vdma_chan_reset() which resets a vdma channel by calling
xilinx_vdma_reset(), and re-enables interrupts.

Signed-off-by: Hyun Kwon <hyunk@xilinx.com>