[RFC PATCH 5/6] iommufd: Unpin the DMA-buf while holding resv

From: Karl Mehltretter

Date: Tue Oct 20 2026 - 02:43:57 EST


iopt_release_pages() calls dma_buf_unpin() after releasing the DMA-buf
reservation lock. The unpin interface requires the reservation to be
held while it invokes the exporter callback.

Move the unpin into the reservation critical section used to release
the PAL physical list.

Signed-off-by: Karl Mehltretter <kmehltretter@xxxxxxxxx>
---
drivers/iommu/iommufd/pages.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iommu/iommufd/pages.c b/drivers/iommu/iommufd/pages.c
index 59ee68a1a..85004a936 100644
--- a/drivers/iommu/iommufd/pages.c
+++ b/drivers/iommu/iommufd/pages.c
@@ -1678,9 +1678,8 @@ void iopt_release_pages(struct kref *kref)
pages->dmabuf.exp_phys);
pages->dmabuf.exp_phys = NULL;
}
- dma_resv_unlock(dmabuf->resv);
-
dma_buf_unpin(pages->dmabuf.attach);
+ dma_resv_unlock(dmabuf->resv);

dma_buf_detach(dmabuf, pages->dmabuf.attach);
dma_buf_put(dmabuf);
--
2.39.5 (Apple Git-154)