drm/rockchip: logo: attach crtc to drm state earlier

When the connector is disconneted, the crtc->state->state will be used
before it assignment a value, which will cause a NULL ppinter issue,
the dumpstack as follow:

[    3.015805][    T9] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000048
[    3.024448][    T9] Mem abort info:
[    3.024821][    T9]   ESR = 0x96000005
[    3.025176][    T9]   EC = 0x25: DABT (current EL), IL = 32 bits
[    3.025725][    T9]   SET = 0, FnV = 0
[    3.026076][    T9]   EA = 0, S1PTW = 0
[    3.026434][    T9] Data abort info:
[    3.026771][    T9]   ISV = 0, ISS = 0x00000005
[    3.027190][    T9]   CM = 0, WnR = 0
[    3.027530][    T9] [0000000000000048] user address but active_mm is swapper
[    3.028194][    T9] Internal error: Oops: 96000005 [#1] PREEMPT SMP
[    3.028764][    T9] Modules linked in:
[    3.029140][    T9] CPU: 2 PID: 9 Comm: kworker/u16:1 Not tainted 5.10.66 #234
[    3.029797][    T9] Hardware name: Firefly ITX-3588J HDMI(Android) (DT)
[    3.030417][    T9] Workqueue: events_unbound deferred_probe_work_func
[    3.031018][    T9] pstate: 00c00009 (nzcv daif +PAN +UAO -TCO BTYPE=--)
[    3.031638][    T9] pc : drm_atomic_get_crtc_state+0x1c/0x104
[    3.032175][    T9] lr : vop2_crtc_loader_protect+0x160/0x34c
[    3.032700][    T9] sp : ffffffc0124737b0
[    3.033074][    T9] x29: ffffffc0124737b0 x28: ffffff80052db108
[    3.033629][    T9] x27: dead000000000100 x26: ffffff80061da400
[    3.034192][    T9] x25: ffffff8006208a60 x24: ffffff80062189b8
[    3.034756][    T9] x23: 0000000000000000 x22: 0000000000000001
[    3.035320][    T9] x21: ffffff8006208880 x20: ffffff8006210080
[    3.035882][    T9] x19: ffffff80062108e0 x18: ffffffc0124250a0
[    3.036444][    T9] x17: 0000000000000040 x16: 0000000000000000
[    3.037005][    T9] x15: 0000000000000001 x14: 0000000000000010
[    3.037567][    T9] x13: 0000000000000010 x12: 0000000000000010
[    3.038118][    T9] x11: 0000000000000001 x10: 0000000000000000
[    3.038680][    T9] x9 : 0000000000000002 x8 : ffffff8005726800
[    3.039232][    T9] x7 : 0000000000000020 x6 : 0000000000000000
[    3.039782][    T9] x5 : 0000000000000020 x4 : 0000000080000000
[    3.040345][    T9] x3 : 0000000000000020 x2 : 0000000000000001
[    3.040907][    T9] x1 : ffffff80062108e0 x0 : 0000000000000000
[    3.041466][    T9] Call trace:
[    3.041774][    T9]  drm_atomic_get_crtc_state+0x1c/0x104
[    3.042261][    T9]  vop2_crtc_loader_protect+0x160/0x34c
[    3.042752][    T9]  rockchip_drm_show_logo+0x11e8/0x18e4
[    3.043239][    T9]  rockchip_drm_bind+0x488/0x57c
[    3.043673][    T9]  try_to_bring_up_master+0x16c/0x1b4
[    3.044148][    T9]  __component_add+0xc0/0x188
[    3.044556][    T9]  component_add+0x18/0x28
[    3.044944][    T9]  dw_dp_probe+0x5ac/0x5bc
[    3.045331][    T9]  platform_drv_probe+0x9c/0xc4
[    3.045761][    T9]  really_probe+0x204/0x510
[    3.046158][    T9]  driver_probe_device+0x80/0xc0
[    3.046588][    T9]  __device_attach_driver+0x118/0x140
[    3.047062][    T9]  bus_for_each_drv+0x84/0xd4
[    3.047469][    T9]  __device_attach+0xc0/0x158
[    3.047876][    T9]  device_initial_probe+0x18/0x28
[    3.048317][    T9]  bus_probe_device+0x38/0xa0
[    3.048723][    T9]  deferred_probe_work_func+0x80/0xe0
[    3.049202][    T9]  process_one_work+0x1f4/0x490
[    3.049631][    T9]  worker_thread+0x324/0x4dc
[    3.050039][    T9]  kthread+0x13c/0x344
[    3.050403][    T9]  ret_from_fork+0x10/0x30

Attaching crtc to drm state earlier to avoid attaching the drm state
failed if the function is not normally return.

Fixed:
commit 0a196311ef ("drm/rockchip: logo: attach crtc to drm state")

Signed-off-by: Zhang Yubing <yubing.zhang@rock-chips.com>
Change-Id: I53211f91089143b093e74bf5016cacf8c677dc74
This commit is contained in:
Zhang Yubing
2022-06-07 15:41:47 +08:00
committed by Tao Huang
parent 24275dd459
commit 77ac72f1ec

View File

@@ -644,6 +644,8 @@ static int setup_initial_state(struct drm_device *drm_dev,
if (!set->hdisplay || !set->vdisplay || !set->vrefresh)
is_crtc_enabled = false;
crtc->state->state = state;
conn_state = drm_atomic_get_connector_state(state, connector);
if (IS_ERR(conn_state))
return PTR_ERR(conn_state);
@@ -709,7 +711,6 @@ static int setup_initial_state(struct drm_device *drm_dev,
goto error_conn;
}
crtc->state->state = state;
drm_mode_copy(&crtc_state->adjusted_mode, mode);
if (!match || !is_crtc_enabled) {
set->mode_changed = true;