pci/pci_ivshmem: fix bug in remove and add vmid check

1. Should check the vmid in ivshmem_remove() when release irq instead
check the ivdev->reg;
2. Add vmid check in ivshmem_probe() because ivshmem driver only support
vmid == 0 or 1 for now in NuttX;

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
This commit is contained in:
Bowen Wang 2024-04-26 19:36:43 +08:00 committed by Xiang Xiao
parent 218210d26e
commit 9c91ed2360

View File

@ -247,6 +247,13 @@ static int ivshmem_probe(FAR struct pci_device_s *dev)
(FAR char *)ivdev->reg + IVSHMEM_REG_IVPOSITION, (FAR char *)ivdev->reg + IVSHMEM_REG_IVPOSITION,
&ivdev->vmid); &ivdev->vmid);
if (ivdev->vmid != 0 && ivdev->vmid != 1)
{
ret = -EINVAL;
pcierr("Vmid must be 0 or 1\n");
goto err_master;
}
ret = pci_alloc_irq(dev, &ivdev->irq, 1); ret = pci_alloc_irq(dev, &ivdev->irq, 1);
if (ret != 1) if (ret != 1)
{ {
@ -296,7 +303,7 @@ static void ivshmem_remove(FAR struct pci_device_s *dev)
FAR struct ivshmem_device_s *ivdev = dev->priv; FAR struct ivshmem_device_s *ivdev = dev->priv;
ivshmem_unregister_device(ivdev); ivshmem_unregister_device(ivdev);
if (ivdev->reg != NULL) if (ivdev->vmid != IVSHMEM_INVALID_VMID)
{ {
pci_release_irq(dev, &ivdev->irq, 1); pci_release_irq(dev, &ivdev->irq, 1);
} }