Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 210921
b: refs/heads/master
c: df08cdc
h: refs/heads/master
i:
  210919: 7baf901
v: v3
  • Loading branch information
Andrew Morton authored and Linus Torvalds committed Sep 23, 2010
1 parent b16672f commit c97bb76
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 48 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: e85bfd3aa7a34fa963bb268a676b41694e6dcf96
refs/heads/master: df08cdc7ef606509debe7677c439be0ca48790e4
90 changes: 43 additions & 47 deletions trunk/drivers/pci/intel-iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,49 @@
#define DMA_32BIT_PFN IOVA_PFN(DMA_BIT_MASK(32))
#define DMA_64BIT_PFN IOVA_PFN(DMA_BIT_MASK(64))

/* page table handling */
#define LEVEL_STRIDE (9)
#define LEVEL_MASK (((u64)1 << LEVEL_STRIDE) - 1)

static inline int agaw_to_level(int agaw)
{
return agaw + 2;
}

static inline int agaw_to_width(int agaw)
{
return 30 + agaw * LEVEL_STRIDE;
}

static inline int width_to_agaw(int width)
{
return (width - 30) / LEVEL_STRIDE;
}

static inline unsigned int level_to_offset_bits(int level)
{
return (level - 1) * LEVEL_STRIDE;
}

static inline int pfn_level_offset(unsigned long pfn, int level)
{
return (pfn >> level_to_offset_bits(level)) & LEVEL_MASK;
}

static inline unsigned long level_mask(int level)
{
return -1UL << level_to_offset_bits(level);
}

static inline unsigned long level_size(int level)
{
return 1UL << level_to_offset_bits(level);
}

static inline unsigned long align_to_level(unsigned long pfn, int level)
{
return (pfn + level_size(level) - 1) & level_mask(level);
}

/* VT-d pages must always be _smaller_ than MM pages. Otherwise things
are never going to work. */
Expand Down Expand Up @@ -434,8 +477,6 @@ void free_iova_mem(struct iova *iova)
}


static inline int width_to_agaw(int width);

static int __iommu_calculate_agaw(struct intel_iommu *iommu, int max_gaw)
{
unsigned long sagaw;
Expand Down Expand Up @@ -646,51 +687,6 @@ static void free_context_table(struct intel_iommu *iommu)
spin_unlock_irqrestore(&iommu->lock, flags);
}

/* page table handling */
#define LEVEL_STRIDE (9)
#define LEVEL_MASK (((u64)1 << LEVEL_STRIDE) - 1)

static inline int agaw_to_level(int agaw)
{
return agaw + 2;
}

static inline int agaw_to_width(int agaw)
{
return 30 + agaw * LEVEL_STRIDE;

}

static inline int width_to_agaw(int width)
{
return (width - 30) / LEVEL_STRIDE;
}

static inline unsigned int level_to_offset_bits(int level)
{
return (level - 1) * LEVEL_STRIDE;
}

static inline int pfn_level_offset(unsigned long pfn, int level)
{
return (pfn >> level_to_offset_bits(level)) & LEVEL_MASK;
}

static inline unsigned long level_mask(int level)
{
return -1UL << level_to_offset_bits(level);
}

static inline unsigned long level_size(int level)
{
return 1UL << level_to_offset_bits(level);
}

static inline unsigned long align_to_level(unsigned long pfn, int level)
{
return (pfn + level_size(level) - 1) & level_mask(level);
}

static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain,
unsigned long pfn)
{
Expand Down

0 comments on commit c97bb76

Please sign in to comment.