Skip to contentSkip to conversation

serial: 8250_pcilib: Replace deprecated PCI functions

PATCH Andy Shevchenko 2 participants 5 messages Oct 18, 2025 – Oct 20, 2025 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw
Quoted 16 lines · Florian Eckert

When the '8250_exar' module is loaded into the kernel, a kernel trace with 'WARN_ON(legacy_iomap_table[bar])' is dumped to the console, because the old pci table mapping is still used in '8250_pcilib'.

The old function have been deprecated in commit e354bb84a4c1 ("PCI:
Deprecate pcim_iomap_table(), pcim_iomap_regions_request_all()").

The remapping already takes or must take place in the driver that calls the function 'serial8250_pci_setup_port()'. The remapping should only be called once via 'pcim_iomap()'. Therefore the remapping moved to the caller of 'serial8250_pci_setup_port()'.

To replace the outdated/legacy iomap_table processing in '8250_pcilib' the function signature of 'serial8250_pci_setup_port()' has been extended with an already iomapped address value. So this can be used directly without io mapping again.

...

Review

Quoted 1 line
(quoted diff) +1 -0
+	if (pci_resource_flags(priv->dev, bar) & IORESOURCE_MEM) {

Dunno if this is included already in Linux Next, but here is room for improvement.

The problem with the above code is it (wrongly?) checks for bit and not for the resource type. OTOH I don't remember if 64-bit version requires the IORESOURCE_MEM to be set along with that.

Quoted 4 lines
(quoted diff) +4 -0
+		iomem = pcim_iomap(priv->dev, bar, 0);
+		if (!iomem)
+			return -ENOMEM;
+	}
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#1 lore raw
Quoted 18 lines · Andy Shevchenko
Quoted 12 lines · Florian Eckert

When the '8250_exar' module is loaded into the kernel, a kernel trace with 'WARN_ON(legacy_iomap_table[bar])' is dumped to the console, because the old pci table mapping is still used in '8250_pcilib'.

The old function have been deprecated in commit e354bb84a4c1 ("PCI:
Deprecate pcim_iomap_table(), pcim_iomap_regions_request_all()").

The remapping already takes or must take place in the driver that calls the function 'serial8250_pci_setup_port()'. The remapping should only be called once via 'pcim_iomap()'. Therefore the remapping moved to the caller of 'serial8250_pci_setup_port()'.

Quoted 4 lines

To replace the outdated/legacy iomap_table processing in '8250_pcilib' the function signature of 'serial8250_pci_setup_port()' has been extended with an already iomapped address value. So this can be used directly without io mapping again.

Quoted 7 lines

...

Review

Quoted 1 line
(quoted diff) +1 -0
+	if (pci_resource_flags(priv->dev, bar) & IORESOURCE_MEM) {

Dunno if this is included already in Linux Next, but here is room for improvement.

I followed the code in the 'serial8250_pci_setup_port()' [1] function. The same pattern is used there [2].

Quoted 5 lines

The problem with the above code is it (wrongly?) checks for bit and not for the resource type. OTOH I don't remember if 64-bit version requires the IORESOURCE_MEM to be set along with that.

Do you mean the function 'platform_get_resource()' [3]? This is a platform device function?

[1] https://elixir.bootlin.com/linux/v6.18-rc1/source/drivers/tty/serial/8250/8250_pcilib.c#L24
[2] https://elixir.bootlin.com/linux/v6.18-rc1/source/drivers/tty/serial/8250/8250_pcilib.c#L30
[3] https://elixir.bootlin.com/linux/v6.17.3/source/drivers/base/platform.c#L55

---
Florian

#2 lore raw
Quoted 2 lines · Florian Eckert
Quoted 1 line · Andy Shevchenko

On Tue, Sep 30, 2025 at 09:27:43AM +0200, Florian Eckert wrote:

...

Quoted 7 lines
Quoted 4 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	if (pci_resource_flags(priv->dev, bar) & IORESOURCE_MEM) {

Dunno if this is included already in Linux Next, but here is room for improvement.

I followed the code in the 'serial8250_pci_setup_port()' [1] function. The same pattern is used there [2].

I see. So if we want to amend that, it should be done separately.

Quoted 6 lines
Quoted 3 lines

The problem with the above code is it (wrongly?) checks for bit and not for the resource type. OTOH I don't remember if 64-bit version requires the IORESOURCE_MEM to be set along with that.

Do you mean the function 'platform_get_resource()' [3]? This is a platform device function?

I mean that the IORESOURCE_MEM and IORESOURCE_MEM_64 are separate bit flags in struct resource::flags. Checking on one might not imply the other be set, however brief look at the sources shows that _MEM_64 is supposed to be set on top of _MEM.

Quoted 4 lines

[1] https://elixir.bootlin.com/linux/v6.18-rc1/source/drivers/tty/serial/8250/8250_pcilib.c#L24
[2] https://elixir.bootlin.com/linux/v6.18-rc1/source/drivers/tty/serial/8250/8250_pcilib.c#L30
[3]
https://elixir.bootlin.com/linux/v6.17.3/source/drivers/base/platform.c#L55

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 11 lines · Andy Shevchenko
Quoted 2 lines · Florian Eckert
Quoted 1 line · Andy Shevchenko

On Tue, Sep 30, 2025 at 09:27:43AM +0200, Florian Eckert wrote:

...

Quoted 5 lines
Quoted 4 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	if (pci_resource_flags(priv->dev, bar) & IORESOURCE_MEM) {

Dunno if this is included already in Linux Next, but here is room for improvement.

Quoted 4 lines
Quoted 2 lines

I followed the code in the 'serial8250_pci_setup_port()' [1] function. The same pattern is used there [2].

I see. So if we want to amend that, it should be done separately.

If that's the case, then I'm done with this patchset, right? I do not have to send a v3?

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

The problem with the above code is it (wrongly?) checks for bit and not for the resource type. OTOH I don't remember if 64-bit version requires the IORESOURCE_MEM to be set along with that.

Quoted 7 lines
Quoted 2 lines

Do you mean the function 'platform_get_resource()' [3]? This is a platform device function?

I mean that the IORESOURCE_MEM and IORESOURCE_MEM_64 are separate bit flags in struct resource::flags. Checking on one might not imply the other be set, however brief look at the sources shows that _MEM_64 is supposed to be set on top of _MEM.

Okay, I understand.

---
Best regards

Florian

#4 lore raw
Quoted 4 lines · Florian Eckert
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Florian Eckert
Quoted 1 line · Andy Shevchenko

On Tue, Sep 30, 2025 at 09:27:43AM +0200, Florian Eckert wrote:

...

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	if (pci_resource_flags(priv->dev, bar) & IORESOURCE_MEM) {

Dunno if this is included already in Linux Next, but here is room for improvement.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I followed the code in the 'serial8250_pci_setup_port()' [1] function. The same pattern is used there [2].

I see. So if we want to amend that, it should be done separately.

If that's the case, then I'm done with this patchset, right? I do not have to send a v3?

Yeah, that proposal is not directly related to this change anyway.

Quoted 14 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

The problem with the above code is it (wrongly?) checks for bit and not for the resource type. OTOH I don't remember if 64-bit version requires the IORESOURCE_MEM to be set along with that.

Quoted 8 lines
Quoted 3 lines

Do you mean the function 'platform_get_resource()' [3]? This is a platform
device function?

I mean that the IORESOURCE_MEM and IORESOURCE_MEM_64 are separate bit flags in struct resource::flags. Checking on one might not imply the other be set, however brief look at the sources shows that _MEM_64 is supposed to be set on top of _MEM.

Okay, I understand.

Signature · 2 lines
With Best Regards,
Andy Shevchenko