From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42863) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVZtJ-0003XV-PE for qemu-devel@nongnu.org; Wed, 11 Mar 2015 02:13:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YVZtD-00032J-K5 for qemu-devel@nongnu.org; Wed, 11 Mar 2015 02:13:13 -0400 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:33234) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVZtD-00031y-00 for qemu-devel@nongnu.org; Wed, 11 Mar 2015 02:13:07 -0400 Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 11 Mar 2015 16:13:03 +1000 From: Gavin Shan Date: Wed, 11 Mar 2015 17:11:53 +1100 Message-Id: <1426054314-19564-2-git-send-email-gwshan@linux.vnet.ibm.com> In-Reply-To: <1426054314-19564-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1426054314-19564-1-git-send-email-gwshan@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 2/3] VFIO: Clear INTx pending state on EEH reset List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aik@ozlabs.ru, agraf@suse.de, Gavin Shan , alex.williamson@redhat.com, qemu-ppc@nongnu.org, david@gibson.dropbear.id.au When Linux guest recovers from EEH error on the following Emulex adapter, the MSIx interrupts are disabled and the INTx emulation is enabled. One INTx interrupt is injected to the guest by host because of detected pending INTx interrupts on the adapter. QEMU disables mmap'ed BAR regions and starts a timer to enable those regions at later point the INTx interrupt handler. Unfortunately, "VFIOPCIDevice->intx.pending" isn't cleared, meaning those disabled mapp'ed BAR regions won't be reenabled properly. It leads to EEH recovery failure at guest side because of hanged MMIO access. # lspci | grep Emulex 0000:01:00.0 Ethernet controller: Emulex Corporation \ OneConnect 10Gb NIC (be3) (rev 02) 0000:01:00.1 Ethernet controller: Emulex Corporation \ OneConnect 10Gb NIC (be3) (rev 02) The patch clears "VFIOPCIDevice->intx.pending" after EEH reset is completed on the PE, which contains the adapter. In turn, the mmap'ed BAR regions can be reenabled to avoid EEH recovery failure. Signed-off-by: Gavin Shan --- hw/vfio/pci.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 8c4a8cb..55e0904 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3352,6 +3352,20 @@ int vfio_container_eeh_event(AddressSpace *as, int32_t groupid, } break; + case VFIO_EEH_PE_RESET_DEACTIVATE: + /* + * We might have INTx interrupt whose handler disabled the + * memory mapped BARs. Without clearing the INTx pending + * state, the timer kicked by the INTx interrupt handler + * won't enable those disabled memory mapped BARs, which + * leads EEH recovery failure. + */ + QLIST_FOREACH(vbasedev, &group->device_list, next) { + vdev = container_of(vbasedev, VFIOPCIDevice, vbasedev); + vdev->intx.pending = false; + } + + break; } vfio_put_group(group); -- 1.8.3.2