summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>2019-02-19 14:04:51 -0500
committerJoerg Roedel <jroedel@suse.de>2019-02-26 05:07:05 -0500
commite5567f5f67621877726f99be040af9fbedda37dc (patch)
treeadedf638da604e2a1340da262ee7d6faa4107983
parent3f0c625c6ae714cf4dbab534b4c399f1d720e5db (diff)
PCI/ATS: Add pci_prg_resp_pasid_required() interface.
Return the PRG Response PASID Required bit in the Page Request Status Register. As per PCIe spec r4.0, sec 10.5.2.3, if this bit is Set, the device expects a PASID TLP Prefix on PRG Response Messages when the corresponding Page Requests had a PASID TLP Prefix. If Clear, the device does not expect PASID TLP Prefixes on any PRG Response Message, and the device behavior is undefined if the device receives a PRG Response Message with a PASID TLP Prefix. Also the device behavior is undefined if this bit is Set and the device receives a PRG Response Message with no PASID TLP Prefix when the corresponding Page Requests had a PASID TLP Prefix. This function will be used by drivers like IOMMU, if it is required to check the status of the PRG Response PASID Required bit before enabling the PASID support of the device. Cc: Ashok Raj <ashok.raj@intel.com> Cc: Jacob Pan <jacob.jun.pan@linux.intel.com> Cc: Keith Busch <keith.busch@intel.com> Suggested-by: Ashok Raj <ashok.raj@intel.com> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
-rw-r--r--drivers/pci/ats.c30
-rw-r--r--include/linux/pci-ats.h5
-rw-r--r--include/uapi/linux/pci_regs.h1
3 files changed, 36 insertions, 0 deletions
diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c
index 5b78f3b1b918..420cd0a578d0 100644
--- a/drivers/pci/ats.c
+++ b/drivers/pci/ats.c
@@ -368,6 +368,36 @@ int pci_pasid_features(struct pci_dev *pdev)
368} 368}
369EXPORT_SYMBOL_GPL(pci_pasid_features); 369EXPORT_SYMBOL_GPL(pci_pasid_features);
370 370
371/**
372 * pci_prg_resp_pasid_required - Return PRG Response PASID Required bit
373 * status.
374 * @pdev: PCI device structure
375 *
376 * Returns 1 if PASID is required in PRG Response Message, 0 otherwise.
377 *
378 * Even though the PRG response PASID status is read from PRI Status
379 * Register, since this API will mainly be used by PASID users, this
380 * function is defined within #ifdef CONFIG_PCI_PASID instead of
381 * CONFIG_PCI_PRI.
382 */
383int pci_prg_resp_pasid_required(struct pci_dev *pdev)
384{
385 u16 status;
386 int pos;
387
388 pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PRI);
389 if (!pos)
390 return 0;
391
392 pci_read_config_word(pdev, pos + PCI_PRI_STATUS, &status);
393
394 if (status & PCI_PRI_STATUS_PASID)
395 return 1;
396
397 return 0;
398}
399EXPORT_SYMBOL_GPL(pci_prg_resp_pasid_required);
400
371#define PASID_NUMBER_SHIFT 8 401#define PASID_NUMBER_SHIFT 8
372#define PASID_NUMBER_MASK (0x1f << PASID_NUMBER_SHIFT) 402#define PASID_NUMBER_MASK (0x1f << PASID_NUMBER_SHIFT)
373/** 403/**
diff --git a/include/linux/pci-ats.h b/include/linux/pci-ats.h
index 7c4b8e27268c..facfd6a18fe1 100644
--- a/include/linux/pci-ats.h
+++ b/include/linux/pci-ats.h
@@ -40,6 +40,7 @@ void pci_disable_pasid(struct pci_dev *pdev);
40void pci_restore_pasid_state(struct pci_dev *pdev); 40void pci_restore_pasid_state(struct pci_dev *pdev);
41int pci_pasid_features(struct pci_dev *pdev); 41int pci_pasid_features(struct pci_dev *pdev);
42int pci_max_pasids(struct pci_dev *pdev); 42int pci_max_pasids(struct pci_dev *pdev);
43int pci_prg_resp_pasid_required(struct pci_dev *pdev);
43 44
44#else /* CONFIG_PCI_PASID */ 45#else /* CONFIG_PCI_PASID */
45 46
@@ -66,6 +67,10 @@ static inline int pci_max_pasids(struct pci_dev *pdev)
66 return -EINVAL; 67 return -EINVAL;
67} 68}
68 69
70static int pci_prg_resp_pasid_required(struct pci_dev *pdev)
71{
72 return 0;
73}
69#endif /* CONFIG_PCI_PASID */ 74#endif /* CONFIG_PCI_PASID */
70 75
71 76
diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h
index e1e9888c85e6..898be572b010 100644
--- a/include/uapi/linux/pci_regs.h
+++ b/include/uapi/linux/pci_regs.h
@@ -880,6 +880,7 @@
880#define PCI_PRI_STATUS_RF 0x001 /* Response Failure */ 880#define PCI_PRI_STATUS_RF 0x001 /* Response Failure */
881#define PCI_PRI_STATUS_UPRGI 0x002 /* Unexpected PRG index */ 881#define PCI_PRI_STATUS_UPRGI 0x002 /* Unexpected PRG index */
882#define PCI_PRI_STATUS_STOPPED 0x100 /* PRI Stopped */ 882#define PCI_PRI_STATUS_STOPPED 0x100 /* PRI Stopped */
883#define PCI_PRI_STATUS_PASID 0x8000 /* PRG Response PASID Required */
883#define PCI_PRI_MAX_REQ 0x08 /* PRI max reqs supported */ 884#define PCI_PRI_MAX_REQ 0x08 /* PRI max reqs supported */
884#define PCI_PRI_ALLOC_REQ 0x0c /* PRI max reqs allowed */ 885#define PCI_PRI_ALLOC_REQ 0x0c /* PRI max reqs allowed */
885#define PCI_EXT_CAP_PRI_SIZEOF 16 886#define PCI_EXT_CAP_PRI_SIZEOF 16