From: David Gibson <hidden> Date: 2007-02-20 03:17:22
Andrew, please apply to -mm. I think these should be good to merge
for 2.6.22.
At present, MMIO addresses for serial port (the ->mapbase field in
uart_port and other structures) are unsigned longs. This causes
problems on some 32-bit platforms which have a >32-bit physical
address bus, for example the embedded PowerPC 440GP chip, which has a
36-bit physical address bus, and on-chip serial ports located at an
MMIO address above 4GB.
The second patch in this series changes mapbase to a resource_size_t
(which can be 64-bit on the problematic platforms) in struct uart_port
and struct plat_serial8250_port. It does *not* change the type in
serial_struct, because that structure is exposed to userspace. It is
therefore unsafe to use setserial to change the address parameters on
a port using a mapbase above 4GB.
The first patch in the series contains the damage of the setserial
problem. It allows serial ports to be marked with a new
UPF_FIXED_PORT flag, which causes any attempts to change the port's
type (PIO/MMIO etc.), address or irq with setserial to be ignored.
While using setserial to alter the port address is useful for legacy
ISA ports, it is generally a bad idea for ports such as on-chip or
other hardwired ports where the arch code has good information (from
firmware or hardware probing) on the port's type and address.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
From: David Gibson <hidden> Date: 2007-02-20 03:19:53
At present, the serial core always allows setserial in userspace to
change the port address, irq and base clock of any serial port. That
makes sense for legacy ISA ports, but not for (say) embedded ns16550
compatible serial ports at peculiar addresses. In these cases, the
kernel code configuring the ports must know exactly where they are,
and their clocking arrangements (which can be unusual on embedded
boards). It doesn't make sense for userspace to change these
settings.
Therefore, this patch defines a UPF_FIXED_PORT flag for the uart_port
structure. If this flag is set when the serial port is configured,
any attempts to alter the port's type, io address, irq or base clock
with setserial are ignored.
In addition this patch uses the new flag for on-chip serial ports
probed in arch/powerpc/kernel/legacy_serial.c, and for other
hard-wired serial ports probed by drivers/serial/of_serial.c.
Signed-off-by: David Gibson <redacted>
---
arch/powerpc/kernel/legacy_serial.c | 3 ++-
drivers/serial/of_serial.c | 3 ++-
drivers/serial/serial_core.c | 22 +++++++++++++---------
include/linux/serial_core.h | 1 +
4 files changed, 18 insertions(+), 11 deletions(-)
Index: working-2.6/drivers/serial/serial_core.c
===================================================================
@@ -115,7 +115,8 @@ static int __init add_legacy_soc_port(st{u64addr;constu32*addrp;-upf_tflags=UPF_BOOT_AUTOCONF|UPF_SKIP_TEST|UPF_SHARE_IRQ;+upf_tflags=UPF_BOOT_AUTOCONF|UPF_SKIP_TEST|UPF_SHARE_IRQ+|UPF_FIXED_PORT;structdevice_node*tsi=of_get_parent(np);/* We only support ports that have a clock frequency properly
From: David Gibson <hidden> Date: 2007-02-20 03:19:54
At present, various parts of the serial code use unsigned long to
define resource addresses. This is a problem, because some 32-bit
platforms have physical addresses larger than 32-bits, and have mmio
serial uarts located above the 4GB point.
This patch changes the type of mapbase in both struct uart_port and
struct plat_serial8250_port to resource_size_t, which can be
configured to be 64 bits on such platforms. The mapbase in
serial_struct can't safely be changed, because that structure is user
visible.
Signed-off-by: David Gibson <redacted>
---
drivers/serial/8250.c | 5 +++--
drivers/serial/8250_early.c | 16 +++++++++-------
drivers/serial/serial_core.c | 9 +++++----
include/linux/serial_8250.h | 2 +-
include/linux/serial_core.h | 2 +-
5 files changed, 19 insertions(+), 15 deletions(-)
Index: working-2.6/include/linux/serial_core.h
===================================================================
@@ -273,7 +273,7 @@ struct uart_port {conststructuart_ops*ops;unsignedintcustom_divisor;unsignedintline;/* port index */-unsignedlongmapbase;/* for ioremap */+resource_size_tmapbase;/* for ioremap */structdevice*dev;/* parent device */unsignedcharhub6;/* this should be in the 8250 driver */unsignedcharunused[3];
@@ -168,9 +169,10 @@ static int __init parse_options(struct edevice->baud);}-printk(KERN_INFO"Early serial console at %s 0x%lx (options '%s')\n",+printk(KERN_INFO"Early serial console at %s 0x%llx (options '%s')\n",mmio?"MMIO":"I/O port",-mmio?port->mapbase:(unsignedlong)port->iobase,+mmio?(unsignedlonglong)port->mapbase+:(unsignedlonglong)port->iobase,device->options);return0;}
@@ -236,10 +238,10 @@ static int __init early_uart_console_swimmio=(port->iotype==UPIO_MEM);line=serial8250_start_console(port,device->options);if(line<0)-printk("No ttyS device at %s 0x%lx for console\n",+printk("No ttyS device at %s 0x%llx for console\n",mmio?"MMIO":"I/O port",-mmio?port->mapbase:-(unsignedlong)port->iobase);+mmio?(unsignedlonglong)port->mapbase+:(unsignedlonglong)port->iobase);unregister_console(&early_uart_console);if(mmio)
@@ -2550,8 +2550,9 @@ static int __devinit serial8250_probe(stret=serial8250_register_port(&port);if(ret<0){dev_err(&dev->dev,"unable to register port at index %d "-"(IO%lx MEM%lx IRQ%d): %d\n",i,-p->iobase,p->mapbase,p->irq,ret);+"(IO%lx MEM%llx IRQ%d): %d\n",i,+p->iobase,(unsignedlonglong)p->mapbase,+p->irq,ret);}}return0;
On Tue, 20 Feb 2007 14:19:51 +1100 (EST)
David Gibson [off-list ref] wrote:
At present, various parts of the serial code use unsigned long to
define resource addresses. This is a problem, because some 32-bit
platforms have physical addresses larger than 32-bits, and have mmio
serial uarts located above the 4GB point.
This patch changes the type of mapbase in both struct uart_port and
struct plat_serial8250_port to resource_size_t, which can be
configured to be 64 bits on such platforms. The mapbase in
serial_struct can't safely be changed, because that structure is user
visible.
Signed-off-by: David Gibson <redacted>
On Tue, 20 Feb 2007 14:19:51 +1100 (EST)
David Gibson [off-list ref] wrote:
At present, the serial core always allows setserial in userspace to
change the port address, irq and base clock of any serial port. That
makes sense for legacy ISA ports, but not for (say) embedded ns16550
compatible serial ports at peculiar addresses. In these cases, the
kernel code configuring the ports must know exactly where they are,
and their clocking arrangements (which can be unusual on embedded
boards). It doesn't make sense for userspace to change these
settings.
Therefore, this patch defines a UPF_FIXED_PORT flag for the uart_port
structure. If this flag is set when the serial port is configured,
any attempts to alter the port's type, io address, irq or base clock
with setserial are ignored.
In addition this patch uses the new flag for on-chip serial ports
probed in arch/powerpc/kernel/legacy_serial.c, and for other
hard-wired serial ports probed by drivers/serial/of_serial.c.
Signed-off-by: David Gibson <redacted>
From: Russell King <hidden> Date: 2007-02-28 22:26:46
On Tue, Feb 20, 2007 at 02:19:51PM +1100, David Gibson wrote:
Therefore, this patch defines a UPF_FIXED_PORT flag for the uart_port
structure. If this flag is set when the serial port is configured,
any attempts to alter the port's type, io address, irq or base clock
with setserial are ignored.
I've been wondering about this, and it is questionable whether we
should allow any serial port which isn't owned by the legacy platform
device (the one called "serial8250", iow by the 8250 driver itself)
to have the base addresses and interrupts changed.
IOW, we apply this "fixed port" to any port registered by probe
modules external to the 8250 driver itself, such as PCI, PNP, etc.
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of:
From: David Gibson <hidden> Date: 2007-03-01 00:00:18
On Wed, Feb 28, 2007 at 10:26:30PM +0000, Russell King wrote:
On Tue, Feb 20, 2007 at 02:19:51PM +1100, David Gibson wrote:
quoted
Therefore, this patch defines a UPF_FIXED_PORT flag for the uart_port
structure. If this flag is set when the serial port is configured,
any attempts to alter the port's type, io address, irq or base clock
with setserial are ignored.
I've been wondering about this, and it is questionable whether we
should allow any serial port which isn't owned by the legacy platform
device (the one called "serial8250", iow by the 8250 driver itself)
to have the base addresses and interrupts changed.
IOW, we apply this "fixed port" to any port registered by probe
modules external to the 8250 driver itself, such as PCI, PNP, etc.
Sounds reasonable to me. But maybe in that case we should invert the
sense of the flag. UPF_MOVABLE_PORT or UPF_USER_CONFIGURABLE or
something.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
From: Russell King <hidden> Date: 2007-03-01 10:30:18
On Thu, Mar 01, 2007 at 10:44:24AM +1100, David Gibson wrote:
On Wed, Feb 28, 2007 at 10:26:30PM +0000, Russell King wrote:
quoted
On Tue, Feb 20, 2007 at 02:19:51PM +1100, David Gibson wrote:
quoted
Therefore, this patch defines a UPF_FIXED_PORT flag for the uart_port
structure. If this flag is set when the serial port is configured,
any attempts to alter the port's type, io address, irq or base clock
with setserial are ignored.
I've been wondering about this, and it is questionable whether we
should allow any serial port which isn't owned by the legacy platform
device (the one called "serial8250", iow by the 8250 driver itself)
to have the base addresses and interrupts changed.
IOW, we apply this "fixed port" to any port registered by probe
modules external to the 8250 driver itself, such as PCI, PNP, etc.
Sounds reasonable to me. But maybe in that case we should invert the
sense of the flag. UPF_MOVABLE_PORT or UPF_USER_CONFIGURABLE or
something.
I was thinking about not even having a flag, but instead checking for
port->dev == &serial8250_isa_devs->dev.
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of:
From: David Gibson <hidden> Date: 2007-03-02 01:57:33
On Thu, Mar 01, 2007 at 10:30:04AM +0000, Russell King wrote:
On Thu, Mar 01, 2007 at 10:44:24AM +1100, David Gibson wrote:
quoted
On Wed, Feb 28, 2007 at 10:26:30PM +0000, Russell King wrote:
quoted
On Tue, Feb 20, 2007 at 02:19:51PM +1100, David Gibson wrote:
quoted
Therefore, this patch defines a UPF_FIXED_PORT flag for the uart_port
structure. If this flag is set when the serial port is configured,
any attempts to alter the port's type, io address, irq or base clock
with setserial are ignored.
I've been wondering about this, and it is questionable whether we
should allow any serial port which isn't owned by the legacy platform
device (the one called "serial8250", iow by the 8250 driver itself)
to have the base addresses and interrupts changed.
IOW, we apply this "fixed port" to any port registered by probe
modules external to the 8250 driver itself, such as PCI, PNP, etc.
Sounds reasonable to me. But maybe in that case we should invert the
sense of the flag. UPF_MOVABLE_PORT or UPF_USER_CONFIGURABLE or
something.
I was thinking about not even having a flag, but instead checking for
port->dev == &serial8250_isa_devs->dev.
Hmm.. ok. Will you spin a patch, or should I?
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson