Re: MSIs not freed in GICv3 ITS driver

From: Thomas Gleixner

Date: Tue Apr 07 2026 - 06:52:14 EST


On Wed, Apr 01 2026 at 17:08, Marc Zyngier wrote:
> On Wed, 01 Apr 2026 13:01:49 +0100,
> Manivannan Sadhasivam <mani@xxxxxxxxxx> wrote:
> 1 *IS* a power of two. Any driver that does that is perfectly fine.
>
> A driver that does
>
> pci_alloc_irq_vectors(pdev, 1, 7, PCI_IRQ_MSI);
>
> or
>
> pci_alloc_irq_vectors(pdev, 7, 7, PCI_IRQ_MSI);
>
> is broken. *That* is what the PCI core code should enforce.

No.

The PCI MSI specification mandates that the number of MSI vectors
supported by a device has to be a power of two. That's what the kernel
reads from the 'Multiple Message Capable' field in the MSI control word.

It also mandates the the number of enabled vectors in the 'Multiple
Message Enable' field of the MSI control word is a power of two and has
to be less and equal than the Capable field.

But the specification does not mandate at all how many vectors a driver
uses for operation. It neither mandates that a device can actually
utilize all possible vectors it advertises.

So having a MSI capable device which supports 5 vectors is perfectly
valid. In order to do that, the device must have the Capable field
populated to '8' and PCI core has to write 8 to the Enable field in
order to allocate 5 vectors. That's the only requirement.

For MSI-X there is no explicit power of two requirement in the
specification at all. The message table size is encoded in the Table
Size field without any power of two requirement. The description of the
Pending Bit Array makes this entirely clear:

"The Pending Bit Array (PBA) structure, illustrated in Figure 6-4,
contains the function’s Pending Bits, one per Table entry, organized
as a packed array of bits within QWORDs. The last QWORD will not
necessarily be fully populated."

So it is clearly not something which can be enforced by the PCI core or
imposed on drivers. It's a problem of the underlying infrastructure.

If underlying infrastructure has power of two requirements to
e.g. allocate a redirection table, then it has to ensure that on its own
and not impose restrictions on everybody else for it's own conveniance.

Thanks,

tglx