From: Maarten Lankhorst Date: Tue, 24 Nov 2020 11:57:07 +0000 (+0100) Subject: dma-buf/dma-resv: Respect num_fences when initializing the shared fence list. X-Git-Tag: rel_imx_5.10.35_2.0.0-somdevices.0~491^2~27 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=0c500d6a5c7a1e363652781e4dd03b7ec37f3c04;p=linux.git dma-buf/dma-resv: Respect num_fences when initializing the shared fence list. commit bf8975837dac156c33a4d15d46602700998cb6dd upstream. We hardcode the maximum number of shared fences to 4, instead of respecting num_fences. Use a minimum of 4, but more if num_fences is higher. This seems to have been an oversight when first implementing the api. Fixes: 04a5faa8cbe5 ("reservation: update api and add some helpers") Cc: # v3.17+ Reported-by: Niranjana Vishwanathapura Signed-off-by: Maarten Lankhorst Reviewed-by: Thomas Hellström Link: https://patchwork.freedesktop.org/patch/msgid/20201124115707.406917-1-maarten.lankhorst@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 1c8f2581cb09..1187e5e80ede 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -200,7 +200,7 @@ int dma_resv_reserve_shared(struct dma_resv *obj, unsigned int num_fences) max = max(old->shared_count + num_fences, old->shared_max * 2); } else { - max = 4; + max = max(4ul, roundup_pow_of_two(num_fences)); } new = dma_resv_list_alloc(max);