Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linux-davinci
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
linux
linux-davinci
Commits
6660c63a
Commit
6660c63a
authored
Jun 27, 2009
by
David Woodhouse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
intel-iommu: Make dma_pte_free_pagetable() use pfns
Signed-off-by:
David Woodhouse
<
David.Woodhouse@intel.com
>
parent
595badf5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
18 deletions
+22
-18
drivers/pci/intel-iommu.c
drivers/pci/intel-iommu.c
+22
-18
No files found.
drivers/pci/intel-iommu.c
View file @
6660c63a
...
@@ -669,27 +669,27 @@ static inline int width_to_agaw(int width)
...
@@ -669,27 +669,27 @@ static inline int width_to_agaw(int width)
static
inline
unsigned
int
level_to_offset_bits
(
int
level
)
static
inline
unsigned
int
level_to_offset_bits
(
int
level
)
{
{
return
(
12
+
(
level
-
1
)
*
LEVEL_STRIDE
)
;
return
(
level
-
1
)
*
LEVEL_STRIDE
;
}
}
static
inline
int
pfn_level_offset
(
unsigned
long
pfn
,
int
level
)
static
inline
int
pfn_level_offset
(
unsigned
long
pfn
,
int
level
)
{
{
return
(
pfn
>>
(
level_to_offset_bits
(
level
)
-
12
))
&
LEVEL_MASK
;
return
(
pfn
>>
level_to_offset_bits
(
level
))
&
LEVEL_MASK
;
}
}
static
inline
u
64
level_mask
(
int
level
)
static
inline
u
nsigned
long
level_mask
(
int
level
)
{
{
return
((
u64
)
-
1
<<
level_to_offset_bits
(
level
)
);
return
-
1UL
<<
level_to_offset_bits
(
level
);
}
}
static
inline
u
64
level_size
(
int
level
)
static
inline
u
nsigned
long
level_size
(
int
level
)
{
{
return
((
u64
)
1
<<
level_to_offset_bits
(
level
)
);
return
1UL
<<
level_to_offset_bits
(
level
);
}
}
static
inline
u
64
align_to_level
(
u64
addr
,
int
level
)
static
inline
u
nsigned
long
align_to_level
(
unsigned
long
pfn
,
int
level
)
{
{
return
(
(
addr
+
level_size
(
level
)
-
1
)
&
level_mask
(
level
)
);
return
(
pfn
+
level_size
(
level
)
-
1
)
&
level_mask
(
level
);
}
}
static
struct
dma_pte
*
addr_to_dma_pte
(
struct
dmar_domain
*
domain
,
u64
addr
)
static
struct
dma_pte
*
addr_to_dma_pte
(
struct
dmar_domain
*
domain
,
u64
addr
)
...
@@ -798,25 +798,29 @@ static void dma_pte_clear_range(struct dmar_domain *domain,
...
@@ -798,25 +798,29 @@ static void dma_pte_clear_range(struct dmar_domain *domain,
static
void
dma_pte_free_pagetable
(
struct
dmar_domain
*
domain
,
static
void
dma_pte_free_pagetable
(
struct
dmar_domain
*
domain
,
u64
start
,
u64
end
)
u64
start
,
u64
end
)
{
{
int
addr_width
=
agaw_to_width
(
domain
->
agaw
);
int
addr_width
=
agaw_to_width
(
domain
->
agaw
)
-
VTD_PAGE_SHIFT
;
unsigned
long
start_pfn
=
start
>>
VTD_PAGE_SHIFT
;
unsigned
long
last_pfn
=
(
end
-
1
)
>>
VTD_PAGE_SHIFT
;
struct
dma_pte
*
pte
;
struct
dma_pte
*
pte
;
int
total
=
agaw_to_level
(
domain
->
agaw
);
int
total
=
agaw_to_level
(
domain
->
agaw
);
int
level
;
int
level
;
u
64
tmp
;
u
nsigned
long
tmp
;
BUG_ON
(
start
>>
addr_width
);
BUG_ON
(
addr_width
<
BITS_PER_LONG
&&
start_pfn
>>
addr_width
);
BUG_ON
(
end
>>
addr_width
);
BUG_ON
(
addr_width
<
BITS_PER_LONG
&&
last_pfn
>>
addr_width
);
/* we don't need lock here, nobody else touches the iova range */
/* we don't need lock here, nobody else touches the iova range */
level
=
2
;
level
=
2
;
while
(
level
<=
total
)
{
while
(
level
<=
total
)
{
tmp
=
align_to_level
(
start
,
level
);
tmp
=
align_to_level
(
start_pfn
,
level
);
if
(
tmp
>=
end
||
(
tmp
+
level_size
(
level
)
>
end
))
/* Only clear this pte/pmd if we're asked to clear its
_whole_ range */
if
(
tmp
+
level_size
(
level
)
-
1
>
last_pfn
)
return
;
return
;
while
(
tmp
<
end
)
{
while
(
tmp
<=
last_pfn
)
{
pte
=
dma_pfn_level_pte
(
domain
,
tmp
>>
VTD_PAGE_SHIFT
,
pte
=
dma_pfn_level_pte
(
domain
,
tmp
,
level
);
level
);
if
(
pte
)
{
if
(
pte
)
{
free_pgtable_page
(
free_pgtable_page
(
phys_to_virt
(
dma_pte_addr
(
pte
)));
phys_to_virt
(
dma_pte_addr
(
pte
)));
...
@@ -828,7 +832,7 @@ static void dma_pte_free_pagetable(struct dmar_domain *domain,
...
@@ -828,7 +832,7 @@ static void dma_pte_free_pagetable(struct dmar_domain *domain,
level
++
;
level
++
;
}
}
/* free pgd */
/* free pgd */
if
(
start
==
0
&&
end
>=
((((
u64
)
1
)
<<
addr_width
)
-
1
))
{
if
(
start
==
0
&&
last_pfn
==
DOMAIN_MAX_PFN
(
domain
->
gaw
))
{
free_pgtable_page
(
domain
->
pgd
);
free_pgtable_page
(
domain
->
pgd
);
domain
->
pgd
=
NULL
;
domain
->
pgd
=
NULL
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment