From: Yu Zhao <yu.zhao@intel.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: "jbarnes@virtuousgeek.org" <jbarnes@virtuousgeek.org>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v8 1/7] PCI: initialize and release SR-IOV capability
Date: Fri, 13 Feb 2009 20:30:19 +0800 [thread overview]
Message-ID: <20090213123019.GA16067@yzhao-otc.sh.intel.com> (raw)
In-Reply-To: <877i3uwa0j.fsf@basil.nowhere.org>
On Sat, Feb 14, 2009 at 12:56:44AM +0800, Andi Kleen wrote:
> Yu Zhao <yu.zhao@intel.com> writes:
> > +
> > +
> > +static int sriov_init(struct pci_dev *dev, int pos)
> > +{
> > + int i;
> > + int rc;
> > + int nres;
> > + u32 pgsz;
> > + u16 ctrl, total, offset, stride;
> > + struct pci_sriov *iov;
> > + struct resource *res;
> > + struct pci_dev *pdev;
> > +
> > + if (dev->pcie_type != PCI_EXP_TYPE_RC_END &&
> > + dev->pcie_type != PCI_EXP_TYPE_ENDPOINT)
> > + return -ENODEV;
> > +
>
> It would be a good idea to put a might_sleep() here just in
> case the msleep happens below and drivers call it incorrectly.
Yes, will do.
> > + pci_read_config_word(dev, pos + PCI_SRIOV_CTRL, &ctrl);
> > + if (ctrl & PCI_SRIOV_CTRL_VFE) {
> > + pci_write_config_word(dev, pos + PCI_SRIOV_CTRL, 0);
> > + msleep(100);
>
> That's really long. Hopefully that's really needed.
It's needed according to SR-IOV spec, however, these lines clear
the VF Enable bit if the BIOS or something else has set it. So it
doesn't always run into this.
> > +
> > + pci_write_config_word(dev, pos + PCI_SRIOV_CTRL, ctrl);
> > + pci_write_config_word(dev, pos + PCI_SRIOV_NUM_VF, total);
> > + pci_read_config_word(dev, pos + PCI_SRIOV_VF_OFFSET, &offset);
> > + pci_read_config_word(dev, pos + PCI_SRIOV_VF_STRIDE, &stride);
> > + if (!offset || (total > 1 && !stride))
> > + return -EIO;
> > +
> > + pci_read_config_dword(dev, pos + PCI_SRIOV_SUP_PGSIZE, &pgsz);
> > + i = PAGE_SHIFT > 12 ? PAGE_SHIFT - 12 : 0;
> > + pgsz &= ~((1 << i) - 1);
> > + if (!pgsz)
> > + return -EIO;
>
> All the error paths don't seem to undo the config space writes.
> How will the devices behave with half initialized context?
Since the VF Enable bit is cleared before the initialization, setting
others SR-IOV registers won't change state of the device. So it should
be OK even without undo these writes as long as the VF Enable bit is
not set.
Thanks,
Yu
next prev parent reply other threads:[~2009-02-13 12:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-10 8:59 [PATCH v8 0/7] PCI: Linux kernel SR-IOV support Yu Zhao
2009-02-10 8:59 ` [PATCH v8 1/7] PCI: initialize and release SR-IOV capability Yu Zhao
2009-02-13 16:56 ` Andi Kleen
2009-02-13 12:30 ` Yu Zhao [this message]
2009-02-13 17:49 ` Matthew Wilcox
2009-02-13 12:47 ` Yu Zhao
2009-02-10 8:59 ` [PATCH v8 2/7] PCI: restore saved SR-IOV state Yu Zhao
2009-02-10 8:59 ` [PATCH v8 3/7] PCI: reserve bus range for SR-IOV device Yu Zhao
2009-02-10 8:59 ` [PATCH v8 4/7] PCI: add SR-IOV API for Physical Function driver Yu Zhao
2009-02-10 8:59 ` [PATCH v8 5/7] PCI: handle SR-IOV Virtual Function Migration Yu Zhao
2009-02-10 8:59 ` [PATCH v8 6/7] PCI: document SR-IOV sysfs entries Yu Zhao
2009-02-10 8:59 ` [PATCH v8 7/7] PCI: manual for SR-IOV user and driver developer Yu Zhao
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=20090213123019.GA16067@yzhao-otc.sh.intel.com \
--to=yu.zhao@intel.com \
--cc=andi@firstfloor.org \
--cc=jbarnes@virtuousgeek.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.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