From patchwork Mon Sep 10 04:13:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 11272 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 BC4E323F26 for ; Mon, 10 Sep 2012 04:16:08 +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 6F1B1A1831C for ; Mon, 10 Sep 2012 04:16:08 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id k11so2310032iea.11 for ; Sun, 09 Sep 2012 21:16:08 -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:date:from :to:cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent:x-gm-message-state; bh=UHQK30vZizGwnzAVRoEjF8rTm3DZJk8nIU/B02LymIU=; b=kIa742sgy+m0VObzM/iFqrcb41E5u+fFg/mJUgryvDRRV/emmuVh2Kyvsw9jlDslFd TGCXuJmp/dnMWukIK7V/OqFvsXgxOVJlZ3JreTRAbCaGcuQzvGtkaTxBM6TfBQlyCPKO UNF8d0jmeIvvEaiUd9iADpEL3+OM+tLj81TnpGHkP/vJn+sPQaxCyhr3wzmr3AjQoGt+ xh4zUKJTI8UNE0yxFSR1mOie1FI2QCKJRiR9Cxip2HYQOzI5JriBgox7Xokre2cTGrt3 047l2GqCzYNEQK7s6MeNrohGAiTIDVa3NsMV8KIMkB0zBPdtRzhnTo8uSb7aeG83teu+ z+CA== Received: by 10.50.191.227 with SMTP id hb3mr861643igc.43.1347250568210; Sun, 09 Sep 2012 21:16:08 -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 ex8csp72943igc; Sun, 9 Sep 2012 21:16:07 -0700 (PDT) Received: by 10.68.220.104 with SMTP id pv8mr3859706pbc.119.1347250567607; Sun, 09 Sep 2012 21:16:07 -0700 (PDT) Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id qs7si18534769pbc.222.2012.09.09.21.16.07 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 09 Sep 2012 21:16:07 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.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 mail-pz0-f50.google.com with SMTP id e7so1311836dad.37 for ; Sun, 09 Sep 2012 21:16:07 -0700 (PDT) Received: by 10.68.223.163 with SMTP id qv3mr3872034pbc.101.1347250567291; Sun, 09 Sep 2012 21:16:07 -0700 (PDT) Received: from localhost (ip-64-134-230-8.public.wayport.net. [64.134.230.8]) by mx.google.com with ESMTPS id qf4sm7443341pbc.1.2012.09.09.21.16.06 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 09 Sep 2012 21:16:07 -0700 (PDT) Date: Sun, 9 Sep 2012 21:13:35 -0700 From: Anton Vorontsov To: Andrew Morton , Russell King , Jason Wessel , Greg Kroah-Hartman , Alan Cox Cc: Arve =?utf-8?B?SGrDuG5uZXbDpWc=?= , 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 06/14] tty/serial/core: Introduce poll_init callback Message-ID: <20120910041335.GF29537@lizard> References: <20120910040802.GA1261@lizard> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120910040802.GA1261@lizard> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQn5EJtPQsMjADOvQbKNZUQr4O7pbTuvDrO8d0G+ltDADwp77Udk+J5oPV6vNLU9RmHGs+ju 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 | 15 +++++++++++++++ include/linux/serial_core.h | 1 + 2 files changed, 16 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index a21dc8e..cba8443 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2108,11 +2108,13 @@ static int uart_poll_init(struct tty_driver *driver, int line, char *options) { struct uart_driver *drv = driver->driver_state; struct uart_state *state = drv->state + line; + struct tty_port *tport; struct uart_port *port; int baud = 9600; int bits = 8; int parity = 'n'; int flow = 'n'; + int ret; if (!state || !state->uart_port) return -1; @@ -2121,6 +2123,19 @@ 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; + tport = &state->port; + if (!(tport->flags & ASYNC_INITIALIZED) && port->ops->poll_init) { + mutex_lock(&tport->mutex); + ret = port->ops->poll_init(port); + /* + * We don't set ASYNCB_INITIALIZED as we only initialized the + * hw, e.g. state->xmit is still uninitialized. + */ + 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 0253c20..3642710 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