From: Matthew Wilcox <matthew@wil.cx>
To: Yu Zhao <yu.zhao@intel.com>
Cc: jbarnes@virtuousgeek.org, linux-pci@vger.kernel.org,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
"Randy.Dunlap" <rdunlap@xenotime.net>
Subject: Re: [PATCH v10 1/7] PCI: initialize and release SR-IOV capability
Date: Fri, 6 Mar 2009 13:08:10 -0700 [thread overview]
Message-ID: <20090306200810.GD25995@parisc-linux.org> (raw)
In-Reply-To: <1235112888-9524-2-git-send-email-yu.zhao@intel.com>
On Fri, Feb 20, 2009 at 02:54:42PM +0800, Yu Zhao wrote:
> +config PCI_IOV
> + bool "PCI IOV support"
> + depends on PCI
> + select PCI_MSI
My understanding is that having 'select' of a config symbol that the
user can choose is bad. I think we should probably make this 'depends
on PCI_MSI'.
PCI MSI can also be disabled at runtime (and Fedora do by default).
Since SR-IOV really does require MSI, we need to put in a runtime check
to see if pci_msi_enabled() is false.
We don't depend on PCIEPORTBUS (a horribly named symbol). Should we?
SR-IOV is only supported for PCI Express machines. I'm not sure of the
right answer here, but I thought I should raise the question.
> + default n
You don't need this -- the default default is n ;-)
> + help
> + PCI-SIG I/O Virtualization (IOV) Specifications support.
> + Single Root IOV: allows the Physical Function driver to enable
> + the hardware capability, so the Virtual Function is accessible
> + via the PCI Configuration Space using its own Bus, Device and
> + Function Numbers. Each Virtual Function also has the PCI Memory
> + Space to map the device specific register set.
I'm not convinced this is the most helpful we could be to the user who's
configuring their own kernel. How about something like this? (Randy, I
particularly look to you to make my prose less turgid).
help
IO Virtualisation is a PCI feature supported by some devices
which allows you to create virtual PCI devices and assign them
to guest OSes. This option needs to be selected in the host
or Dom0 kernel, but does not need to be selected in the guest
or DomU kernel. If you don't know whether your hardware supports
it, you can check by using lspci to look for the SR-IOV capability.
If you have no idea what any of that means, it is safe to
answer 'N' here.
> diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
> index 3d07ce2..ba99282 100644
> --- a/drivers/pci/Makefile
> +++ b/drivers/pci/Makefile
> @@ -29,6 +29,9 @@ obj-$(CONFIG_DMAR) += dmar.o iova.o intel-iommu.o
>
> obj-$(CONFIG_INTR_REMAP) += dmar.o intr_remapping.o
>
> +# PCI IOV support
> +obj-$(CONFIG_PCI_IOV) += iov.o
I see you're following the gerneal style in this file, but the comments
really add no value. I should send a patch to take out the existing ones.
> + list_for_each_entry(pdev, &dev->bus->devices, bus_list)
> + if (pdev->sriov)
> + break;
> + if (list_empty(&dev->bus->devices) || !pdev->sriov)
> + pdev = NULL;
> + ctrl = 0;
> + if (!pdev && pci_ari_enabled(dev->bus))
> + ctrl |= PCI_SRIOV_CTRL_ARI;
> +
I don't like this loop. At the end of a list_for_each_entry() loop,
pdev will not be pointing at a pci_device, it'll be pointing to some
offset from &dev->bus->devices. So checking pdev->sriov at this point
is really, really bad. I would prefer to see something like this:
ctrl = 0;
list_for_each_entry(pdev, &dev->bus->devices, bus_list) {
if (pdev->sriov)
goto ari_enabled;
}
if (pci_ari_enabled(dev->bus))
ctrl = PCI_SRIOV_CTRL_ARI;
ari_enabled:
pci_write_config_word(dev, pos + PCI_SRIOV_CTRL, ctrl);
> + if (pdev)
> + iov->pdev = pci_dev_get(pdev);
> + else {
> + iov->pdev = dev;
> + mutex_init(&iov->lock);
> + }
Now I'm confused. Why don't we need to init the mutex if there's another
device on the same bus which also has an iov capability?
> +static void sriov_release(struct pci_dev *dev)
> +{
> + if (dev == dev->sriov->pdev)
> + mutex_destroy(&dev->sriov->lock);
> + else
> + pci_dev_put(dev->sriov->pdev);
> +
> + kfree(dev->sriov);
> + dev->sriov = NULL;
> +}
> +void pci_iov_release(struct pci_dev *dev)
> +{
> + if (dev->sriov)
> + sriov_release(dev);
> +}
This seems to be a bit of a design pattern with you, and I'm not quite sure why you do it like this instead of just doing:
void pci_iov_release(struct pci_dev *dev)
{
if (!dev->sriov)
return;
[...]
}
--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
next prev parent reply other threads:[~2009-03-06 20:08 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-20 6:54 [PATCH v10 0/7] PCI: Linux kernel SR-IOV support Yu Zhao
2009-02-20 6:54 ` [PATCH v10 1/7] PCI: initialize and release SR-IOV capability Yu Zhao
2009-03-06 20:08 ` Matthew Wilcox [this message]
2009-03-06 22:03 ` Randy Dunlap
2009-03-06 23:31 ` Duyck, Alexander H
2009-03-07 2:38 ` Greg KH
2009-03-10 1:19 ` Yu Zhao
2009-03-11 4:36 ` Greg KH
2009-03-09 8:12 ` Yu Zhao
2009-02-20 6:54 ` [PATCH v10 2/7] PCI: restore saved SR-IOV state Yu Zhao
2009-03-06 20:09 ` Matthew Wilcox
2009-02-20 6:54 ` [PATCH v10 3/7] PCI: reserve bus range for SR-IOV device Yu Zhao
2009-03-06 20:20 ` Matthew Wilcox
2009-03-09 8:13 ` Yu Zhao
2009-03-09 18:09 ` Randy Dunlap
2009-03-09 18:11 ` Matthew Wilcox
2009-02-20 6:54 ` [PATCH v10 4/7] PCI: add SR-IOV API for Physical Function driver Yu Zhao
2009-03-06 20:37 ` Matthew Wilcox
2009-03-06 21:48 ` Randy Dunlap
2009-03-09 8:29 ` Yu Zhao
2009-03-07 2:40 ` Greg KH
2009-03-09 8:25 ` Yu Zhao
2009-03-09 19:39 ` Greg KH
2009-03-10 1:37 ` Yu Zhao
2009-03-11 4:34 ` Greg KH
2009-02-20 6:54 ` [PATCH v10 5/7] PCI: handle SR-IOV Virtual Function Migration Yu Zhao
2009-03-06 21:13 ` Matthew Wilcox
2009-03-09 8:28 ` Yu Zhao
2009-02-20 6:54 ` [PATCH v10 6/7] PCI: document SR-IOV sysfs entries Yu Zhao
2009-03-06 21:16 ` Matthew Wilcox
2009-03-06 22:35 ` Randy Dunlap
2009-02-20 6:54 ` [PATCH v10 7/7] PCI: manual for SR-IOV user and driver developer Yu Zhao
2009-03-06 21:17 ` Matthew Wilcox
2009-02-24 10:47 ` [PATCH v10 0/7] PCI: Linux kernel SR-IOV support Avi Kivity
2009-02-25 1:36 ` Yu Zhao
2009-03-06 19:33 ` Matthew Wilcox
2009-03-08 14:30 ` Avi Kivity
2009-03-08 15:01 ` Matthew Wilcox
2009-03-09 0:45 ` Greg KH
2009-03-09 3:42 ` Yang, Sheng
2009-03-09 4:35 ` Yang, Sheng
2009-03-09 13:45 ` Avi Kivity
2009-03-06 19:44 ` Matthew Wilcox
2009-03-07 2:34 ` Greg KH
2009-03-10 1:11 ` 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=20090306200810.GD25995@parisc-linux.org \
--to=matthew@wil.cx \
--cc=jbarnes@virtuousgeek.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=rdunlap@xenotime.net \
--cc=yu.zhao@intel.com \
/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