* [PATCH 02/13] move page table handling utility functions
@ 2008-12-02 14:22 Han, Weidong
2008-12-04 17:12 ` Mark McLoughlin
0 siblings, 1 reply; 4+ messages in thread
From: Han, Weidong @ 2008-12-02 14:22 UTC (permalink / raw)
To: 'Avi Kivity', Woodhouse, David, 'Jesse Barnes'
Cc: 'Joerg Roedel', Kay, Allen M, Yu, Fenghua,
'kvm@vger.kernel.org',
'iommu@lists.linux-foundation.org'
[-- Attachment #1: Type: text/plain, Size: 3376 bytes --]
move page table handling utility functions from intel-iommu.c to dma_remapping.h, because some of them will be used in other .c files.
Signed-off-by: Weidong Han <weidong.han@intel.com>
---
drivers/pci/intel-iommu.c | 45 ----------------------------------------
include/linux/dma_remapping.h | 46 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 45 insertions(+), 46 deletions(-)
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 39c5e9d..a18e0b4 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -288,51 +288,6 @@ out:
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 (12 + (level - 1) * LEVEL_STRIDE);
-}
-
-static inline int address_level_offset(u64 addr, int level)
-{
- return ((addr >> level_to_offset_bits(level)) & LEVEL_MASK);
-}
-
-static inline u64 level_mask(int level)
-{
- return ((u64)-1 << level_to_offset_bits(level));
-}
-
-static inline u64 level_size(int level)
-{
- return ((u64)1 << level_to_offset_bits(level));
-}
-
-static inline u64 align_to_level(u64 addr, int level)
-{
- return ((addr + level_size(level) - 1) & level_mask(level));
-}
-
static struct dma_pte * addr_to_dma_pte(struct dmar_domain *domain, u64 addr)
{
int addr_width = agaw_to_width(domain->agaw);
diff --git a/include/linux/dma_remapping.h b/include/linux/dma_remapping.h
index 66f7887..eeb8243 100644
--- a/include/linux/dma_remapping.h
+++ b/include/linux/dma_remapping.h
@@ -13,6 +13,50 @@
#define DMA_32BIT_PFN IOVA_PFN(DMA_32BIT_MASK)
#define DMA_64BIT_PFN IOVA_PFN(DMA_64BIT_MASK)
+/* page table handling */
+#define VTD_LEVEL_STRIDE (9)
+#define VTD_LEVEL_MASK (((u64)1 << VTD_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 * VTD_LEVEL_STRIDE;
+}
+
+static inline int width_to_agaw(int width)
+{
+ return (width - 30) / VTD_LEVEL_STRIDE;
+}
+
+static inline unsigned int level_to_offset_bits(int level)
+{
+ return 12 + (level - 1) * VTD_LEVEL_STRIDE;
+}
+
+static inline int address_level_offset(u64 addr, int level)
+{
+ return (addr >> level_to_offset_bits(level)) & VTD_LEVEL_MASK;
+}
+
+static inline u64 level_mask(int level)
+{
+ return (u64)-1 << level_to_offset_bits(level);
+}
+
+static inline u64 level_size(int level)
+{
+ return (u64)1 << level_to_offset_bits(level);
+}
+
+static inline u64 align_to_level(u64 addr, int level)
+{
+ return (addr + level_size(level) - 1) & level_mask(level);
+}
+
/*
* 0: Present
@@ -27,7 +71,7 @@ struct root_entry {
#define ROOT_ENTRY_NR (VTD_PAGE_SIZE/sizeof(struct root_entry))
static inline bool root_present(struct root_entry *root)
{
- return (root->val & 1);
+ return root->val & 1;
}
static inline void set_root_present(struct root_entry *root)
{
--
1.5.1
[-- Attachment #2: 0002-move-page-table-handling-utility-functions.patch --]
[-- Type: application/octet-stream, Size: 3323 bytes --]
From 1b387b63b9537c5d693d7775edf172b82422e0f2 Mon Sep 17 00:00:00 2001
From: Weidong Han <weidong.han@intel.com>
Date: Tue, 2 Dec 2008 14:02:26 +0800
Subject: [PATCH] move page table handling utility functions
Signed-off-by: Weidong Han <weidong.han@intel.com>
---
drivers/pci/intel-iommu.c | 45 ----------------------------------------
include/linux/dma_remapping.h | 46 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 45 insertions(+), 46 deletions(-)
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 39c5e9d..a18e0b4 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -288,51 +288,6 @@ out:
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 (12 + (level - 1) * LEVEL_STRIDE);
-}
-
-static inline int address_level_offset(u64 addr, int level)
-{
- return ((addr >> level_to_offset_bits(level)) & LEVEL_MASK);
-}
-
-static inline u64 level_mask(int level)
-{
- return ((u64)-1 << level_to_offset_bits(level));
-}
-
-static inline u64 level_size(int level)
-{
- return ((u64)1 << level_to_offset_bits(level));
-}
-
-static inline u64 align_to_level(u64 addr, int level)
-{
- return ((addr + level_size(level) - 1) & level_mask(level));
-}
-
static struct dma_pte * addr_to_dma_pte(struct dmar_domain *domain, u64 addr)
{
int addr_width = agaw_to_width(domain->agaw);
diff --git a/include/linux/dma_remapping.h b/include/linux/dma_remapping.h
index 66f7887..eeb8243 100644
--- a/include/linux/dma_remapping.h
+++ b/include/linux/dma_remapping.h
@@ -13,6 +13,50 @@
#define DMA_32BIT_PFN IOVA_PFN(DMA_32BIT_MASK)
#define DMA_64BIT_PFN IOVA_PFN(DMA_64BIT_MASK)
+/* page table handling */
+#define VTD_LEVEL_STRIDE (9)
+#define VTD_LEVEL_MASK (((u64)1 << VTD_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 * VTD_LEVEL_STRIDE;
+}
+
+static inline int width_to_agaw(int width)
+{
+ return (width - 30) / VTD_LEVEL_STRIDE;
+}
+
+static inline unsigned int level_to_offset_bits(int level)
+{
+ return 12 + (level - 1) * VTD_LEVEL_STRIDE;
+}
+
+static inline int address_level_offset(u64 addr, int level)
+{
+ return (addr >> level_to_offset_bits(level)) & VTD_LEVEL_MASK;
+}
+
+static inline u64 level_mask(int level)
+{
+ return (u64)-1 << level_to_offset_bits(level);
+}
+
+static inline u64 level_size(int level)
+{
+ return (u64)1 << level_to_offset_bits(level);
+}
+
+static inline u64 align_to_level(u64 addr, int level)
+{
+ return (addr + level_size(level) - 1) & level_mask(level);
+}
+
/*
* 0: Present
@@ -27,7 +71,7 @@ struct root_entry {
#define ROOT_ENTRY_NR (VTD_PAGE_SIZE/sizeof(struct root_entry))
static inline bool root_present(struct root_entry *root)
{
- return (root->val & 1);
+ return root->val & 1;
}
static inline void set_root_present(struct root_entry *root)
{
--
1.5.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 02/13] move page table handling utility functions
2008-12-02 14:22 [PATCH 02/13] move page table handling utility functions Han, Weidong
@ 2008-12-04 17:12 ` Mark McLoughlin
2008-12-05 0:32 ` Han, Weidong
0 siblings, 1 reply; 4+ messages in thread
From: Mark McLoughlin @ 2008-12-04 17:12 UTC (permalink / raw)
To: Han, Weidong
Cc: 'Avi Kivity', Woodhouse, David, 'Jesse Barnes',
Yu, Fenghua, 'iommu@lists.linux-foundation.org',
'kvm@vger.kernel.org'
On Tue, 2008-12-02 at 22:22 +0800, Han, Weidong wrote:
> move page table handling utility functions from intel-iommu.c to
> dma_remapping.h, because some of them will be used in other .c files.
You need to rebase your patches against dwmw2's tree where some cleanup
patches of mine moved a bunch of stuff from dma_remapping.h to
intel-iommu.c
And preferably, this stuff could stay internal to intel-iommu.c.
Cheers,
Mark.
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH 02/13] move page table handling utility functions
2008-12-04 17:12 ` Mark McLoughlin
@ 2008-12-05 0:32 ` Han, Weidong
2008-12-05 2:39 ` Yu, Fenghua
0 siblings, 1 reply; 4+ messages in thread
From: Han, Weidong @ 2008-12-05 0:32 UTC (permalink / raw)
To: 'Mark McLoughlin'
Cc: 'Avi Kivity', Woodhouse, David, 'Jesse Barnes',
Yu, Fenghua, 'iommu@lists.linux-foundation.org',
'kvm@vger.kernel.org'
Mark McLoughlin wrote:
> On Tue, 2008-12-02 at 22:22 +0800, Han, Weidong wrote:
>
>> move page table handling utility functions from intel-iommu.c to
>> dma_remapping.h, because some of them will be used in other .c files.
>
> You need to rebase your patches against dwmw2's tree where some
> cleanup patches of mine moved a bunch of stuff from dma_remapping.h to
> intel-iommu.c
>
How to get dwmw2's tree?
Regards,
Weidong
> And preferably, this stuff could stay internal to intel-iommu.c.
>
> Cheers,
> Mark.
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH 02/13] move page table handling utility functions
2008-12-05 0:32 ` Han, Weidong
@ 2008-12-05 2:39 ` Yu, Fenghua
0 siblings, 0 replies; 4+ messages in thread
From: Yu, Fenghua @ 2008-12-05 2:39 UTC (permalink / raw)
To: Han, Weidong, 'Mark McLoughlin'
Cc: 'Avi Kivity', Woodhouse, David, 'Jesse Barnes',
'iommu@lists.linux-foundation.org',
'kvm@vger.kernel.org'
>
>> You need to rebase your patches against dwmw2's tree where some
>> cleanup patches of mine moved a bunch of stuff from dma_remapping.h to
>> intel-iommu.c
>How to get dwmw2's tree?
git://git.infradead.org/iommu-2.6.git
Thanks.
-Fenghua
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-12-05 2:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-02 14:22 [PATCH 02/13] move page table handling utility functions Han, Weidong
2008-12-04 17:12 ` Mark McLoughlin
2008-12-05 0:32 ` Han, Weidong
2008-12-05 2:39 ` Yu, Fenghua
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox