Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
3bdb2591
Commit
3bdb2591
authored
Mar 09, 2014
by
David Woodhouse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iommu/vt-d: Make iommu_should_identity_map() take struct device
Signed-off-by:
David Woodhouse
<
David.Woodhouse@intel.com
>
parent
0b9d9753
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
50 deletions
+57
-50
drivers/iommu/intel-iommu.c
drivers/iommu/intel-iommu.c
+57
-50
No files found.
drivers/iommu/intel-iommu.c
View file @
3bdb2591
...
@@ -2518,58 +2518,65 @@ static bool device_has_rmrr(struct device *dev)
...
@@ -2518,58 +2518,65 @@ static bool device_has_rmrr(struct device *dev)
return
false
;
return
false
;
}
}
static
int
iommu_should_identity_map
(
struct
pci_dev
*
p
dev
,
int
startup
)
static
int
iommu_should_identity_map
(
struct
device
*
dev
,
int
startup
)
{
{
/*
if
(
dev_is_pci
(
dev
))
{
* We want to prevent any device associated with an RMRR from
struct
pci_dev
*
pdev
=
to_pci_dev
(
dev
);
* getting placed into the SI Domain. This is done because
* problems exist when devices are moved in and out of domains
* and their respective RMRR info is lost. We exempt USB devices
* from this process due to their usage of RMRRs that are known
* to not be needed after BIOS hand-off to OS.
*/
if
(
device_has_rmrr
(
&
pdev
->
dev
)
&&
(
pdev
->
class
>>
8
)
!=
PCI_CLASS_SERIAL_USB
)
return
0
;
if
((
iommu_identity_mapping
&
IDENTMAP_AZALIA
)
&&
IS_AZALIA
(
pdev
))
/*
return
1
;
* We want to prevent any device associated with an RMRR from
* getting placed into the SI Domain. This is done because
* problems exist when devices are moved in and out of domains
* and their respective RMRR info is lost. We exempt USB devices
* from this process due to their usage of RMRRs that are known
* to not be needed after BIOS hand-off to OS.
*/
if
(
device_has_rmrr
(
dev
)
&&
(
pdev
->
class
>>
8
)
!=
PCI_CLASS_SERIAL_USB
)
return
0
;
if
((
iommu_identity_mapping
&
IDENTMAP_GFX
)
&&
IS_GFX_DEVICE
(
pdev
))
if
((
iommu_identity_mapping
&
IDENTMAP_AZALIA
)
&&
IS_AZALIA
(
pdev
))
return
1
;
return
1
;
if
(
!
(
iommu_identity_mapping
&
IDENTMAP_ALL
))
if
((
iommu_identity_mapping
&
IDENTMAP_GFX
)
&&
IS_GFX_DEVICE
(
pdev
))
return
0
;
return
1
;
/*
if
(
!
(
iommu_identity_mapping
&
IDENTMAP_ALL
))
* We want to start off with all devices in the 1:1 domain, and
* take them out later if we find they can't access all of memory.
*
* However, we can't do this for PCI devices behind bridges,
* because all PCI devices behind the same bridge will end up
* with the same source-id on their transactions.
*
* Practically speaking, we can't change things around for these
* devices at run-time, because we can't be sure there'll be no
* DMA transactions in flight for any of their siblings.
*
* So PCI devices (unless they're on the root bus) as well as
* their parent PCI-PCI or PCIe-PCI bridges must be left _out_ of
* the 1:1 domain, just in _case_ one of their siblings turns out
* not to be able to map all of memory.
*/
if
(
!
pci_is_pcie
(
pdev
))
{
if
(
!
pci_is_root_bus
(
pdev
->
bus
))
return
0
;
return
0
;
if
(
pdev
->
class
>>
8
==
PCI_CLASS_BRIDGE_PCI
)
/*
* We want to start off with all devices in the 1:1 domain, and
* take them out later if we find they can't access all of memory.
*
* However, we can't do this for PCI devices behind bridges,
* because all PCI devices behind the same bridge will end up
* with the same source-id on their transactions.
*
* Practically speaking, we can't change things around for these
* devices at run-time, because we can't be sure there'll be no
* DMA transactions in flight for any of their siblings.
*
* So PCI devices (unless they're on the root bus) as well as
* their parent PCI-PCI or PCIe-PCI bridges must be left _out_ of
* the 1:1 domain, just in _case_ one of their siblings turns out
* not to be able to map all of memory.
*/
if
(
!
pci_is_pcie
(
pdev
))
{
if
(
!
pci_is_root_bus
(
pdev
->
bus
))
return
0
;
if
(
pdev
->
class
>>
8
==
PCI_CLASS_BRIDGE_PCI
)
return
0
;
}
else
if
(
pci_pcie_type
(
pdev
)
==
PCI_EXP_TYPE_PCI_BRIDGE
)
return
0
;
return
0
;
}
else
if
(
pci_pcie_type
(
pdev
)
==
PCI_EXP_TYPE_PCI_BRIDGE
)
}
else
{
return
0
;
if
(
device_has_rmrr
(
dev
))
return
0
;
}
/*
/*
* At boot time, we don't yet know if devices will be 64-bit capable.
* At boot time, we don't yet know if devices will be 64-bit capable.
* Assume that they will
-- if they turn out not to be, then we can
* Assume that they will
— if they turn out not to be, then we can
* take them out of the 1:1 domain later.
* take them out of the 1:1 domain later.
*/
*/
if
(
!
startup
)
{
if
(
!
startup
)
{
...
@@ -2577,13 +2584,13 @@ static int iommu_should_identity_map(struct pci_dev *pdev, int startup)
...
@@ -2577,13 +2584,13 @@ static int iommu_should_identity_map(struct pci_dev *pdev, int startup)
* If the device's dma_mask is less than the system's memory
* If the device's dma_mask is less than the system's memory
* size then this is not a candidate for identity mapping.
* size then this is not a candidate for identity mapping.
*/
*/
u64
dma_mask
=
p
dev
->
dma_mask
;
u64
dma_mask
=
*
dev
->
dma_mask
;
if
(
pdev
->
dev
.
coherent_dma_mask
&&
if
(
dev
->
coherent_dma_mask
&&
pdev
->
dev
.
coherent_dma_mask
<
dma_mask
)
dev
->
coherent_dma_mask
<
dma_mask
)
dma_mask
=
pdev
->
dev
.
coherent_dma_mask
;
dma_mask
=
dev
->
coherent_dma_mask
;
return
dma_mask
>=
dma_get_required_mask
(
&
pdev
->
dev
);
return
dma_mask
>=
dma_get_required_mask
(
dev
);
}
}
return
1
;
return
1
;
...
@@ -2599,7 +2606,7 @@ static int __init iommu_prepare_static_identity_mapping(int hw)
...
@@ -2599,7 +2606,7 @@ static int __init iommu_prepare_static_identity_mapping(int hw)
return
-
EFAULT
;
return
-
EFAULT
;
for_each_pci_dev
(
pdev
)
{
for_each_pci_dev
(
pdev
)
{
if
(
iommu_should_identity_map
(
p
dev
,
1
))
{
if
(
iommu_should_identity_map
(
&
pdev
->
dev
,
1
))
{
ret
=
domain_add_dev_info
(
si_domain
,
pdev
,
ret
=
domain_add_dev_info
(
si_domain
,
pdev
,
hw
?
CONTEXT_TT_PASS_THROUGH
:
hw
?
CONTEXT_TT_PASS_THROUGH
:
CONTEXT_TT_MULTI_LEVEL
);
CONTEXT_TT_MULTI_LEVEL
);
...
@@ -2917,7 +2924,7 @@ static int iommu_no_mapping(struct device *dev)
...
@@ -2917,7 +2924,7 @@ static int iommu_no_mapping(struct device *dev)
pdev
=
to_pci_dev
(
dev
);
pdev
=
to_pci_dev
(
dev
);
found
=
identity_mapping
(
dev
);
found
=
identity_mapping
(
dev
);
if
(
found
)
{
if
(
found
)
{
if
(
iommu_should_identity_map
(
p
dev
,
0
))
if
(
iommu_should_identity_map
(
&
pdev
->
dev
,
0
))
return
1
;
return
1
;
else
{
else
{
/*
/*
...
@@ -2934,7 +2941,7 @@ static int iommu_no_mapping(struct device *dev)
...
@@ -2934,7 +2941,7 @@ static int iommu_no_mapping(struct device *dev)
* In case of a detached 64 bit DMA device from vm, the device
* In case of a detached 64 bit DMA device from vm, the device
* is put into si_domain for identity mapping.
* is put into si_domain for identity mapping.
*/
*/
if
(
iommu_should_identity_map
(
p
dev
,
0
))
{
if
(
iommu_should_identity_map
(
&
pdev
->
dev
,
0
))
{
int
ret
;
int
ret
;
ret
=
domain_add_dev_info
(
si_domain
,
pdev
,
ret
=
domain_add_dev_info
(
si_domain
,
pdev
,
hw_pass_through
?
hw_pass_through
?
...
...
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