public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/tegra: Test for imported buffers with drm_gem_is_imported()
  2025-04-14 13:31 [PATCH 0/2] drm/tegra: Avoid struct drm_gem_object.import_attach Thomas Zimmermann
@ 2025-04-14 13:31 ` Thomas Zimmermann
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Zimmermann @ 2025-04-14 13:31 UTC (permalink / raw)
  To: thierry.reding, mperttunen, jonathanh
  Cc: dri-devel, linux-tegra, Thomas Zimmermann

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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/tegra/gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
index ace3e5a805cf..c1695caec956 100644
--- a/drivers/gpu/drm/tegra/gem.c
+++ b/drivers/gpu/drm/tegra/gem.c
@@ -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);
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 0/2] drm/tegra: Avoid using import_attach directly
@ 2025-06-19 11:26 Thomas Zimmermann
  2025-06-19 11:27 ` [PATCH 1/2] drm/tegra: Test for imported buffers with drm_gem_is_imported() Thomas Zimmermann
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Thomas Zimmermann @ 2025-06-19 11:26 UTC (permalink / raw)
  To: thierry.reding, mperttunen, jonathanh, sumit.semwal,
	christian.koenig, simona, airlied
  Cc: dri-devel, linux-tegra, 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(-)

-- 
2.49.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] drm/tegra: Test for imported buffers with drm_gem_is_imported()
  2025-06-19 11:26 [PATCH 0/2] drm/tegra: Avoid using import_attach directly Thomas Zimmermann
@ 2025-06-19 11:27 ` Thomas Zimmermann
  2025-06-19 11:27 ` [PATCH 2/2] drm/tegra: Use dma_buf from GEM object instance Thomas Zimmermann
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Thomas Zimmermann @ 2025-06-19 11:27 UTC (permalink / raw)
  To: thierry.reding, mperttunen, jonathanh, sumit.semwal,
	christian.koenig, simona, airlied
  Cc: dri-devel, linux-tegra, Thomas Zimmermann

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

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/tegra/gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
index dbc1394f96b8..8ede07fb7a21 100644
--- a/drivers/gpu/drm/tegra/gem.c
+++ b/drivers/gpu/drm/tegra/gem.c
@@ -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);
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] drm/tegra: Use dma_buf from GEM object instance
  2025-06-19 11:26 [PATCH 0/2] drm/tegra: Avoid using import_attach directly Thomas Zimmermann
  2025-06-19 11:27 ` [PATCH 1/2] drm/tegra: Test for imported buffers with drm_gem_is_imported() Thomas Zimmermann
@ 2025-06-19 11:27 ` Thomas Zimmermann
  2025-06-23 14:59 ` [PATCH 0/2] drm/tegra: Avoid using import_attach directly Christian König
  2025-07-04 11:17 ` Thierry Reding
  3 siblings, 0 replies; 6+ messages in thread
From: Thomas Zimmermann @ 2025-06-19 11:27 UTC (permalink / raw)
  To: thierry.reding, mperttunen, jonathanh, sumit.semwal,
	christian.koenig, simona, airlied
  Cc: dri-devel, linux-tegra, 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/tegra/gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
index 8ede07fb7a21..41a285ec889f 100644
--- a/drivers/gpu/drm/tegra/gem.c
+++ b/drivers/gpu/drm/tegra/gem.c
@@ -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);
 		}
 	}
 
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] drm/tegra: Avoid using import_attach directly
  2025-06-19 11:26 [PATCH 0/2] drm/tegra: Avoid using import_attach directly Thomas Zimmermann
  2025-06-19 11:27 ` [PATCH 1/2] drm/tegra: Test for imported buffers with drm_gem_is_imported() Thomas Zimmermann
  2025-06-19 11:27 ` [PATCH 2/2] drm/tegra: Use dma_buf from GEM object instance Thomas Zimmermann
@ 2025-06-23 14:59 ` Christian König
  2025-07-04 11:17 ` Thierry Reding
  3 siblings, 0 replies; 6+ messages in thread
From: Christian König @ 2025-06-23 14:59 UTC (permalink / raw)
  To: Thomas Zimmermann, thierry.reding, mperttunen, jonathanh,
	sumit.semwal, simona, airlied
  Cc: dri-devel, linux-tegra

Reviewed-by: Christian König <christian.koenig@amd.com> for both patches.

On 19.06.25 13:26, Thomas Zimmermann wrote:
> 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(-)
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] drm/tegra: Avoid using import_attach directly
  2025-06-19 11:26 [PATCH 0/2] drm/tegra: Avoid using import_attach directly Thomas Zimmermann
                   ` (2 preceding siblings ...)
  2025-06-23 14:59 ` [PATCH 0/2] drm/tegra: Avoid using import_attach directly Christian König
@ 2025-07-04 11:17 ` Thierry Reding
  3 siblings, 0 replies; 6+ messages in thread
From: Thierry Reding @ 2025-07-04 11:17 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: mperttunen, jonathanh, sumit.semwal, christian.koenig, simona,
	airlied, dri-devel, linux-tegra

[-- Attachment #1: Type: text/plain, Size: 504 bytes --]

On Thu, Jun 19, 2025 at 01:26:59PM +0200, Thomas Zimmermann wrote:
> 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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-07-04 11:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-19 11:26 [PATCH 0/2] drm/tegra: Avoid using import_attach directly Thomas Zimmermann
2025-06-19 11:27 ` [PATCH 1/2] drm/tegra: Test for imported buffers with drm_gem_is_imported() Thomas Zimmermann
2025-06-19 11:27 ` [PATCH 2/2] drm/tegra: Use dma_buf from GEM object instance Thomas Zimmermann
2025-06-23 14:59 ` [PATCH 0/2] drm/tegra: Avoid using import_attach directly Christian König
2025-07-04 11:17 ` Thierry Reding
  -- strict thread matches above, loose matches on Subject: below --
2025-04-14 13:31 [PATCH 0/2] drm/tegra: Avoid struct drm_gem_object.import_attach Thomas Zimmermann
2025-04-14 13:31 ` [PATCH 1/2] drm/tegra: Test for imported buffers with drm_gem_is_imported() Thomas Zimmermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox