aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/iov.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-04-01 18:14:04 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-01 18:14:04 -0400
commit4b1779c2cf030c68aefe939d946475e4136c1895 (patch)
tree27e4bda2f6c8d269d02dec52a62dd1443880c6dc /drivers/pci/iov.c
parent62ff577fa2fec87edbf26f53e87210ba726d4d44 (diff)
parent30723cbf6f7aec2ab4810bdc4bf12c5749a09e33 (diff)
Merge tag 'pci-v3.15-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
Pull PCI changes from Bjorn Helgaas: "Enumeration - Increment max correctly in pci_scan_bridge() (Andreas Noever) - Clarify the "scan anyway" comment in pci_scan_bridge() (Andreas Noever) - Assign CardBus bus number only during the second pass (Andreas Noever) - Use request_resource_conflict() instead of insert_ for bus numbers (Andreas Noever) - Make sure bus number resources stay within their parents bounds (Andreas Noever) - Remove pci_fixup_parent_subordinate_busnr() (Andreas Noever) - Check for child busses which use more bus numbers than allocated (Andreas Noever) - Don't scan random busses in pci_scan_bridge() (Andreas Noever) - x86: Drop pcibios_scan_root() check for bus already scanned (Bjorn Helgaas) - x86: Use pcibios_scan_root() instead of pci_scan_bus_with_sysdata() (Bjorn Helgaas) - x86: Use pcibios_scan_root() instead of pci_scan_bus_on_node() (Bjorn Helgaas) - x86: Merge pci_scan_bus_on_node() into pcibios_scan_root() (Bjorn Helgaas) - x86: Drop return value of pcibios_scan_root() (Bjorn Helgaas) NUMA - x86: Add x86_pci_root_bus_node() to look up NUMA node from PCI bus (Bjorn Helgaas) - x86: Use x86_pci_root_bus_node() instead of get_mp_bus_to_node() (Bjorn Helgaas) - x86: Remove mp_bus_to_node[], set_mp_bus_to_node(), get_mp_bus_to_node() (Bjorn Helgaas) - x86: Use NUMA_NO_NODE, not -1, for unknown node (Bjorn Helgaas) - x86: Remove acpi_get_pxm() usage (Bjorn Helgaas) - ia64: Use NUMA_NO_NODE, not MAX_NUMNODES, for unknown node (Bjorn Helgaas) - ia64: Remove acpi_get_pxm() usage (Bjorn Helgaas) - ACPI: Fix acpi_get_node() prototype (Bjorn Helgaas) Resource management - i2o: Fix and refactor PCI space allocation (Bjorn Helgaas) - Add resource_contains() (Bjorn Helgaas) - Add %pR support for IORESOURCE_UNSET (Bjorn Helgaas) - Mark resources as IORESOURCE_UNSET if we can't assign them (Bjorn Helgaas) - Don't clear IORESOURCE_UNSET when updating BAR (Bjorn Helgaas) - Check IORESOURCE_UNSET before updating BAR (Bjorn Helgaas) - Don't try to claim IORESOURCE_UNSET resources (Bjorn Helgaas) - Mark 64-bit resource as IORESOURCE_UNSET if we only support 32-bit (Bjorn Helgaas) - Don't enable decoding if BAR hasn't been assigned an address (Bjorn Helgaas) - Add "weak" generic pcibios_enable_device() implementation (Bjorn Helgaas) - alpha, microblaze, sh, sparc, tile: Use default pcibios_enable_device() (Bjorn Helgaas) - s390: Use generic pci_enable_resources() (Bjorn Helgaas) - Don't check resource_size() in pci_bus_alloc_resource() (Bjorn Helgaas) - Set type in __request_region() (Bjorn Helgaas) - Check all IORESOURCE_TYPE_BITS in pci_bus_alloc_from_region() (Bjorn Helgaas) - Change pci_bus_alloc_resource() type_mask to unsigned long (Bjorn Helgaas) - Log IDE resource quirk in dmesg (Bjorn Helgaas) - Revert "[PATCH] Insert GART region into resource map" (Bjorn Helgaas) PCI device hotplug - Make check_link_active() non-static (Rajat Jain) - Use link change notifications for hot-plug and removal (Rajat Jain) - Enable link state change notifications (Rajat Jain) - Don't disable the link permanently during removal (Rajat Jain) - Don't check adapter or latch status while disabling (Rajat Jain) - Disable link notification across slot reset (Rajat Jain) - Ensure very fast hotplug events are also processed (Rajat Jain) - Add hotplug_lock to serialize hotplug events (Rajat Jain) - Remove a non-existent card, regardless of "surprise" capability (Rajat Jain) - Don't turn slot off when hot-added device already exists (Yijing Wang) MSI - Keep pci_enable_msi() documentation (Alexander Gordeev) - ahci: Fix broken single MSI fallback (Alexander Gordeev) - ahci, vfio: Use pci_enable_msi_range() (Alexander Gordeev) - Check kmalloc() return value, fix leak of name (Greg Kroah-Hartman) - Fix leak of msi_attrs (Greg Kroah-Hartman) - Fix pci_msix_vec_count() htmldocs failure (Masanari Iida) Virtualization - Device-specific ACS support (Alex Williamson) Freescale i.MX6 - Wait for retraining (Marek Vasut) Marvell MVEBU - Use Device ID and revision from underlying endpoint (Andrew Lunn) - Fix incorrect size for PCI aperture resources (Jason Gunthorpe) - Call request_resource() on the apertures (Jason Gunthorpe) - Fix potential issue in range parsing (Jean-Jacques Hiblot) Renesas R-Car - Check platform_get_irq() return code (Ben Dooks) - Add error interrupt handling (Ben Dooks) - Fix bridge logic configuration accesses (Ben Dooks) - Register each instance independently (Magnus Damm) - Break out window size handling (Magnus Damm) - Make the Kconfig dependencies more generic (Magnus Damm) Synopsys DesignWare - Fix RC BAR to be single 64-bit non-prefetchable memory (Mohit Kumar) Miscellaneous - Remove unused SR-IOV VF Migration support (Bjorn Helgaas) - Enable INTx if BIOS left them disabled (Bjorn Helgaas) - Fix hex vs decimal typo in cpqhpc_probe() (Dan Carpenter) - Clean up par-arch object file list (Liviu Dudau) - Set IORESOURCE_ROM_SHADOW only for the default VGA device (Sander Eikelenboom) - ACPI, ARM, drm, powerpc, pcmcia, PCI: Use list_for_each_entry() for bus traversal (Yijing Wang) - Fix pci_bus_b() build failure (Paul Gortmaker)" * tag 'pci-v3.15-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (108 commits) Revert "[PATCH] Insert GART region into resource map" PCI: Log IDE resource quirk in dmesg PCI: Change pci_bus_alloc_resource() type_mask to unsigned long PCI: Check all IORESOURCE_TYPE_BITS in pci_bus_alloc_from_region() resources: Set type in __request_region() PCI: Don't check resource_size() in pci_bus_alloc_resource() s390/PCI: Use generic pci_enable_resources() tile PCI RC: Use default pcibios_enable_device() sparc/PCI: Use default pcibios_enable_device() (Leon only) sh/PCI: Use default pcibios_enable_device() microblaze/PCI: Use default pcibios_enable_device() alpha/PCI: Use default pcibios_enable_device() PCI: Add "weak" generic pcibios_enable_device() implementation PCI: Don't enable decoding if BAR hasn't been assigned an address PCI: Enable INTx in pci_reenable_device() only when MSI/MSI-X not enabled PCI: Mark 64-bit resource as IORESOURCE_UNSET if we only support 32-bit PCI: Don't try to claim IORESOURCE_UNSET resources PCI: Check IORESOURCE_UNSET before updating BAR PCI: Don't clear IORESOURCE_UNSET when updating BAR PCI: Mark resources as IORESOURCE_UNSET if we can't assign them ... Conflicts: arch/x86/include/asm/topology.h drivers/ata/ahci.c
Diffstat (limited to 'drivers/pci/iov.c')
-rw-r--r--drivers/pci/iov.c119
1 files changed, 0 insertions, 119 deletions
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 9dce7c5e2a77..de7a74782f92 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -170,97 +170,6 @@ static void virtfn_remove(struct pci_dev *dev, int id, int reset)
170 pci_dev_put(dev); 170 pci_dev_put(dev);
171} 171}
172 172
173static int sriov_migration(struct pci_dev *dev)
174{
175 u16 status;
176 struct pci_sriov *iov = dev->sriov;
177
178 if (!iov->num_VFs)
179 return 0;
180
181 if (!(iov->cap & PCI_SRIOV_CAP_VFM))
182 return 0;
183
184 pci_read_config_word(dev, iov->pos + PCI_SRIOV_STATUS, &status);
185 if (!(status & PCI_SRIOV_STATUS_VFM))
186 return 0;
187
188 schedule_work(&iov->mtask);
189
190 return 1;
191}
192
193static void sriov_migration_task(struct work_struct *work)
194{
195 int i;
196 u8 state;
197 u16 status;
198 struct pci_sriov *iov = container_of(work, struct pci_sriov, mtask);
199
200 for (i = iov->initial_VFs; i < iov->num_VFs; i++) {
201 state = readb(iov->mstate + i);
202 if (state == PCI_SRIOV_VFM_MI) {
203 writeb(PCI_SRIOV_VFM_AV, iov->mstate + i);
204 state = readb(iov->mstate + i);
205 if (state == PCI_SRIOV_VFM_AV)
206 virtfn_add(iov->self, i, 1);
207 } else if (state == PCI_SRIOV_VFM_MO) {
208 virtfn_remove(iov->self, i, 1);
209 writeb(PCI_SRIOV_VFM_UA, iov->mstate + i);
210 state = readb(iov->mstate + i);
211 if (state == PCI_SRIOV_VFM_AV)
212 virtfn_add(iov->self, i, 0);
213 }
214 }
215
216 pci_read_config_word(iov->self, iov->pos + PCI_SRIOV_STATUS, &status);
217 status &= ~PCI_SRIOV_STATUS_VFM;
218 pci_write_config_word(iov->self, iov->pos + PCI_SRIOV_STATUS, status);
219}
220
221static int sriov_enable_migration(struct pci_dev *dev, int nr_virtfn)
222{
223 int bir;
224 u32 table;
225 resource_size_t pa;
226 struct pci_sriov *iov = dev->sriov;
227
228 if (nr_virtfn <= iov->initial_VFs)
229 return 0;
230
231 pci_read_config_dword(dev, iov->pos + PCI_SRIOV_VFM, &table);
232 bir = PCI_SRIOV_VFM_BIR(table);
233 if (bir > PCI_STD_RESOURCE_END)
234 return -EIO;
235
236 table = PCI_SRIOV_VFM_OFFSET(table);
237 if (table + nr_virtfn > pci_resource_len(dev, bir))
238 return -EIO;
239
240 pa = pci_resource_start(dev, bir) + table;
241 iov->mstate = ioremap(pa, nr_virtfn);
242 if (!iov->mstate)
243 return -ENOMEM;
244
245 INIT_WORK(&iov->mtask, sriov_migration_task);
246
247 iov->ctrl |= PCI_SRIOV_CTRL_VFM | PCI_SRIOV_CTRL_INTR;
248 pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl);
249
250 return 0;
251}
252
253static void sriov_disable_migration(struct pci_dev *dev)
254{
255 struct pci_sriov *iov = dev->sriov;
256
257 iov->ctrl &= ~(PCI_SRIOV_CTRL_VFM | PCI_SRIOV_CTRL_INTR);
258 pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl);
259
260 cancel_work_sync(&iov->mtask);
261 iounmap(iov->mstate);
262}
263
264static int sriov_enable(struct pci_dev *dev, int nr_virtfn) 173static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
265{ 174{
266 int rc; 175 int rc;
@@ -351,12 +260,6 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
351 goto failed; 260 goto failed;
352 } 261 }
353 262
354 if (iov->cap & PCI_SRIOV_CAP_VFM) {
355 rc = sriov_enable_migration(dev, nr_virtfn);
356 if (rc)
357 goto failed;
358 }
359
360 kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE); 263 kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE);
361 iov->num_VFs = nr_virtfn; 264 iov->num_VFs = nr_virtfn;
362 265
@@ -387,9 +290,6 @@ static void sriov_disable(struct pci_dev *dev)
387 if (!iov->num_VFs) 290 if (!iov->num_VFs)
388 return; 291 return;
389 292
390 if (iov->cap & PCI_SRIOV_CAP_VFM)
391 sriov_disable_migration(dev);
392
393 for (i = 0; i < iov->num_VFs; i++) 293 for (i = 0; i < iov->num_VFs; i++)
394 virtfn_remove(dev, i, 0); 294 virtfn_remove(dev, i, 0);
395 295
@@ -688,25 +588,6 @@ void pci_disable_sriov(struct pci_dev *dev)
688EXPORT_SYMBOL_GPL(pci_disable_sriov); 588EXPORT_SYMBOL_GPL(pci_disable_sriov);
689 589
690/** 590/**
691 * pci_sriov_migration - notify SR-IOV core of Virtual Function Migration
692 * @dev: the PCI device
693 *
694 * Returns IRQ_HANDLED if the IRQ is handled, or IRQ_NONE if not.
695 *
696 * Physical Function driver is responsible to register IRQ handler using
697 * VF Migration Interrupt Message Number, and call this function when the
698 * interrupt is generated by the hardware.
699 */
700irqreturn_t pci_sriov_migration(struct pci_dev *dev)
701{
702 if (!dev->is_physfn)
703 return IRQ_NONE;
704
705 return sriov_migration(dev) ? IRQ_HANDLED : IRQ_NONE;
706}
707EXPORT_SYMBOL_GPL(pci_sriov_migration);
708
709/**
710 * pci_num_vf - return number of VFs associated with a PF device_release_driver 591 * pci_num_vf - return number of VFs associated with a PF device_release_driver
711 * @dev: the PCI device 592 * @dev: the PCI device
712 * 593 *