Skip to content

Commit

Permalink
pci_ivshmem: return back to polling mode when interrupt mode invalid
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
CV-Bowen committed Jan 14, 2025
1 parent be21e32 commit dc852ee
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions drivers/pci/pci_ivshmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,23 +255,26 @@ static int ivshmem_probe(FAR struct pci_device_s *dev)

if (ivdev->vmid != 0 && ivdev->vmid != 1)
{
ret = -EINVAL;
pcierr("Vmid must be 0 or 1\n");
goto err_master;
pciwarn("Vmid=%"PRIu32" not 0/1, use polling mode\n", ivdev->vmid);
ivdev->vmid = IVSHMEM_INVALID_VMID;
goto out;
}

ret = pci_alloc_irq(dev, &ivdev->irq, 1);
if (ret != 1)
{
pcierr("Failed to allocate irq %d\n", ret);
goto err_master;
pciwarn("Failed to allocate irq %d, use polling mode\n", ret);
ivdev->vmid = IVSHMEM_INVALID_VMID;
goto out;
}

ret = pci_connect_irq(dev, &ivdev->irq, 1);
if (ret < 0)
{
pcierr("Failed to connect irq %d\n", ret);
goto err_msi_alloc;
pciwarn("Failed to connect irq %d, use polling mode\n", ret);
pci_release_irq(dev, &ivdev->irq, 1);
ivdev->vmid = IVSHMEM_INVALID_VMID;
goto out;
}

pciinfo("vmid=%" PRIu32 " irq=%d\n", ivdev->vmid, ivdev->irq);
Expand All @@ -281,6 +284,7 @@ static int ivshmem_probe(FAR struct pci_device_s *dev)
ivdev->vmid = IVSHMEM_INVALID_VMID;
}

out:
ret = ivshmem_register_device(ivdev);
if (ret < 0)
{
Expand All @@ -290,8 +294,6 @@ static int ivshmem_probe(FAR struct pci_device_s *dev)
g_ivshmem_next_id++;
return ret;

err_msi_alloc:
pci_release_irq(dev, &ivdev->irq, 1);
err_master:
pci_clear_master(dev);
pci_disable_device(dev);
Expand Down

0 comments on commit dc852ee

Please sign in to comment.