PCI: Add pcie_flags_reg to cache PCIe capabilities register
Since PCI Express Capabilities Register is read only, cache its value into struct pci_dev to avoid repeatedly calling pci_read_config_*(). Signed-off-by: Yijing Wang <wangyijing@huawei.com> Signed-off-by: Jiang Liu <jiang.liu@huawei.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
@@ -258,6 +258,7 @@ struct pci_dev {
|
||||
u8 pcie_mpss:3; /* PCI-E Max Payload Size Supported */
|
||||
u8 rom_base_reg; /* which config register controls the ROM */
|
||||
u8 pin; /* which interrupt pin this device uses */
|
||||
u16 pcie_flags_reg; /* cached PCI-E Capabilities Register */
|
||||
|
||||
struct pci_driver *driver; /* which driver has allocated this device */
|
||||
u64 dma_mask; /* Mask of the bits of bus address this
|
||||
@@ -1650,6 +1651,15 @@ static inline bool pci_is_pcie(struct pci_dev *dev)
|
||||
return !!pci_pcie_cap(dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* pci_pcie_type - get the PCIe device/port type
|
||||
* @dev: PCI device
|
||||
*/
|
||||
static inline int pci_pcie_type(const struct pci_dev *dev)
|
||||
{
|
||||
return (dev->pcie_flags_reg & PCI_EXP_FLAGS_TYPE) >> 4;
|
||||
}
|
||||
|
||||
void pci_request_acs(void);
|
||||
bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags);
|
||||
bool pci_acs_path_enabled(struct pci_dev *start,
|
||||
|
||||
Reference in New Issue
Block a user