summaryrefslogtreecommitdiff
path: root/drivers/tty/mxser.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2022-01-24 10:14:25 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-01-26 16:54:48 +0300
commit92cc9d1d14e3ba8e82c99a4b4c90cce1db3c3fa9 (patch)
tree7a798228a1af53a4a0616727f40678b843f2fff4 /drivers/tty/mxser.c
parentcd3a4907ee334b40d7aa880c7ab310b154fd5cd4 (diff)
downloadlinux-92cc9d1d14e3ba8e82c99a4b4c90cce1db3c3fa9.tar.xz
mxser: use tty_port xmit_buf helpers
For the mxser driver to use kfifo, use tty_port_alloc_xmit_buf() and tty_port_free_xmit_buf() helpers in activate/shutdown, respectively. As these calls have to be done in a non-atomic context, we have to move them outside spinlock and make sure irq is really stopped after we write to the ISR register. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20220124071430.14907-7-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/mxser.c')
-rw-r--r--drivers/tty/mxser.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index fbb796f83753..4ddc12a63666 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -742,13 +742,12 @@ static void mxser_disable_and_clear_FIFO(struct mxser_port *info)
static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
{
struct mxser_port *info = container_of(port, struct mxser_port, port);
- unsigned long page;
unsigned long flags;
int ret;
- page = __get_free_page(GFP_KERNEL);
- if (!page)
- return -ENOMEM;
+ ret = tty_port_alloc_xmit_buf(port);
+ if (ret < 0)
+ return ret;
spin_lock_irqsave(&info->slock, flags);
@@ -758,7 +757,6 @@ static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
ret = 0;
goto err_free_xmit;
}
- info->port.xmit_buf = (unsigned char *) page;
/*
* Clear the FIFO buffers and disable them
@@ -825,8 +823,7 @@ static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
return 0;
err_free_xmit:
- free_page(page);
- info->port.xmit_buf = NULL;
+ tty_port_free_xmit_buf(port);
return ret;
}
@@ -862,14 +859,6 @@ static void mxser_shutdown_port(struct tty_port *port)
*/
wake_up_interruptible(&info->port.delta_msr_wait);
- /*
- * Free the xmit buffer, if necessary
- */
- if (info->port.xmit_buf) {
- free_page((unsigned long) info->port.xmit_buf);
- info->port.xmit_buf = NULL;
- }
-
info->IER = 0;
outb(0x00, info->ioaddr + UART_IER);
@@ -884,6 +873,11 @@ static void mxser_shutdown_port(struct tty_port *port)
mxser_must_no_sw_flow_control(info->ioaddr);
spin_unlock_irqrestore(&info->slock, flags);
+
+ /* make sure ISR is not running while we free the buffer */
+ synchronize_irq(info->board->irq);
+
+ tty_port_free_xmit_buf(port);
}
/*