[PATCH 2/3] mcb: Fix detection of iomapped pci devices

From: Filip Jensen

Date: Thu Feb 26 2026 - 10:37:14 EST


The mcb driver in a PCI bus is not detecting if an attached device has
an iomapped or a memory mapped BAR, as all the addresses returned by
pci_resource_start end in 0.

Instead of the low level approach, which is still valid for lpc buses,
here it will be used the standard PCI helper pci_resource_flags for
checking if the PCI BAR is IO mapped (as it is done in mcb_pci_probe)

Reviewed-by: Jose Javier Rodriguez Barbarin <dev-josejavier.rodriguez@xxxxxxxxxx>
Signed-off-by: Filip Jensen <dev-Felipe.Jensen@xxxxxxxxxx>
---
drivers/mcb/mcb-parse.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/mcb/mcb-parse.c b/drivers/mcb/mcb-parse.c
index 806be67b960d..251be2428873 100644
--- a/drivers/mcb/mcb-parse.c
+++ b/drivers/mcb/mcb-parse.c
@@ -29,9 +29,9 @@ static int chameleon_parse_bdd(struct mcb_bus *bus,
return 0;
}

-static int chameleon_parse_gdd(struct mcb_bus *bus,
- struct chameleon_bar *cb,
- void __iomem *base, int bar_count)
+static int chameleon_parse_gdd(struct mcb_bus *bus, struct chameleon_bar *cb,
+ void __iomem *base, int bar_count,
+ bool mcb_is_pci_device)
{
struct chameleon_gdd __iomem *gdd =
(struct chameleon_gdd __iomem *) base;
@@ -76,8 +76,12 @@ static int chameleon_parse_gdd(struct mcb_bus *bus,
ret = 0;
goto err;
}
-
- if (dev_mapbase & 0x01) {
+ if (mcb_is_pci_device) {
+ if (pci_resource_flags(to_pci_dev(bus->carrier), mdev->bar) &
+ IORESOURCE_IO)
+ goto io_unsupported;
+ } else if (dev_mapbase & 0x01) {
+io_unsupported:
pr_info("IO mapped Device (16z%03d) not yet supported\n",
mdev->id);
ret = 0;
@@ -125,7 +129,7 @@ static void chameleon_parse_bar(void __iomem *base,
}

static int chameleon_get_bar(void __iomem **base, struct chameleon_bar **cb,
- struct device *dev)
+ struct device *dev, bool *mcb_is_pci_device)
{
struct chameleon_bar *c;
int bar_count;
@@ -154,6 +158,7 @@ static int chameleon_get_bar(void __iomem **base, struct chameleon_bar **cb,

chameleon_parse_bar(*base, c, bar_count);
*base += BAR_DESC_SIZE(bar_count);
+ *mcb_is_pci_device = false;
} else {
pdev = to_pci_dev(dev);
bar_count = PCI_STD_NUM_BARS;
@@ -164,6 +169,7 @@ static int chameleon_get_bar(void __iomem **base, struct chameleon_bar **cb,
c[i].addr = pci_resource_start(pdev, i);
c[i].size = pci_resource_len(pdev, i);
}
+ *mcb_is_pci_device = true;
}

*cb = c;
@@ -182,6 +188,7 @@ int chameleon_parse_cells(struct mcb_bus *bus, void __iomem *base)
int ret;
u32 hsize;
u32 table_size;
+ bool mcb_is_pci_device;

hsize = sizeof(struct chameleon_fpga_header);

@@ -207,7 +214,8 @@ int chameleon_parse_cells(struct mcb_bus *bus, void __iomem *base)
memcpy(bus->name, header->filename, CHAMELEON_FILENAME_LEN);
bus->name[CHAMELEON_FILENAME_LEN] = '\0';

- bar_count = chameleon_get_bar(&p, &cb, bus->carrier);
+ bar_count =
+ chameleon_get_bar(&p, &cb, bus->carrier, &mcb_is_pci_device);
if (bar_count < 0) {
ret = bar_count;
goto free_header;
@@ -216,7 +224,8 @@ int chameleon_parse_cells(struct mcb_bus *bus, void __iomem *base)
for_each_chameleon_cell(dtype, p) {
switch (dtype) {
case CHAMELEON_DTYPE_GENERAL:
- ret = chameleon_parse_gdd(bus, cb, p, bar_count);
+ ret = chameleon_parse_gdd(bus, cb, p, bar_count,
+ mcb_is_pci_device);
if (ret < 0)
goto free_bar;
p += sizeof(struct chameleon_gdd);
--
2.34.1