History

kgdb: Don't call the deinit under spinlock

When I combined kgdboc_earlycon with an inflight patch titled ("soc: qcom-geni-se: Add interconnect support to fix earlycon crash") [1] things went boom. Specifically I got a crash during the transition between kgdboc_earlycon and the main kgdboc that looked like this: Call trace: __schedule_bug+0x68/0x6c __schedule+0x75c/0x924 schedule+0x8c/0xbc schedule_timeout+0x9c/0xfc do_wait_for_common+0xd0/0x160 wait_for_completion_timeout+0x54/0x74 rpmh_write_batch+0x1fc/0x23c qcom_icc_bcm_voter_commit+0x1b4/0x388 qcom_icc_set+0x2c/0x3c apply_constraints+0x5c/0x98 icc_set_bw+0x204/0x3bc icc_put+0x30/0xf8 geni_remove_earlycon_icc_vote+0x6c/0x9c qcom_geni_serial_earlycon_exit+0x10/0x1c kgdboc_earlycon_deinit+0x38/0x58 kgdb_register_io_module+0x11c/0x194 configure_kgdboc+0x108/0x174 kgdboc_probe+0x38/0x60 platform_drv_probe+0x90/0xb0 really_probe+0x130/0x2fc ... The problem was that we were holding the "kgdb_registration_lock" while calling into code that didn't expect to be called in spinlock context. Let's slightly defer when we call the deinit code so that it's not done under spinlock. NOTE: this does mean that the "deinit" call of the old kgdb IO module is now made _after_ the init of the new IO module, but presumably that's OK. [1] https://lkml.kernel.org/r/1588919619-21355-3-git-send-email-akashast@codeaurora.org

Douglas Anderson committed 6 years ago

Commit b1350131 parent 1feb48b1 file · +3 −2Browse files

Showing the changes to kernel/debug/debug_core.c (1 of 1 file). Show all

Unified · Split

kernel/debug/debug_core.c+3−2
@@ -1089,7 +1089,6 @@ int kgdb_register_io_module(struct kgdb_io *new_dbg_io_ops) · 1088 unmodified lines
1089 }1089 }
1090 pr_info("Replacing I/O driver %s with %s\n",1090 pr_info("Replacing I/O driver %s with %s\n",
1091 old_dbg_io_ops->name, new_dbg_io_ops->name);1091 old_dbg_io_ops->name, new_dbg_io_ops->name);
1092 old_dbg_io_ops->deinit();
1093 }1092 }
1094 1093
1095 if (new_dbg_io_ops->init) {1094 if (new_dbg_io_ops->init) {
@@ -1104,8 +1103,10 @@ int kgdb_register_io_module(struct kgdb_io *new_dbg_io_ops) · 8 unmodified lines
1104 1103
1105 spin_unlock(&kgdb_registration_lock);1104 spin_unlock(&kgdb_registration_lock);
1106 1105
1107 if (old_dbg_io_ops)1106 if (old_dbg_io_ops) {
1107 old_dbg_io_ops->deinit();
1108 return 0;1108 return 0;
1109 }
1109 1110
1110 pr_info("Registered I/O driver %s\n", new_dbg_io_ops->name);1111 pr_info("Registered I/O driver %s\n", new_dbg_io_ops->name);
1111 1112