Skip to contentSkip to conversation

Questions about vfio-pci

DISCUSSION yangjinqian via 2 participants 2 messages Mar 25, 2025 – Mar 26, 2025

lore
Share & tools
lore
#0 lore raw

Hi,

I'm observing intermittent failures when enabling the HNS3 network port in VM using QEMU with the mainline kernel.

HNS3 drive in kernel:
static int hns3_nic_net_up(struct net_device *netdev) {
......

       /* enable the vectors */
       for (i = 0; i < vector_num; i++)
{
napi_enable(napi);
             enable_irq(vector_irq);
             hns3_mask_vector_irq(tqp_vector, 1);
       }

......
}

When the VM has two vCPUs, the guest HNS3 driver performs two sequential enable_irq operations (vector_num=2). The enable_irq will trap into KVM for interrupt configuration and exit to QEMU for PCI device emulation. When emulating interrupt enabling in QEMU, vfio_[intx/msi/msix]_enable calls vfio_disable_interrupts to disable all interrupts on the vdev.

The questions are:

1. Why does the vfio-pci disable all interrupts of the device before enabling irqs?

2. Is this a normal vfio-pci process or a problem?

Thanks
Jinqian

#1 lore raw

Hello Jinqian

Quoted 5 lines · yangjinqian via

Hi,

I'm observing intermittent failures when enabling the HNS3 network port in VM using

QEMU with the mainline kernel.

Would you mind opening a gitlab issue with more details on the context, host, guest, HW ?

https://gitlab.com/qemu-project/qemu/-/issues/

Thanks,

C.

Quoted 38 lines

HNS3 drive in kernel:

static int hns3_nic_net_up(struct net_device *netdev)

{

......

       /* enable the vectors */

       for (i = 0; i < vector_num; i++)

{

napi_enable(napi);

             enable_irq(vector_irq);

             hns3_mask_vector_irq(tqp_vector, 1);

       }

......

}

When the VM has two vCPUs, the guest HNS3 driver performs two sequential

enable_irq operations (vector_num=2). The enable_irq will trap into KVM for interrupt

configuration and exit to QEMU for PCI device emulation. When emulating interrupt

enabling in QEMU, vfio_[intx/msi/msix]_enable calls vfio_disable_interrupts to disable

all interrupts on the vdev.

The questions are:

Quoted 8 lines

1.Why does the vfio-pci disable all interrupts of the device before enabling irqs?

2.Is this a normal vfio-pci process or a problem?

Thanks

Jinqian

Would