Skip to contentSkip to conversation

drm/amdgpu: use kmemdup rather than duplicating its implementation

PATCH In review Wei Yongjun 5 participants 6 messages Jul 28, 2016 – Aug 2, 2016

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

PATCH 1/1 drm/amdgpu: use kmemdup rather than duplicating its implementation

Use kmemdup rather than duplicating its implementation.

Generated by: scripts/coccinelle/api/memdup.cocci

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +1 -3
index a46a64c..b779b5f 100644
@@ -296,12 +296,10 @@ int amdgpu_uvd_suspend(struct amdgpu_device *adev)
 	size = amdgpu_bo_size(adev->uvd.vcpu_bo);
 	ptr = adev->uvd.cpu_addr;
 
-	adev->uvd.saved_bo = kmalloc(size, GFP_KERNEL);
+	adev->uvd.saved_bo = kmemdup(ptr, size, GFP_KERNEL);
 	if (!adev->uvd.saved_bo)
 		return -ENOMEM;
 
-	memcpy(adev->uvd.saved_bo, ptr, size);
-
 	return 0;
 }
 
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Wei Yongjun

Use kmemdup rather than duplicating its implementation.

Generated by: scripts/coccinelle/api/memdup.cocci

Thanks for the patch. I'll apply this to -misc once the merge window is closed.

Quoted 25 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +1 -3
index a46a64c..b779b5f 100644
@@ -296,12 +296,10 @@ int amdgpu_uvd_suspend(struct amdgpu_device *adev)
        size = amdgpu_bo_size(adev->uvd.vcpu_bo);
        ptr = adev->uvd.cpu_addr;
 
-       adev->uvd.saved_bo = kmalloc(size, GFP_KERNEL);
+       adev->uvd.saved_bo = kmemdup(ptr, size, GFP_KERNEL);
        if (!adev->uvd.saved_bo)
                return -ENOMEM;
 
-       memcpy(adev->uvd.saved_bo, ptr, size);
-
        return 0;
 }
 
#3 lore raw
In reply to Deucher, Alexander
Quoted 15 lines · Alexander
Quoted 15 lines

-----Original Message-----
From: Sean Paul [mailto:[email protected]]
Sent: Friday, July 29, 2016 3:35 PM
To: Wei Yongjun
Cc: Deucher, Alexander; Koenig, Christian; Dave Airlie; Jiang, Sonny; Liu, Leo; Nath, Arindam; Zhou, David(ChunMing); Zhou, Jammy; Liu, Monk; dri-devel; Linux Kernel Mailing List
Subject: Re: [PATCH -next] drm/amdgpu: use kmemdup rather than duplicating its implementation

Quoted 4 lines · Wei Yongjun

Use kmemdup rather than duplicating its implementation.

Generated by: scripts/coccinelle/api/memdup.cocci

Quoted 9 lines
Quoted 6 lines
Quoted 1 line

Thanks for the patch. I'll apply this to -misc once the merge window is closed.

Unless you've already applied this to the misc tree, I'd prefer to take it via the amdgpu tree.

Nope, it's all yours.

Sean

Quoted 31 lines

Alex

Quoted 29 lines

Review

Quoted 7 lines

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c

drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c int amdgpu_uvd_suspend(struct amdgpu_device

Quoted 4 lines

index a46a64c..b779b5f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +0 -0
@@ -296,12 +296,10 @@ int amdgpu_uvd_suspend(struct amdgpu_device

*adev)

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +1 -3
        size = amdgpu_bo_size(adev->uvd.vcpu_bo);
        ptr = adev->uvd.cpu_addr;
 
-       adev->uvd.saved_bo = kmalloc(size, GFP_KERNEL);
+       adev->uvd.saved_bo = kmemdup(ptr, size, GFP_KERNEL);
        if (!adev->uvd.saved_bo)
                return -ENOMEM;
 
-       memcpy(adev->uvd.saved_bo, ptr, size);
-
        return 0;
 }
 
#2 lore raw
In reply to Sean Paul
Quoted 13 lines

-----Original Message-----
From: Sean Paul [mailto:[email protected]]
Sent: Friday, July 29, 2016 3:35 PM
To: Wei Yongjun
Cc: Deucher, Alexander; Koenig, Christian; Dave Airlie; Jiang, Sonny; Liu, Leo; Nath, Arindam; Zhou, David(ChunMing); Zhou, Jammy; Liu, Monk; dri-devel; Linux Kernel Mailing List
Subject: Re: [PATCH -next] drm/amdgpu: use kmemdup rather than duplicating its implementation

Quoted 2 lines · Wei Yongjun

Use kmemdup rather than duplicating its implementation.

Quoted 8 lines
Quoted 3 lines

Generated by: scripts/coccinelle/api/memdup.cocci

Thanks for the patch. I'll apply this to -misc once the merge window is closed.

Unless you've already applied this to the misc tree, I'd prefer to take it via the amdgpu tree.

Alex

Quoted 6 lines
Quoted 6 lines

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
Quoted 23 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c

drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c int amdgpu_uvd_suspend(struct amdgpu_device

Quoted 4 lines

index a46a64c..b779b5f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +0 -0
@@ -296,12 +296,10 @@ int amdgpu_uvd_suspend(struct amdgpu_device

*adev)

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +1 -3
        size = amdgpu_bo_size(adev->uvd.vcpu_bo);
        ptr = adev->uvd.cpu_addr;
 
-       adev->uvd.saved_bo = kmalloc(size, GFP_KERNEL);
+       adev->uvd.saved_bo = kmemdup(ptr, size, GFP_KERNEL);
        if (!adev->uvd.saved_bo)
                return -ENOMEM;
 
-       memcpy(adev->uvd.saved_bo, ptr, size);
-
        return 0;
 }
 

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

#4 lore raw
Quoted 15 lines · Alexander
Quoted 15 lines

-----Original Message-----
From: Sean Paul [mailto:[email protected]]
Sent: Friday, July 29, 2016 3:35 PM
To: Wei Yongjun
Cc: Deucher, Alexander; Koenig, Christian; Dave Airlie; Jiang, Sonny; Liu, Leo; Nath, Arindam; Zhou, David(ChunMing); Zhou, Jammy; Liu, Monk; dri-devel; Linux Kernel Mailing List
Subject: Re: [PATCH -next] drm/amdgpu: use kmemdup rather than duplicating its implementation

Quoted 4 lines · Wei Yongjun

Use kmemdup rather than duplicating its implementation.

Generated by: scripts/coccinelle/api/memdup.cocci

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Thanks for the patch. I'll apply this to -misc once the merge window is closed.

Unless you've already applied this to the misc tree, I'd prefer to take it via the amdgpu tree.

I recall Christian NAKing an almost identical patch some time ago. Something about needing memcpy_fromio()?

Yup, it's here: https://lkml.org/lkml/2016/5/19/235

Cheers,
Nicolai

Quoted 32 lines

Alex

Quoted 6 lines
Quoted 6 lines

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
Quoted 23 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c

drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c int amdgpu_uvd_suspend(struct amdgpu_device

Quoted 4 lines

index a46a64c..b779b5f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +0 -0
@@ -296,12 +296,10 @@ int amdgpu_uvd_suspend(struct amdgpu_device

*adev)

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +1 -3
        size = amdgpu_bo_size(adev->uvd.vcpu_bo);
        ptr = adev->uvd.cpu_addr;
 
-       adev->uvd.saved_bo = kmalloc(size, GFP_KERNEL);
+       adev->uvd.saved_bo = kmemdup(ptr, size, GFP_KERNEL);
        if (!adev->uvd.saved_bo)
                return -ENOMEM;
 
-       memcpy(adev->uvd.saved_bo, ptr, size);
-
        return 0;
 }
 
Quoted 5 lines

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

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

#5 lore raw

Am 01.08.2016 um 14:16 schrieb Nicolai Hähnle:

Quoted 21 lines · Alexander
Quoted 20 lines
Quoted 20 lines

-----Original Message-----
From: Sean Paul [mailto:[email protected]]
Sent: Friday, July 29, 2016 3:35 PM
To: Wei Yongjun
Cc: Deucher, Alexander; Koenig, Christian; Dave Airlie; Jiang, Sonny; Liu, Leo; Nath, Arindam; Zhou, David(ChunMing); Zhou, Jammy; Liu, Monk; dri-devel; Linux Kernel Mailing List
Subject: Re: [PATCH -next] drm/amdgpu: use kmemdup rather than duplicating its implementation

Quoted 5 lines · Wei Yongjun

Use kmemdup rather than duplicating its implementation.

Generated by: scripts/coccinelle/api/memdup.cocci

Thanks for the patch. I'll apply this to -misc once the merge window is closed.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Unless you've already applied this to the misc tree, I'd prefer to take it via the amdgpu tree.

I recall Christian NAKing an almost identical patch some time ago. Something about needing memcpy_fromio()?

Yup, it's here: https://lkml.org/lkml/2016/5/19/235

Yes, exactly. We need memcpy_fromio() and memcpy_toio() in the suspend/resume functions instead of memcpy.

I just didn't had time to test that yet (and that was unfortunately a few month ago already).

So please drop this patch,
Christian.

Quoted 41 lines

Cheers,
Nicolai

Quoted 32 lines

Alex

Quoted 6 lines
Quoted 6 lines

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
Quoted 23 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c

drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c int amdgpu_uvd_suspend(struct amdgpu_device

Quoted 4 lines

index a46a64c..b779b5f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +0 -0
@@ -296,12 +296,10 @@ int amdgpu_uvd_suspend(struct amdgpu_device

*adev)

Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +1 -3
        size = amdgpu_bo_size(adev->uvd.vcpu_bo);
        ptr = adev->uvd.cpu_addr;
 
-       adev->uvd.saved_bo = kmalloc(size, GFP_KERNEL);
+       adev->uvd.saved_bo = kmemdup(ptr, size, GFP_KERNEL);
        if (!adev->uvd.saved_bo)
                return -ENOMEM;
 
-       memcpy(adev->uvd.saved_bo, ptr, size);
-
        return 0;
 }
 
Quoted 5 lines

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

Quoted 4 lines

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

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