From patchwork Wed Jun 13 00:57:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Neri X-Patchwork-Id: 928554 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=sparclinux-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4157pc5ZjGz9s1R for ; Wed, 13 Jun 2018 11:05:28 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935146AbeFMBFI (ORCPT ); Tue, 12 Jun 2018 21:05:08 -0400 Received: from mga14.intel.com ([192.55.52.115]:64685 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933569AbeFMBBg (ORCPT ); Tue, 12 Jun 2018 21:01:36 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jun 2018 18:01:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,216,1526367600"; d="scan'208";a="47283481" Received: from voyager.sc.intel.com ([10.3.52.149]) by fmsmga008.fm.intel.com with ESMTP; 12 Jun 2018 18:01:32 -0700 From: Ricardo Neri To: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" Cc: Andi Kleen , Ashok Raj , Borislav Petkov , Tony Luck , "Ravi V. Shankar" , x86@kernel.org, sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Ricardo Neri , Jacob Pan , Clemens Ladisch , Arnd Bergmann , Philippe Ombredanne , Kate Stewart , "Rafael J. Wysocki" , iommu@lists.linux-foundation.org Subject: [RFC PATCH 09/23] x86/hpet: Reserve timer for the HPET hardlockup detector Date: Tue, 12 Jun 2018 17:57:29 -0700 Message-Id: <1528851463-21140-10-git-send-email-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528851463-21140-1-git-send-email-ricardo.neri-calderon@linux.intel.com> References: <1528851463-21140-1-git-send-email-ricardo.neri-calderon@linux.intel.com> Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org HPET timer 2 will be used to drive the HPET-based hardlockup detector. Reserve such timer to ensure it cannot be used by user space programs or clock events. When looking for MSI-capable timers for clock events, skip timer 2 if the HPET hardlockup detector is selected. Also, do not assign an IO APIC pin to timer 2 of the HPET. A subsequent changeset will handle the interrupt setup of the timer used for the hardlockup detector. Cc: Ashok Raj Cc: Andi Kleen Cc: Tony Luck Cc: Borislav Petkov Cc: Jacob Pan Cc: Clemens Ladisch Cc: Arnd Bergmann Cc: Philippe Ombredanne Cc: Kate Stewart Cc: "Rafael J. Wysocki" Cc: "Ravi V. Shankar" Cc: x86@kernel.org Cc: iommu@lists.linux-foundation.org Signed-off-by: Ricardo Neri --- arch/x86/include/asm/hpet.h | 3 +++ arch/x86/kernel/hpet.c | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/hpet.h b/arch/x86/include/asm/hpet.h index 9e0afde..3266796 100644 --- a/arch/x86/include/asm/hpet.h +++ b/arch/x86/include/asm/hpet.h @@ -61,6 +61,9 @@ */ #define HPET_MIN_PERIOD 100000UL +/* Timer used for the hardlockup detector */ +#define HPET_WD_TIMER_NR 2 + /* hpet memory map physical address */ extern unsigned long hpet_address; extern unsigned long force_hpet_address; diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c index 3fa1d3f..b03faee 100644 --- a/arch/x86/kernel/hpet.c +++ b/arch/x86/kernel/hpet.c @@ -185,7 +185,8 @@ do { \ /* * When the hpet driver (/dev/hpet) is enabled, we need to reserve - * timer 0 and timer 1 in case of RTC emulation. + * timer 0 and timer 1 in case of RTC emulation. Timer 2 is reserved in case + * the HPET-based hardlockup detector is used. */ #ifdef CONFIG_HPET @@ -195,7 +196,7 @@ static void hpet_reserve_platform_timers(unsigned int id) { struct hpet __iomem *hpet = hpet_virt_address; struct hpet_timer __iomem *timer = &hpet->hpet_timers[2]; - unsigned int nrtimers, i; + unsigned int nrtimers, i, start_timer; struct hpet_data hd; nrtimers = ((id & HPET_ID_NUMBER) >> HPET_ID_NUMBER_SHIFT) + 1; @@ -210,6 +211,13 @@ static void hpet_reserve_platform_timers(unsigned int id) hpet_reserve_timer(&hd, 1); #endif + if (IS_ENABLED(CONFIG_HARDLOCKUP_DETECTOR_HPET)) { + hpet_reserve_timer(&hd, HPET_WD_TIMER_NR); + start_timer = HPET_WD_TIMER_NR + 1; + } else { + start_timer = HPET_WD_TIMER_NR; + } + /* * NOTE that hd_irq[] reflects IOAPIC input pins (LEGACY_8254 * is wrong for i8259!) not the output IRQ. Many BIOS writers @@ -218,7 +226,7 @@ static void hpet_reserve_platform_timers(unsigned int id) hd.hd_irq[0] = HPET_LEGACY_8254; hd.hd_irq[1] = HPET_LEGACY_RTC; - for (i = 2; i < nrtimers; timer++, i++) { + for (i = start_timer; i < nrtimers; timer++, i++) { hd.hd_irq[i] = (readl(&timer->hpet_config) & Tn_INT_ROUTE_CNF_MASK) >> Tn_INT_ROUTE_CNF_SHIFT; } @@ -630,6 +638,11 @@ static void hpet_msi_capability_lookup(unsigned int start_timer) struct hpet_dev *hdev = &hpet_devs[num_timers_used]; unsigned int cfg = hpet_readl(HPET_Tn_CFG(i)); + /* Do not use timer reserved for the HPET watchdog. */ + if (IS_ENABLED(CONFIG_HARDLOCKUP_DETECTOR_HPET) && + i == HPET_WD_TIMER_NR) + continue; + /* Only consider HPET timer with MSI support */ if (!(cfg & HPET_TN_FSB_CAP)) continue;