From patchwork Tue Jan 6 03:09:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Hurley X-Patchwork-Id: 5571801 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BA1049F1C5 for ; Tue, 6 Jan 2015 03:13:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A637320166 for ; Tue, 6 Jan 2015 03:13:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9C1B22010F for ; Tue, 6 Jan 2015 03:13:23 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y8KXV-0001KE-GP; Tue, 06 Jan 2015 03:10:37 +0000 Received: from mail-qa0-f44.google.com ([209.85.216.44]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y8KXS-0001IM-6h for linux-arm-kernel@lists.infradead.org; Tue, 06 Jan 2015 03:10:35 +0000 Received: by mail-qa0-f44.google.com with SMTP id bm13so16059189qab.3 for ; Mon, 05 Jan 2015 19:10:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=gs2O22yzlcvkth1K4tezCQ7i6vxicb73m8brpGE/UdA=; b=Lcofx0HDJB1XAxW6Fb2xDns8/A5ttBMLM9qn6NCbGISdUwsohrzlgX1RM298v8f+1/ HGBVR8fd9f1ozpmFgllpNnoO4/e4LEih3ZA24lsyzelpK0IEXLxAWNxwccTOzIr22zgg Yx2AqIRdNzPnKSmcSTFZZyKi8Naf20Zg6TOJ9p9jc2e5TEA85yZAKUTqQ+KGDrwiWSy4 3ISNlxhQMGcdDuqqCBQ1+QNtGSY0wIPc33SInJw/F/QhPv2hoBGb3wJw8GAN0lqB9Hxg SSqCnvULdMNl3ZNXaBfX1BJbJRyv9ntI/yc03LDg2ipJkP/XP/Ya/c+F3rb5Pw03hNMW geLg== X-Gm-Message-State: ALoCoQn2k3AivEIMybnwujY2noUQwptBmyiFqjuorf+EdD95VpWI4fpVKwRE5W2dYORWmvOu4n15 X-Received: by 10.229.212.67 with SMTP id gr3mr116713354qcb.6.1420513811608; Mon, 05 Jan 2015 19:10:11 -0800 (PST) Received: from thor.lan (h96-61-87-245.cntcnh.dsl.dynamic.tds.net. [96.61.87.245]) by mx.google.com with ESMTPSA id 91sm15617677qgf.1.2015.01.05.19.10.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Jan 2015 19:10:10 -0800 (PST) From: Peter Hurley To: Greg Kroah-Hartman Subject: [PATCH] serial: 8250: Make ISA ports optional Date: Mon, 5 Jan 2015 22:09:45 -0500 Message-Id: <1420513785-23660-1-git-send-email-peter@hurleysoftware.com> X-Mailer: git-send-email 2.2.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150105_191034_564608_00072439 X-CRM114-Status: GOOD ( 17.69 ) X-Spam-Score: -0.7 (/) Cc: One Thousand Gnomes , Peter Hurley , Arnd Bergmann , Tony Lindgren , Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Grant Likely , linux-omap@vger.kernel.org, Jiri Slaby , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some arches have no need to create unprobed 8250 ports; these phantom ports are primarily required for ISA ports which have no probe mechanism or to provide non-operational ports for userspace to configure (via TIOCSSERIAL and TIOCSERCONFIG ioctls). Provide CONFIG_SERIAL_8250_PHANTOM_UARTS knob to disable phantom port registration; ie., CONFIG_SERIAL_8250_PHANTOM_UARTS=N only registers probed ports (ACPI/PNP, "serial8250" platform devices, PCI, etc). Cc: Sebastian Andrzej Siewior Cc: Tony Lindgren Cc: Grant Likely Cc: Arnd Bergmann Signed-off-by: Peter Hurley --- drivers/tty/serial/8250/8250.h | 6 ++++++ drivers/tty/serial/8250/8250_core.c | 13 +++++++++++-- drivers/tty/serial/8250/Kconfig | 24 +++++++++++++++++++----- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h index b008368..bda82f7 100644 --- a/drivers/tty/serial/8250/8250.h +++ b/drivers/tty/serial/8250/8250.h @@ -96,6 +96,12 @@ struct serial8250_config { #define SERIAL8250_SHARE_IRQS 0 #endif +#ifdef CONFIG_SERIAL_8250_PHANTOM_UARTS +#define SERIAL8250_PHANTOM_UARTS 1 +#else +#define SERIAL8250_PHANTOM_UARTS 0 +#endif + static inline int serial_in(struct uart_8250_port *up, int offset) { return up->port.serial_in(&up->port, offset); diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c index 3bfcfdb..1b27b2f 100644 --- a/drivers/tty/serial/8250/8250_core.c +++ b/drivers/tty/serial/8250/8250_core.c @@ -52,10 +52,13 @@ * Configuration: * share_irqs - whether we pass IRQF_SHARED to request_irq(). This option * is unsafe when used on edge-triggered interrupts. + * nr_uarts - max # of ports which can be registered + * phantom_uarts - whether we pre-register "nr_uarts". Required for ISA ports + * and providing unprobed ports for userspace to configure. */ static unsigned int share_irqs = SERIAL8250_SHARE_IRQS; - static unsigned int nr_uarts = CONFIG_SERIAL_8250_RUNTIME_UARTS; +static unsigned int phantom_uarts = SERIAL8250_PHANTOM_UARTS; static struct uart_driver serial8250_reg; @@ -3155,6 +3158,9 @@ serial8250_register_ports(struct uart_driver *drv, struct device *dev) { int i; + if (!phantom_uarts) + return; + for (i = 0; i < nr_uarts; i++) { struct uart_8250_port *up = &serial8250_ports[i]; @@ -3662,7 +3668,7 @@ void serial8250_unregister_port(int line) mutex_lock(&serial_mutex); uart_remove_one_port(&serial8250_reg, &uart->port); - if (serial8250_isa_devs) { + if (serial8250_isa_devs && phantom_uarts) { uart->port.flags &= ~UPF_BOOT_AUTOCONF; uart->port.type = PORT_UNKNOWN; uart->port.dev = &serial8250_isa_devs->dev; @@ -3769,6 +3775,9 @@ MODULE_PARM_DESC(share_irqs, "Share IRQs with other non-8250/16x50 devices" module_param(nr_uarts, uint, 0644); MODULE_PARM_DESC(nr_uarts, "Maximum number of UARTs supported. (1-" __MODULE_STRING(CONFIG_SERIAL_8250_NR_UARTS) ")"); +module_param(phantom_uarts, uint, 0644); +MODULE_PARM_DESC(phantom_uarts, "Enable UARTs with no hardware"); + module_param(skip_txen_test, uint, 0644); MODULE_PARM_DESC(skip_txen_test, "Skip checking for the TXEN bug at init time"); diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig index 0fcbcd2..87e649b 100644 --- a/drivers/tty/serial/8250/Kconfig +++ b/drivers/tty/serial/8250/Kconfig @@ -145,15 +145,29 @@ config SERIAL_8250_NR_UARTS via hot-plug, or any ISA multi-port serial cards. config SERIAL_8250_RUNTIME_UARTS - int "Number of 8250/16550 serial ports to register at runtime" + int "Maximum number of 8250/16550 serial ports to enable" depends on SERIAL_8250 range 0 SERIAL_8250_NR_UARTS default "4" help - Set this to the maximum number of serial ports you want - the kernel to register at boot time. This can be overridden - with the module parameter "nr_uarts", or boot-time parameter - 8250.nr_uarts + Set this to the maximum number of 8250/16550 serial ports you + want the kernel to allow. This can be overridden with the module + parameter "nr_uarts", or boot-time parameter, 8250.nr_uarts, + up to the maximum. + +config SERIAL_8250_PHANTOM_UARTS + bool + prompt "Enable phantom 8250/16550 serial ports" if !ISA + depends on SERIAL_8250 + default y + ---help--- + Say Y here to create all 8250/16550 serial ports at module load time. + Saying N here prevents the creation of unprobed ports, but also + disables userspace probe/configure (since no device node is created + for userspace to open). This can be overridden with the module + parameter "phantom_uarts", or boot-time parameter, 8250.phantom_uarts + + If unsure, say Y. config SERIAL_8250_EXTENDED bool "Extended 8250/16550 serial driver options"