From: David Gibson <david@gibson.dropbear.id.au>
To: Gavin Shan <gwshan@linux.vnet.ibm.com>
Cc: aik@ozlabs.ru, alex.williamson@redhat.com, qemu-ppc@nongnu.org,
qemu-devel@nongnu.org, agraf@suse.de
Subject: Re: [Qemu-devel] [PATCH 1/3] VFIO: Clear stale MSIx table during EEH reset
Date: Thu, 12 Mar 2015 12:04:59 +1100 [thread overview]
Message-ID: <20150312010459.GQ11973@voom.redhat.com> (raw)
In-Reply-To: <1426054314-19564-1-git-send-email-gwshan@linux.vnet.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 4048 bytes --]
On Wed, Mar 11, 2015 at 05:11:52PM +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 <gwshan@linux.vnet.ibm.com>
> ---
> 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)) {
Please use == 0 not !, remembering that !some_function() is the
success case hurts my brain.
> + break;
> + }
> + /* fallthru */
It doesn't look like the fallthrough will generate the correct error
message: it will say "unsupported ioctl" but
vfio_container_eeh_event() could fail for some other reason.
> 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)
> +{
> + VFIOGroup *group;
> + VFIODevice *vbasedev;
> + VFIOPCIDevice *vdev;
> +
> + group = vfio_get_group(groupid, as);
> + if (!group) {
> + vfio_put_group(group);
Is vfio_put_group(NULL) really what you want?
> + 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
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-03-12 1:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-11 6:11 [Qemu-devel] [PATCH 1/3] VFIO: Clear stale MSIx table during EEH reset Gavin Shan
2015-03-11 6:11 ` [Qemu-devel] [PATCH 2/3] VFIO: Clear INTx pending state on " Gavin Shan
2015-03-12 1:48 ` David Gibson
2015-03-12 3:07 ` Gavin Shan
2015-03-13 21:51 ` Alex Williamson
2015-03-16 1:04 ` Gavin Shan
2015-03-16 4:05 ` [Qemu-devel] [Qemu-ppc] " Benjamin Herrenschmidt
2015-03-16 14:34 ` Gavin Shan
2015-03-16 15:05 ` Alex Williamson
2015-03-16 15:38 ` Gavin Shan
2015-03-11 6:11 ` [Qemu-devel] [PATCH 3/3] sPAPR: Reenable EEH functionality on reboot Gavin Shan
2015-03-12 1:04 ` David Gibson [this message]
2015-03-12 3:02 ` [Qemu-devel] [PATCH 1/3] VFIO: Clear stale MSIx table during EEH reset Gavin Shan
2015-03-13 21:33 ` Alex Williamson
2015-03-15 22:27 ` Gavin Shan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150312010459.GQ11973@voom.redhat.com \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=aik@ozlabs.ru \
--cc=alex.williamson@redhat.com \
--cc=gwshan@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).