* [PATCH] AMD IOMMU: fix find_iommu_from_bdf_cap()
@ 2012-10-02 14:33 Jan Beulich
2012-10-09 8:14 ` Wei Wang
0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2012-10-02 14:33 UTC (permalink / raw)
To: xen-devel; +Cc: Wei Wang
[-- Attachment #1: Type: text/plain, Size: 1898 bytes --]
The arguments passed for the "cap_offset" parameter get read from 16-
bit fields, so the parameter should also have (at least) 16 bits.
While fixing this I also noticed that this was yet another case where
PCI segment information wasn't properly propagated, so a respective
first parameter gets added to the function at once.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/drivers/passthrough/amd/iommu_acpi.c
+++ b/xen/drivers/passthrough/amd/iommu_acpi.c
@@ -86,12 +86,13 @@ static void __init add_ivrs_mapping_entr
}
static struct amd_iommu * __init find_iommu_from_bdf_cap(
- u16 bdf, u8 cap_offset)
+ u16 seg, u16 bdf, u16 cap_offset)
{
struct amd_iommu *iommu;
for_each_amd_iommu ( iommu )
- if ( (iommu->bdf == bdf) && (iommu->cap_offset == cap_offset) )
+ if ( (iommu->seg == seg) && (iommu->bdf == bdf) &&
+ (iommu->cap_offset == cap_offset) )
return iommu;
return NULL;
@@ -319,10 +320,11 @@ static int __init parse_ivmd_device_iomm
const struct acpi_ivrs_memory *ivmd_block,
unsigned long base, unsigned long limit, u8 iw, u8 ir)
{
+ int seg = 0; /* XXX */
struct amd_iommu *iommu;
/* find target IOMMU */
- iommu = find_iommu_from_bdf_cap(ivmd_block->header.device_id,
+ iommu = find_iommu_from_bdf_cap(seg, ivmd_block->header.device_id,
ivmd_block->aux_data);
if ( !iommu )
{
@@ -669,7 +671,8 @@ static int __init parse_ivhd_block(const
return -ENODEV;
}
- iommu = find_iommu_from_bdf_cap(ivhd_block->header.device_id,
+ iommu = find_iommu_from_bdf_cap(ivhd_block->pci_segment_group,
+ ivhd_block->header.device_id,
ivhd_block->capability_offset);
if ( !iommu )
{
[-- Attachment #2: AMD-IOMMU-cap-width.patch --]
[-- Type: text/plain, Size: 1936 bytes --]
AMD IOMMU: fix find_iommu_from_bdf_cap()
The arguments passed for the "cap_offset" parameter get read from 16-
bit fields, so the parameter should also have (at least) 16 bits.
While fixing this I also noticed that this was yet another case where
PCI segment information wasn't properly propagated, so a respective
first parameter gets added to the function at once.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/drivers/passthrough/amd/iommu_acpi.c
+++ b/xen/drivers/passthrough/amd/iommu_acpi.c
@@ -86,12 +86,13 @@ static void __init add_ivrs_mapping_entr
}
static struct amd_iommu * __init find_iommu_from_bdf_cap(
- u16 bdf, u8 cap_offset)
+ u16 seg, u16 bdf, u16 cap_offset)
{
struct amd_iommu *iommu;
for_each_amd_iommu ( iommu )
- if ( (iommu->bdf == bdf) && (iommu->cap_offset == cap_offset) )
+ if ( (iommu->seg == seg) && (iommu->bdf == bdf) &&
+ (iommu->cap_offset == cap_offset) )
return iommu;
return NULL;
@@ -319,10 +320,11 @@ static int __init parse_ivmd_device_iomm
const struct acpi_ivrs_memory *ivmd_block,
unsigned long base, unsigned long limit, u8 iw, u8 ir)
{
+ int seg = 0; /* XXX */
struct amd_iommu *iommu;
/* find target IOMMU */
- iommu = find_iommu_from_bdf_cap(ivmd_block->header.device_id,
+ iommu = find_iommu_from_bdf_cap(seg, ivmd_block->header.device_id,
ivmd_block->aux_data);
if ( !iommu )
{
@@ -669,7 +671,8 @@ static int __init parse_ivhd_block(const
return -ENODEV;
}
- iommu = find_iommu_from_bdf_cap(ivhd_block->header.device_id,
+ iommu = find_iommu_from_bdf_cap(ivhd_block->pci_segment_group,
+ ivhd_block->header.device_id,
ivhd_block->capability_offset);
if ( !iommu )
{
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] AMD IOMMU: fix find_iommu_from_bdf_cap()
2012-10-02 14:33 [PATCH] AMD IOMMU: fix find_iommu_from_bdf_cap() Jan Beulich
@ 2012-10-09 8:14 ` Wei Wang
0 siblings, 0 replies; 2+ messages in thread
From: Wei Wang @ 2012-10-09 8:14 UTC (permalink / raw)
To: Jan Beulich; +Cc: xen-devel
Acked. Thanks.
Wei
On 10/02/2012 04:33 PM, Jan Beulich wrote:
> The arguments passed for the "cap_offset" parameter get read from 16-
> bit fields, so the parameter should also have (at least) 16 bits.
>
> While fixing this I also noticed that this was yet another case where
> PCI segment information wasn't properly propagated, so a respective
> first parameter gets added to the function at once.
>
> Signed-off-by: Jan Beulich<jbeulich@suse.com>
>
> --- a/xen/drivers/passthrough/amd/iommu_acpi.c
> +++ b/xen/drivers/passthrough/amd/iommu_acpi.c
> @@ -86,12 +86,13 @@ static void __init add_ivrs_mapping_entr
> }
>
> static struct amd_iommu * __init find_iommu_from_bdf_cap(
> - u16 bdf, u8 cap_offset)
> + u16 seg, u16 bdf, u16 cap_offset)
> {
> struct amd_iommu *iommu;
>
> for_each_amd_iommu ( iommu )
> - if ( (iommu->bdf == bdf)&& (iommu->cap_offset == cap_offset) )
> + if ( (iommu->seg == seg)&& (iommu->bdf == bdf)&&
> + (iommu->cap_offset == cap_offset) )
> return iommu;
>
> return NULL;
> @@ -319,10 +320,11 @@ static int __init parse_ivmd_device_iomm
> const struct acpi_ivrs_memory *ivmd_block,
> unsigned long base, unsigned long limit, u8 iw, u8 ir)
> {
> + int seg = 0; /* XXX */
> struct amd_iommu *iommu;
>
> /* find target IOMMU */
> - iommu = find_iommu_from_bdf_cap(ivmd_block->header.device_id,
> + iommu = find_iommu_from_bdf_cap(seg, ivmd_block->header.device_id,
> ivmd_block->aux_data);
> if ( !iommu )
> {
> @@ -669,7 +671,8 @@ static int __init parse_ivhd_block(const
> return -ENODEV;
> }
>
> - iommu = find_iommu_from_bdf_cap(ivhd_block->header.device_id,
> + iommu = find_iommu_from_bdf_cap(ivhd_block->pci_segment_group,
> + ivhd_block->header.device_id,
> ivhd_block->capability_offset);
> if ( !iommu )
> {
>
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-10-09 8:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-02 14:33 [PATCH] AMD IOMMU: fix find_iommu_from_bdf_cap() Jan Beulich
2012-10-09 8:14 ` Wei Wang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.