Re: [PATCH] dma-buf: Fix confusion of dynamic dma-buf vs dynamic attachment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 05.03.21 um 11:51 schrieb Chris Wilson:
Commit c545781e1c55 ("dma-buf: doc polish for pin/unpin") disagrees with
the introduction of dynamism in commit: bb42df4662a4 ("dma-buf: add
dynamic DMA-buf handling v15") resulting in warning spew on
importing dma-buf. Silence the warning from the latter by only pinning
the attachment if the attachment rather than the dmabuf is to be
dynamic.

NAK, this is intentionally like this. You need to pin the DMA-buf if it is dynamic and the attachment isn't.

Otherwise the DMA-buf would be able to move even when it has an attachment which can't handle that.

We should rather fix the documentation if that is wrong on this point.

Regards,
Christian.


Fixes: bb42df4662a4 ("dma-buf: add dynamic DMA-buf handling v15")
Fixes: c545781e1c55 ("dma-buf: doc polish for pin/unpin")
Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
Cc: Daniel Vetter <daniel.vetter@xxxxxxxx>
Cc: Christian König <christian.koenig@xxxxxxx>
Cc: <stable@xxxxxxxxxxxxxxx> # v5.7+
---
  drivers/dma-buf/dma-buf.c | 9 +++++----
  1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index f264b70c383e..09f5ae458515 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -758,8 +758,8 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev,
  	    dma_buf_is_dynamic(dmabuf)) {
  		struct sg_table *sgt;
- if (dma_buf_is_dynamic(attach->dmabuf)) {
-			dma_resv_lock(attach->dmabuf->resv, NULL);
+		if (dma_buf_attachment_is_dynamic(attach)) {
+			dma_resv_lock(dmabuf->resv, NULL);
  			ret = dma_buf_pin(attach);
  			if (ret)
  				goto err_unlock;
@@ -772,8 +772,9 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev,
  			ret = PTR_ERR(sgt);
  			goto err_unpin;
  		}
-		if (dma_buf_is_dynamic(attach->dmabuf))
-			dma_resv_unlock(attach->dmabuf->resv);
+		if (dma_buf_attachment_is_dynamic(attach))
+			dma_resv_unlock(dmabuf->resv);
+
  		attach->sgt = sgt;
  		attach->dir = DMA_BIDIRECTIONAL;
  	}

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux