Skip to contentSkip to conversation

drm/amdgpu: For virtual_display feature, the vblank_get_counter hook is always return 0 when there's no hardware frame counter which can be used.

PATCH In review Emily Deng 2 participants 5 messages Aug 16, 2016 – Aug 17, 2016 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Emily Deng

author
#0 lore raw

PATCH 1/1 drm/amdgpu: For virtual_display feature, the vblank_get_counter hook is always return 0 when there's no hardware frame counter which can be used.

---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +4 -12
index 2ce5f90..85f14a6 100644
@@ -55,10 +55,7 @@ static void dce_virtual_vblank_wait(struct amdgpu_device *adev, int crtc)
 
 static u32 dce_virtual_vblank_get_counter(struct amdgpu_device *adev, int crtc)
 {
-	if (crtc >= adev->mode_info.num_crtc)
-		return 0;
-	else
-		return adev->ddev->vblank[crtc].count;
+	return 0;
 }
 
 static void dce_virtual_page_flip(struct amdgpu_device *adev,
@@ -70,13 +67,10 @@ static void dce_virtual_page_flip(struct amdgpu_device *adev,
 static int dce_virtual_crtc_get_scanoutpos(struct amdgpu_device *adev, int crtc,
 					u32 *vbl, u32 *position)
 {
-	if ((crtc < 0) || (crtc >= adev->mode_info.num_crtc))
-		return -EINVAL;
-
 	*vbl = 0;
 	*position = 0;
 
-	return 0;
+	return -EINVAL;
 }
 
 static bool dce_virtual_hpd_sense(struct amdgpu_device *adev,
@@ -405,6 +399,8 @@ static int dce_virtual_sw_init(void *handle)
 	if (r)
 		return r;
 
+	adev->ddev->max_vblank_count = 0;
+
 	adev->ddev->mode_config.funcs = &amdgpu_mode_funcs;
 
 	adev->ddev->mode_config.max_width = 16384;
@@ -653,7 +649,6 @@ static enum hrtimer_restart dce_virtual_vblank_timer_handle(struct hrtimer *vbla
 	struct amdgpu_mode_info *mode_info = container_of(vblank_timer, struct amdgpu_mode_info ,vblank_timer);
 	struct amdgpu_device *adev = container_of(mode_info, struct amdgpu_device ,mode_info);
 	unsigned crtc = 0;
-	adev->ddev->vblank[0].count++;
 	drm_handle_vblank(adev->ddev, crtc);
 	dce_virtual_pageflip_irq(adev, NULL, NULL);
 	hrtimer_start(vblank_timer, ktime_set(0, DCE_VIRTUAL_VBLANK_PERIOD), HRTIMER_MODE_REL);
@@ -680,8 +675,6 @@ static void dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device *ad
 		hrtimer_cancel(&adev->mode_info.vblank_timer);
 	}
 
-	if (!state || (state && !adev->mode_info.vsync_timer_enabled))
-		adev->ddev->vblank[0].count = 0;
 	adev->mode_info.vsync_timer_enabled = state;
 	DRM_DEBUG("[FM]set crtc %d vblank interrupt state %d\n", crtc, state);
 }
@@ -718,7 +711,6 @@ static int dce_virtual_crtc_irq(struct amdgpu_device *adev,
 	unsigned crtc = 0;
 	unsigned irq_type = AMDGPU_CRTC_IRQ_VBLANK1;
 
-	adev->ddev->vblank[crtc].count++;
 	dce_virtual_crtc_vblank_int_ack(adev, crtc);
 
 	if (amdgpu_irq_enabled(adev, source, irq_type)) {
Signature · 6 lines
1.9.1

_______________________________________________
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): 1471342515-2952-1-git-send-email-Emily.Deng-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Ping ...
Hi Michel,
Could you please help to review this? Thanks very much.

Best Wishes,
Emily Deng

Quoted 91 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Emily Deng
Sent: Tuesday, August 16, 2016 6:15 PM
To: [email protected]
Cc: Deng, Emily <[email protected]>
Subject: [PATCH] drm/amdgpu: For virtual_display feature, the vblank_get_counter hook is always return 0 when there's no hardware frame counter which can be used.

---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +1 -4
index 2ce5f90..85f14a6 100644
@@ -55,10 +55,7 @@ static void dce_virtual_vblank_wait(struct
 amdgpu_device *adev, int crtc)
 
 static u32 dce_virtual_vblank_get_counter(struct amdgpu_device *adev, int
 crtc)  {
-	if (crtc >= adev->mode_info.num_crtc)
-		return 0;
-	else
-		return adev->ddev->vblank[crtc].count;
+	return 0;
 }
 

static void dce_virtual_page_flip(struct amdgpu_device *adev, @@ -70,13
+67,10 @@ static void dce_virtual_page_flip(struct amdgpu_device *adev, static int dce_virtual_crtc_get_scanoutpos(struct amdgpu_device *adev, int crtc,

drivers/gpu/drm/amd/amdgpu/dce_virtual.c +4 -4
 					u32 *vbl, u32 *position)
 {
-	if ((crtc < 0) || (crtc >= adev->mode_info.num_crtc))
-		return -EINVAL;
-
 	*vbl = 0;
 	*position = 0;
 
-	return 0;
+	return -EINVAL;
 }
 
 static bool dce_virtual_hpd_sense(struct amdgpu_device *adev, @@ -405,6
+399,8 @@ static int dce_virtual_sw_init(void *handle)
 	if (r)
 		return r;
 
+	adev->ddev->max_vblank_count = 0;
+
 	adev->ddev->mode_config.funcs = &amdgpu_mode_funcs;
 
 	adev->ddev->mode_config.max_width = 16384; @@ -653,7 +649,6

@@ static enum hrtimer_restart dce_virtual_vblank_timer_handle(struct hrtimer *vbla
struct amdgpu_mode_info *mode_info = container_of(vblank_timer,
struct amdgpu_mode_info ,vblank_timer);
struct amdgpu_device *adev = container_of(mode_info, struct
amdgpu_device ,mode_info);

drivers/gpu/drm/amd/amdgpu/dce_virtual.c +0 -1
 	unsigned crtc = 0;
-	adev->ddev->vblank[0].count++;
 	drm_handle_vblank(adev->ddev, crtc);
 	dce_virtual_pageflip_irq(adev, NULL, NULL);
 	hrtimer_start(vblank_timer, ktime_set(0,

DCE_VIRTUAL_VBLANK_PERIOD), HRTIMER_MODE_REL); @@ -680,8 +675,6 @@ static void dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device *ad

drivers/gpu/drm/amd/amdgpu/dce_virtual.c +0 -2
 		hrtimer_cancel(&adev->mode_info.vblank_timer);
 	}
 
-	if (!state || (state && !adev->mode_info.vsync_timer_enabled))
-		adev->ddev->vblank[0].count = 0;
 	adev->mode_info.vsync_timer_enabled = state;
 	DRM_DEBUG("[FM]set crtc %d vblank interrupt state %d\n", crtc,

state); } @@ -718,7 +711,6 @@ static int dce_virtual_crtc_irq(struct amdgpu_device *adev,

drivers/gpu/drm/amd/amdgpu/dce_virtual.c +0 -2
 	unsigned crtc = 0;
 	unsigned irq_type = AMDGPU_CRTC_IRQ_VBLANK1;
 
-	adev->ddev->vblank[crtc].count++;
 	dce_virtual_crtc_vblank_int_ack(adev, crtc);
 
 	if (amdgpu_irq_enabled(adev, source, irq_type)) {
--

1.9.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

#3 lore raw
In reply to a message not in the archive
Quoted 1 line · Emily Deng

Please change the shortlog to be no longer than ~72 characters. Maybe something like this for the commit log:

drm/amdgpu: Hardcode virtual DCE vblank / scanout position return values

By hardcoding 0 for the vblank counter and -EINVAL for the scanout position return value, we signal to the core DRM code that there are no hardware counters we can use for these.

Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +1 -4
index 2ce5f90..85f14a6 100644
@@ -55,10 +55,7 @@ static void dce_virtual_vblank_wait(struct amdgpu_device *adev, int crtc)
 
 static u32 dce_virtual_vblank_get_counter(struct amdgpu_device *adev, int crtc)
 {
-	if (crtc >= adev->mode_info.num_crtc)
-		return 0;
-	else
-		return adev->ddev->vblank[crtc].count;
+	return 0;
 }
 
 static void dce_virtual_page_flip(struct amdgpu_device *adev,
@@ -70,13 +67,10 @@ static void dce_virtual_page_flip(struct amdgpu_device *adev,
 static int dce_virtual_crtc_get_scanoutpos(struct amdgpu_device *adev, int crtc,
 					u32 *vbl, u32 *position)

drivers/gpu/drm/amd/amdgpu/dce_virtual.c static void dce_virtual_page_flip(struct amdgpu_device *adev, · line 74

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +1 -4
 {
-	if ((crtc < 0) || (crtc >= adev->mode_info.num_crtc))
-		return -EINVAL;
-
 	*vbl = 0;
 	*position = 0;
 
-	return 0;
+	return -EINVAL;
 }

Would it be possible to add short-circuits for the virtual display case in amdgpu_get_crtc_scanoutpos and amdgpu_get_vblank_counter_kms, so they don't do any unnecessary work, and remove dce_virtual_vblank_get_counter and dce_virtual_crtc_get_scanoutpos?

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
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): 25b298cc-4d8b-ecd1-87d3-c169aa39e679-otUistvHUpPR7s880joybQ@public.gmane.org

#5 lore raw
Quoted 12 lines

-----Original Message-----
From: Michel Dänzer [mailto:[email protected]]
Sent: Wednesday, August 17, 2016 11:50 AM
To: Deng, Emily <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] drm/amdgpu: For virtual_display feature, the vblank_get_counter hook is always return 0 when there's no hardware frame counter which can be used.

Quoted 1 line · Emily Deng
Quoted 9 lines

Please change the shortlog to be no longer than ~72 characters. Maybe something like this for the commit log:

drm/amdgpu: Hardcode virtual DCE vblank / scanout position return values

By hardcoding 0 for the vblank counter and -EINVAL for the scanout position return value, we signal to the core DRM code that there are no hardware counters we can use for these.

[[EmilyD]] Thanks, will modify this.

Quoted 30 lines
Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +1 -4
index 2ce5f90..85f14a6 100644
@@ -55,10 +55,7 @@ static void dce_virtual_vblank_wait(struct
 amdgpu_device *adev, int crtc)
 
 static u32 dce_virtual_vblank_get_counter(struct amdgpu_device *adev,
 int crtc)  {
-	if (crtc >= adev->mode_info.num_crtc)
-		return 0;
-	else
-		return adev->ddev->vblank[crtc].count;
+	return 0;
 }
 
Quoted 3 lines

static void dce_virtual_page_flip(struct amdgpu_device *adev, @@
-70,13 +67,10 @@ static void dce_virtual_page_flip(struct amdgpu_device *adev, static int dce_virtual_crtc_get_scanoutpos(struct

amdgpu_device *adev, int crtc,

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +0 -3
 					u32 *vbl, u32 *position)
 {
-	if ((crtc < 0) || (crtc >= adev->mode_info.num_crtc))
-		return -EINVAL;
-
 	*vbl = 0;
 	*position = 0;
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/dce_virtual.c static void dce_virtual_page_flip(struct amdgpu_device *adev, · line 74

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +1 -1
-	return 0;
+	return -EINVAL;
 }

Would it be possible to add short-circuits for the virtual display case in amdgpu_get_crtc_scanoutpos and amdgpu_get_vblank_counter_kms, so they don't do any unnecessary work, and remove dce_virtual_vblank_get_counter and dce_virtual_crtc_get_scanoutpos?

[[EmilyD]] Hi Michel, I am inclined not to add virtual display relevant code in amdgpu other place except that must do case. And don't want to break the amdgpu code level.

Best Wishes,
Emily Deng

Quoted 4 lines

--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer

_______________________________________________
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): DM5PR12MB165933CB0CBE195F6F6417168F140-2J9CzHegvk/[email protected]

Reviewed-by
#7 lore raw
Quoted 61 lines · Emily
Quoted 12 lines

-----Original Message-----
From: Michel Dänzer [mailto:[email protected]]
Sent: Wednesday, August 17, 2016 11:50 AM
To: Deng, Emily <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] drm/amdgpu: For virtual_display feature, the vblank_get_counter hook is always return 0 when there's no hardware frame counter which can be used.

Quoted 1 line · Emily Deng
Quoted 9 lines

Please change the shortlog to be no longer than ~72 characters. Maybe something like this for the commit log:

drm/amdgpu: Hardcode virtual DCE vblank / scanout position return values

By hardcoding 0 for the vblank counter and -EINVAL for the scanout position return value, we signal to the core DRM code that there are no hardware counters we can use for these.

[[EmilyD]] Thanks, will modify this.

Quoted 30 lines
Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +1 -4
index 2ce5f90..85f14a6 100644
@@ -55,10 +55,7 @@ static void dce_virtual_vblank_wait(struct
 amdgpu_device *adev, int crtc)
 
 static u32 dce_virtual_vblank_get_counter(struct amdgpu_device *adev,
 int crtc)  {
-	if (crtc >= adev->mode_info.num_crtc)
-		return 0;
-	else
-		return adev->ddev->vblank[crtc].count;
+	return 0;
 }
 
Quoted 3 lines

static void dce_virtual_page_flip(struct amdgpu_device *adev, @@
-70,13 +67,10 @@ static void dce_virtual_page_flip(struct amdgpu_device *adev, static int dce_virtual_crtc_get_scanoutpos(struct

amdgpu_device *adev, int crtc,

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +0 -3
 					u32 *vbl, u32 *position)
 {
-	if ((crtc < 0) || (crtc >= adev->mode_info.num_crtc))
-		return -EINVAL;
-
 	*vbl = 0;
 	*position = 0;
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/dce_virtual.c static void dce_virtual_page_flip(struct amdgpu_device *adev, · line 74

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +1 -1
-	return 0;
+	return -EINVAL;
 }

Would it be possible to add short-circuits for the virtual display case in amdgpu_get_crtc_scanoutpos and amdgpu_get_vblank_counter_kms, so they don't do any unnecessary work, and remove dce_virtual_vblank_get_counter and dce_virtual_crtc_get_scanoutpos?

Quoted 2 lines

[[EmilyD]] Hi Michel, I am inclined not to add virtual display relevant code in amdgpu other place except that must do case. And don't want to break the amdgpu code level.

Okay. With the commit log fixed, the change is

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx