@@ -859,8 +859,8 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev,
859
859
dma_buf_is_dynamic (dmabuf )) {
860
860
struct sg_table * sgt ;
861
861
862
+ dma_resv_lock (attach -> dmabuf -> resv , NULL );
862
863
if (dma_buf_is_dynamic (attach -> dmabuf )) {
863
- dma_resv_lock (attach -> dmabuf -> resv , NULL );
864
864
ret = dmabuf -> ops -> pin (attach );
865
865
if (ret )
866
866
goto err_unlock ;
@@ -873,8 +873,7 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev,
873
873
ret = PTR_ERR (sgt );
874
874
goto err_unpin ;
875
875
}
876
- if (dma_buf_is_dynamic (attach -> dmabuf ))
877
- dma_resv_unlock (attach -> dmabuf -> resv );
876
+ dma_resv_unlock (attach -> dmabuf -> resv );
878
877
attach -> sgt = sgt ;
879
878
attach -> dir = DMA_BIDIRECTIONAL ;
880
879
}
@@ -890,8 +889,7 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev,
890
889
dmabuf -> ops -> unpin (attach );
891
890
892
891
err_unlock :
893
- if (dma_buf_is_dynamic (attach -> dmabuf ))
894
- dma_resv_unlock (attach -> dmabuf -> resv );
892
+ dma_resv_unlock (attach -> dmabuf -> resv );
895
893
896
894
dma_buf_detach (dmabuf , attach );
897
895
return ERR_PTR (ret );
@@ -937,21 +935,19 @@ void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach)
937
935
if (WARN_ON (!dmabuf || !attach ))
938
936
return ;
939
937
938
+ dma_resv_lock (attach -> dmabuf -> resv , NULL );
939
+
940
940
if (attach -> sgt ) {
941
- if (dma_buf_is_dynamic (attach -> dmabuf ))
942
- dma_resv_lock (attach -> dmabuf -> resv , NULL );
943
941
944
942
__unmap_dma_buf (attach , attach -> sgt , attach -> dir );
945
943
946
- if (dma_buf_is_dynamic (attach -> dmabuf )) {
944
+ if (dma_buf_is_dynamic (attach -> dmabuf ))
947
945
dmabuf -> ops -> unpin (attach );
948
- dma_resv_unlock (attach -> dmabuf -> resv );
949
- }
950
946
}
951
-
952
- dma_resv_lock (dmabuf -> resv , NULL );
953
947
list_del (& attach -> node );
948
+
954
949
dma_resv_unlock (dmabuf -> resv );
950
+
955
951
if (dmabuf -> ops -> detach )
956
952
dmabuf -> ops -> detach (dmabuf , attach );
957
953
0 commit comments