Skip to contentSkip to conversation

PCI: Remove useless WARN_ON() from devres

PATCH Applied Philipp Stanner 3 participants 3 messages Dec 18, 2025 – Jan 14 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: Remove useless WARN_ON() from devres

PCI's devres implementation contains a WARN_ON() which served to inform users relying on the legacy devres iomap table that this table does not support multiple mappings per BAR.

The WARN_ON() can be regarded as useless by now, since mapping a BAR multiple times is legal behavior and old users of pcim_iomap_table(), the accessor function for that table, did not break in the past PCI devres cleanup. New PCI users will hopefully notice that pcim_iomap_table() is deprecated and are unlikely to use it for mapping the same BAR multiple times.

Moreover, WARN_ON()s create noisy, difficult to read error messages which can be more confusing than helpful, since they don't inform the user about what precisely the problem is.

Remove the WARN_ON().

---
 drivers/pci/devres.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/pci/devres.c +0 -3
index 9f4190501395..f075e7881c3a 100644
@@ -469,9 +469,6 @@ static int pcim_add_mapping_to_legacy_table(struct pci_dev *pdev,
 	if (!legacy_iomap_table)
 		return -ENOMEM;
 
-	/* The legacy mechanism doesn't allow for duplicate mappings. */
-	WARN_ON(legacy_iomap_table[bar]);
-
 	legacy_iomap_table[bar] = mapping;
 
 	return 0;
Signature · 1 line
2.49.0
#1 lore raw
Quoted 11 lines · Philipp Stanner

PCI's devres implementation contains a WARN_ON() which served to inform users relying on the legacy devres iomap table that this table does not support multiple mappings per BAR.

The WARN_ON() can be regarded as useless by now, since mapping a BAR multiple times is legal behavior and old users of pcim_iomap_table(), the accessor function for that table, did not break in the past PCI devres cleanup. New PCI users will hopefully notice that pcim_iomap_table() is deprecated and are unlikely to use it for mapping the same BAR multiple times.

Quoted 8 lines

Moreover, WARN_ON()s create noisy, difficult to read error messages which can be more confusing than helpful, since they don't inform the user about what precisely the problem is.

Remove the WARN_ON().

*ping*

Quoted 18 lines

---
 drivers/pci/devres.c | 3 ---

 1 file changed, 3 deletions(-)
drivers/pci/devres.c +0 -0
index 9f4190501395..f075e7881c3a 100644
@@ -469,9 +469,6 @@ static int pcim_add_mapping_to_legacy_table(struct pci_dev *pdev,
  	if (!legacy_iomap_table)
  		return -ENOMEM;

drivers/pci/devres.c +0 -3
-	/* The legacy mechanism doesn't allow for duplicate mappings. */
-	WARN_ON(legacy_iomap_table[bar]);
-

  legacy_iomap_table[bar] = mapping;

  return 0;

#2 lore raw
In reply to Philipp Stanner
Quoted 11 lines · Philipp Stanner

PCI's devres implementation contains a WARN_ON() which served to inform users relying on the legacy devres iomap table that this table does not support multiple mappings per BAR.

The WARN_ON() can be regarded as useless by now, since mapping a BAR multiple times is legal behavior and old users of pcim_iomap_table(), the accessor function for that table, did not break in the past PCI devres cleanup. New PCI users will hopefully notice that pcim_iomap_table() is deprecated and are unlikely to use it for mapping the same BAR multiple times.

Quoted 8 lines

Moreover, WARN_ON()s create noisy, difficult to read error messages which can be more confusing than helpful, since they don't inform the user about what precisely the problem is.

Remove the WARN_ON().

Applied to pci/misc for v6.20, thanks!

Quoted 21 lines
---
 drivers/pci/devres.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/pci/devres.c +0 -3
index 9f4190501395..f075e7881c3a 100644
@@ -469,9 +469,6 @@ static int pcim_add_mapping_to_legacy_table(struct pci_dev *pdev,
 	if (!legacy_iomap_table)
 		return -ENOMEM;
 
-	/* The legacy mechanism doesn't allow for duplicate mappings. */
-	WARN_ON(legacy_iomap_table[bar]);
-
 	legacy_iomap_table[bar] = mapping;
 
 	return 0;
Signature · 1 line
2.49.0