diff options
Diffstat (limited to 'drivers/pci')
29 files changed, 881 insertions, 358 deletions
| diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index 8d688b260e28..0c3efcffa83b 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -4,7 +4,7 @@  obj-y		+= access.o bus.o probe.o host-bridge.o remove.o pci.o \  			pci-driver.o search.o pci-sysfs.o rom.o setup-res.o \ -			irq.o vpd.o +			irq.o vpd.o setup-bus.o  obj-$(CONFIG_PROC_FS) += proc.o  obj-$(CONFIG_SYSFS) += slot.o @@ -15,8 +15,6 @@ obj-$(CONFIG_PCIEPORTBUS) += pcie/  obj-$(CONFIG_PCI_IOAPIC) += ioapic.o -obj-$(CONFIG_HOTPLUG) += hotplug.o -  # Build the PCI Hotplug drivers if we were asked to  obj-$(CONFIG_HOTPLUG_PCI) += hotplug/  ifdef CONFIG_HOTPLUG_PCI @@ -60,9 +58,6 @@ obj-$(CONFIG_ACPI)    += pci-acpi.o  # SMBIOS provided firmware instance and labels  obj-$(CONFIG_PCI_LABEL) += pci-label.o -# Cardbus & CompactPCI use setup-bus -obj-$(CONFIG_HOTPLUG) += setup-bus.o -  obj-$(CONFIG_PCI_SYSCALL) += syscall.o  obj-$(CONFIG_PCI_STUB) += pci-stub.o diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index a543746fb354..ad6a8b635692 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -170,6 +170,11 @@ int pci_bus_add_device(struct pci_dev *dev)  	int retval;  	pci_fixup_device(pci_fixup_final, dev); + +	retval = pcibios_add_device(dev); +	if (retval) +		return retval; +  	retval = device_add(&dev->dev);  	if (retval)  		return retval; diff --git a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c deleted file mode 100644 index 2b5352a7dffc..000000000000 --- a/drivers/pci/hotplug.c +++ /dev/null @@ -1,37 +0,0 @@ -#include <linux/kernel.h> -#include <linux/pci.h> -#include <linux/module.h> -#include "pci.h" - -int pci_uevent(struct device *dev, struct kobj_uevent_env *env) -{ -	struct pci_dev *pdev; - -	if (!dev) -		return -ENODEV; - -	pdev = to_pci_dev(dev); -	if (!pdev) -		return -ENODEV; - -	if (add_uevent_var(env, "PCI_CLASS=%04X", pdev->class)) -		return -ENOMEM; - -	if (add_uevent_var(env, "PCI_ID=%04X:%04X", pdev->vendor, pdev->device)) -		return -ENOMEM; - -	if (add_uevent_var(env, "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor, -			   pdev->subsystem_device)) -		return -ENOMEM; - -	if (add_uevent_var(env, "PCI_SLOT_NAME=%s", pci_name(pdev))) -		return -ENOMEM; - -	if (add_uevent_var(env, "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x", -			   pdev->vendor, pdev->device, -			   pdev->subsystem_vendor, pdev->subsystem_device, -			   (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), -			   (u8)(pdev->class))) -		return -ENOMEM; -	return 0; -} diff --git a/drivers/pci/hotplug/Kconfig b/drivers/pci/hotplug/Kconfig index b0e46dede1a9..13e9e63a7266 100644 --- a/drivers/pci/hotplug/Kconfig +++ b/drivers/pci/hotplug/Kconfig @@ -151,4 +151,15 @@ config HOTPLUG_PCI_SGI  	  When in doubt, say N. +config HOTPLUG_PCI_S390 +	tristate "System z PCI Hotplug Support" +	depends on S390 && 64BIT +	help +	  Say Y here if you want to use the System z PCI Hotplug +	  driver for PCI devices. Without this driver it is not +	  possible to access stand-by PCI functions nor to deconfigure +	  PCI functions. + +	  When in doubt, say Y. +  endif # HOTPLUG_PCI diff --git a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile index c459cd4e39c2..47ec8c80e16d 100644 --- a/drivers/pci/hotplug/Makefile +++ b/drivers/pci/hotplug/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_HOTPLUG_PCI_RPA)		+= rpaphp.o  obj-$(CONFIG_HOTPLUG_PCI_RPA_DLPAR)	+= rpadlpar_io.o  obj-$(CONFIG_HOTPLUG_PCI_SGI)		+= sgi_hotplug.o  obj-$(CONFIG_HOTPLUG_PCI_ACPI)		+= acpiphp.o +obj-$(CONFIG_HOTPLUG_PCI_S390)		+= s390_pci_hpc.o  # acpiphp_ibm extends acpiphp, so should be linked afterwards. diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c index 6bf8d2ab164f..449b4bbc8301 100644 --- a/drivers/pci/hotplug/cpcihp_zt5550.c +++ b/drivers/pci/hotplug/cpcihp_zt5550.c @@ -271,7 +271,7 @@ init_hc_error:  } -static void __devexit zt5550_hc_remove_one(struct pci_dev *pdev) +static void zt5550_hc_remove_one(struct pci_dev *pdev)  {  	cpci_hp_stop();  	cpci_hp_unregister_bus(bus0); @@ -290,7 +290,7 @@ static struct pci_driver zt5550_hc_driver = {  	.name		= "zt5550_hc",  	.id_table	= zt5550_hc_pci_tbl,  	.probe		= zt5550_hc_init_one, -	.remove		= __devexit_p(zt5550_hc_remove_one), +	.remove		= zt5550_hc_remove_one,  };  static int __init zt5550_init(void) diff --git a/drivers/pci/hotplug/s390_pci_hpc.c b/drivers/pci/hotplug/s390_pci_hpc.c new file mode 100644 index 000000000000..dee68e0698e1 --- /dev/null +++ b/drivers/pci/hotplug/s390_pci_hpc.c @@ -0,0 +1,252 @@ +/* + * PCI Hot Plug Controller Driver for System z + * + * Copyright 2012 IBM Corp. + * + * Author(s): + *   Jan Glauber <[email protected]> + */ + +#define COMPONENT "zPCI hpc" +#define pr_fmt(fmt) COMPONENT ": " fmt + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/slab.h> +#include <linux/pci.h> +#include <linux/pci_hotplug.h> +#include <linux/init.h> +#include <asm/sclp.h> + +#define SLOT_NAME_SIZE	10 +static LIST_HEAD(s390_hotplug_slot_list); + +MODULE_AUTHOR("Jan Glauber <[email protected]"); +MODULE_DESCRIPTION("Hot Plug PCI Controller for System z"); +MODULE_LICENSE("GPL"); + +static int zpci_fn_configured(enum zpci_state state) +{ +	return state == ZPCI_FN_STATE_CONFIGURED || +	       state == ZPCI_FN_STATE_ONLINE; +} + +/* + * struct slot - slot information for each *physical* slot + */ +struct slot { +	struct list_head slot_list; +	struct hotplug_slot *hotplug_slot; +	struct zpci_dev *zdev; +}; + +static int enable_slot(struct hotplug_slot *hotplug_slot) +{ +	struct slot *slot = hotplug_slot->private; +	int rc; + +	if (slot->zdev->state != ZPCI_FN_STATE_STANDBY) +		return -EIO; + +	rc = sclp_pci_configure(slot->zdev->fid); +	if (!rc) { +		slot->zdev->state = ZPCI_FN_STATE_CONFIGURED; +		/* automatically scan the device after is was configured */ +		zpci_enable_device(slot->zdev); +		zpci_scan_device(slot->zdev); +	} +	return rc; +} + +static int disable_slot(struct hotplug_slot *hotplug_slot) +{ +	struct slot *slot = hotplug_slot->private; +	int rc; + +	if (!zpci_fn_configured(slot->zdev->state)) +		return -EIO; + +	/* TODO: we rely on the user to unbind/remove the device, is that plausible +	 *	 or do we need to trigger that here? +	 */ +	rc = sclp_pci_deconfigure(slot->zdev->fid); +	if (!rc) { +		/* Fixme: better call List-PCI to find the disabled FH +		   for the FID since the FH should be opaque... */ +		slot->zdev->fh &= 0x7fffffff; +		slot->zdev->state = ZPCI_FN_STATE_STANDBY; +	} +	return rc; +} + +static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value) +{ +	struct slot *slot = hotplug_slot->private; + +	switch (slot->zdev->state) { +	case ZPCI_FN_STATE_STANDBY: +		*value = 0; +		break; +	default: +		*value = 1; +		break; +	} +	return 0; +} + +static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) +{ +	/* if the slot exits it always contains a function */ +	*value = 1; +	return 0; +} + +static void release_slot(struct hotplug_slot *hotplug_slot) +{ +	struct slot *slot = hotplug_slot->private; + +	pr_debug("%s - physical_slot = %s\n", __func__, hotplug_slot_name(hotplug_slot)); +	kfree(slot->hotplug_slot->info); +	kfree(slot->hotplug_slot); +	kfree(slot); +} + +static struct hotplug_slot_ops s390_hotplug_slot_ops = { +	.enable_slot =		enable_slot, +	.disable_slot =		disable_slot, +	.get_power_status =	get_power_status, +	.get_adapter_status =	get_adapter_status, +}; + +static int init_pci_slot(struct zpci_dev *zdev) +{ +	struct hotplug_slot *hotplug_slot; +	struct hotplug_slot_info *info; +	char name[SLOT_NAME_SIZE]; +	struct slot *slot; +	int rc; + +	if (!zdev) +		return 0; + +	slot = kzalloc(sizeof(*slot), GFP_KERNEL); +	if (!slot) +		goto error; + +	hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL); +	if (!hotplug_slot) +		goto error_hp; +	hotplug_slot->private = slot; + +	slot->hotplug_slot = hotplug_slot; +	slot->zdev = zdev; + +	info = kzalloc(sizeof(*info), GFP_KERNEL); +	if (!info) +		goto error_info; +	hotplug_slot->info = info; + +	hotplug_slot->ops = &s390_hotplug_slot_ops; +	hotplug_slot->release = &release_slot; + +	get_power_status(hotplug_slot, &info->power_status); +	get_adapter_status(hotplug_slot, &info->adapter_status); + +	snprintf(name, SLOT_NAME_SIZE, "%08x", zdev->fid); +	rc = pci_hp_register(slot->hotplug_slot, zdev->bus, +			     ZPCI_DEVFN, name); +	if (rc) { +		pr_err("pci_hp_register failed with error %d\n", rc); +		goto error_reg; +	} +	list_add(&slot->slot_list, &s390_hotplug_slot_list); +	return 0; + +error_reg: +	kfree(info); +error_info: +	kfree(hotplug_slot); +error_hp: +	kfree(slot); +error: +	return -ENOMEM; +} + +static int __init init_pci_slots(void) +{ +	struct zpci_dev *zdev; +	int device = 0; + +	/* +	 * Create a structure for each slot, and register that slot +	 * with the pci_hotplug subsystem. +	 */ +	mutex_lock(&zpci_list_lock); +	list_for_each_entry(zdev, &zpci_list, entry) { +		init_pci_slot(zdev); +		device++; +	} + +	mutex_unlock(&zpci_list_lock); +	return (device) ? 0 : -ENODEV; +} + +static void exit_pci_slot(struct zpci_dev *zdev) +{ +	struct list_head *tmp, *n; +	struct slot *slot; + +	list_for_each_safe(tmp, n, &s390_hotplug_slot_list) { +		slot = list_entry(tmp, struct slot, slot_list); +		if (slot->zdev != zdev) +			continue; +		list_del(&slot->slot_list); +		pci_hp_deregister(slot->hotplug_slot); +	} +} + +static void __exit exit_pci_slots(void) +{ +	struct list_head *tmp, *n; +	struct slot *slot; + +	/* +	 * Unregister all of our slots with the pci_hotplug subsystem. +	 * Memory will be freed in release_slot() callback after slot's +	 * lifespan is finished. +	 */ +	list_for_each_safe(tmp, n, &s390_hotplug_slot_list) { +		slot = list_entry(tmp, struct slot, slot_list); +		list_del(&slot->slot_list); +		pci_hp_deregister(slot->hotplug_slot); +	} +} + +static int __init pci_hotplug_s390_init(void) +{ +	/* +	 * Do specific initialization stuff for your driver here +	 * like initializing your controller hardware (if any) and +	 * determining the number of slots you have in the system +	 * right now. +	 */ + +	if (!pci_probe) +		return -EOPNOTSUPP; + +	/* register callbacks for slot handling from arch code */ +	mutex_lock(&zpci_list_lock); +	hotplug_ops.create_slot = init_pci_slot; +	hotplug_ops.remove_slot = exit_pci_slot; +	mutex_unlock(&zpci_list_lock); +	pr_info("registered hotplug slot callbacks\n"); +	return init_pci_slots(); +} + +static void __exit pci_hotplug_s390_exit(void) +{ +	exit_pci_slots(); +} + +module_init(pci_hotplug_s390_init); +module_exit(pci_hotplug_s390_exit); diff --git a/drivers/pci/ioapic.c b/drivers/pci/ioapic.c index 205af8dc83c2..3c6bbdd059a4 100644 --- a/drivers/pci/ioapic.c +++ b/drivers/pci/ioapic.c @@ -27,7 +27,7 @@ struct ioapic {  	u32		gsi_base;  }; -static int __devinit ioapic_probe(struct pci_dev *dev, const struct pci_device_id *ent) +static int ioapic_probe(struct pci_dev *dev, const struct pci_device_id *ent)  {  	acpi_handle handle;  	acpi_status status; @@ -88,7 +88,7 @@ exit_free:  	return -ENODEV;  } -static void __devexit ioapic_remove(struct pci_dev *dev) +static void ioapic_remove(struct pci_dev *dev)  {  	struct ioapic *ioapic = pci_get_drvdata(dev); @@ -110,7 +110,7 @@ static struct pci_driver ioapic_driver = {  	.name		= "ioapic",  	.id_table	= ioapic_devices,  	.probe		= ioapic_probe, -	.remove		= __devexit_p(ioapic_remove), +	.remove		= ioapic_remove,  };  static int __init ioapic_init(void) @@ -125,3 +125,5 @@ static void __exit ioapic_exit(void)  module_init(ioapic_init);  module_exit(ioapic_exit); + +MODULE_LICENSE("GPL"); diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index aeccc911abb8..bafd2bbcaf65 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -106,7 +106,7 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)  		virtfn->resource[i].name = pci_name(virtfn);  		virtfn->resource[i].flags = res->flags;  		size = resource_size(res); -		do_div(size, iov->total); +		do_div(size, iov->total_VFs);  		virtfn->resource[i].start = res->start + size * id;  		virtfn->resource[i].end = virtfn->resource[i].start + size - 1;  		rc = request_resource(res, &virtfn->resource[i]); @@ -194,7 +194,7 @@ static int sriov_migration(struct pci_dev *dev)  	u16 status;  	struct pci_sriov *iov = dev->sriov; -	if (!iov->nr_virtfn) +	if (!iov->num_VFs)  		return 0;  	if (!(iov->cap & PCI_SRIOV_CAP_VFM)) @@ -216,7 +216,7 @@ static void sriov_migration_task(struct work_struct *work)  	u16 status;  	struct pci_sriov *iov = container_of(work, struct pci_sriov, mtask); -	for (i = iov->initial; i < iov->nr_virtfn; i++) { +	for (i = iov->initial_VFs; i < iov->num_VFs; i++) {  		state = readb(iov->mstate + i);  		if (state == PCI_SRIOV_VFM_MI) {  			writeb(PCI_SRIOV_VFM_AV, iov->mstate + i); @@ -244,7 +244,7 @@ static int sriov_enable_migration(struct pci_dev *dev, int nr_virtfn)  	resource_size_t pa;  	struct pci_sriov *iov = dev->sriov; -	if (nr_virtfn <= iov->initial) +	if (nr_virtfn <= iov->initial_VFs)  		return 0;  	pci_read_config_dword(dev, iov->pos + PCI_SRIOV_VFM, &table); @@ -294,15 +294,15 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)  	if (!nr_virtfn)  		return 0; -	if (iov->nr_virtfn) +	if (iov->num_VFs)  		return -EINVAL;  	pci_read_config_word(dev, iov->pos + PCI_SRIOV_INITIAL_VF, &initial); -	if (initial > iov->total || -	    (!(iov->cap & PCI_SRIOV_CAP_VFM) && (initial != iov->total))) +	if (initial > iov->total_VFs || +	    (!(iov->cap & PCI_SRIOV_CAP_VFM) && (initial != iov->total_VFs)))  		return -EIO; -	if (nr_virtfn < 0 || nr_virtfn > iov->total || +	if (nr_virtfn < 0 || nr_virtfn > iov->total_VFs ||  	    (!(iov->cap & PCI_SRIOV_CAP_VFM) && (nr_virtfn > initial)))  		return -EINVAL; @@ -359,7 +359,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)  	msleep(100);  	pci_cfg_access_unlock(dev); -	iov->initial = initial; +	iov->initial_VFs = initial;  	if (nr_virtfn < initial)  		initial = nr_virtfn; @@ -376,7 +376,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)  	}  	kobject_uevent(&dev->dev.kobj, KOBJ_CHANGE); -	iov->nr_virtfn = nr_virtfn; +	iov->num_VFs = nr_virtfn;  	return 0; @@ -401,13 +401,13 @@ static void sriov_disable(struct pci_dev *dev)  	int i;  	struct pci_sriov *iov = dev->sriov; -	if (!iov->nr_virtfn) +	if (!iov->num_VFs)  		return;  	if (iov->cap & PCI_SRIOV_CAP_VFM)  		sriov_disable_migration(dev); -	for (i = 0; i < iov->nr_virtfn; i++) +	for (i = 0; i < iov->num_VFs; i++)  		virtfn_remove(dev, i, 0);  	iov->ctrl &= ~(PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE); @@ -419,7 +419,7 @@ static void sriov_disable(struct pci_dev *dev)  	if (iov->link != dev->devfn)  		sysfs_remove_link(&dev->dev.kobj, "dep_link"); -	iov->nr_virtfn = 0; +	iov->num_VFs = 0;  }  static int sriov_init(struct pci_dev *dev, int pos) @@ -496,7 +496,7 @@ found:  	iov->pos = pos;  	iov->nres = nres;  	iov->ctrl = ctrl; -	iov->total = total; +	iov->total_VFs = total;  	iov->offset = offset;  	iov->stride = stride;  	iov->pgsz = pgsz; @@ -529,7 +529,7 @@ failed:  static void sriov_release(struct pci_dev *dev)  { -	BUG_ON(dev->sriov->nr_virtfn); +	BUG_ON(dev->sriov->num_VFs);  	if (dev != dev->sriov->dev)  		pci_dev_put(dev->sriov->dev); @@ -554,7 +554,7 @@ static void sriov_restore_state(struct pci_dev *dev)  		pci_update_resource(dev, i);  	pci_write_config_dword(dev, iov->pos + PCI_SRIOV_SYS_PGSIZE, iov->pgsz); -	pci_write_config_word(dev, iov->pos + PCI_SRIOV_NUM_VF, iov->nr_virtfn); +	pci_write_config_word(dev, iov->pos + PCI_SRIOV_NUM_VF, iov->num_VFs);  	pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl);  	if (iov->ctrl & PCI_SRIOV_CTRL_VFE)  		msleep(100); @@ -661,7 +661,7 @@ int pci_iov_bus_range(struct pci_bus *bus)  	list_for_each_entry(dev, &bus->devices, bus_list) {  		if (!dev->is_physfn)  			continue; -		busnr = virtfn_bus(dev, dev->sriov->total - 1); +		busnr = virtfn_bus(dev, dev->sriov->total_VFs - 1);  		if (busnr > max)  			max = busnr;  	} @@ -729,9 +729,56 @@ EXPORT_SYMBOL_GPL(pci_sriov_migration);   */  int pci_num_vf(struct pci_dev *dev)  { -	if (!dev || !dev->is_physfn) +	if (!dev->is_physfn)  		return 0; -	else -		return dev->sriov->nr_virtfn; + +	return dev->sriov->num_VFs;  }  EXPORT_SYMBOL_GPL(pci_num_vf); + +/** + * pci_sriov_set_totalvfs -- reduce the TotalVFs available + * @dev: the PCI PF device + * numvfs: number that should be used for TotalVFs supported + * + * Should be called from PF driver's probe routine with + * device's mutex held. + * + * Returns 0 if PF is an SRIOV-capable device and + * value of numvfs valid. If not a PF with VFS, return -EINVAL; + * if VFs already enabled, return -EBUSY. + */ +int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs) +{ +	if (!dev->is_physfn || (numvfs > dev->sriov->total_VFs)) +		return -EINVAL; + +	/* Shouldn't change if VFs already enabled */ +	if (dev->sriov->ctrl & PCI_SRIOV_CTRL_VFE) +		return -EBUSY; +	else +		dev->sriov->driver_max_VFs = numvfs; + +	return 0; +} +EXPORT_SYMBOL_GPL(pci_sriov_set_totalvfs); + +/** + * pci_sriov_get_totalvfs -- get total VFs supported on this devic3 + * @dev: the PCI PF device + * + * For a PCIe device with SRIOV support, return the PCIe + * SRIOV capability value of TotalVFs or the value of driver_max_VFs + * if the driver reduced it.  Otherwise, -EINVAL. + */ +int pci_sriov_get_totalvfs(struct pci_dev *dev) +{ +	if (!dev->is_physfn) +		return -EINVAL; + +	if (dev->sriov->driver_max_VFs) +		return dev->sriov->driver_max_VFs; + +	return dev->sriov->total_VFs; +} +EXPORT_SYMBOL_GPL(pci_sriov_get_totalvfs); diff --git a/drivers/pci/irq.c b/drivers/pci/irq.c index e5f69a43b1b1..b008cf86b9c3 100644 --- a/drivers/pci/irq.c +++ b/drivers/pci/irq.c @@ -14,11 +14,11 @@ static void pci_note_irq_problem(struct pci_dev *pdev, const char *reason)  {  	struct pci_dev *parent = to_pci_dev(pdev->dev.parent); -	dev_printk(KERN_ERR, &pdev->dev, -		   "Potentially misrouted IRQ (Bridge %s %04x:%04x)\n", -		   dev_name(&parent->dev), parent->vendor, parent->device); -	dev_printk(KERN_ERR, &pdev->dev, "%s\n", reason); -	dev_printk(KERN_ERR, &pdev->dev, "Please report to [email protected]\n"); +	dev_err(&pdev->dev, +		"Potentially misrouted IRQ (Bridge %s %04x:%04x)\n", +		dev_name(&parent->dev), parent->vendor, parent->device); +	dev_err(&pdev->dev, "%s\n", reason); +	dev_err(&pdev->dev, "Please report to [email protected]\n");  	WARN_ON(1);  } diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index a825d78fd0aa..5099636a6e5f 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -207,6 +207,8 @@ static void msix_mask_irq(struct msi_desc *desc, u32 flag)  	desc->masked = __msix_mask_irq(desc, flag);  } +#ifdef CONFIG_GENERIC_HARDIRQS +  static void msi_set_mask_bit(struct irq_data *data, u32 flag)  {  	struct msi_desc *desc = irq_data_get_msi(data); @@ -230,6 +232,8 @@ void unmask_msi_irq(struct irq_data *data)  	msi_set_mask_bit(data, 0);  } +#endif /* CONFIG_GENERIC_HARDIRQS */ +  void __read_msi_msg(struct msi_desc *entry, struct msi_msg *msg)  {  	BUG_ON(entry->dev->current_state != PCI_D0); @@ -337,8 +341,10 @@ static void free_msi_irqs(struct pci_dev *dev)  		if (!entry->irq)  			continue;  		nvec = 1 << entry->msi_attrib.multiple; +#ifdef CONFIG_GENERIC_HARDIRQS  		for (i = 0; i < nvec; i++)  			BUG_ON(irq_has_action(entry->irq + i)); +#endif  	}  	arch_teardown_msi_irqs(dev); diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index c5792d622dc4..1af4008182fd 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -17,10 +17,9 @@  #include <linux/pci-acpi.h>  #include <linux/pm_runtime.h> +#include <linux/pm_qos.h>  #include "pci.h" -static DEFINE_MUTEX(pci_acpi_pm_notify_mtx); -  /**   * pci_acpi_wake_bus - Wake-up notification handler for root buses.   * @handle: ACPI handle of a device the notification is for. @@ -68,67 +67,6 @@ static void pci_acpi_wake_dev(acpi_handle handle, u32 event, void *context)  }  /** - * add_pm_notifier - Register PM notifier for given ACPI device. - * @dev: ACPI device to add the notifier for. - * @context: PCI device or bus to check for PME status if an event is signaled. - * - * NOTE: @dev need not be a run-wake or wake-up device to be a valid source of - * PM wake-up events.  For example, wake-up events may be generated for bridges - * if one of the devices below the bridge is signaling PME, even if the bridge - * itself doesn't have a wake-up GPE associated with it. - */ -static acpi_status add_pm_notifier(struct acpi_device *dev, -				   acpi_notify_handler handler, -				   void *context) -{ -	acpi_status status = AE_ALREADY_EXISTS; - -	mutex_lock(&pci_acpi_pm_notify_mtx); - -	if (dev->wakeup.flags.notifier_present) -		goto out; - -	status = acpi_install_notify_handler(dev->handle, -					     ACPI_SYSTEM_NOTIFY, -					     handler, context); -	if (ACPI_FAILURE(status)) -		goto out; - -	dev->wakeup.flags.notifier_present = true; - - out: -	mutex_unlock(&pci_acpi_pm_notify_mtx); -	return status; -} - -/** - * remove_pm_notifier - Unregister PM notifier from given ACPI device. - * @dev: ACPI device to remove the notifier from. - */ -static acpi_status remove_pm_notifier(struct acpi_device *dev, -				      acpi_notify_handler handler) -{ -	acpi_status status = AE_BAD_PARAMETER; - -	mutex_lock(&pci_acpi_pm_notify_mtx); - -	if (!dev->wakeup.flags.notifier_present) -		goto out; - -	status = acpi_remove_notify_handler(dev->handle, -					    ACPI_SYSTEM_NOTIFY, -					    handler); -	if (ACPI_FAILURE(status)) -		goto out; - -	dev->wakeup.flags.notifier_present = false; - - out: -	mutex_unlock(&pci_acpi_pm_notify_mtx); -	return status; -} - -/**   * pci_acpi_add_bus_pm_notifier - Register PM notifier for given PCI bus.   * @dev: ACPI device to add the notifier for.   * @pci_bus: PCI bus to walk checking for PME status if an event is signaled. @@ -136,7 +74,7 @@ static acpi_status remove_pm_notifier(struct acpi_device *dev,  acpi_status pci_acpi_add_bus_pm_notifier(struct acpi_device *dev,  					 struct pci_bus *pci_bus)  { -	return add_pm_notifier(dev, pci_acpi_wake_bus, pci_bus); +	return acpi_add_pm_notifier(dev, pci_acpi_wake_bus, pci_bus);  }  /** @@ -145,7 +83,7 @@ acpi_status pci_acpi_add_bus_pm_notifier(struct acpi_device *dev,   */  acpi_status pci_acpi_remove_bus_pm_notifier(struct acpi_device *dev)  { -	return remove_pm_notifier(dev, pci_acpi_wake_bus); +	return acpi_remove_pm_notifier(dev, pci_acpi_wake_bus);  }  /** @@ -156,7 +94,7 @@ acpi_status pci_acpi_remove_bus_pm_notifier(struct acpi_device *dev)  acpi_status pci_acpi_add_pm_notifier(struct acpi_device *dev,  				     struct pci_dev *pci_dev)  { -	return add_pm_notifier(dev, pci_acpi_wake_dev, pci_dev); +	return acpi_add_pm_notifier(dev, pci_acpi_wake_dev, pci_dev);  }  /** @@ -165,7 +103,7 @@ acpi_status pci_acpi_add_pm_notifier(struct acpi_device *dev,   */  acpi_status pci_acpi_remove_pm_notifier(struct acpi_device *dev)  { -	return remove_pm_notifier(dev, pci_acpi_wake_dev); +	return acpi_remove_pm_notifier(dev, pci_acpi_wake_dev);  }  phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle) @@ -257,11 +195,16 @@ static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)  		return -ENODEV;  	switch (state) { +	case PCI_D3cold: +		if (dev_pm_qos_flags(&dev->dev, PM_QOS_FLAG_NO_POWER_OFF) == +				PM_QOS_FLAGS_ALL) { +			error = -EBUSY; +			break; +		}  	case PCI_D0:  	case PCI_D1:  	case PCI_D2:  	case PCI_D3hot: -	case PCI_D3cold:  		error = acpi_bus_set_power(handle, state_conv[state]);  	} diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 6c94fc9489e7..f79cbcd3944b 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -89,10 +89,6 @@ static void pci_free_dynids(struct pci_driver *drv)  	spin_unlock(&drv->dynids.lock);  } -/* - * Dynamic device ID manipulation via sysfs is disabled for !CONFIG_HOTPLUG - */ -#ifdef CONFIG_HOTPLUG  /**   * store_new_id - sysfs frontend to pci_add_dynid()   * @driver: target device driver @@ -191,10 +187,6 @@ static struct driver_attribute pci_drv_attrs[] = {  	__ATTR_NULL,  }; -#else -#define pci_drv_attrs	NULL -#endif /* CONFIG_HOTPLUG */ -  /**   * pci_match_id - See if a pci device matches a given pci_id table   * @ids: array of PCI device id structures to search in @@ -256,31 +248,26 @@ struct drv_dev_and_id {  static long local_pci_probe(void *_ddi)  {  	struct drv_dev_and_id *ddi = _ddi; -	struct device *dev = &ddi->dev->dev; -	struct device *parent = dev->parent; +	struct pci_dev *pci_dev = ddi->dev; +	struct pci_driver *pci_drv = ddi->drv; +	struct device *dev = &pci_dev->dev;  	int rc; -	/* The parent bridge must be in active state when probing */ -	if (parent) -		pm_runtime_get_sync(parent); -	/* Unbound PCI devices are always set to disabled and suspended. -	 * During probe, the device is set to enabled and active and the -	 * usage count is incremented.  If the driver supports runtime PM, -	 * it should call pm_runtime_put_noidle() in its probe routine and -	 * pm_runtime_get_noresume() in its remove routine. +	/* +	 * Unbound PCI devices are always put in D0, regardless of +	 * runtime PM status.  During probe, the device is set to +	 * active and the usage count is incremented.  If the driver +	 * supports runtime PM, it should call pm_runtime_put_noidle() +	 * in its probe routine and pm_runtime_get_noresume() in its +	 * remove routine.  	 */ -	pm_runtime_get_noresume(dev); -	pm_runtime_set_active(dev); -	pm_runtime_enable(dev); - -	rc = ddi->drv->probe(ddi->dev, ddi->id); +	pm_runtime_get_sync(dev); +	pci_dev->driver = pci_drv; +	rc = pci_drv->probe(pci_dev, ddi->id);  	if (rc) { -		pm_runtime_disable(dev); -		pm_runtime_set_suspended(dev); -		pm_runtime_put_noidle(dev); +		pci_dev->driver = NULL; +		pm_runtime_put_sync(dev);  	} -	if (parent) -		pm_runtime_put(parent);  	return rc;  } @@ -330,10 +317,8 @@ __pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev)  		id = pci_match_device(drv, pci_dev);  		if (id)  			error = pci_call_probe(drv, pci_dev, id); -		if (error >= 0) { -			pci_dev->driver = drv; +		if (error >= 0)  			error = 0; -		}  	}  	return error;  } @@ -369,9 +354,7 @@ static int pci_device_remove(struct device * dev)  	}  	/* Undo the runtime PM settings in local_pci_probe() */ -	pm_runtime_disable(dev); -	pm_runtime_set_suspended(dev); -	pm_runtime_put_noidle(dev); +	pm_runtime_put_sync(dev);  	/*  	 * If the device is still on, set the power state as "unknown", @@ -994,6 +977,13 @@ static int pci_pm_runtime_suspend(struct device *dev)  	pci_power_t prev = pci_dev->current_state;  	int error; +	/* +	 * If pci_dev->driver is not set (unbound), the device should +	 * always remain in D0 regardless of the runtime PM status +	 */ +	if (!pci_dev->driver) +		return 0; +  	if (!pm || !pm->runtime_suspend)  		return -ENOSYS; @@ -1015,10 +1005,10 @@ static int pci_pm_runtime_suspend(struct device *dev)  		return 0;  	} -	if (!pci_dev->state_saved) +	if (!pci_dev->state_saved) {  		pci_save_state(pci_dev); - -	pci_finish_runtime_suspend(pci_dev); +		pci_finish_runtime_suspend(pci_dev); +	}  	return 0;  } @@ -1029,6 +1019,13 @@ static int pci_pm_runtime_resume(struct device *dev)  	struct pci_dev *pci_dev = to_pci_dev(dev);  	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; +	/* +	 * If pci_dev->driver is not set (unbound), the device should +	 * always remain in D0 regardless of the runtime PM status +	 */ +	if (!pci_dev->driver) +		return 0; +  	if (!pm || !pm->runtime_resume)  		return -ENOSYS; @@ -1046,8 +1043,16 @@ static int pci_pm_runtime_resume(struct device *dev)  static int pci_pm_runtime_idle(struct device *dev)  { +	struct pci_dev *pci_dev = to_pci_dev(dev);  	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; +	/* +	 * If pci_dev->driver is not set (unbound), the device should +	 * always remain in D0 regardless of the runtime PM status +	 */ +	if (!pci_dev->driver) +		goto out; +  	if (!pm)  		return -ENOSYS; @@ -1057,8 +1062,8 @@ static int pci_pm_runtime_idle(struct device *dev)  			return ret;  	} +out:  	pm_runtime_suspend(dev); -  	return 0;  } @@ -1223,12 +1228,38 @@ void pci_dev_put(struct pci_dev *dev)  		put_device(&dev->dev);  } -#ifndef CONFIG_HOTPLUG -int pci_uevent(struct device *dev, struct kobj_uevent_env *env) +static int pci_uevent(struct device *dev, struct kobj_uevent_env *env)  { -	return -ENODEV; +	struct pci_dev *pdev; + +	if (!dev) +		return -ENODEV; + +	pdev = to_pci_dev(dev); +	if (!pdev) +		return -ENODEV; + +	if (add_uevent_var(env, "PCI_CLASS=%04X", pdev->class)) +		return -ENOMEM; + +	if (add_uevent_var(env, "PCI_ID=%04X:%04X", pdev->vendor, pdev->device)) +		return -ENOMEM; + +	if (add_uevent_var(env, "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor, +			   pdev->subsystem_device)) +		return -ENOMEM; + +	if (add_uevent_var(env, "PCI_SLOT_NAME=%s", pci_name(pdev))) +		return -ENOMEM; + +	if (add_uevent_var(env, "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x", +			   pdev->vendor, pdev->device, +			   pdev->subsystem_vendor, pdev->subsystem_device, +			   (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), +			   (u8)(pdev->class))) +		return -ENOMEM; +	return 0;  } -#endif  struct bus_type pci_bus_type = {  	.name		= "pci", diff --git a/drivers/pci/pci-stub.c b/drivers/pci/pci-stub.c index 775e933c2225..6e47c519c510 100644 --- a/drivers/pci/pci-stub.c +++ b/drivers/pci/pci-stub.c @@ -28,7 +28,7 @@ MODULE_PARM_DESC(ids, "Initial PCI IDs to add to the stub driver, format is "  static int pci_stub_probe(struct pci_dev *dev, const struct pci_device_id *id)  { -	dev_printk(KERN_INFO, &dev->dev, "claimed by stub\n"); +	dev_info(&dev->dev, "claimed by stub\n");  	return 0;  } diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index f39378d9da15..05b78b16d20b 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -284,7 +284,6 @@ msi_bus_store(struct device *dev, struct device_attribute *attr,  	return count;  } -#ifdef CONFIG_HOTPLUG  static DEFINE_MUTEX(pci_remove_rescan_mutex);  static ssize_t bus_rescan_store(struct bus_type *bus, const char *buf,  				size_t count) @@ -377,8 +376,6 @@ dev_bus_rescan_store(struct device *dev, struct device_attribute *attr,  	return count;  } -#endif -  #if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI)  static ssize_t d3cold_allowed_store(struct device *dev,  				    struct device_attribute *attr, @@ -404,6 +401,106 @@ static ssize_t d3cold_allowed_show(struct device *dev,  }  #endif +#ifdef CONFIG_PCI_IOV +static ssize_t sriov_totalvfs_show(struct device *dev, +				   struct device_attribute *attr, +				   char *buf) +{ +	struct pci_dev *pdev = to_pci_dev(dev); + +	return sprintf(buf, "%u\n", pci_sriov_get_totalvfs(pdev)); +} + + +static ssize_t sriov_numvfs_show(struct device *dev, +				 struct device_attribute *attr, +				 char *buf) +{ +	struct pci_dev *pdev = to_pci_dev(dev); + +	return sprintf(buf, "%u\n", pdev->sriov->num_VFs); +} + +/* + * num_vfs > 0; number of vfs to enable + * num_vfs = 0; disable all vfs + * + * Note: SRIOV spec doesn't allow partial VF + *       disable, so its all or none. + */ +static ssize_t sriov_numvfs_store(struct device *dev, +				  struct device_attribute *attr, +				  const char *buf, size_t count) +{ +	struct pci_dev *pdev = to_pci_dev(dev); +	int num_vfs_enabled = 0; +	int num_vfs; +	int ret = 0; +	u16 total; + +	if (kstrtoint(buf, 0, &num_vfs) < 0) +		return -EINVAL; + +	/* is PF driver loaded w/callback */ +	if (!pdev->driver || !pdev->driver->sriov_configure) { +		dev_info(&pdev->dev, +			 "Driver doesn't support SRIOV configuration via sysfs\n"); +		return -ENOSYS; +	} + +	/* if enabling vf's ... */ +	total = pci_sriov_get_totalvfs(pdev); +	/* Requested VFs to enable < totalvfs and none enabled already */ +	if ((num_vfs > 0) && (num_vfs <= total)) { +		if (pdev->sriov->num_VFs == 0) { +			num_vfs_enabled = +				pdev->driver->sriov_configure(pdev, num_vfs); +			if ((num_vfs_enabled >= 0) && +			    (num_vfs_enabled != num_vfs)) { +				dev_warn(&pdev->dev, +					 "Only %d VFs enabled\n", +					 num_vfs_enabled); +				return count; +			} else if (num_vfs_enabled < 0) +				/* error code from driver callback */ +				return num_vfs_enabled; +		} else if (num_vfs == pdev->sriov->num_VFs) { +			dev_warn(&pdev->dev, +				 "%d VFs already enabled; no enable action taken\n", +				 num_vfs); +			return count; +		} else { +			dev_warn(&pdev->dev, +				 "%d VFs already enabled. Disable before enabling %d VFs\n", +				 pdev->sriov->num_VFs, num_vfs); +			return -EINVAL; +		} +	} + +	/* disable vfs */ +	if (num_vfs == 0) { +		if (pdev->sriov->num_VFs != 0) { +			ret = pdev->driver->sriov_configure(pdev, 0); +			return ret ? ret : count; +		} else { +			dev_warn(&pdev->dev, +				 "All VFs disabled; no disable action taken\n"); +			return count; +		} +	} + +	dev_err(&pdev->dev, +		"Invalid value for number of VFs to enable: %d\n", num_vfs); + +	return -EINVAL; +} + +static struct device_attribute sriov_totalvfs_attr = __ATTR_RO(sriov_totalvfs); +static struct device_attribute sriov_numvfs_attr = +		__ATTR(sriov_numvfs, (S_IRUGO|S_IWUSR|S_IWGRP), +		       sriov_numvfs_show, sriov_numvfs_store); +#endif /* CONFIG_PCI_IOV */ +  struct device_attribute pci_dev_attrs[] = {  	__ATTR_RO(resource),  	__ATTR_RO(vendor), @@ -424,10 +521,8 @@ struct device_attribute pci_dev_attrs[] = {  	__ATTR(broken_parity_status,(S_IRUGO|S_IWUSR),  		broken_parity_status_show,broken_parity_status_store),  	__ATTR(msi_bus, 0644, msi_bus_show, msi_bus_store), -#ifdef CONFIG_HOTPLUG  	__ATTR(remove, (S_IWUSR|S_IWGRP), NULL, remove_store),  	__ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_rescan_store), -#endif  #if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI)  	__ATTR(d3cold_allowed, 0644, d3cold_allowed_show, d3cold_allowed_store),  #endif @@ -435,9 +530,7 @@ struct device_attribute pci_dev_attrs[] = {  };  struct device_attribute pcibus_dev_attrs[] = { -#ifdef CONFIG_HOTPLUG  	__ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_bus_rescan_store), -#endif  	__ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpumaskaffinity, NULL),  	__ATTR(cpulistaffinity, S_IRUGO, pci_bus_show_cpulistaffinity, NULL),  	__ATTR_NULL, @@ -1269,29 +1362,20 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)  		pdev->rom_attr = attr;  	} -	if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) { -		retval = device_create_file(&pdev->dev, &vga_attr); -		if (retval) -			goto err_rom_file; -	} -  	/* add platform-specific attributes */  	retval = pcibios_add_platform_entries(pdev);  	if (retval) -		goto err_vga_file; +		goto err_rom_file;  	/* add sysfs entries for various capabilities */  	retval = pci_create_capabilities_sysfs(pdev);  	if (retval) -		goto err_vga_file; +		goto err_rom_file;  	pci_create_firmware_label_files(pdev);  	return 0; -err_vga_file: -	if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) -		device_remove_file(&pdev->dev, &vga_attr);  err_rom_file:  	if (rom_size) {  		sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr); @@ -1377,3 +1461,62 @@ static int __init pci_sysfs_init(void)  }  late_initcall(pci_sysfs_init); + +static struct attribute *pci_dev_dev_attrs[] = { +	&vga_attr.attr, +	NULL, +}; + +static umode_t pci_dev_attrs_are_visible(struct kobject *kobj, +						struct attribute *a, int n) +{ +	struct device *dev = container_of(kobj, struct device, kobj); +	struct pci_dev *pdev = to_pci_dev(dev); + +	if (a == &vga_attr.attr) +		if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA) +			return 0; + +	return a->mode; +} + +#ifdef CONFIG_PCI_IOV +static struct attribute *sriov_dev_attrs[] = { +	&sriov_totalvfs_attr.attr, +	&sriov_numvfs_attr.attr, +	NULL, +}; + +static umode_t sriov_attrs_are_visible(struct kobject *kobj, +					 struct attribute *a, int n) +{ +	struct device *dev = container_of(kobj, struct device, kobj); + +	if (!dev_is_pf(dev)) +		return 0; + +	return a->mode; +} + +static struct attribute_group sriov_dev_attr_group = { +	.attrs = sriov_dev_attrs, +	.is_visible = sriov_attrs_are_visible, +}; +#endif /* CONFIG_PCI_IOV */ + +static struct attribute_group pci_dev_attr_group = { +	.attrs = pci_dev_dev_attrs, +	.is_visible = pci_dev_attrs_are_visible, +}; + +static const struct attribute_group *pci_dev_attr_groups[] = { +	&pci_dev_attr_group, +#ifdef CONFIG_PCI_IOV +	&sriov_dev_attr_group, +#endif +	NULL, +}; + +struct device_type pci_dev_type = { +	.groups = pci_dev_attr_groups, +}; diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index aabf64798bda..5cb5820fae40 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -86,7 +86,7 @@ enum pcie_bus_config_types pcie_bus_config = PCIE_BUS_TUNE_OFF;   * the dfl or actual value as it sees fit.  Don't forget this is   * measured in 32-bit words, not bytes.   */ -u8 pci_dfl_cache_line_size __devinitdata = L1_CACHE_BYTES >> 2; +u8 pci_dfl_cache_line_size = L1_CACHE_BYTES >> 2;  u8 pci_cache_line_size;  /* @@ -1333,6 +1333,19 @@ void pcim_pin_device(struct pci_dev *pdev)  		dr->pinned = 1;  } +/* + * pcibios_add_device - provide arch specific hooks when adding device dev + * @dev: the PCI device being added + * + * Permits the platform to provide architecture specific functionality when + * devices are added. This is the default implementation. Architecture + * implementations can override this. + */ +int __weak pcibios_add_device (struct pci_dev *dev) +{ +	return 0; +} +  /**   * pcibios_disable_device - disable arch specific PCI resources for device dev   * @dev: the PCI device to disable @@ -1578,15 +1591,25 @@ void pci_pme_active(struct pci_dev *dev, bool enable)  	pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pmcsr); -	/* PCI (as opposed to PCIe) PME requires that the device have -	   its PME# line hooked up correctly. Not all hardware vendors -	   do this, so the PME never gets delivered and the device -	   remains asleep. The easiest way around this is to -	   periodically walk the list of suspended devices and check -	   whether any have their PME flag set. The assumption is that -	   we'll wake up often enough anyway that this won't be a huge -	   hit, and the power savings from the devices will still be a -	   win. */ +	/* +	 * PCI (as opposed to PCIe) PME requires that the device have +	 * its PME# line hooked up correctly. Not all hardware vendors +	 * do this, so the PME never gets delivered and the device +	 * remains asleep. The easiest way around this is to +	 * periodically walk the list of suspended devices and check +	 * whether any have their PME flag set. The assumption is that +	 * we'll wake up often enough anyway that this won't be a huge +	 * hit, and the power savings from the devices will still be a +	 * win. +	 * +	 * Although PCIe uses in-band PME message instead of PME# line +	 * to report PME, PME does not work for some PCIe devices in +	 * reality.  For example, there are devices that set their PME +	 * status bits, but don't really bother to send a PME message; +	 * there are PCI Express Root Ports that don't bother to +	 * trigger interrupts when they receive PME messages from the +	 * devices below.  So PME poll is used for PCIe devices too. +	 */  	if (dev->pme_poll) {  		struct pci_pme_device *pme_dev; @@ -1900,6 +1923,8 @@ void pci_pm_init(struct pci_dev *dev)  	u16 pmc;  	pm_runtime_forbid(&dev->dev); +	pm_runtime_set_active(&dev->dev); +	pm_runtime_enable(&dev->dev);  	device_enable_async_suspend(&dev->dev);  	dev->wakeup_prepared = false; @@ -3857,7 +3882,7 @@ static int __init pci_resource_alignment_sysfs_init(void)  late_initcall(pci_resource_alignment_sysfs_init); -static void __devinit pci_no_domains(void) +static void pci_no_domains(void)  {  #ifdef CONFIG_PCI_DOMAINS  	pci_domains_supported = 0; @@ -3865,14 +3890,13 @@ static void __devinit pci_no_domains(void)  }  /** - * pci_ext_cfg_enabled - can we access extended PCI config space? - * @dev: The PCI device of the root bridge. + * pci_ext_cfg_avail - can we access extended PCI config space?   *   * Returns 1 if we can access PCI extended config space (offsets   * greater than 0xff). This is the default implementation. Architecture   * implementations can override this.   */ -int __weak pci_ext_cfg_avail(struct pci_dev *dev) +int __weak pci_ext_cfg_avail(void)  {  	return 1;  } diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index fd92aab9904b..e8518292826f 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -8,7 +8,6 @@  /* Functions internal to the PCI core code */ -extern int pci_uevent(struct device *dev, struct kobj_uevent_env *env);  extern int pci_create_sysfs_dev_files(struct pci_dev *pdev);  extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev);  #if !defined(CONFIG_DMI) && !defined(CONFIG_ACPI) @@ -159,11 +158,8 @@ static inline int pci_no_d1d2(struct pci_dev *dev)  }  extern struct device_attribute pci_dev_attrs[];  extern struct device_attribute pcibus_dev_attrs[]; -#ifdef CONFIG_HOTPLUG +extern struct device_type pci_dev_type;  extern struct bus_attribute pci_bus_attrs[]; -#else -#define pci_bus_attrs	NULL -#endif  /** @@ -234,13 +230,14 @@ struct pci_sriov {  	int nres;		/* number of resources */  	u32 cap;		/* SR-IOV Capabilities */  	u16 ctrl;		/* SR-IOV Control */ -	u16 total;		/* total VFs associated with the PF */ -	u16 initial;		/* initial VFs associated with the PF */ -	u16 nr_virtfn;		/* number of VFs available */ +	u16 total_VFs;		/* total VFs associated with the PF */ +	u16 initial_VFs;	/* initial VFs associated with the PF */ +	u16 num_VFs;		/* number of VFs available */  	u16 offset;		/* first VF Routing ID offset */  	u16 stride;		/* following VF stride */  	u32 pgsz;		/* page size for BAR alignment */  	u8 link;		/* Function Dependency Link */ +	u16 driver_max_VFs;	/* max num VFs driver supports */  	struct pci_dev *dev;	/* lowest numbered PF */  	struct pci_dev *self;	/* this PF */  	struct mutex lock;	/* lock for VF bus */ diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c index 030cf12d5468..76ef634caf6f 100644 --- a/drivers/pci/pcie/aer/aerdrv.c +++ b/drivers/pci/pcie/aer/aerdrv.c @@ -41,7 +41,7 @@ MODULE_AUTHOR(DRIVER_AUTHOR);  MODULE_DESCRIPTION(DRIVER_DESC);  MODULE_LICENSE("GPL"); -static int __devinit aer_probe(struct pcie_device *dev); +static int aer_probe(struct pcie_device *dev);  static void aer_remove(struct pcie_device *dev);  static pci_ers_result_t aer_error_detected(struct pci_dev *dev,  	enum pci_channel_state error); @@ -300,7 +300,7 @@ static void aer_remove(struct pcie_device *dev)   *   * Invoked when PCI Express bus loads AER service driver.   */ -static int __devinit aer_probe(struct pcie_device *dev) +static int aer_probe(struct pcie_device *dev)  {  	int status;  	struct aer_rpc *rpc; diff --git a/drivers/pci/pcie/aer/aerdrv.h b/drivers/pci/pcie/aer/aerdrv.h index 94a7598eb262..22f840f4dda1 100644 --- a/drivers/pci/pcie/aer/aerdrv.h +++ b/drivers/pci/pcie/aer/aerdrv.h @@ -87,6 +87,9 @@ struct aer_broadcast_data {  static inline pci_ers_result_t merge_result(enum pci_ers_result orig,  		enum pci_ers_result new)  { +	if (new == PCI_ERS_RESULT_NO_AER_DRIVER) +		return PCI_ERS_RESULT_NO_AER_DRIVER; +  	if (new == PCI_ERS_RESULT_NONE)  		return orig; @@ -97,7 +100,7 @@ static inline pci_ers_result_t merge_result(enum pci_ers_result orig,  		break;  	case PCI_ERS_RESULT_DISCONNECT:  		if (new == PCI_ERS_RESULT_NEED_RESET) -			orig = new; +			orig = PCI_ERS_RESULT_NEED_RESET;  		break;  	default:  		break; diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c index af4e31cd3a3b..421bbc5fee32 100644 --- a/drivers/pci/pcie/aer/aerdrv_core.c +++ b/drivers/pci/pcie/aer/aerdrv_core.c @@ -232,13 +232,27 @@ static int report_error_detected(struct pci_dev *dev, void *data)  				   dev->driver ?  				   "no AER-aware driver" : "no driver");  		} -		goto out; + +		/* +		 * If there's any device in the subtree that does not +		 * have an error_detected callback, returning +		 * PCI_ERS_RESULT_NO_AER_DRIVER prevents calling of +		 * the subsequent mmio_enabled/slot_reset/resume +		 * callbacks of "any" device in the subtree. All the +		 * devices in the subtree are left in the error state +		 * without recovery. +		 */ + +		if (!(dev->hdr_type & PCI_HEADER_TYPE_BRIDGE)) +			vote = PCI_ERS_RESULT_NO_AER_DRIVER; +		else +			vote = PCI_ERS_RESULT_NONE; +	} else { +		err_handler = dev->driver->err_handler; +		vote = err_handler->error_detected(dev, result_data->state);  	} -	err_handler = dev->driver->err_handler; -	vote = err_handler->error_detected(dev, result_data->state);  	result_data->result = merge_result(result_data->result, vote); -out:  	device_unlock(&dev->dev);  	return 0;  } diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 213753b283a6..b52630b8eada 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -242,8 +242,7 @@ static void pcie_aspm_configure_common_clock(struct pcie_link_state *link)  		return;  	/* Training failed. Restore common clock configurations */ -	dev_printk(KERN_ERR, &parent->dev, -		   "ASPM: Could not configure common clock\n"); +	dev_err(&parent->dev, "ASPM: Could not configure common clock\n");  	list_for_each_entry(child, &linkbus->devices, bus_list)  		pcie_capability_write_word(child, PCI_EXP_LNKCTL,  					   child_reg[PCI_FUNC(child->devfn)]); @@ -427,7 +426,8 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)  static void pcie_config_aspm_dev(struct pci_dev *pdev, u32 val)  { -	pcie_capability_clear_and_set_word(pdev, PCI_EXP_LNKCTL, 0x3, val); +	pcie_capability_clear_and_set_word(pdev, PCI_EXP_LNKCTL, +					   PCI_EXP_LNKCTL_ASPMC, val);  }  static void pcie_config_aspm_link(struct pcie_link_state *link, u32 state) @@ -442,12 +442,12 @@ static void pcie_config_aspm_link(struct pcie_link_state *link, u32 state)  		return;  	/* Convert ASPM state to upstream/downstream ASPM register state */  	if (state & ASPM_STATE_L0S_UP) -		dwstream |= PCIE_LINK_STATE_L0S; +		dwstream |= PCI_EXP_LNKCTL_ASPM_L0S;  	if (state & ASPM_STATE_L0S_DW) -		upstream |= PCIE_LINK_STATE_L0S; +		upstream |= PCI_EXP_LNKCTL_ASPM_L0S;  	if (state & ASPM_STATE_L1) { -		upstream |= PCIE_LINK_STATE_L1; -		dwstream |= PCIE_LINK_STATE_L1; +		upstream |= PCI_EXP_LNKCTL_ASPM_L1; +		dwstream |= PCI_EXP_LNKCTL_ASPM_L1;  	}  	/*  	 * Spec 2.0 suggests all functions should be configured the @@ -507,9 +507,7 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev)  		 */  		pcie_capability_read_dword(child, PCI_EXP_DEVCAP, ®32);  		if (!(reg32 & PCI_EXP_DEVCAP_RBER) && !aspm_force) { -			dev_printk(KERN_INFO, &child->dev, "disabling ASPM" -				" on pre-1.1 PCIe device.  You can enable it" -				" with 'pcie_aspm=force'\n"); +			dev_info(&child->dev, "disabling ASPM on pre-1.1 PCIe device.  You can enable it with 'pcie_aspm=force'\n");  			return -EINVAL;  		}  	} diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index ed129b414624..b42133afca98 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c @@ -120,8 +120,7 @@ static int pcie_port_enable_msix(struct pci_dev *dev, int *vectors, int mask)  		 * the value in this field indicates which MSI-X Table entry is  		 * used to generate the interrupt message."  		 */ -		pos = pci_pcie_cap(dev); -		pci_read_config_word(dev, pos + PCI_EXP_FLAGS, ®16); +		pcie_capability_read_word(dev, PCI_EXP_FLAGS, ®16);  		entry = (reg16 & PCI_EXP_FLAGS_IRQ) >> 9;  		if (entry >= nr_entries)  			goto Error; diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index 0761d90ca279..d4824cb78b49 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/drivers/pci/pcie/portdrv_pci.c @@ -182,7 +182,7 @@ static const struct pci_device_id port_runtime_pm_black_list[] = {   * this port device.   *   */ -static int __devinit pcie_portdrv_probe(struct pci_dev *dev, +static int pcie_portdrv_probe(struct pci_dev *dev,  					const struct pci_device_id *id)  {  	int status; diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index ec909afa90b6..6186f03d84f3 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -305,7 +305,7 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)  	}  } -static void __devinit pci_read_bridge_io(struct pci_bus *child) +static void pci_read_bridge_io(struct pci_bus *child)  {  	struct pci_dev *dev = child->self;  	u8 io_base_lo, io_limit_lo; @@ -345,7 +345,7 @@ static void __devinit pci_read_bridge_io(struct pci_bus *child)  	}  } -static void __devinit pci_read_bridge_mmio(struct pci_bus *child) +static void pci_read_bridge_mmio(struct pci_bus *child)  {  	struct pci_dev *dev = child->self;  	u16 mem_base_lo, mem_limit_lo; @@ -367,7 +367,7 @@ static void __devinit pci_read_bridge_mmio(struct pci_bus *child)  	}  } -static void __devinit pci_read_bridge_mmio_pref(struct pci_bus *child) +static void pci_read_bridge_mmio_pref(struct pci_bus *child)  {  	struct pci_dev *dev = child->self;  	u16 mem_base_lo, mem_limit_lo; @@ -417,7 +417,7 @@ static void __devinit pci_read_bridge_mmio_pref(struct pci_bus *child)  	}  } -void __devinit pci_read_bridge_bases(struct pci_bus *child) +void pci_read_bridge_bases(struct pci_bus *child)  {  	struct pci_dev *dev = child->self;  	struct resource *res; @@ -521,7 +521,7 @@ static unsigned char pcie_link_speed[] = {  void pcie_update_link_speed(struct pci_bus *bus, u16 linksta)  { -	bus->cur_bus_speed = pcie_link_speed[linksta & 0xf]; +	bus->cur_bus_speed = pcie_link_speed[linksta & PCI_EXP_LNKSTA_CLS];  }  EXPORT_SYMBOL_GPL(pcie_update_link_speed); @@ -579,14 +579,16 @@ static void pci_set_bus_speed(struct pci_bus *bus)  	if (pos) {  		u16 status;  		enum pci_bus_speed max; -		pci_read_config_word(bridge, pos + 2, &status); -		if (status & 0x8000) { +		pci_read_config_word(bridge, pos + PCI_X_BRIDGE_SSTATUS, +				     &status); + +		if (status & PCI_X_SSTATUS_533MHZ) {  			max = PCI_SPEED_133MHz_PCIX_533; -		} else if (status & 0x4000) { +		} else if (status & PCI_X_SSTATUS_266MHZ) {  			max = PCI_SPEED_133MHz_PCIX_266; -		} else if (status & 0x0002) { -			if (((status >> 12) & 0x3) == 2) { +		} else if (status & PCI_X_SSTATUS_133MHZ) { +			if ((status & PCI_X_SSTATUS_VERS) == PCI_X_SSTATUS_V2) {  				max = PCI_SPEED_133MHz_PCIX_ECC;  			} else {  				max = PCI_SPEED_133MHz_PCIX; @@ -596,7 +598,8 @@ static void pci_set_bus_speed(struct pci_bus *bus)  		}  		bus->max_bus_speed = max; -		bus->cur_bus_speed = pcix_bus_speed[(status >> 6) & 0xf]; +		bus->cur_bus_speed = pcix_bus_speed[ +			(status & PCI_X_SSTATUS_FREQ) >> 6];  		return;  	} @@ -607,7 +610,7 @@ static void pci_set_bus_speed(struct pci_bus *bus)  		u16 linksta;  		pcie_capability_read_dword(bridge, PCI_EXP_LNKCAP, &linkcap); -		bus->max_bus_speed = pcie_link_speed[linkcap & 0xf]; +		bus->max_bus_speed = pcie_link_speed[linkcap & PCI_EXP_LNKCAP_SLS];  		pcie_capability_read_word(bridge, PCI_EXP_LNKSTA, &linksta);  		pcie_update_link_speed(bus, linksta); @@ -705,7 +708,7 @@ static void pci_fixup_parent_subordinate_busnr(struct pci_bus *child, int max)   * them, we proceed to assigning numbers to the remaining buses in   * order to avoid overlaps between old and new bus numbers.   */ -int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass) +int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass)  {  	struct pci_bus *child;  	int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS); @@ -975,6 +978,7 @@ int pci_setup_device(struct pci_dev *dev)  	dev->sysdata = dev->bus->sysdata;  	dev->dev.parent = dev->bus->bridge;  	dev->dev.bus = &pci_bus_type; +	dev->dev.type = &pci_dev_type;  	dev->hdr_type = hdr_type & 0x7f;  	dev->multifunction = !!(hdr_type & 0x80);  	dev->error_state = pci_channel_io_normal; @@ -1586,7 +1590,7 @@ void pcie_bus_configure_settings(struct pci_bus *bus, u8 mpss)  }  EXPORT_SYMBOL_GPL(pcie_bus_configure_settings); -unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus) +unsigned int pci_scan_child_bus(struct pci_bus *bus)  {  	unsigned int devfn, pass, max = bus->busn_res.start;  	struct pci_dev *dev; @@ -1790,7 +1794,7 @@ void pci_bus_release_busn_res(struct pci_bus *b)  			res, ret ? "can not be" : "is");  } -struct pci_bus * __devinit pci_scan_root_bus(struct device *parent, int bus, +struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,  		struct pci_ops *ops, void *sysdata, struct list_head *resources)  {  	struct pci_host_bridge_window *window; @@ -1826,7 +1830,7 @@ struct pci_bus * __devinit pci_scan_root_bus(struct device *parent, int bus,  EXPORT_SYMBOL(pci_scan_root_bus);  /* Deprecated; use pci_scan_root_bus() instead */ -struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, +struct pci_bus *pci_scan_bus_parented(struct device *parent,  		int bus, struct pci_ops *ops, void *sysdata)  {  	LIST_HEAD(resources); @@ -1844,7 +1848,7 @@ struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent,  }  EXPORT_SYMBOL(pci_scan_bus_parented); -struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *ops, +struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,  					void *sysdata)  {  	LIST_HEAD(resources); @@ -1864,7 +1868,6 @@ struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *ops,  }  EXPORT_SYMBOL(pci_scan_bus); -#ifdef CONFIG_HOTPLUG  /**   * pci_rescan_bus_bridge_resize - scan a PCI bus for devices.   * @bridge: PCI bridge for the bus to scan @@ -1890,11 +1893,32 @@ unsigned int __ref pci_rescan_bus_bridge_resize(struct pci_dev *bridge)  	return max;  } +/** + * pci_rescan_bus - scan a PCI bus for devices. + * @bus: PCI bus to scan + * + * Scan a PCI bus and child buses for new devices, adds them, + * and enables them. + * + * Returns the max number of subordinate bus discovered. + */ +unsigned int __ref pci_rescan_bus(struct pci_bus *bus) +{ +	unsigned int max; + +	max = pci_scan_child_bus(bus); +	pci_assign_unassigned_bus_resources(bus); +	pci_enable_bridges(bus); +	pci_bus_add_devices(bus); + +	return max; +} +EXPORT_SYMBOL_GPL(pci_rescan_bus); +  EXPORT_SYMBOL(pci_add_new_bus);  EXPORT_SYMBOL(pci_scan_slot);  EXPORT_SYMBOL(pci_scan_bridge);  EXPORT_SYMBOL_GPL(pci_scan_child_bus); -#endif  static int __init pci_sort_bf_cmp(const struct device *d_a, const struct device *d_b)  { diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 7a451ff56ecc..8f7a6344e79e 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -37,7 +37,7 @@   * key system devices. For devices that need to have mmio decoding always-on,   * we need to set the dev->mmio_always_on bit.   */ -static void __devinit quirk_mmio_always_on(struct pci_dev *dev) +static void quirk_mmio_always_on(struct pci_dev *dev)  {  	dev->mmio_always_on = 1;  } @@ -48,7 +48,7 @@ DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_ANY_ID, PCI_ANY_ID,   * Mark this device with a broken_parity_status, to allow   * PCI scanning code to "skip" this now blacklisted device.   */ -static void __devinit quirk_mellanox_tavor(struct pci_dev *dev) +static void quirk_mellanox_tavor(struct pci_dev *dev)  {  	dev->broken_parity_status = 1;	/* This device gives false positives */  } @@ -83,7 +83,7 @@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_82441,	quirk_p      This appears to be BIOS not version dependent. So presumably there is a       chipset level fix */ -static void __devinit quirk_isa_dma_hangs(struct pci_dev *dev) +static void quirk_isa_dma_hangs(struct pci_dev *dev)  {  	if (!isa_dma_bridge_buggy) {  		isa_dma_bridge_buggy=1; @@ -106,7 +106,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NEC,	PCI_DEVICE_ID_NEC_CBUS_3,	quirk_isa_d   * Intel NM10 "TigerPoint" LPC PM1a_STS.BM_STS must be clear   * for some HT machines to use C4 w/o hanging.   */ -static void __devinit quirk_tigerpoint_bm_sts(struct pci_dev *dev) +static void quirk_tigerpoint_bm_sts(struct pci_dev *dev)  {  	u32 pmbase;  	u16 pm1a; @@ -125,7 +125,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TGP_LPC, quirk  /*   *	Chipsets where PCI->PCI transfers vanish or hang   */ -static void __devinit quirk_nopcipci(struct pci_dev *dev) +static void quirk_nopcipci(struct pci_dev *dev)  {  	if ((pci_pci_problems & PCIPCI_FAIL)==0) {  		dev_info(&dev->dev, "Disabling direct PCI/PCI transfers\n"); @@ -135,7 +135,7 @@ static void __devinit quirk_nopcipci(struct pci_dev *dev)  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SI,	PCI_DEVICE_ID_SI_5597,		quirk_nopcipci);  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SI,	PCI_DEVICE_ID_SI_496,		quirk_nopcipci); -static void __devinit quirk_nopciamd(struct pci_dev *dev) +static void quirk_nopciamd(struct pci_dev *dev)  {  	u8 rev;  	pci_read_config_byte(dev, 0x08, &rev); @@ -150,7 +150,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD,	PCI_DEVICE_ID_AMD_8151_0,	quirk_nopci  /*   *	Triton requires workarounds to be used by the drivers   */ -static void __devinit quirk_triton(struct pci_dev *dev) +static void quirk_triton(struct pci_dev *dev)  {  	if ((pci_pci_problems&PCIPCI_TRITON)==0) {  		dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n"); @@ -229,7 +229,7 @@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_8361,		quirk_viala  /*   *	VIA Apollo VP3 needs ETBF on BT848/878   */ -static void __devinit quirk_viaetbf(struct pci_dev *dev) +static void quirk_viaetbf(struct pci_dev *dev)  {  	if ((pci_pci_problems&PCIPCI_VIAETBF)==0) {  		dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n"); @@ -238,7 +238,7 @@ static void __devinit quirk_viaetbf(struct pci_dev *dev)  }  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C597_0,	quirk_viaetbf); -static void __devinit quirk_vsfx(struct pci_dev *dev) +static void quirk_vsfx(struct pci_dev *dev)  {  	if ((pci_pci_problems&PCIPCI_VSFX)==0) {  		dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n"); @@ -253,7 +253,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C576,	quirk_vsfx)   *	workaround applied too   *	[Info kindly provided by ALi]   */	 -static void __devinit quirk_alimagik(struct pci_dev *dev) +static void quirk_alimagik(struct pci_dev *dev)  {  	if ((pci_pci_problems&PCIPCI_ALIMAGIK)==0) {  		dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n"); @@ -267,7 +267,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, 	PCI_DEVICE_ID_AL_M1651, 	quirk_alimag   *	Natoma has some interesting boundary conditions with Zoran stuff   *	at least   */ -static void __devinit quirk_natoma(struct pci_dev *dev) +static void quirk_natoma(struct pci_dev *dev)  {  	if ((pci_pci_problems&PCIPCI_NATOMA)==0) {  		dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n"); @@ -285,7 +285,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 	PCI_DEVICE_ID_INTEL_82443BX_2, 	qu   *  This chip can cause PCI parity errors if config register 0xA0 is read   *  while DMAs are occurring.   */ -static void __devinit quirk_citrine(struct pci_dev *dev) +static void quirk_citrine(struct pci_dev *dev)  {  	dev->cfg_size = 0xA0;  } @@ -295,7 +295,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IBM,	PCI_DEVICE_ID_IBM_CITRINE,	quirk_cit   *  S3 868 and 968 chips report region size equal to 32M, but they decode 64M.   *  If it's needed, re-allocate the region.   */ -static void __devinit quirk_s3_64M(struct pci_dev *dev) +static void quirk_s3_64M(struct pci_dev *dev)  {  	struct resource *r = &dev->resource[0]; @@ -313,7 +313,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_S3,	PCI_DEVICE_ID_S3_968,		quirk_s3_64M);   * BAR0 should be 8 bytes; instead, it may be set to something like 8k   * (which conflicts w/ BAR1's memory range).   */ -static void __devinit quirk_cs5536_vsa(struct pci_dev *dev) +static void quirk_cs5536_vsa(struct pci_dev *dev)  {  	if (pci_resource_len(dev, 0) != 8) {  		struct resource *res = &dev->resource[0]; @@ -324,7 +324,7 @@ static void __devinit quirk_cs5536_vsa(struct pci_dev *dev)  }  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA, quirk_cs5536_vsa); -static void __devinit quirk_io_region(struct pci_dev *dev, unsigned region, +static void quirk_io_region(struct pci_dev *dev, unsigned region,  	unsigned size, int nr, const char *name)  {  	region &= ~(size-1); @@ -352,7 +352,7 @@ static void __devinit quirk_io_region(struct pci_dev *dev, unsigned region,   *	ATI Northbridge setups MCE the processor if you even   *	read somewhere between 0x3b0->0x3bb or read 0x3d3   */ -static void __devinit quirk_ati_exploding_mce(struct pci_dev *dev) +static void quirk_ati_exploding_mce(struct pci_dev *dev)  {  	dev_info(&dev->dev, "ATI Northbridge, reserving I/O ports 0x3b0 to 0x3bb\n");  	/* Mae rhaid i ni beidio ag edrych ar y lleoliadiau I/O hyn */ @@ -372,7 +372,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI,	PCI_DEVICE_ID_ATI_RS100,   quirk_ati_   *	0xE0 (64 bytes of ACPI registers)   *	0xE2 (32 bytes of SMB registers)   */ -static void __devinit quirk_ali7101_acpi(struct pci_dev *dev) +static void quirk_ali7101_acpi(struct pci_dev *dev)  {  	u16 region; @@ -440,7 +440,7 @@ static void piix4_mem_quirk(struct pci_dev *dev, const char *name, unsigned int   *	0x90 (16 bytes of SMB registers)   * and a few strange programmable PIIX4 device resources.   */ -static void __devinit quirk_piix4_acpi(struct pci_dev *dev) +static void quirk_piix4_acpi(struct pci_dev *dev)  {  	u32 region, res_a; @@ -489,7 +489,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_82443MX_3,	qui   *	0x40 (128 bytes of ACPI, GPIO & TCO registers)   *	0x58 (64 bytes of GPIO I/O space)   */ -static void __devinit quirk_ich4_lpc_acpi(struct pci_dev *dev) +static void quirk_ich4_lpc_acpi(struct pci_dev *dev)  {  	u32 region;  	u8 enable; @@ -531,7 +531,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_82801DB_12,  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_82801EB_0,		quirk_ich4_lpc_acpi);  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_ESB_1,		quirk_ich4_lpc_acpi); -static void __devinit ich6_lpc_acpi_gpio(struct pci_dev *dev) +static void ich6_lpc_acpi_gpio(struct pci_dev *dev)  {  	u32 region;  	u8 enable; @@ -555,7 +555,7 @@ static void __devinit ich6_lpc_acpi_gpio(struct pci_dev *dev)  	}  } -static void __devinit ich6_lpc_generic_decode(struct pci_dev *dev, unsigned reg, const char *name, int dynsize) +static void ich6_lpc_generic_decode(struct pci_dev *dev, unsigned reg, const char *name, int dynsize)  {  	u32 val;  	u32 size, base; @@ -583,7 +583,7 @@ static void __devinit ich6_lpc_generic_decode(struct pci_dev *dev, unsigned reg,  	dev_info(&dev->dev, "%s PIO at %04x-%04x\n", name, base, base+size-1);  } -static void __devinit quirk_ich6_lpc(struct pci_dev *dev) +static void quirk_ich6_lpc(struct pci_dev *dev)  {  	/* Shared ACPI/GPIO decode with all ICH6+ */  	ich6_lpc_acpi_gpio(dev); @@ -595,7 +595,7 @@ static void __devinit quirk_ich6_lpc(struct pci_dev *dev)  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_ICH6_0, quirk_ich6_lpc);  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_ICH6_1, quirk_ich6_lpc); -static void __devinit ich7_lpc_generic_decode(struct pci_dev *dev, unsigned reg, const char *name) +static void ich7_lpc_generic_decode(struct pci_dev *dev, unsigned reg, const char *name)  {  	u32 val;  	u32 mask, base; @@ -619,7 +619,7 @@ static void __devinit ich7_lpc_generic_decode(struct pci_dev *dev, unsigned reg,  }  /* ICH7-10 has the same common LPC generic IO decode registers */ -static void __devinit quirk_ich7_lpc(struct pci_dev *dev) +static void quirk_ich7_lpc(struct pci_dev *dev)  {  	/* We share the common ACPI/GPIO decode with ICH6 */  	ich6_lpc_acpi_gpio(dev); @@ -648,7 +648,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL,   PCI_DEVICE_ID_INTEL_ICH10_1, qui   * VIA ACPI: One IO region pointed to by longword at   *	0x48 or 0x20 (256 bytes of ACPI registers)   */ -static void __devinit quirk_vt82c586_acpi(struct pci_dev *dev) +static void quirk_vt82c586_acpi(struct pci_dev *dev)  {  	u32 region; @@ -666,7 +666,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C586_3,	quirk_vt   *	0x70 (128 bytes of hardware monitoring register)   *	0x90 (16 bytes of SMB registers)   */ -static void __devinit quirk_vt82c686_acpi(struct pci_dev *dev) +static void quirk_vt82c686_acpi(struct pci_dev *dev)  {  	u16 hm;  	u32 smb; @@ -688,7 +688,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C686_4,	quirk_vt   *	0x88 (128 bytes of power management registers)   *	0xd0 (16 bytes of SMB registers)   */ -static void __devinit quirk_vt8235_acpi(struct pci_dev *dev) +static void quirk_vt8235_acpi(struct pci_dev *dev)  {  	u16 pm, smb; @@ -706,7 +706,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_8235,	quirk_vt8235   * TI XIO2000a PCIe-PCI Bridge erroneously reports it supports fast back-to-back:   *	Disable fast back-to-back on the secondary bus segment   */ -static void __devinit quirk_xio2000a(struct pci_dev *dev) +static void quirk_xio2000a(struct pci_dev *dev)  {  	struct pci_dev *pdev;  	u16 command; @@ -780,7 +780,7 @@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_8237,		quirk   * noapic specified. For the moment we assume it's the erratum. We may be wrong   * of course. However the advice is demonstrably good even if so..   */ -static void __devinit quirk_amd_ioapic(struct pci_dev *dev) +static void quirk_amd_ioapic(struct pci_dev *dev)  {  	if (dev->revision >= 0x02) {  		dev_warn(&dev->dev, "I/O APIC: AMD Erratum #22 may be present. In the event of instability try\n"); @@ -789,7 +789,7 @@ static void __devinit quirk_amd_ioapic(struct pci_dev *dev)  }  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD,	PCI_DEVICE_ID_AMD_VIPER_7410,	quirk_amd_ioapic); -static void __devinit quirk_ioapic_rmw(struct pci_dev *dev) +static void quirk_ioapic_rmw(struct pci_dev *dev)  {  	if (dev->devfn == 0 && dev->bus->number == 0)  		sis_apic_bug = 1; @@ -801,7 +801,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SI,	PCI_ANY_ID,			quirk_ioapic_rmw);   * Some settings of MMRBC can lead to data corruption so block changes.   * See AMD 8131 HyperTransport PCI-X Tunnel Revision Guide   */ -static void __devinit quirk_amd_8131_mmrbc(struct pci_dev *dev) +static void quirk_amd_8131_mmrbc(struct pci_dev *dev)  {  	if (dev->subordinate && dev->revision <= 0x12) {  		dev_info(&dev->dev, "AMD8131 rev %x detected; " @@ -819,7 +819,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_   * value of the ACPI SCI interrupt is only done for convenience.   *	-jgarzik   */ -static void __devinit quirk_via_acpi(struct pci_dev *d) +static void quirk_via_acpi(struct pci_dev *d)  {  	/*  	 * VIA ACPI device: SCI IRQ line in PCI config byte 0x42 @@ -926,7 +926,7 @@ DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_ANY_ID, quirk_via_vlink);   * We need to switch it off to be able to recognize the real   * type of the chip.   */ -static void __devinit quirk_vt82c598_id(struct pci_dev *dev) +static void quirk_vt82c598_id(struct pci_dev *dev)  {  	pci_write_config_byte(dev, 0xfc, 0);  	pci_read_config_word(dev, PCI_DEVICE_ID, &dev->device); @@ -978,7 +978,7 @@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AMD,	PCI_DEVICE_ID_AMD_FE_GATE_700C   *	assigned to it. We force a larger allocation to ensure that   *	nothing gets put too close to it.   */ -static void __devinit quirk_dunord ( struct pci_dev * dev ) +static void quirk_dunord(struct pci_dev *dev)  {  	struct resource *r = &dev->resource [1];  	r->start = 0; @@ -992,7 +992,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_DUNORD,	PCI_DEVICE_ID_DUNORD_I3000,	quirk   * in the ProgIf. Unfortunately, the ProgIf value is wrong - 0x80   * instead of 0x01.   */ -static void __devinit quirk_transparent_bridge(struct pci_dev *dev) +static void quirk_transparent_bridge(struct pci_dev *dev)  {  	dev->transparent = 1;  } @@ -1066,7 +1066,7 @@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SATA  /*   *	Serverworks CSB5 IDE does not fully support native mode   */ -static void __devinit quirk_svwks_csb5ide(struct pci_dev *pdev) +static void quirk_svwks_csb5ide(struct pci_dev *pdev)  {  	u8 prog;  	pci_read_config_byte(pdev, PCI_CLASS_PROG, &prog); @@ -1082,7 +1082,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB  /*   *	Intel 82801CAM ICH3-M datasheet says IDE modes must be the same   */ -static void __devinit quirk_ide_samemode(struct pci_dev *pdev) +static void quirk_ide_samemode(struct pci_dev *pdev)  {  	u8 prog; @@ -1101,7 +1101,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_10, qui   * Some ATA devices break if put into D3   */ -static void __devinit quirk_no_ata_d3(struct pci_dev *pdev) +static void quirk_no_ata_d3(struct pci_dev *pdev)  {  	pdev->dev_flags |= PCI_DEV_FLAGS_NO_D3;  } @@ -1121,7 +1121,7 @@ DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_VIA, PCI_ANY_ID,  /* This was originally an Alpha specific thing, but it really fits here.   * The i82375 PCI/EISA bridge appears as non-classified. Fix that.   */ -static void __devinit quirk_eisa_bridge(struct pci_dev *dev) +static void quirk_eisa_bridge(struct pci_dev *dev)  {  	dev->class = PCI_CLASS_BRIDGE_EISA << 8;  } @@ -1155,7 +1155,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_82375,	quirk_e   */  static int asus_hides_smbus; -static void __devinit asus_hides_smbus_hostbridge(struct pci_dev *dev) +static void asus_hides_smbus_hostbridge(struct pci_dev *dev)  {  	if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_ASUSTEK)) {  		if (dev->device == PCI_DEVICE_ID_INTEL_82845_HB) @@ -1538,7 +1538,7 @@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB3  #endif  #ifdef CONFIG_X86_IO_APIC -static void __devinit quirk_alder_ioapic(struct pci_dev *pdev) +static void quirk_alder_ioapic(struct pci_dev *pdev)  {  	int i; @@ -1561,7 +1561,7 @@ static void __devinit quirk_alder_ioapic(struct pci_dev *pdev)  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_EESSC,	quirk_alder_ioapic);  #endif -static void __devinit quirk_pcie_mch(struct pci_dev *pdev) +static void quirk_pcie_mch(struct pci_dev *pdev)  {  	pci_msi_off(pdev);  	pdev->no_msi = 1; @@ -1575,7 +1575,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_E7525_MCH,	quir   * It's possible for the MSI to get corrupted if shpc and acpi   * are used together on certain PXH-based systems.   */ -static void __devinit quirk_pcie_pxh(struct pci_dev *dev) +static void quirk_pcie_pxh(struct pci_dev *dev)  {  	pci_msi_off(dev);  	dev->no_msi = 1; @@ -1777,7 +1777,7 @@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD,   PCI_DEVICE_ID_AMD_8111_SMBUS, 	qui   * but the PIO transfers won't work if BAR0 falls at the odd 8 bytes.   * Re-allocate the region if needed...   */ -static void __devinit quirk_tc86c001_ide(struct pci_dev *dev) +static void quirk_tc86c001_ide(struct pci_dev *dev)  {  	struct resource *r = &dev->resource[0]; @@ -1790,7 +1790,46 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TOSHIBA_2,  			 PCI_DEVICE_ID_TOSHIBA_TC86C001_IDE,  			 quirk_tc86c001_ide); -static void __devinit quirk_netmos(struct pci_dev *dev) +/* + * PLX PCI 9050 PCI Target bridge controller has an errata that prevents the + * local configuration registers accessible via BAR0 (memory) or BAR1 (i/o) + * being read correctly if bit 7 of the base address is set. + * The BAR0 or BAR1 region may be disabled (size 0) or enabled (size 128). + * Re-allocate the regions to a 256-byte boundary if necessary. + */ +static void quirk_plx_pci9050(struct pci_dev *dev) +{ +	unsigned int bar; + +	/* Fixed in revision 2 (PCI 9052). */ +	if (dev->revision >= 2) +		return; +	for (bar = 0; bar <= 1; bar++) +		if (pci_resource_len(dev, bar) == 0x80 && +		    (pci_resource_start(dev, bar) & 0x80)) { +			struct resource *r = &dev->resource[bar]; +			dev_info(&dev->dev, +				 "Re-allocating PLX PCI 9050 BAR %u to length 256 to avoid bit 7 bug\n", +				 bar); +			r->start = 0; +			r->end = 0xff; +		} +} +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, +			 quirk_plx_pci9050); +/* + * The following Meilhaus (vendor ID 0x1402) device IDs (amongst others) + * may be using the PLX PCI 9050: 0x0630, 0x0940, 0x0950, 0x0960, 0x100b, + * 0x1400, 0x140a, 0x140b, 0x14e0, 0x14ea, 0x14eb, 0x1604, 0x1608, 0x160c, + * 0x168f, 0x2000, 0x2600, 0x3000, 0x810a, 0x810b. + * + * Currently, device IDs 0x2000 and 0x2600 are used by the Comedi "me_daq" + * driver. + */ +DECLARE_PCI_FIXUP_HEADER(0x1402, 0x2000, quirk_plx_pci9050); +DECLARE_PCI_FIXUP_HEADER(0x1402, 0x2600, quirk_plx_pci9050); + +static void quirk_netmos(struct pci_dev *dev)  {  	unsigned int num_parallel = (dev->subsystem_device & 0xf0) >> 4;  	unsigned int num_serial = dev->subsystem_device & 0xf; @@ -1828,7 +1867,7 @@ static void __devinit quirk_netmos(struct pci_dev *dev)  DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_NETMOS, PCI_ANY_ID,  			 PCI_CLASS_COMMUNICATION_SERIAL, 8, quirk_netmos); -static void __devinit quirk_e100_interrupt(struct pci_dev *dev) +static void quirk_e100_interrupt(struct pci_dev *dev)  {  	u16 command, pmcsr;  	u8 __iomem *csr; @@ -1901,7 +1940,7 @@ DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID,   * The 82575 and 82598 may experience data corruption issues when transitioning   * out of L0S.  To prevent this we need to disable L0S on the pci-e link   */ -static void __devinit quirk_disable_aspm_l0s(struct pci_dev *dev) +static void quirk_disable_aspm_l0s(struct pci_dev *dev)  {  	dev_info(&dev->dev, "Disabling L0s\n");  	pci_disable_link_state(dev, PCIE_LINK_STATE_L0S); @@ -1921,7 +1960,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10f1, quirk_disable_aspm_l0s);  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10f4, quirk_disable_aspm_l0s);  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1508, quirk_disable_aspm_l0s); -static void __devinit fixup_rev1_53c810(struct pci_dev* dev) +static void fixup_rev1_53c810(struct pci_dev *dev)  {  	/* rev 1 ncr53c810 chips don't set the class at all which means  	 * they don't get their resources remapped. Fix that here. @@ -1935,7 +1974,7 @@ static void __devinit fixup_rev1_53c810(struct pci_dev* dev)  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, fixup_rev1_53c810);  /* Enable 1k I/O space granularity on the Intel P64H2 */ -static void __devinit quirk_p64h2_1k_io(struct pci_dev *dev) +static void quirk_p64h2_1k_io(struct pci_dev *dev)  {  	u16 en1k; @@ -1968,7 +2007,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA,  PCI_DEVICE_ID_NVIDIA_CK804_PCIE,  DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_NVIDIA,  PCI_DEVICE_ID_NVIDIA_CK804_PCIE,  			quirk_nvidia_ck804_pcie_aer_ext_cap); -static void __devinit quirk_via_cx700_pci_parking_caching(struct pci_dev *dev) +static void quirk_via_cx700_pci_parking_caching(struct pci_dev *dev)  {  	/*  	 * Disable PCI Bus Parking and PCI Master read caching on CX700 @@ -2031,7 +2070,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, 0x324e, quirk_via_cx700_pci_parking_c   * We believe that it is legal to read beyond the end tag and   * therefore the solution is to limit the read/write length.   */ -static void __devinit quirk_brcm_570x_limit_vpd(struct pci_dev *dev) +static void quirk_brcm_570x_limit_vpd(struct pci_dev *dev)  {  	/*  	 * Only disable the VPD capability for 5706, 5706S, 5708, @@ -2091,7 +2130,7 @@ DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_BROADCOM,   * the DRBs - this is where we expose device 6.   * http://www.x86-secret.com/articles/tweak/pat/patsecrets-2.htm   */ -static void __devinit quirk_unhide_mch_dev6(struct pci_dev *dev) +static void quirk_unhide_mch_dev6(struct pci_dev *dev)  {  	u8 reg; @@ -2115,7 +2154,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82875_HB,   * supports link speed auto negotiation, but falsely sets   * the link speed to 5GT/s.   */ -static void __devinit quirk_tile_plx_gen1(struct pci_dev *dev) +static void quirk_tile_plx_gen1(struct pci_dev *dev)  {  	if (tile_plx_gen1) {  		pci_write_config_dword(dev, 0x98, 0x1); @@ -2132,7 +2171,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_PLX, 0x8624, quirk_tile_plx_gen1);   * aware of it.  Instead of setting the flag on all busses in the   * machine, simply disable MSI globally.   */ -static void __devinit quirk_disable_all_msi(struct pci_dev *dev) +static void quirk_disable_all_msi(struct pci_dev *dev)  {  	pci_no_msi();  	dev_warn(&dev->dev, "MSI quirk detected; MSI disabled\n"); @@ -2146,7 +2185,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VT3364, quirk_disab  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8380_0, quirk_disable_all_msi);  /* Disable MSI on chipsets that are known to not support it */ -static void __devinit quirk_disable_msi(struct pci_dev *dev) +static void quirk_disable_msi(struct pci_dev *dev)  {  	if (dev->subordinate) {  		dev_warn(&dev->dev, "MSI quirk detected; " @@ -2164,7 +2203,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x5a3f, quirk_disable_msi);   * we use the possible vendor/device IDs of the host bridge for the   * declared quirk, and search for the APC bridge by slot number.   */ -static void __devinit quirk_amd_780_apc_msi(struct pci_dev *host_bridge) +static void quirk_amd_780_apc_msi(struct pci_dev *host_bridge)  {  	struct pci_dev *apc_bridge; @@ -2272,7 +2311,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8132_BRIDGE,   * for the MCP55 NIC. It is not yet determined whether the msi problem   * also affects other devices. As for now, turn off msi for this device.   */ -static void __devinit nvenet_msi_disable(struct pci_dev *dev) +static void nvenet_msi_disable(struct pci_dev *dev)  {  	const char *board_name = dmi_get_system_info(DMI_BOARD_NAME); @@ -2298,7 +2337,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NVIDIA,   * we have it set correctly.   * Note this is an undocumented register.   */ -static void __devinit nvbridge_check_legacy_irq_routing(struct pci_dev *dev) +static void nvbridge_check_legacy_irq_routing(struct pci_dev *dev)  {  	u32 cfg; @@ -2534,11 +2573,11 @@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, nv_msi_ht_cap_q  DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, PCI_ANY_ID, nv_msi_ht_cap_quirk_all);  DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AL, PCI_ANY_ID, nv_msi_ht_cap_quirk_all); -static void __devinit quirk_msi_intx_disable_bug(struct pci_dev *dev) +static void quirk_msi_intx_disable_bug(struct pci_dev *dev)  {  	dev->dev_flags |= PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG;  } -static void __devinit quirk_msi_intx_disable_ati_bug(struct pci_dev *dev) +static void quirk_msi_intx_disable_ati_bug(struct pci_dev *dev)  {  	struct pci_dev *p; @@ -2612,7 +2651,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, 0x1083,   * kernel fails to allocate resources when hotplug device is    * inserted and PCI bus is rescanned.   */ -static void __devinit quirk_hotplug_bridge(struct pci_dev *dev) +static void quirk_hotplug_bridge(struct pci_dev *dev)  {  	dev->is_hotplug_bridge = 1;  } @@ -2752,7 +2791,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x342e, vtd_mask_spec_errors);  DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x3c28, vtd_mask_spec_errors);  #endif -static void __devinit fixup_ti816x_class(struct pci_dev* dev) +static void fixup_ti816x_class(struct pci_dev *dev)  {  	/* TI 816x devices do not have class code set when in PCIe boot mode */  	dev_info(&dev->dev, "Setting PCI class for 816x PCIe device\n"); @@ -2764,7 +2803,7 @@ DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_TI, 0xb800,  /* Some PCIe devices do not work reliably with the claimed maximum   * payload size supported.   */ -static void __devinit fixup_mpss_256(struct pci_dev *dev) +static void fixup_mpss_256(struct pci_dev *dev)  {  	dev->pcie_mpss = 1; /* 256 bytes */  } @@ -2782,7 +2821,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SOLARFLARE,   * coalescing must be disabled.  Unfortunately, it cannot be re-enabled because   * it is possible to hotplug a device with MPS of 256B.   */ -static void __devinit quirk_intel_mc_errata(struct pci_dev *dev) +static void quirk_intel_mc_errata(struct pci_dev *dev)  {  	int err;  	u16 rcc; @@ -2888,7 +2927,7 @@ static void fixup_debug_report(struct pci_dev *dev, ktime_t calltime,   * This resolves crashes often seen on monitor unplug.   */  #define I915_DEIER_REG 0x4400c -static void __devinit disable_igfx_irq(struct pci_dev *dev) +static void disable_igfx_irq(struct pci_dev *dev)  {  	void __iomem *regs = pci_iomap(dev, 0, 0);  	if (regs == NULL) { @@ -2914,7 +2953,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x010a, disable_igfx_irq);   * PCI_COMMAND_INTX_DISABLE works though they actually do not properly   * support this feature.   */ -static void __devinit quirk_broken_intx_masking(struct pci_dev *dev) +static void quirk_broken_intx_masking(struct pci_dev *dev)  {  	dev->broken_intx_masking = 1;  } diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index 513972f3ed13..7c0fd9252e6f 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c @@ -111,3 +111,39 @@ void pci_stop_and_remove_bus_device(struct pci_dev *dev)  	pci_remove_bus_device(dev);  }  EXPORT_SYMBOL(pci_stop_and_remove_bus_device); + +void pci_stop_root_bus(struct pci_bus *bus) +{ +	struct pci_dev *child, *tmp; +	struct pci_host_bridge *host_bridge; + +	if (!pci_is_root_bus(bus)) +		return; + +	host_bridge = to_pci_host_bridge(bus->bridge); +	list_for_each_entry_safe_reverse(child, tmp, +					 &bus->devices, bus_list) +		pci_stop_bus_device(child); + +	/* stop the host bridge */ +	device_del(&host_bridge->dev); +} + +void pci_remove_root_bus(struct pci_bus *bus) +{ +	struct pci_dev *child, *tmp; +	struct pci_host_bridge *host_bridge; + +	if (!pci_is_root_bus(bus)) +		return; + +	host_bridge = to_pci_host_bridge(bus->bridge); +	list_for_each_entry_safe(child, tmp, +				 &bus->devices, bus_list) +		pci_remove_bus_device(child); +	pci_remove_bus(bus); +	host_bridge->bus = NULL; + +	/* remove the host bridge */ +	put_device(&host_bridge->dev); +} diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c index 0b3037ab8b93..ab886b7ee327 100644 --- a/drivers/pci/rom.c +++ b/drivers/pci/rom.c @@ -118,11 +118,17 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)  	void __iomem *rom;  	/* +	 * Some devices may provide ROMs via a source other than the BAR +	 */ +	if (pdev->rom && pdev->romlen) { +		*size = pdev->romlen; +		return phys_to_virt(pdev->rom); +	/*  	 * IORESOURCE_ROM_SHADOW set on x86, x86_64 and IA64 supports legacy  	 * memory map if the VGA enable bit of the Bridge Control register is  	 * set for embedded VGA.  	 */ -	if (res->flags & IORESOURCE_ROM_SHADOW) { +	} else if (res->flags & IORESOURCE_ROM_SHADOW) {  		/* primary video rom always starts here */  		start = (loff_t)0xC0000;  		*size = 0x20000; /* cover C000:0 through E000:0 */ @@ -181,7 +187,8 @@ void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom)  	if (res->flags & (IORESOURCE_ROM_COPY | IORESOURCE_ROM_BIOS_COPY))  		return; -	iounmap(rom); +	if (!pdev->rom || !pdev->romlen) +		iounmap(rom);  	/* Disable again before continuing, leave enabled if pci=rom */  	if (!(res->flags & (IORESOURCE_ROM_ENABLE | IORESOURCE_ROM_SHADOW))) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 1e808ca338f8..6d3591d57ea0 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1550,25 +1550,12 @@ enable_all:  }  EXPORT_SYMBOL_GPL(pci_assign_unassigned_bridge_resources); -#ifdef CONFIG_HOTPLUG -/** - * pci_rescan_bus - scan a PCI bus for devices. - * @bus: PCI bus to scan - * - * Scan a PCI bus and child buses for new devices, adds them, - * and enables them. - * - * Returns the max number of subordinate bus discovered. - */ -unsigned int __ref pci_rescan_bus(struct pci_bus *bus) +void pci_assign_unassigned_bus_resources(struct pci_bus *bus)  { -	unsigned int max;  	struct pci_dev *dev;  	LIST_HEAD(add_list); /* list of resources that  					want additional resources */ -	max = pci_scan_child_bus(bus); -  	down_read(&pci_bus_sem);  	list_for_each_entry(dev, &bus->devices, bus_list)  		if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || @@ -1579,11 +1566,4 @@ unsigned int __ref pci_rescan_bus(struct pci_bus *bus)  	up_read(&pci_bus_sem);  	__pci_bus_assign_resources(bus, &add_list, NULL);  	BUG_ON(!list_empty(&add_list)); - -	pci_enable_bridges(bus); -	pci_bus_add_devices(bus); - -	return max;  } -EXPORT_SYMBOL_GPL(pci_rescan_bus); -#endif diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c index 0aab85a51559..966abc6054d7 100644 --- a/drivers/pci/xen-pcifront.c +++ b/drivers/pci/xen-pcifront.c @@ -412,7 +412,7 @@ static int pcifront_claim_resource(struct pci_dev *dev, void *data)  	return 0;  } -static int __devinit pcifront_scan_bus(struct pcifront_device *pdev, +static int pcifront_scan_bus(struct pcifront_device *pdev,  				unsigned int domain, unsigned int bus,  				struct pci_bus *b)  { @@ -441,7 +441,7 @@ static int __devinit pcifront_scan_bus(struct pcifront_device *pdev,  	return 0;  } -static int __devinit pcifront_scan_root(struct pcifront_device *pdev, +static int pcifront_scan_root(struct pcifront_device *pdev,  				 unsigned int domain, unsigned int bus)  {  	struct pci_bus *b; @@ -503,7 +503,7 @@ err_out:  	return err;  } -static int __devinit pcifront_rescan_root(struct pcifront_device *pdev, +static int pcifront_rescan_root(struct pcifront_device *pdev,  				   unsigned int domain, unsigned int bus)  {  	int err; @@ -834,7 +834,7 @@ out:  	return err;  } -static int __devinit pcifront_try_connect(struct pcifront_device *pdev) +static int pcifront_try_connect(struct pcifront_device *pdev)  {  	int err = -EFAULT;  	int i, num_roots, len; @@ -924,7 +924,7 @@ out:  	return err;  } -static int __devinit pcifront_attach_devices(struct pcifront_device *pdev) +static int pcifront_attach_devices(struct pcifront_device *pdev)  {  	int err = -EFAULT;  	int i, num_roots, len; @@ -1068,13 +1068,16 @@ static void __init_refok pcifront_backend_changed(struct xenbus_device *xdev,  	case XenbusStateInitialising:  	case XenbusStateInitWait:  	case XenbusStateInitialised: -	case XenbusStateClosed:  		break;  	case XenbusStateConnected:  		pcifront_try_connect(pdev);  		break; +	case XenbusStateClosed: +		if (xdev->state == XenbusStateClosed) +			break; +		/* Missed the backend's CLOSING state -- fallthrough */  	case XenbusStateClosing:  		dev_warn(&xdev->dev, "backend going away!\n");  		pcifront_try_disconnect(pdev); |