drm/tegra: Avoid struct drm_gem_object.import_attach
cover drm/tegra: Avoid struct drm_gem_object.import_attach
Avoid the use of struct drm_gem_object.import_attach to get the object's dma-buf or test for an imported buffer. The import_attach field in struct drm_gem_object is an artifact of the import process, but should not be used otherwise.
The helper drm_gem_is_imported() tests if a GEM object's buffer has been imported into the driver. The corresponding dma-buf is referenced by the object itself. Both cases avoid import_attach.
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
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. The helper tests the dma_buf itself while import_attach is just an artifact of the import. Prepares to make import_attach optional.
--- drivers/gpu/drm/tegra/gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tegra/gem.c +1 -1
@@ -524,7 +524,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
PATCH 2/2 drm/tegra: Use dma_buf from GEM object instance
In reply to Thomas ZimmermannAvoid 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 optional.
--- drivers/gpu/drm/tegra/gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tegra/gem.c +1 -1
@@ -527,7 +527,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