Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1946557img; Wed, 27 Feb 2019 08:06:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IbN52X89myhQKJHo3ulqkvdE9Vm6bpxMOF6z5jmWMZI2FcHQS4VxNIZ9NSecWPhiCTCMK0E X-Received: by 2002:a17:902:e60e:: with SMTP id cm14mr2896081plb.192.1551283612624; Wed, 27 Feb 2019 08:06:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551283612; cv=none; d=google.com; s=arc-20160816; b=QDi6lsUeL89LGaOJC7sjjSEcK3jl0RoRen+yFjizaWBrHRc1x23vSzkzOkiNywxa5E E1CEs81URIBvjKqyoAKQaJ3sjfSnmljIBuqatjkKbcSopLKpDlquZe3fxxWvRSfX+Mif cqn1M8xTNVmWY0jAeWGLoS6Eirg/voE1RB2xN5Juc8rlnB6xeQVPoYjGwNnlR66ayZ0C 5GD+6YDzbVOnvjEC4eO0okZ+nGoFRmxNW6CCxo1qRhlXE1xRlYCbo58aBJQMsvJ3tz9U 2ZKpAG4369Jvwawd0HnnwpILMotH/By1BQIyBuul/JLcM90G38P3phoDowd+s14C1EOQ hFtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=77wYER3kLP+lXLz9PvP1Y1ikAgnjZVFixrDmojUkjhw=; b=pOodRKPatY1Ym0zrjN/mDnTkIRt9jEN9FJsFag9H04dIalx4cUB/GLF7rQMZMYwdi5 CpDG5kToEIBPjh7QIXE9tZHnIGJpNH4CxxTzG5VR6WeQdzZyYTsQvMeoUinetB6cWOIC qx4MLuamn8/9c0xQyAvh/vbqjzZRwKslfvPeYziAjXIZCg+C8ZA3PGCO1D1uOXeKeOa9 WUp+orVrIN8L7OUKutFxI1mT8Y6ENINwTjUgLMYd5sc7EuiWaTWx3Im78cyQwB5UVltc +4yOc1aWNfD/xk/r5bpxfn8gWZGM7DnTQ6UpVXWea8w0czWwJk2M/m6Xht0CfmlRg1WP U7Hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id a89si15778259pla.362.2019.02.27.08.06.34; Wed, 27 Feb 2019 08:06:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1729643AbfB0QFs (ORCPT + 99 others); Wed, 27 Feb 2019 11:05:48 -0500 Received: from mga01.intel.com ([192.55.52.88]:6599 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729329AbfB0QFp (ORCPT ); Wed, 27 Feb 2019 11:05:45 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2019 08:05:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,420,1544515200"; d="scan'208";a="303011642" Received: from unknown (HELO luv-build.sc.intel.com) ([172.25.110.25]) by orsmga005.jf.intel.com with ESMTP; 27 Feb 2019 08:05:44 -0800 From: Ricardo Neri To: Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: Ashok Raj , Andi Kleen , Peter Zijlstra , "Ravi V. Shankar" , x86@kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , Ricardo Neri , "H. Peter Anvin" , Tony Luck , Clemens Ladisch , Arnd Bergmann , Philippe Ombredanne , Kate Stewart , "Rafael J. Wysocki" Subject: [RFC PATCH v2 04/14] x86/hpet: Reserve timer for the HPET hardlockup detector Date: Wed, 27 Feb 2019 08:05:08 -0800 Message-Id: <1551283518-18922-5-git-send-email-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551283518-18922-1-git-send-email-ricardo.neri-calderon@linux.intel.com> References: <1551283518-18922-1-git-send-email-ricardo.neri-calderon@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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. Cc: "H. Peter Anvin" Cc: Ashok Raj Cc: Andi Kleen Cc: Tony Luck Cc: Clemens Ladisch Cc: Arnd Bergmann Cc: Philippe Ombredanne Cc: Kate Stewart Cc: "Rafael J. Wysocki" Cc: "Ravi V. Shankar" Cc: x86@kernel.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 9e0afde47587..3266796f7b60 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 ee439d84e83b..e9e18bf7e65d 100644 --- a/arch/x86/kernel/hpet.c +++ b/arch/x86/kernel/hpet.c @@ -182,7 +182,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 @@ -192,7 +193,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; @@ -207,6 +208,13 @@ static void hpet_reserve_platform_timers(unsigned int id) hpet_reserve_timer(&hd, 1); #endif + if (IS_ENABLED(CONFIG_X86_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 @@ -215,7 +223,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; } @@ -627,6 +635,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_X86_HARDLOCKUP_DETECTOR_HPET) && + i == HPET_WD_TIMER_NR) + continue; + /* Only consider HPET timer with MSI support */ if (!(cfg & HPET_TN_FSB_CAP)) continue; -- 2.17.1