drm/amdgpu:fix virtual dce bug
Subsystems (2)
PATCH 1/2 drm/amdgpu:fix virtual dce bug
this fix the issue that access memory after freed
after driver unloaded.
--- drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +3 -1
@@ -437,6 +437,8 @@ static int dce_virtual_sw_fini(void *handle)drm_kms_helper_poll_fini (adev->ddev);drm_mode_config_cleanup (adev->ddev); +/* clear crtcs pointer to avoid dce irq finish routine access freed data */ +memset (adev->mode_info.crtcs,0 ,sizeof (adev->mode_info.crtcs[0 ]) *AMDGPU_MAX_CRTCS ); adev->mode_info.mode_config_initialized = false;return 0 ; }
@@ -723,7 +725,7 @@ static void dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device *ad int crtc, enum amdgpu_interrupt_state state) { -if (crtc >= adev->mode_info.num_crtc) { +if (crtc >= adev->mode_info.num_crtc || !adev->mode_info.crtcs[crtc]) {DRM_DEBUG ("invalid crtc %d\n" , crtc);return ; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1510802063-20869-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org
PATCH 2/2 drm/amdgpu:cancel timer of virtual DCE
virtual DCE Timer structure is already released after its sw_fini(), so we need to cancel the its Timer in hw_fini() otherwise the Timer canceling is missed.
--- drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +13 -0
@@ -489,8 +489,21 @@ static int dce_virtual_hw_init(void *handle)return 0 ; } +static void dce_virtual_set_crtc_vblank_interrupt_state (struct amdgpu_device *adev, +int crtc, +enum amdgpu_interrupt_state state); +static int dce_virtual_hw_fini (void *handle) { +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +int i =0 ; + +while (i <AMDGPU_MAX_CRTCS ) { +if (adev->mode_info.crtcs[i]) +dce_virtual_set_crtc_vblank_interrupt_state (adev, i,AMDGPU_IRQ_STATE_DISABLE ); + i++; + } +return 0 ; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1510802063-20869-2-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org
RE: [PATCH 2/2] drm/amdgpu:cancel timer of virtual DCE
Quoted 25 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Monk Liu
Sent: Wednesday, November 15, 2017 10:14 PM
To: [email protected]
Cc: Liu, Monk
Subject: [PATCH 2/2] drm/amdgpu:cancel timer of virtual DCEvirtual DCE Timer structure is already released after its
sw_fini(), so we need to cancel the its Timer inhw_fini()otherwise the Timer canceling is missed.Change-Id I03d6ca7aa07591d287da379ef4fe008f06edaff6Signed-off-by Monk Liu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/gpu/drm/amd/amdgpu/dce_virtual.c +0
-0
drivers/gpu/drm/amd/amdgpu/dce_virtual.c static int dce_virtual_hw_init(void *handle) · line 497
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +4
-0@@ -489,8 +489,21 @@ static int dce_virtual_hw_init(void *handle)return 0 ; } +static void dce_virtual_set_crtc_vblank_interrupt_state (struct amdgpu_device *adev, +int crtc, +enum amdgpu_interrupt_state state); +
Please put the forward declaration at the top of the file.
drivers/gpu/drm/amd/amdgpu/dce_virtual.c static int dce_virtual_hw_init(void *handle) · line 505
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +8
-0static int dce_virtual_hw_fini (void *handle) { +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +int i =0 ; + +while (i <AMDGPU_MAX_CRTCS ) { +if (adev->mode_info.crtcs[i]) +dce_virtual_set_crtc_vblank_interrupt_state (adev, i,AMDGPU_IRQ_STATE_DISABLE ); + i++; + }
I think a for loop is clearer here. Also, why not use adev->mode_info.num_crtc so we don’t loop longer than we have to?
Alex
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +1
-0+return 0;
}--
2.7.4_______________________________________________
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
A message that is not in the archive (sent off-list or not yet received): BN6PR12MB165204AC0F92A06F56BDC6ACF72E0-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
RE: [PATCH 2/2] drm/amdgpu:cancel timer of virtual DCE
Good idea
-----Original Message-----
From: Deucher, Alexander
Sent: 2017年11月16日 12:14
To: Liu, Monk <[email protected]>; [email protected]
Cc: Liu, Monk <[email protected]>
Subject: RE: [PATCH 2/2] drm/amdgpu:cancel timer of virtual DCE
Quoted 24 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Monk Liu
Sent: Wednesday, November 15, 2017 10:14 PM
To: [email protected]
Cc: Liu, Monk
Subject: [PATCH 2/2] drm/amdgpu:cancel timer of virtual DCEvirtual DCE Timer structure is already released after its
sw_fini(), so we need to cancel the its Timer inhw_fini()otherwise the Timer canceling is missed.Change-Id I03d6ca7aa07591d287da379ef4fe008f06edaff6Signed-off-by Monk Liu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/gpu/drm/amd/amdgpu/dce_virtual.c +0
-0
drivers/gpu/drm/amd/amdgpu/dce_virtual.c static int dce_virtual_hw_init(void *handle) · line 497
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +4
-0@@ -489,8 +489,21 @@ static int dce_virtual_hw_init(void *handle)return 0 ; } +static void dce_virtual_set_crtc_vblank_interrupt_state (struct amdgpu_device *adev, +int crtc, +enum amdgpu_interrupt_state state); +
Please put the forward declaration at the top of the file.
drivers/gpu/drm/amd/amdgpu/dce_virtual.c static int dce_virtual_hw_init(void *handle) · line 505
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +8
-0static int dce_virtual_hw_fini (void *handle) { +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +int i =0 ; + +while (i <AMDGPU_MAX_CRTCS ) { +if (adev->mode_info.crtcs[i]) +dce_virtual_set_crtc_vblank_interrupt_state (adev, i,AMDGPU_IRQ_STATE_DISABLE ); + i++; + }
I think a for loop is clearer here. Also, why not use adev->mode_info.num_crtc so we don’t loop longer than we have to?
Alex
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +1
-0+return 0 ;}
--
2.7.4_______________________________________________
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
Quoted 2 lines · Monk Liu
this fix the issue that access memory after freed
after driver unloaded.
can you please change the patch subject and commit message to something more descriptive?
Jan
Quoted 21 lines
Change-Id I64e2488c18f5dc044b57c74567785da21fc028daSigned-off-by Monk Liu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/dce_virtual.c +2
-0@@ -437,6 +437,8 @@ static int dce_virtual_sw_fini(void *handle)drm_kms_helper_poll_fini (adev->ddev);drm_mode_config_cleanup (adev->ddev); +/* clear crtcs pointer to avoid dce irq finish routine access freed data */ +memset (adev->mode_info.crtcs,0 ,sizeof (adev->mode_info.crtcs[0 ]) *AMDGPU_MAX_CRTCS ); adev->mode_info.mode_config_initialized = false;return 0 ; }
drivers/gpu/drm/amd/amdgpu/dce_virtual.c static void dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device *ad · line 731
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +1
-1@@ -723,7 +725,7 @@ static void dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device *ad int crtc, enum amdgpu_interrupt_state state) { -if (crtc >= adev->mode_info.num_crtc) { +if (crtc >= adev->mode_info.num_crtc || !adev->mode_info.crtcs[crtc]) {DRM_DEBUG ("invalid crtc %d\n" , crtc);return ; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1510850414.3218.161.camel-kgbqMDwikbSVc3sceRu5cw@public.gmane.org
I think it's already clear enough
-----Original Message-----
From: Jan Vesely [mailto:[email protected]] On Behalf Of Jan Vesely
Sent: 2017年11月17日 0:40
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH 1/2] drm/amdgpu:fix virtual dce bug
Quoted 2 lines · Monk Liu
this fix the issue that access memory after freed after driver unloaded.
can you please change the patch subject and commit message to something more descriptive?
Jan
Quoted 23 lines
Change-Id I64e2488c18f5dc044b57c74567785da21fc028daSigned-off-by Monk Liu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/dce_virtual.c +3
-0@@ -437,6 +437,8 @@ static int dce_virtual_sw_fini(void *handle)drm_kms_helper_poll_fini (adev->ddev);drm_mode_config_cleanup (adev->ddev); +/* clear crtcs pointer to avoid dce irq finish routine access freed data */ +memset (adev->mode_info.crtcs,0 ,sizeof (adev->mode_info.crtcs[0 ]) * +AMDGPU_MAX_CRTCS ); adev->mode_info.mode_config_initialized = false;return 0 ; }
drivers/gpu/drm/amd/amdgpu/dce_virtual.c static void dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device *ad · line 731
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +2
-1@@ -723,7 +725,7 @@ static void dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device *ad int crtc, enum amdgpu_interrupt_state state) { -if (crtc >= adev->mode_info.num_crtc) { +if (crtc >= adev->mode_info.num_crtc || +!adev->mode_info.crtcs[crtc]) {DRM_DEBUG ("invalid crtc %d\n" , crtc);return ; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): BLUPR12MB04498F5AE2FF155F75D61BF3842F0-7LeqcoF/[email protected]
Quoted 1 line · Monk
I think it's already clear enough
nice. what a friendly response. good job!
"fix a bug" is definitely not descriptive of the change, and the commit message does not even parse as a sentence.
Jan
Quoted 46 lines
-----Original Message-----
From: Jan Vesely [mailto:jv356-nChP9VK/[email protected]] On Behalf Of Jan Vesely
Sent: 2017年11月17日 0:40
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH 1/2] drm/amdgpu:fix virtual dce bugQuoted 2 lines · Monk Liu
this fix the issue that access memory after freed after driver unloaded.
can you please change the patch subject and commit message to something more descriptive?
Jan
Quoted 31 lines
Change-Id I64e2488c18f5dc044b57c74567785da21fc028daSigned-off-by Monk Liu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/dce_virtual.c +5
-1@@ -437,6 +437,8 @@ static int dce_virtual_sw_fini(void *handle)drm_kms_helper_poll_fini (adev->ddev);drm_mode_config_cleanup (adev->ddev); +/* clear crtcs pointer to avoid dce irq finish routine access freed data */ +memset (adev->mode_info.crtcs,0 ,sizeof (adev->mode_info.crtcs[0 ]) * +AMDGPU_MAX_CRTCS ); adev->mode_info.mode_config_initialized = false;return 0 ; }@@ -723,7 +725,7 @@ static void dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device *ad int crtc, enum amdgpu_interrupt_state state) { -if (crtc >= adev->mode_info.num_crtc) { +if (crtc >= adev->mode_info.num_crtc || +!adev->mode_info.crtcs[crtc]) {DRM_DEBUG ("invalid crtc %d\n" , crtc);return ; }
Signature · 1 line
Jan Vesely <[email protected]>
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx