Skip to content

Commit 405e2f1

Browse files
ssuthiku-amdjoergroedel
authored andcommitted
iommu/amd: Add support for page response
This generates AMD IOMMU COMPLETE_PPR_REQUEST for the specified device with the specified PRI Response Code. Also update amd_iommu_complete_ppr() to accept 'struct device' instead of pdev as it just need device reference. Signed-off-by: Suravee Suthikulpanit <[email protected]> Signed-off-by: Wei Huang <[email protected]> Co-developed-by: Vasant Hegde <[email protected]> Signed-off-by: Vasant Hegde <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 61928ba commit 405e2f1

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

drivers/iommu/amd/amd_iommu.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ bool amd_iommu_pasid_supported(void);
4949
/* IOPF */
5050
int amd_iommu_iopf_init(struct amd_iommu *iommu);
5151
void amd_iommu_iopf_uninit(struct amd_iommu *iommu);
52+
void amd_iommu_page_response(struct device *dev, struct iopf_fault *evt,
53+
struct iommu_page_response *resp);
5254

5355
/* GCR3 setup */
5456
int amd_iommu_set_gcr3(struct iommu_dev_data *dev_data,
@@ -60,8 +62,7 @@ int __init amd_iommu_alloc_ppr_log(struct amd_iommu *iommu);
6062
void __init amd_iommu_free_ppr_log(struct amd_iommu *iommu);
6163
void amd_iommu_enable_ppr_log(struct amd_iommu *iommu);
6264
void amd_iommu_poll_ppr_log(struct amd_iommu *iommu);
63-
int amd_iommu_complete_ppr(struct pci_dev *pdev, u32 pasid,
64-
int status, int tag);
65+
int amd_iommu_complete_ppr(struct device *dev, u32 pasid, int status, int tag);
6566

6667
/*
6768
* This function flushes all internal caches of

drivers/iommu/amd/iommu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,15 +1628,14 @@ void amd_iommu_domain_update(struct protection_domain *domain)
16281628
amd_iommu_domain_flush_all(domain);
16291629
}
16301630

1631-
int amd_iommu_complete_ppr(struct pci_dev *pdev, u32 pasid,
1632-
int status, int tag)
1631+
int amd_iommu_complete_ppr(struct device *dev, u32 pasid, int status, int tag)
16331632
{
16341633
struct iommu_dev_data *dev_data;
16351634
struct amd_iommu *iommu;
16361635
struct iommu_cmd cmd;
16371636

1638-
dev_data = dev_iommu_priv_get(&pdev->dev);
1639-
iommu = get_amd_iommu_from_dev(&pdev->dev);
1637+
dev_data = dev_iommu_priv_get(dev);
1638+
iommu = get_amd_iommu_from_dev(dev);
16401639

16411640
build_complete_ppr(&cmd, dev_data->devid, pasid, status,
16421641
tag, dev_data->pri_tlp);
@@ -2852,6 +2851,7 @@ const struct iommu_ops amd_iommu_ops = {
28522851
.def_domain_type = amd_iommu_def_domain_type,
28532852
.dev_enable_feat = amd_iommu_dev_enable_feature,
28542853
.dev_disable_feat = amd_iommu_dev_disable_feature,
2854+
.page_response = amd_iommu_page_response,
28552855
.default_domain_ops = &(const struct iommu_domain_ops) {
28562856
.attach_dev = amd_iommu_attach_device,
28572857
.map_pages = amd_iommu_map_pages,

drivers/iommu/amd/ppr.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,9 @@ void amd_iommu_iopf_uninit(struct amd_iommu *iommu)
139139
iopf_queue_free(iommu->iopf_queue);
140140
iommu->iopf_queue = NULL;
141141
}
142+
143+
void amd_iommu_page_response(struct device *dev, struct iopf_fault *evt,
144+
struct iommu_page_response *resp)
145+
{
146+
amd_iommu_complete_ppr(dev, resp->pasid, resp->code, resp->grpid);
147+
}

0 commit comments

Comments
 (0)