linux/drivers/staging/media
Marek Szyprowski 76f50ad9b1 staging: tegra-vde: fix common struct sg_table related issues
The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function
returns the number of the created entries in the DMA address space.
However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and
dma_unmap_sg must be called with the original number of the entries
passed to the dma_map_sg().

struct sg_table is a common structure used for describing a non-contiguous
memory buffer, used commonly in the DRM and graphics subsystems. It
consists of a scatterlist with memory pages and DMA addresses (sgl entry),
as well as the number of scatterlist entries: CPU pages (orig_nents entry)
and DMA mapped pages (nents entry).

It turned out that it was a common mistake to misuse nents and orig_nents
entries, calling DMA-mapping functions with a wrong number of entries or
ignoring the number of mapped entries returned by the dma_map_sg()
function.

To avoid such issues, lets use a common dma-mapping wrappers operating
directly on the struct sg_table objects and use scatterlist page
iterators where possible. This, almost always, hides references to the
nents and orig_nents entries, making the code robust, easier to follow
and copy/paste safe.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Link: https://lore.kernel.org/r/20200904131711.12950-27-m.szyprowski@samsung.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-09-05 16:58:27 +02:00
..
allegro-dvt media: allegro: fix potential null dereference on header 2020-08-06 11:28:04 +02:00
atomisp staging: media: atomisp: Convert to GPIO descriptors 2020-08-28 12:21:46 +02:00
hantro hantro: h264: Refuse to decode unsupported bitstream 2020-07-19 13:37:49 +02:00
imx staging/media: Remove unneeded geometry restrictions from i.MX CSI driver 2020-07-19 13:39:45 +02:00
ipu3 media updates for v5.8-rc1 2020-06-03 20:59:38 -07:00
meson/vdec media: meson: vdec: enable mcrcc for VP9 2020-05-05 17:09:37 +02:00
omap4iss media: Kconfig files: use select for V4L2 subdevs and MC 2020-04-14 10:29:05 +02:00
phy-rockchip-dphy-rx0 media: dt-bindings: phy: phy-rockchip-dphy-rx0: move rockchip dphy rx0 bindings out of staging 2020-05-20 15:22:27 +02:00
rkisp1 media: staging: rkisp1: set pads array of the resizer to size 2 2020-07-19 14:06:09 +02:00
rkvdec rkvdec: h264: Refuse to decode unsupported bitstream 2020-07-19 13:26:25 +02:00
sunxi media: cedrus: Implement runtime PM 2020-06-11 19:19:27 +02:00
tegra-vde staging: tegra-vde: fix common struct sg_table related issues 2020-09-05 16:58:27 +02:00
tegra-video staging: tegra-video: fix V4L2 dependency 2020-05-28 13:00:43 +02:00
usbvision media: staging: media: usbvision: usbvision-core Correct spelling 2020-05-05 17:23:36 +02:00
Kconfig media: staging/media/soc_camera: remove this driver 2020-07-04 12:19:41 +02:00
Makefile media: staging/media/soc_camera: remove this driver 2020-07-04 12:19:41 +02:00