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

dma-buf: fix unintended pin/unpin warnings

DMA-buf internal users call the pin/unpin functions without having a
dynamic attachment. Avoid the warning and backtrace in the logs.

Signed-off-by: Christian König <christian.koenig@amd.com>
Bugs: https://gitlab.freedesktop.org/drm/intel/-/issues/3481
Fixes: c545781e1c55 ("dma-buf: doc polish for pin/unpin")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
CC: stable@kernel.org
Link: https://patchwork.freedesktop.org/patch/msgid/20210517115705.2141-1-christian.koenig@amd.com

+5 -5
+5 -5
drivers/dma-buf/dma-buf.c
··· 760 760 761 761 if (dma_buf_is_dynamic(attach->dmabuf)) { 762 762 dma_resv_lock(attach->dmabuf->resv, NULL); 763 - ret = dma_buf_pin(attach); 763 + ret = dmabuf->ops->pin(attach); 764 764 if (ret) 765 765 goto err_unlock; 766 766 } ··· 786 786 787 787 err_unpin: 788 788 if (dma_buf_is_dynamic(attach->dmabuf)) 789 - dma_buf_unpin(attach); 789 + dmabuf->ops->unpin(attach); 790 790 791 791 err_unlock: 792 792 if (dma_buf_is_dynamic(attach->dmabuf)) ··· 843 843 __unmap_dma_buf(attach, attach->sgt, attach->dir); 844 844 845 845 if (dma_buf_is_dynamic(attach->dmabuf)) { 846 - dma_buf_unpin(attach); 846 + dmabuf->ops->unpin(attach); 847 847 dma_resv_unlock(attach->dmabuf->resv); 848 848 } 849 849 } ··· 956 956 if (dma_buf_is_dynamic(attach->dmabuf)) { 957 957 dma_resv_assert_held(attach->dmabuf->resv); 958 958 if (!IS_ENABLED(CONFIG_DMABUF_MOVE_NOTIFY)) { 959 - r = dma_buf_pin(attach); 959 + r = attach->dmabuf->ops->pin(attach); 960 960 if (r) 961 961 return ERR_PTR(r); 962 962 } ··· 968 968 969 969 if (IS_ERR(sg_table) && dma_buf_is_dynamic(attach->dmabuf) && 970 970 !IS_ENABLED(CONFIG_DMABUF_MOVE_NOTIFY)) 971 - dma_buf_unpin(attach); 971 + attach->dmabuf->ops->unpin(attach); 972 972 973 973 if (!IS_ERR(sg_table) && attach->dmabuf->ops->cache_sgt_mapping) { 974 974 attach->sgt = sg_table;