Re: [PATCH v8 2/5] PCI: endpoint: Add BAR subrange mapping support

Niklas Cassel
2026-01-15T15:21:43Z

On Thu, Jan 15, 2026 at 09:52:58AM -0500, Frank Li wrote:
> > @@ -127,6 +150,10 @@ struct pci_epf_bar {
> > size_t mem_size;
> > enum pci_barno barno;
> > int flags;
> > +
> > + /* Optional sub-range mapping */
> > + unsigned int num_submap;
> > + struct pci_epf_bar_submap *submap;
>
> struct pci_epf_bar_submap submap[] __counted_by(num_submap);
>
> Not sure if use this simplify alloc/free.

Your suggestion changes the submap from a pointer to a flexible array
member.

A flexible array member must always be last in the struct,
and you can only have one flexible array member per struct.

Additionally, using a flexible array member requires the struct to
always be allocated on the heap. You can't allocate a struct with a
flexible array member on the stack.

So I'm not sure that if your suggestion is something we want.

Kind regards,
Niklas