[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [qemu-xen-4.3-testing] qemu-xen-trad: free all the pirqs for msi/msix when driver unloads



commit 8a7abb1694f22cb18616ee7a7a544b026c914bf9
Author:     Zhenzhong Duan <zhenzhong.duan@xxxxxxxxxx>
AuthorDate: Tue Apr 8 16:50:06 2014 +0000
Commit:     Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
CommitDate: Wed Jul 2 15:54:45 2014 +0100

    qemu-xen-trad: free all the pirqs for msi/msix when driver unloads
    
    Pirqs are not freed when driver unloads, then new pirqs are allocated when
    driver reloads. This could exhaust pirqs if do it in a loop.
    
    This patch fixes the bug by freeing pirqs when ENABLE bit is cleared in
    msi/msix control reg.
    
    There is also other way of fixing it such as reuse pirqs between driver 
reload,
    but this way is better.
    Xen-devel: http://marc.info/?l=xen-devel&m=136800120304275&w=2
    
    Signed-off-by: Zhenzhong Duan <zhenzhong.duan@xxxxxxxxxx>
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
    
    [ This is the qemu-xen-trad version of qemu-xen-upstream
      1d4fd4f0e2fc5dcae0c60e00cc9af95f52988050 -iwj ]
    (cherry picked from commit d0395cc49b2ec6d1723c01f1daf2394b9264ca29)
    (cherry picked from commit 6ae4e588081620b141071eb010ec40aca7e12876)
---
 hw/pass-through.c |    8 +++++++-
 hw/pt-msi.c       |    5 +++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/hw/pass-through.c b/hw/pass-through.c
index 304c438..4821182 100644
--- a/hw/pass-through.c
+++ b/hw/pass-through.c
@@ -3866,7 +3866,11 @@ static int pt_msgctrl_reg_write(struct pt_dev *ptdev,
         ptdev->msi->flags |= PCI_MSI_FLAGS_ENABLE;
     }
     else
-        ptdev->msi->flags &= ~PCI_MSI_FLAGS_ENABLE;
+    {
+        if (ptdev->msi->flags & PT_MSI_MAPPED) {
+            pt_msi_disable(ptdev);
+        }
+    }
 
     /* pass through MSI_ENABLE bit when no MSI-INTx translation */
     if (!ptdev->msi_trans_en) {
@@ -4013,6 +4017,8 @@ static int pt_msixctrl_reg_write(struct pt_dev *ptdev,
             pt_disable_msi_translate(ptdev);
         }
         pt_msix_update(ptdev);
+    } else if (!(*value & PCI_MSIX_ENABLE) && ptdev->msix->enabled) {
+        pt_msix_disable(ptdev);
     }
 
     ptdev->msix->enabled = !!(*value & PCI_MSIX_ENABLE);
diff --git a/hw/pt-msi.c b/hw/pt-msi.c
index b03b989..3f5f94b 100644
--- a/hw/pt-msi.c
+++ b/hw/pt-msi.c
@@ -213,7 +213,8 @@ void pt_msi_disable(struct pt_dev *dev)
 
 out:
     /* clear msi info */
-    dev->msi->flags &= ~(MSI_FLAG_UNINIT | PT_MSI_MAPPED | 
PCI_MSI_FLAGS_ENABLE);
+    dev->msi->flags &= ~(PT_MSI_MAPPED | PCI_MSI_FLAGS_ENABLE);
+    dev->msi->flags |= MSI_FLAG_UNINIT;
     dev->msi->pirq = -1;
     dev->msi_trans_en = 0;
 }
@@ -447,7 +448,7 @@ static void pci_msix_writel(void *opaque, 
target_phys_addr_t addr, uint32_t val)
     {
         const volatile uint32_t *vec_ctrl;
 
-        if ( entry->io_mem[offset] == val )
+        if ( entry->io_mem[offset] == val && entry->pirq != -1)
             return;
 
         /*
--
generated by git-patchbot for /home/xen/git/qemu-xen-4.3-testing.git

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.