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
146922ec
Commit
146922ec
authored
Mar 09, 2014
by
David Woodhouse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iommu/vt-d: Make get_domain_for_dev() take struct device
Signed-off-by:
David Woodhouse
<
David.Woodhouse@intel.com
>
parent
e1f167f3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
39 deletions
+36
-39
drivers/iommu/intel-iommu.c
drivers/iommu/intel-iommu.c
+36
-39
No files found.
drivers/iommu/intel-iommu.c
View file @
146922ec
...
...
@@ -2207,31 +2207,32 @@ static struct dmar_domain *dmar_insert_dev_info(struct intel_iommu *iommu,
}
/* domain is initialized */
static
struct
dmar_domain
*
get_domain_for_dev
(
struct
pci_dev
*
p
dev
,
int
gaw
)
static
struct
dmar_domain
*
get_domain_for_dev
(
struct
device
*
dev
,
int
gaw
)
{
struct
dmar_domain
*
domain
,
*
free
=
NULL
;
struct
intel_iommu
*
iommu
=
NULL
;
struct
device_domain_info
*
info
;
struct
dmar_drhd_unit
*
drhd
;
struct
pci_dev
*
dev_tmp
;
struct
pci_dev
*
dev_tmp
=
NULL
;
unsigned
long
flags
;
int
bus
=
0
,
devfn
=
0
;
int
segment
;
u8
bus
,
devfn
,
bridge_bus
,
bridge_devfn
;
domain
=
find_domain
(
&
pdev
->
dev
);
domain
=
find_domain
(
dev
);
if
(
domain
)
return
domain
;
segment
=
pci_domain_nr
(
pdev
->
bus
);
if
(
dev_is_pci
(
dev
))
{
struct
pci_dev
*
pdev
=
to_pci_dev
(
dev
);
u16
segment
;
segment
=
pci_domain_nr
(
pdev
->
bus
);
dev_tmp
=
pci_find_upstream_pcie_bridge
(
pdev
);
if
(
dev_tmp
)
{
if
(
pci_is_pcie
(
dev_tmp
))
{
bus
=
dev_tmp
->
subordinate
->
number
;
devfn
=
0
;
bridge_
bus
=
dev_tmp
->
subordinate
->
number
;
bridge_
devfn
=
0
;
}
else
{
bus
=
dev_tmp
->
bus
->
number
;
devfn
=
dev_tmp
->
devfn
;
bridge_
bus
=
dev_tmp
->
bus
->
number
;
bridge_
devfn
=
dev_tmp
->
devfn
;
}
spin_lock_irqsave
(
&
device_domain_lock
,
flags
);
info
=
dmar_search_domain_by_dev_info
(
segment
,
bus
,
devfn
);
...
...
@@ -2240,19 +2241,17 @@ static struct dmar_domain *get_domain_for_dev(struct pci_dev *pdev, int gaw)
domain
=
info
->
domain
;
}
spin_unlock_irqrestore
(
&
device_domain_lock
,
flags
);
/* pcie-pci bridge already has a domain, uses it */
if
(
info
)
goto
found_domain
;
}
drhd
=
dmar_find_matched_drhd_unit
(
pdev
);
if
(
!
drhd
)
{
printk
(
KERN_ERR
"IOMMU: can't find DMAR for device %s
\n
"
,
pci_name
(
pdev
));
return
NULL
;
}
iommu
=
drhd
->
iommu
;
/* Allocate and intialize new domain for the device */
iommu
=
device_to_iommu
(
dev
,
&
bus
,
&
devfn
);
if
(
!
iommu
)
goto
error
;
/* Allocate and initialize new domain for the device */
domain
=
alloc_domain
(
false
);
if
(
!
domain
)
goto
error
;
...
...
@@ -2266,15 +2265,14 @@ static struct dmar_domain *get_domain_for_dev(struct pci_dev *pdev, int gaw)
/* register pcie-to-pci device */
if
(
dev_tmp
)
{
domain
=
dmar_insert_dev_info
(
iommu
,
b
us
,
devfn
,
NULL
,
domain
);
domain
=
dmar_insert_dev_info
(
iommu
,
b
ridge_bus
,
bridge_devfn
,
NULL
,
domain
);
if
(
!
domain
)
goto
error
;
}
found_domain:
domain
=
dmar_insert_dev_info
(
iommu
,
pdev
->
bus
->
number
,
pdev
->
devfn
,
&
pdev
->
dev
,
domain
);
domain
=
dmar_insert_dev_info
(
iommu
,
bus
,
devfn
,
dev
,
domain
);
error:
if
(
free
!=
domain
)
domain_exit
(
free
);
...
...
@@ -2320,7 +2318,7 @@ static int iommu_prepare_identity_map(struct pci_dev *pdev,
struct
dmar_domain
*
domain
;
int
ret
;
domain
=
get_domain_for_dev
(
p
dev
,
DEFAULT_DOMAIN_ADDRESS_WIDTH
);
domain
=
get_domain_for_dev
(
&
pdev
->
dev
,
DEFAULT_DOMAIN_ADDRESS_WIDTH
);
if
(
!
domain
)
return
-
ENOMEM
;
...
...
@@ -2864,8 +2862,7 @@ static struct dmar_domain *__get_valid_domain_for_dev(struct pci_dev *pdev)
struct
dmar_domain
*
domain
;
int
ret
;
domain
=
get_domain_for_dev
(
pdev
,
DEFAULT_DOMAIN_ADDRESS_WIDTH
);
domain
=
get_domain_for_dev
(
&
pdev
->
dev
,
DEFAULT_DOMAIN_ADDRESS_WIDTH
);
if
(
!
domain
)
{
printk
(
KERN_ERR
"Allocating domain for %s failed"
,
pci_name
(
pdev
));
...
...
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