linux_kernel/drivers/gpu/drm/lima
Marek Szyprowski c3d9c17f48 drm: lima: 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: Qiang Yu <yuq825@gmail.com>
2020-09-10 08:18:35 +02:00
..
Kconfig drm/lima: Add optional devfreq and cooling device support 2020-03-28 16:29:46 +08:00
lima_bcast.c drm/lima: add resume/suspend callback for each ip 2020-04-24 20:51:10 +08:00
lima_bcast.h drm/lima: add resume/suspend callback for each ip 2020-04-24 20:51:10 +08:00
lima_ctx.c drm/lima: save process info for debug usage 2020-03-22 09:34:33 +08:00
lima_ctx.h drm/lima: save process info for debug usage 2020-03-22 09:34:33 +08:00
lima_devfreq.c drm/lima: add lima_devfreq_resume/suspend 2020-04-24 20:50:57 +08:00
lima_devfreq.h drm/lima: add lima_devfreq_resume/suspend 2020-04-24 20:50:57 +08:00
lima_device.c drm/lima: add pm resume/suspend ops 2020-04-24 20:51:19 +08:00
lima_device.h drm/lima: add pm resume/suspend ops 2020-04-24 20:51:19 +08:00
lima_dlbu.c drm/lima: add resume/suspend callback for each ip 2020-04-24 20:51:10 +08:00
lima_dlbu.h drm/lima: add resume/suspend callback for each ip 2020-04-24 20:51:10 +08:00
lima_drv.c drm/lima: Expose job_hang_limit module parameter 2020-07-13 13:47:41 +08:00
lima_drv.h drm/lima: Expose job_hang_limit module parameter 2020-07-13 13:47:41 +08:00
lima_dump.h drm/lima: save task info dump when task fail 2020-03-22 09:35:19 +08:00
lima_gem.c drm: lima: fix common struct sg_table related issues 2020-09-10 08:18:35 +02:00
lima_gem.h drm/lima: support heap buffer creation 2020-01-27 22:01:09 +08:00
lima_gp.c drm/lima: add resume/suspend callback for each ip 2020-04-24 20:51:10 +08:00
lima_gp.h drm/lima: add resume/suspend callback for each ip 2020-04-24 20:51:10 +08:00
lima_l2_cache.c drm/lima: add resume/suspend callback for each ip 2020-04-24 20:51:10 +08:00
lima_l2_cache.h drm/lima: add resume/suspend callback for each ip 2020-04-24 20:51:10 +08:00
lima_mmu.c drm/lima: add resume/suspend callback for each ip 2020-04-24 20:51:10 +08:00
lima_mmu.h drm/lima: add resume/suspend callback for each ip 2020-04-24 20:51:10 +08:00
lima_pmu.c drm/lima: add resume/suspend callback for each ip 2020-04-24 20:51:10 +08:00
lima_pmu.h drm/lima: add resume/suspend callback for each ip 2020-04-24 20:51:10 +08:00
lima_pp.c drm/lima: fix wait pp reset timeout 2020-07-20 08:46:06 +08:00
lima_pp.h drm/lima: add resume/suspend callback for each ip 2020-04-24 20:51:10 +08:00
lima_regs.h drm/lima: update register info 2020-01-27 22:00:12 +08:00
lima_sched.c drm/lima: Expose job_hang_limit module parameter 2020-07-13 13:47:41 +08:00
lima_sched.h drm/lima: Add optional devfreq and cooling device support 2020-03-28 16:29:46 +08:00
lima_trace.c drm/lima: add trace point for tasks 2020-03-22 09:57:21 +08:00
lima_trace.h drm/lima: add trace point for tasks 2020-03-22 09:57:21 +08:00
lima_vm.c drm: lima: fix common struct sg_table related issues 2020-09-10 08:18:35 +02:00
lima_vm.h drm/lima: check vm != NULL in lima_vm_put 2020-04-24 20:50:46 +08:00
Makefile drm/lima: Add optional devfreq and cooling device support 2020-03-28 16:29:46 +08:00