From patchwork Mon Sep 24 21:27:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 11687 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 104F223E41 for ; Mon, 24 Sep 2012 21:32:04 +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 B7705A18111 for ; Mon, 24 Sep 2012 21:32:03 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so11249367iej.11 for ; Mon, 24 Sep 2012 14:32:03 -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=0DiPYZzp/VZOadqhmLb2xxQQKUjSXTzfzqNC51r53vE=; b=jfFicNvXuY5ZAT9Y/Mu0522ElfcxzifB9t9EN99iSIbCHmmLwxsrky6ueqoJStZojX u6N0kqh4j7rRtE+hBt/4p76I4poPdcqO9ID2GKVjaP6roMZoTvLSHzbglhoAQNLEkEZ1 61FgDDzVEl4yxUb7ukoBT+q5kuo8dOWSrcQhkSzj/pZmLGDqWEgs+HBXbwXmdoCVsBKw AGDPaPQHahnOBPeq7mnPOO7L85LEEO65mN7kZDIKMdqVjeuKjFhIBr8kNyNGd3mp9rat 44FXUbWLFNMVv9s2yDKpooF4oCWYYsPqOwTangGoEiseCsJHXZzwkFVuYrZT2EXU3UeR TeJQ== Received: by 10.50.150.198 with SMTP id uk6mr724801igb.43.1348522323522; Mon, 24 Sep 2012 14:32:03 -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 ex8csp263612igc; Mon, 24 Sep 2012 14:32:02 -0700 (PDT) Received: by 10.68.237.3 with SMTP id uy3mr40058875pbc.30.1348522322663; Mon, 24 Sep 2012 14:32:02 -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 j9si6686665paw.67.2012.09.24.14.32.02 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 24 Sep 2012 14:32:02 -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 md12so13998041pbc.37 for ; Mon, 24 Sep 2012 14:32:02 -0700 (PDT) Received: by 10.66.72.132 with SMTP id d4mr35569317pav.61.1348522322428; Mon, 24 Sep 2012 14:32:02 -0700 (PDT) Received: from localhost (ip-64-134-232-154.public.wayport.net. [64.134.232.154]) by mx.google.com with ESMTPS id kt2sm10166469pbc.73.2012.09.24.14.31.57 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 24 Sep 2012 14:32:01 -0700 (PDT) From: Anton Vorontsov To: Greg Kroah-Hartman , Russell King Cc: Alan Cox , Jason Wessel , =?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/11] tty/serial/core: Introduce poll_init callback Date: Mon, 24 Sep 2012 14:27:53 -0700 Message-Id: <1348522080-32629-4-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.12 In-Reply-To: <20120924212648.GA27605@lizard> References: <20120924212648.GA27605@lizard> X-Gm-Message-State: ALoCoQmQ7jJvy0TgIsNGl/5ZSjDG0t6+aWDwe6NyHMsyfNAinm8QvV8RajoHmesUIju3dN5bls0O 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 Acked-by: Alan Cox --- 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 78036c5..0fcfd98a 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