Lines Matching refs:dev

163 …dev_warn(&bus->dev, "%d-byte config write to %04x:%02x:%02x.%d offset %#x may corrupt adjacent RW1…  in pci_generic_config_write32()
208 static noinline void pci_wait_cfg(struct pci_dev *dev) in pci_wait_cfg() argument
213 wait_event(pci_cfg_wait, !dev->block_cfg_access); in pci_wait_cfg()
215 } while (dev->block_cfg_access); in pci_wait_cfg()
221 (struct pci_dev *dev, int pos, type *val) \
228 if (unlikely(dev->block_cfg_access)) \
229 pci_wait_cfg(dev); \
230 ret = dev->bus->ops->read(dev->bus, dev->devfn, \
244 (struct pci_dev *dev, int pos, type val) \
250 if (unlikely(dev->block_cfg_access)) \
251 pci_wait_cfg(dev); \
252 ret = dev->bus->ops->write(dev->bus, dev->devfn, \
274 void pci_cfg_access_lock(struct pci_dev *dev) in PCI_USER_READ_CONFIG()
279 if (dev->block_cfg_access) in PCI_USER_READ_CONFIG()
280 pci_wait_cfg(dev); in PCI_USER_READ_CONFIG()
281 dev->block_cfg_access = 1; in PCI_USER_READ_CONFIG()
294 bool pci_cfg_access_trylock(struct pci_dev *dev) in pci_cfg_access_trylock() argument
300 if (dev->block_cfg_access) in pci_cfg_access_trylock()
303 dev->block_cfg_access = 1; in pci_cfg_access_trylock()
316 void pci_cfg_access_unlock(struct pci_dev *dev) in pci_cfg_access_unlock() argument
326 WARN_ON(!dev->block_cfg_access); in pci_cfg_access_unlock()
328 dev->block_cfg_access = 0; in pci_cfg_access_unlock()
335 static inline int pcie_cap_version(const struct pci_dev *dev) in pcie_cap_version() argument
337 return pcie_caps_reg(dev) & PCI_EXP_FLAGS_VERS; in pcie_cap_version()
340 bool pcie_cap_has_lnkctl(const struct pci_dev *dev) in pcie_cap_has_lnkctl() argument
342 int type = pci_pcie_type(dev); in pcie_cap_has_lnkctl()
353 bool pcie_cap_has_lnkctl2(const struct pci_dev *dev) in pcie_cap_has_lnkctl2() argument
355 return pcie_cap_has_lnkctl(dev) && pcie_cap_version(dev) > 1; in pcie_cap_has_lnkctl2()
358 static inline bool pcie_cap_has_sltctl(const struct pci_dev *dev) in pcie_cap_has_sltctl() argument
360 return pcie_downstream_port(dev) && in pcie_cap_has_sltctl()
361 pcie_caps_reg(dev) & PCI_EXP_FLAGS_SLOT; in pcie_cap_has_sltctl()
364 bool pcie_cap_has_rtctl(const struct pci_dev *dev) in pcie_cap_has_rtctl() argument
366 int type = pci_pcie_type(dev); in pcie_cap_has_rtctl()
372 static bool pcie_capability_reg_implemented(struct pci_dev *dev, int pos) in pcie_capability_reg_implemented() argument
374 if (!pci_is_pcie(dev)) in pcie_capability_reg_implemented()
387 return pcie_cap_has_lnkctl(dev); in pcie_capability_reg_implemented()
391 return pcie_cap_has_sltctl(dev); in pcie_capability_reg_implemented()
395 return pcie_cap_has_rtctl(dev); in pcie_capability_reg_implemented()
398 return pcie_cap_version(dev) > 1; in pcie_capability_reg_implemented()
402 return pcie_cap_has_lnkctl2(dev); in pcie_capability_reg_implemented()
413 int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val) in pcie_capability_read_word() argument
421 if (pcie_capability_reg_implemented(dev, pos)) { in pcie_capability_read_word()
422 ret = pci_read_config_word(dev, pci_pcie_cap(dev) + pos, val); in pcie_capability_read_word()
440 if (pci_is_pcie(dev) && pcie_downstream_port(dev) && in pcie_capability_read_word()
448 int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val) in pcie_capability_read_dword() argument
456 if (pcie_capability_reg_implemented(dev, pos)) { in pcie_capability_read_dword()
457 ret = pci_read_config_dword(dev, pci_pcie_cap(dev) + pos, val); in pcie_capability_read_dword()
468 if (pci_is_pcie(dev) && pcie_downstream_port(dev) && in pcie_capability_read_dword()
476 int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val) in pcie_capability_write_word() argument
481 if (!pcie_capability_reg_implemented(dev, pos)) in pcie_capability_write_word()
484 return pci_write_config_word(dev, pci_pcie_cap(dev) + pos, val); in pcie_capability_write_word()
488 int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val) in pcie_capability_write_dword() argument
493 if (!pcie_capability_reg_implemented(dev, pos)) in pcie_capability_write_dword()
496 return pci_write_config_dword(dev, pci_pcie_cap(dev) + pos, val); in pcie_capability_write_dword()
500 int pcie_capability_clear_and_set_word_unlocked(struct pci_dev *dev, int pos, in pcie_capability_clear_and_set_word_unlocked() argument
506 ret = pcie_capability_read_word(dev, pos, &val); in pcie_capability_clear_and_set_word_unlocked()
512 return pcie_capability_write_word(dev, pos, val); in pcie_capability_clear_and_set_word_unlocked()
516 int pcie_capability_clear_and_set_word_locked(struct pci_dev *dev, int pos, in pcie_capability_clear_and_set_word_locked() argument
522 spin_lock_irqsave(&dev->pcie_cap_lock, flags); in pcie_capability_clear_and_set_word_locked()
523 ret = pcie_capability_clear_and_set_word_unlocked(dev, pos, clear, set); in pcie_capability_clear_and_set_word_locked()
524 spin_unlock_irqrestore(&dev->pcie_cap_lock, flags); in pcie_capability_clear_and_set_word_locked()
530 int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos, in pcie_capability_clear_and_set_dword() argument
536 ret = pcie_capability_read_dword(dev, pos, &val); in pcie_capability_clear_and_set_dword()
542 return pcie_capability_write_dword(dev, pos, val); in pcie_capability_clear_and_set_dword()
546 int pci_read_config_byte(const struct pci_dev *dev, int where, u8 *val) in pci_read_config_byte() argument
548 if (pci_dev_is_disconnected(dev)) { in pci_read_config_byte()
552 return pci_bus_read_config_byte(dev->bus, dev->devfn, where, val); in pci_read_config_byte()
556 int pci_read_config_word(const struct pci_dev *dev, int where, u16 *val) in pci_read_config_word() argument
558 if (pci_dev_is_disconnected(dev)) { in pci_read_config_word()
562 return pci_bus_read_config_word(dev->bus, dev->devfn, where, val); in pci_read_config_word()
566 int pci_read_config_dword(const struct pci_dev *dev, int where, in pci_read_config_dword() argument
569 if (pci_dev_is_disconnected(dev)) { in pci_read_config_dword()
573 return pci_bus_read_config_dword(dev->bus, dev->devfn, where, val); in pci_read_config_dword()
577 int pci_write_config_byte(const struct pci_dev *dev, int where, u8 val) in pci_write_config_byte() argument
579 if (pci_dev_is_disconnected(dev)) in pci_write_config_byte()
581 return pci_bus_write_config_byte(dev->bus, dev->devfn, where, val); in pci_write_config_byte()
585 int pci_write_config_word(const struct pci_dev *dev, int where, u16 val) in pci_write_config_word() argument
587 if (pci_dev_is_disconnected(dev)) in pci_write_config_word()
589 return pci_bus_write_config_word(dev->bus, dev->devfn, where, val); in pci_write_config_word()
593 int pci_write_config_dword(const struct pci_dev *dev, int where, in pci_write_config_dword() argument
596 if (pci_dev_is_disconnected(dev)) in pci_write_config_dword()
598 return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val); in pci_write_config_dword()