diff options
author | Jason Gunthorpe <jgg@mellanox.com> | 2019-01-04 13:40:21 -0500 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2019-02-11 17:02:33 -0500 |
commit | d901b2760dc6cd5fbbf2eac31d71d94baa6c4aef (patch) | |
tree | 6598a5b011cea1bcdf160c2be9fd4e677d387e2b /drivers/media/pci/intel/ipu3 | |
parent | f368ff188ae4b3ef6f740a15999ea0373261b619 (diff) |
lib/scatterlist: Provide a DMA page iterator
Commit 2db76d7c3c6d ("lib/scatterlist: sg_page_iter: support sg lists w/o
backing pages") introduced the sg_page_iter_dma_address() function without
providing a way to use it in the general case. If the sg_dma_len() is not
equal to the sg length callers cannot safely use the
for_each_sg_page/sg_page_iter_dma_address combination.
Resolve this API mistake by providing a DMA specific iterator,
for_each_sg_dma_page(), that uses the right length so
sg_page_iter_dma_address() works as expected with all sglists.
A new iterator type is introduced to provide compile-time safety against
wrongly mixing accessors and iterators.
Acked-by: Christoph Hellwig <hch@lst.de> (for scatterlist)
Acked-by: Thomas Hellstrom <thellstrom@vmware.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> (ipu3-cio2)
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/media/pci/intel/ipu3')
-rw-r--r-- | drivers/media/pci/intel/ipu3/ipu3-cio2.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c index cdb79ae2d8dc..9fbfbda74171 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c | |||
@@ -846,7 +846,7 @@ static int cio2_vb2_buf_init(struct vb2_buffer *vb) | |||
846 | unsigned int pages = DIV_ROUND_UP(vb->planes[0].length, CIO2_PAGE_SIZE); | 846 | unsigned int pages = DIV_ROUND_UP(vb->planes[0].length, CIO2_PAGE_SIZE); |
847 | unsigned int lops = DIV_ROUND_UP(pages + 1, entries_per_page); | 847 | unsigned int lops = DIV_ROUND_UP(pages + 1, entries_per_page); |
848 | struct sg_table *sg; | 848 | struct sg_table *sg; |
849 | struct sg_page_iter sg_iter; | 849 | struct sg_dma_page_iter sg_iter; |
850 | int i, j; | 850 | int i, j; |
851 | 851 | ||
852 | if (lops <= 0 || lops > CIO2_MAX_LOPS) { | 852 | if (lops <= 0 || lops > CIO2_MAX_LOPS) { |
@@ -873,7 +873,7 @@ static int cio2_vb2_buf_init(struct vb2_buffer *vb) | |||
873 | b->offset = sg->sgl->offset; | 873 | b->offset = sg->sgl->offset; |
874 | 874 | ||
875 | i = j = 0; | 875 | i = j = 0; |
876 | for_each_sg_page(sg->sgl, &sg_iter, sg->nents, 0) { | 876 | for_each_sg_dma_page (sg->sgl, &sg_iter, sg->nents, 0) { |
877 | if (!pages--) | 877 | if (!pages--) |
878 | break; | 878 | break; |
879 | b->lop[i][j] = sg_page_iter_dma_address(&sg_iter) >> PAGE_SHIFT; | 879 | b->lop[i][j] = sg_page_iter_dma_address(&sg_iter) >> PAGE_SHIFT; |