diff options
Diffstat (limited to 'drivers/pci/pci.c')
| -rw-r--r-- | drivers/pci/pci.c | 66 | 
1 files changed, 52 insertions, 14 deletions
| diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 16a17215f633..b717680377a9 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -693,6 +693,36 @@ u8 pci_find_ht_capability(struct pci_dev *dev, int ht_cap)  EXPORT_SYMBOL_GPL(pci_find_ht_capability);  /** + * pci_find_vsec_capability - Find a vendor-specific extended capability + * @dev: PCI device to query + * @vendor: Vendor ID for which capability is defined + * @cap: Vendor-specific capability ID + * + * If @dev has Vendor ID @vendor, search for a VSEC capability with + * VSEC ID @cap. If found, return the capability offset in + * config space; otherwise return 0. + */ +u16 pci_find_vsec_capability(struct pci_dev *dev, u16 vendor, int cap) +{ +	u16 vsec = 0; +	u32 header; + +	if (vendor != dev->vendor) +		return 0; + +	while ((vsec = pci_find_next_ext_capability(dev, vsec, +						     PCI_EXT_CAP_ID_VNDR))) { +		if (pci_read_config_dword(dev, vsec + PCI_VNDR_HEADER, +					  &header) == PCIBIOS_SUCCESSFUL && +		    PCI_VNDR_HEADER_ID(header) == cap) +			return vsec; +	} + +	return 0; +} +EXPORT_SYMBOL_GPL(pci_find_vsec_capability); + +/**   * pci_find_parent_resource - return resource region of parent bus of given   *			      region   * @dev: PCI device structure contains resources to be searched @@ -1870,20 +1900,10 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)  	int err;  	int i, bars = 0; -	/* -	 * Power state could be unknown at this point, either due to a fresh -	 * boot or a device removal call.  So get the current power state -	 * so that things like MSI message writing will behave as expected -	 * (e.g. if the device really is in D0 at enable time). -	 */ -	if (dev->pm_cap) { -		u16 pmcsr; -		pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); -		dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK); -	} - -	if (atomic_inc_return(&dev->enable_cnt) > 1) +	if (atomic_inc_return(&dev->enable_cnt) > 1) { +		pci_update_current_state(dev, dev->current_state);  		return 0;		/* already enabled */ +	}  	bridge = pci_upstream_bridge(dev);  	if (bridge) @@ -4052,6 +4072,7 @@ phys_addr_t pci_pio_to_address(unsigned long pio)  	return address;  } +EXPORT_SYMBOL_GPL(pci_pio_to_address);  unsigned long __weak pci_address_to_pio(phys_addr_t address)  { @@ -4112,7 +4133,7 @@ void pci_unmap_iospace(struct resource *res)  #if defined(PCI_IOBASE) && defined(CONFIG_MMU)  	unsigned long vaddr = (unsigned long)PCI_IOBASE + res->start; -	unmap_kernel_range(vaddr, resource_size(res)); +	vunmap_range(vaddr, vaddr + resource_size(res));  #endif  }  EXPORT_SYMBOL(pci_unmap_iospace); @@ -4454,6 +4475,23 @@ void pci_clear_mwi(struct pci_dev *dev)  EXPORT_SYMBOL(pci_clear_mwi);  /** + * pci_disable_parity - disable parity checking for device + * @dev: the PCI device to operate on + * + * Disable parity checking for device @dev + */ +void pci_disable_parity(struct pci_dev *dev) +{ +	u16 cmd; + +	pci_read_config_word(dev, PCI_COMMAND, &cmd); +	if (cmd & PCI_COMMAND_PARITY) { +		cmd &= ~PCI_COMMAND_PARITY; +		pci_write_config_word(dev, PCI_COMMAND, cmd); +	} +} + +/**   * pci_intx - enables/disables PCI INTx for device dev   * @pdev: the PCI device to operate on   * @enable: boolean: whether to enable or disable PCI INTx | 
