From patchwork Tue Sep 11 09:34:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 11294 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id A4FAF23EFE for ; Tue, 11 Sep 2012 09:38:10 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 53987A1804C for ; Tue, 11 Sep 2012 09:38:10 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id k11so513911iea.11 for ; Tue, 11 Sep 2012 02:38:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=orvonyQMlcMCSKo1mH/RfzVoKlz5AiM5jIsnudyLFNE=; b=MXpu0s+t85GptNGxhRgIKpTB+rhZsq6oYp7CkLjoScJwdRqEc5x6EW8vQUefQpckJm kAl2eOJLfpUxaFiZQz99aQXO40JbRyU6bKndk6zJGdIW1yqhKXHQs2vD5cSDxDTEnKIe 7Iz0awXXlfnLO2olsmxvfWkt5tOlJDk4TN9Sl0s/80jTwJY//ojV3uU9XbpIryVYaRHV uaOm8hVJeB6vlyHlTV4Gp9nBQfSBRhkCHxSab9UOlvVGprC6Yfd8M4NO2qpK7lktuA1m sLLPnHLOo7Q6jZi3VyRSl4XVTWxEsJTVhoBVJmc1tvhgpuMHTYgKctYsjovPhODOTx3i Lz/Q== Received: by 10.50.207.106 with SMTP id lv10mr16063372igc.0.1347356290111; Tue, 11 Sep 2012 02:38:10 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp4772igc; Tue, 11 Sep 2012 02:38:09 -0700 (PDT) Received: by 10.68.212.70 with SMTP id ni6mr10534000pbc.22.1347356289478; Tue, 11 Sep 2012 02:38:09 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id qd8si24203454pbc.127.2012.09.11.02.38.09 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 11 Sep 2012 02:38:09 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) smtp.mail=anton.vorontsov@linaro.org Received: by pbcmd12 with SMTP id md12so636945pbc.37 for ; Tue, 11 Sep 2012 02:38:09 -0700 (PDT) Received: by 10.66.85.70 with SMTP id f6mr26190764paz.7.1347356289150; Tue, 11 Sep 2012 02:38:09 -0700 (PDT) Received: from localhost (c-71-204-165-222.hsd1.ca.comcast.net. [71.204.165.222]) by mx.google.com with ESMTPS id wn1sm3321338pbc.57.2012.09.11.02.38.07 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 11 Sep 2012 02:38:08 -0700 (PDT) From: Anton Vorontsov To: Andrew Morton , Russell King , Jason Wessel , Greg Kroah-Hartman , Alan Cox Cc: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Colin Cross , Brian Swetland , John Stultz , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, patches@linaro.org, kernel-team@android.com, kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Subject: [PATCH 04/12] tty/serial/core: Introduce poll_init callback Date: Tue, 11 Sep 2012 02:34:58 -0700 Message-Id: <1347356106-25368-4-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.11.5 In-Reply-To: <20120911093042.GA12471@lizard> References: <20120911093042.GA12471@lizard> X-Gm-Message-State: ALoCoQkVvAz6YbRfpW/2Y0bM5vV6r9gFWWlxnvoj7Xx2cIp/eyJj2ZrGUfj3Chc5iKVMEBfLkRxM It was noticed that polling drivers (like KGDB) are not able to use serial ports if the ports were not previously initialized via console. I.e. when booting with console=ttyAMA0 kgdboc=ttyAMA0, everything works fine, but with console=ttyFOO kgdboc=ttyAMA0, the kgdboc doesn't work. This is because we don't initialize the hardware. Calling ->startup() is not an option, because drivers request interrupts there, and drivers fail to handle situations when tty isn't opened with interrupts enabled. So, we have to implement a new callback (actually, tty_ops already have a similar callback), which does everything needed to initialize just the hardware. Signed-off-by: Anton Vorontsov --- drivers/tty/serial/serial_core.c | 17 +++++++++++++++++ include/linux/serial_core.h | 1 + 2 files changed, 18 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 046279c..dcb2d5a 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2129,6 +2129,7 @@ static int uart_poll_init(struct tty_driver *driver, int line, char *options) int bits = 8; int parity = 'n'; int flow = 'n'; + int ret; if (!state || !state->uart_port) return -1; @@ -2137,6 +2138,22 @@ static int uart_poll_init(struct tty_driver *driver, int line, char *options) if (!(port->ops->poll_get_char && port->ops->poll_put_char)) return -1; + if (port->ops->poll_init) { + struct tty_port *tport = &state->port; + + ret = 0; + mutex_lock(&tport->mutex); + /* + * We don't set ASYNCB_INITIALIZED as we only initialized the + * hw, e.g. state->xmit is still uninitialized. + */ + if (!test_bit(ASYNCB_INITIALIZED, &tport->flags)) + ret = port->ops->poll_init(port); + mutex_unlock(&tport->mutex); + if (ret) + return ret; + } + if (options) { uart_parse_options(options, &baud, &parity, &bits, &flow); return uart_set_options(port, NULL, baud, parity, bits, flow); diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 7cf0b68..822c887 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -274,6 +274,7 @@ struct uart_ops { int (*verify_port)(struct uart_port *, struct serial_struct *); int (*ioctl)(struct uart_port *, unsigned int, unsigned long); #ifdef CONFIG_CONSOLE_POLL + int (*poll_init)(struct uart_port *); void (*poll_put_char)(struct uart_port *, unsigned char); int (*poll_get_char)(struct uart_port *); #endif