From: Peter Hurley <peter@hurleysoftware.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>,
Jiri Slaby <jslaby@suse.cz>,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
Peter Hurley <peter@hurleysoftware.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Tony Lindgren <tony@atomide.com>,
Grant Likely <grant.likely@linaro.org>,
Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH] serial: 8250: Make ISA ports optional
Date: Mon, 5 Jan 2015 22:09:45 -0500 [thread overview]
Message-ID: <1420513785-23660-1-git-send-email-peter@hurleysoftware.com> (raw)
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 <bigeasy@linutronix.de>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
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"
--
2.2.1
next reply other threads:[~2015-01-06 3:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-06 3:09 Peter Hurley [this message]
2015-01-06 13:13 ` [PATCH] serial: 8250: Make ISA ports optional Arnd Bergmann
2015-01-06 14:32 ` Peter Hurley
2015-01-06 19:43 ` Arnd Bergmann
2015-01-06 21:47 ` Peter Hurley
2015-01-07 10:05 ` Arnd Bergmann
2015-01-08 13:10 ` One Thousand Gnomes
2015-01-08 16:11 ` Peter Hurley
2015-01-08 22:05 ` Arnd Bergmann
2015-01-08 22:36 ` One Thousand Gnomes
2015-01-08 23:25 ` Peter Hurley
2015-01-09 5:13 ` Peter Hurley
2015-01-09 8:48 ` Arnd Bergmann
2015-01-09 14:14 ` Peter Hurley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1420513785-23660-1-git-send-email-peter@hurleysoftware.com \
--to=peter@hurleysoftware.com \
--cc=arnd@arndb.de \
--cc=bigeasy@linutronix.de \
--cc=gnomes@lxorguk.ukuu.org.uk \
--cc=grant.likely@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.cz \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).