Skip to content

Commit 45bbe00

Browse files
LinoSanfilippo333gregkh
authored andcommitted
serial: amba-pl011: do not request memory region twice
[ Upstream commit d118040 ] With commit 3873e2d ("drivers: PL011: refactor pl011_probe()") the function devm_ioremap() called from pl011_setup_port() was replaced with devm_ioremap_resource(). Since this function not only remaps but also requests the ports io memory region it now collides with the .config_port() callback which requests the same region at uart port registration. Since devm_ioremap_resource() already claims the memory successfully, the request in .config_port() fails. Later at uart port deregistration the attempt to release the unclaimed memory also fails. The failure results in a “Trying to free nonexistent resource" warning. Fix these issues by removing the callbacks that implement the redundant memory allocation/release. Also make sure that changing the drivers io memory base address via TIOCSSERIAL is not allowed any more. Fixes: 3873e2d ("drivers: PL011: refactor pl011_probe()") Signed-off-by: Lino Sanfilippo <LinoSanfilippo@gmx.de> Link: https://lore.kernel.org/r/20211129174238.8333-1-LinoSanfilippo@gmx.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 8409d23 commit 45bbe00

1 file changed

Lines changed: 3 additions & 24 deletions

File tree

‎drivers/tty/serial/amba-pl011.c‎

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,32 +2083,13 @@ static const char *pl011_type(struct uart_port *port)
20832083
return uap->port.type == PORT_AMBA ? uap->type : NULL;
20842084
}
20852085

2086-
/*
2087-
* Release the memory region(s) being used by 'port'
2088-
*/
2089-
static void pl011_release_port(struct uart_port *port)
2090-
{
2091-
release_mem_region(port->mapbase, SZ_4K);
2092-
}
2093-
2094-
/*
2095-
* Request the memory region(s) being used by 'port'
2096-
*/
2097-
static int pl011_request_port(struct uart_port *port)
2098-
{
2099-
return request_mem_region(port->mapbase, SZ_4K, "uart-pl011")
2100-
!= NULL ? 0 : -EBUSY;
2101-
}
2102-
21032086
/*
21042087
* Configure/autoconfigure the port.
21052088
*/
21062089
static void pl011_config_port(struct uart_port *port, int flags)
21072090
{
2108-
if (flags & UART_CONFIG_TYPE) {
2091+
if (flags & UART_CONFIG_TYPE)
21092092
port->type = PORT_AMBA;
2110-
pl011_request_port(port);
2111-
}
21122093
}
21132094

21142095
/*
@@ -2123,6 +2104,8 @@ static int pl011_verify_port(struct uart_port *port, struct serial_struct *ser)
21232104
ret = -EINVAL;
21242105
if (ser->baud_base < 9600)
21252106
ret = -EINVAL;
2107+
if (port->mapbase != (unsigned long) ser->iomem_base)
2108+
ret = -EINVAL;
21262109
return ret;
21272110
}
21282111

@@ -2140,8 +2123,6 @@ static const struct uart_ops amba_pl011_pops = {
21402123
.flush_buffer = pl011_dma_flush_buffer,
21412124
.set_termios = pl011_set_termios,
21422125
.type = pl011_type,
2143-
.release_port = pl011_release_port,
2144-
.request_port = pl011_request_port,
21452126
.config_port = pl011_config_port,
21462127
.verify_port = pl011_verify_port,
21472128
#ifdef CONFIG_CONSOLE_POLL
@@ -2171,8 +2152,6 @@ static const struct uart_ops sbsa_uart_pops = {
21712152
.shutdown = sbsa_uart_shutdown,
21722153
.set_termios = sbsa_uart_set_termios,
21732154
.type = pl011_type,
2174-
.release_port = pl011_release_port,
2175-
.request_port = pl011_request_port,
21762155
.config_port = pl011_config_port,
21772156
.verify_port = pl011_verify_port,
21782157
#ifdef CONFIG_CONSOLE_POLL

0 commit comments

Comments
 (0)