Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dma-buf: add a warning when drv try to reserve 0 fence slots

When dma_resv_reserve_fences() is called with num_fences=0 it usually
means that a driver or other component messed up its calculation how
many fences are needed. Warn in that situation.

When no fence are needed the function shouldn't be called in the first
place.

Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240529084322.2284-1-christian.koenig@amd.com
Reviewed-by: Matthew Auld <matthew.auld@intel.com>

authored by

Christian König and committed by
Christian König
c9402efe c4e32678

+7
+7
drivers/dma-buf/dma-resv.c
··· 186 186 187 187 dma_resv_assert_held(obj); 188 188 189 + /* Driver and component code should never call this function with 190 + * num_fences=0. If they do it usually points to bugs when calculating 191 + * the number of needed fences dynamically. 192 + */ 193 + if (WARN_ON(!num_fences)) 194 + return -EINVAL; 195 + 189 196 old = dma_resv_fences_list(obj); 190 197 if (old && old->max_fences) { 191 198 if ((old->num_fences + num_fences) <= old->max_fences)