Skip to content

Commit 6755ec0

Browse files
Peter Ujfalusivinodkoul
authored andcommitted
dmaengine: Add support for reporting DMA cached data amount
A DMA hardware can have big cache or FIFO and the amount of data sitting in the DMA fabric can be an interest for the clients. For example in audio we want to know the delay in the data flow and in case the DMA have significantly large FIFO/cache, it can affect the latenc/delay Signed-off-by: Peter Ujfalusi <[email protected]> Reviewed-by: Tero Kristo <[email protected]> Tested-by: Keerthy <[email protected]> Reviewed-by: Grygorii Strashko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 4db8fd3 commit 6755ec0

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

drivers/dma/dmaengine.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ static inline enum dma_status dma_cookie_status(struct dma_chan *chan,
7777
state->last = complete;
7878
state->used = used;
7979
state->residue = 0;
80+
state->in_flight_bytes = 0;
8081
}
8182
return dma_async_is_complete(cookie, complete, used);
8283
}
@@ -87,6 +88,13 @@ static inline void dma_set_residue(struct dma_tx_state *state, u32 residue)
8788
state->residue = residue;
8889
}
8990

91+
static inline void dma_set_in_flight_bytes(struct dma_tx_state *state,
92+
u32 in_flight_bytes)
93+
{
94+
if (state)
95+
state->in_flight_bytes = in_flight_bytes;
96+
}
97+
9098
struct dmaengine_desc_callback {
9199
dma_async_tx_callback callback;
92100
dma_async_tx_callback_result callback_result;

include/linux/dmaengine.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,11 +686,13 @@ static inline struct dma_async_tx_descriptor *txd_next(struct dma_async_tx_descr
686686
* @residue: the remaining number of bytes left to transmit
687687
* on the selected transfer for states DMA_IN_PROGRESS and
688688
* DMA_PAUSED if this is implemented in the driver, else 0
689+
* @in_flight_bytes: amount of data in bytes cached by the DMA.
689690
*/
690691
struct dma_tx_state {
691692
dma_cookie_t last;
692693
dma_cookie_t used;
693694
u32 residue;
695+
u32 in_flight_bytes;
694696
};
695697

696698
/**

0 commit comments

Comments
 (0)