From dc852ee13c6f7a54eb55fd7c1c225a4590deb232 Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Mon, 21 Oct 2024 16:58:03 +0800 Subject: [PATCH] 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 --- drivers/pci/pci_ivshmem.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/pci/pci_ivshmem.c b/drivers/pci/pci_ivshmem.c index 8c66f0b1218..bcf69de6289 100644 --- a/drivers/pci/pci_ivshmem.c +++ b/drivers/pci/pci_ivshmem.c @@ -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); @@ -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) { @@ -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);