x86/AMD-Vi: Fix IVRS HPET special->handle override
PATCH v2 1/1 x86/AMD-Vi: Fix IVRS HPET special->handle override
From: Suravee Suthikulpanit <[email protected]>
The current logic does not handle the case when HPET special->handle is invalid in IVRS. On such system, the following message is shown:
(XEN) AMD-Vi: Failed to setup HPET MSI remapping: Wrong HPET
This patch will allow the ivrs_hpet[<handle>]=<sbdf> to override the IVRS. Also, it removes struct hpet_sbdf.iommu since it is not used anywhere in the code.
---
Changes from V1:
* Remove the struct hpet_sbdf.iommu
xen/drivers/passthrough/amd/iommu_acpi.c | 21 +++++++++++++-------- xen/drivers/passthrough/amd/iommu_intr.c | 5 ++--- xen/include/asm-x86/hvm/svm/amd-iommu-proto.h | 1 - 3 files changed, 15 insertions(+), 12 deletions(-)
xen/drivers/passthrough/amd/iommu_acpi.c +13 -8
@@ -789,20 +789,25 @@ static u16 __init parse_ivhd_device_special( }break ;case ACPI_IVHD_HPET : +if ( hpet_sbdf.cmdline ) + { +AMD_IOMMU_DEBUG ("IVHD: Command line override present for HPET %#x " +"(IVRS: %#x devID %04x:%02x:%02x.%u)\n" , + hpet_sbdf.id, special->handle, seg,PCI_BUS (bdf), +PCI_SLOT (bdf),PCI_FUNC (bdf)); +break ; + } +/* set device id of hpet */ -if ( hpet_sbdf.iommu || - (hpet_sbdf.cmdline && hpet_sbdf.id != special->handle) ) +if ( hpet_sbdf.id !=0 ) {printk (XENLOG_WARNING "Only one IVHD HPET entry is supported\n" );break ; } + hpet_sbdf.id = special->handle; -if ( !hpet_sbdf.cmdline ) - { - hpet_sbdf.bdf = bdf; - hpet_sbdf.seg = seg; - } - hpet_sbdf.iommu = iommu; + hpet_sbdf.bdf = bdf; + hpet_sbdf.seg = seg;break ;default : printk(XENLOG_ERR "Unrecognized IVHD special variety %#x\n",
xen/drivers/passthrough/amd/iommu_intr.c +2 -3
@@ -598,10 +598,9 @@ int __init amd_setup_hpet_msi(struct msi_desc *msi_desc)unsigned long flags;int rc =0 ; -if ( msi_desc->hpet_id != hpet_sbdf.id || !hpet_sbdf.iommu ) +if ( msi_desc->hpet_id != hpet_sbdf.id ) { -AMD_IOMMU_DEBUG ("Failed to setup HPET MSI remapping: %s\n" , - hpet_sbdf.iommu ?"Wrong HPET" :"No IOMMU" ); +AMD_IOMMU_DEBUG ("Failed to setup HPET MSI remapping. Mismatch IVRS info.\n" );return -ENODEV ; }
xen/include/asm-x86/hvm/svm/amd-iommu-proto.h +0 -1
@@ -109,7 +109,6 @@ extern struct ioapic_sbdf {extern struct hpet_sbdf {u16 bdf, seg, id;bool_t cmdline; -struct amd_iommu *iommu; } hpet_sbdf;extern void *shared_intremap_table;
Signature · 1 line
1.8.1.2
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 25.09.13 at 21:15, <[email protected]> wrote:
xen/drivers/passthrough/amd/iommu_acpi.c +3
-0@@ -789,20 +789,25 @@ static u16 __init parse_ivhd_device_special( }break ;case ACPI_IVHD_HPET : +if ( hpet_sbdf.cmdline ) + { + AMD_IOMMU_DEBUG("IVHD: Command line override present for HPET %#x "
xen/drivers/passthrough/amd/iommu_acpi.c static u16 __init parse_ivhd_device_special( · line 802
Quoted 10 lines
xen/drivers/passthrough/amd/iommu_acpi.c +7
-2+"(IVRS: %#x devID %04x:%02x:%02x.%u)\n" , + hpet_sbdf.id, special->handle, seg,PCI_BUS (bdf), + PCI_SLOT(bdf), PCI_FUNC(bdf)); +break ; + } +/* set device id of hpet */ -if ( hpet_sbdf.iommu || - (hpet_sbdf.cmdline && hpet_sbdf.id != special->handle) ) +if ( hpet_sbdf.id !=0 )
Surely there's no guarantee that special->handle in non-zero. After all that's a firmware allocated value. What might be acceptable is assuming bdf to be non-zero, but even that would look sort of hackish. Perhaps you'd be better off converting .cmdline to an enum with states none, cmdline, and ivhd, and use a switch() here.
Quoted 20 lines
xen/drivers/passthrough/amd/iommu_acpi.c +3
-6{printk (XENLOG_WARNING "Only one IVHD HPET entry is supported\n" );break ; } + hpet_sbdf.id = special->handle; -if ( !hpet_sbdf.cmdline ) - { - hpet_sbdf.bdf = bdf; - hpet_sbdf.seg = seg; - } - hpet_sbdf.iommu = iommu; + hpet_sbdf.bdf = bdf; + hpet_sbdf.seg = seg;break ;default : printk(XENLOG_ERR "Unrecognized IVHD special variety %#x\n",
xen/drivers/passthrough/amd/iommu_intr.c int __init amd_setup_hpet_msi(struct msi_desc *msi_desc) · line 603
Quoted 9 lines
xen/drivers/passthrough/amd/iommu_intr.c +2
-3@@ -598,10 +598,9 @@ int __init amd_setup_hpet_msi(struct msi_desc *msi_desc)unsigned long flags;int rc =0 ; -if ( msi_desc->hpet_id != hpet_sbdf.id || !hpet_sbdf.iommu ) +if ( msi_desc->hpet_id != hpet_sbdf.id ) { -AMD_IOMMU_DEBUG ("Failed to setup HPET MSI remapping: %s\n" , - hpet_sbdf.iommu ?"Wrong HPET" :"No IOMMU" ); +AMD_IOMMU_DEBUG ("Failed to setup HPET MSI remapping. Mismatch IVRS info.\n" );
This will need to get adjusted too - instead of !hpet_sbdf.iommu you'd now need to check the new enum to be other than "none".
Jan