Patch "serial: amba-pl011: do not request memory region twice" has been added to the 5.4-stable tree

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

 



This is a note to let you know that I've just added the patch titled

    serial: amba-pl011: do not request memory region twice

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     serial-amba-pl011-do-not-request-memory-region-twice.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit ffc3639650c1dca24fb8db35d161219361b0c388
Author: Lino Sanfilippo <LinoSanfilippo@xxxxxx>
Date:   Mon Nov 29 18:42:38 2021 +0100

    serial: amba-pl011: do not request memory region twice
    
    [ Upstream commit d1180405c7b5c7a1c6bde79d5fc24fe931430737 ]
    
    With commit 3873e2d7f63a ("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: 3873e2d7f63a ("drivers: PL011: refactor pl011_probe()")
    Signed-off-by: Lino Sanfilippo <LinoSanfilippo@xxxxxx>
    Link: https://lore.kernel.org/r/20211129174238.8333-1-LinoSanfilippo@xxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 6741d0f3daf94..0bd8c05d72d60 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2094,32 +2094,13 @@ static const char *pl011_type(struct uart_port *port)
 	return uap->port.type == PORT_AMBA ? uap->type : NULL;
 }
 
-/*
- * Release the memory region(s) being used by 'port'
- */
-static void pl011_release_port(struct uart_port *port)
-{
-	release_mem_region(port->mapbase, SZ_4K);
-}
-
-/*
- * Request the memory region(s) being used by 'port'
- */
-static int pl011_request_port(struct uart_port *port)
-{
-	return request_mem_region(port->mapbase, SZ_4K, "uart-pl011")
-			!= NULL ? 0 : -EBUSY;
-}
-
 /*
  * Configure/autoconfigure the port.
  */
 static void pl011_config_port(struct uart_port *port, int flags)
 {
-	if (flags & UART_CONFIG_TYPE) {
+	if (flags & UART_CONFIG_TYPE)
 		port->type = PORT_AMBA;
-		pl011_request_port(port);
-	}
 }
 
 /*
@@ -2134,6 +2115,8 @@ static int pl011_verify_port(struct uart_port *port, struct serial_struct *ser)
 		ret = -EINVAL;
 	if (ser->baud_base < 9600)
 		ret = -EINVAL;
+	if (port->mapbase != (unsigned long) ser->iomem_base)
+		ret = -EINVAL;
 	return ret;
 }
 
@@ -2151,8 +2134,6 @@ static const struct uart_ops amba_pl011_pops = {
 	.flush_buffer	= pl011_dma_flush_buffer,
 	.set_termios	= pl011_set_termios,
 	.type		= pl011_type,
-	.release_port	= pl011_release_port,
-	.request_port	= pl011_request_port,
 	.config_port	= pl011_config_port,
 	.verify_port	= pl011_verify_port,
 #ifdef CONFIG_CONSOLE_POLL
@@ -2182,8 +2163,6 @@ static const struct uart_ops sbsa_uart_pops = {
 	.shutdown	= sbsa_uart_shutdown,
 	.set_termios	= sbsa_uart_set_termios,
 	.type		= pl011_type,
-	.release_port	= pl011_release_port,
-	.request_port	= pl011_request_port,
 	.config_port	= pl011_config_port,
 	.verify_port	= pl011_verify_port,
 #ifdef CONFIG_CONSOLE_POLL



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux