Message ID | 1455852618-5224-3-git-send-email-peterx@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 02/19/2016 05:30 AM, Peter Xu wrote: > In ACPI DMA remapping report structure, enable INTR flag when specified. > > Signed-off-by: Peter Xu <peterx@redhat.com> > --- > hw/i386/acpi-build.c | 31 ++++++++++++++++++++++++------- > include/hw/i386/intel_iommu.h | 2 ++ > 2 files changed, 26 insertions(+), 7 deletions(-) > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c > index 4554eb8..d9e4f91 100644 > --- a/hw/i386/acpi-build.c > +++ b/hw/i386/acpi-build.c > @@ -2489,6 +2489,19 @@ build_mcfg_q35(GArray *table_data, GArray *linker, AcpiMcfgInfo *info) > build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL); > } > > +static IntelIOMMUState *acpi_get_iommu(void) > +{ > + bool ambiguous = false; > + Object *intel_iommu = NULL; > + > + intel_iommu = object_resolve_path_type("", TYPE_INTEL_IOMMU_DEVICE, > + &ambiguous); > + if (ambiguous) > + intel_iommu = NULL; > + > + return (IntelIOMMUState *)intel_iommu; > +} > + > static void > build_dmar_q35(GArray *table_data, GArray *linker) > { > @@ -2496,10 +2509,19 @@ build_dmar_q35(GArray *table_data, GArray *linker) > > AcpiTableDmar *dmar; > AcpiDmarHardwareUnit *drhd; > + uint8_t dmar_flags = 0; > + IntelIOMMUState *intel_iommu = acpi_get_iommu(); > + > + assert(intel_iommu); > + > + if (intel_iommu->intr_supported) { Hi, It seems intr_supported duplicates the same field you have in machine. You can pass the machine to build_dmar_q35 and get rid of the extra field. Thanks, Marcel > + /* enable INTR for the IOMMU device */ > + dmar_flags |= DMAR_REPORT_F_INTR; > + } > > dmar = acpi_data_push(table_data, sizeof(*dmar)); > dmar->host_address_width = VTD_HOST_ADDRESS_WIDTH - 1; > - dmar->flags = 0; /* No intr_remap for now */ > + dmar->flags = dmar_flags; > > /* DMAR Remapping Hardware Unit Definition structure */ > drhd = acpi_data_push(table_data, sizeof(*drhd)); > @@ -2572,12 +2594,7 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg) > > static bool acpi_has_iommu(void) > { > - bool ambiguous; > - Object *intel_iommu; > - > - intel_iommu = object_resolve_path_type("", TYPE_INTEL_IOMMU_DEVICE, > - &ambiguous); > - return intel_iommu && !ambiguous; > + return !!acpi_get_iommu(); > } > > static bool acpi_has_nvdimm(void) > diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h > index 6e52c6b..83e5a1e 100644 > --- a/include/hw/i386/intel_iommu.h > +++ b/include/hw/i386/intel_iommu.h > @@ -44,6 +44,8 @@ > #define VTD_HOST_ADDRESS_WIDTH 39 > #define VTD_HAW_MASK ((1ULL << VTD_HOST_ADDRESS_WIDTH) - 1) > > +#define DMAR_REPORT_F_INTR (1) > + > typedef struct VTDContextEntry VTDContextEntry; > typedef struct VTDContextCacheEntry VTDContextCacheEntry; > typedef struct IntelIOMMUState IntelIOMMUState; >
On Sun, Feb 21, 2016 at 01:05:24PM +0200, Marcel Apfelbaum wrote: [...] > > static void > > build_dmar_q35(GArray *table_data, GArray *linker) > > { > >@@ -2496,10 +2509,19 @@ build_dmar_q35(GArray *table_data, GArray *linker) > > > > AcpiTableDmar *dmar; > > AcpiDmarHardwareUnit *drhd; > >+ uint8_t dmar_flags = 0; > >+ IntelIOMMUState *intel_iommu = acpi_get_iommu(); > >+ > >+ assert(intel_iommu); > >+ > >+ if (intel_iommu->intr_supported) { > > Hi, > > It seems intr_supported duplicates the same field you have in machine. > You can pass the machine to build_dmar_q35 and get rid of the extra field. You are right. Will drop intr_supported in all the patches. Thanks. -- peterx
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 4554eb8..d9e4f91 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2489,6 +2489,19 @@ build_mcfg_q35(GArray *table_data, GArray *linker, AcpiMcfgInfo *info) build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL); } +static IntelIOMMUState *acpi_get_iommu(void) +{ + bool ambiguous = false; + Object *intel_iommu = NULL; + + intel_iommu = object_resolve_path_type("", TYPE_INTEL_IOMMU_DEVICE, + &ambiguous); + if (ambiguous) + intel_iommu = NULL; + + return (IntelIOMMUState *)intel_iommu; +} + static void build_dmar_q35(GArray *table_data, GArray *linker) { @@ -2496,10 +2509,19 @@ build_dmar_q35(GArray *table_data, GArray *linker) AcpiTableDmar *dmar; AcpiDmarHardwareUnit *drhd; + uint8_t dmar_flags = 0; + IntelIOMMUState *intel_iommu = acpi_get_iommu(); + + assert(intel_iommu); + + if (intel_iommu->intr_supported) { + /* enable INTR for the IOMMU device */ + dmar_flags |= DMAR_REPORT_F_INTR; + } dmar = acpi_data_push(table_data, sizeof(*dmar)); dmar->host_address_width = VTD_HOST_ADDRESS_WIDTH - 1; - dmar->flags = 0; /* No intr_remap for now */ + dmar->flags = dmar_flags; /* DMAR Remapping Hardware Unit Definition structure */ drhd = acpi_data_push(table_data, sizeof(*drhd)); @@ -2572,12 +2594,7 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg) static bool acpi_has_iommu(void) { - bool ambiguous; - Object *intel_iommu; - - intel_iommu = object_resolve_path_type("", TYPE_INTEL_IOMMU_DEVICE, - &ambiguous); - return intel_iommu && !ambiguous; + return !!acpi_get_iommu(); } static bool acpi_has_nvdimm(void) diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index 6e52c6b..83e5a1e 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -44,6 +44,8 @@ #define VTD_HOST_ADDRESS_WIDTH 39 #define VTD_HAW_MASK ((1ULL << VTD_HOST_ADDRESS_WIDTH) - 1) +#define DMAR_REPORT_F_INTR (1) + typedef struct VTDContextEntry VTDContextEntry; typedef struct VTDContextCacheEntry VTDContextCacheEntry; typedef struct IntelIOMMUState IntelIOMMUState;
In ACPI DMA remapping report structure, enable INTR flag when specified. Signed-off-by: Peter Xu <peterx@redhat.com> --- hw/i386/acpi-build.c | 31 ++++++++++++++++++++++++------- include/hw/i386/intel_iommu.h | 2 ++ 2 files changed, 26 insertions(+), 7 deletions(-)