···736736 CMD_SET_TYPE(cmd, CMD_INV_IOTLB_PAGES);737737}738738739739+static void build_complete_ppr(struct iommu_cmd *cmd, u16 devid, int pasid,740740+ int status, int tag, bool gn)741741+{742742+ memset(cmd, 0, sizeof(*cmd));743743+744744+ cmd->data[0] = devid;745745+ if (gn) {746746+ cmd->data[1] = pasid & PASID_MASK;747747+ cmd->data[2] = CMD_INV_IOMMU_PAGES_GN_MASK;748748+ }749749+ cmd->data[3] = tag & 0x1ff;750750+ cmd->data[3] |= (status & PPR_STATUS_MASK) << PPR_STATUS_SHIFT;751751+752752+ CMD_SET_TYPE(cmd, CMD_COMPLETE_PPR);753753+}754754+739755static void build_inv_all(struct iommu_cmd *cmd)740756{741757 memset(cmd, 0, sizeof(*cmd));···19661950 return ret;19671951}1968195219531953+/* FIXME: Move this to PCI code */19541954+#define PCI_PRI_TLP_OFF (1 << 2)19551955+19561956+bool pci_pri_tlp_required(struct pci_dev *pdev)19571957+{19581958+ u16 control;19591959+ int pos;19601960+19611961+ pos = pci_find_ext_capability(pdev, PCI_PRI_CAP);19621962+ if (!pos)19631963+ return false;19641964+19651965+ pci_read_config_word(pdev, pos + PCI_PRI_CONTROL_OFF, &control);19661966+19671967+ return (control & PCI_PRI_TLP_OFF) ? true : false;19681968+}19691969+19691970/*19701971 * If a device is not yet associated with a domain, this function does19711972 * assigns it visible for the hardware···2006197320071974 dev_data->ats.enabled = true;20081975 dev_data->ats.qdep = pci_ats_queue_depth(pdev);19761976+ dev_data->pri_tlp = pci_pri_tlp_required(pdev);20091977 } else if (amd_iommu_iotlb_sup &&20101978 pci_enable_ats(pdev, PAGE_SHIFT) == 0) {20111979 dev_data->ats.enabled = true;···34463412 return ret;34473413}34483414EXPORT_SYMBOL(amd_iommu_domain_clear_gcr3);34153415+34163416+int amd_iommu_complete_ppr(struct pci_dev *pdev, int pasid,34173417+ int status, int tag)34183418+{34193419+ struct iommu_dev_data *dev_data;34203420+ struct amd_iommu *iommu;34213421+ struct iommu_cmd cmd;34223422+34233423+ dev_data = get_dev_data(&pdev->dev);34243424+ iommu = amd_iommu_rlookup_table[dev_data->devid];34253425+34263426+ build_complete_ppr(&cmd, dev_data->devid, pasid, status,34273427+ tag, dev_data->pri_tlp);34283428+34293429+ return iommu_queue_command(iommu, &cmd);34303430+}34313431+EXPORT_SYMBOL(amd_iommu_complete_ppr);
+6
drivers/iommu/amd_iommu_proto.h
···4747 unsigned long cr3);4848extern int amd_iommu_domain_clear_gcr3(struct iommu_domain *dom, int pasid);49495050+#define PPR_SUCCESS 0x05151+#define PPR_INVALID 0x15252+#define PPR_FAILURE 0xf5353+5454+extern int amd_iommu_complete_ppr(struct pci_dev *pdev, int pasid,5555+ int status, int tag);50565157#ifndef CONFIG_AMD_IOMMU_STATS5258