xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Chao Gao <chao.gao@intel.com>
Cc: Juergen Gross <jgross@suse.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	linux-kernel@vger.kernel.org, Jia-Ju Bai <baijiaju1990@gmail.com>,
	xen-devel <xen-devel@lists.xenproject.org>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: Re: [PATCH] xen: xen-pciback: Reset MSI-X state when exposing a device
Date: Wed, 05 Dec 2018 09:26:32 -0700	[thread overview]
Message-ID: <5C07FC380200007800203394__45026.2645645582$1544027132$gmane$org@prv1-mh.provo.novell.com> (raw)
In-Reply-To: <1543976357-1053-1-git-send-email-chao.gao@intel.com>

>>> On 05.12.18 at 03:19, <chao.gao@intel.com> wrote:
> --- a/drivers/xen/xen-pciback/pci_stub.c
> +++ b/drivers/xen/xen-pciback/pci_stub.c
> @@ -87,6 +87,55 @@ static struct pcistub_device *pcistub_device_alloc(struct pci_dev *dev)
>  	return psdev;
>  }
>  
> +/*
> + * Reset Xen internal MSI-X state by invoking PHYSDEVOP_{release, prepare}_msix.
> + */
> +int pcistub_msix_reset(struct pci_dev *dev)
> +{
> +#ifdef CONFIG_PCI_MSI
> +	if (dev->msix_cap) {
> +		struct physdev_pci_device ppdev = {
> +			.seg = pci_domain_nr(dev->bus),
> +			.bus = dev->bus->number,
> +			.devfn = dev->devfn
> +		};
> +		int err;
> +		u16 val;
> +
> +		/*
> +		 * Do a write first to flush Xen's internal state to hardware
> +		 * such that the following read can infer whether MSI-X maskall
> +		 * bit is set by Xen.
> +		 */
> +		pci_read_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, &val);
> +		pci_write_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, val);
> +
> +		pci_read_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, &val);
> +		if (!(val & PCI_MSIX_FLAGS_MASKALL))
> +			return 0;

I'm agreeing with prior comments: I don't see why you need
this conditional.

> +		pr_info("Reset MSI-X state for device %04x:%02x:%02x.%d\n",
> +			ppdev.seg, ppdev.bus, PCI_SLOT(ppdev.devfn),
> +			PCI_FUNC(ppdev.devfn));
> +
> +		err = HYPERVISOR_physdev_op(PHYSDEVOP_release_msix, &ppdev);
> +		if (err) {
> +			dev_warn(&dev->dev, "MSI-X release failed (%d)\n",
> +				 err);
> +			return err;
> +		}
> +
> +		err = HYPERVISOR_physdev_op(PHYSDEVOP_prepare_msix, &ppdev);
> +		if (err) {
> +			dev_err(&dev->dev, "MSI-X preparation failed (%d)\n",
> +				err);

Please can you make both log messages distinguishable from
the pre-existing ones, to aid diagnosis of possible probelms?

Jan



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

  parent reply	other threads:[~2018-12-05 16:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1543976357-1053-1-git-send-email-chao.gao@intel.com>
2018-12-05  9:32 ` [PATCH] xen: xen-pciback: Reset MSI-X state when exposing a device Roger Pau Monné
2018-12-05 16:26 ` Jan Beulich [this message]
     [not found] ` <20181205093223.dncg4nq4dh6xmrhk@mac>
2018-12-05 14:01   ` Boris Ostrovsky
2018-12-06  2:18   ` Chao Gao
     [not found]   ` <c27236d3-6125-4049-6268-3d9c93cf3ef2@oracle.com>
2018-12-12  7:06     ` Chao Gao
     [not found]     ` <20181212070654.GA13411@gao-cwp>
2018-12-12  8:51       ` Jan Beulich
     [not found]       ` <5C10CBF50200007800205596@prv1-mh.provo.novell.com>
2018-12-12 15:18         ` Chao Gao
     [not found]         ` <20181212151824.GA17227@gao-cwp>
2018-12-12 15:21           ` Jan Beulich
     [not found]           ` <5C112783020000780020589C@prv1-mh.provo.novell.com>
2018-12-13  3:46             ` Chao Gao
     [not found]             ` <20181213034657.GA26926@gao-cwp>
2018-12-13  7:54               ` Jan Beulich
     [not found]               ` <5C12104C0200007800205B4B@prv1-mh.provo.novell.com>
2018-12-13 13:17                 ` Chao Gao
2019-09-13 10:02 ` [Xen-devel] " Spassov, Stanislav
2019-09-13 15:28   ` Chao Gao
2019-09-26 10:13     ` Pasi Kärkkäinen
2019-09-26 10:54       ` Spassov, Stanislav
2020-01-17 18:57       ` Rich Persaud
2020-01-18  1:13         ` Chao Gao
2018-12-05  2:19 Chao Gao

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='5C07FC380200007800203394__45026.2645645582$1544027132$gmane$org@prv1-mh.provo.novell.com' \
    --to=jbeulich@suse.com \
    --cc=baijiaju1990@gmail.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=chao.gao@intel.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --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).