xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Roger Pau Monne <roger.pau@citrix.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
	Julien Grall <julien.grall@arm.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v2 06/11] vpci/header: add teardown cleanup
Date: Fri, 28 Sep 2018 09:29:56 -0600	[thread overview]
Message-ID: <5BAE48F402000078001ECF7E@prv1-mh.provo.novell.com> (raw)
In-Reply-To: <20180717094830.54806-7-roger.pau@citrix.com>

>>> On 17.07.18 at 11:48, <roger.pau@citrix.com> wrote:
> --- a/xen/drivers/vpci/header.c
> +++ b/xen/drivers/vpci/header.c
> @@ -131,12 +131,15 @@ bool vpci_process_pending(struct vcpu *v)
>          if ( rc == -ERESTART )
>              return true;
>  
> -        spin_lock(&v->vpci.pdev->vpci_lock);
> -        if ( v->vpci.pdev->vpci )
> -            /* Disable memory decoding unconditionally on failure. */
> -            modify_decoding(v->vpci.pdev, !rc && v->vpci.map,
> -                            !rc && v->vpci.rom_only);
> -        spin_unlock(&v->vpci.pdev->vpci_lock);
> +        if ( v->vpci.pdev )
> +        {
> +            spin_lock(&v->vpci.pdev->vpci_lock);
> +            if ( v->vpci.pdev->vpci )
> +                /* Disable memory decoding unconditionally on failure. */
> +                modify_decoding(v->vpci.pdev, !rc && v->vpci.map,
> +                                !rc && v->vpci.rom_only);
> +            spin_unlock(&v->vpci.pdev->vpci_lock);
> +        }
>  
>          rangeset_destroy(v->vpci.mem);
>          v->vpci.mem = NULL;

A few lines down from here there is

            vpci_remove_device(v->vpci.pdev);

which I think has the same issue.

> @@ -560,7 +563,25 @@ static int init_bars(struct pci_dev *pdev)
>  
>      return (cmd & PCI_COMMAND_MEMORY) ? modify_bars(pdev, true, false) : 0;
>  }
> -REGISTER_VPCI_INIT(init_bars, NULL, VPCI_PRIORITY_MIDDLE);
> +
> +static void teardown_bars(struct pci_dev *pdev)
> +{
> +    uint16_t cmd = pci_conf_read16(pdev->seg, pdev->bus, PCI_SLOT(pdev->devfn),
> +                                   PCI_FUNC(pdev->devfn), PCI_COMMAND);
> +
> +    if ( cmd & PCI_COMMAND_MEMORY )
> +    {
> +        /* Unmap all BARs from guest p2m. */
> +        modify_bars(pdev, false, false);
> +        /*
> +         * Since this operation is deferred at the point when it finishes the
> +         * device might have been removed, so don't attempt to disable memory
> +         * decoding afterwards.
> +         */
> +        current->vpci.pdev = NULL;

Did you not mean to prefix the comment with FIXME: ? Ultimately
device removal should be delayed until all cleanup has been done,
imo.

Jan



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-09-28 15:30 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-17  9:48 [PATCH v2 00/11] vpci: add support for SR-IOV capability Roger Pau Monne
2018-07-17  9:48 ` [PATCH v2 01/11] vpci: move lock Roger Pau Monne
2018-09-06  9:57   ` Wei Liu
2018-09-26 10:37   ` Jan Beulich
2018-07-17  9:48 ` [PATCH v2 02/11] vpci/msix: add lock to protect the list of MSIX regions Roger Pau Monne
2018-09-26 10:42   ` Jan Beulich
2018-07-17  9:48 ` [PATCH v2 03/11] vpci: add tear down functions Roger Pau Monne
2018-09-06  9:57   ` Wei Liu
2018-09-26 10:50   ` Jan Beulich
2018-07-17  9:48 ` [PATCH v2 04/11] vpci/msix: add teardown cleanup Roger Pau Monne
2018-09-06 10:14   ` Wei Liu
2018-09-26 15:32   ` Jan Beulich
2018-07-17  9:48 ` [PATCH v2 05/11] vpci/msi: " Roger Pau Monne
2018-09-06 10:14   ` Wei Liu
2018-09-26 15:34   ` Jan Beulich
2018-07-17  9:48 ` [PATCH v2 06/11] vpci/header: " Roger Pau Monne
2018-09-28 15:29   ` Jan Beulich [this message]
2018-07-17  9:48 ` [PATCH v2 07/11] rangeset: introduce rangeset_merge Roger Pau Monne
2018-07-17  9:48 ` [PATCH v2 08/11] vpci/header: allow multiple map operations Roger Pau Monne
2018-09-28 15:38   ` Jan Beulich
2018-07-17  9:48 ` [PATCH v2 09/11] pci: add vpci hooks for device addition/removal Roger Pau Monne
2018-09-28 15:48   ` Jan Beulich
2018-07-17  9:48 ` [PATCH v2 10/11] vpci: add a wait operation to the vpci vcpu pending actions Roger Pau Monne
2018-07-17  9:48 ` [PATCH v2 11/11] vpci/sriov: add support for SR-IOV capability Roger Pau Monne
2018-09-06 10:37   ` Wei Liu
2018-09-07  9:16     ` Roger Pau Monné
2018-10-04 14:50   ` Jan Beulich

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=5BAE48F402000078001ECF7E@prv1-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=julien.grall@arm.com \
    --cc=konrad.wilk@oracle.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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).