Skip to content

Commit

Permalink
x86/amd-iommu: Remove amd_iommu_pd_table
Browse files Browse the repository at this point in the history
The data that was stored in this table is now available in
dev->archdata.iommu. So this table is not longer necessary.
This patch removes the remaining uses of that variable and
removes it from the code.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
  • Loading branch information
Joerg Roedel committed Nov 27, 2009
1 parent 8eed983 commit 492667d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 45 deletions.
3 changes: 0 additions & 3 deletions arch/x86/include/asm/amd_iommu_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,6 @@ extern unsigned amd_iommu_aperture_order;
/* largest PCI device id we expect translation requests for */
extern u16 amd_iommu_last_bdf;

/* data structures for protection domain handling */
extern struct protection_domain **amd_iommu_pd_table;

/* allocation bitmap for domain ids */
extern unsigned long *amd_iommu_pd_alloc_bitmap;

Expand Down
35 changes: 11 additions & 24 deletions arch/x86/kernel/amd_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1309,29 +1309,17 @@ static void set_dte_entry(u16 devid, struct protection_domain *domain)
{
u64 pte_root = virt_to_phys(domain->pt_root);

BUG_ON(amd_iommu_pd_table[devid] != NULL);

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;

amd_iommu_dev_table[devid].data[2] = domain->id;
amd_iommu_dev_table[devid].data[1] = upper_32_bits(pte_root);
amd_iommu_dev_table[devid].data[0] = lower_32_bits(pte_root);

amd_iommu_pd_table[devid] = domain;

}

static void clear_dte_entry(u16 devid)
{
struct protection_domain *domain = amd_iommu_pd_table[devid];

BUG_ON(domain == NULL);

/* remove domain from the lookup table */
amd_iommu_pd_table[devid] = NULL;

/* remove entry from the device table seen by the hardware */
amd_iommu_dev_table[devid].data[0] = IOMMU_PTE_P | IOMMU_PTE_TV;
amd_iommu_dev_table[devid].data[1] = 0;
Expand Down Expand Up @@ -1641,15 +1629,11 @@ static struct protection_domain *get_domain(struct device *dev)

static void update_device_table(struct protection_domain *domain)
{
unsigned long flags;
int i;
struct iommu_dev_data *dev_data;

for (i = 0; i <= amd_iommu_last_bdf; ++i) {
if (amd_iommu_pd_table[i] != domain)
continue;
write_lock_irqsave(&amd_iommu_devtable_lock, flags);
set_dte_entry(i, domain);
write_unlock_irqrestore(&amd_iommu_devtable_lock, flags);
list_for_each_entry(dev_data, &domain->dev_list, list) {
u16 devid = get_device_id(dev_data->dev);
set_dte_entry(devid, domain);
}
}

Expand Down Expand Up @@ -2259,14 +2243,17 @@ int __init amd_iommu_init_dma_ops(void)

static void cleanup_domain(struct protection_domain *domain)
{
struct iommu_dev_data *dev_data, *next;
unsigned long flags;
u16 devid;

write_lock_irqsave(&amd_iommu_devtable_lock, flags);

for (devid = 0; devid <= amd_iommu_last_bdf; ++devid)
if (amd_iommu_pd_table[devid] == domain)
clear_dte_entry(devid);
list_for_each_entry_safe(dev_data, next, &domain->dev_list, list) {
struct device *dev = dev_data->dev;

do_detach(dev);
atomic_set(&dev_data->bind, 0);
}

write_unlock_irqrestore(&amd_iommu_devtable_lock, flags);
}
Expand Down
18 changes: 0 additions & 18 deletions arch/x86/kernel/amd_iommu_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,6 @@ u16 *amd_iommu_alias_table;
*/
struct amd_iommu **amd_iommu_rlookup_table;

/*
* The pd table (protection domain table) is used to find the protection domain
* data structure a device belongs to. Indexed with the PCI device id too.
*/
struct protection_domain **amd_iommu_pd_table;

/*
* AMD IOMMU allows up to 2^16 differend protection domains. This is a bitmap
* to know which ones are already in use.
Expand Down Expand Up @@ -1238,15 +1232,6 @@ static int __init amd_iommu_init(void)
if (amd_iommu_rlookup_table == NULL)
goto free;

/*
* Protection Domain table - maps devices to protection domains
* This table has the same size as the rlookup_table
*/
amd_iommu_pd_table = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
get_order(rlookup_table_size));
if (amd_iommu_pd_table == NULL)
goto free;

amd_iommu_pd_alloc_bitmap = (void *)__get_free_pages(
GFP_KERNEL | __GFP_ZERO,
get_order(MAX_DOMAIN_ID/8));
Expand Down Expand Up @@ -1314,9 +1299,6 @@ static int __init amd_iommu_init(void)
free_pages((unsigned long)amd_iommu_pd_alloc_bitmap,
get_order(MAX_DOMAIN_ID/8));

free_pages((unsigned long)amd_iommu_pd_table,
get_order(rlookup_table_size));

free_pages((unsigned long)amd_iommu_rlookup_table,
get_order(rlookup_table_size));

Expand Down

0 comments on commit 492667d

Please sign in to comment.