Re: [PATCH v2 1/2] mcb: Use more than the first bar in pci devices

From: Johannes Thumshirn

Date: Tue Mar 03 2026 - 12:15:05 EST


Filip Jensen @ 2026-03-02 14:47 :


> +static int chameleon_get_bar(void __iomem **base, struct chameleon_bar **cb,
> + struct device *dev)
> {
> struct chameleon_bar *c;
> int bar_count;
> __le32 reg;
> u32 dtype;
> + struct pci_dev *pdev;

Sorry for not having noticed this in v1 but this...

> /*
> * For those devices which are not connected
> @@ -153,12 +155,15 @@ static int chameleon_get_bar(void __iomem **base, phys_addr_t mapbase,
> chameleon_parse_bar(*base, c, bar_count);
> *base += BAR_DESC_SIZE(bar_count);
> } else {

can be declared here, as it's not used outside of this block.

> - c = kzalloc_obj(struct chameleon_bar);
> + pdev = to_pci_dev(dev);
> + bar_count = PCI_STD_NUM_BARS;
> + c = kzalloc_objs(struct chameleon_bar, bar_count);
> if (!c)
> return -ENOMEM;
> -
> - bar_count = 1;
> - c->addr = mapbase;
> + for (int i = 0; i < bar_count; ++i) {
> + c[i].addr = pci_resource_start(pdev, i);
> + c[i].size = pci_resource_len(pdev, i);
> + }
> }