[PATCH -next 14/17] serial: 8250: Only get RSA resource when required

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The probe for Remote Supervisor Adapter is limited to port i/o
addresses which match one of the probe_rsa[] module parameter
addresses. Limit RSA resource acquire to matching i/o ports.

The result is a saner probe policy: only perform optional probes
when specified rather than by default.

NB: It is possible for userspace to set the port type == PORT_RSA
with ioctl(TIOCSSERIAL) and then autoconfig with ioctl(TIOCSERCONFIG),
which if it fails, may leave the port type set to PORT_RSA. Since
this may have previously resulted in a working RSA port, this behavior
is preserved.

Signed-off-by: Peter Hurley <peter@xxxxxxxxxxxxxxxxxx>
---
 drivers/tty/serial/8250/8250_core.c | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 21395f7..72c9f2d 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -1228,16 +1228,9 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
 	/*
 	 * Only probe for RSA ports if we got the region.
 	 */
-	if (port->type == PORT_16550A && probeflags & PROBE_RSA) {
-		int i;
-
-		for (i = 0 ; i < probe_rsa_count; ++i) {
-			if (probe_rsa[i] == port->iobase && __enable_rsa(up)) {
-				port->type = PORT_RSA;
-				break;
-			}
-		}
-	}
+	if (port->type == PORT_16550A && probeflags & PROBE_RSA &&
+	    __enable_rsa(up))
+		port->type = PORT_RSA;
 #endif
 
 	serial_out(up, UART_LCR, save_lcr);
@@ -3009,7 +3002,7 @@ static void register_dev_spec_attr_grp(struct uart_8250_port *up)
 static void serial8250_config_port(struct uart_port *port, int flags)
 {
 	struct uart_8250_port *up = up_to_u8250p(port);
-	int probeflags = PROBE_ANY;
+	int probeflags = 0;
 	int ret;
 
 	if (port->type == PORT_8250_CIR)
@@ -3024,9 +3017,20 @@ static void serial8250_config_port(struct uart_port *port, int flags)
 		return;
 
 #ifdef CONFIG_SERIAL_8250_RSA
-	ret = serial8250_request_rsa_resource(up);
-	if (ret < 0)
-		probeflags &= ~PROBE_RSA;
+	if (port->type == PORT_RSA) {
+		if (serial8250_request_rsa_resource(up) == 0)
+			probeflags |= PROBE_RSA;
+	} else if (flags & UART_CONFIG_TYPE) {
+		int i;
+
+		for (i = 0 ; i < probe_rsa_count; ++i) {
+			if (probe_rsa[i] == port->iobase) {
+				if (serial8250_request_rsa_resource(up) == 0)
+					probeflags |= PROBE_RSA;
+				break;
+			}
+		}
+	}
 #endif
 
 	if (port->iotype != up->cur_iotype)
-- 
2.3.0

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux