Re: [PATCH] tty: serial: 8250: exar: fix kernel warning in default_setup function

From: Wilken Gottwalt
Date: Wed Jul 30 2025 - 07:09:36 EST


On Tue, 29 Jul 2025 10:48:17 +0200
Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:

> > diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
> > index 04a0cbab02c2..5660bb897803 100644
> > --- a/drivers/tty/serial/8250/8250_exar.c
> > +++ b/drivers/tty/serial/8250/8250_exar.c
> > @@ -500,12 +500,13 @@ static int default_setup(struct exar8250 *priv, struct pci_dev *pcidev,
> > struct uart_8250_port *port)
> > {
> > const struct exar8250_board *board = priv->board;
> > + unsigned int bar = 0;
> > unsigned char status;
> > - int err;
> >
> > - err = serial8250_pci_setup_port(pcidev, port, 0, offset, board->reg_shift);
> > - if (err)
> > - return err;
> > + port->port.iotype = UPIO_MEM;
> > + port->port.mapbase = pci_resource_start(pcidev, bar) + offset;
> > + port->port.membase = priv->virt + offset;
> > + port->port.regshift = board->reg_shift;
>
> And so now serial8250_pci_setup_port() is never called? Are you sure
> that's ok?

Hi Greg,

I will not provide a second version of this patch, because this is a bigger
problem involving 8250_exar, 8250_pci and 8250_pci1xxxx. With the changes from
kernel 6.10 to 6.11 the underlying pcim_* functions where changed. The
serial8250_pci_setup_port() does checks on pci_dev + BAR where resources were
already mapped via pcim_iomap(), pci_iomap() or even pci_ioremap_bar(). Not
sure if mixing this is a good idea after the kernel 6.11 changes.

serial8250_pci_setup_port() uses pcim_iomap() and pcim_iomap_table() for checking
these already mapped resources. But the pcim_iomap_table() is deprecated and
suggests to use pcim_iomap() function to aquire the pointer to the resources
while at the same time pcim_iomap() description states, don't use this function
twice on the same BAR. I think the most sane approach would be to drop the
pcim_iomap() and pcim_iomap_table() checks from the serial8250_pci_setup_port()
function. But I can not fully test this, I only have access to some hardware
used by the 8250_exar driver. I also CC Andy and Parker, both worked on the
affected code.

greetings,
Wilken