Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp312337ybm; Tue, 26 May 2020 17:55:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvK9eCFoWnbkmf2yemhMBi4ae3rK3YbdWWEihfGlVkWoJAFpJaIN5m3XblJcNanAG+HhwX X-Received: by 2002:a17:906:edb6:: with SMTP id sa22mr3605768ejb.393.1590540904975; Tue, 26 May 2020 17:55:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590540904; cv=none; d=google.com; s=arc-20160816; b=LUihPNQflCuKRtNNKByZth/sr9o4RNQ9v+KfXNk+tZr7rEu1gJ4WiiL49U5cdtphjn XXC3ONr5jg/0GX3u0pDC6UYWgLEOVFxeKqimw76aCTGeY1iGDSa28e5yZPzqxyehKfem dtP1aZnArAHtgFco5c/+AvtwxC48PFNI1ZsZSe88afrO35oldLOXBXlST+v5NYSe4hLK Q5aqs+ygGKeI+Z/Q4ZhDSPjFsWPLvJ3tC395ntPSxKIMcgrFKG4b2qwN5yG1yRubexgH vj3dSseCYxKXh8Fz0H6yUNLH+toT+2crTlUx/Q2GyoLC/WpmJPgSX86H+lOjr7DkSxR4 rjgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=mGisQOmV53APODapZGkiDQDW8pXpGOOkL2XHOF+ONZg=; b=vCxEM9coMs2qVH8o3Nhfj+QN9oxcXFB1+fFSsdMVMCGxaGk6GYkz1N8fcUs3VA0M3H 6HCDgiUX1JYTz05lwhAm7rXw5UaxqP2lsZXI74KhtbBNUGU/fjHqgfmTfdIIIz8dpkBW wqj5xLaI0RQaSsuGywITYGKZf8ozm0l29f7C+NwUFH1EGOs6URLcgy1mgScy6Wj1ZPfO SWNRhU8m4juJa4TmkiMHktLr+Q0iG1hLz6apg9rbPkAEwrLv5AZLli27XO9L1b9qhn8a 52105xCGCNYk4XfdPeAatopU8gQTvSRdTYsViHOwvdQcFO83bl2qA0f47LjVXT0IFFFk W7YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KK2BAaIA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k26si864654ejv.260.2020.05.26.17.54.42; Tue, 26 May 2020 17:55:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KK2BAaIA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404010AbgEZVUd (ORCPT + 99 others); Tue, 26 May 2020 17:20:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403878AbgEZVUc (ORCPT ); Tue, 26 May 2020 17:20:32 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85D90C061A0F for ; Tue, 26 May 2020 14:20:32 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id e11so9793678pfn.3 for ; Tue, 26 May 2020 14:20:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mGisQOmV53APODapZGkiDQDW8pXpGOOkL2XHOF+ONZg=; b=KK2BAaIAJ5Yi+TjwvE6MIde1Xjru0T5NibzAPzJhO8RKPqzn8GcPkr2VIoE6xPH0+U FGSplpDbAP61D36YAYEzx+L9yoZlEuUje6O2N5qNB5tgNN7uaWi4EKhtqhAialpU+Hmo ct7qVgSi0UawvYteoDUGFGo1alXKRElYtmWgU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mGisQOmV53APODapZGkiDQDW8pXpGOOkL2XHOF+ONZg=; b=ApnSnOGSUh+bYh5GZwjbNfBxIWddUEJ8QxlnYBqd5uVAUDHRg6lbFancAmw76F/jck ArP61Ofe01KuBbrLTMrL55UXAYixQ6WmPkBqyF03Yh+Mib/I1+KIpGuJyHz0DKzla3uy Gv6WHxUNYTrkM6/pYkPe/iRTCVGOek2ZyqTDITXkWYRsMW7g/cHkfoNFzZ4FltuRTrE0 /wQVSe4as4u7o8tqtEPLCmNYoWFqKlz6mWwrxWvRR9dn1fwrwoHPYyUoCQObU+ZcAy+p OTFKqx83fPnjzSVtFKJXQzjLtpD3lF6eegxtepcHXlUKguWe7GBijF2WR63jpdQTsG3p OBYg== X-Gm-Message-State: AOAM533NhloL9Jh/CRYO2SvgLUGCIL+QqmNAwgcsNnZ/nwxMjozhAGlS 3uvSrO7ObU+TgwwATVf5xRvB9w== X-Received: by 2002:aa7:9464:: with SMTP id t4mr696239pfq.52.1590528032045; Tue, 26 May 2020 14:20:32 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id j124sm382333pfd.116.2020.05.26.14.20.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 14:20:31 -0700 (PDT) From: Douglas Anderson To: Jason Wessel , Daniel Thompson Cc: sumit.garg@linaro.org, akashast@codeaurora.org, mka@chromium.org, Douglas Anderson , Greg Kroah-Hartman , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH] kgdb: Don't call the deinit under spinlock Date: Tue, 26 May 2020 14:20:06 -0700 Message-Id: <20200526142001.1.I523dc33f96589cb9956f5679976d402c8cda36fa@changeid> X-Mailer: git-send-email 2.27.0.rc0.183.gde8f92d652-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Fixes: 220995622da5 ("kgdboc: Add kgdboc_earlycon to support early kgdb using boot consoles") Signed-off-by: Douglas Anderson --- kernel/debug/debug_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 4d59aa907fdc..ef94e906f05a 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -1089,7 +1089,6 @@ int kgdb_register_io_module(struct kgdb_io *new_dbg_io_ops) } pr_info("Replacing I/O driver %s with %s\n", old_dbg_io_ops->name, new_dbg_io_ops->name); - old_dbg_io_ops->deinit(); } if (new_dbg_io_ops->init) { @@ -1104,8 +1103,10 @@ int kgdb_register_io_module(struct kgdb_io *new_dbg_io_ops) spin_unlock(&kgdb_registration_lock); - if (old_dbg_io_ops) + if (old_dbg_io_ops) { + old_dbg_io_ops->deinit(); return 0; + } pr_info("Registered I/O driver %s\n", new_dbg_io_ops->name); -- 2.27.0.rc0.183.gde8f92d652-goog