[PATCH v2] drm/loongson: stop to set get_vblank_timestamp for LS7A1000 CRTC

Icenowy Zheng posted 1 patch 2 weeks, 1 day ago
drivers/gpu/drm/loongson/lsdc_crtc.c | 1 -
1 file changed, 1 deletion(-)
[PATCH v2] drm/loongson: stop to set get_vblank_timestamp for LS7A1000 CRTC
Posted by Icenowy Zheng 2 weeks, 1 day ago
As there's no known hardware capability about querying vblank on the
LS7A1000 display controller, setting get_vblank_timestamp will mislead the
kernel about the support of DC-backed high precision vblank query.

Drop this function pointer in the CRTC function table for LS7A1000.

This solves a kernel warning when booting Linux 7.0-rc3 on a
Loongson-3A4000+LS7A1000 Haier Boyue G51 laptop (with injected EDID for
replicating the display timing set by the firmware).

Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
---
Changes in v2:
- Re-formatted Loongson product model numbers per request from Huacai.

 drivers/gpu/drm/loongson/lsdc_crtc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/loongson/lsdc_crtc.c b/drivers/gpu/drm/loongson/lsdc_crtc.c
index 587fbe285e9ef..b3af8e0cdb15f 100644
--- a/drivers/gpu/drm/loongson/lsdc_crtc.c
+++ b/drivers/gpu/drm/loongson/lsdc_crtc.c
@@ -721,7 +721,6 @@ static const struct drm_crtc_funcs ls7a1000_crtc_funcs = {
 	.late_register = lsdc_crtc_late_register,
 	.enable_vblank = lsdc_crtc_enable_vblank,
 	.disable_vblank = lsdc_crtc_disable_vblank,
-	.get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
 	.atomic_print_state = lsdc_crtc_atomic_print_state,
 };
 
-- 
2.52.0
Re: [PATCH v2] drm/loongson: stop to set get_vblank_timestamp for LS7A1000 CRTC
Posted by Icenowy Zheng 2 weeks, 1 day ago
在 2026-03-21六的 17:28 +0800,Icenowy Zheng写道:
> As there's no known hardware capability about querying vblank on the
> LS7A1000 display controller, setting get_vblank_timestamp will
> mislead the
> kernel about the support of DC-backed high precision vblank query.
> 
> Drop this function pointer in the CRTC function table for LS7A1000.
> 
> This solves a kernel warning when booting Linux 7.0-rc3 on a
> Loongson-3A4000+LS7A1000 Haier Boyue G51 laptop (with injected EDID
> for
> replicating the display timing set by the firmware).
> 
> Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>

Oh forgot to attach when crafting v2:

```
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
```

> ---
> Changes in v2:
> - Re-formatted Loongson product model numbers per request from
> Huacai.
> 
>  drivers/gpu/drm/loongson/lsdc_crtc.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/loongson/lsdc_crtc.c
> b/drivers/gpu/drm/loongson/lsdc_crtc.c
> index 587fbe285e9ef..b3af8e0cdb15f 100644
> --- a/drivers/gpu/drm/loongson/lsdc_crtc.c
> +++ b/drivers/gpu/drm/loongson/lsdc_crtc.c
> @@ -721,7 +721,6 @@ static const struct drm_crtc_funcs
> ls7a1000_crtc_funcs = {
>  	.late_register = lsdc_crtc_late_register,
>  	.enable_vblank = lsdc_crtc_enable_vblank,
>  	.disable_vblank = lsdc_crtc_disable_vblank,
> -	.get_vblank_timestamp =
> drm_crtc_vblank_helper_get_vblank_timestamp,
>  	.atomic_print_state = lsdc_crtc_atomic_print_state,
>  };
>  
Re: [PATCH v2] drm/loongson: stop to set get_vblank_timestamp for LS7A1000 CRTC
Posted by Thomas Zimmermann 2 weeks ago
Hi

Am 21.03.26 um 10:29 schrieb Icenowy Zheng:
> 在 2026-03-21六的 17:28 +0800,Icenowy Zheng写道:
>> As there's no known hardware capability about querying vblank on the
>> LS7A1000 display controller, setting get_vblank_timestamp will
>> mislead the
>> kernel about the support of DC-backed high precision vblank query.
>>
>> Drop this function pointer in the CRTC function table for LS7A1000.
>>
>> This solves a kernel warning when booting Linux 7.0-rc3 on a
>> Loongson-3A4000+LS7A1000 Haier Boyue G51 laptop (with injected EDID
>> for
>> replicating the display timing set by the firmware).
>>
>> Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
> Oh forgot to attach when crafting v2:
>
> ```
> Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
> ```

I just want to add that the a-b was given wrt. the correctness of the 
source-code changes.  But now it seems that the hardware does support 
the vblank timestamp, (?) so removing the callback might not be the best 
thing.

Best regards
Thomas

>
>> ---
>> Changes in v2:
>> - Re-formatted Loongson product model numbers per request from
>> Huacai.
>>
>>   drivers/gpu/drm/loongson/lsdc_crtc.c | 1 -
>>   1 file changed, 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/loongson/lsdc_crtc.c
>> b/drivers/gpu/drm/loongson/lsdc_crtc.c
>> index 587fbe285e9ef..b3af8e0cdb15f 100644
>> --- a/drivers/gpu/drm/loongson/lsdc_crtc.c
>> +++ b/drivers/gpu/drm/loongson/lsdc_crtc.c
>> @@ -721,7 +721,6 @@ static const struct drm_crtc_funcs
>> ls7a1000_crtc_funcs = {
>>   	.late_register = lsdc_crtc_late_register,
>>   	.enable_vblank = lsdc_crtc_enable_vblank,
>>   	.disable_vblank = lsdc_crtc_disable_vblank,
>> -	.get_vblank_timestamp =
>> drm_crtc_vblank_helper_get_vblank_timestamp,
>>   	.atomic_print_state = lsdc_crtc_atomic_print_state,
>>   };
>>   

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)


Re: [PATCH v2] drm/loongson: stop to set get_vblank_timestamp for LS7A1000 CRTC
Posted by Jianmin Lv 2 weeks ago

On 2026/3/21 下午5:29, Icenowy Zheng wrote:
> 在 2026-03-21六的 17:28 +0800,Icenowy Zheng写道:
>> As there's no known hardware capability about querying vblank on the
>> LS7A1000 display controller, setting get_vblank_timestamp will
>> mislead the
>> kernel about the support of DC-backed high precision vblank query.
>>
>> Drop this function pointer in the CRTC function table for LS7A1000.
>>
>> This solves a kernel warning when booting Linux 7.0-rc3 on a
>> Loongson-3A4000+LS7A1000 Haier Boyue G51 laptop (with injected EDID
>> for
>> replicating the display timing set by the firmware).
>>
The drm_crtc_vblank_helper_get_vblank_timestamp will call 
get_scanout_position hook to caculate timestamp, and the driver has 
get_scanout_position to support it (LS7A1000 has related register). So 
the get_vblank_timestamp hook is ok for LS7A1000, and we'd better look 
into the warning information.

>> Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
> 
> Oh forgot to attach when crafting v2:
> 
> ```
> Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
> ```
> 
>> ---
>> Changes in v2:
>> - Re-formatted Loongson product model numbers per request from
>> Huacai.
>>
>>   drivers/gpu/drm/loongson/lsdc_crtc.c | 1 -
>>   1 file changed, 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/loongson/lsdc_crtc.c
>> b/drivers/gpu/drm/loongson/lsdc_crtc.c
>> index 587fbe285e9ef..b3af8e0cdb15f 100644
>> --- a/drivers/gpu/drm/loongson/lsdc_crtc.c
>> +++ b/drivers/gpu/drm/loongson/lsdc_crtc.c
>> @@ -721,7 +721,6 @@ static const struct drm_crtc_funcs
>> ls7a1000_crtc_funcs = {
>>   	.late_register = lsdc_crtc_late_register,
>>   	.enable_vblank = lsdc_crtc_enable_vblank,
>>   	.disable_vblank = lsdc_crtc_disable_vblank,
>> -	.get_vblank_timestamp =
>> drm_crtc_vblank_helper_get_vblank_timestamp,
>>   	.atomic_print_state = lsdc_crtc_atomic_print_state,
>>   };
>>   

Re: [PATCH v2] drm/loongson: stop to set get_vblank_timestamp for LS7A1000 CRTC
Posted by Icenowy Zheng 1 week, 6 days ago
在 2026-03-23一的 11:40 +0800,Jianmin Lv写道:
> 
> 
> On 2026/3/21 下午5:29, Icenowy Zheng wrote:
> > 在 2026-03-21六的 17:28 +0800,Icenowy Zheng写道:
> > > As there's no known hardware capability about querying vblank on
> > > the
> > > LS7A1000 display controller, setting get_vblank_timestamp will
> > > mislead the
> > > kernel about the support of DC-backed high precision vblank
> > > query.
> > > 
> > > Drop this function pointer in the CRTC function table for
> > > LS7A1000.
> > > 
> > > This solves a kernel warning when booting Linux 7.0-rc3 on a
> > > Loongson-3A4000+LS7A1000 Haier Boyue G51 laptop (with injected
> > > EDID
> > > for
> > > replicating the display timing set by the firmware).
> > > 
> The drm_crtc_vblank_helper_get_vblank_timestamp will call 
> get_scanout_position hook to caculate timestamp, and the driver has 
> get_scanout_position to support it (LS7A1000 has related register).
> So 
> the get_vblank_timestamp hook is ok for LS7A1000, and we'd better
> look 
> into the warning information.

The warning information is copied here:
```
[    0.334960] ------------[ cut here ]------------
[    0.334960] WARNING: drivers/gpu/drm/drm_vblank.c:747 at
drm_crtc_vblank_helper_get_vblank_timestamp_internal+0x3c8/0x438,
CPU#0: kworker/0:1/11
[    0.334960] loongson 0000:00:06.1: [drm]
drm_WARN_ON_ONCE(drm_drv_uses_atomic_modeset(dev))
[    0.334960] Modules linked in:
[    0.334960] CPU: 0 UID: 0 PID: 11 Comm: kworker/0:1 Not tainted
7.0.0-rc4-3a4000-laptop-test+ #31 PREEMPT 
[    0.334960] Hardware name: Haier Boyue G51/Boyue G51, BIOS
K3L3A4000.HR10.200909.T 09/09/2020
[    0.334960] Workqueue: events drm_fb_helper_damage_work
[    0.334960] Stack : ffffffff819dec03 0000000000000000
0000000000000018 9800000100223938
[    0.334960]         9800000100223938 9800000100223a68
0000000000000000 0000000000000000
[    0.334960]         b8e8b3f2ec6b8200 98000000092bffa8
9800000100223768 0000000000000000
[    0.334960]         ffffffff81632b08 0000000000000030
ffffffff813c9530 0000000000200b20
[    0.334960]         fffffffffffffffc 0000000000000000
0000000000000000 ffffffff816c1d50
[    0.334960]         ffffffff81890000 00000000000002eb
0000000000000000 ffffffff80c1b180
[    0.334960]         9800000100ff8500 0000000000000000
9800000005c965a8 0000000000000000
[    0.334960]         ffffffff81a70000 9800000100220000
9800000100223930 0000000000000000
[    0.334960]         ffffffff802274dc 0000000000000000
0000000000000000 0000000000000000
[    0.334960]         0000000000000000 0000000000000000
ffffffff802274fc b8e8b3f2ec6b8200
[    0.334960]         ...
[    0.334960] Call Trace:
[    0.334960] [<ffffffff802274fc>] show_stack+0x64/0x158
[    0.334960] [<ffffffff8021bac4>] dump_stack_lvl+0x70/0xb0
[    0.334960] [<ffffffff8026a988>] __warn+0xa8/0x120
[    0.334960] [<ffffffff8026ab60>] warn_slowpath_fmt+0x160/0x1f8
[    0.334960] [<ffffffff80be5668>]
drm_crtc_vblank_helper_get_vblank_timestamp_internal+0x3c8/0x438
[    0.334960] [<ffffffff80be48d8>]
drm_crtc_get_last_vbltimestamp+0x68/0xb0
[    0.334960] [<ffffffff80be5e14>] drm_update_vblank_count+0xac/0x418
[    0.334960] [<ffffffff80be6270>] drm_vblank_enable+0xf0/0x288
[    0.334960] [<ffffffff80be7010>] drm_vblank_get+0xf8/0x160
[    0.334960] [<ffffffff80beb2e0>]
drm_client_modeset_wait_for_vblank+0x50/0xa0
[    0.334960] [<ffffffff80c0a144>]
drm_fb_helper_damage_work+0x8c/0x1d8
[    0.334960] [<ffffffff8028fac8>] process_one_work+0x198/0x348
[    0.334960] [<ffffffff802906c0>] worker_thread+0x238/0x390
[    0.334960] [<ffffffff8029c0d8>] kthread+0x160/0x198
[    0.334960] [<ffffffff8021fd8c>] ret_from_kernel_thread+0x14/0x1c

[    0.334960] ---[ end trace 0000000000000000 ]---
```

> 
> > > Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
> > 
> > Oh forgot to attach when crafting v2:
> > 
> > ```
> > Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
> > ```
> > 
> > > ---
> > > Changes in v2:
> > > - Re-formatted Loongson product model numbers per request from
> > > Huacai.
> > > 
> > >   drivers/gpu/drm/loongson/lsdc_crtc.c | 1 -
> > >   1 file changed, 1 deletion(-)
> > > 
> > > diff --git a/drivers/gpu/drm/loongson/lsdc_crtc.c
> > > b/drivers/gpu/drm/loongson/lsdc_crtc.c
> > > index 587fbe285e9ef..b3af8e0cdb15f 100644
> > > --- a/drivers/gpu/drm/loongson/lsdc_crtc.c
> > > +++ b/drivers/gpu/drm/loongson/lsdc_crtc.c
> > > @@ -721,7 +721,6 @@ static const struct drm_crtc_funcs
> > > ls7a1000_crtc_funcs = {
> > >   	.late_register = lsdc_crtc_late_register,
> > >   	.enable_vblank = lsdc_crtc_enable_vblank,
> > >   	.disable_vblank = lsdc_crtc_disable_vblank,
> > > -	.get_vblank_timestamp =
> > > drm_crtc_vblank_helper_get_vblank_timestamp,
> > >   	.atomic_print_state = lsdc_crtc_atomic_print_state,
> > >   };
> > >   
Re: [PATCH v2] drm/loongson: stop to set get_vblank_timestamp for LS7A1000 CRTC
Posted by Thomas Zimmermann 1 week, 6 days ago
Hi

Am 23.03.26 um 10:40 schrieb Icenowy Zheng:
> 在 2026-03-23一的 11:40 +0800,Jianmin Lv写道:
>>
>> On 2026/3/21 下午5:29, Icenowy Zheng wrote:
>>> 在 2026-03-21六的 17:28 +0800,Icenowy Zheng写道:
>>>> As there's no known hardware capability about querying vblank on
>>>> the
>>>> LS7A1000 display controller, setting get_vblank_timestamp will
>>>> mislead the
>>>> kernel about the support of DC-backed high precision vblank
>>>> query.
>>>>
>>>> Drop this function pointer in the CRTC function table for
>>>> LS7A1000.
>>>>
>>>> This solves a kernel warning when booting Linux 7.0-rc3 on a
>>>> Loongson-3A4000+LS7A1000 Haier Boyue G51 laptop (with injected
>>>> EDID
>>>> for
>>>> replicating the display timing set by the firmware).
>>>>
>> The drm_crtc_vblank_helper_get_vblank_timestamp will call
>> get_scanout_position hook to caculate timestamp, and the driver has
>> get_scanout_position to support it (LS7A1000 has related register).
>> So
>> the get_vblank_timestamp hook is ok for LS7A1000, and we'd better
>> look
>> into the warning information.
> The warning information is copied here:
> ```
> [    0.334960] ------------[ cut here ]------------
> [    0.334960] WARNING: drivers/gpu/drm/drm_vblank.c:747 at
> drm_crtc_vblank_helper_get_vblank_timestamp_internal+0x3c8/0x438,
> CPU#0: kworker/0:1/11
> [    0.334960] loongson 0000:00:06.1: [drm]
> drm_WARN_ON_ONCE(drm_drv_uses_atomic_modeset(dev))

This is what you should investigate. mode->crtc_clock seems invalid. [1]

[1] 
https://elixir.bootlin.com/linux/v6.19.9/source/drivers/gpu/drm/drm_vblank.c#L743

Best regards
Thomas

> [    0.334960] Modules linked in:
> [    0.334960] CPU: 0 UID: 0 PID: 11 Comm: kworker/0:1 Not tainted
> 7.0.0-rc4-3a4000-laptop-test+ #31 PREEMPT
> [    0.334960] Hardware name: Haier Boyue G51/Boyue G51, BIOS
> K3L3A4000.HR10.200909.T 09/09/2020
> [    0.334960] Workqueue: events drm_fb_helper_damage_work
> [    0.334960] Stack : ffffffff819dec03 0000000000000000
> 0000000000000018 9800000100223938
> [    0.334960]         9800000100223938 9800000100223a68
> 0000000000000000 0000000000000000
> [    0.334960]         b8e8b3f2ec6b8200 98000000092bffa8
> 9800000100223768 0000000000000000
> [    0.334960]         ffffffff81632b08 0000000000000030
> ffffffff813c9530 0000000000200b20
> [    0.334960]         fffffffffffffffc 0000000000000000
> 0000000000000000 ffffffff816c1d50
> [    0.334960]         ffffffff81890000 00000000000002eb
> 0000000000000000 ffffffff80c1b180
> [    0.334960]         9800000100ff8500 0000000000000000
> 9800000005c965a8 0000000000000000
> [    0.334960]         ffffffff81a70000 9800000100220000
> 9800000100223930 0000000000000000
> [    0.334960]         ffffffff802274dc 0000000000000000
> 0000000000000000 0000000000000000
> [    0.334960]         0000000000000000 0000000000000000
> ffffffff802274fc b8e8b3f2ec6b8200
> [    0.334960]         ...
> [    0.334960] Call Trace:
> [    0.334960] [<ffffffff802274fc>] show_stack+0x64/0x158
> [    0.334960] [<ffffffff8021bac4>] dump_stack_lvl+0x70/0xb0
> [    0.334960] [<ffffffff8026a988>] __warn+0xa8/0x120
> [    0.334960] [<ffffffff8026ab60>] warn_slowpath_fmt+0x160/0x1f8
> [    0.334960] [<ffffffff80be5668>]
> drm_crtc_vblank_helper_get_vblank_timestamp_internal+0x3c8/0x438
> [    0.334960] [<ffffffff80be48d8>]
> drm_crtc_get_last_vbltimestamp+0x68/0xb0
> [    0.334960] [<ffffffff80be5e14>] drm_update_vblank_count+0xac/0x418
> [    0.334960] [<ffffffff80be6270>] drm_vblank_enable+0xf0/0x288
> [    0.334960] [<ffffffff80be7010>] drm_vblank_get+0xf8/0x160
> [    0.334960] [<ffffffff80beb2e0>]
> drm_client_modeset_wait_for_vblank+0x50/0xa0
> [    0.334960] [<ffffffff80c0a144>]
> drm_fb_helper_damage_work+0x8c/0x1d8
> [    0.334960] [<ffffffff8028fac8>] process_one_work+0x198/0x348
> [    0.334960] [<ffffffff802906c0>] worker_thread+0x238/0x390
> [    0.334960] [<ffffffff8029c0d8>] kthread+0x160/0x198
> [    0.334960] [<ffffffff8021fd8c>] ret_from_kernel_thread+0x14/0x1c
>
> [    0.334960] ---[ end trace 0000000000000000 ]---
> ```
>
>>>> Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
>>> Oh forgot to attach when crafting v2:
>>>
>>> ```
>>> Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
>>> ```
>>>
>>>> ---
>>>> Changes in v2:
>>>> - Re-formatted Loongson product model numbers per request from
>>>> Huacai.
>>>>
>>>>    drivers/gpu/drm/loongson/lsdc_crtc.c | 1 -
>>>>    1 file changed, 1 deletion(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/loongson/lsdc_crtc.c
>>>> b/drivers/gpu/drm/loongson/lsdc_crtc.c
>>>> index 587fbe285e9ef..b3af8e0cdb15f 100644
>>>> --- a/drivers/gpu/drm/loongson/lsdc_crtc.c
>>>> +++ b/drivers/gpu/drm/loongson/lsdc_crtc.c
>>>> @@ -721,7 +721,6 @@ static const struct drm_crtc_funcs
>>>> ls7a1000_crtc_funcs = {
>>>>    	.late_register = lsdc_crtc_late_register,
>>>>    	.enable_vblank = lsdc_crtc_enable_vblank,
>>>>    	.disable_vblank = lsdc_crtc_disable_vblank,
>>>> -	.get_vblank_timestamp =
>>>> drm_crtc_vblank_helper_get_vblank_timestamp,
>>>>    	.atomic_print_state = lsdc_crtc_atomic_print_state,
>>>>    };
>>>>    

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)


Re: [PATCH v2] drm/loongson: stop to set get_vblank_timestamp for LS7A1000 CRTC
Posted by Icenowy Zheng 1 week, 6 days ago
在 2026-03-23一的 11:31 +0100,Thomas Zimmermann写道:
> Hi
> 
> Am 23.03.26 um 10:40 schrieb Icenowy Zheng:
> > 在 2026-03-23一的 11:40 +0800,Jianmin Lv写道:
> > > 
> > > On 2026/3/21 下午5:29, Icenowy Zheng wrote:
> > > > 在 2026-03-21六的 17:28 +0800,Icenowy Zheng写道:
> > > > > As there's no known hardware capability about querying vblank
> > > > > on
> > > > > the
> > > > > LS7A1000 display controller, setting get_vblank_timestamp
> > > > > will
> > > > > mislead the
> > > > > kernel about the support of DC-backed high precision vblank
> > > > > query.
> > > > > 
> > > > > Drop this function pointer in the CRTC function table for
> > > > > LS7A1000.
> > > > > 
> > > > > This solves a kernel warning when booting Linux 7.0-rc3 on a
> > > > > Loongson-3A4000+LS7A1000 Haier Boyue G51 laptop (with
> > > > > injected
> > > > > EDID
> > > > > for
> > > > > replicating the display timing set by the firmware).
> > > > > 
> > > The drm_crtc_vblank_helper_get_vblank_timestamp will call
> > > get_scanout_position hook to caculate timestamp, and the driver
> > > has
> > > get_scanout_position to support it (LS7A1000 has related
> > > register).
> > > So
> > > the get_vblank_timestamp hook is ok for LS7A1000, and we'd better
> > > look
> > > into the warning information.
> > The warning information is copied here:
> > ```
> > [    0.334960] ------------[ cut here ]------------
> > [    0.334960] WARNING: drivers/gpu/drm/drm_vblank.c:747 at
> > drm_crtc_vblank_helper_get_vblank_timestamp_internal+0x3c8/0x438,
> > CPU#0: kworker/0:1/11
> > [    0.334960] loongson 0000:00:06.1: [drm]
> > drm_WARN_ON_ONCE(drm_drv_uses_atomic_modeset(dev))
> 
> This is what you should investigate. mode->crtc_clock seems invalid.
> [1]
> 
> [1] 
> https://elixir.bootlin.com/linux/v6.19.9/source/drivers/gpu/drm/drm_vblank.c#L743
> 
> Best regards
> Thomas
> 
> > [    0.334960] Modules linked in:
> > [    0.334960] CPU: 0 UID: 0 PID: 11 Comm: kworker/0:1 Not tainted
> > 7.0.0-rc4-3a4000-laptop-test+ #31 PREEMPT
> > [    0.334960] Hardware name: Haier Boyue G51/Boyue G51, BIOS
> > K3L3A4000.HR10.200909.T 09/09/2020
> > [    0.334960] Workqueue: events drm_fb_helper_damage_work
> > [    0.334960] Stack : ffffffff819dec03 0000000000000000
> > 0000000000000018 9800000100223938
> > [    0.334960]         9800000100223938 9800000100223a68
> > 0000000000000000 0000000000000000
> > [    0.334960]         b8e8b3f2ec6b8200 98000000092bffa8
> > 9800000100223768 0000000000000000
> > [    0.334960]         ffffffff81632b08 0000000000000030
> > ffffffff813c9530 0000000000200b20
> > [    0.334960]         fffffffffffffffc 0000000000000000
> > 0000000000000000 ffffffff816c1d50
> > [    0.334960]         ffffffff81890000 00000000000002eb
> > 0000000000000000 ffffffff80c1b180
> > [    0.334960]         9800000100ff8500 0000000000000000
> > 9800000005c965a8 0000000000000000
> > [    0.334960]         ffffffff81a70000 9800000100220000
> > 9800000100223930 0000000000000000
> > [    0.334960]         ffffffff802274dc 0000000000000000
> > 0000000000000000 0000000000000000
> > [    0.334960]         0000000000000000 0000000000000000
> > ffffffff802274fc b8e8b3f2ec6b8200
> > [    0.334960]         ...
> > [    0.334960] Call Trace:
> > [    0.334960] [<ffffffff802274fc>] show_stack+0x64/0x158
> > [    0.334960] [<ffffffff8021bac4>] dump_stack_lvl+0x70/0xb0
> > [    0.334960] [<ffffffff8026a988>] __warn+0xa8/0x120
> > [    0.334960] [<ffffffff8026ab60>] warn_slowpath_fmt+0x160/0x1f8
> > [    0.334960] [<ffffffff80be5668>]
> > drm_crtc_vblank_helper_get_vblank_timestamp_internal+0x3c8/0x438
> > [    0.334960] [<ffffffff80be48d8>]
> > drm_crtc_get_last_vbltimestamp+0x68/0xb0
> > [    0.334960] [<ffffffff80be5e14>]
> > drm_update_vblank_count+0xac/0x418
> > [    0.334960] [<ffffffff80be6270>] drm_vblank_enable+0xf0/0x288
> > [    0.334960] [<ffffffff80be7010>] drm_vblank_get+0xf8/0x160
> > [    0.334960] [<ffffffff80beb2e0>]
> > drm_client_modeset_wait_for_vblank+0x50/0xa0

I doubt the problem here is that the function above is called with
hardcoded 0 by drm_fb_helper_fb_dirty() (being inlined into
drm_fb_helper_damage_work() by the compiler). Then on my setup it
failed because my primary output (laptop LCD) is on CRTC 1 (CRTC 0 is
external HDMI instead).

This is new behavior introduced by d8c4bddcd8bc ("drm/fb-helper:
Synchronize dirty worker with vblank"), and the commit messages say
`This allows several screen updates to pile up and acts as a rate
limiter.` .

Should it wait for any vblanks instead of waiting for one on CRTC 0 ?
(Or check whether CRTC 0 is on before waiting on it?)

Thanks,
Icenowy

> > [    0.334960] [<ffffffff80c0a144>]
> > drm_fb_helper_damage_work+0x8c/0x1d8
> > [    0.334960] [<ffffffff8028fac8>] process_one_work+0x198/0x348
> > [    0.334960] [<ffffffff802906c0>] worker_thread+0x238/0x390
> > [    0.334960] [<ffffffff8029c0d8>] kthread+0x160/0x198
> > [    0.334960] [<ffffffff8021fd8c>]
> > ret_from_kernel_thread+0x14/0x1c
> > 
> > [    0.334960] ---[ end trace 0000000000000000 ]---
> > ```
> > 
> > > > > Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
> > > > Oh forgot to attach when crafting v2:
> > > > 
> > > > ```
> > > > Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
> > > > ```
> > > > 
> > > > > ---
> > > > > Changes in v2:
> > > > > - Re-formatted Loongson product model numbers per request
> > > > > from
> > > > > Huacai.
> > > > > 
> > > > >    drivers/gpu/drm/loongson/lsdc_crtc.c | 1 -
> > > > >    1 file changed, 1 deletion(-)
> > > > > 
> > > > > diff --git a/drivers/gpu/drm/loongson/lsdc_crtc.c
> > > > > b/drivers/gpu/drm/loongson/lsdc_crtc.c
> > > > > index 587fbe285e9ef..b3af8e0cdb15f 100644
> > > > > --- a/drivers/gpu/drm/loongson/lsdc_crtc.c
> > > > > +++ b/drivers/gpu/drm/loongson/lsdc_crtc.c
> > > > > @@ -721,7 +721,6 @@ static const struct drm_crtc_funcs
> > > > > ls7a1000_crtc_funcs = {
> > > > >    	.late_register = lsdc_crtc_late_register,
> > > > >    	.enable_vblank = lsdc_crtc_enable_vblank,
> > > > >    	.disable_vblank = lsdc_crtc_disable_vblank,
> > > > > -	.get_vblank_timestamp =
> > > > > drm_crtc_vblank_helper_get_vblank_timestamp,
> > > > >    	.atomic_print_state = lsdc_crtc_atomic_print_state,
> > > > >    };
> > > > >    
Re: [PATCH v2] drm/loongson: stop to set get_vblank_timestamp for LS7A1000 CRTC
Posted by Thomas Zimmermann 1 week, 6 days ago
Hi

Am 23.03.26 um 12:42 schrieb Icenowy Zheng:
[...]
>>> drm_update_vblank_count+0xac/0x418
>>> [    0.334960] [<ffffffff80be6270>] drm_vblank_enable+0xf0/0x288
>>> [    0.334960] [<ffffffff80be7010>] drm_vblank_get+0xf8/0x160
>>> [    0.334960] [<ffffffff80beb2e0>]
>>> drm_client_modeset_wait_for_vblank+0x50/0xa0
> I doubt the problem here is that the function above is called with
> hardcoded 0 by drm_fb_helper_fb_dirty() (being inlined into
> drm_fb_helper_damage_work() by the compiler). Then on my setup it
> failed because my primary output (laptop LCD) is on CRTC 1 (CRTC 0 is
> external HDMI instead).

The CRTC 0 has vblank interrupt. The CRTC 1 does not. Is that correct?

>
> This is new behavior introduced by d8c4bddcd8bc ("drm/fb-helper:
> Synchronize dirty worker with vblank"), and the commit messages say
> `This allows several screen updates to pile up and acts as a rate
> limiter.` .

This should work if the vblanks are configured correctly.


>
> Should it wait for any vblanks instead of waiting for one on CRTC 0 ?
> (Or check whether CRTC 0 is on before waiting on it?)

It should only wait for the vblank on the CRTC it uses (1 in your case).

Best regards
Thomas


>
> Thanks,
> Icenowy
>
>>> [    0.334960] [<ffffffff80c0a144>]
>>> drm_fb_helper_damage_work+0x8c/0x1d8
>>> [    0.334960] [<ffffffff8028fac8>] process_one_work+0x198/0x348
>>> [    0.334960] [<ffffffff802906c0>] worker_thread+0x238/0x390
>>> [    0.334960] [<ffffffff8029c0d8>] kthread+0x160/0x198
>>> [    0.334960] [<ffffffff8021fd8c>]
>>> ret_from_kernel_thread+0x14/0x1c
>>>
>>> [    0.334960] ---[ end trace 0000000000000000 ]---
>>> ```
>>>
>>>>>> Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
>>>>> Oh forgot to attach when crafting v2:
>>>>>
>>>>> ```
>>>>> Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
>>>>> ```
>>>>>
>>>>>> ---
>>>>>> Changes in v2:
>>>>>> - Re-formatted Loongson product model numbers per request
>>>>>> from
>>>>>> Huacai.
>>>>>>
>>>>>>     drivers/gpu/drm/loongson/lsdc_crtc.c | 1 -
>>>>>>     1 file changed, 1 deletion(-)
>>>>>>
>>>>>> diff --git a/drivers/gpu/drm/loongson/lsdc_crtc.c
>>>>>> b/drivers/gpu/drm/loongson/lsdc_crtc.c
>>>>>> index 587fbe285e9ef..b3af8e0cdb15f 100644
>>>>>> --- a/drivers/gpu/drm/loongson/lsdc_crtc.c
>>>>>> +++ b/drivers/gpu/drm/loongson/lsdc_crtc.c
>>>>>> @@ -721,7 +721,6 @@ static const struct drm_crtc_funcs
>>>>>> ls7a1000_crtc_funcs = {
>>>>>>     	.late_register = lsdc_crtc_late_register,
>>>>>>     	.enable_vblank = lsdc_crtc_enable_vblank,
>>>>>>     	.disable_vblank = lsdc_crtc_disable_vblank,
>>>>>> -	.get_vblank_timestamp =
>>>>>> drm_crtc_vblank_helper_get_vblank_timestamp,
>>>>>>     	.atomic_print_state = lsdc_crtc_atomic_print_state,
>>>>>>     };
>>>>>>     

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)


Re: [PATCH v2] drm/loongson: stop to set get_vblank_timestamp for LS7A1000 CRTC
Posted by Icenowy Zheng 1 week, 6 days ago
在 2026-03-23一的 14:32 +0100,Thomas Zimmermann写道:
> Hi
> 
> Am 23.03.26 um 12:42 schrieb Icenowy Zheng:
> [...]
> > > > drm_update_vblank_count+0xac/0x418
> > > > [    0.334960] [<ffffffff80be6270>]
> > > > drm_vblank_enable+0xf0/0x288
> > > > [    0.334960] [<ffffffff80be7010>] drm_vblank_get+0xf8/0x160
> > > > [    0.334960] [<ffffffff80beb2e0>]
> > > > drm_client_modeset_wait_for_vblank+0x50/0xa0
> > I doubt the problem here is that the function above is called with
> > hardcoded 0 by drm_fb_helper_fb_dirty() (being inlined into
> > drm_fb_helper_damage_work() by the compiler). Then on my setup it
> > failed because my primary output (laptop LCD) is on CRTC 1 (CRTC 0
> > is
> > external HDMI instead).
> 
> The CRTC 0 has vblank interrupt. The CRTC 1 does not. Is that
> correct?

Both have vblank interrupts support. The situation here is that only
the CRTC 1 is actively outputting an image; the CRTC 0 has remaining
timing programmed by the firmware and being running the timing
generator, but not doing DMA nor generating image. (I think this could
be on purpose to prevent some registers from being erased?)

BTW after this warning, the vblank of CRTC 0 is enabled, and no one
bother to disable it, so the interrupt triggers continously.

> 
> > 
> > This is new behavior introduced by d8c4bddcd8bc ("drm/fb-helper:
> > Synchronize dirty worker with vblank"), and the commit messages say
> > `This allows several screen updates to pile up and acts as a rate
> > limiter.` .
> 
> This should work if the vblanks are configured correctly.

Hardcoding 0 here sounds not correct to me, see my analyze below.

By the way, the other codepath, ioctl FBIO_WAITFORVSYNC, mentions that
hardcoding 0 there is just guessing `The first CRTC should be the
integrated panel on most drivers`, and suggests affected applications
to switch to KMS -- but the fb dirty codepath is used by fbcon, the
biggest fbdev consumer here not yet converted...

> 
> 
> > 
> > Should it wait for any vblanks instead of waiting for one on CRTC 0
> > ?
> > (Or check whether CRTC 0 is on before waiting on it?)
> 
> It should only wait for the vblank on the CRTC it uses (1 in your
> case).

I traced some code:

The second parameter of drm_client_modeset_wait_for_vblank is called
crtc_index, and it tries to retrieve the CRTC with `client->
modesets[crtc_index].crtc` ; the modesets array is initialized with:

```
	drm_for_each_crtc(crtc, dev)
		client->modesets[i++].crtc = crtc;
```

So non-active CRTCs are also included, and hardcoding 0 here can easily
hit non-active CRTC 0.

Thanks,
Icenowy

> 
> Best regards
> Thomas
> 
> 
> > 
> > Thanks,
> > Icenowy
> > 
> > > > [    0.334960] [<ffffffff80c0a144>]
> > > > drm_fb_helper_damage_work+0x8c/0x1d8
> > > > [    0.334960] [<ffffffff8028fac8>]
> > > > process_one_work+0x198/0x348
> > > > [    0.334960] [<ffffffff802906c0>] worker_thread+0x238/0x390
> > > > [    0.334960] [<ffffffff8029c0d8>] kthread+0x160/0x198
> > > > [    0.334960] [<ffffffff8021fd8c>]
> > > > ret_from_kernel_thread+0x14/0x1c
> > > > 
> > > > [    0.334960] ---[ end trace 0000000000000000 ]---
> > > > ```
> > > > 
> > > > > > > Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
> > > > > > Oh forgot to attach when crafting v2:
> > > > > > 
> > > > > > ```
> > > > > > Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
> > > > > > ```
> > > > > > 
> > > > > > > ---
> > > > > > > Changes in v2:
> > > > > > > - Re-formatted Loongson product model numbers per request
> > > > > > > from
> > > > > > > Huacai.
> > > > > > > 
> > > > > > >     drivers/gpu/drm/loongson/lsdc_crtc.c | 1 -
> > > > > > >     1 file changed, 1 deletion(-)
> > > > > > > 
> > > > > > > diff --git a/drivers/gpu/drm/loongson/lsdc_crtc.c
> > > > > > > b/drivers/gpu/drm/loongson/lsdc_crtc.c
> > > > > > > index 587fbe285e9ef..b3af8e0cdb15f 100644
> > > > > > > --- a/drivers/gpu/drm/loongson/lsdc_crtc.c
> > > > > > > +++ b/drivers/gpu/drm/loongson/lsdc_crtc.c
> > > > > > > @@ -721,7 +721,6 @@ static const struct drm_crtc_funcs
> > > > > > > ls7a1000_crtc_funcs = {
> > > > > > >     	.late_register = lsdc_crtc_late_register,
> > > > > > >     	.enable_vblank = lsdc_crtc_enable_vblank,
> > > > > > >     	.disable_vblank = lsdc_crtc_disable_vblank,
> > > > > > > -	.get_vblank_timestamp =
> > > > > > > drm_crtc_vblank_helper_get_vblank_timestamp,
> > > > > > >     	.atomic_print_state =
> > > > > > > lsdc_crtc_atomic_print_state,
> > > > > > >     };
> > > > > > >