The PRG Response PASID Required bit in the PRI Capability is read-only. Read it once when we enumerate the device and cache the value so we don't need to read it again.
Unified · Split
| @@ -161,7 +161,16 @@ EXPORT_SYMBOL_GPL(pci_ats_page_aligned); · 160 unmodified lines | |||
| 161 | #ifdef CONFIG_PCI_PRI | 161 | #ifdef CONFIG_PCI_PRI |
| 162 | void pci_pri_init(struct pci_dev *pdev) | 162 | void pci_pri_init(struct pci_dev *pdev) |
| 163 | { | 163 | { |
| 164 | u16 status; | ||
| 165 | |||
| 164 | pdev->pri_cap = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PRI); | 166 | pdev->pri_cap = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PRI); |
| 167 | |||
| 168 | if (!pdev->pri_cap) | ||
| 169 | return; | ||
| 170 | |||
| 171 | pci_read_config_word(pdev, pdev->pri_cap + PCI_PRI_STATUS, &status); | ||
| 172 | if (status & PCI_PRI_STATUS_PASID) | ||
| 173 | pdev->pasid_required = 1; | ||
| 165 | } | 174 | } |
| 166 | 175 | ||
| 167 | /** | 176 | /** |
| @@ -301,22 +310,10 @@ EXPORT_SYMBOL_GPL(pci_reset_pri); · 133 unmodified lines | |||
| 301 | */ | 310 | */ |
| 302 | int pci_prg_resp_pasid_required(struct pci_dev *pdev) | 311 | int pci_prg_resp_pasid_required(struct pci_dev *pdev) |
| 303 | { | 312 | { |
| 304 | u16 status; | ||
| 305 | int pri; | ||
| 306 | |||
| 307 | if (pdev->is_virtfn) | 313 | if (pdev->is_virtfn) |
| 308 | pdev = pci_physfn(pdev); | 314 | pdev = pci_physfn(pdev); |
| 309 | 315 | ||
| 310 | pri = pdev->pri_cap; | 316 | return pdev->pasid_required; |
| 311 | if (!pri) | ||
| 312 | return 0; | ||
| 313 | |||
| 314 | pci_read_config_word(pdev, pri + PCI_PRI_STATUS, &status); | ||
| 315 | |||
| 316 | if (status & PCI_PRI_STATUS_PASID) | ||
| 317 | return 1; | ||
| 318 | |||
| 319 | return 0; | ||
| 320 | } | 317 | } |
| 321 | EXPORT_SYMBOL_GPL(pci_prg_resp_pasid_required); | 318 | EXPORT_SYMBOL_GPL(pci_prg_resp_pasid_required); |
| 322 | #endif /* CONFIG_PCI_PRI */ | 319 | #endif /* CONFIG_PCI_PRI */ |
| @@ -456,6 +456,7 @@ struct pci_dev { · 455 unmodified lines | |||
| 456 | #ifdef CONFIG_PCI_PRI | 456 | #ifdef CONFIG_PCI_PRI |
| 457 | u16 pri_cap; /* PRI Capability offset */ | 457 | u16 pri_cap; /* PRI Capability offset */ |
| 458 | u32 pri_reqs_alloc; /* Number of PRI requests allocated */ | 458 | u32 pri_reqs_alloc; /* Number of PRI requests allocated */ |
| 459 | unsigned int pasid_required:1; /* PRG Response PASID Required */ | ||
| 459 | #endif | 460 | #endif |
| 460 | #ifdef CONFIG_PCI_PASID | 461 | #ifdef CONFIG_PCI_PASID |
| 461 | u16 pasid_cap; /* PASID Capability offset */ | 462 | u16 pasid_cap; /* PASID Capability offset */ |