Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3889647pxy; Tue, 4 May 2021 12:13:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEnhCoF39XKy4lIbZr1/RwFNtdnJ17gQnGiW6unQROrYdHIjeb+jpqG2wyAjOPEe9I8K3j X-Received: by 2002:a50:fe03:: with SMTP id f3mr27308372edt.92.1620155583347; Tue, 04 May 2021 12:13:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620155583; cv=none; d=google.com; s=arc-20160816; b=gIorrmGL16rMV35pZnejVB7dpapyPbWy9Ggil4EQoGfm/Hw6ik7QYOX/3qN00UjZqr X9KKsaHbQhwgZhB1j4gpBksxXwNtSlY6s44POIOEa2CAKA70hFFnIJCapC5cKdWu38+2 ssqkjayKhQt1Hoq6gNTbB4sPSfyG7Zp3Mn5mt9LV0EKoaM9NH04O3vC2+0ykhJXymMfa B/AhK4hPzygVuN/iCexh6x7d49G7LzP12RcJ6uH6UVEFW4p3Kf1ofmdqaUT9U8pJUQ57 IIdbUrHBulkh+gAGmgdRT9mRcTY5PEn61eVtq4Tyt5/6lfBmb6UUZFxYlDW8I82y5Hwg jFew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=Y9RG1c/mDosA6wRKM6ZfQTl39qakzTV5XBlKAcaHXLs=; b=u9yBevV7N0TooqZk9zlU83cNOsMsh3gmh3lwUxlFYkYR9jnKQoD5e/V/jv6ykDwgOK ERVL/02BvTDFJRZhhfwS2t0KC/dnCpOdoOmyjfbGHu6yLWz8c4ZCKnEOfAXjttEKgCI3 eF88DkVxqbPmg7HefvlXrM5px++BNoqJRVsBnYNwTTWttsAxKE42yPfRMEM2sz/aO3kx MX3vNO1KArPChtuzE7qys2NG9PIB/2TFva2dDQoBXTgJ/nle8JAOfBYez8c/bcKAbtPy vQh2cQdTep2XU3AnCMqPnj7h/u0QD3cFGW3Lx35zD7XdL0TcZPVqwGxy5S0BaC/k1LJm dSxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o13si12955733edi.135.2021.05.04.12.12.40; Tue, 04 May 2021 12:13:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232311AbhEDTMk (ORCPT + 99 others); Tue, 4 May 2021 15:12:40 -0400 Received: from mga03.intel.com ([134.134.136.65]:9835 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232102AbhEDTMg (ORCPT ); Tue, 4 May 2021 15:12:36 -0400 IronPort-SDR: 7PS1QenTxsZ1v/0mXxVbGTo92b6CKm4KihSgvQ7enDnfFSZbdtQY9usnsO3UYOhfwjwKge9aiz 9igBHPiYvNgg== X-IronPort-AV: E=McAfee;i="6200,9189,9974"; a="198115953" X-IronPort-AV: E=Sophos;i="5.82,272,1613462400"; d="scan'208";a="198115953" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2021 12:11:41 -0700 IronPort-SDR: 6p0FpG4JiRnHAfLETLhIKxYaKWvAVyMDeVKz4hGji4aYIx+Wuxg4wdIDMAHAR3BeEXff74BPna ld1YiEvKEaVg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,272,1613462400"; d="scan'208";a="396245282" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by fmsmga007.fm.intel.com with ESMTP; 04 May 2021 12:11:40 -0700 From: Ricardo Neri To: Joerg Roedel , Will Deacon Cc: woodhouse@vger.kernel.org, Jacob Pan , Lu Baolu , Stephane Eranian , Thomas Gleixner , Ingo Molnar , Borislav Petkov , iommu@lists.linux-foundation.org, x86@kernel.org, linux-kernel@vger.kernel.org, "Ravi V. Shankar" , Ricardo Neri , Ricardo Neri , Andi Kleen , David Woodhouse Subject: [RFC PATCH v5 2/7] x86/hpet: Introduce function to identify HPET hardlockup detector irq Date: Tue, 4 May 2021 12:10:44 -0700 Message-Id: <20210504191049.22661-3-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210504191049.22661-1-ricardo.neri-calderon@linux.intel.com> References: <20210504191049.22661-1-ricardo.neri-calderon@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Borislav Petkov Cc: David Woodhouse (supporter:INTEL IOMMU (VT-d)) Cc: "Ravi V. Shankar" Cc: Ingo Molnar Cc: Jacob Pan Cc: Lu Baolu (supporter:INTEL IOMMU (VT-d)) Cc: Stephane Eranian Cc: Thomas Gleixner Cc: iommu@lists.linux-foundation.org (open list:INTEL IOMMU (VT-d)) Cc: x86@kernel.org Reviewed-by: Ashok Raj Signed-off-by: Ricardo Neri --- 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