13 #include <linux/export.h>
15 #include <linux/pci.h>
16 #include <linux/slab.h>
44 static void ats_free_one(
struct pci_dev *dev)
62 BUG_ON(dev->ats && dev->ats->is_enabled);
72 rc = pdev->ats->stu == ps ? 0 : -
EINVAL;
74 rc = ats_alloc_one(pdev, ps);
84 rc = ats_alloc_one(dev, ps);
92 pci_write_config_word(dev, dev->ats->pos +
PCI_ATS_CTRL, ctrl);
94 dev->ats->is_enabled = 1;
108 BUG_ON(!dev->ats || !dev->ats->is_enabled);
110 pci_read_config_word(dev, dev->ats->pos +
PCI_ATS_CTRL, &ctrl);
112 pci_write_config_word(dev, dev->ats->pos +
PCI_ATS_CTRL, ctrl);
114 dev->ats->is_enabled = 0;
120 pdev->ats->ref_cnt--;
121 if (!pdev->ats->ref_cnt)
135 if (!pci_ats_enabled(dev))
144 pci_write_config_word(dev, dev->ats->pos +
PCI_ATS_CTRL, ctrl);
169 return dev->ats->qdep;
175 pci_read_config_word(dev, pos +
PCI_ATS_CAP, &cap);
182 #ifdef CONFIG_PCI_PRI
189 int pci_enable_pri(
struct pci_dev *pdev,
u32 reqs)
199 pci_read_config_word(pdev, pos +
PCI_PRI_CTRL, &control);
206 reqs =
min(max_requests, reqs);
210 pci_write_config_word(pdev, pos +
PCI_PRI_CTRL, control);
222 void pci_disable_pri(
struct pci_dev *pdev)
231 pci_read_config_word(pdev, pos +
PCI_PRI_CTRL, &control);
232 control &= ~PCI_PRI_CTRL_ENABLE;
233 pci_write_config_word(pdev, pos +
PCI_PRI_CTRL, control);
243 bool pci_pri_enabled(
struct pci_dev *pdev)
252 pci_read_config_word(pdev, pos +
PCI_PRI_CTRL, &control);
254 return (control & PCI_PRI_CTRL_ENABLE) ?
true :
false;
265 int pci_reset_pri(
struct pci_dev *pdev)
274 pci_read_config_word(pdev, pos +
PCI_PRI_CTRL, &control);
275 if (control & PCI_PRI_CTRL_ENABLE)
280 pci_write_config_word(pdev, pos +
PCI_PRI_CTRL, control);
298 bool pci_pri_stopped(
struct pci_dev *pdev)
307 pci_read_config_word(pdev, pos +
PCI_PRI_CTRL, &control);
310 if (control & PCI_PRI_CTRL_ENABLE)
327 int pci_pri_status(
struct pci_dev *pdev)
336 pci_read_config_word(pdev, pos +
PCI_PRI_CTRL, &control);
340 if (control & PCI_PRI_CTRL_ENABLE)
348 #ifdef CONFIG_PCI_PASID
376 if ((supported & features) != features)
379 control = PCI_PASID_CTRL_ENABLE |
features;
392 void pci_disable_pasid(
struct pci_dev *pdev)
415 int pci_pasid_features(
struct pci_dev *pdev)
432 #define PASID_NUMBER_SHIFT 8
433 #define PASID_NUMBER_MASK (0x1f << PASID_NUMBER_SHIFT)
441 int pci_max_pasids(
struct pci_dev *pdev)
452 supported = (supported & PASID_NUMBER_MASK) >> PASID_NUMBER_SHIFT;
454 return (1 << supported);