Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 245387
b: refs/heads/master
c: 7d0c5cc
h: refs/heads/master
i:
  245385: 6d00949
  245383: 9f5dfd3
v: v3
  • Loading branch information
Joerg Roedel committed Apr 7, 2011
1 parent ca55c97 commit 36d9caa
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 46 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d8c13085775c72e2d46edc54ed0c803c3a944ddb
refs/heads/master: 7d0c5cc5be73f7ce26fdcca7b8ec2203f661eb93
2 changes: 0 additions & 2 deletions trunk/arch/x86/include/asm/amd_iommu_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ struct amd_iommu;
extern int amd_iommu_init_dma_ops(void);
extern int amd_iommu_init_passthrough(void);
extern irqreturn_t amd_iommu_int_handler(int irq, void *data);
extern void amd_iommu_flush_all_domains(void);
extern void amd_iommu_flush_all_devices(void);
extern void amd_iommu_apply_erratum_63(u16 devid);
extern void amd_iommu_reset_cmd_buffer(struct amd_iommu *iommu);
extern int amd_iommu_init_devices(void);
Expand Down
75 changes: 34 additions & 41 deletions trunk/arch/x86/kernel/amd_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,40 @@ static int iommu_flush_dte(struct amd_iommu *iommu, u16 devid)
return iommu_queue_command(iommu, &cmd);
}

static void iommu_flush_dte_all(struct amd_iommu *iommu)
{
u32 devid;

for (devid = 0; devid <= 0xffff; ++devid)
iommu_flush_dte(iommu, devid);

iommu_completion_wait(iommu);
}

/*
* This function uses heavy locking and may disable irqs for some time. But
* this is no issue because it is only called during resume.
*/
static void iommu_flush_tlb_all(struct amd_iommu *iommu)
{
u32 dom_id;

for (dom_id = 0; dom_id <= 0xffff; ++dom_id) {
struct iommu_cmd cmd;
build_inv_iommu_pages(&cmd, 0, CMD_INV_IOMMU_ALL_PAGES_ADDRESS,
dom_id, 1);
iommu_queue_command(iommu, &cmd);
}

iommu_completion_wait(iommu);
}

void iommu_flush_all_caches(struct amd_iommu *iommu)
{
iommu_flush_dte_all(iommu);
iommu_flush_tlb_all(iommu);
}

/*
* Command send function for invalidating a device table entry
*/
Expand Down Expand Up @@ -631,47 +665,6 @@ static void domain_flush_devices(struct protection_domain *domain)
spin_unlock_irqrestore(&domain->lock, flags);
}

static void iommu_flush_all_domain_devices(void)
{
struct protection_domain *domain;
unsigned long flags;

spin_lock_irqsave(&amd_iommu_pd_lock, flags);

list_for_each_entry(domain, &amd_iommu_pd_list, list) {
domain_flush_devices(domain);
domain_flush_complete(domain);
}

spin_unlock_irqrestore(&amd_iommu_pd_lock, flags);
}

void amd_iommu_flush_all_devices(void)
{
iommu_flush_all_domain_devices();
}

/*
* This function uses heavy locking and may disable irqs for some time. But
* this is no issue because it is only called during resume.
*/
void amd_iommu_flush_all_domains(void)
{
struct protection_domain *domain;
unsigned long flags;

spin_lock_irqsave(&amd_iommu_pd_lock, flags);

list_for_each_entry(domain, &amd_iommu_pd_list, list) {
spin_lock(&domain->lock);
domain_flush_tlb_pde(domain);
domain_flush_complete(domain);
spin_unlock(&domain->lock);
}

spin_unlock_irqrestore(&amd_iommu_pd_lock, flags);
}

/****************************************************************************
*
* The functions below are used the create the page table mappings for
Expand Down
11 changes: 9 additions & 2 deletions trunk/arch/x86/kernel/amd_iommu_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ static u32 dev_table_size; /* size of the device table */
static u32 alias_table_size; /* size of the alias table */
static u32 rlookup_table_size; /* size if the rlookup table */

/*
* This function flushes all internal caches of
* the IOMMU used by this driver.
*/
extern void iommu_flush_all_caches(struct amd_iommu *iommu);

static inline void update_last_devid(u16 devid)
{
if (devid > amd_iommu_last_bdf)
Expand Down Expand Up @@ -1244,6 +1250,7 @@ static void enable_iommus(void)
iommu_set_exclusion_range(iommu);
iommu_init_msi(iommu);
iommu_enable(iommu);
iommu_flush_all_caches(iommu);
}
}

Expand Down Expand Up @@ -1274,8 +1281,8 @@ static void amd_iommu_resume(void)
* we have to flush after the IOMMUs are enabled because a
* disabled IOMMU will never execute the commands we send
*/
amd_iommu_flush_all_devices();
amd_iommu_flush_all_domains();
for_each_iommu(iommu)
iommu_flush_all_caches(iommu);
}

static int amd_iommu_suspend(void)
Expand Down

0 comments on commit 36d9caa

Please sign in to comment.