pci_ivshmem: return back to polling mode when interrupt mode invalid
Improve the pci ivshmem device compatibility, do not return error when irq mode init failed, fallback to the polling mode as mush as possible. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
This commit is contained in:
parent
707f0ce719
commit
eede50f465
1 changed files with 11 additions and 9 deletions
|
|
@ -255,23 +255,26 @@ static int ivshmem_probe(FAR struct pci_device_s *dev)
|
||||||
|
|
||||||
if (ivdev->vmid != 0 && ivdev->vmid != 1)
|
if (ivdev->vmid != 0 && ivdev->vmid != 1)
|
||||||
{
|
{
|
||||||
ret = -EINVAL;
|
pciwarn("Vmid=%"PRIu32" not 0/1, use polling mode\n", ivdev->vmid);
|
||||||
pcierr("Vmid must be 0 or 1\n");
|
ivdev->vmid = IVSHMEM_INVALID_VMID;
|
||||||
goto err_master;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pci_alloc_irq(dev, &ivdev->irq, 1);
|
ret = pci_alloc_irq(dev, &ivdev->irq, 1);
|
||||||
if (ret != 1)
|
if (ret != 1)
|
||||||
{
|
{
|
||||||
pcierr("Failed to allocate irq %d\n", ret);
|
pciwarn("Failed to allocate irq %d, use polling mode\n", ret);
|
||||||
goto err_master;
|
ivdev->vmid = IVSHMEM_INVALID_VMID;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pci_connect_irq(dev, &ivdev->irq, 1);
|
ret = pci_connect_irq(dev, &ivdev->irq, 1);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
pcierr("Failed to connect irq %d\n", ret);
|
pciwarn("Failed to connect irq %d, use polling mode\n", ret);
|
||||||
goto err_msi_alloc;
|
pci_release_irq(dev, &ivdev->irq, 1);
|
||||||
|
ivdev->vmid = IVSHMEM_INVALID_VMID;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
pciinfo("vmid=%" PRIu32 " irq=%d\n", ivdev->vmid, ivdev->irq);
|
pciinfo("vmid=%" PRIu32 " irq=%d\n", ivdev->vmid, ivdev->irq);
|
||||||
|
|
@ -281,6 +284,7 @@ static int ivshmem_probe(FAR struct pci_device_s *dev)
|
||||||
ivdev->vmid = IVSHMEM_INVALID_VMID;
|
ivdev->vmid = IVSHMEM_INVALID_VMID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
ret = ivshmem_register_device(ivdev);
|
ret = ivshmem_register_device(ivdev);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
|
@ -290,8 +294,6 @@ static int ivshmem_probe(FAR struct pci_device_s *dev)
|
||||||
g_ivshmem_next_id++;
|
g_ivshmem_next_id++;
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
err_msi_alloc:
|
|
||||||
pci_release_irq(dev, &ivdev->irq, 1);
|
|
||||||
err_master:
|
err_master:
|
||||||
pci_clear_master(dev);
|
pci_clear_master(dev);
|
||||||
pci_disable_device(dev);
|
pci_disable_device(dev);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue