Re: [RFC PATCH 22/23] watchdog/hardlockup/hpet: Only enable the HPET watchdog via a boot parameter

2018-06-12 Thread Randy Dunlap
On 06/12/2018 05:57 PM, Ricardo Neri wrote: > diff --git a/Documentation/admin-guide/kernel-parameters.txt > b/Documentation/admin-guide/kernel-parameters.txt > index f2040d4..a8833c7 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters

Re: [RFC PATCH 16/23] watchdog/hardlockup: Add an HPET-based hardlockup detector

2018-06-12 Thread Randy Dunlap
Hi, On 06/12/2018 05:57 PM, Ricardo Neri wrote: > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > index c40c7b7..6e79833 100644 > --- a/lib/Kconfig.debug > +++ b/lib/Kconfig.debug > @@ -828,6 +828,16 @@ config HARDLOCKUP_DETECTOR_PERF > bool > select SOFTLOCKUP_DETECTOR > > +con

[RFC PATCH 20/23] watchdog/hardlockup/hpet: Rotate interrupt among all monitored CPUs

2018-06-12 Thread Ricardo Neri
In order to detect hardlockups in all the monitored CPUs, move the interrupt to the next monitored CPU when handling the NMI interrupt; wrap around when reaching the highest CPU in the mask. This rotation is achieved by setting the affinity mask to only contain the next CPU to monitor. In order to

[RFC PATCH 23/23] watchdog/hardlockup: Activate the HPET-based lockup detector

2018-06-12 Thread Ricardo Neri
Now that the implementation of the HPET-based hardlockup detector is complete, enable it. It will be used only if it can be initialized successfully. Otherwise, the perf-based detector will be used. Cc: Ashok Raj Cc: Andi Kleen Cc: Tony Luck Cc: Borislav Petkov Cc: Jacob Pan Cc: "Rafael J. Wy

[RFC PATCH 22/23] watchdog/hardlockup/hpet: Only enable the HPET watchdog via a boot parameter

2018-06-12 Thread Ricardo Neri
Keep the HPET-based hardlockup detector disabled unless explicitly enabled via a command line argument. If such parameter is not given, the hardlockup detector will fallback to use the perf-based implementation. The function hardlockup_panic_setup() is updated to return 0 in order to to allow __se

[RFC PATCH 21/23] watchdog/hardlockup/hpet: Adjust timer expiration on the number of monitored CPUs

2018-06-12 Thread Ricardo Neri
Each CPU should be monitored for hardlockups every watchdog_thresh seconds. Since all the CPUs in the system are monitored by the same timer and the timer interrupt is rotated among the monitored CPUs, the timer must expire every watchdog_thresh/N seconds; where N is the number of monitored CPUs.

[RFC PATCH 17/23] watchdog/hardlockup/hpet: Convert the timer's interrupt to NMI

2018-06-12 Thread Ricardo Neri
In order to detect hardlockups, it is necessary to have the ability to receive interrupts even when disabled: a non-maskable interrupt is required. Add the flag IRQF_DELIVER_AS_NMI to the arguments of request_irq() for this purpose. Note that the timer, when programmed to deliver interrupts via th

[RFC PATCH 19/23] watchdog/hardlockup: Make arch_touch_nmi_watchdog() to hpet-based implementation

2018-06-12 Thread Ricardo Neri
CPU architectures that have an NMI watchdog use arch_touch_nmi_watchdog() to briefly ignore the hardlockup detector. If the architecture does not have an NMI watchdog, one can be constructed using a source of non- maskable interrupts. In this case, arch_touch_nmi_watchdog() is common to any underly

[RFC PATCH 18/23] watchdog/hardlockup/hpet: Add the NMI watchdog operations

2018-06-12 Thread Ricardo Neri
Implement the start, stop and disable operations of the HPET-based NMI watchdog. Given that a single timer is used to monitor all the CPUs in the system, it is necessary to define a cpumask that keeps track of the CPUs that can be monitored. This cpumask is protected with a spin lock. As individua

[RFC PATCH 16/23] watchdog/hardlockup: Add an HPET-based hardlockup detector

2018-06-12 Thread Ricardo Neri
This is the initial implementation of a hardlockup detector driven by an HPET timer. This initial implementation includes functions to control the timer via its registers. It also requests such timer, installs a minimal interrupt handler and performs the initial configuration of the timer. The det

[RFC PATCH 14/23] watchdog/hardlockup: Decouple the hardlockup detector from perf

2018-06-12 Thread Ricardo Neri
The current default implementation of the hardlockup detector assumes that it is implemented using perf events. However, the hardlockup detector can be driven by other sources of non-maskable interrupts (e.g., a properly configured timer). Put in a separate file all the code that is specific to pe

[RFC PATCH 15/23] kernel/watchdog: Add a function to obtain the watchdog_allowed_mask

2018-06-12 Thread Ricardo Neri
Implementations of NMI watchdogs that use a single piece of hardware to monitor all the CPUs in the system (as opposed to per-CPU implementations such as perf) need to know which CPUs the watchdog is allowed to monitor. In this manner, non-maskable interrupts are directed only to the monitored CPUs

[RFC PATCH 11/23] x86/hpet: Configure the timer used by the hardlockup detector

2018-06-12 Thread Ricardo Neri
Implement the initial configuration of the timer to be used by the hardlockup detector. The main focus of this configuration is to provide an interrupt for the timer. Two types of interrupt can be assigned to the timer. First, attempt to assign a message-signaled interrupt. This implies creating t

[RFC PATCH 13/23] watchdog/hardlockup: Define a generic function to detect hardlockups

2018-06-12 Thread Ricardo Neri
The procedure to detect hardlockups is independent of the underlying mechanism that generated the non-maskable interrupt used to drive the detector. Thus, it can be put in a separate, generic function. In this manner, it can be invoked by various implementations of the NMI watchdog. For this purpo

[RFC PATCH 12/23] kernel/watchdog: Introduce a struct for NMI watchdog operations

2018-06-12 Thread Ricardo Neri
Instead of exposing individual functions for the operations of the NMI watchdog, define a common interface that can be used across multiple implementations. The struct nmi_watchdog_ops is defined for such operations. These initial definitions include the enable, disable, start, stop, and cleanup o

[RFC PATCH 10/23] x86/hpet: Relocate flag definitions to a header file

2018-06-12 Thread Ricardo Neri
Users of HPET timers (such as the hardlockup detector) need the definitions of these flags to interpret the configuration of a timer as passed by platform code. Cc: Ashok Raj Cc: Andi Kleen Cc: Tony Luck Cc: Borislav Petkov Cc: Jacob Pan Cc: Clemens Ladisch Cc: Arnd Bergmann Cc: Philippe Om

[RFC PATCH 09/23] x86/hpet: Reserve timer for the HPET hardlockup detector

2018-06-12 Thread Ricardo Neri
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 A

[RFC PATCH 08/23] x86/hpet: Calculate ticks-per-second in a separate function

2018-06-12 Thread Ricardo Neri
It is easier to compute the expiration times of an HPET timer by using its frequency (i.e., the number of times it ticks in a second) than its period, as given in the capabilities register. In addition to the HPET char driver, the HPET-based hardlockup detector will also need to know the timer's f

[RFC PATCH 07/23] x86/hpet: Expose more functions to read and write registers

2018-06-12 Thread Ricardo Neri
Some of the registers in the HPET hardware have a width of 64 bits. 64-bit access functions are needed mostly to read the counter and write the comparator in a single read or write. Also, 64-bit accesses can be used to to read parameters located in the higher bits of some registers (such as the tim

[RFC PATCH 03/23] genirq: Introduce IRQF_DELIVER_AS_NMI

2018-06-12 Thread Ricardo Neri
Certain interrupt controllers (such as APIC) are capable of delivering interrupts as non-maskable. Likewise, drivers or subsystems (e.g., the hardlockup detector) might be interested in requesting a non-maskable interrupt. The new flag IRQF_DELIVER_AS_NMI serves this purpose. When setting up an in

[RFC PATCH 06/23] x86/ioapic: Add support for IRQCHIP_CAN_DELIVER_AS_NMI with interrupt remapping

2018-06-12 Thread Ricardo Neri
Even though there is a delivery mode field at the entries of an IO APIC's redirection table, the documentation of the majority of the IO APICs explicitly states that interrupt delivery as non-maskable is not supported. Thus, However, when using an IO APIC in combination with the Intel VT-d interru

[RFC PATCH 05/23] x86/msi: Add support for IRQCHIP_CAN_DELIVER_AS_NMI

2018-06-12 Thread Ricardo Neri
As per the Intel 64 and IA-32 Architectures Software Developer's Manual Volume 3 Section 10.11.2, the delivery mode field of the interrupt message can be set to configure as non-maskable. Declare support to deliver non- maskable interrupts by adding IRQCHIP_CAN_DELIVER_AS_NMI. When composing the i

[RFC PATCH 04/23] iommu/vt-d/irq_remapping: Add support for IRQCHIP_CAN_DELIVER_AS_NMI

2018-06-12 Thread Ricardo Neri
The Intel IOMMU is capable of delivering remapped interrupts as non- maskable. Add the IRQCHIP_CAN_DELIVER_AS_NMI flag to its irq_chip structure to declare this capability. The delivery mode of each interrupt can be set separately. By default, the deliver mode is taken from the configuration field

[RFC PATCH 01/23] x86/apic: Add a parameter for the APIC delivery mode

2018-06-12 Thread Ricardo Neri
Until now, the delivery mode of APIC interrupts is set to the default mode set in the APIC driver. However, there are no restrictions in hardware to configure each interrupt with a different delivery mode. Specifying the delivery mode per interrupt is useful when one is interested in changing the d

[RFC PATCH 02/23] genirq: Introduce IRQD_DELIVER_AS_NMI

2018-06-12 Thread Ricardo Neri
Certain interrupt controllers (e.g., APIC) are capable of delivering interrupts to the CPU as non-maskable. Add the new IRQD_DELIVER_AS_NMI interrupt state flag. The purpose of this flag is to communicate to the underlying irqchip whether the interrupt must be delivered in this manner. Cc: Ashok R

[PATCH v9 2/2] iommu/amd: Add basic debugfs infrastructure for AMD IOMMU

2018-06-12 Thread Gary R Hook
Implement a skeleton framework for debugfs support in the AMD IOMMU. Add an AMD-specific Kconfig boolean that depends upon general enablement of DebugFS in the IOMMU. Signed-off-by: Gary R Hook --- drivers/iommu/Kconfig | 12 drivers/iommu/Makefile|1 +

[PATCH v9 1/2] iommu - Enable debugfs exposure of IOMMU driver internals

2018-06-12 Thread Gary R Hook
Provide base enablement for using debugfs to expose internal data of an IOMMU driver. When called, create the /sys/kernel/debug/iommu directory. Emit a strong warning at boot time to indicate that this feature is enabled. This function is called from iommu_init, and creates the initial DebugFS di

[PATCH v9 0/2] Base enablement of IOMMU debugfs support

2018-06-12 Thread Gary R Hook
These patches create a top-level function, called at IOMMU initialization, to create a debugfs directory for the IOMMU. Under this directory drivers may create and populate vendor-specific directories for their device internals. Patch 1: general IOMMU enablement Patch 2: basic AMD enablement to de

Re: [PATCH v8 2/2] iommu/amd: Add basic debugfs infrastructure for AMD IOMMU

2018-06-12 Thread Gary R Hook
On 06/04/2018 08:23 PM, Randy Dunlap wrote: On 05/29/2018 11:39 AM, Greg KH wrote: On Tue, May 29, 2018 at 01:23:23PM -0500, Gary R Hook wrote: Implement a skeleton framework for debugfs support in the AMD IOMMU. Add a hidden boolean to Kconfig that is defined for the AMD IOMMU when general IOM

Re: [PATCH v8 1/2] iommu - Enable debugfs exposure of IOMMU driver internals

2018-06-12 Thread Gary R Hook
On 06/05/2018 12:08 PM, Greg KH wrote: On Tue, Jun 05, 2018 at 12:01:41PM -0500, Gary R Hook wrote: +/** + * iommu_debugfs_new_driver_dir - create a vendor directory under debugfs/iommu + * @vendor: name of the vendor-specific subdirectory to create + * + * This function is called by an IOMMU dr

Re: [PATCH v8 2/2] iommu/amd: Add basic debugfs infrastructure for AMD IOMMU

2018-06-12 Thread Gary R Hook
On 06/05/2018 12:06 PM, Greg KH wrote: On Tue, Jun 05, 2018 at 11:58:13AM -0500, Gary R Hook wrote: On 05/29/2018 01:39 PM, Greg KH wrote: On Tue, May 29, 2018 at 01:23:23PM -0500, Gary R Hook wrote: Implement a skeleton framework for debugfs support in the AMD IOMMU. Add a hidden boolean to K

[PATCH RESEND] iommu/msm: Don't call iommu_device_{, un}link from atomic context

2018-06-12 Thread Niklas Cassel
Fixes the following splat during boot: BUG: sleeping function called from invalid context at kernel/locking/mutex.c:747 in_atomic(): 1, irqs_disabled(): 128, pid: 77, name: kworker/2:1 4 locks held by kworker/2:1/77: #0: (ptrval) ((wq_completion)"events"){+.+.}, at: process_one_work+0x1fc/0x8fc

Re: [PATCH v2 0/5] add non-strict mode support for arm-smmu-v3

2018-06-12 Thread Leizhen (ThunderTown)
On 2018/6/11 19:05, Jean-Philippe Brucker wrote: > Hi Zhen Lei, > > On 10/06/18 12:07, Zhen Lei wrote: >> v1 -> v2: >> Use the lowest bit of the io_pgtable_ops.unmap's iova parameter to pass the >> strict mode: >> 0, IOMMU_STRICT; >> 1, IOMMU_NON_STRICT; >> Treat 0 as IOMMU_STRICT, so that the