Skip to content

Commit

Permalink
dmaengine: of-dma: Add support for optional router configuration call…
Browse files Browse the repository at this point in the history
…back

Additional configuration for the DMA event router might be needed for a
channel which can not be done during device_alloc_chan_resources callback
since the router information is not yet present for the drivers.

If there is a need for additional configuration for the channel if DMA
router is in use, then the driver can implement the device_router_config
callback.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20201208090440.31792-8-peter.ujfalusi@ti.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
  • Loading branch information
Peter Ujfalusi authored and Vinod Koul committed Dec 11, 2020
1 parent d553e2a commit 4f910c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/dma/of-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,18 @@ static struct dma_chan *of_dma_router_xlate(struct of_phandle_args *dma_spec,
ofdma->dma_router->route_free(ofdma->dma_router->dev,
route_data);
} else {
int ret = 0;

chan->router = ofdma->dma_router;
chan->route_data = route_data;

if (chan->device->device_router_config)
ret = chan->device->device_router_config(chan);

if (ret) {
dma_release_channel(chan);
chan = ERR_PTR(ret);
}
}

/*
Expand Down
2 changes: 2 additions & 0 deletions include/linux/dmaengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ struct dma_filter {
* by tx_status
* @device_alloc_chan_resources: allocate resources and return the
* number of allocated descriptors
* @device_router_config: optional callback for DMA router configuration
* @device_free_chan_resources: release DMA channel's resources
* @device_prep_dma_memcpy: prepares a memcpy operation
* @device_prep_dma_xor: prepares a xor operation
Expand Down Expand Up @@ -879,6 +880,7 @@ struct dma_device {
enum dma_residue_granularity residue_granularity;

int (*device_alloc_chan_resources)(struct dma_chan *chan);
int (*device_router_config)(struct dma_chan *chan);
void (*device_free_chan_resources)(struct dma_chan *chan);

struct dma_async_tx_descriptor *(*device_prep_dma_memcpy)(
Expand Down

0 comments on commit 4f910c0

Please sign in to comment.