Skip to contentSkip to conversation

drm/amdgpu: use adev_to_drm to get drm_device

PATCH In review Guchun Chen 5 participants 8 messages Jun 9, 2021 – Jun 10, 2021

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

PATCH 1/1 drm/amdgpu: use adev_to_drm to get drm_device

Fixes:
9faf262c32d3 drm/amdgpu: Add DMA mapping of GTT BOs 090f3a60d7e8 drm/amdgpu: Use delayed work to collect RAS error counters

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
index 016815b7a773..fb6bcc386de1 100644
@@ -639,7 +639,7 @@ kfd_mem_attach_dmabuf(struct amdgpu_device *adev, struct kgd_mem *mem,
 		}
 	}
 
-	gobj = amdgpu_gem_prime_import(&adev->ddev, mem->dmabuf);
+	gobj = amdgpu_gem_prime_import(adev_to_drm(adev), mem->dmabuf);
 	if (IS_ERR(gobj))
 		return PTR_ERR(gobj);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
index ec936cde2726..bfbcb9ff2453 100644
@@ -2122,7 +2122,7 @@ static void amdgpu_ras_counte_dw(struct work_struct *work)
 	struct amdgpu_ras *con = container_of(work, struct amdgpu_ras,
 					      ras_counte_delay_work.work);
 	struct amdgpu_device *adev = con->adev;
-	struct drm_device *dev = &adev->ddev;
+	struct drm_device *dev = adev_to_drm(adev->ddev);
 	unsigned long ce_count, ue_count;
 	int res;
 
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
maintainer
#1 lore raw

Am 2021-06-09 um 5:23 a.m. schrieb Guchun Chen:

Quoted 3 lines

Fixes:
9faf262c32d3 drm/amdgpu: Add DMA mapping of GTT BOs 090f3a60d7e8 drm/amdgpu: Use delayed work to collect RAS error counters

A Fixes tag implies that something was broken. However, the implementation of adev_to_drm does the exact same thing. I don't see the point of this patch. It doesn't fix any problem, and IMHO doesn't make the code more readable.

Regards,
  Felix

Quoted 25 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
index 016815b7a773..fb6bcc386de1 100644
@@ -639,7 +639,7 @@ kfd_mem_attach_dmabuf(struct amdgpu_device *adev, struct kgd_mem *mem,
 		}
 	}
 
-	gobj = amdgpu_gem_prime_import(&adev->ddev, mem->dmabuf);
+	gobj = amdgpu_gem_prime_import(adev_to_drm(adev), mem->dmabuf);
 	if (IS_ERR(gobj))
 		return PTR_ERR(gobj);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
index ec936cde2726..bfbcb9ff2453 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_counte_dw(struct work_struct *work) · line 2128

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
@@ -2122,7 +2122,7 @@ static void amdgpu_ras_counte_dw(struct work_struct *work)
 	struct amdgpu_ras *con = container_of(work, struct amdgpu_ras,
 					      ras_counte_delay_work.work);
 	struct amdgpu_device *adev = con->adev;
-	struct drm_device *dev = &adev->ddev;
+	struct drm_device *dev = adev_to_drm(adev->ddev);
 	unsigned long ce_count, ue_count;
 	int res;
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#2 lore raw
Quoted 8 lines · Felix Kuehling

Am 2021-06-09 um 5:23 a.m. schrieb Guchun Chen:

Quoted 3 lines

Fixes:
9faf262c32d3 drm/amdgpu: Add DMA mapping of GTT BOs 090f3a60d7e8 drm/amdgpu: Use delayed work to collect RAS error counters

A Fixes tag implies that something was broken. However, the implementation of adev_to_drm does the exact same thing. I don't see the point of this patch. It doesn't fix any problem, and IMHO doesn't make the code more readable.

We added this due to some changes in DRM:

8aba21b75136c3 drm/amdgpu: Embed drm_device into amdgpu_device (v3) 4a580877bdcb83 drm/amdgpu: Get DRM dev from adev by inline-f

It's good to use this inline function, to accommodate more flexible DRM.

Regards,
Luben

Quoted 24 lines

Regards,
  Felix

Quoted 19 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
index 016815b7a773..fb6bcc386de1 100644
@@ -639,7 +639,7 @@ kfd_mem_attach_dmabuf(struct amdgpu_device *adev, struct kgd_mem *mem,
 		}
 	}
 
-	gobj = amdgpu_gem_prime_import(&adev->ddev, mem->dmabuf);
+	gobj = amdgpu_gem_prime_import(adev_to_drm(adev), mem->dmabuf);
 	if (IS_ERR(gobj))
 		return PTR_ERR(gobj);
 
Quoted 13 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_counte_dw(struct work_struct *work) · line 2128

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
index ec936cde2726..bfbcb9ff2453 100644
@@ -2122,7 +2122,7 @@ static void amdgpu_ras_counte_dw(struct work_struct *work)
 	struct amdgpu_ras *con = container_of(work, struct amdgpu_ras,
 					      ras_counte_delay_work.work);
 	struct amdgpu_device *adev = con->adev;
-	struct drm_device *dev = &adev->ddev;
+	struct drm_device *dev = adev_to_drm(adev->ddev);
 	unsigned long ce_count, ue_count;
 	int res;
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

maintainer
#3 lore raw

Am 2021-06-09 um 11:20 a.m. schrieb Luben Tuikov:

Quoted 9 lines · Felix Kuehling
Quoted 8 lines

Am 2021-06-09 um 5:23 a.m. schrieb Guchun Chen:

Quoted 3 lines

Fixes:
9faf262c32d3 drm/amdgpu: Add DMA mapping of GTT BOs 090f3a60d7e8 drm/amdgpu: Use delayed work to collect RAS error counters

A Fixes tag implies that something was broken. However, the implementation of adev_to_drm does the exact same thing. I don't see the point of this patch. It doesn't fix any problem, and IMHO doesn't make the code more readable.

Quoted 6 lines

We added this due to some changes in DRM:

8aba21b75136c3 drm/amdgpu: Embed drm_device into amdgpu_device (v3) 4a580877bdcb83 drm/amdgpu: Get DRM dev from adev by inline-f

It's good to use this inline function, to accommodate more flexible DRM.

Thanks for the explanation. I found your changes as well and it makes sense now, especially for the DKMS branch. Unfortunately that's not a justification we can use for upstream.

Regards,
  Felix

Quoted 27 lines

Regards,
Luben

Quoted 23 lines

Regards,
  Felix

Quoted 19 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
index 016815b7a773..fb6bcc386de1 100644
@@ -639,7 +639,7 @@ kfd_mem_attach_dmabuf(struct amdgpu_device *adev, struct kgd_mem *mem,
 		}
 	}
 
-	gobj = amdgpu_gem_prime_import(&adev->ddev, mem->dmabuf);
+	gobj = amdgpu_gem_prime_import(adev_to_drm(adev), mem->dmabuf);
 	if (IS_ERR(gobj))
 		return PTR_ERR(gobj);
 
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
index ec936cde2726..bfbcb9ff2453 100644
@@ -2122,7 +2122,7 @@ static void amdgpu_ras_counte_dw(struct work_struct *work)
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_counte_dw(struct work_struct *work) · line 2128

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
 	struct amdgpu_ras *con = container_of(work, struct amdgpu_ras,
 					      ras_counte_delay_work.work);
 	struct amdgpu_device *adev = con->adev;
-	struct drm_device *dev = &adev->ddev;
+	struct drm_device *dev = adev_to_drm(adev->ddev);
 	unsigned long ce_count, ue_count;
 	int res;
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#4 lore raw

[Public]

We already use the macro everywhere else upstream, so this just makes it consistent.

Alex

________________________________
From: amd-gfx <[email protected]> on behalf of Felix Kuehling <[email protected]>
Sent: Wednesday, June 9, 2021 11:32 AM
To: Tuikov, Luben <[email protected]>; Chen, Guchun <[email protected]>; [email protected] <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: use adev_to_drm to get drm_device

Am 2021-06-09 um 11:20 a.m. schrieb Luben Tuikov:

Quoted 9 lines · Felix Kuehling
Quoted 8 lines

Am 2021-06-09 um 5:23 a.m. schrieb Guchun Chen:

Quoted 3 lines

Fixes:
9faf262c32d3 drm/amdgpu: Add DMA mapping of GTT BOs 090f3a60d7e8 drm/amdgpu: Use delayed work to collect RAS error counters

A Fixes tag implies that something was broken. However, the implementation of adev_to_drm does the exact same thing. I don't see the point of this patch. It doesn't fix any problem, and IMHO doesn't make the code more readable.

Quoted 6 lines

We added this due to some changes in DRM:

8aba21b75136c3 drm/amdgpu: Embed drm_device into amdgpu_device (v3) 4a580877bdcb83 drm/amdgpu: Get DRM dev from adev by inline-f

It's good to use this inline function, to accommodate more flexible DRM.

Thanks for the explanation. I found your changes as well and it makes sense now, especially for the DKMS branch. Unfortunately that's not a justification we can use for upstream.

Regards,
Felix

Quoted 27 lines

Regards,
Luben

Quoted 23 lines

Regards,
Felix

Quoted 19 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
index 016815b7a773..fb6bcc386de1 100644
@@ -639,7 +639,7 @@ kfd_mem_attach_dmabuf(struct amdgpu_device *adev, struct kgd_mem *mem,
             }
     }
 
-   gobj = amdgpu_gem_prime_import(&adev->ddev, mem->dmabuf);
+   gobj = amdgpu_gem_prime_import(adev_to_drm(adev), mem->dmabuf);
     if (IS_ERR(gobj))
             return PTR_ERR(gobj);
 
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
index ec936cde2726..bfbcb9ff2453 100644
@@ -2122,7 +2122,7 @@ static void amdgpu_ras_counte_dw(struct work_struct *work)
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static void amdgpu_ras_counte_dw(struct work_struct *work) · line 2128

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
     struct amdgpu_ras *con = container_of(work, struct amdgpu_ras,
                                           ras_counte_delay_work.work);
     struct amdgpu_device *adev = con->adev;
-   struct drm_device *dev = &adev->ddev;
+   struct drm_device *dev = adev_to_drm(adev->ddev);
     unsigned long ce_count, ue_count;
     int res;
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=04%7C01%7Calexander.deucher%40amd.com%7C310371950837474774fc08d92b5bc3a6%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637588495393971133%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=QMJ31mr9By5%2FAnnJ0QotXy3iNc8Bjn56oC2jeoKBVEg%3D&amp;reserved=0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by on v1 1/1
#5 lore raw
In reply to Guchun Chen
Quoted 5 lines · Guchun Chen

Fixes:
9faf262c32d3 drm/amdgpu: Add DMA mapping of GTT BOs 090f3a60d7e8 drm/amdgpu: Use delayed work to collect RAS error counters

drop the fixes lines and say something like use the adev_to_drm() macro for consistency. With that,

Quoted 35 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
index 016815b7a773..fb6bcc386de1 100644
@@ -639,7 +639,7 @@ kfd_mem_attach_dmabuf(struct amdgpu_device *adev, struct kgd_mem *mem,
                }
        }
 
-       gobj = amdgpu_gem_prime_import(&adev->ddev, mem->dmabuf);
+       gobj = amdgpu_gem_prime_import(adev_to_drm(adev), mem->dmabuf);
        if (IS_ERR(gobj))
                return PTR_ERR(gobj);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -2
index ec936cde2726..bfbcb9ff2453 100644
@@ -2122,7 +2122,7 @@ static void amdgpu_ras_counte_dw(struct work_struct *work)
        struct amdgpu_ras *con = container_of(work, struct amdgpu_ras,
                                              ras_counte_delay_work.work);
        struct amdgpu_device *adev = con->adev;
-       struct drm_device *dev = &adev->ddev;
+       struct drm_device *dev = adev_to_drm(adev->ddev);
        unsigned long ce_count, ue_count;
        int res;
 
--

2.17.1

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#6 lore raw

That's exactly what I said, but can see that 1/2 of the responses went to amd-gfx, and the other half to brahma ML.

Regards,
Luben

Quoted 41 lines · Alex Deucher
Quoted 4 lines · Guchun Chen

Fixes:
9faf262c32d3 drm/amdgpu: Add DMA mapping of GTT BOs 090f3a60d7e8 drm/amdgpu: Use delayed work to collect RAS error counters

drop the fixes lines and say something like use the adev_to_drm() macro for consistency. With that,

Quoted 32 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
index 016815b7a773..fb6bcc386de1 100644
@@ -639,7 +639,7 @@ kfd_mem_attach_dmabuf(struct amdgpu_device *adev, struct kgd_mem *mem,
                }
        }
 
-       gobj = amdgpu_gem_prime_import(&adev->ddev, mem->dmabuf);
+       gobj = amdgpu_gem_prime_import(adev_to_drm(adev), mem->dmabuf);
        if (IS_ERR(gobj))
                return PTR_ERR(gobj);
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
index ec936cde2726..bfbcb9ff2453 100644
@@ -2122,7 +2122,7 @@ static void amdgpu_ras_counte_dw(struct work_struct *work)
        struct amdgpu_ras *con = container_of(work, struct amdgpu_ras,
                                              ras_counte_delay_work.work);
        struct amdgpu_device *adev = con->adev;
-       struct drm_device *dev = &adev->ddev;
+       struct drm_device *dev = adev_to_drm(adev->ddev);
        unsigned long ce_count, ue_count;
        int res;
 
Quoted 7 lines
Quoted 7 lines

--
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=04%7C01%7Cluben.tuikov%40amd.com%7C04e4afbe1642484eb15008d92b5ca67d%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637588499214061155%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=DvbjnGu0Lafx%2FgCIejsFJgMyngl9bKIvIdLjTngQrCM%3D&amp;reserved=0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#7 lore raw

[Public]

Thanks for your kind feedback, Luben, Felix and Alex.

I will send a v2 set with your comments addressed and RB added.

Regards,
Guchun

-----Original Message-----
From: Tuikov, Luben <[email protected]>
Sent: Thursday, June 10, 2021 1:06 AM
To: Alex Deucher <[email protected]>; Chen, Guchun <[email protected]>
Cc: amd-gfx list <[email protected]>; Kuehling, Felix <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: use adev_to_drm to get drm_device

That's exactly what I said, but can see that 1/2 of the responses went to amd-gfx, and the other half to brahma ML.

Regards,
Luben

Quoted 48 lines · Alex Deucher
Quoted 5 lines · Guchun Chen

Fixes:
9faf262c32d3 drm/amdgpu: Add DMA mapping of GTT BOs 090f3a60d7e8 drm/amdgpu: Use delayed work to collect RAS error counters

drop the fixes lines and say something like use the adev_to_drm() macro for consistency. With that,

Quoted 38 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2 -1
index 016815b7a773..fb6bcc386de1 100644
@@ -639,7 +639,7 @@ kfd_mem_attach_dmabuf(struct amdgpu_device *adev, struct kgd_mem *mem,
                }
        }
 
-       gobj = amdgpu_gem_prime_import(&adev->ddev, mem->dmabuf);
+       gobj = amdgpu_gem_prime_import(adev_to_drm(adev), 
+ mem->dmabuf);
        if (IS_ERR(gobj))
                return PTR_ERR(gobj);
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -2
index ec936cde2726..bfbcb9ff2453 100644
@@ -2122,7 +2122,7 @@ static void amdgpu_ras_counte_dw(struct work_struct *work)
        struct amdgpu_ras *con = container_of(work, struct amdgpu_ras,
                                              ras_counte_delay_work.work);
        struct amdgpu_device *adev = con->adev;
-       struct drm_device *dev = &adev->ddev;
+       struct drm_device *dev = adev_to_drm(adev->ddev);
        unsigned long ce_count, ue_count;
        int res;
 
--

2.17.1

Quoted 10 lines
Quoted 10 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flis
ts.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=04%7C01%7C luben.tuikov%40amd.com%7C04e4afbe1642484eb15008d92b5ca67d%7C3dd8961fe 4884e608e11a82d994e183d%7C0%7C0%7C637588499214061155%7CUnknown%7CTWFp bGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6M n0%3D%7C1000&amp;sdata=DvbjnGu0Lafx%2FgCIejsFJgMyngl9bKIvIdLjTngQrCM% 3D&amp;reserved=0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx