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

dma-buf: clarify dma_fence_add_callback documentation

That the caller doesn't need to keep a reference is rather
risky and not defensive at all.

Especially dma_buf_poll got that horrible wrong, so better
remove that sentence and also clarify that the callback
might be called in atomic or interrupt context.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210901120240.7339-3-christian.koenig@amd.com

+5 -8
+5 -8
drivers/dma-buf/dma-fence.c
··· 616 616 * @cb: the callback to register 617 617 * @func: the function to call 618 618 * 619 + * Add a software callback to the fence. The caller should keep a reference to 620 + * the fence. 621 + * 619 622 * @cb will be initialized by dma_fence_add_callback(), no initialization 620 623 * by the caller is required. Any number of callbacks can be registered 621 624 * to a fence, but a callback can only be registered to one fence at a time. 622 625 * 623 - * Note that the callback can be called from an atomic context. If 624 - * fence is already signaled, this function will return -ENOENT (and 626 + * If fence is already signaled, this function will return -ENOENT (and 625 627 * *not* call the callback). 626 628 * 627 - * Add a software callback to the fence. Same restrictions apply to 628 - * refcount as it does to dma_fence_wait(), however the caller doesn't need to 629 - * keep a refcount to fence afterward dma_fence_add_callback() has returned: 630 - * when software access is enabled, the creator of the fence is required to keep 631 - * the fence alive until after it signals with dma_fence_signal(). The callback 632 - * itself can be called from irq context. 629 + * Note that the callback can be called from an atomic context or irq context. 633 630 * 634 631 * Returns 0 in case of success, -ENOENT if the fence is already signaled 635 632 * and -EINVAL in case of error.