Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 863c74eb authored by Joerg Roedel's avatar Joerg Roedel
Browse files

AMD IOMMU: add device reference counting for protection domains



Impact: know how many devices are assigned to a domain

Signed-off-by: default avatarJoerg Roedel <joerg.roedel@amd.com>
parent 5b28df6f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -203,6 +203,7 @@ struct protection_domain {
	int mode;		/* paging mode (0-6 levels) */
	u64 *pt_root;		/* page table root pointer */
	unsigned long flags;	/* flags to find out type of domain */
	unsigned dev_cnt;	/* devices assigned to this domain */
	void *priv;		/* private data */
};

+2 −1
Original line number Diff line number Diff line
@@ -825,9 +825,10 @@ static void set_device_domain(struct amd_iommu *iommu,
			      u16 devid)
{
	unsigned long flags;

	u64 pte_root = virt_to_phys(domain->pt_root);

	domain->dev_cnt += 1;

	pte_root |= (domain->mode & DEV_ENTRY_MODE_MASK)
		    << DEV_ENTRY_MODE_SHIFT;
	pte_root |= IOMMU_PTE_IR | IOMMU_PTE_IW | IOMMU_PTE_P | IOMMU_PTE_TV;