From 3a7ff28a931f5f9156562b9802fbbff93a7b720c Mon Sep 17 00:00:00 2001 From: David Heidelberg Date: Mon, 24 Feb 2020 12:03:25 +0100 Subject: [PATCH] Revert "drm/msm/dsi: Move setup_encoder to modeset_init" This reverts commit 03436e3ec69c8e026224a5f172e5d0431f722305. Fixes: mdp: dummy supplies not allowed for exclusive requests [ 2.641236] 8<--- cut here --- [ 2.641279] Unable to handle kernel NULL pointer dereference at virtual address 00000000 [ 2.643206] pgd = (ptrval) [ 2.651522] [00000000] *pgd=00000000 [ 2.653973] Internal error: Oops: 5 [#1] PREEMPT SMP ARM [ 2.657695] Modules linked in: [ 2.663000] CPU: 3 PID: 105 Comm: kworker/3:1 Not tainted 5.3.0-00014-g9bf8d2ba4898 #120 [ 2.665859] Hardware name: Generic DT based system [ 2.674123] Workqueue: events deferred_probe_work_func [ 2.678718] PC is at msm_dsi_manager_setup_encoder+0x38/0x6c [ 2.683830] LR is at msm_dsi_manager_setup_encoder+0x30/0x6c [ 2.689643] pc : [] lr : [] psr: a0000013 [ 2.695283] sp : e8043c08 ip : e8043c08 fp : e8043c24 [ 2.701271] r10: e8305c00 r9 : e8305400 r8 : e8305c00 [ 2.706482] r7 : e7d1fc00 r6 : 00000000 r5 : e7d1c4c0 r4 : e7d1fc00 [ 2.711693] r3 : e7d1c4c0 r2 : e7d19280 r1 : 00000000 r0 : e7d1fc00 [ 2.718297] Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none [ 2.724803] Control: 10c5787d Table: 8020406a DAC: 00000051 [ 2.732006] Process kworker/3:1 (pid: 105, stack limit = 0x(ptrval)) [ 2.737736] Stack: (0xe8043c08 to 0xe8044000) [ 2.744179] 3c00: e7d1c4c0 e8305400 00000000 e7d1fc00 e8043c4c e8043c28 [ 2.748445] 3c20: c07629dc c0766a20 e7d1f780 00000006 e8305400 e8305400 00000001 e8305400 [ 2.756606] 3c40: e8043c8c e8043c50 c071caac c0762948 00000002 e8043c60 c091d268 c0c5ee2c [ 2.764766] 3c60: e8305c00 e8305c00 e8305400 00000000 e89efa10 e8305c00 00000002 c12c2ea8 [ 2.772926] 3c80: e8043cec e8043c90 c0754554 c071c540 c034bfd8 c036f8a8 e89efba4 60000013 [ 2.781086] 3ca0: e89efa10 e89efba4 e8043ccc c0c5ee58 e8043ccc e8043cc0 c0c5ee58 c034be74 [ 2.789245] 3cc0: e8043cec e7d11c40 e7d11f40 e7d11f18 e7d16540 e7d11f18 00000002 c12c2ea8 [ 2.797405] 3ce0: e8043d2c e8043cf0 c0770244 c0754190 c0d1db90 e7d11f40 e89efa10 00000000 [ 2.805565] 3d00: e8043d2c c12775d4 e7d11f40 e89efa10 c0d5a440 c0f8cbf0 e89efa10 00000000 [ 2.813725] 3d20: e8043d54 e8043d30 c0770644 c0770054 c0d5f5f4 c038f528 e93f3378 e89efa10 [ 2.821885] 3d40: e93f5ab8 e89efa10 e8043d94 e8043d58 c0753dbc c0770590 e7d16540 00000003 [ 2.830043] 3d60: 00000000 e93f6274 c07908d8 00000000 e89efa10 c1276f10 00000000 c1313718 [ 2.838203] 3d80: c1276f10 c12c3160 e8043db4 e8043d98 c077992c c0753b98 e89efa10 c1313714 [ 2.846364] 3da0: 00000000 00000000 e8043df4 e8043db8 c0776ffc c07798e0 e8043dd4 e8043dc8 [ 2.854523] 3dc0: c0c5eebc 00000007 e8043df4 e89efa10 c1276f10 e8043e78 e89efa10 c0f91d0c [ 2.862683] 3de0: c12c3160 e89efa10 e8043e2c e8043df8 c077754c c0776ef4 c1276f10 c1276f10 [ 2.870844] 3e00: e8043e78 e89efa10 00000001 c1276f10 e8043e78 e89efa10 c0f91d0c c12c3160 [ 2.879002] 3e20: e8043e4c e8043e30 c0777870 c07774d8 00000000 e8043e78 c07777cc c12c3160 [ 2.887162] 3e40: e8043e74 e8043e50 c0774ff4 c07777d8 c02e686c e8ba4738 e89efa10 e89efa10 [ 2.895322] 3e60: 00000001 e89efa54 e8043e9c e8043e78 c0776e30 c0774f80 e89efa10 00000001 [ 2.903483] 3e80: c07733dc c127780c e89efa10 c1277a88 e8043eac e8043ea0 c07778f8 c0776d7c [ 2.911641] 3ea0: e8043ecc e8043eb0 c0775f08 c07778e8 c127780c c127780c c1277820 c12c3160 [ 2.919801] 3ec0: e8043efc e8043ed0 c07764b8 c0775e80 c0776430 c1277844 e8a21000 e93d4dc0 [ 2.927959] 3ee0: e93d7f00 00000000 c12bb270 00000000 e8043f3c e8043f00 c033d1b8 c077643c [ 2.936121] 3f00: c034bfd8 c036f8a8 e93d4dc0 e93d4dc0 e93d4dc0 e8a21000 e93d4dc0 e8a21014 [ 2.944279] 3f20: e93d4dd8 c1203d00 00000008 e8863e88 e8043f74 e8043f40 c033ed74 c033cfe8 [ 2.952440] 3f40: e8043f74 e8042000 c0343274 e8a20600 e8a20780 00000000 e8042000 e8a21000 [ 2.960601] 3f60: e8a2061c e8863e88 e8043fac e8043f78 c03436e0 c033eb2c c032fe64 c033eb20 [ 2.968757] 3f80: 00000000 e8a20780 c03435b4 00000000 00000000 00000000 00000000 00000000 [ 2.976919] 3fa0: 00000000 e8043fb0 c03010e8 c03435c0 00000000 00000000 00000000 00000000 [ 2.985078] 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 2.993236] 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000 [ 3.001359] Backtrace: [ 3.009541] [] (msm_dsi_manager_setup_encoder) from [] (msm_dsi_modeset_init+0xa0/0x1c8) [ 3.011796] r7:e7d1fc00 r6:00000000 r5:e8305400 r4:e7d1c4c0 [ 3.021869] [] (msm_dsi_modeset_init) from [] (mdp4_kms_init+0x578/0x7b4) [ 3.027510] r9:e8305400 r8:00000001 r7:e8305400 r6:e8305400 r5:00000006 r4:e7d1f780 [ 3.035927] [] (mdp4_kms_init) from [] (msm_drm_bind+0x3d0/0x5f4) [ 3.043741] r10:c12c2ea8 r9:00000002 r8:e8305c00 r7:e89efa10 r6:00000000 r5:e8305400 [ 3.051449] r4:e8305c00 [ 3.059274] [] (msm_drm_bind) from [] (try_to_bring_up_master+0x1fc/0x2c8) [ 3.061884] r10:c12c2ea8 r9:00000002 r8:e7d11f18 r7:e7d16540 r6:e7d11f18 r5:e7d11f40 [ 3.070285] r4:e7d11c40 [ 3.078198] [] (try_to_bring_up_master) from [] (component_master_add_with_match+0xc0/0x100) [ 3.080811] r10:00000000 r9:e89efa10 r8:c0f8cbf0 r7:c0d5a440 r6:e89efa10 r5:e7d11f40 [ 3.090945] r4:c12775d4 [ 3.098679] [] (component_master_add_with_match) from [] (msm_pdev_probe+0x230/0x290) [ 3.101291] r7:e89efa10 r6:e93f5ab8 r5:e89efa10 r4:e93f3378 [ 3.110756] [] (msm_pdev_probe) from [] (platform_drv_probe+0x58/0xa8) [ 3.116484] r10:c12c3160 r9:c1276f10 r8:c1313718 r7:00000000 r6:c1276f10 r5:e89efa10 [ 3.124540] r4:00000000 [ 3.132447] [] (platform_drv_probe) from [] (really_probe+0x114/0x424) [ 3.135053] r7:00000000 r6:00000000 r5:c1313714 r4:e89efa10 [ 3.143129] [] (really_probe) from [] (driver_probe_device+0x80/0x1dc) [ 3.148950] r10:e89efa10 r9:c12c3160 r8:c0f91d0c r7:e89efa10 r6:e8043e78 r5:c1276f10 [ 3.157005] r4:e89efa10 [ 3.164911] [] (driver_probe_device) from [] (__device_attach_driver+0xa4/0x110) [ 3.167527] r9:c12c3160 r8:c0f91d0c r7:e89efa10 r6:e8043e78 r5:c1276f10 r4:00000001 [ 3.176637] [] (__device_attach_driver) from [] (bus_for_each_drv+0x80/0xb0) [ 3.184361] r7:c12c3160 r6:c07777cc r5:e8043e78 r4:00000000 [ 3.193127] [] (bus_for_each_drv) from [] (__device_attach+0xc0/0x158) [ 3.198766] r6:e89efa54 r5:00000001 r4:e89efa10 [ 3.206841] [] (__device_attach) from [] (device_initial_probe+0x1c/0x20) [ 3.211614] r6:c1277a88 r5:e89efa10 r4:c127780c [ 3.220035] [] (device_initial_probe) from [] (bus_probe_device+0x94/0x9c) [ 3.224730] [] (bus_probe_device) from [] (deferred_probe_work_func+0x88/0xd0) [ 3.233145] r7:c12c3160 r6:c1277820 r5:c127780c r4:c127780c [ 3.242096] [] (deferred_probe_work_func) from [] (process_one_work+0x1dc/0x53c) [ 3.247910] r10:00000000 r9:c12bb270 r8:00000000 r7:e93d7f00 r6:e93d4dc0 r5:e8a21000 [ 3.257009] r4:c1277844 r3:c0776430 [ 3.264741] [] (process_one_work) from [] (worker_thread+0x254/0x500) [ 3.268393] r10:e8863e88 r9:00000008 r8:c1203d00 r7:e93d4dd8 r6:e8a21014 r5:e93d4dc0 [ 3.276449] r4:e8a21000 [ 3.284270] [] (worker_thread) from [] (kthread+0x12c/0x168) [ 3.286881] r10:e8863e88 r9:e8a2061c r8:e8a21000 r7:e8042000 r6:00000000 r5:e8a20780 [ 3.294246] r4:e8a20600 [ 3.301977] [] (kthread) from [] (ret_from_fork+0x14/0x2c) [ 3.304575] Exception stack(0xe8043fb0 to 0xe8043ff8) [ 3.311617] 3fa0: 00000000 00000000 00000000 00000000 [ 3.316761] 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 3.324913] 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 [ 3.333060] r10:00000000 r9:00000000 r8:00000000 r7:00000000 r6:00000000 r5:c03435b4 [ 3.339471] r4:e8a20780 [ 3.347469] Code: e5936004 ebffefaa e2504000 089da8f0 (e5963000) [ 3.350237] ---[ end trace ef11f4cc25ead15d ]--- [ 3.377018] Kernel panic - not syncing: Fatal exception [ 3.377092] CPU0: stopping [ 3.381054] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G D 5.3.0-00014-g9bf8d2ba4898 #120 [ 3.383835] Hardware name: Generic DT based system [ 3.393116] Backtrace: [ 3.397727] [] (dump_backtrace) from [] (show_stack+0x20/0x24) [ 3.400069] r7:c12b4080 r6:20000193 r5:00000000 r4:c12b4080 [ 3.407712] [] (show_stack) from [] (dump_stack+0x78/0x94) [ 3.413531] [] (dump_stack) from [] (handle_IPI+0x3a4/0x408) [ 3.420555] r7:00000000 r6:c12bb144 r5:00000004 r4:c11a5d50 [ 3.428108] [] (handle_IPI) from [] (gic_handle_irq+0x94/0xa0) [ 3.433751] r10:00000000 r9:c1201ec0 r8:ea803000 r7:c124cf28 r6:c1206894 r5:ea802000 [ 3.441124] r4:ea80200c [ 3.449021] [] (gic_handle_irq) from [] (__irq_svc+0x6c/0xa8) [ 3.451629] Exception stack(0xc1201ec0 to 0xc1201f08) [ 3.459024] 1ec0: 00000000 00002f2c e93999f0 c031ac20 00000000 c1200000 c12060e4 c1206120 [ 3.464065] 1ee0: 00000000 c11a5548 00000000 c1201f1c c1201f20 c1201f10 c030a474 c030a478 [ 3.472208] 1f00: 60000013 ffffffff [ 3.480359] r9:c1200000 r8:00000000 r7:c1201ef4 r6:ffffffff r5:60000013 r4:c030a478 [ 3.483683] [] (arch_cpu_idle) from [] (default_idle_call+0x30/0x3c) [ 3.491656] [] (default_idle_call) from [] (do_idle+0x204/0x284) [ 3.499725] [] (do_idle) from [] (cpu_startup_entry+0x28/0x2c) [ 3.507448] r10:c12060c0 r9:00000001 r8:c12d9140 r7:c12d9140 r6:ffffffff r5:c1216348 [ 3.514822] r4:000000cd [ 3.522719] [] (cpu_startup_entry) from [] (rest_init+0xb8/0xd8) [ 3.525339] [] (rest_init) from [] (arch_call_rest_init+0x18/0x1c) [ 3.533053] r5:00000001 r4:c12d9194 [ 3.540777] [] (arch_call_rest_init) from [] (start_kernel+0x408/0x4ac) [ 3.544517] [] (start_kernel) from [<00000000>] (0x0) [ 3.552585] r10:10c5387d r9:511f06f0 r8:819700a0 r7:00001e7a r6:10c0387d r5:00000051 [ 3.558484] r4:c1100330 [ 3.566469] CPU1: stopping [ 3.569089] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G D 5.3.0-00014-g9bf8d2ba4898 #120 [ 3.571604] Hardware name: Generic DT based system [ 3.580882] Backtrace: [ 3.585500] [] (dump_backtrace) from [] (show_stack+0x20/0x24) [ 3.587846] r7:c12b4080 r6:20000193 r5:00000000 r4:c12b4080 [ 3.595489] [] (show_stack) from [] (dump_stack+0x78/0x94) [ 3.601310] [] (dump_stack) from [] (handle_IPI+0x3a4/0x408) [ 3.608331] r7:00000001 r6:c12bb144 r5:00000004 r4:c11a5d50 [ 3.615888] [] (handle_IPI) from [] (gic_handle_irq+0x94/0xa0) [ 3.621532] r10:00000000 r9:e882df20 r8:ea803000 r7:c124cf28 r6:c1206894 r5:ea802000 [ 3.628896] r4:ea80200c [ 3.636800] [] (gic_handle_irq) from [] (__irq_svc+0x6c/0xa8) [ 3.639399] Exception stack(0xe882df20 to 0xe882df68) [ 3.646805] df20: 00000000 000002fc e93ad9f0 c031ac20 00000001 e882c000 c12060e4 c1206120 [ 3.651846] df40: 00000000 c11a5548 00000000 e882df7c e882df80 e882df70 c030a474 c030a478 [ 3.659982] df60: 60000013 ffffffff [ 3.668141] r9:e882c000 r8:00000000 r7:e882df54 r6:ffffffff r5:60000013 r4:c030a478 [ 3.671457] [] (arch_cpu_idle) from [] (default_idle_call+0x30/0x3c) [ 3.679434] [] (default_idle_call) from [] (do_idle+0x204/0x284) [ 3.687504] [] (do_idle) from [] (cpu_startup_entry+0x28/0x2c) [ 3.695230] r10:00000000 r9:511f06f0 r8:8020406a r7:c12d9438 r6:10c0387d r5:00000001 [ 3.702592] r4:00000089 [ 3.710502] [] (cpu_startup_entry) from [] (secondary_start_kernel+0x154/0x19c) [ 3.713113] [] (secondary_start_kernel) from [<8030284c>] (0x8030284c) [ 3.721866] r5:00000051 r4:a882406a [ 3.729497] CPU2: stopping [ 3.733066] CPU: 2 PID: 0 Comm: swapper/2 Tainted: G D 5.3.0-00014-g9bf8d2ba4898 #120 [ 3.735581] Hardware name: Generic DT based system [ 3.744858] Backtrace: [ 3.749476] [] (dump_backtrace) from [] (show_stack+0x20/0x24) [ 3.751821] r7:c12b4080 r6:20000193 r5:00000000 r4:c12b4080 [ 3.759466] [] (show_stack) from [] (dump_stack+0x78/0x94) [ 3.765287] [] (dump_stack) from [] (handle_IPI+0x3a4/0x408) [ 3.772308] r7:00000002 r6:c12bb144 r5:00000004 r4:c11a5d50 [ 3.779864] [] (handle_IPI) from [] (gic_handle_irq+0x94/0xa0) [ 3.785509] r10:00000000 r9:e882ff20 r8:ea803000 r7:c124cf28 r6:c1206894 r5:ea802000 [ 3.792871] r4:ea80200c [ 3.800776] [] (gic_handle_irq) from [] (__irq_svc+0x6c/0xa8) [ 3.803375] Exception stack(0xe882ff20 to 0xe882ff68) [ 3.810781] ff20: 00000000 000006fc e93c19f0 c031ac20 00000002 e882e000 c12060e4 c1206120 [ 3.815821] ff40: 00000000 c11a5548 00000000 e882ff7c e882ff80 e882ff70 c030a474 c030a478 [ 3.823957] ff60: 60000013 ffffffff [ 3.832116] r9:e882e000 r8:00000000 r7:e882ff54 r6:ffffffff r5:60000013 r4:c030a478 [ 3.835430] [] (arch_cpu_idle) from [] (default_idle_call+0x30/0x3c) [ 3.843410] [] (default_idle_call) from [] (do_idle+0x204/0x284) [ 3.851479] [] (do_idle) from [] (cpu_startup_entry+0x28/0x2c) [ 3.859206] r10:00000000 r9:511f06f0 r8:8020406a r7:c12d9438 r6:10c0387d r5:00000002 [ 3.866569] r4:00000089 [ 3.874476] [] (cpu_startup_entry) from [] (secondary_start_kernel+0x154/0x19c) [ 3.877087] [] (secondary_start_kernel) from [<8030284c>] (0x8030284c) [ 3.885843] r5:00000051 r4:a882406a --- drivers/gpu/drm/msm/dsi/dsi.c | 2 -- drivers/gpu/drm/msm/dsi/dsi.h | 2 +- drivers/gpu/drm/msm/dsi/dsi_host.c | 2 ++ drivers/gpu/drm/msm/dsi/dsi_manager.c | 37 +++++++++++++++++++++++++-- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c index 55ea4bc2ee9cb..ada942498b4ee 100644 --- a/drivers/gpu/drm/msm/dsi/dsi.c +++ b/drivers/gpu/drm/msm/dsi/dsi.c @@ -242,8 +242,6 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev, goto fail; } - msm_dsi_manager_setup_encoder(msm_dsi->id); - priv->bridges[priv->num_bridges++] = msm_dsi->bridge; priv->connectors[priv->num_connectors++] = msm_dsi->connector; diff --git a/drivers/gpu/drm/msm/dsi/dsi.h b/drivers/gpu/drm/msm/dsi/dsi.h index 4de771d6f0be8..ca6fde9749b4b 100644 --- a/drivers/gpu/drm/msm/dsi/dsi.h +++ b/drivers/gpu/drm/msm/dsi/dsi.h @@ -89,7 +89,7 @@ struct drm_connector *msm_dsi_manager_connector_init(u8 id); struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id); int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg); bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len); -void msm_dsi_manager_setup_encoder(int id); +void msm_dsi_manager_attach_dsi_device(int id); int msm_dsi_manager_register(struct msm_dsi *msm_dsi); void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi); bool msm_dsi_manager_validate_current_config(u8 id); diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c index 11ae5b8444c32..2ceeb723898d8 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_host.c +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c @@ -1608,6 +1608,8 @@ static int dsi_host_attach(struct mipi_dsi_host *host, msm_host->format = dsi->format; msm_host->mode_flags = dsi->mode_flags; + msm_dsi_manager_attach_dsi_device(msm_host->id); + /* Some gpios defined in panel DT need to be controlled by host */ ret = dsi_host_init_panel_gpios(msm_host, &dsi->dev); if (ret) diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c index 4b363bd7ddfff..23b020ada860d 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_manager.c +++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c @@ -231,7 +231,7 @@ static bool dsi_mgr_is_cmd_mode(struct msm_dsi *msm_dsi) return !(host_flags & MIPI_DSI_MODE_VIDEO); } -void msm_dsi_manager_setup_encoder(int id) +static void msm_dsi_manager_setup_encoder(int id) { struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); struct msm_drm_private *priv = msm_dsi->dev->dev_private; @@ -272,7 +272,12 @@ static int msm_dsi_manager_panel_init(struct drm_connector *conn, u8 id) return PTR_ERR(panel); } - if (!panel || !IS_DUAL_DSI()) + if (!panel) + return 0; + + msm_dsi_manager_setup_encoder(id); + + if (!IS_DUAL_DSI()) goto out; drm_object_attach_property(&conn->base, @@ -802,6 +807,34 @@ bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len) return true; } +void msm_dsi_manager_attach_dsi_device(int id) +{ + struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id); + struct drm_device *dev; + + /* + * drm_device pointer is assigned to msm_dsi only in the modeset_init + * path. If mipi_dsi_attach() happens in DSI driver's probe path + * (generally the case when we're connected to a drm_panel of the type + * mipi_dsi_device), this would be NULL. In such cases, try to set the + * encoder mode in the DSI connector's detect() op. + * + * msm_dsi pointer is assigned to a valid dsi device only when + * msm_dsi_manager_register() succeeds. When panel hasnt probed yet + * dsi_mgr_setup_components() could potentially return -EDEFER and + * assign the msm_dsi->dev to NULL. When the panel now probes and calls + * mipi_dsi_attach(), this will call msm_dsi_manager_attach_dsi_device() + * which will result in a NULL pointer dereference + */ + + dev = msm_dsi ? msm_dsi->dev : NULL; + + if (!dev) + return; + + msm_dsi_manager_setup_encoder(id); +} + int msm_dsi_manager_register(struct msm_dsi *msm_dsi) { struct msm_dsi_manager *msm_dsim = &msm_dsim_glb;