From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XK2ZF-0003iL-0N for qemu-devel@nongnu.org; Wed, 20 Aug 2014 05:52:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XK2Z5-0007dq-FX for qemu-devel@nongnu.org; Wed, 20 Aug 2014 05:52:32 -0400 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:51175) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XK2Z4-0007cR-Fu for qemu-devel@nongnu.org; Wed, 20 Aug 2014 05:52:23 -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, 20 Aug 2014 19:52:17 +1000 Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id ADAD22CE8055 for ; Wed, 20 Aug 2014 19:52:15 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s7K9r9Hm16253114 for ; Wed, 20 Aug 2014 19:53:09 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s7K9qEou009337 for ; Wed, 20 Aug 2014 19:52:15 +1000 From: Gavin Shan Date: Wed, 20 Aug 2014 19:52:08 +1000 Message-Id: <1408528328-11560-3-git-send-email-gwshan@linux.vnet.ibm.com> In-Reply-To: <1408528328-11560-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1408528328-11560-1-git-send-email-gwshan@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC PATCH 2/2] VFIO: Clear stale MSIx table during EEH reset List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aik@ozlabs.ru, alex.williamson@redhat.com, Gavin Shan The PCI device MSIx table is cleaned out in hardware after EEH PE reset. However, we still hold the stale MSIx entries in QEMU, which should be cleared accordingly. Otherwise, we will run into another (recursive) EEH error and the PCI devices contained in the PE have to be offlined exceptionally. The patch clears stale MSIx table before EEH PE reset so that MSIx table could be restored properly after EEH PE reset. Signed-off-by: Gavin Shan --- hw/misc/vfio.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c index 1a3e7eb..3cf7f02 100644 --- a/hw/misc/vfio.c +++ b/hw/misc/vfio.c @@ -4424,6 +4424,8 @@ int vfio_container_ioctl(AddressSpace *as, int32_t groupid, { VFIOGroup *group; VFIOContainer *container; + VFIODevice *vdev; + struct vfio_eeh_pe_op *arg; int ret = -1; group = vfio_get_group(groupid, as); @@ -4442,7 +4444,29 @@ int vfio_container_ioctl(AddressSpace *as, int32_t groupid, switch (req) { case VFIO_CHECK_EXTENSION: case VFIO_IOMMU_SPAPR_TCE_GET_INFO: + break; case VFIO_EEH_PE_OP: + arg = (struct vfio_eeh_pe_op *)param; + switch (arg->op) { + case VFIO_EEH_PE_RESET_HOT: + case VFIO_EEH_PE_RESET_FUNDAMENTAL: + /* + * The MSIx table will be cleaned out by reset. We need + * disable it so that it can be reenabled properly. Also, + * the cached MSIx table should be cleared as it's not + * reflecting the contents in hardware. + */ + QLIST_FOREACH(vdev, &group->device_list, next) { + if (msix_enabled(&vdev->pdev)) { + vfio_disable_msix(vdev); + } + + msix_reset(&vdev->pdev); + } + + break; + } + break; default: /* Return an error on unknown requests */ -- 1.8.3.2