[PATCH] drm/amdgpu: Fix dead lock issue for vblank

Zhang, Hawking Hawking.Zhang at amd.com
Mon Sep 21 02:45:56 UTC 2020


[AMD Public Use]

I see. The patch is

Reviewed-by: Hawking Zhang <Hawking.Zhang at amd.com>

-----Original Message-----
From: Deng, Emily <Emily.Deng at amd.com> 
Sent: Monday, September 21, 2020 09:14
To: Zhang, Hawking <Hawking.Zhang at amd.com>; amd-gfx at lists.freedesktop.org
Subject: RE: [PATCH] drm/amdgpu: Fix dead lock issue for vblank

Hi Hawking,
    It already exit in the original file, for before patch, I move it to another place, for this V2 patch, I just use:
static int dce_virtual_pageflip(struct amdgpu_device *adev,
>+				unsigned crtc_id);


>-----Original Message-----
>From: Zhang, Hawking <Hawking.Zhang at amd.com>
>Sent: Friday, September 18, 2020 8:12 PM
>To: Deng, Emily <Emily.Deng at amd.com>; amd-gfx at lists.freedesktop.org
>Cc: Deng, Emily <Emily.Deng at amd.com>
>Subject: RE: [PATCH] drm/amdgpu: Fix dead lock issue for vblank
>
>[AMD Public Use]
>
>Hi Emily,
>
>I can't find the implementation of dce_virtual_pageflip in the patch. 
>Is it dropped by accident?
>
>Regards,
>Hawking
>
>-----Original Message-----
>From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of 
>Emily.Deng
>Sent: Friday, September 18, 2020 18:13
>To: amd-gfx at lists.freedesktop.org
>Cc: Deng, Emily <Emily.Deng at amd.com>
>Subject: [PATCH] drm/amdgpu: Fix dead lock issue for vblank
>
>Always start vblank timer, but only calls vblank function when vblank is enabled.
>
>This is used to fix the dead lock issue.
>When drm_crtc_vblank_off want to disable vblank, it first get 
>event_lock, and then call hrtimer_cancel, but hrtimer_cancel want to 
>wait timer handler function finished.
>Timer handler also want to aquire event_lock in drm_handle_vblank.
>
>Signed-off-by: Emily.Deng <Emily.Deng at amd.com>
>Change-Id: I7d3cfb1202cd030fdcdec3e7483fcc4c9fa8db70
>---
> drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 35 ++++++++++++------------
> 1 file changed, 17 insertions(+), 18 deletions(-)
>
>diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
>b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
>index cc93577dee03..469c05fd43d5 100644
>--- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
>+++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c
>@@ -47,6 +47,9 @@ static void dce_virtual_set_display_funcs(struct
>amdgpu_device *adev);  static void dce_virtual_set_irq_funcs(struct 
>amdgpu_device *adev);  static int 
>dce_virtual_connector_encoder_init(struct
>amdgpu_device *adev,
> 					      int index);
>+static int dce_virtual_pageflip(struct amdgpu_device *adev,
>+				unsigned crtc_id);
>+static enum hrtimer_restart dce_virtual_vblank_timer_handle(struct
>+hrtimer *vblank_timer);
> static void dce_virtual_set_crtc_vblank_interrupt_state(struct 
>amdgpu_device *adev,
> 							int crtc,
> 							enum
>amdgpu_interrupt_state state); @@ -247,6 +250,11 @@ static int 
>dce_virtual_crtc_init(struct amdgpu_device *adev, int index)
> 	amdgpu_crtc->vsync_timer_enabled = AMDGPU_IRQ_STATE_DISABLE;
> 	drm_crtc_helper_add(&amdgpu_crtc->base,
>&dce_virtual_crtc_helper_funcs);
>
>+	hrtimer_init(&amdgpu_crtc->vblank_timer, CLOCK_MONOTONIC,
>HRTIMER_MODE_REL);
>+	hrtimer_set_expires(&amdgpu_crtc->vblank_timer,
>DCE_VIRTUAL_VBLANK_PERIOD);
>+	amdgpu_crtc->vblank_timer.function =
>dce_virtual_vblank_timer_handle;
>+	hrtimer_start(&amdgpu_crtc->vblank_timer,
>+		      DCE_VIRTUAL_VBLANK_PERIOD, HRTIMER_MODE_REL);
> 	return 0;
> }
>
>@@ -476,7 +484,7 @@ static int dce_virtual_hw_fini(void *handle)
>
> 	for (i = 0; i<adev->mode_info.num_crtc; i++)
> 		if (adev->mode_info.crtcs[i])
>-			dce_virtual_set_crtc_vblank_interrupt_state(adev, i,
>AMDGPU_IRQ_STATE_DISABLE);
>+			hrtimer_cancel(&adev->mode_info.crtcs[i]-
>>vblank_timer);
>
> 	return 0;
> }
>@@ -698,9 +706,15 @@ static enum hrtimer_restart 
>dce_virtual_vblank_timer_handle(struct hrtimer *vbla
> 						       struct amdgpu_crtc,
>vblank_timer);
> 	struct drm_device *ddev = amdgpu_crtc->base.dev;
> 	struct amdgpu_device *adev = drm_to_adev(ddev);
>+	struct amdgpu_irq_src *source = adev-
>>irq.client[AMDGPU_IRQ_CLIENTID_LEGACY].sources
>+		[VISLANDS30_IV_SRCID_SMU_DISP_TIMER2_TRIGGER];
>+	int irq_type = amdgpu_display_crtc_idx_to_irq_type(adev,
>+						amdgpu_crtc->crtc_id);
>
>-	drm_handle_vblank(ddev, amdgpu_crtc->crtc_id);
>-	dce_virtual_pageflip(adev, amdgpu_crtc->crtc_id);
>+	if (amdgpu_irq_enabled(adev, source, irq_type)) {
>+		drm_handle_vblank(ddev, amdgpu_crtc->crtc_id);
>+		dce_virtual_pageflip(adev, amdgpu_crtc->crtc_id);
>+	}
> 	hrtimer_start(vblank_timer, DCE_VIRTUAL_VBLANK_PERIOD,
> 		      HRTIMER_MODE_REL);
>
>@@ -716,21 +730,6 @@ static void
>dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device *ad
> 		return;
> 	}
>
>-	if (state && !adev->mode_info.crtcs[crtc]->vsync_timer_enabled) {
>-		DRM_DEBUG("Enable software vsync timer\n");
>-		hrtimer_init(&adev->mode_info.crtcs[crtc]->vblank_timer,
>-			     CLOCK_MONOTONIC, HRTIMER_MODE_REL);
>-		hrtimer_set_expires(&adev->mode_info.crtcs[crtc]-
>>vblank_timer,
>-				    DCE_VIRTUAL_VBLANK_PERIOD);
>-		adev->mode_info.crtcs[crtc]->vblank_timer.function =
>-			dce_virtual_vblank_timer_handle;
>-		hrtimer_start(&adev->mode_info.crtcs[crtc]->vblank_timer,
>-			      DCE_VIRTUAL_VBLANK_PERIOD,
>HRTIMER_MODE_REL);
>-	} else if (!state && adev->mode_info.crtcs[crtc]->vsync_timer_enabled)
>{
>-		DRM_DEBUG("Disable software vsync timer\n");
>-		hrtimer_cancel(&adev->mode_info.crtcs[crtc]->vblank_timer);
>-	}
>-
> 	adev->mode_info.crtcs[crtc]->vsync_timer_enabled = state;
> 	DRM_DEBUG("[FM]set crtc %d vblank interrupt state %d\n", crtc, 
>state);  }
>--
>2.25.1
>
>_______________________________________________
>amd-gfx mailing list
>amd-gfx at lists.freedesktop.org
>https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists
>.fre
>edesktop.org%2Fmailman%2Flistinfo%2Famd-
>gfx&data=02%7C01%7Chawking.zhang%40amd.com%7Cabf1fe6040c6488
>e4c2808d85bbb8623%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0
>%7C637360208252937744&sdata=rDwqEd0k94ih31%2B%2FgfzcMW%2B
>JT1VxUp0Cvh3JvoTy76s%3D&reserved=0


More information about the amd-gfx mailing list