Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3614475ybk; Tue, 19 May 2020 08:51:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzh1hrT0jX6v4zQqBYeeujboqw5yMrc+MnWwMz2W50almPoCuPXfmyBbrDGB5L2twBYJugE X-Received: by 2002:a17:906:b299:: with SMTP id q25mr1284233ejz.448.1589903471414; Tue, 19 May 2020 08:51:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589903471; cv=none; d=google.com; s=arc-20160816; b=UZPueD8oR5do+4Z9rqAqYmGQJANmTam8P5M1YdDq8FzQ23DOP819L7QlYbfFzmSAdK mJuHk7C1QEisoftlabkmeW4kqkNBmhq60HK9uRXXX5KbLLSdtqtFiRcbDpNrxE7ZvCot 44bf9l9oB/V5ydB5UZZLspud+qEFVD98hIl83FdjyB62/Y0QMRvRhFDfHGsw358Bqrj8 k+yKhzkpmpgxONzf2gsA/zInafXuHuYUdD7fvfSD4/ipbB1e6aKKXHzOpW3Xdisf/6m4 F2BdhRgTniW3ihHKvAy6Fe0OGJB5TFYrvDMCr033f5FnDAuc7jgJJsd2Oplx3st7Tmvg 0M1A== 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=npj6nyuWQ54ZRzukHs7PaMjCvPNDE9Mt94DLOgYmdAM=; b=EHbDneHWRAILa6H5uuM5NZz35PEo3yyk+x/pwhSk77rGGhQH62olAtfNDMC/xetiYI P0zZF4pfkjJfhhBEI7gfLiMkdRhbpA1HGkxxntz2CPucIHGNMVnOP22DLwnKcDZIr7Ws eM1ZnNF6rcmN67aWSUqdhp8EbYdjYrQUCnUYX/heBM1nr79Kawzy+vWUr7BQvOaFEB/e fASgLtEJiNmjTiDHyOZ1ZOyUyt+CRuB75XpNip/WKqyuQR4Q8KScVtd2JW2fWKL/QQRl buEvxuoNrnwYWG7I9dHKvlMLZWXOaPWa05jAib5BH/QPbsvOgCk1tX/YXAVuIHQT10GK DYEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=P0+mae6a; 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 qx12si72962ejb.340.2020.05.19.08.50.47; Tue, 19 May 2020 08:51:11 -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=P0+mae6a; 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 S1729297AbgESPsr (ORCPT + 99 others); Tue, 19 May 2020 11:48:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729007AbgESPsq (ORCPT ); Tue, 19 May 2020 11:48:46 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95EEDC08C5C1 for ; Tue, 19 May 2020 08:48:46 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id p30so589364pgl.11 for ; Tue, 19 May 2020 08:48:46 -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=npj6nyuWQ54ZRzukHs7PaMjCvPNDE9Mt94DLOgYmdAM=; b=P0+mae6a84cR5xUqIaEO+Q0bl2fCnvLeySFo+ugO3JyjssDIgkmsmpUbWGMOo30eLp 4la4jakE5roQ8jjlKA1FzIi2twmGQr7jNmyR4G/fELC21PiyyV8enb6i9lBDEIrIB2rV AVTHOA5HszSMzkwJ81gPBz5iiLnARXbKwKDDs= 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=npj6nyuWQ54ZRzukHs7PaMjCvPNDE9Mt94DLOgYmdAM=; b=Pcr/rNsvpHsTQxIvTIfOEPTDoJMSBKZXUH4HAgSsAFogdYQuqIbt3dIbEqoBCpic61 rycYWzDkR6GAgm/eAxHInpderbTyeN8xwOqbRTJROnTahFqWnirnmZ1x3x3WiluWVgxH 9Bh5q2T7Pyer/E4pwL5129gUWg6RlMsnW0BUL50gLGjxZxGzGtm+RoNWT+OaVLgprR4R 7LyYlsJ7LMjElZvSeAAMXjgARH690I6g1IRvrRtBJxYcd5/e69Uq5SNp+8SPXzk8FMBR R50gAiNl/y7GO8a64b6oMQ3ZLdz1IOuUopyhDsswwIrucKPiPR1X/Dth9wPIkxEYsG09 AcOw== X-Gm-Message-State: AOAM532c/oZ+GrT6qE58i7xpMCch7vIagESdrPB89Ek1N1B+G47P2tuK vc4xtUuVrG0IHKCB3iwuomRrkA== X-Received: by 2002:aa7:9aa8:: with SMTP id x8mr11608662pfi.182.1589903326036; Tue, 19 May 2020 08:48:46 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id c2sm9506pjg.51.2020.05.19.08.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 08:48:45 -0700 (PDT) From: Douglas Anderson To: Stephen Rothwell , Daniel Thompson , Jason Wessel Cc: linux-next@vger.kernel.org, sumit.garg@linaro.org, Douglas Anderson , Greg Kroah-Hartman , Jiri Slaby , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH] kgdboc: Disable all the early code when kgdboc is a module Date: Tue, 19 May 2020 08:44:02 -0700 Message-Id: <20200519084345.1.I91670accc8a5ddabab227eb63bb4ad3e2e9d2b58@changeid> X-Mailer: git-send-email 2.26.2.761.g0e0b3e54be-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 kgdboc is compiled as a module all of the "ekgdboc" and "kgdb_earlycon" code isn't useful and, in fact, breaks compilation. This is because early_param() isn't defined for modules and that's how this code gets configured. It turns out that this was broken by commit eae3e19ca930 ("kgdboc: Remove useless #ifdef CONFIG_KGDB_SERIAL_CONSOLE in kgdboc") and then made worse by commit 220995622da5 ("kgdboc: Add kgdboc_earlycon to support early kgdb using boot consoles"). I guess the #ifdef wasn't so useless, even if it wasn't obvious why it was useful. When kgdboc was compiled as a module only "CONFIG_KGDB_SERIAL_CONSOLE_MODULE" was defined, not "CONFIG_KGDB_SERIAL_CONSOLE". That meant that the old module. Let's basically do the same thing that the old code (pre-removal of the #ifdef) did but use "IS_BUILTIN(CONFIG_KGDB_SERIAL_CONSOLE)" to make it more obvious what the point of the check is. We'll fix kgdboc_earlycon in a similar way. Fixes: 220995622da5 ("kgdboc: Add kgdboc_earlycon to support early kgdb using boot consoles") Fixes: eae3e19ca930 ("kgdboc: Remove useless #ifdef CONFIG_KGDB_SERIAL_CONSOLE in kgdboc") Reported-by: Stephen Rothwell Signed-off-by: Douglas Anderson --- drivers/tty/serial/kgdboc.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c index 34b5e91dd245..fa6f7a3e73b9 100644 --- a/drivers/tty/serial/kgdboc.c +++ b/drivers/tty/serial/kgdboc.c @@ -43,9 +43,11 @@ static int kgdb_tty_line; static struct platform_device *kgdboc_pdev; +#if IS_BUILTIN(CONFIG_KGDB_SERIAL_CONSOLE) static struct kgdb_io kgdboc_earlycon_io_ops; static struct console *earlycon; static int (*earlycon_orig_exit)(struct console *con); +#endif /* IS_BUILTIN(CONFIG_KGDB_SERIAL_CONSOLE) */ #ifdef CONFIG_KDB_KEYBOARD static int kgdboc_reset_connect(struct input_handler *handler, @@ -140,10 +142,19 @@ static void kgdboc_unregister_kbd(void) #define kgdboc_restore_input() #endif /* ! CONFIG_KDB_KEYBOARD */ -static void cleanup_kgdboc(void) +#if IS_BUILTIN(CONFIG_KGDB_SERIAL_CONSOLE) +static void cleanup_earlycon(void) { if (earlycon) kgdb_unregister_io_module(&kgdboc_earlycon_io_ops); +} +#else /* !IS_BUILTIN(CONFIG_KGDB_SERIAL_CONSOLE) */ +static inline void cleanup_earlycon(void) { } +#endif /* !IS_BUILTIN(CONFIG_KGDB_SERIAL_CONSOLE) */ + +static void cleanup_kgdboc(void) +{ + cleanup_earlycon(); if (configured != 1) return; @@ -388,6 +399,7 @@ static struct kgdb_io kgdboc_io_ops = { .post_exception = kgdboc_post_exp_handler, }; +#if IS_BUILTIN(CONFIG_KGDB_SERIAL_CONSOLE) static int kgdboc_option_setup(char *opt) { if (!opt) { @@ -544,6 +556,7 @@ static int __init kgdboc_earlycon_init(char *opt) } early_param("kgdboc_earlycon", kgdboc_earlycon_init); +#endif /* IS_BUILTIN(CONFIG_KGDB_SERIAL_CONSOLE) */ module_init(init_kgdboc); module_exit(exit_kgdboc); -- 2.26.2.761.g0e0b3e54be-goog