dmaengine: avoid map_cnt overflow with CONFIG_DMA_ENGINE_RAID
PATCH 1/1 dmaengine: avoid map_cnt overflow with CONFIG_DMA_ENGINE_RAID
From: Zi Yan <[email protected]>
When CONFIG_DMA_ENGINE_RAID is enabled, unmap pool size can reach to
256. But in struct dmaengine_unmap_data, map_cnt is only u8, wrapping to 0, if the unmap pool is maximally used. This triggers BUG() when struct dmaengine_unmap_data is freed. Use u16 to fix the problem.
--- include/linux/dmaengine.h | 4 ++++ 1 file changed, 4 insertions(+)
include/linux/dmaengine.h +4 -0
@@ -470,7 +470,11 @@ typedef void (*dma_async_tx_callback_result)(void *dma_async_param, const struct dmaengine_result *result);struct dmaengine_unmap_data { +#if IS_ENABLED (CONFIG_DMA_ENGINE_RAID ) +u16 map_cnt; +#else u8 map_cnt; +#endif u8 to_cnt;u8 from_cnt;u8 bidi_cnt;
Quoted 18 lines · Zi Yan
From: Zi Yan <[email protected]>
When
CONFIG_DMA_ENGINE_RAIDis enabled, unmap pool size can reach to
256. But in structdmaengine_unmap_data,map_cntis only u8, wrapping to 0, if the unmap pool is maximally used. This triggersBUG()when structdmaengine_unmap_datais freed. Use u16 to fix the problem.Signed-off-by Zi Yan <[email protected]>--- include/linux/dmaengine.h | 4 ++++ 1 file changed, 4 insertions(+)include/linux/dmaengine.h +0
-0@@ -470,7 +470,11 @@ typedef void (*dma_async_tx_callback_result)(void *dma_async_param, const struct dmaengine_result *result);
include/linux/dmaengine.h typedef void (*dma_async_tx_callback_result)(void *dma_async_param, · line 480
Quoted 10 lines
include/linux/dmaengine.h +4
-0struct dmaengine_unmap_data { +#if IS_ENABLED (CONFIG_DMA_ENGINE_RAID ) +u16 map_cnt; +#else u8 map_cnt; +#endif u8 to_cnt;u8 from_cnt;u8 bidi_cnt;
Would that cause adverse performance, the data structure is not aligned anymore. Dan was that a consideration while adding this?
Signature · 1 line
~Vinod
Quoted 21 lines · Vinod Koul
Quoted 20 lines · Zi Yan
From: Zi Yan <[email protected]>
When
CONFIG_DMA_ENGINE_RAIDis enabled, unmap pool size can reach to
256. But in structdmaengine_unmap_data,map_cntis only u8, wrapping to 0, if the unmap pool is maximally used. This triggersBUG()when structdmaengine_unmap_datais freed. Use u16 to fix the problem.Signed-off-by Zi Yan <[email protected]>--- include/linux/dmaengine.h | 4 ++++ 1 file changed, 4 insertions(+)include/linux/dmaengine.h +0
-0@@ -470,7 +470,11 @@ typedef void (*dma_async_tx_callback_result)(void *dma_async_param, const struct dmaengine_result *result);
Quoted 14 lines
Quoted 9 lines
include/linux/dmaengine.h +4
-0struct dmaengine_unmap_data { +#if IS_ENABLED (CONFIG_DMA_ENGINE_RAID ) +u16 map_cnt; +#else u8 map_cnt; +#endif u8 to_cnt;u8 from_cnt;u8
bidi_cnt;Would that cause adverse performance, the data structure is not aligned
anymore. Dan was that a consideration while adding this?
It will be only two more cache misses (one for map the data, the other for unmap the data)
for each DMA engine operation, no matter what data size is. And there is no impact on
the actual DMA transfers. So the impact should be minimal.
—
Best Regards,
Yan Zi
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Vinod Koul
AppliedQuoted 6 lines · Zi Yan
From: Zi Yan <[email protected]>
When
CONFIG_DMA_ENGINE_RAIDis enabled, unmap pool size can reach to
256. But in structdmaengine_unmap_data,map_cntis only u8, wrapping to 0, if the unmap pool is maximally used. This triggersBUG()when structdmaengine_unmap_datais freed. Use u16 to fix the problem.
Applied, thanks
Signature · 1 line
~Vinod