[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210504191049.22661-3-ricardo.neri-calderon@linux.intel.com>
Date: Tue, 4 May 2021 12:10:44 -0700
From: Ricardo Neri <ricardo.neri-calderon@...ux.intel.com>
To: Joerg Roedel <joro@...tes.org>, Will Deacon <will@...nel.org>
Cc: woodhouse@...r.kernel.org, Jacob Pan <jacob.jun.pan@...el.com>,
Lu Baolu <baolu.lu@...ux.intel.com>,
Stephane Eranian <eranian@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...nel.org>, Borislav Petkov <bp@...e.de>,
iommu@...ts.linux-foundation.org, x86@...nel.org,
linux-kernel@...r.kernel.org,
"Ravi V. Shankar" <ravi.v.shankar@...el.com>,
Ricardo Neri <ricardo.neri@...el.com>,
Ricardo Neri <ricardo.neri-calderon@...ux.intel.com>,
Andi Kleen <andi.kleen@...el.com>,
David Woodhouse <dwmw2@...radead.org>
Subject: [RFC PATCH v5 2/7] x86/hpet: Introduce function to identify HPET hardlockup detector irq
The HPET hardlockup detector needs to deliver its interrupt as NMI.
In x86 there is not an IRQF_NMI flag that can be used in the irq plumbing
code to tell interrupt remapping drivers to set the interrupt delivery
mode accordingly. Hence, they must fixup the delivery mode internally.
Implement a method to determine if the interrupt being allocated belongs
to the HPET hardlockup detector.
Cc: Andi Kleen <andi.kleen@...el.com>
Cc: Borislav Petkov <bp@...e.de>
Cc: David Woodhouse <dwmw2@...radead.org> (supporter:INTEL IOMMU (VT-d))
Cc: "Ravi V. Shankar" <ravi.v.shankar@...el.com>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Jacob Pan <jacob.jun.pan@...el.com>
Cc: Lu Baolu <baolu.lu@...ux.intel.com> (supporter:INTEL IOMMU (VT-d))
Cc: Stephane Eranian <eranian@...gle.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: iommu@...ts.linux-foundation.org (open list:INTEL IOMMU (VT-d))
Cc: x86@...nel.org
Reviewed-by: Ashok Raj <ashok.raj@...el.com>
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@...ux.intel.com>
---
Changes since v4:
* Introduced this patch. Previous versions had special functions to
allocate and set the affinity of a remapped NMI interrupt.
Changes since v3:
* N/A
Changes since v2:
* N/A
Changes since v1:
* N/A
---
arch/x86/include/asm/hpet.h | 3 +++
arch/x86/kernel/hpet.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/arch/x86/include/asm/hpet.h b/arch/x86/include/asm/hpet.h
index df11c7d4af44..5bf675970d4b 100644
--- a/arch/x86/include/asm/hpet.h
+++ b/arch/x86/include/asm/hpet.h
@@ -149,6 +149,7 @@ extern void hardlockup_detector_hpet_stop(void);
extern void hardlockup_detector_hpet_enable(unsigned int cpu);
extern void hardlockup_detector_hpet_disable(unsigned int cpu);
extern void hardlockup_detector_switch_to_perf(void);
+extern bool is_hpet_irq_hardlockup_detector(struct irq_alloc_info *info);
#else
static inline int hardlockup_detector_hpet_init(void)
{ return -ENODEV; }
@@ -156,6 +157,8 @@ static inline void hardlockup_detector_hpet_stop(void) {}
static inline void hardlockup_detector_hpet_enable(unsigned int cpu) {}
static inline void hardlockup_detector_hpet_disable(unsigned int cpu) {}
static inline void hardlockup_detector_switch_to_perf(void) {}
+static inline bool is_hpet_irq_hardlockup_detector(struct irq_alloc_info *info)
+{ return false; }
#endif /* CONFIG_X86_HARDLOCKUP_DETECTOR_HPET */
#else /* CONFIG_HPET_TIMER */
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 5012590dc1b8..3e43e0f348b8 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -1479,6 +1479,39 @@ struct hpet_hld_data *hpet_hld_get_timer(void)
hld_data = NULL;
return NULL;
}
+
+/**
+ * is_hpet_irq_hardlockup_detector() - Identify the HPET hld interrupt info
+ * @info: Interrupt allocation info, with private HPET channel data
+ *
+ * The HPET hardlockup detector is special as it needs its interrupts delivered
+ * as NMI. However, for interrupt remapping we use the existing irq subsystem
+ * to configure and route the HPET interrupt. Unfortunately, there is not a
+ * IRQF_NMI flag for x86. Instead, identify whether the interrupt being
+ * allocated for the HPET channel belongs to the hardlockup detector.
+ *
+ * Returns: True if @info indicates that it belongs to the HPET hardlockup
+ * detector. False otherwise.
+ */
+bool is_hpet_irq_hardlockup_detector(struct irq_alloc_info *info)
+{
+ struct hpet_channel *hc;
+
+ if (!info)
+ return false;
+
+ if (info->type != X86_IRQ_ALLOC_TYPE_HPET)
+ return false;
+
+ hc = info->data;
+ if (!hc)
+ return false;
+
+ if (hc->mode == HPET_MODE_NMI_WATCHDOG)
+ return true;
+
+ return false;
+}
#endif /* CONFIG_X86_HARDLOCKUP_DETECTOR_HPET */
#endif
--
2.17.1
Powered by blists - more mailing lists