[RFC PATCH 1/3] ata: Allocate PCI iomap table statically

From: Philipp Stanner
Date: Wed Dec 04 2024 - 12:38:21 EST


struct ata_host.iomap has been created and administrated so far by
pcim_iomap_table(), a problematic function that has been deprecated in
commit e354bb84a4c1c ("PCI: Deprecate pcim_iomap_table(),
pcim_iomap_regions_request_all()")

Ideally, drivers should not need a global table at all and should store
ioremaped BARs in their respective structs separately. For ATA, however,
it's far easier to deprecate pcim_iomap_table() by allocating struct
ata_host.iomap statically as an array of iomem pointers. Since
PCI_STD_NUM_BARS is currently defined to be 6, the memory overhead is
irrelevant.

Make struct ata_host.iomap a static iomem pointer table.

Signed-off-by: Philipp Stanner <pstanner@xxxxxxxxxx>
---
include/linux/libata.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/linux/libata.h b/include/linux/libata.h
index c1a85d46eba6..d12a9627c96e 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -23,6 +23,9 @@
#include <linux/cdrom.h>
#include <linux/sched.h>
#include <linux/async.h>
+#ifdef CONFIG_PCI
+#include <linux/pci_regs.h> /* for PCI_STD_NUM_BARS */
+#endif /* CONFIG_PCI */

/*
* Define if arch has non-standard setup. This is a _PCI_ standard
@@ -615,7 +618,9 @@ struct ata_ioports {
struct ata_host {
spinlock_t lock;
struct device *dev;
- void __iomem * const *iomap;
+#ifdef CONFIG_PCI
+ void __iomem *iomap[PCI_STD_NUM_BARS];
+#endif /* CONFIG_PCI */
unsigned int n_ports;
unsigned int n_tags; /* nr of NCQ tags */
void *private_data;
--
2.47.0