Skip to content

Commit 474bf01

Browse files
hegdevasantjoergroedel
authored andcommitted
iommu/amd: Add support for device based TLB invalidation
Add support to invalidate TLB/IOTLB for the given device. These functions will be used in subsequent patches where we will introduce per device GCR3 table and SVA support. 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 7b4e562 commit 474bf01

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

drivers/iommu/amd/amd_iommu.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ void amd_iommu_domain_update(struct protection_domain *domain);
5555
void amd_iommu_domain_flush_complete(struct protection_domain *domain);
5656
void amd_iommu_domain_flush_pages(struct protection_domain *domain,
5757
u64 address, size_t size);
58+
void amd_iommu_dev_flush_pasid_pages(struct iommu_dev_data *dev_data,
59+
ioasid_t pasid, u64 address, size_t size);
60+
void amd_iommu_dev_flush_pasid_all(struct iommu_dev_data *dev_data,
61+
ioasid_t pasid);
62+
5863
int amd_iommu_flush_tlb(struct iommu_domain *dom, u32 pasid);
5964
int amd_iommu_domain_set_gcr3(struct iommu_domain *dom, u32 pasid,
6065
unsigned long cr3);

drivers/iommu/amd/iommu.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,29 @@ static void amd_iommu_domain_flush_all(struct protection_domain *domain)
15381538
CMD_INV_IOMMU_ALL_PAGES_ADDRESS);
15391539
}
15401540

1541+
void amd_iommu_dev_flush_pasid_pages(struct iommu_dev_data *dev_data,
1542+
ioasid_t pasid, u64 address, size_t size)
1543+
{
1544+
struct iommu_cmd cmd;
1545+
struct amd_iommu *iommu = get_amd_iommu_from_dev(dev_data->dev);
1546+
1547+
build_inv_iommu_pages(&cmd, address, size,
1548+
dev_data->domain->id, pasid, true);
1549+
iommu_queue_command(iommu, &cmd);
1550+
1551+
if (dev_data->ats_enabled)
1552+
device_flush_iotlb(dev_data, address, size, pasid, true);
1553+
1554+
iommu_completion_wait(iommu);
1555+
}
1556+
1557+
void amd_iommu_dev_flush_pasid_all(struct iommu_dev_data *dev_data,
1558+
ioasid_t pasid)
1559+
{
1560+
amd_iommu_dev_flush_pasid_pages(dev_data, 0,
1561+
CMD_INV_IOMMU_ALL_PAGES_ADDRESS, pasid);
1562+
}
1563+
15411564
void amd_iommu_domain_flush_complete(struct protection_domain *domain)
15421565
{
15431566
int i;

0 commit comments

Comments
 (0)