Re: [PATCH v2 3/3] misc: pci_endpoint_test: Fix irq_type to convey the correct type

From: Niklas Cassel
Date: Fri Jan 31 2025 - 07:20:51 EST


On Fri, Jan 31, 2025 at 01:10:54PM +0100, Niklas Cassel wrote:
> >
> > If SET_IRQTYPE is AUTO, how will test->irq_type be set?
>
> I was thinking something like this:
>
> pci_endpoint_test_set_irq()
> {
> u32 caps = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_CAPS);
>
> ...
>
> if (req_irq_type == IRQ_TYPE_AUTO) {
> if (caps & MSI_CAPABLE)
> test->irq_type = IRQ_TYPE_MSI;
> else if (caps & MSIX_CAPABLE)
> test->irq_type = IRQ_TYPE_MSIX;
> else
> test->irq_type = IRQ_TYPE_INTX;
>
> }
>
> ...
> }


Or even simpler (since it requires less changes to
pci_endpoint_test_set_irq()):

if (req_irq_type == IRQ_TYPE_AUTO) {
if (caps & MSI_CAPABLE)
req_irq_type = IRQ_TYPE_MSI;
else if (caps & MSIX_CAPABLE)
req_irq_type = IRQ_TYPE_MSIX;
else
req_irq_type = IRQ_TYPE_INTX;

}

...

/* Sets test->irq_type = req_irq_type; on success */
pci_endpoint_test_alloc_irq_vectors();



Kind regards,
Niklas