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

dma-buf: simplify reservation_object_get_fences_rcu a bit

We can add the exclusive fence to the list after making sure we got
a consistent state.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/322034/?series=64786&rev=1

+5 -10
+5 -10
drivers/dma-buf/reservation.c
··· 459 459 if (!dma_fence_get_rcu(shared[i])) 460 460 break; 461 461 } 462 - 463 - if (!pfence_excl && fence_excl) { 464 - shared[i] = fence_excl; 465 - fence_excl = NULL; 466 - ++i; 467 - ++shared_count; 468 - } 469 462 } 470 463 471 464 if (i != shared_count || read_seqcount_retry(&obj->seq, seq)) { ··· 473 480 rcu_read_unlock(); 474 481 } while (ret); 475 482 483 + if (pfence_excl) 484 + *pfence_excl = fence_excl; 485 + else if (fence_excl) 486 + shared[++shared_count] = fence_excl; 487 + 476 488 if (!shared_count) { 477 489 kfree(shared); 478 490 shared = NULL; ··· 485 487 486 488 *pshared_count = shared_count; 487 489 *pshared = shared; 488 - if (pfence_excl) 489 - *pfence_excl = fence_excl; 490 - 491 490 return ret; 492 491 } 493 492 EXPORT_SYMBOL_GPL(reservation_object_get_fences_rcu);