drm/prime: drm_prime_sg_to_dma_addr_array(): Return -EINVAL on error
Subsystems (2)
PATCH 1/1 drm/prime: drm_prime_sg_to_dma_addr_array(): Return -EINVAL on error
'-EINVAL' stands for invalid argument, while '-1' will accidently be interpreted as '-EPERM' by the potential upper caller. Which does not describe the error case accurately, since such an error can happens when the caller pass a smaller number than actually needed size to describe the array passed-in. Such an error is invalid argument.
Take drm/vmwgfx driver as an example, the function call trace is:
|- ttm_bo_vmap() |-- ttm_tt_populate() |--- bdev->funcs->ttm_tt_populate() |----- vmw_ttm_populate() |------ drm_prime_sg_to_dma_addr_array()
While ttm_bo_vmap() requires its callees return '-EINVAL' on invalid range, similier for other users or call path. Let's meet the requirement.
Signed-off-by Sui Jingfeng <[email protected]>
--- drivers/gpu/drm/drm_prime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_prime.c +1 -1
@@ -1055,7 +1055,7 @@ int drm_prime_sg_to_dma_addr_array(struct sg_table *sgt, dma_addr_t *addrs,for_each_sgtable_dma_page (sgt, &dma_iter,0 ) {if (WARN_ON (a - addrs >= max_entries)) -return -1 ; +return -EINVAL ; *a++ =sg_page_iter_dma_address (&dma_iter); }return 0 ;
Signature · 1 line
2.34.1