Commit 62f51781 authored by Federico Vaga's avatar Federico Vaga

sw:drv:dma: set max_seg_size and validate scatterlist

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 7c162926
......@@ -458,6 +458,12 @@ static struct dma_async_tx_descriptor *gn412x_dma_prep_slave_sg(
src_addr = sconfig->src_addr;
for_each_sg(sgl, sg, sg_len, i) {
if (sg_dma_len(sg) > dma_get_max_seg_size(chan->dev->device)) {
dev_err(&chan->dev->device,
"Maximum transfer size %d, got %d on transfer %d\n",
0x3FFF, sg_dma_len(sg), i);
goto err_alloc_pool;
}
gn412x_dma_prep_fixup(tx_hw, phys);
tx_hw = dma_pool_alloc(gn412x_dma->pool, GFP_NOWAIT, &phys);
if (!tx_hw)
......@@ -744,6 +750,8 @@ static int gn412x_dma_engine_init(struct gn412x_dma_device *gn412x_dma,
tasklet_init(&gn412x_dma->chan.task, gn412x_dma_start_task,
(unsigned long)&gn412x_dma->chan);
dma_set_max_seg_size(dma->dev, 0x3FFF);
gn412x_dma->pool = dma_pool_create(dev_name(dma->dev), dma->dev,
sizeof(struct gn412x_dma_tx_hw),
sizeof(struct gn412x_dma_tx_hw),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment