Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp446388ybz; Fri, 24 Apr 2020 03:15:46 -0700 (PDT) X-Google-Smtp-Source: APiQypKr3EbZpQiPs/EGlB96Psjxq+jNLZvSMs9xfi6Jp/2eLmN5twbAnzvccgjFUlqjGD9ZlMCP X-Received: by 2002:aa7:cf94:: with SMTP id z20mr6212574edx.302.1587723346045; Fri, 24 Apr 2020 03:15:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587723346; cv=none; d=google.com; s=arc-20160816; b=tBHE2+ny8XrBEyQJWEuymgU6M/tjx13HHa8fjvu92j6d+9eFEL8Z4mqkOoM7DKUAL6 CV94nO+4ccco6O5DCyNydWeAfi/erekveMoLIP2d5vcbW71YtpSyJkJXwetFHXRjpZNj 64WTPLIUENd3aneUumfV9MLKTPxM0yzmkkOngwUeMQ9gD/ouC2SCCkAW+eZz2VGYqYgH kSOUtZSv5OWuXIl6NMAWx3RoeFd9qmCcy6zMIusLCoqAgRAfr6GfoTXwpjwlYwul+F1z tgELWlepQjFEQLL9y+ueH+dvnHztj3FeKwaIQHx0cp+IAMvs3ikvBSB8PosO+8sbB3dy coKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ZjzQSYK/IyLxZafwcBa3oQLq8j0LeJ0VAvQG1IbtSsk=; b=QdGo5pPXYlF8YodrE/gIx36B4CKfUvmGcK+VpUZWZ0jRJPWyuO+SPRTLm8UO1h47QI DGn6UUNxw9GdY/sTMIVVoI4Lq+30XyQP5TUo6cyApLTIRxlPQDe2FYW6qOKlaKg3phAU VmOYOXsNFiua2aHtQUa/fOuQzQ9IVZSAfQ34nwKlzDBpKKXT1FIZbYUQQIL3On//h4tj hix7RqeBYgfOb0WeQob/gykwSrWNDnpEIa7dBs+4mLpH7AB4jHGuD5l9FWjyUfTUGKTR SneRM3alnbJiOgiX9jeR9OPdkVssUhL4cUIspylOrHkePL+153Od68WjnNlP9el9tsVL Hn1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nJpiIDKi; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o19si3095189edz.588.2020.04.24.03.15.22; Fri, 24 Apr 2020 03:15:46 -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=@linaro.org header.s=google header.b=nJpiIDKi; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726958AbgDXKNg (ORCPT + 99 others); Fri, 24 Apr 2020 06:13:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726939AbgDXKNa (ORCPT ); Fri, 24 Apr 2020 06:13:30 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92E95C09B046 for ; Fri, 24 Apr 2020 03:13:30 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id g12so10036930wmh.3 for ; Fri, 24 Apr 2020 03:13:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ZjzQSYK/IyLxZafwcBa3oQLq8j0LeJ0VAvQG1IbtSsk=; b=nJpiIDKisp4o81gcE2OE3PWQ4HjSno7DC9r80HSP9jRZj7oSRNnoOqH+Fm9xb8UYCZ Wmk1qocpOudxfgvO6KHvAnun/O4FaekVyRFA2z4In3z8cONLN+unHmUCW4XzxSaZJBjc +6nOwtx6/o9v5JDmPnVyB9wx3tTUVvEqtHY4VhETf7Q7p2WrPKPYwjoSm0HnbkpnKS0V WlWv8hpgzzbNGD/Za+R2jBW1j1YYhNEZ9yPLMN8qpAlkQY1vxu0nnDP5J3vDm5YQiC6G QsT6iU0KSCintcgbl2xU2k28mHQyJTVm0QOh4Ny3Hmse36LKBFp249aHQ116xAA8h2qb dVbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZjzQSYK/IyLxZafwcBa3oQLq8j0LeJ0VAvQG1IbtSsk=; b=AjS9sgRujdJZLNB8X2C+U1RAhJ7Kj4cm6ScKTsmzXCBA4PVQrnWK/JGsGlKD/eWLsN 5QZOgNJ/AKvSQHsYA9oj3vD/kZcTkHglR2SzF40CCm4EjIK4xlV39VucYrbGA43G5DZy UATp7DLT5ye2AvKJW+KQbZk7r6cM0LhC9cp+Ef3gnE2Qstf7d89mREllHgziAuDrrNpG Kw4XkMR5NGKW0qZiYs6T0fcMZJlkiJKFLQtudPToNTJ4DS8K/HCqxgXBAd8AcIHZT0+c H2oD9oYp1cKgcJT9TpJ3yt6iZA+9lLqhTDYcYZeLii76d5Uf9HOi5S2/L2Ol/6E0jvYR dCjQ== X-Gm-Message-State: AGi0PuboOyAV2OBobKAVWz/kQ//sKJFEILotTaCsV4QuzUQ2NWYrWQIG C24TFVeejDZa1k/LL1BGRHJ7MA== X-Received: by 2002:a1c:66d5:: with SMTP id a204mr9365795wmc.69.1587723209114; Fri, 24 Apr 2020 03:13:29 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id f8sm7617423wrm.14.2020.04.24.03.13.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 03:13:28 -0700 (PDT) Date: Fri, 24 Apr 2020 11:13:25 +0100 From: Daniel Thompson To: Sumit Garg Cc: Douglas Anderson , jason.wessel@windriver.com, Greg Kroah-Hartman , Mark Rutland , Linux Doc Mailing List , Peter Zijlstra , catalin.marinas@arm.com, bjorn.andersson@linaro.org, Nadav Amit , hpa@zytor.com, Mauro Carvalho Chehab , will@kernel.org, Matt Mullins , Jonathan Corbet , frowand.list@gmail.com, x86@kernel.org, jinho lim , agross@kernel.org, Pawan Gupta , linux-arm-kernel , linux-serial@vger.kernel.org, kgdb-bugreport@lists.sourceforge.net, Borislav Petkov , Dave Martin , Masami Hiramatsu , Arnd Bergmann , linux-arm-msm@vger.kernel.org, jslaby@suse.com, Alexios Zavras , bp@alien8.de, tglx@linutronix.de, mingo@redhat.com, Allison Randal , Juergen Gross , linux-usb@vger.kernel.org, Linux Kernel Mailing List , James Morse , "Eric W. Biederman" , Andrew Morton , Rick Edgecombe , Enrico Weigelt Subject: Re: [PATCH v2 0/9] kgdb: Support late serial drivers; enable early debug w/ boot consoles Message-ID: <20200424101325.fvsxn32qzfocz7hb@holly.lan> References: <20200421211447.193860-1-dianders@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 24, 2020 at 02:02:51PM +0530, Sumit Garg wrote: > Hi Doug, > > On Wed, 22 Apr 2020 at 02:45, Douglas Anderson wrote: > > > > This whole pile of patches was motivated by me trying to get kgdb to > > work properly on a platform where my serial driver ended up being hit > > by the -EPROBE_DEFER virus (it wasn't practicing social distancing > > from other drivers). Specifically my serial driver's parent device > > depended on a resource that wasn't available when its probe was first > > called. It returned -EPROBE_DEFER which meant that when "kgdboc" > > tried to run its setup the serial driver wasn't there. Unfortunately > > "kgdboc" never tried again, so that meant that kgdb was disabled until > > I manually enalbed it via sysfs. > > > > While I could try to figure out how to get around the -EPROBE_DEFER > > somehow, the above problems could happen to anyone and -EPROBE_DEFER > > is generally considered something you just have to live with. In any > > case the current "kgdboc" setup is a bit of a race waiting to happen. > > I _think_ I saw during early testing that even adding a msleep() in > > the typical serial driver's probe() is enough to trigger similar > > issues. > > > > I decided that for the above race the best attitude to get kgdb to > > register at boot was probably "if you can't beat 'em, join 'em". > > Thus, "kgdboc" now jumps on the -EPROBE_DEFER bandwagon (now that my > > driver uses it it's no longer a virus). It does so a little awkwardly > > because "kgdboc" hasn't normally had a "struct device" associated with > > it, but it's really not _that_ ugly to make a platform device and > > seems less ugly than alternatives. > > > > Unfortunately now on my system the debugger is one of the last things > > to register at boot. That's OK for debugging problems that show up > > significantly after boot, but isn't so hot for all the boot problems > > that I end up debugging. This motivated me to try to get something > > working a little earlier. > > > > My first attempt was to try to get the existing "ekgdboc" to work > > earlier. I tried that for a bit until I realized that it needed to > > work at the tty layer and I couldn't find any serial drivers that > > managed to register themselves to the tty layer super early at boot. > > The only documented use of "ekgdboc" is "ekgdboc=kbd" and that's a bit > > of a special snowflake. Trying to get my serial driver and all its > > dependencies to probe normally and register the tty driver super early > > at boot seemed like a bad way to go. In fact, all the complexity > > needed to do something like this is why the system already has a > > special concept of a "boot console" that lives only long enough to > > transition to the normal console. > > > > Leveraging the boot console seemed like a good way to go and that's > > what this series does. I found that consoles could have a read() > > function, though I couldn't find anyone who implemented it. I > > implemented it for two serial drivers for the devices I had easy > > access to, making the assumption that for boot consoles that we could > > assume read() and write() were polling-compatible (seems sane I > > think). > > > > Now anyone who makes a small change to their serial driver can easily > > enable early kgdb debugging! > > > > The devices I had for testing were: > > - arm32: rk3288-veyron-jerry > > - arm64: rk3399-gru-kevin > > - arm64: qcom-sc7180-trogdor (not mainline yet) > > > > These are the devices I tested this series on. I tried to test > > various combinations of enabling/disabling various options and I > > hopefully caught the corner cases, but I'd appreciate any extra > > testing people can do. > > earlycon_kgdboc sounds like a really cool feature. So I gave it a try > on my arm64 machine (Developerbox) and it works like a charm. So for > patch 6/9 you can add: > > Tested-by: Sumit Garg > > Plus, in order to enable earlycon_kgdboc on Developerbox I had to > implement the read() function in the early console driver for > amba-pl011 (see patch [1]). It would be great if you could pick that > patch [1] too as part of this series. > > [1] https://lkml.org/lkml/2020/4/24/173 I think PL011 support is also useful for getting this feature integrated into the test suite too! Daniel. > > -Sumit > > > Notably I didn't test on x86, but (I think) I > > didn't touch much there so I shouldn't have broken anything. > > > > When testing I found a few problems with actually dropping into the > > debugger super early on arm and arm64 devices. Patches in this series > > should help with this. For arm I just avoid dropping into the > > debugger until a little later and for arm64 I actually enable > > debugging super early. > > > > I realize that bits of this series might feel a little hacky, though > > I've tried to do things in the cleanest way I could without overly > > interferring with the rest of the kernel. If you hate the way I > > solved a problem I would love it if you could provide guidance on how > > you think I could solve the problem better. > > > > This series (and my comments / documentation / commit messages) are > > now long enough that my eyes glaze over when I try to read it all over > > to double-check. I've nontheless tried to double-check it, but I'm > > pretty sure I did something stupid. Thank you ahead of time for > > pointing it out to me so I can fix it in v3. If somehow I managed to > > not do anything stupid (really?) then thank you for double-checking me > > anyway. > > > > Changes in v2: > > - ("kgdb: Disable WARN_CONSOLE_UNLOCKED for all kgdb") new for v2. > > - ("Revert "kgdboc: disable the console lock when in kgdb"") new for v2. > > - Assumes we have ("kgdb: Disable WARN_CONSOLE_UNLOCKED for all kgdb") > > - Fix kgdbts, tty/mips_ejtag_fdc, and usb/early/ehci-dbgp > > > > Douglas Anderson (9): > > kgdb: Disable WARN_CONSOLE_UNLOCKED for all kgdb > > Revert "kgdboc: disable the console lock when in kgdb" > > kgdboc: Use a platform device to handle tty drivers showing up late > > kgdb: Delay "kgdbwait" to dbg_late_init() by default > > arm64: Add call_break_hook() to early_brk64() for early kgdb > > kgdboc: Add earlycon_kgdboc to support early kgdb using boot consoles > > Documentation: kgdboc: Document new earlycon_kgdboc parameter > > serial: qcom_geni_serial: Support earlycon_kgdboc > > serial: 8250_early: Support earlycon_kgdboc > > > > .../admin-guide/kernel-parameters.txt | 20 ++ > > Documentation/dev-tools/kgdb.rst | 14 + > > arch/arm64/include/asm/debug-monitors.h | 2 + > > arch/arm64/kernel/debug-monitors.c | 2 +- > > arch/arm64/kernel/kgdb.c | 5 + > > arch/arm64/kernel/traps.c | 3 + > > arch/x86/kernel/kgdb.c | 5 + > > drivers/misc/kgdbts.c | 2 +- > > drivers/tty/mips_ejtag_fdc.c | 2 +- > > drivers/tty/serial/8250/8250_early.c | 23 ++ > > drivers/tty/serial/kgdboc.c | 262 ++++++++++++++++-- > > drivers/tty/serial/qcom_geni_serial.c | 32 +++ > > drivers/usb/early/ehci-dbgp.c | 2 +- > > include/linux/kgdb.h | 25 +- > > kernel/debug/debug_core.c | 48 +++- > > 15 files changed, 400 insertions(+), 47 deletions(-) > > > > -- > > 2.26.1.301.g55bc3eb7cb9-goog > > > > > > _______________________________________________ > > linux-arm-kernel mailing list > > linux-arm-kernel@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel