]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
staging: apf: Correct sg list length assignment in apf dma
authorMichael Gill <michael.gill@xilinx.com>
Tue, 15 May 2018 20:13:56 +0000 (13:13 -0700)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 16 May 2018 07:56:27 +0000 (09:56 +0200)
When using DMABUFs in the apf dma driver, there were specific
lengths that resulted in the transfer length being incorrectly
assigned.  This patch corrects that by assigning lengths correctly
when the sg descriptor length is smaller than the transfer size.

Signed-off-by: Michael Gill <michael.gill@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/staging/apf/xilinx-dma-apf.c
drivers/staging/apf/xlnk.h

index 7bcce2d66e11668b6bd99a979e289f73b6a91cb5..55913130eafc8088a69f1bdaf77c8faa0ee351ab 100644 (file)
@@ -818,8 +818,9 @@ int xdma_submit(struct xdma_chan *chan,
                sglist = kmalloc_array(dp->dbuf_sg_table->nents,
                                       sizeof(*sglist),
                                       GFP_KERNEL);
-               if (!dp->sg_list)
+               if (!sglist)
                        return -ENOMEM;
+
                sg_init_table(sglist, dp->dbuf_sg_table->nents);
                sgcnt = 0;
                for_each_sg(dp->dbuf_sg_table->sgl,
@@ -837,6 +838,7 @@ int xdma_submit(struct xdma_chan *chan,
                                sg_dma_len(sglist + i) = remaining_size;
                                sgcnt++;
                        } else {
+                               sg_dma_len(sglist + i) = sg_dma_len(sg);
                                remaining_size -= sg_dma_len(sg);
                                sgcnt++;
                        }
index 6f7e77fe3dc098eb6cf4a3d48b9050469ee13c8b..eb94ef2b1da35d0f5f40ce89003ad75b84d401f1 100644 (file)
@@ -45,8 +45,6 @@ struct xlnk_dmabuf_reg {
        struct dma_buf *dbuf;
        struct dma_buf_attachment *dbuf_attach;
        struct sg_table *dbuf_sg_table;
-       struct scatterlist *sg_list;
-       int sg_list_cnt;
        int is_mapped;
        int dma_direction;
        struct list_head list;