From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXH1l-0000pW-BC for qemu-devel@nongnu.org; Sun, 15 Mar 2015 18:29:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YXH1a-0006xq-2j for qemu-devel@nongnu.org; Sun, 15 Mar 2015 18:28:57 -0400 Received: from e23smtp05.au.ibm.com ([202.81.31.147]:54754) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXH1Z-0006x0-GK for qemu-devel@nongnu.org; Sun, 15 Mar 2015 18:28:46 -0400 Received: from /spool/local by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Mar 2015 08:28:39 +1000 Date: Mon, 16 Mar 2015 09:27:35 +1100 From: Gavin Shan Message-ID: <20150315222735.GA3960@shangw> References: <1426054314-19564-1-git-send-email-gwshan@linux.vnet.ibm.com> <1426282430.3643.125.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1426282430.3643.125.camel@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/3] VFIO: Clear stale MSIx table during EEH reset Reply-To: Gavin Shan List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Williamson Cc: qemu-devel@nongnu.org, aik@ozlabs.ru, agraf@suse.de, Gavin Shan , qemu-ppc@nongnu.org, david@gibson.dropbear.id.au On Fri, Mar 13, 2015 at 03:33:50PM -0600, Alex Williamson wrote: >On Wed, 2015-03-11 at 17:11 +1100, Gavin Shan wrote: >> 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/vfio/common.c | 6 +++++- >> hw/vfio/pci.c | 39 +++++++++++++++++++++++++++++++++++++++ >> include/hw/vfio/vfio.h | 3 ++- >> 3 files changed, 46 insertions(+), 2 deletions(-) >> >> diff --git a/hw/vfio/common.c b/hw/vfio/common.c >> index 148eb53..e3833f4 100644 >> --- a/hw/vfio/common.c >> +++ b/hw/vfio/common.c >> @@ -949,8 +949,12 @@ int vfio_container_ioctl(AddressSpace *as, int32_t groupid, >> switch (req) { >> case VFIO_CHECK_EXTENSION: >> case VFIO_IOMMU_SPAPR_TCE_GET_INFO: >> - case VFIO_EEH_PE_OP: >> break; >> + case VFIO_EEH_PE_OP: >> + if (!vfio_container_eeh_event(as, groupid, param)) { >> + break; >> + } >> + /* fallthru */ >> default: >> /* Return an error on unknown requests */ >> error_report("vfio: unsupported ioctl %X", req); >> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c >> index 6b80539..8c4a8cb 100644 >> --- a/hw/vfio/pci.c >> +++ b/hw/vfio/pci.c >> @@ -3319,6 +3319,45 @@ static void vfio_unregister_req_notifier(VFIOPCIDevice *vdev) >> vdev->req_enabled = false; >> } >> >> +int vfio_container_eeh_event(AddressSpace *as, int32_t groupid, >> + struct vfio_eeh_pe_op *op) > >Called by common, but lives in pci. This would need a stub if QEMU is >built without CONFIG_PCI. Thanks, > Right. I'll add a stub for !CONFIG_PCI. Thanks, Gavin >Alex > >> +{ >> + VFIOGroup *group; >> + VFIODevice *vbasedev; >> + VFIOPCIDevice *vdev; >> + >> + group = vfio_get_group(groupid, as); >> + if (!group) { >> + vfio_put_group(group); >> + error_report("vfio: group %d not found\n", groupid); >> + return -1; >> + } >> + >> + switch (op->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(vbasedev, &group->device_list, next) { >> + vdev = container_of(vbasedev, VFIOPCIDevice, vbasedev); >> + if (msix_enabled(&vdev->pdev)) { >> + vfio_disable_msix(vdev); >> + } >> + >> + msix_reset(&vdev->pdev); >> + } >> + >> + break; >> + } >> + >> + vfio_put_group(group); >> + return 0; >> +} >> + >> static int vfio_initfn(PCIDevice *pdev) >> { >> VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev); >> diff --git a/include/hw/vfio/vfio.h b/include/hw/vfio/vfio.h >> index 0b26cd8..99528a3 100644 >> --- a/include/hw/vfio/vfio.h >> +++ b/include/hw/vfio/vfio.h >> @@ -5,5 +5,6 @@ >> >> extern int vfio_container_ioctl(AddressSpace *as, int32_t groupid, >> int req, void *param); >> - >> +extern int vfio_container_eeh_event(AddressSpace *as, int32_t groupid, >> + struct vfio_eeh_pe_op *op); >> #endif > > >