When interrupt remapping is enabled in the system, the MSI interrupt message must follow a special format the IOMMU can understand. Hence, utilize the functionality provided by the IOMMU driver for such purpose.
The first step is to determine whether interrupt remapping is enabled by looking for the existence of an interrupt remapping domain. If it exists, let the IOMMU driver compose the MSI message for us. The hard- lockup detector is still responsible of writing the message in the HPET FSB route register. Cc: Ashok Raj <ashok....@intel.com> Cc: Andi Kleen <andi.kl...@intel.com> Cc: Tony Luck <tony.l...@intel.com> Cc: Borislav Petkov <b...@suse.de> Cc: Jacob Pan <jacob.jun....@intel.com> Cc: Joerg Roedel <j...@8bytes.org> Cc: Juergen Gross <jgr...@suse.com> Cc: Bjorn Helgaas <bhelg...@google.com> Cc: Wincy Van <fanwenyi0...@gmail.com> Cc: Kate Stewart <kstew...@linuxfoundation.org> Cc: Philippe Ombredanne <pombreda...@nexb.com> Cc: "Eric W. Biederman" <ebied...@xmission.com> Cc: Baoquan He <b...@redhat.com> Cc: Dou Liyang <douly.f...@cn.fujitsu.com> Cc: Jan Kiszka <jan.kis...@siemens.com> Cc: Stephane Eranian <eran...@google.com> Cc: Suravee Suthikulpanit <suravee.suthikulpa...@amd.com> Cc: "Ravi V. Shankar" <ravi.v.shan...@intel.com> Cc: x...@kernel.org Cc: iommu@lists.linux-foundation.org Signed-off-by: Ricardo Neri <ricardo.neri-calde...@linux.intel.com> --- arch/x86/kernel/watchdog_hld_hpet.c | 33 ++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/watchdog_hld_hpet.c b/arch/x86/kernel/watchdog_hld_hpet.c index 90680a8cf9fc..2d59b8f0390e 100644 --- a/arch/x86/kernel/watchdog_hld_hpet.c +++ b/arch/x86/kernel/watchdog_hld_hpet.c @@ -19,6 +19,7 @@ #include <linux/nmi.h> #include <linux/hpet.h> #include <asm/msidef.h> +#include <asm/irq_remapping.h> #include <asm/hpet.h> static struct hpet_hld_data *hld_data; @@ -116,6 +117,25 @@ static bool is_hpet_wdt_interrupt(struct hpet_hld_data *hdata) return false; } +/** irq_remapping_enabled() - Detect if interrupt remapping is enabled + * @hdata: A data structure with the HPET block id + * + * Determine if the HPET block that the hardlockup detector is under + * the remapped interrupt domain. + * + * Returns: True interrupt remapping is enabled. False otherwise. + */ +static bool irq_remapping_enabled(struct hpet_hld_data *hdata) +{ + struct irq_alloc_info info; + + init_irq_alloc_info(&info, NULL); + info.type = X86_IRQ_ALLOC_TYPE_HPET; + info.hpet_id = hdata->blockid; + + return !!irq_remapping_get_ir_irq_domain(&info); +} + /** * compose_msi_msg() - Populate address and data fields of an MSI message * @hdata: A data strucure with the message to populate @@ -160,6 +180,9 @@ static int update_msi_destid(struct hpet_hld_data *hdata) { u32 destid; + if (irq_remapping_enabled(hdata)) + return hld_hpet_intremap_activate_irq(hdata); + hdata->msi_msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK; destid = apic->calc_dest_apicid(hdata->handling_cpu); hdata->msi_msg.address_lo |= MSI_ADDR_DEST_ID(destid); @@ -216,9 +239,17 @@ static int hardlockup_detector_nmi_handler(unsigned int type, */ static int setup_irq_msi_mode(struct hpet_hld_data *hdata) { + s32 ret; u32 v; - compose_msi_msg(hdata); + if (irq_remapping_enabled(hdata)) { + ret = hld_hpet_intremap_alloc_irq(hdata); + if (ret) + return ret; + } else { + compose_msi_msg(hdata); + } + hpet_writel(hdata->msi_msg.data, HPET_Tn_ROUTE(hdata->num)); hpet_writel(hdata->msi_msg.address_lo, HPET_Tn_ROUTE(hdata->num) + 4); -- 2.17.1