From patchwork Mon Aug 20 14:47:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 10807 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 55A1323E56 for ; Mon, 20 Aug 2012 14:50:10 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id DE540A18B4E for ; Mon, 20 Aug 2012 14:50:03 +0000 (UTC) Received: by iadj38 with SMTP id j38so2715925iad.11 for ; Mon, 20 Aug 2012 07:50:09 -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=UHQK30vZizGwnzAVRoEjF8rTm3DZJk8nIU/B02LymIU=; b=XrehHvt8msGI3F9tG0Yzn0KLJgRyRwPA7ZS8QqVO4oaQrjVE4tq3VihIKDUhfYo6dW tKcDvWhrUaZOBSDzMiO4NWslfmmB/1fYEoYlo767wRUD8VQczNkgTSqnw+YrJvGSr57s WxwQElX18GBT7Q2VGOYpB5vBnluEu6ti4d8APk3/6WOMjMpKk/NojG3OeP4aNEEDHbvm bv62/sL4zTo36KI6Yn6ymGc3ZGgLGGORs9Gzgk0gCJWjP1d6Q3x24TluwFF7rNWK9tH2 Mvf792C9050KqaBhVFfmPlrKp0BT6I4k6hJNjOfTWfpU9XSIss1zmWHKOeZxKzjCHGIG O+ng== Received: by 10.42.60.139 with SMTP id q11mr11103370ich.53.1345474209152; Mon, 20 Aug 2012 07:50:09 -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 ex8csp87698igc; Mon, 20 Aug 2012 07:50:08 -0700 (PDT) Received: by 10.66.89.234 with SMTP id br10mr30162245pab.25.1345474207719; Mon, 20 Aug 2012 07:50:07 -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 kn7si27031018pbc.26.2012.08.20.07.50.07 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 20 Aug 2012 07:50:07 -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 mail-pb0-f50.google.com with SMTP id md12so7851924pbc.37 for ; Mon, 20 Aug 2012 07:50:07 -0700 (PDT) Received: by 10.66.76.227 with SMTP id n3mr30057991paw.53.1345474207442; Mon, 20 Aug 2012 07:50:07 -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 gt2sm11221432pbc.62.2012.08.20.07.50.06 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 20 Aug 2012 07:50:07 -0700 (PDT) From: Anton Vorontsov To: Russell King , Jason Wessel , Greg Kroah-Hartman , Alan Cox Cc: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Colin Cross , 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 Subject: [PATCH 04/12] tty/serial/core: Introduce poll_init callback Date: Mon, 20 Aug 2012 07:47:22 -0700 Message-Id: <1345474050-8339-4-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.11.5 In-Reply-To: <20120820144449.GA32560@lizard> References: <20120820144449.GA32560@lizard> X-Gm-Message-State: ALoCoQlUaKet9R5RoeAhPdItbDgWsUng6KBio6O93O7zeetadyXqaz3lEIjGsvtm0usHAqVOylTi 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