Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 316592
b: refs/heads/master
c: f9a4f06
h: refs/heads/master
v: v3
  • Loading branch information
Joerg Roedel committed Jul 17, 2012
1 parent 10b6cf8 commit 94765f7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 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: 9e971a03af736acc6f96c200c2626d3bcb3d6927
refs/heads/master: f9a4f063a88297e361fd6676986cf3e39b22de72
29 changes: 16 additions & 13 deletions trunk/drivers/iommu/tegra-smmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,25 +553,26 @@ static inline void put_signature(struct smmu_as *as,
#endif

/*
* Caller must lock/unlock as
* Caller must not hold as->lock
*/
static int alloc_pdir(struct smmu_as *as, unsigned long *flags)
static int alloc_pdir(struct smmu_as *as)
{
unsigned long *pdir;
unsigned long *pdir, flags;
int pdn, err = 0;
u32 val;
struct smmu_device *smmu = as->smmu;
struct page *page;
unsigned int *cnt;

/*
* do the allocation outside the as->lock
* do the allocation, then grab as->lock
*/
spin_unlock_irqrestore(&as->lock, *flags);
cnt = devm_kzalloc(smmu->dev,
sizeof(cnt[0]) * SMMU_PDIR_COUNT, GFP_KERNEL);
sizeof(cnt[0]) * SMMU_PDIR_COUNT,
GFP_KERNEL);
page = alloc_page(GFP_KERNEL | __GFP_DMA);
spin_lock_irqsave(&as->lock, *flags);

spin_lock_irqsave(&as->lock, flags);

if (as->pdir_page) {
/* We raced, free the redundant */
Expand Down Expand Up @@ -603,9 +604,13 @@ static int alloc_pdir(struct smmu_as *as, unsigned long *flags)
smmu_write(smmu, val, SMMU_TLB_FLUSH);
FLUSH_SMMU_REGS(as->smmu);

spin_unlock_irqrestore(&as->lock, flags);

return 0;

err_out:
spin_unlock_irqrestore(&as->lock, flags);

devm_kfree(smmu->dev, cnt);
if (page)
__free_page(page);
Expand Down Expand Up @@ -809,13 +814,11 @@ static int smmu_iommu_domain_init(struct iommu_domain *domain)
/* Look for a free AS with lock held */
for (i = 0; i < smmu->num_as; i++) {
as = &smmu->as[i];
spin_lock_irqsave(&as->lock, flags);
if (!as->pdir_page) {
err = alloc_pdir(as, &flags);
err = alloc_pdir(as);
if (!err)
goto found;
}
spin_unlock_irqrestore(&as->lock, flags);
if (err != -EAGAIN)
break;
}
Expand All @@ -824,20 +827,20 @@ static int smmu_iommu_domain_init(struct iommu_domain *domain)
return err;

found:
spin_lock(&smmu->lock);
spin_lock_irqsave(&smmu->lock, flags);

/* Update PDIR register */
smmu_write(smmu, SMMU_PTB_ASID_CUR(as->asid), SMMU_PTB_ASID);
smmu_write(smmu,
SMMU_MK_PDIR(as->pdir_page, as->pdir_attr), SMMU_PTB_DATA);
FLUSH_SMMU_REGS(smmu);

spin_unlock(&smmu->lock);
spin_unlock_irqrestore(&smmu->lock, flags);

spin_unlock_irqrestore(&as->lock, flags);
domain->priv = as;

dev_dbg(smmu->dev, "smmu_as@%p\n", as);

return 0;
}

Expand Down

0 comments on commit 94765f7

Please sign in to comment.