Skip to contentSkip to conversation

drm/tegra: Avoid using import_attach directly

PATCH Applied Thomas Zimmermann 3 participants 5 messages Jun 19, 2025 – Jul 4, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover drm/tegra: Avoid using import_attach directly

The field import_attach of struct drm_gem_object is often only required by PRIME code. In other places, replace its use with clearer alternatives.

Thomas Zimmermann (2):
drm/tegra: Test for imported buffers with drm_gem_is_imported() drm/tegra: Use dma_buf from GEM object instance

 drivers/gpu/drm/tegra/gem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.49.0
#1 lore raw

PATCH 1/2 drm/tegra: Test for imported buffers with drm_gem_is_imported()

Instead of testing import_attach for imported GEM buffers, invoke drm_gem_is_imported() to do the test.

---
 drivers/gpu/drm/tegra/gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tegra/gem.c +1 -1
index dbc1394f96b8..8ede07fb7a21 100644
@@ -523,7 +523,7 @@ void tegra_bo_free_object(struct drm_gem_object *gem)
 	if (tegra->domain) {
 		tegra_bo_iommu_unmap(tegra, bo);
 
-		if (gem->import_attach) {
+		if (drm_gem_is_imported(gem)) {
 			dma_buf_unmap_attachment_unlocked(gem->import_attach, bo->sgt,
 							  DMA_TO_DEVICE);
 			dma_buf_detach(gem->import_attach->dmabuf, gem->import_attach);
Signature · 1 line
2.49.0
#2 lore raw

PATCH 2/2 drm/tegra: Use dma_buf from GEM object instance

In reply to Thomas Zimmermann

Avoid dereferencing struct drm_gem_object.import_attach for the imported dma-buf. The dma_buf field in the GEM object instance refers to the same buffer. Prepares to make import_attach an implementation detail of PRIME.

---
 drivers/gpu/drm/tegra/gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tegra/gem.c +1 -1
index 8ede07fb7a21..41a285ec889f 100644
@@ -526,7 +526,7 @@ void tegra_bo_free_object(struct drm_gem_object *gem)
 		if (drm_gem_is_imported(gem)) {
 			dma_buf_unmap_attachment_unlocked(gem->import_attach, bo->sgt,
 							  DMA_TO_DEVICE);
-			dma_buf_detach(gem->import_attach->dmabuf, gem->import_attach);
+			dma_buf_detach(gem->dma_buf, gem->import_attach);
 		}
 	}
 
Signature · 1 line
2.49.0
Reviewed-by on the v1 series
#3 lore raw
In reply to Thomas Zimmermann
Quoted 11 lines · Thomas Zimmermann

The field import_attach of struct drm_gem_object is often only required by PRIME code. In other places, replace its use with clearer alternatives.

Thomas Zimmermann (2):
drm/tegra: Test for imported buffers with drm_gem_is_imported() drm/tegra: Use dma_buf from GEM object instance

 drivers/gpu/drm/tegra/gem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
#4 lore raw
In reply to Thomas Zimmermann
Quoted 10 lines · Thomas Zimmermann

The field import_attach of struct drm_gem_object is often only required by PRIME code. In other places, replace its use with clearer alternatives.

Thomas Zimmermann (2):
drm/tegra: Test for imported buffers with drm_gem_is_imported() drm/tegra: Use dma_buf from GEM object instance

 drivers/gpu/drm/tegra/gem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks.

Thierry