TX2i tegra_nvdisp_head_enable fails if HDMI is connected after boot

The following sequence of commands

echo 4 > blank && echo 0x0 > device/win_mask && echo 0x3f > device/win_mask && echo 0 >blank

Caused the driver to crash

[ 529.261173] tegradc 15210000.nvdisplay: blank - powerdown
[ 529.263424] tegradc 15210000.nvdisplay: unblank
[ 529.264399] Parent Clock set for DC plld2
[ 529.317733] tegradc 15210000.nvdisplay: dc_poll_register 0x41: timeout
[ 529.317752] tegradc 15210000.nvdisplay: dc timeout waiting for DC to stop
[ 529.369714] tegradc 15210000.nvdisplay: dc_poll_register 0x41: timeout
[ 529.369730] tegradc 15210000.nvdisplay: dc timeout waiting for DC to stop
[ 529.421737] tegradc 15210000.nvdisplay: dc_poll_register 0x41: timeout
[ 529.421755] tegradc 15210000.nvdisplay: timeout waiting for postcomp init state to promote
[ 529.473759] tegradc 15210000.nvdisplay: dc_poll_register 0x41: timeout
[ 529.473777] tegradc 15210000.nvdisplay: timeout waiting for win assignments to promote
[ 529.473793] tegradc 15210000.nvdisplay: tegra_nvdisp_head_enable, failed head enable
[ 529.474520] ignoring invalid window 0 request
[ 529.474526] ------------[ cut here ]------------
[ 529.474577] WARNING: CPU: 2 PID: 7212 at /home/lab/work/l4t/kernel_build/kernel/nvidia/drivers/video/tegra/dc/window.c:1045 tegra_dc_update_windows+0x304/0x540
[ 529.474671] Modules linked in: iptable_filter zram nvgpu bluedroid_pm fbtft_device(C) fb_ssd1351(C) fbtft(C) ip_tables x_tables

[ 529.474707] CPU: 2 PID: 7212 Comm: bash Tainted: G C 4.9.140 #1
[ 529.474719] Hardware name: storm (DT)
[ 529.474737] task: ffffffc19e639c00 task.stack: ffffffc19e1cc000
[ 529.474775] PC is at tegra_dc_update_windows+0x304/0x540
[ 529.474882] LR is at tegra_dc_update_windows+0x304/0x540
[ 529.474906] pc : [] lr : [] pstate: 20400045
[ 529.474917] sp : ffffffc19e1cf800
[ 529.474950] x29: ffffffc19e1cf800 x28: ffffff800a16fef0
[ 529.474977] x27: ffffffc1ac563000 x26: 0000000000000000
[ 529.475000] x25: 0000000000000001 x24: 0000000000000000
[ 529.475026] x23: ffffffc19e1cf8c8 x22: 0000000000000001
[ 529.475051] x21: ffffffc1aa528e38 x20: ffffffc1aa4f8000
[ 529.475074] x19: 0000000000000000 x18: 0000000000000001
[ 529.475096] x17: 0000000000000001 x16: 0000000000000000
[ 529.475123] x15: ffffffffffffffff x14: ffffff800a128260
[ 529.475150] x13: ffffff800a127e99 x12: 0000005800000094
[ 529.475176] x11: 00001a4ea257d980 x10: ffffffc1b6790540
[ 529.475204] x9 : 0000000000000001 x8 : 7365757165722030
[ 529.475229] x7 : 20776f646e697720 x6 : ffffff800a127141
[ 529.475253] x5 : 0000000000000000 x4 : 0000000000000000
[ 529.475281] x3 : ffffffffffffffff x2 : 00000041acf97000
[ 529.475306] x1 : ffffffc19e639c00 x0 : 0000000000000021

[ 529.475327] —[ end trace 6963c2030ad96c15 ]—
[ 529.475336] Call trace:
[ 529.475369] [] tegra_dc_update_windows+0x304/0x540
[ 529.475429] [] tegra_fb_pan_display+0xcc/0x100
[ 529.475457] [] fb_pan_display+0x9c/0x120
[ 529.475485] [] bit_update_start+0x28/0x50
[ 529.475510] [] fbcon_switch+0x35c/0x590
[ 529.475536] [] redraw_screen+0x144/0x248
[ 529.475582] [] fbcon_blank+0x124/0x2b8
[ 529.475607] [] do_unblank_screen+0xa4/0x198
[ 529.475630] [] fbcon_event_notify+0x9ec/0xa10
[ 529.475661] [] notifier_call_chain+0x5c/0xa0
[ 529.475684] [] blocking_notifier_call_chain+0x64/0x88
[ 529.475707] [] fb_notifier_call_chain+0x30/0x40
[ 529.475726] [] fb_blank+0x88/0xc0
[ 529.475746] [] store_blank+0x5c/0x90
[ 529.475767] [] dev_attr_store+0x44/0x60
[ 529.475873] [] sysfs_kf_write+0x58/0x80
[ 529.475896] [] kernfs_fop_write+0xfc/0x1e0
[ 529.475920] [] __vfs_write+0x48/0x118
[ 529.475942] [] vfs_write+0xac/0x1b0
[ 529.475964] [] SyS_write+0x54/0xb0
[ 529.475987] [] el0_svc_naked+0x34/0x38