Re: [PATCH v1] drm/modes: Skip invalid cmdline mode
From: Dmitry Osipenko
Date: Wed Jul 10 2019 - 09:36:11 EST
10.07.2019 16:29, Dmitry Osipenko ÐÐÑÐÑ:
> 10.07.2019 16:11, Dmitry Osipenko ÐÐÑÐÑ:
>> 10.07.2019 16:06, Maxime Ripard ÐÐÑÐÑ:
>>> On Wed, Jul 10, 2019 at 03:59:55PM +0300, Dmitry Osipenko wrote:
>>>> 10.07.2019 15:55, Maxime Ripard ÐÐÑÐÑ:
>>>>> On Wed, Jul 10, 2019 at 03:42:28PM +0300, Dmitry Osipenko wrote:
>>>>>> 10.07.2019 13:12, Maxime Ripard ÐÐÑÐÑ:
>>>>>>> On Tue, Jul 09, 2019 at 05:51:51PM +0300, Dmitry Osipenko wrote:
>>>>>>>> The named mode could be invalid and then cmdline parser misses to validate
>>>>>>>> mode's dimensions, happily adding 0x0 mode as a valid mode. One case where
>>>>>>>> this happens is NVIDIA Tegra devices that are using downstream bootloader
>>>>>>>> which adds "video=tegrafb" to the kernel's cmdline and thus upstream Tegra
>>>>>>>> DRM driver fails to probe because of the invalid mode.
>>>>>>>>
>>>>>>>> Fixes: 3aeeb13d8996 ("drm/modes: Support modes names on the command line")
>>>>>>>> Signed-off-by: Dmitry Osipenko <digetx@xxxxxxxxx>
>>>>>>>
>>>>>>> Applied to drm-misc-next-fixes
>>>>>>>
>>>>>>> Thanks for figuring this out!
>>>>>>
>>>>>> Thank you very much! So the driver now doesn't fail to probe because
>>>>>> of the cmdline, but what else I noticed is that the framebuffer
>>>>>> console is now rotated by 90Â on a 800x1280 panel, while display in
>>>>>> Xorg is vertical as it was before. Seems something else is still
>>>>>> missing, reverting "drm/modes: Rewrite the command line parser"
>>>>>> returns the framebuffer's console orientation into the original
>>>>>> state.
>>>>>
>>>>> What is the whole command line passed by the bootloader ?
>>>>
>>>> tegraid=30.1.3.0.0 mem=1022M@2048M android.commchip=0 vmalloc=512M androidboot.serialno=015d3f18c9081210 video=tegrafb no_console_suspend=1 console=none
>>>> debug_uartport=hsport usbcore.old_scheme_first=1 lp0_vec=8192@0xbddf9000 tegra_fbmem=8195200@0xabe01000 core_edp_mv=0 audio_codec=rt5640 board_info=f41:a00:1:44:2
>>>> root=/dev/sda1 rw rootwait tegraboot=sdmmc gpt gpt_sector=61079551 androidboot.bootloader=4.23 androidboot.baseband=1231_0.18.0_0409
>>>
>>> Thanks.
>>>
>>> It still doesn't really make sense to me why that video=tegrafb should
>>> be considered valid.
>>>
>>> However, I don't see anything rotation related in the commit you
>>> list. Are you sure it's really the offending one and not another one?
>>
>> Yes.
>>
>>> Also, do you have the option to recompile a kernel so that we can add
>>> some debug?
>>
>> Recompiling kernel is not a problem at all.
>>
>> Before "drm/modes: Rewrite the command line parser":
>>
>> [ 1.256454] [drm] parse error at position 6 in video mode 'tegrafb'
>> [ 1.256654] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
>> [ 1.256664] [drm] No driver support for vblank timestamp query.
>> [ 1.256703] [drm:drm_client_modeset_probe]
>> [ 1.256719] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:95:LVDS-1]
>> [ 1.256731] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:95:LVDS-1] status updated from unknown to connected
>> [ 1.256828] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:95:LVDS-1] probed modes :
>> [ 1.256842] [drm:drm_mode_debug_printmodeline] Modeline "800x1280": 60 66770 800 849 882 899 1280 1281 1288 1303 0x48 0xa
>> [ 1.256849] [drm:drm_client_modeset_probe] connector 95 enabled? yes
>> [ 1.256859] [drm:drm_client_modeset_probe] Not using firmware configuration
>> [ 1.256867] [drm:drm_client_modeset_probe] looking for cmdline mode on connector 95
>> [ 1.256874] [drm:drm_client_modeset_probe] looking for preferred mode on connector 95 0
>> [ 1.256880] [drm:drm_client_modeset_probe] found mode 800x1280
>> [ 1.256886] [drm:drm_client_modeset_probe] picking CRTCs for 4096x4096 config
>> [ 1.256896] [drm:drm_client_modeset_probe] desired mode 800x1280 set on crtc 94 (0,0)
>> [ 1.279069] [drm:tegra_crtc_atomic_enable] rate: 408000000, div: 10
>> [ 1.279077] [drm:tegra_crtc_atomic_enable] pclk: 0
>> [ 1.296744] [drm:drm_fb_helper_hotplug_event.part.0]
>> [ 1.296760] [drm:drm_client_modeset_probe]
>> [ 1.296792] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:95:LVDS-1]
>> [ 1.296987] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:95:LVDS-1] probed modes :
>> [ 1.297010] [drm:drm_mode_debug_printmodeline] Modeline "800x1280": 60 66770 800 849 882 899 1280 1281 1288 1303 0x48 0xa
>> [ 1.297022] [drm:drm_client_modeset_probe] connector 95 enabled? yes
>> [ 1.297040] [drm:drm_client_modeset_probe] Not using firmware configuration
>> [ 1.297054] [drm:drm_client_modeset_probe] looking for cmdline mode on connector 95
>> [ 1.297065] [drm:drm_client_modeset_probe] looking for preferred mode on connector 95 0
>> [ 1.297073] [drm:drm_client_modeset_probe] found mode 800x1280
>> [ 1.297083] [drm:drm_client_modeset_probe] picking CRTCs for 800x1280 config
>> [ 1.297102] [drm:drm_client_modeset_probe] desired mode 800x1280 set on crtc 94 (0,0)
>>
>> After:
>>
>> [ 1.225000] [drm:drm_connector_init] cmdline mode for connector LVDS-1 tegrafb 0x0@60Hz
>> [ 1.225143] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
>> [ 1.225154] [drm] No driver support for vblank timestamp query.
>> [ 1.225182] [drm:drm_client_modeset_probe]
>> [ 1.225195] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:95:LVDS-1]
>> [ 1.225203] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:95:LVDS-1] status updated from unknown to connected
>> [ 1.225283] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:95:LVDS-1] probed modes :
>> [ 1.225294] [drm:drm_mode_debug_printmodeline] Modeline "800x1280": 60 66770 800 849 882 899 1280 1281 1288 1303 0x48 0xa
>> [ 1.225299] [drm:drm_client_modeset_probe] connector 95 enabled? yes
>> [ 1.225307] [drm:drm_client_modeset_probe] Not using firmware configuration
>> [ 1.225314] [drm:drm_client_modeset_probe] looking for cmdline mode on connector 95
>> [ 1.225319] [drm:drm_client_modeset_probe] looking for preferred mode on connector 95 0
>> [ 1.225323] [drm:drm_client_modeset_probe] found mode 800x1280
>> [ 1.225328] [drm:drm_client_modeset_probe] picking CRTCs for 4096x4096 config
>> [ 1.225336] [drm:drm_client_modeset_probe] desired mode 800x1280 set on crtc 94 (0,0)
>> [ 1.249051] [drm:tegra_crtc_atomic_enable] rate: 408000000, div: 10
>> [ 1.249058] [drm:tegra_crtc_atomic_enable] pclk: 0
>> [ 1.266748] [drm:drm_fb_helper_hotplug_event.part.0]
>> [ 1.266768] [drm:drm_client_modeset_probe]
>> [ 1.266805] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:95:LVDS-1]
>> [ 1.267045] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:95:LVDS-1] probed modes :
>> [ 1.267074] [drm:drm_mode_debug_printmodeline] Modeline "800x1280": 60 66770 800 849 882 899 1280 1281 1288 1303 0x48 0xa
>> [ 1.267091] [drm:drm_client_modeset_probe] connector 95 enabled? yes
>> [ 1.267113] [drm:drm_client_modeset_probe] Not using firmware configuration
>> [ 1.267129] [drm:drm_client_modeset_probe] looking for cmdline mode on connector 95
>> [ 1.267143] [drm:drm_client_modeset_probe] looking for preferred mode on connector 95 0
>> [ 1.267155] [drm:drm_client_modeset_probe] found mode 800x1280
>> [ 1.267168] [drm:drm_client_modeset_probe] picking CRTCs for 800x1280 config
>> [ 1.267191] [drm:drm_client_modeset_probe] desired mode 800x1280 set on crtc 94 (0,0)
>>
>
> This works:
>
> diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c
> index 56d36779d213..e5a2f9c8f404 100644
> --- a/drivers/gpu/drm/drm_client_modeset.c
> +++ b/drivers/gpu/drm/drm_client_modeset.c
> @@ -182,6 +182,8 @@ drm_connector_pick_cmdline_mode(struct drm_connector *connector)
> mode = drm_mode_create_from_cmdline_mode(connector->dev, cmdline_mode);
> if (mode)
> list_add(&mode->head, &connector->modes);
> + else
> + cmdline_mode->specified = false;
>
> return mode;
> }
>
> I'll make a proper patch later today if there are no objections.
>
Pleas note that drm_client_rotation() takes into account whether cmdline->specified.